From 713e4b310b2d969c5aafe7b3ec2d421439b2bb0b Mon Sep 17 00:00:00 2001 From: Naomi Date: Thu, 24 Oct 2013 17:44:53 -0400 Subject: [PATCH] CC-5450 : Refactor Media Management (Classes/DB) in Airtime upgrading to propel 1.7 creating namespaces in Propel, using these namespaced models within the existing code. starting test new tables for a new media management system. --- .../configs/airtime-conf-production.php | 4 +- .../application/configs/airtime-conf.php | 6 +- .../configs/classmap-airtime-conf.php | 499 +- .../application/controllers/ApiController.php | 5 + .../controllers/AudiopreviewController.php | 2 + .../controllers/LibraryController.php | 2 + .../controllers/LoginController.php | 2 + .../controllers/ShowbuilderController.php | 3 + .../controllers/WebstreamController.php | 3 + airtime_mvc/application/forms/AddUser.php | 2 + airtime_mvc/application/forms/EditUser.php | 2 + airtime_mvc/application/forms/ShowBuilder.php | 2 + .../application/forms/SmartBlockCriteria.php | 4 + airtime_mvc/application/models/Auth.php | 4 + airtime_mvc/application/models/Block.php | 7 + airtime_mvc/application/models/MusicDir.php | 4 + airtime_mvc/application/models/Playlist.php | 13 + airtime_mvc/application/models/Preference.php | 2 + airtime_mvc/application/models/Schedule.php | 3 + airtime_mvc/application/models/Scheduler.php | 8 + .../application/models/ServiceRegister.php | 4 + airtime_mvc/application/models/Show.php | 6 + .../application/models/ShowBuilder.php | 3 + .../application/models/ShowInstance.php | 7 + airtime_mvc/application/models/StoredFile.php | 11 + .../application/models/StreamSetting.php | 3 + .../application/models/Systemstatus.php | 2 + airtime_mvc/application/models/User.php | 5 + airtime_mvc/application/models/Webstream.php | 4 + .../application/models/airtime/AudioFile.php | 21 + .../models/airtime/AudioFilePeer.php | 21 + .../models/airtime/AudioFileQuery.php | 21 + .../airtime/{CcAccess.php => Block.php} | 13 +- .../{CcAccessPeer.php => BlockPeer.php} | 13 +- .../{CcBackupQuery.php => BlockQuery.php} | 13 +- .../models/airtime/CcBackupPeer.php | 18 - .../application/models/airtime/CcBlock.php | 4 +- .../models/airtime/CcBlockPeer.php | 11 +- .../models/airtime/CcBlockQuery.php | 11 +- .../models/airtime/CcBlockcontents.php | 3 + .../models/airtime/CcBlockcontentsPeer.php | 11 +- .../models/airtime/CcBlockcontentsQuery.php | 11 +- .../models/airtime/CcBlockcriteria.php | 11 +- .../models/airtime/CcBlockcriteriaPeer.php | 11 +- .../models/airtime/CcBlockcriteriaQuery.php | 11 +- .../application/models/airtime/CcCountry.php | 11 +- .../models/airtime/CcCountryPeer.php | 11 +- .../models/airtime/CcCountryQuery.php | 11 +- .../application/models/airtime/CcFileTag.php | 18 - .../models/airtime/CcFileTagPeer.php | 18 - .../models/airtime/CcFileTagQuery.php | 18 - .../application/models/airtime/CcFiles.php | 4 + .../models/airtime/CcFilesPeer.php | 11 +- .../models/airtime/CcFilesQuery.php | 11 +- .../models/airtime/CcListenerCount.php | 11 +- .../models/airtime/CcListenerCountPeer.php | 11 +- .../models/airtime/CcListenerCountQuery.php | 11 +- .../application/models/airtime/CcLiveLog.php | 11 +- .../models/airtime/CcLiveLogPeer.php | 11 +- .../models/airtime/CcLiveLogQuery.php | 11 +- .../application/models/airtime/CcLocale.php | 11 +- .../models/airtime/CcLocalePeer.php | 11 +- .../models/airtime/CcLocaleQuery.php | 11 +- .../models/airtime/CcLoginAttempts.php | 11 +- .../models/airtime/CcLoginAttemptsPeer.php | 11 +- .../models/airtime/CcLoginAttemptsQuery.php | 11 +- .../models/airtime/CcMountName.php | 11 +- .../models/airtime/CcMountNamePeer.php | 11 +- .../models/airtime/CcMountNameQuery.php | 11 +- .../models/airtime/CcMusicDirs.php | 11 +- .../models/airtime/CcMusicDirsPeer.php | 11 +- .../models/airtime/CcMusicDirsQuery.php | 11 +- .../models/airtime/CcPermsPeer.php | 18 - .../models/airtime/CcPermsQuery.php | 18 - .../application/models/airtime/CcPlaylist.php | 4 +- .../models/airtime/CcPlaylistPeer.php | 11 +- .../models/airtime/CcPlaylistQuery.php | 11 +- .../models/airtime/CcPlaylistcontents.php | 4 + .../models/airtime/CcPlaylistcontentsPeer.php | 11 +- .../airtime/CcPlaylistcontentsQuery.php | 11 +- .../models/airtime/CcPlaylistcriteria.php | 18 - .../airtime/CcPlaylistcriteriaQuery.php | 18 - .../models/airtime/CcPlayoutHistory.php | 11 +- .../airtime/CcPlayoutHistoryMetaData.php | 3 + .../airtime/CcPlayoutHistoryMetaDataPeer.php | 11 +- .../airtime/CcPlayoutHistoryMetaDataQuery.php | 11 +- .../models/airtime/CcPlayoutHistoryPeer.php | 11 +- .../models/airtime/CcPlayoutHistoryQuery.php | 11 +- .../airtime/CcPlayoutHistoryTemplate.php | 11 +- .../airtime/CcPlayoutHistoryTemplateField.php | 11 +- .../CcPlayoutHistoryTemplateFieldPeer.php | 11 +- .../CcPlayoutHistoryTemplateFieldQuery.php | 11 +- .../airtime/CcPlayoutHistoryTemplatePeer.php | 11 +- .../airtime/CcPlayoutHistoryTemplateQuery.php | 11 +- .../application/models/airtime/CcPref.php | 11 +- .../application/models/airtime/CcPrefPeer.php | 11 +- .../models/airtime/CcPrefQuery.php | 11 +- .../application/models/airtime/CcSchedule.php | 4 +- .../models/airtime/CcSchedulePeer.php | 11 +- .../models/airtime/CcScheduleQuery.php | 11 +- .../models/airtime/CcServiceRegister.php | 11 +- .../models/airtime/CcServiceRegisterPeer.php | 11 +- .../models/airtime/CcServiceRegisterQuery.php | 11 +- .../application/models/airtime/CcSess.php | 18 - .../application/models/airtime/CcSessPeer.php | 18 - .../models/airtime/CcSessQuery.php | 18 - .../application/models/airtime/CcShow.php | 4 +- .../application/models/airtime/CcShowDays.php | 4 +- .../models/airtime/CcShowDaysPeer.php | 11 +- .../models/airtime/CcShowDaysQuery.php | 11 +- .../models/airtime/CcShowHosts.php | 11 +- .../models/airtime/CcShowHostsPeer.php | 11 +- .../models/airtime/CcShowHostsQuery.php | 11 +- .../models/airtime/CcShowInstances.php | 4 +- .../models/airtime/CcShowInstancesPeer.php | 11 +- .../models/airtime/CcShowInstancesQuery.php | 11 +- .../application/models/airtime/CcShowPeer.php | 11 +- .../models/airtime/CcShowQuery.php | 11 +- .../models/airtime/CcShowRebroadcast.php | 11 +- .../models/airtime/CcShowRebroadcastPeer.php | 11 +- .../models/airtime/CcShowRebroadcastQuery.php | 11 +- .../models/airtime/CcShowSchedule.php | 18 - .../models/airtime/CcShowSchedulePeer.php | 18 - .../models/airtime/CcShowScheduleQuery.php | 18 - .../application/models/airtime/CcSmemb.php | 18 - .../models/airtime/CcSmembPeer.php | 18 - .../models/airtime/CcSmembQuery.php | 18 - .../models/airtime/CcStreamSetting.php | 11 +- .../models/airtime/CcStreamSettingPeer.php | 11 +- .../models/airtime/CcStreamSettingQuery.php | 11 +- .../application/models/airtime/CcSubjs.php | 4 + .../models/airtime/CcSubjsPeer.php | 11 +- .../models/airtime/CcSubjsQuery.php | 11 +- .../models/airtime/CcSubjsToken.php | 11 +- .../models/airtime/CcSubjsTokenPeer.php | 11 +- .../models/airtime/CcSubjsTokenQuery.php | 11 +- .../application/models/airtime/CcTag.php | 18 - .../application/models/airtime/CcTagPeer.php | 18 - .../application/models/airtime/CcTagQuery.php | 18 - .../models/airtime/CcTimestamp.php | 11 +- .../models/airtime/CcTimestampPeer.php | 11 +- .../models/airtime/CcTimestampQuery.php | 11 +- .../application/models/airtime/CcTrans.php | 18 - .../models/airtime/CcTransPeer.php | 18 - .../models/airtime/CcTransQuery.php | 18 - .../models/airtime/CcWebstream.php | 11 +- .../models/airtime/CcWebstreamMetadata.php | 11 +- .../airtime/CcWebstreamMetadataPeer.php | 11 +- .../airtime/CcWebstreamMetadataQuery.php | 11 +- .../models/airtime/CcWebstreamPeer.php | 11 +- .../models/airtime/CcWebstreamQuery.php | 11 +- .../models/airtime/MediaContents.php | 21 + .../models/airtime/MediaContentsPeer.php | 21 + .../models/airtime/MediaContentsQuery.php | 21 + .../application/models/airtime/MediaItem.php | 21 + ...listcriteriaPeer.php => MediaItemPeer.php} | 13 +- .../{CcAccessQuery.php => MediaItemQuery.php} | 13 +- .../airtime/{CcPerms.php => Playlist.php} | 13 +- .../models/airtime/PlaylistPeer.php | 21 + .../models/airtime/PlaylistQuery.php | 21 + .../airtime/{CcBackup.php => Webstream.php} | 13 +- .../models/airtime/WebstreamPeer.php | 21 + .../models/airtime/WebstreamQuery.php | 21 + .../models/airtime/map/AudioFileTableMap.php | 123 + .../models/airtime/map/BlockTableMap.php | 93 + .../models/airtime/map/CcBlockTableMap.php | 119 +- .../airtime/map/CcBlockcontentsTableMap.php | 116 +- .../airtime/map/CcBlockcriteriaTableMap.php | 79 +- .../models/airtime/map/CcCountryTableMap.php | 67 +- .../models/airtime/map/CcFilesTableMap.php | 221 +- .../airtime/map/CcListenerCountTableMap.php | 77 +- .../models/airtime/map/CcLiveLogTableMap.php | 73 +- .../models/airtime/map/CcLocaleTableMap.php | 71 +- .../airtime/map/CcLoginAttemptsTableMap.php | 67 +- .../airtime/map/CcMountNameTableMap.php | 71 +- .../airtime/map/CcMusicDirsTableMap.php | 78 +- .../models/airtime/map/CcPermsTableMap.php | 75 +- .../models/airtime/map/CcPlaylistTableMap.php | 113 +- .../map/CcPlaylistcontentsTableMap.php | 124 +- .../map/CcPlayoutHistoryMetaDataTableMap.php | 75 +- .../airtime/map/CcPlayoutHistoryTableMap.php | 81 +- .../CcPlayoutHistoryTemplateFieldTableMap.php | 81 +- .../map/CcPlayoutHistoryTemplateTableMap.php | 73 +- .../models/airtime/map/CcPrefTableMap.php | 75 +- .../models/airtime/map/CcScheduleTableMap.php | 103 +- .../airtime/map/CcServiceRegisterTableMap.php | 67 +- .../models/airtime/map/CcSessTableMap.php | 73 +- .../models/airtime/map/CcShowDaysTableMap.php | 89 +- .../airtime/map/CcShowHostsTableMap.php | 75 +- .../airtime/map/CcShowInstancesTableMap.php | 101 +- .../airtime/map/CcShowRebroadcastTableMap.php | 75 +- .../models/airtime/map/CcShowTableMap.php | 99 +- .../models/airtime/map/CcSmembTableMap.php | 73 +- .../airtime/map/CcStreamSettingTableMap.php | 69 +- .../models/airtime/map/CcSubjsTableMap.php | 112 +- .../airtime/map/CcSubjsTokenTableMap.php | 77 +- .../airtime/map/CcTimestampTableMap.php | 71 +- .../map/CcWebstreamMetadataTableMap.php | 75 +- .../airtime/map/CcWebstreamTableMap.php | 87 +- .../airtime/map/MediaContentsTableMap.php | 66 + .../models/airtime/map/MediaItemTableMap.php | 92 + .../models/airtime/map/PlaylistTableMap.php | 95 + .../models/airtime/map/WebstreamTableMap.php | 92 + .../models/airtime/om/BaseAudioFile.php | 3588 +++++ .../models/airtime/om/BaseAudioFilePeer.php | 1945 +++ .../models/airtime/om/BaseAudioFileQuery.php | 2074 +++ .../models/airtime/om/BaseBlock.php | 1769 +++ .../models/airtime/om/BaseBlockPeer.php | 1791 +++ .../models/airtime/om/BaseBlockQuery.php | 970 ++ .../models/airtime/om/BaseCcAccess.php | 1236 -- .../models/airtime/om/BaseCcAccessPeer.php | 1008 -- .../models/airtime/om/BaseCcAccessQuery.php | 477 - .../models/airtime/om/BaseCcBackup.php | 956 -- .../models/airtime/om/BaseCcBackupPeer.php | 750 - .../models/airtime/om/BaseCcBackupQuery.php | 292 - .../models/airtime/om/BaseCcBlock.php | 4133 +++--- .../models/airtime/om/BaseCcBlockPeer.php | 2036 +-- .../models/airtime/om/BaseCcBlockQuery.php | 1431 +- .../models/airtime/om/BaseCcBlockcontents.php | 3076 ++-- .../airtime/om/BaseCcBlockcontentsPeer.php | 2816 ++-- .../airtime/om/BaseCcBlockcontentsQuery.php | 1500 +- .../models/airtime/om/BaseCcBlockcriteria.php | 2160 +-- .../airtime/om/BaseCcBlockcriteriaPeer.php | 1995 +-- .../airtime/om/BaseCcBlockcriteriaQuery.php | 854 +- .../models/airtime/om/BaseCcCountry.php | 1516 +- .../models/airtime/om/BaseCcCountryPeer.php | 1474 +- .../models/airtime/om/BaseCcCountryQuery.php | 451 +- .../models/airtime/om/BaseCcFileTag.php | 936 -- .../models/airtime/om/BaseCcFileTagPeer.php | 1365 -- .../models/airtime/om/BaseCcFileTagQuery.php | 371 - .../models/airtime/om/BaseCcFiles.php | 12288 +++++++++------- .../models/airtime/om/BaseCcFilesPeer.php | 3901 ++--- .../models/airtime/om/BaseCcFilesQuery.php | 5985 ++++---- .../models/airtime/om/BaseCcListenerCount.php | 2118 +-- .../airtime/om/BaseCcListenerCountPeer.php | 2756 ++-- .../airtime/om/BaseCcListenerCountQuery.php | 927 +- .../models/airtime/om/BaseCcLiveLog.php | 1904 +-- .../models/airtime/om/BaseCcLiveLogPeer.php | 1502 +- .../models/airtime/om/BaseCcLiveLogQuery.php | 619 +- .../models/airtime/om/BaseCcLocale.php | 1642 ++- .../models/airtime/om/BaseCcLocalePeer.php | 1492 +- .../models/airtime/om/BaseCcLocaleQuery.php | 516 +- .../models/airtime/om/BaseCcLoginAttempts.php | 1570 +- .../airtime/om/BaseCcLoginAttemptsPeer.php | 1474 +- .../airtime/om/BaseCcLoginAttemptsQuery.php | 473 +- .../models/airtime/om/BaseCcMountName.php | 2057 +-- .../models/airtime/om/BaseCcMountNamePeer.php | 1489 +- .../airtime/om/BaseCcMountNameQuery.php | 600 +- .../models/airtime/om/BaseCcMusicDirs.php | 2840 ++-- .../models/airtime/om/BaseCcMusicDirsPeer.php | 1512 +- .../airtime/om/BaseCcMusicDirsQuery.php | 836 +- .../models/airtime/om/BaseCcPerms.php | 945 -- .../models/airtime/om/BaseCcPermsPeer.php | 984 -- .../models/airtime/om/BaseCcPermsQuery.php | 355 - .../models/airtime/om/BaseCcPlaylist.php | 3105 ++-- .../models/airtime/om/BaseCcPlaylistPeer.php | 2012 +-- .../models/airtime/om/BaseCcPlaylistQuery.php | 1096 +- .../airtime/om/BaseCcPlaylistcontents.php | 3566 ++--- .../airtime/om/BaseCcPlaylistcontentsPeer.php | 3531 ++--- .../om/BaseCcPlaylistcontentsQuery.php | 1880 ++- .../airtime/om/BaseCcPlayoutHistory.php | 2834 ++-- .../om/BaseCcPlayoutHistoryMetaData.php | 1952 +-- .../om/BaseCcPlayoutHistoryMetaDataPeer.php | 1975 +-- .../om/BaseCcPlayoutHistoryMetaDataQuery.php | 740 +- .../airtime/om/BaseCcPlayoutHistoryPeer.php | 2773 ++-- .../airtime/om/BaseCcPlayoutHistoryQuery.php | 1147 +- .../om/BaseCcPlayoutHistoryTemplate.php | 2111 +-- .../om/BaseCcPlayoutHistoryTemplateField.php | 2326 +-- .../BaseCcPlayoutHistoryTemplateFieldPeer.php | 2005 +-- ...BaseCcPlayoutHistoryTemplateFieldQuery.php | 926 +- .../om/BaseCcPlayoutHistoryTemplatePeer.php | 1499 +- .../om/BaseCcPlayoutHistoryTemplateQuery.php | 657 +- .../models/airtime/om/BaseCcPref.php | 1952 +-- .../models/airtime/om/BaseCcPrefPeer.php | 1975 +-- .../models/airtime/om/BaseCcPrefQuery.php | 740 +- .../models/airtime/om/BaseCcSchedule.php | 4336 +++--- .../models/airtime/om/BaseCcSchedulePeer.php | 3556 ++--- .../models/airtime/om/BaseCcScheduleQuery.php | 1987 +-- .../airtime/om/BaseCcServiceRegister.php | 1516 +- .../airtime/om/BaseCcServiceRegisterPeer.php | 1474 +- .../airtime/om/BaseCcServiceRegisterQuery.php | 451 +- .../models/airtime/om/BaseCcSess.php | 949 -- .../models/airtime/om/BaseCcSessPeer.php | 979 -- .../models/airtime/om/BaseCcSessQuery.php | 334 - .../models/airtime/om/BaseCcShow.php | 4752 +++--- .../models/airtime/om/BaseCcShowDays.php | 3048 ++-- .../models/airtime/om/BaseCcShowDaysPeer.php | 2045 +-- .../models/airtime/om/BaseCcShowDaysQuery.php | 1297 +- .../models/airtime/om/BaseCcShowHosts.php | 2014 +-- .../models/airtime/om/BaseCcShowHostsPeer.php | 2746 ++-- .../airtime/om/BaseCcShowHostsQuery.php | 848 +- .../models/airtime/om/BaseCcShowInstances.php | 5091 ++++--- .../airtime/om/BaseCcShowInstancesPeer.php | 3156 ++-- .../airtime/om/BaseCcShowInstancesQuery.php | 2070 +-- .../models/airtime/om/BaseCcShowPeer.php | 1620 +- .../models/airtime/om/BaseCcShowQuery.php | 1616 +- .../airtime/om/BaseCcShowRebroadcast.php | 2032 +-- .../airtime/om/BaseCcShowRebroadcastPeer.php | 1975 +-- .../airtime/om/BaseCcShowRebroadcastQuery.php | 763 +- .../models/airtime/om/BaseCcShowSchedule.php | 905 -- .../airtime/om/BaseCcShowSchedulePeer.php | 983 -- .../airtime/om/BaseCcShowScheduleQuery.php | 338 - .../models/airtime/om/BaseCcSmemb.php | 891 -- .../models/airtime/om/BaseCcSmembPeer.php | 750 - .../models/airtime/om/BaseCcSmembQuery.php | 305 - .../models/airtime/om/BaseCcStreamSetting.php | 1620 +- .../airtime/om/BaseCcStreamSettingPeer.php | 1484 +- .../airtime/om/BaseCcStreamSettingQuery.php | 508 +- .../models/airtime/om/BaseCcSubjs.php | 8037 ++++++---- .../models/airtime/om/BaseCcSubjsPeer.php | 1633 +- .../models/airtime/om/BaseCcSubjsQuery.php | 2643 ++-- .../models/airtime/om/BaseCcSubjsToken.php | 2136 +-- .../airtime/om/BaseCcSubjsTokenPeer.php | 1985 +-- .../airtime/om/BaseCcSubjsTokenQuery.php | 820 +- .../models/airtime/om/BaseCcTag.php | 1306 -- .../models/airtime/om/BaseCcTagPeer.php | 753 - .../models/airtime/om/BaseCcTagQuery.php | 421 - .../models/airtime/om/BaseCcTimestamp.php | 2137 +-- .../models/airtime/om/BaseCcTimestampPeer.php | 1489 +- .../airtime/om/BaseCcTimestampQuery.php | 623 +- .../models/airtime/om/BaseCcTrans.php | 1903 --- .../models/airtime/om/BaseCcTransPeer.php | 849 -- .../models/airtime/om/BaseCcTransQuery.php | 826 -- .../models/airtime/om/BaseCcWebstream.php | 3229 ++-- .../airtime/om/BaseCcWebstreamMetadata.php | 2032 +-- .../om/BaseCcWebstreamMetadataPeer.php | 1975 +-- .../om/BaseCcWebstreamMetadataQuery.php | 763 +- .../models/airtime/om/BaseCcWebstreamPeer.php | 1569 +- .../airtime/om/BaseCcWebstreamQuery.php | 1147 +- .../models/airtime/om/BaseMediaContents.php | 1462 ++ .../airtime/om/BaseMediaContentsPeer.php | 1047 ++ .../airtime/om/BaseMediaContentsQuery.php | 705 + .../models/airtime/om/BaseMediaItem.php | 2160 +++ .../models/airtime/om/BaseMediaItemPeer.php | 1074 ++ .../models/airtime/om/BaseMediaItemQuery.php | 1199 ++ .../models/airtime/om/BasePlaylist.php | 1792 +++ .../models/airtime/om/BasePlaylistPeer.php | 1447 ++ .../models/airtime/om/BasePlaylistQuery.php | 966 ++ .../models/airtime/om/BaseWebstream.php | 1733 +++ .../models/airtime/om/BaseWebstreamPeer.php | 1448 ++ .../models/airtime/om/BaseWebstreamQuery.php | 920 ++ .../application/services/CalendarService.php | 2 + .../application/services/HistoryService.php | 13 + .../application/services/SchedulerService.php | 8 + .../application/services/ShowFormService.php | 4 + .../application/services/ShowService.php | 15 + .../application/services/UserService.php | 2 + airtime_mvc/build/build.properties | 2 +- airtime_mvc/build/schema.xml | 154 +- airtime_mvc/build/sql/schema.sql | 1354 +- airtime_mvc/library/propel/CHANGELOG | 867 +- airtime_mvc/library/propel/INSTALL | 2 +- airtime_mvc/library/propel/LICENSE | 5 +- airtime_mvc/library/propel/README.md | 26 + airtime_mvc/library/propel/WHATS_NEW | 807 - airtime_mvc/library/propel/composer.json | 35 + .../propel/contrib/dbd2propel/dbd2propel.xsl | 381 - .../propel/contrib/dbd2propel/transform.php | 21 - .../library/propel/contrib/pat/patForms.php | 2784 ---- .../pat/patForms/Creator/Definition.php | 42 - .../contrib/pat/patForms/Creator/Propel.php | 132 - .../patForms/Creator/_propel_creator_test.php | 201 - .../pat/patForms/Datasource/Propel.php | 70 - .../contrib/pat/patForms/Definition.php | 122 - .../pat/patForms/Definition/Propel.php | 165 - .../propel/contrib/pat/patForms/Element.php | 1954 --- .../propel/contrib/pat/patForms/Rule.php | 340 - .../contrib/pat/patForms/Rule/Match.php | 163 - .../contrib/pat/patForms/Rule/MaxLength.php | 161 - .../contrib/pat/patForms/Rule/MaxValue.php | 163 - .../contrib/pat/patForms/Rule/MinLength.php | 161 - .../contrib/pat/patForms/Rule/MinValue.php | 165 - .../contrib/pat/patForms/Rule/NotMatch.php | 163 - .../contrib/pat/patForms/Rule/ValidValues.php | 182 - .../contrib/pat/patForms/Storage/Propel.php | 146 - .../contrib/pat/patForms/res/form.dynamic.tpl | 94 - .../pat/patForms/res/mysql-dump.bookstore.sql | 10 - .../pat/patForms_Storage_Propel_test.php | 97 - .../propel/contrib/pat/patTemplate.php | 2378 --- .../pear/HTML_QuickForm_Propel/Propel.php | 909 -- .../Structures_DataGrid_Propel/Propel.php | 352 - .../propel/docs/behavior/aggregate_column.txt | 130 - .../behavior/alternative_coding_standards.txt | 89 - .../propel/docs/behavior/auto_add_pk.txt | 73 - .../propel/docs/behavior/nested_set.txt | 370 - .../propel/docs/behavior/query_cache.txt | 103 - .../propel/docs/behavior/sluggable.txt | 135 - .../propel/docs/behavior/soft_delete.txt | 116 - .../library/propel/docs/behavior/sortable.txt | 285 - .../propel/docs/behavior/timestampable.txt | 92 - airtime_mvc/library/propel/docs/build.xml | 34 - .../propel/docs/cookbook/Add-Custom-SQL.txt | 34 - .../propel/docs/cookbook/Copying-Objects.txt | 47 - .../docs/cookbook/Customizing-Build.txt | 153 - .../docs/cookbook/Existing-Database.txt | 95 - .../propel/docs/cookbook/LOB-Columns.txt | 73 - .../propel/docs/cookbook/Master-Slave.txt | 94 - .../propel/docs/cookbook/Multi-Component.txt | 297 - .../propel/docs/cookbook/Namespaces.txt | 133 - .../propel/docs/cookbook/Nested-Set.txt | 183 - .../docs/cookbook/Runtime-Introspection.txt | 164 - .../propel/docs/cookbook/Writing-Behavior.txt | 424 - .../propel/docs/guide/01-Installation.txt | 164 - .../propel/docs/guide/02-BuildTime.txt | 350 - .../propel/docs/guide/03-Basic-CRUD.txt | 319 - .../propel/docs/guide/04-Relationships.txt | 386 - .../propel/docs/guide/05-Validators.txt | 253 - .../propel/docs/guide/06-Transactions.txt | 291 - .../propel/docs/guide/07-Behaviors.txt | 280 - .../library/propel/docs/guide/08-Logging.txt | 448 - .../propel/docs/guide/09-Inheritance.txt | 329 - .../reference/Buildtime-Configuration.txt | 312 - .../propel/docs/reference/ModelCriteria.txt | 1025 -- .../docs/reference/Runtime-Configuration.txt | 318 - .../library/propel/docs/reference/Schema.txt | 398 - .../library/propel/generator/bin/phing.php | 65 + .../library/propel/generator/bin/propel-gen | 95 +- .../propel/generator/bin/propel-gen.bat | 32 + .../library/propel/generator/build-propel.xml | 1078 +- .../propel/generator/build.properties-sample | 75 +- .../library/propel/generator/build.xml | 344 +- .../library/propel/generator/build.xml-local | 32 +- .../propel/generator/default.properties | 83 +- .../AlternativeCodingStandardsBehavior.php | 180 +- .../lib/behavior/AutoAddPkBehavior.php | 71 +- .../lib/behavior/DelegateBehavior.php | 126 + .../lib/behavior/SoftDeleteBehavior.php | 547 +- .../lib/behavior/TimestampableBehavior.php | 251 +- .../AggregateColumnBehavior.php | 227 +- .../AggregateColumnRelationBehavior.php | 277 +- .../templates/objectCompute.php | 11 +- .../templates/objectPostSave.php | 6 + .../templates/objectUpdate.php | 6 +- .../templates/objectUpdateRelated.php | 16 +- .../templates/queryFindRelated.php | 22 +- .../templates/queryUpdateRelated.php | 8 +- .../archivable/ArchivableBehavior.php | 201 + ...rchivableBehaviorObjectBuilderModifier.php | 252 + ...ArchivableBehaviorQueryBuilderModifier.php | 152 + .../archivable/templates/objectArchive.php | 29 + .../templates/objectDeleteWithoutArchive.php | 14 + .../archivable/templates/objectGetArchive.php | 19 + .../templates/objectPopulateFromArchive.php | 33 + .../archivable/templates/objectPreDelete.php | 17 + .../templates/objectRestoreFromArchive.php | 20 + .../templates/objectSaveWithoutArchive.php | 28 + .../archivable/templates/queryArchive.php | 43 + .../templates/queryDeleteWithoutArchive.php | 28 + .../templates/querySetArchiveOnDelete.php | 10 + .../templates/querySetArchiveOnUpdate.php | 10 + .../templates/queryUpdateWithoutArchive.php | 16 + .../ConcreteInheritanceBehavior.php | 407 +- .../ConcreteInheritanceParentBehavior.php | 108 +- .../lib/behavior/i18n/I18nBehavior.php | 282 + .../I18nBehaviorObjectBuilderModifier.php | 212 + .../i18n/I18nBehaviorPeerBuilderModifier.php | 37 + .../i18n/I18nBehaviorQueryBuilderModifier.php | 77 + .../i18n/templates/objectAttributes.php | 12 + .../i18n/templates/objectClearReferences.php | 2 + .../templates/objectGetCurrentTranslation.php | 12 + .../i18n/templates/objectGetLocale.php | 10 + .../i18n/templates/objectGetLocaleAlias.php | 11 + .../i18n/templates/objectGetTranslation.php | 35 + .../i18n/templates/objectPostDelete.php | 5 + .../templates/objectRemoveTranslation.php | 28 + .../i18n/templates/objectSetLocale.php | 14 + .../i18n/templates/objectSetLocaleAlias.php | 13 + .../i18n/templates/objectSetTranslation.php | 17 + .../objectTranslatedColumnGetter.php | 6 + .../objectTranslatedColumnSetter.php | 7 + .../behavior/i18n/templates/queryJoinI18n.php | 18 + .../i18n/templates/queryJoinWithI18n.php | 19 + .../i18n/templates/queryUseI18nQuery.php | 18 + .../behavior/nestedset/NestedSetBehavior.php | 149 +- ...NestedSetBehaviorObjectBuilderModifier.php | 1841 +-- .../NestedSetBehaviorPeerBuilderModifier.php | 807 +- .../NestedSetBehaviorQueryBuilderModifier.php | 434 +- .../query_cache/QueryCacheBehavior.php | 432 +- .../behavior/sluggable/SluggableBehavior.php | 535 +- .../behavior/sortable/SortableBehavior.php | 247 +- .../SortableBehaviorObjectBuilderModifier.php | 940 +- .../SortableBehaviorPeerBuilderModifier.php | 537 +- .../SortableBehaviorQueryBuilderModifier.php | 484 +- .../sortable/SortableRelationBehavior.php | 90 + .../versionable/VersionableBehavior.php | 289 + ...rsionableBehaviorObjectBuilderModifier.php | 798 + ...VersionableBehaviorPeerBuilderModifier.php | 79 + ...ersionableBehaviorQueryBuilderModifier.php | 123 + .../lib/builder/DataModelBuilder.php | 1143 +- .../generator/lib/builder/om/ClassTools.php | 212 +- .../lib/builder/om/ExtensionQueryBuilder.php | 197 +- .../om/ExtensionQueryInheritanceBuilder.php | 186 +- .../generator/lib/builder/om/OMBuilder.php | 1065 +- .../lib/builder/om/ObjectBuilder.php | 325 +- .../builder/om/PHP5ExtensionNodeBuilder.php | 122 +- .../om/PHP5ExtensionNodePeerBuilder.php | 122 +- .../builder/om/PHP5ExtensionObjectBuilder.php | 178 +- .../builder/om/PHP5ExtensionPeerBuilder.php | 181 +- .../lib/builder/om/PHP5InterfaceBuilder.php | 119 +- .../om/PHP5MultiExtendObjectBuilder.php | 288 +- .../lib/builder/om/PHP5NestedSetBuilder.php | 1944 +-- .../builder/om/PHP5NestedSetPeerBuilder.php | 2916 ++-- .../lib/builder/om/PHP5NodeBuilder.php | 1781 ++- .../lib/builder/om/PHP5NodePeerBuilder.php | 1184 +- .../lib/builder/om/PHP5ObjectBuilder.php | 10072 +++++++------ .../om/PHP5ObjectNoCollectionBuilder.php | 1661 ++- .../lib/builder/om/PHP5PeerBuilder.php | 5489 +++---- .../lib/builder/om/PHP5TableMapBuilder.php | 620 +- .../generator/lib/builder/om/PeerBuilder.php | 530 +- .../generator/lib/builder/om/QueryBuilder.php | 2473 ++-- .../builder/om/QueryInheritanceBuilder.php | 503 +- .../generator/lib/builder/sql/DDLBuilder.php | 166 - .../lib/builder/sql/DataSQLBuilder.php | 430 +- .../lib/builder/sql/mssql/MssqlDDLBuilder.php | 173 - .../builder/sql/mssql/MssqlDataSQLBuilder.php | 29 +- .../lib/builder/sql/mysql/MysqlDDLBuilder.php | 413 - .../builder/sql/oracle/OracleDDLBuilder.php | 185 - .../lib/builder/sql/pgsql/PgsqlDDLBuilder.php | 304 - .../builder/sql/pgsql/PgsqlDataSQLBuilder.php | 147 +- .../builder/sql/sqlite/SqliteDDLBuilder.php | 119 - .../sql/sqlite/SqliteDataSQLBuilder.php | 28 +- .../sql/sqlsrv/SqlsrvDataSQLBuilder.php | 22 + .../builder/util/DefaultEnglishPluralizer.php | 27 +- .../generator/lib/builder/util/Pluralizer.php | 17 +- .../lib/builder/util/PropelStringReader.php | 133 +- .../lib/builder/util/PropelTemplate.php | 146 +- .../util/StandardEnglishPluralizer.php | 152 + .../lib/builder/util/XmlToAppData.php | 793 +- .../lib/builder/util/XmlToDataSQL.php | 391 +- .../generator/lib/config/GeneratorConfig.php | 489 +- .../lib/config/GeneratorConfigInterface.php | 59 + .../lib/config/QuickGeneratorConfig.php | 194 + .../lib/exception/EngineException.php | 6 +- .../lib/exception/SchemaException.php | 19 + .../propel/generator/lib/model/AppData.php | 487 +- .../propel/generator/lib/model/Behavior.php | 494 +- .../propel/generator/lib/model/Column.php | 2517 ++-- .../lib/model/ColumnDefaultValue.php | 145 +- .../lib/model/ConstraintNameGenerator.php | 85 +- .../propel/generator/lib/model/Database.php | 1261 +- .../propel/generator/lib/model/Domain.php | 652 +- .../propel/generator/lib/model/ForeignKey.php | 1177 +- .../propel/generator/lib/model/IDMethod.php | 23 +- .../generator/lib/model/IdMethodParameter.php | 155 +- .../propel/generator/lib/model/Index.php | 523 +- .../generator/lib/model/Inheritance.php | 233 +- .../generator/lib/model/NameFactory.php | 105 +- .../generator/lib/model/NameGenerator.php | 95 +- .../generator/lib/model/PhpNameGenerator.php | 284 +- .../generator/lib/model/PropelTypes.php | 652 +- .../propel/generator/lib/model/Rule.php | 321 +- .../generator/lib/model/ScopedElement.php | 148 + .../propel/generator/lib/model/Table.php | 3621 +++-- .../propel/generator/lib/model/Unique.php | 52 +- .../propel/generator/lib/model/Validator.php | 303 +- .../propel/generator/lib/model/VendorInfo.php | 291 +- .../propel/generator/lib/model/XMLElement.php | 348 +- .../lib/model/diff/PropelColumnComparator.php | 100 + .../lib/model/diff/PropelColumnDiff.php | 120 + .../model/diff/PropelDatabaseComparator.php | 158 + .../lib/model/diff/PropelDatabaseDiff.php | 317 + .../model/diff/PropelForeignKeyComparator.php | 91 + .../lib/model/diff/PropelIndexComparator.php | 59 + .../lib/model/diff/PropelTableComparator.php | 312 + .../lib/model/diff/PropelTableDiff.php | 724 + .../lib/platform/DefaultPlatform.php | 1486 +- .../generator/lib/platform/MssqlPlatform.php | 236 +- .../generator/lib/platform/MysqlPlatform.php | 842 +- .../generator/lib/platform/OraclePlatform.php | 454 +- .../generator/lib/platform/PgsqlPlatform.php | 568 +- .../generator/lib/platform/Platform.php | 182 - .../lib/platform/PropelPlatformInterface.php | 250 + .../generator/lib/platform/SqlitePlatform.php | 205 +- .../generator/lib/platform/SqlsrvPlatform.php | 29 + .../lib/reverse/BaseSchemaParser.php | 359 +- .../generator/lib/reverse/SchemaParser.php | 80 +- .../lib/reverse/mssql/MssqlSchemaParser.php | 399 +- .../lib/reverse/mysql/MysqlSchemaParser.php | 648 +- .../lib/reverse/oracle/OracleSchemaParser.php | 473 +- .../lib/reverse/pgsql/PgsqlSchemaParser.php | 1081 +- .../lib/reverse/sqlite/SqliteSchemaParser.php | 302 +- .../lib/reverse/sqlsrv/SqlsrvSchemaParser.php | 22 + .../lib/task/AbstractPropelDataModelTask.php | 1043 +- .../generator/lib/task/AbstractPropelTask.php | 17 + .../lib/task/BasePropelMigrationTask.php | 110 + .../lib/task/PropelConvertConfTask.php | 618 +- .../generator/lib/task/PropelDataDTDTask.php | 68 - .../generator/lib/task/PropelDataDumpTask.php | 568 +- .../lib/task/PropelDataModelTemplateTask.php | 217 - .../generator/lib/task/PropelDataSQLTask.php | 281 +- .../generator/lib/task/PropelGraphvizTask.php | 221 +- .../lib/task/PropelMigrationDownTask.php | 108 + .../lib/task/PropelMigrationStatusTask.php | 102 + .../lib/task/PropelMigrationTask.php | 107 + .../lib/task/PropelMigrationUpTask.php | 107 + .../generator/lib/task/PropelOMTask.php | 382 +- .../generator/lib/task/PropelSQLDiffTask.php | 191 + .../generator/lib/task/PropelSQLExec.php | 1022 +- .../generator/lib/task/PropelSQLTask.php | 410 +- .../lib/task/PropelSchemaReverseTask.php | 1045 +- .../generator/lib/task/PropelSqlBuildTask.php | 33 + .../generator/lib/util/PropelDotGenerator.php | 65 + .../lib/util/PropelMigrationManager.php | 368 + .../generator/lib/util/PropelPHPParser.php | 222 + .../generator/lib/util/PropelQuickBuilder.php | 243 + .../generator/lib/util/PropelSQLParser.php | 285 + .../lib/util/PropelSchemaValidator.php | 111 + .../generator/lib/util/PropelSqlManager.php | 294 + .../pear/BuildPropelGenPEARPackageTask.php | 363 +- .../generator/pear/build-pear-package.xml | 240 +- .../propel/generator/pear/build.properties | 3 - .../propel/generator/pear/pear-build.xml | 227 +- .../propel/generator/pear/pear-propel-gen | 0 .../propel/generator/pear/pear-propel-gen.bat | 2 +- .../generator/resources/dtd/database.dtd | 314 +- .../resources/xsd/custom_datatypes.xsd | 10 +- .../generator/resources/xsd/database.xsd | 1748 ++- .../generator/resources/xsl/database.xsl | 526 +- .../generator/resources/xsl/dbd2propel.xsl | 406 + .../propel/generator/stubs/functions.php | 10 + airtime_mvc/library/propel/phpunit.xml.dist | 27 + .../library/propel/runtime/lib/Propel.php | 1798 +-- .../propel/runtime/lib/adapter/DBAdapter.php | 788 +- .../propel/runtime/lib/adapter/DBMSSQL.php | 456 +- .../propel/runtime/lib/adapter/DBMySQL.php | 370 +- .../propel/runtime/lib/adapter/DBNone.php | 163 +- .../propel/runtime/lib/adapter/DBOracle.php | 385 +- .../propel/runtime/lib/adapter/DBPostgres.php | 329 +- .../propel/runtime/lib/adapter/DBSQLSRV.php | 115 + .../propel/runtime/lib/adapter/DBSQLite.php | 194 +- .../lib/adapter/MSSQL/MssqlDateTime.class.php | 35 - .../lib/adapter/MSSQL/MssqlDebugPDO.php | 2 +- .../lib/adapter/MSSQL/MssqlPropelPDO.php | 243 +- .../lib/collection/PropelArrayCollection.php | 352 +- .../lib/collection/PropelCollection.php | 980 +- .../lib/collection/PropelObjectCollection.php | 524 +- .../collection/PropelOnDemandCollection.php | 313 +- .../lib/collection/PropelOnDemandIterator.php | 216 +- .../lib/config/PropelConfiguration.php | 282 +- .../config/PropelConfigurationIterator.php | 146 +- .../runtime/lib/connection/DebugPDO.php | 69 +- .../lib/connection/DebugPDOStatement.php | 228 +- .../runtime/lib/connection/PropelPDO.php | 1406 +- .../runtime/lib/exception/PropelException.php | 81 +- .../runtime/lib/formatter/ModelWith.php | 296 +- .../lib/formatter/PropelArrayFormatter.php | 293 +- .../runtime/lib/formatter/PropelFormatter.php | 359 +- .../lib/formatter/PropelObjectFormatter.php | 223 +- .../lib/formatter/PropelOnDemandFormatter.php | 162 +- .../formatter/PropelSimpleArrayFormatter.php | 80 + .../formatter/PropelStatementFormatter.php | 47 +- .../propel/runtime/lib/logger/BasicLogger.php | 111 +- .../runtime/lib/logger/MojaviLogAdapter.php | 249 +- .../propel/runtime/lib/map/ColumnMap.php | 914 +- .../propel/runtime/lib/map/DatabaseMap.php | 317 +- .../propel/runtime/lib/map/RelationMap.php | 542 +- .../propel/runtime/lib/map/TableMap.php | 1452 +- .../propel/runtime/lib/map/ValidatorMap.php | 110 +- .../propel/runtime/lib/om/BaseObject.php | 684 +- .../lib/om/NestedSetRecursiveIterator.php | 117 +- .../propel/runtime/lib/om/NodeObject.php | 568 +- .../propel/runtime/lib/om/Persistent.php | 160 +- .../runtime/lib/om/PreOrderNodeIterator.php | 92 +- .../runtime/lib/parser/PropelCSVParser.php | 314 + .../runtime/lib/parser/PropelJSONParser.php | 67 + .../runtime/lib/parser/PropelParser.php | 108 + .../runtime/lib/parser/PropelXMLParser.php | 211 + .../runtime/lib/parser/PropelYAMLParser.php | 71 + .../propel/runtime/lib/parser/yaml/LICENSE | 19 + .../propel/runtime/lib/parser/yaml/sfYaml.php | 129 + .../runtime/lib/parser/yaml/sfYamlDumper.php | 56 + .../runtime/lib/parser/yaml/sfYamlInline.php | 405 + .../runtime/lib/parser/yaml/sfYamlParser.php | 512 + .../propel/runtime/lib/query/Criteria.php | 3353 +++-- .../propel/runtime/lib/query/Criterion.php | 1006 +- .../runtime/lib/query/CriterionIterator.php | 59 +- .../library/propel/runtime/lib/query/Join.php | 754 +- .../runtime/lib/query/ModelCriteria.php | 4055 ++--- .../runtime/lib/query/ModelCriterion.php | 555 +- .../propel/runtime/lib/query/ModelJoin.php | 288 +- .../propel/runtime/lib/query/PropelQuery.php | 37 +- .../propel/runtime/lib/util/BasePeer.php | 1938 ++- .../propel/runtime/lib/util/NodePeer.php | 656 +- .../runtime/lib/util/PropelAutoloader.php | 174 +- .../runtime/lib/util/PropelColumnTypes.php | 135 +- .../lib/util/PropelConditionalProxy.php | 141 +- .../runtime/lib/util/PropelDateTime.php | 142 +- .../runtime/lib/util/PropelModelPager.php | 655 +- .../propel/runtime/lib/util/PropelPager.php | 944 +- .../runtime/lib/validator/BasicValidator.php | 22 +- .../runtime/lib/validator/MatchValidator.php | 55 +- .../lib/validator/MaxLengthValidator.php | 19 +- .../lib/validator/MaxValueValidator.php | 28 +- .../lib/validator/MinLengthValidator.php | 24 +- .../lib/validator/MinValueValidator.php | 28 +- .../lib/validator/NotMatchValidator.php | 57 +- .../lib/validator/RequiredValidator.php | 22 +- .../runtime/lib/validator/TypeValidator.php | 92 +- .../runtime/lib/validator/UniqueValidator.php | 36 +- .../lib/validator/ValidValuesValidator.php | 19 +- .../lib/validator/ValidationFailed.php | 168 +- .../pear/BuildPropelPEARPackageTask.php | 308 +- .../runtime/pear/build-pear-package.xml | 182 +- .../propel/runtime/stubs/functions.php | 10 + airtime_mvc/library/propel/test/README | 139 - .../propel/test/bookstore-packaged-test.php | 811 - airtime_mvc/library/propel/test/bootstrap.php | 7 + .../library/propel/test/etc/lob/tin_drum.gif | Bin 8202 -> 8199 bytes .../test/etc/schema/tabletest-schema.xml | 25 - .../propel/test/etc/xsl/coverage-frames.xsl | 1140 +- .../library/propel/test/etc/xsl/log.xsl | 22 +- ...nit2-noframes.xsl => phpunit-noframes.xsl} | 56 +- .../test/etc/xsl/str.replace.function.xsl | 2 +- .../bookstore-packaged/build.properties | 12 +- .../bookstore-packaged/runtime-conf.xml | 14 +- .../bookstore/behavior-add-class-schema.xml | 10 + .../bookstore/behavior-auto-add-pk-schema.xml | 4 +- ...concrete-inheritance-one-to-one-schema.xml | 25 + .../behavior-concrete-inheritance-schema.xml | 21 +- .../bookstore/behavior-nested-set-schema.xml | 2 +- .../fixtures/bookstore/behavior-schema.xml | 2 +- .../bookstore/behavior-sluggable-schema.xml | 21 + .../bookstore/behavior-soft-delete-schema.xml | 2 +- .../bookstore/behavior-sortable-schema.xml | 42 + .../test/fixtures/bookstore/build.properties | 20 +- .../test/fixtures/bookstore/runtime-conf.xml | 51 +- .../propel/test/fixtures/bookstore/schema.xml | 117 +- .../fixtures/generator/behavior/Foobar.php | 10 + .../test/fixtures/generator/config/Foobar.php | 8 + .../generator/config/FoobarWithNS.php | 10 + .../test/fixtures/namespaced/build.properties | 14 +- .../test/fixtures/namespaced/runtime-conf.xml | 41 +- .../test/fixtures/namespaced/schema.xml | 12 + .../test/fixtures/nestedset/build.properties | 10 +- .../test/fixtures/nestedset/runtime-conf.xml | 16 +- .../fixtures/reverse/mysql/build.properties | 25 + .../reverse/mysql/build/sql/schema.sql | 19 + .../reverse/mysql/build/sql/sqldb.map | 1 + .../fixtures/reverse/mysql/runtime-conf.xml | 37 + .../fixtures/reverse/pgsql/runtime-conf.xml | 37 + .../test/fixtures/schemas/build.properties | 19 + .../test/fixtures/schemas/runtime-conf.xml | 37 + .../propel/test/fixtures/schemas/schema.xml | 108 + .../test/fixtures/treetest/build.properties | 8 +- .../test/fixtures/treetest/runtime-conf.xml | 18 +- .../fixtures/unique-column/column-schema.xml | 9 - .../fixtures/unique-column/table-schema.xml | 13 - .../library/propel/test/reset_tests.sh | 50 + airtime_mvc/library/propel/test/speed.php | 401 - airtime_mvc/library/propel/test/test.xml | 14 +- .../behavior/AddClassBehaviorTest.php | 26 + ...AlternativeCodingStandardsBehaviorTest.php | 64 + .../behavior/AutoAddPkBehaviorTest.php | 101 +- .../behavior/DelegateBehaviorTest.php | 270 + .../behavior/NamespacedBehaviorTest.php | 32 + .../generator/behavior/ObjectBehaviorTest.php | 38 +- .../generator/behavior/PeerBehaviorTest.php | 8 +- .../behavior/SoftDeleteBehaviorTest.php | 722 +- .../generator/behavior/TableBehaviorTest.php | 16 +- .../behavior/TimestampableBehaviorTest.php | 414 +- .../AggregateColumnBehaviorTest.php | 524 +- .../AggregateColumnBehaviorWithSchemaTest.php | 82 + ...ableAndConcreteInheritanceBehaviorTest.php | 65 + ...vableBehaviorObjectBuilderModifierTest.php | 454 + ...ivableBehaviorQueryBuilderModifierTest.php | 281 + .../archivable/ArchivableBehaviorTest.php | 196 + ...creteInheritanceBehaviorNamespacedTest.php | 41 + .../ConcreteInheritanceBehaviorTest.php | 489 +- ...creteInheritanceBehaviorWithSchemaTest.php | 39 + ...eInheritanceExcludedParentBehaviorTest.php | 39 + .../ConcreteInheritanceParentBehaviorTest.php | 64 +- .../I18nBehaviorObjectBuilderModifierTest.php | 410 + .../I18nBehaviorPeerBuilderModifierTest.php | 65 + .../I18nBehaviorQueryBuilderModifierTest.php | 273 + .../behavior/i18n/I18nBehaviorTest.php | 428 + ...edSetBehaviorObjectBuilderModifierTest.php | 2802 ++-- ...viorObjectBuilderModifierWithScopeTest.php | 1311 +- ...stedSetBehaviorPeerBuilderModifierTest.php | 659 +- ...haviorPeerBuilderModifierWithScopeTest.php | 460 +- ...tedSetBehaviorQueryBuilderModifierTest.php | 514 +- ...aviorQueryBuilderModifierWithScopeTest.php | 539 +- .../nestedset/NestedSetBehaviorTest.php | 135 +- .../NestedSetBehaviorWithNamespaceTest.php | 59 + .../sluggable/SluggableBehaviorTest.php | 700 +- ...tableBehaviorObjectBuilderModifierTest.php | 481 +- ...viorObjectBuilderModifierWithScopeTest.php | 870 +- ...ortableBehaviorPeerBuilderModifierTest.php | 123 +- ...haviorPeerBuilderModifierWithScopeTest.php | 192 +- ...rtableBehaviorQueryBuilderModifierTest.php | 180 +- ...aviorQueryBuilderModifierWithScopeTest.php | 236 +- .../sortable/SortableBehaviorTest.php | 58 +- ...nableBehaviorObjectBuilderModifierTest.php | 1021 ++ ...ionableBehaviorPeerBuilderModifierTest.php | 51 + .../versionable/VersionableBehaviorTest.php | 467 + .../generator/builder/NamespaceTest.php | 476 +- .../om/GeneratedNestedSetObjectTest.php | 273 +- .../builder/om/GeneratedNestedSetPeerTest.php | 274 +- .../builder/om/GeneratedNestedSetTest.php | 148 +- .../om/GeneratedObjectArrayColumnTypeTest.php | 237 + .../GeneratedObjectBooleanColumnTypeTest.php | 86 + .../GeneratedObjectDateTimeColumnTypeTest.php | 51 + .../om/GeneratedObjectEnumColumnTypeTest.php | 144 + .../om/GeneratedObjectLazyLoadTest.php | 96 + .../builder/om/GeneratedObjectLobTest.php | 394 +- .../om/GeneratedObjectMoreRelationTest.php | 236 + .../GeneratedObjectObjectColumnTypeTest.php | 84 + .../builder/om/GeneratedObjectPhpNameTest.php | 83 + .../builder/om/GeneratedObjectRelTest.php | 1200 +- .../GeneratedObjectTemporalColumnTypeTest.php | 125 + .../builder/om/GeneratedObjectTest.php | 2986 ++-- .../om/GeneratedObjectWithFixturesTest.php | 369 + .../om/GeneratedObjectWithInterfaceTest.php | 46 + .../builder/om/GeneratedPeerDoDeleteTest.php | 1010 +- .../builder/om/GeneratedPeerDoSelectTest.php | 698 +- .../om/GeneratedPeerEnumColumnTypeTest.php | 94 + .../builder/om/GeneratedPeerLazyLoadTest.php | 107 + .../builder/om/GeneratedPeerTest.php | 129 +- .../om/GeneratedQueryArrayColumnTypeTest.php | 226 + .../om/GeneratedQueryEnumColumnTypeTest.php | 92 + .../om/GeneratedQueryObjectColumnTypeTest.php | 94 + .../builder/om/OMBuilderNamespaceTest.php | 246 +- .../builder/om/OMBuilderRelatedByTest.php | 83 + .../generator/builder/om/OMBuilderTest.php | 166 +- .../builder/om/PHP5ObjectBuilderTest.php | 77 + .../builder/om/PHP5TableMapBuilderTest.php | 66 +- .../om/QueryBuilderInheritanceTest.php | 229 +- .../generator/builder/om/QueryBuilderTest.php | 1988 +-- ...ComplexColumnTypeEntityWithConstructor.php | 13 + .../util/DefaultEnglishPluralizerTest.php | 45 + .../builder/util/PropelTemplateTest.php | 69 +- .../util/StandardEnglishPluralizerTest.php | 102 + .../builder/util/XmlToAppDataTest.php | 150 + .../generator/builder/util/innerSchema.xml | 6 + .../generator/builder/util/outerSchema.xml | 7 + .../generator/builder/util/template.php | 2 +- .../generator/builder/util/testSchema.xml | 6 + .../generator/config/GeneratorConfigTest.php | 68 + .../generator/model/BehaviorTest.php | 161 +- .../model/ColumnDefaultValueTest.php | 43 + .../testsuite/generator/model/ColumnTest.php | 262 +- .../generator/model/DatabaseTest.php | 146 + .../generator/model/NameFactoryTest.php | 220 +- .../generator/model/PhpNameGeneratorTest.php | 90 +- .../testsuite/generator/model/TableTest.php | 612 +- .../generator/model/XMLElementTest.php | 56 + .../model/diff/PropelColumnComparatorTest.php | 190 + .../PropelDatabaseTableComparatorTest.php | 402 + .../diff/PropelForeignKeyComparatorTest.php | 165 + .../model/diff/PropelIndexComparatorTest.php | 91 + .../diff/PropelTableColumnComparatorTest.php | 229 + .../PropelTableForeignKeyComparatorTest.php | 172 + .../diff/PropelTableIndexComparatorTest.php | 196 + .../PropelTablePkColumnComparatorTest.php | 186 + .../platform/DefaultPlatformTest.php | 103 +- .../generator/platform/MssqlPlatformTest.php | 640 + .../MysqlPlatformMigrationMyISAMTest.php | 262 + .../platform/MysqlPlatformMigrationTest.php | 288 + .../platform/MysqlPlatformMyISAMTest.php | 696 + .../generator/platform/MysqlPlatformTest.php | 756 + .../platform/OraclePlatformMigrationTest.php | 454 + .../generator/platform/OraclePlatformTest.php | 589 + .../platform/PgsqlPlatformMigrationTest.php | 394 + .../generator/platform/PgsqlPlatformTest.php | 727 + .../PlatformMigrationTestProvider.php | 571 + .../generator/platform/PlatformTestBase.php | 48 +- .../platform/PlatformTestProvider.php | 321 + .../generator/platform/SqlitePlatformTest.php | 379 +- .../reverse/mssql/MssqlSchemaParserTest.php | 69 + .../reverse/mysql/MysqlSchemaParserTest.php | 100 + .../reverse/pgsql/PgsqlSchemaParserTest.php | 106 + .../generator/util/PropelDotGeneratorTest.php | 197 + .../generator/util/PropelPHPParserTest.php | 272 + .../generator/util/PropelQuickBuilderTest.php | 140 + .../generator/util/PropelSQLParserTest.php | 228 + .../util/PropelSchemaValidatorTest.php | 185 + .../test/testsuite/misc/BookstoreTest.php | 1698 +-- .../testsuite/misc/CharacterEncodingTest.php | 132 +- .../testsuite/misc/FieldnameRelatedTest.php | 688 +- .../test/testsuite/misc/Issue617Test.php | 226 + .../test/testsuite/misc/Issue651Test.php | 128 + .../testsuite/misc/PoisonedCacheBugTest.php | 170 + .../test/testsuite/misc/Ticket520Test.php | 363 +- .../runtime/adapter/DBAdapterTest.php | 125 + .../runtime/adapter/DBAdapterTestAbstract.php | 23 + .../testsuite/runtime/adapter/DBMSSQLTest.php | 43 + .../testsuite/runtime/adapter/DBMySQLTest.php | 115 + .../runtime/adapter/DBOracleTest.php | 95 +- .../runtime/adapter/DBPostgresTest.php | 37 + .../collection/PropelArrayCollectionTest.php | 302 +- .../PropelCollectionConvertTest.php | 238 + .../collection/PropelCollectionTest.php | 729 +- .../collection/PropelObjectCollectionTest.php | 467 +- ...PropelObjectCollectionWithFixturesTest.php | 233 + .../PropelOnDemandCollectionTest.php | 131 +- .../collection/PropelOnDemandIteratorTest.php | 74 +- .../config/PropelConfigurationTest.php | 205 + .../runtime/connection/PropelPDOTest.php | 976 +- .../runtime/exception/PropelExceptionTest.php | 69 + .../formatter/PropelArrayFormatterTest.php | 193 +- .../PropelArrayFormatterWithTest.php | 779 +- .../runtime/formatter/PropelFormatterTest.php | 65 + .../PropelObjectFormatterInheritanceTest.php | 66 +- .../formatter/PropelObjectFormatterTest.php | 261 +- .../PropelObjectFormatterWithTest.php | 939 +- .../formatter/PropelOnDemandFormatterTest.php | 261 +- .../PropelOnDemandFormatterWithTest.php | 540 +- .../PropelSimpleArrayFormatterTest.php | 72 + .../PropelStatementFormatterTest.php | 190 +- .../testsuite/runtime/map/ColumnMapTest.php | 251 +- .../testsuite/runtime/map/DatabaseMapTest.php | 153 +- .../runtime/map/GeneratedRelationMapTest.php | 106 +- .../GeneratedRelationMapWithSchemasTest.php | 73 + .../runtime/map/RelatedMapSymmetricalTest.php | 86 +- .../RelatedMapSymmetricalWithSchemasTest.php | 72 + .../testsuite/runtime/map/RelationMapTest.php | 18 +- .../testsuite/runtime/map/TableMapTest.php | 195 +- .../runtime/om/BaseObjectConvertTest.php | 233 + .../runtime/om/BaseObjectHashCodeTest.php | 100 + .../runtime/om/BaseObjectSerializeTest.php | 152 +- .../testsuite/runtime/om/BaseObjectTest.php | 87 +- .../runtime/parser/PropelCSVParserTest.php | 114 + .../runtime/parser/PropelJSONParserTest.php | 106 + .../runtime/parser/PropelParserTest.php | 64 + .../runtime/parser/PropelXMLParserTest.php | 198 + .../runtime/parser/PropelYAMLParserTest.php | 173 + .../runtime/parser/fixtures/test_data.xml | 6 + .../runtime/query/CriteriaCombineTest.php | 123 +- .../query/CriteriaFluidConditionTest.php | 453 +- .../query/CriteriaFluidOperatorTest.php | 119 + .../runtime/query/CriteriaMergeTest.php | 773 +- .../testsuite/runtime/query/CriteriaTest.php | 2133 +-- .../runtime/query/ExplainPlanTest.php | 86 + .../test/testsuite/runtime/query/JoinTest.php | 98 +- .../runtime/query/ModelCriteriaHooksTest.php | 294 +- .../runtime/query/ModelCriteriaSelectTest.php | 469 + .../runtime/query/ModelCriteriaTest.php | 4714 +++--- .../query/ModelCriteriaWithNamespaceTest.php | 66 + .../query/ModelCriteriaWithSchemaTest.php | 74 + .../testsuite/runtime/query/ModelJoinTest.php | 119 +- .../testsuite/runtime/query/ModelWithTest.php | 361 +- .../runtime/query/PropelQueryTest.php | 164 +- .../testsuite/runtime/query/SubQueryTest.php | 246 + .../runtime/util/BasePeerExceptionsTest.php | 140 +- .../testsuite/runtime/util/BasePeerTest.php | 647 +- .../util/PropelConditionalProxyTest.php | 112 + .../runtime/util/PropelConfigurationTest.php | 69 - .../runtime/util/PropelDateTimeTest.php | 252 +- .../runtime/util/PropelModelPagerTest.php | 349 +- .../runtime/util/PropelPagerTest.php | 29 +- .../runtime/validator/ValidatorTest.php | 293 +- .../test/tools/helpers/BaseTestCase.php | 15 +- .../test/tools/helpers/DummyPlatforms.php | 11 + .../helpers/PlatformDatabaseBuildTimeBase.php | 98 + .../bookstore/BookstoreDataPopulator.php | 452 +- .../bookstore/BookstoreEmptyTestBase.php | 29 +- .../helpers/bookstore/BookstoreTestBase.php | 58 +- .../bookstore/behavior/AddClassBehavior.php | 16 + .../behavior/AddClassBehaviorBuilder.php | 60 + .../behavior/BookstoreNestedSetTestBase.php | 255 +- .../behavior/BookstoreSortableTestBase.php | 272 +- .../bookstore/behavior/DonothingBehavior.php | 4 +- .../helpers/bookstore/behavior/TestAuthor.php | 133 +- .../behavior/Testallhooksbehavior.php | 103 +- .../bookstore/validator/ISBNValidator.php | 18 +- .../tools/helpers/cms/CmsDataPopulator.php | 246 +- .../test/tools/helpers/cms/CmsTestBase.php | 52 +- .../helpers/namespaces/NamespacesTestBase.php | 34 + .../tools/helpers/schemas/SchemasTestBase.php | 34 + .../propel/test/tools/phing/DefineTask.php | 75 +- airtime_mvc/library/propel/test/tree-test.php | 426 - 970 files changed, 260386 insertions(+), 207015 deletions(-) create mode 100644 airtime_mvc/application/models/airtime/AudioFile.php create mode 100644 airtime_mvc/application/models/airtime/AudioFilePeer.php create mode 100644 airtime_mvc/application/models/airtime/AudioFileQuery.php rename airtime_mvc/application/models/airtime/{CcAccess.php => Block.php} (60%) rename airtime_mvc/application/models/airtime/{CcAccessPeer.php => BlockPeer.php} (70%) rename airtime_mvc/application/models/airtime/{CcBackupQuery.php => BlockQuery.php} (69%) delete mode 100644 airtime_mvc/application/models/airtime/CcBackupPeer.php delete mode 100644 airtime_mvc/application/models/airtime/CcFileTag.php delete mode 100644 airtime_mvc/application/models/airtime/CcFileTagPeer.php delete mode 100644 airtime_mvc/application/models/airtime/CcFileTagQuery.php delete mode 100644 airtime_mvc/application/models/airtime/CcPermsPeer.php delete mode 100644 airtime_mvc/application/models/airtime/CcPermsQuery.php delete mode 100644 airtime_mvc/application/models/airtime/CcPlaylistcriteria.php delete mode 100644 airtime_mvc/application/models/airtime/CcPlaylistcriteriaQuery.php delete mode 100644 airtime_mvc/application/models/airtime/CcSess.php delete mode 100644 airtime_mvc/application/models/airtime/CcSessPeer.php delete mode 100644 airtime_mvc/application/models/airtime/CcSessQuery.php delete mode 100644 airtime_mvc/application/models/airtime/CcShowSchedule.php delete mode 100644 airtime_mvc/application/models/airtime/CcShowSchedulePeer.php delete mode 100644 airtime_mvc/application/models/airtime/CcShowScheduleQuery.php delete mode 100644 airtime_mvc/application/models/airtime/CcSmemb.php delete mode 100644 airtime_mvc/application/models/airtime/CcSmembPeer.php delete mode 100644 airtime_mvc/application/models/airtime/CcSmembQuery.php delete mode 100644 airtime_mvc/application/models/airtime/CcTag.php delete mode 100644 airtime_mvc/application/models/airtime/CcTagPeer.php delete mode 100644 airtime_mvc/application/models/airtime/CcTagQuery.php delete mode 100644 airtime_mvc/application/models/airtime/CcTrans.php delete mode 100644 airtime_mvc/application/models/airtime/CcTransPeer.php delete mode 100644 airtime_mvc/application/models/airtime/CcTransQuery.php create mode 100644 airtime_mvc/application/models/airtime/MediaContents.php create mode 100644 airtime_mvc/application/models/airtime/MediaContentsPeer.php create mode 100644 airtime_mvc/application/models/airtime/MediaContentsQuery.php create mode 100644 airtime_mvc/application/models/airtime/MediaItem.php rename airtime_mvc/application/models/airtime/{CcPlaylistcriteriaPeer.php => MediaItemPeer.php} (71%) rename airtime_mvc/application/models/airtime/{CcAccessQuery.php => MediaItemQuery.php} (70%) rename airtime_mvc/application/models/airtime/{CcPerms.php => Playlist.php} (60%) create mode 100644 airtime_mvc/application/models/airtime/PlaylistPeer.php create mode 100644 airtime_mvc/application/models/airtime/PlaylistQuery.php rename airtime_mvc/application/models/airtime/{CcBackup.php => Webstream.php} (60%) create mode 100644 airtime_mvc/application/models/airtime/WebstreamPeer.php create mode 100644 airtime_mvc/application/models/airtime/WebstreamQuery.php create mode 100644 airtime_mvc/application/models/airtime/map/AudioFileTableMap.php create mode 100644 airtime_mvc/application/models/airtime/map/BlockTableMap.php create mode 100644 airtime_mvc/application/models/airtime/map/MediaContentsTableMap.php create mode 100644 airtime_mvc/application/models/airtime/map/MediaItemTableMap.php create mode 100644 airtime_mvc/application/models/airtime/map/PlaylistTableMap.php create mode 100644 airtime_mvc/application/models/airtime/map/WebstreamTableMap.php create mode 100644 airtime_mvc/application/models/airtime/om/BaseAudioFile.php create mode 100644 airtime_mvc/application/models/airtime/om/BaseAudioFilePeer.php create mode 100644 airtime_mvc/application/models/airtime/om/BaseAudioFileQuery.php create mode 100644 airtime_mvc/application/models/airtime/om/BaseBlock.php create mode 100644 airtime_mvc/application/models/airtime/om/BaseBlockPeer.php create mode 100644 airtime_mvc/application/models/airtime/om/BaseBlockQuery.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcAccess.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcAccessPeer.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcAccessQuery.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcBackup.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcBackupPeer.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcBackupQuery.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcFileTag.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcFileTagPeer.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcFileTagQuery.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcPerms.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcPermsPeer.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcPermsQuery.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcSess.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcSessPeer.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcSessQuery.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcShowSchedule.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcShowSchedulePeer.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcShowScheduleQuery.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcSmemb.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcSmembPeer.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcSmembQuery.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcTag.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcTagPeer.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcTagQuery.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcTrans.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcTransPeer.php delete mode 100644 airtime_mvc/application/models/airtime/om/BaseCcTransQuery.php create mode 100644 airtime_mvc/application/models/airtime/om/BaseMediaContents.php create mode 100644 airtime_mvc/application/models/airtime/om/BaseMediaContentsPeer.php create mode 100644 airtime_mvc/application/models/airtime/om/BaseMediaContentsQuery.php create mode 100644 airtime_mvc/application/models/airtime/om/BaseMediaItem.php create mode 100644 airtime_mvc/application/models/airtime/om/BaseMediaItemPeer.php create mode 100644 airtime_mvc/application/models/airtime/om/BaseMediaItemQuery.php create mode 100644 airtime_mvc/application/models/airtime/om/BasePlaylist.php create mode 100644 airtime_mvc/application/models/airtime/om/BasePlaylistPeer.php create mode 100644 airtime_mvc/application/models/airtime/om/BasePlaylistQuery.php create mode 100644 airtime_mvc/application/models/airtime/om/BaseWebstream.php create mode 100644 airtime_mvc/application/models/airtime/om/BaseWebstreamPeer.php create mode 100644 airtime_mvc/application/models/airtime/om/BaseWebstreamQuery.php create mode 100644 airtime_mvc/library/propel/README.md delete mode 100644 airtime_mvc/library/propel/WHATS_NEW create mode 100644 airtime_mvc/library/propel/composer.json delete mode 100644 airtime_mvc/library/propel/contrib/dbd2propel/dbd2propel.xsl delete mode 100644 airtime_mvc/library/propel/contrib/dbd2propel/transform.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/Creator/Definition.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/Creator/Propel.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/Creator/_propel_creator_test.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/Datasource/Propel.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/Definition.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/Definition/Propel.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/Element.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/Rule.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/Rule/Match.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/Rule/MaxLength.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/Rule/MaxValue.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/Rule/MinLength.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/Rule/MinValue.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/Rule/NotMatch.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/Rule/ValidValues.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/Storage/Propel.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/res/form.dynamic.tpl delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms/res/mysql-dump.bookstore.sql delete mode 100644 airtime_mvc/library/propel/contrib/pat/patForms_Storage_Propel_test.php delete mode 100644 airtime_mvc/library/propel/contrib/pat/patTemplate.php delete mode 100644 airtime_mvc/library/propel/contrib/pear/HTML_QuickForm_Propel/Propel.php delete mode 100644 airtime_mvc/library/propel/contrib/pear/Structures_DataGrid_Propel/Propel.php delete mode 100644 airtime_mvc/library/propel/docs/behavior/aggregate_column.txt delete mode 100644 airtime_mvc/library/propel/docs/behavior/alternative_coding_standards.txt delete mode 100644 airtime_mvc/library/propel/docs/behavior/auto_add_pk.txt delete mode 100644 airtime_mvc/library/propel/docs/behavior/nested_set.txt delete mode 100644 airtime_mvc/library/propel/docs/behavior/query_cache.txt delete mode 100644 airtime_mvc/library/propel/docs/behavior/sluggable.txt delete mode 100644 airtime_mvc/library/propel/docs/behavior/soft_delete.txt delete mode 100644 airtime_mvc/library/propel/docs/behavior/sortable.txt delete mode 100644 airtime_mvc/library/propel/docs/behavior/timestampable.txt delete mode 100644 airtime_mvc/library/propel/docs/build.xml delete mode 100644 airtime_mvc/library/propel/docs/cookbook/Add-Custom-SQL.txt delete mode 100644 airtime_mvc/library/propel/docs/cookbook/Copying-Objects.txt delete mode 100644 airtime_mvc/library/propel/docs/cookbook/Customizing-Build.txt delete mode 100644 airtime_mvc/library/propel/docs/cookbook/Existing-Database.txt delete mode 100644 airtime_mvc/library/propel/docs/cookbook/LOB-Columns.txt delete mode 100644 airtime_mvc/library/propel/docs/cookbook/Master-Slave.txt delete mode 100644 airtime_mvc/library/propel/docs/cookbook/Multi-Component.txt delete mode 100644 airtime_mvc/library/propel/docs/cookbook/Namespaces.txt delete mode 100644 airtime_mvc/library/propel/docs/cookbook/Nested-Set.txt delete mode 100644 airtime_mvc/library/propel/docs/cookbook/Runtime-Introspection.txt delete mode 100644 airtime_mvc/library/propel/docs/cookbook/Writing-Behavior.txt delete mode 100644 airtime_mvc/library/propel/docs/guide/01-Installation.txt delete mode 100644 airtime_mvc/library/propel/docs/guide/02-BuildTime.txt delete mode 100644 airtime_mvc/library/propel/docs/guide/03-Basic-CRUD.txt delete mode 100644 airtime_mvc/library/propel/docs/guide/04-Relationships.txt delete mode 100644 airtime_mvc/library/propel/docs/guide/05-Validators.txt delete mode 100644 airtime_mvc/library/propel/docs/guide/06-Transactions.txt delete mode 100644 airtime_mvc/library/propel/docs/guide/07-Behaviors.txt delete mode 100644 airtime_mvc/library/propel/docs/guide/08-Logging.txt delete mode 100644 airtime_mvc/library/propel/docs/guide/09-Inheritance.txt delete mode 100644 airtime_mvc/library/propel/docs/reference/Buildtime-Configuration.txt delete mode 100644 airtime_mvc/library/propel/docs/reference/ModelCriteria.txt delete mode 100644 airtime_mvc/library/propel/docs/reference/Runtime-Configuration.txt delete mode 100644 airtime_mvc/library/propel/docs/reference/Schema.txt create mode 100755 airtime_mvc/library/propel/generator/bin/phing.php create mode 100755 airtime_mvc/library/propel/generator/bin/propel-gen.bat create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/DelegateBehavior.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/aggregate_column/templates/objectPostSave.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/archivable/ArchivableBehavior.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/archivable/ArchivableBehaviorObjectBuilderModifier.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/archivable/ArchivableBehaviorQueryBuilderModifier.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/archivable/templates/objectArchive.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/archivable/templates/objectDeleteWithoutArchive.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/archivable/templates/objectGetArchive.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/archivable/templates/objectPopulateFromArchive.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/archivable/templates/objectPreDelete.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/archivable/templates/objectRestoreFromArchive.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/archivable/templates/objectSaveWithoutArchive.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/archivable/templates/queryArchive.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/archivable/templates/queryDeleteWithoutArchive.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/archivable/templates/querySetArchiveOnDelete.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/archivable/templates/querySetArchiveOnUpdate.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/archivable/templates/queryUpdateWithoutArchive.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/I18nBehavior.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/I18nBehaviorObjectBuilderModifier.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/I18nBehaviorPeerBuilderModifier.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/I18nBehaviorQueryBuilderModifier.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/templates/objectAttributes.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/templates/objectClearReferences.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/templates/objectGetCurrentTranslation.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/templates/objectGetLocale.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/templates/objectGetLocaleAlias.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/templates/objectGetTranslation.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/templates/objectPostDelete.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/templates/objectRemoveTranslation.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/templates/objectSetLocale.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/templates/objectSetLocaleAlias.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/templates/objectSetTranslation.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/templates/objectTranslatedColumnGetter.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/templates/objectTranslatedColumnSetter.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/templates/queryJoinI18n.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/templates/queryJoinWithI18n.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/i18n/templates/queryUseI18nQuery.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/sortable/SortableRelationBehavior.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/versionable/VersionableBehavior.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/versionable/VersionableBehaviorObjectBuilderModifier.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/versionable/VersionableBehaviorPeerBuilderModifier.php create mode 100644 airtime_mvc/library/propel/generator/lib/behavior/versionable/VersionableBehaviorQueryBuilderModifier.php delete mode 100644 airtime_mvc/library/propel/generator/lib/builder/sql/DDLBuilder.php delete mode 100644 airtime_mvc/library/propel/generator/lib/builder/sql/mssql/MssqlDDLBuilder.php delete mode 100644 airtime_mvc/library/propel/generator/lib/builder/sql/mysql/MysqlDDLBuilder.php delete mode 100644 airtime_mvc/library/propel/generator/lib/builder/sql/oracle/OracleDDLBuilder.php delete mode 100644 airtime_mvc/library/propel/generator/lib/builder/sql/pgsql/PgsqlDDLBuilder.php delete mode 100644 airtime_mvc/library/propel/generator/lib/builder/sql/sqlite/SqliteDDLBuilder.php create mode 100644 airtime_mvc/library/propel/generator/lib/builder/sql/sqlsrv/SqlsrvDataSQLBuilder.php create mode 100644 airtime_mvc/library/propel/generator/lib/builder/util/StandardEnglishPluralizer.php create mode 100644 airtime_mvc/library/propel/generator/lib/config/GeneratorConfigInterface.php create mode 100644 airtime_mvc/library/propel/generator/lib/config/QuickGeneratorConfig.php create mode 100644 airtime_mvc/library/propel/generator/lib/exception/SchemaException.php create mode 100644 airtime_mvc/library/propel/generator/lib/model/ScopedElement.php create mode 100644 airtime_mvc/library/propel/generator/lib/model/diff/PropelColumnComparator.php create mode 100644 airtime_mvc/library/propel/generator/lib/model/diff/PropelColumnDiff.php create mode 100644 airtime_mvc/library/propel/generator/lib/model/diff/PropelDatabaseComparator.php create mode 100644 airtime_mvc/library/propel/generator/lib/model/diff/PropelDatabaseDiff.php create mode 100644 airtime_mvc/library/propel/generator/lib/model/diff/PropelForeignKeyComparator.php create mode 100644 airtime_mvc/library/propel/generator/lib/model/diff/PropelIndexComparator.php create mode 100644 airtime_mvc/library/propel/generator/lib/model/diff/PropelTableComparator.php create mode 100644 airtime_mvc/library/propel/generator/lib/model/diff/PropelTableDiff.php delete mode 100644 airtime_mvc/library/propel/generator/lib/platform/Platform.php create mode 100644 airtime_mvc/library/propel/generator/lib/platform/PropelPlatformInterface.php create mode 100644 airtime_mvc/library/propel/generator/lib/platform/SqlsrvPlatform.php create mode 100644 airtime_mvc/library/propel/generator/lib/reverse/sqlsrv/SqlsrvSchemaParser.php create mode 100644 airtime_mvc/library/propel/generator/lib/task/AbstractPropelTask.php create mode 100644 airtime_mvc/library/propel/generator/lib/task/BasePropelMigrationTask.php delete mode 100644 airtime_mvc/library/propel/generator/lib/task/PropelDataDTDTask.php delete mode 100644 airtime_mvc/library/propel/generator/lib/task/PropelDataModelTemplateTask.php create mode 100644 airtime_mvc/library/propel/generator/lib/task/PropelMigrationDownTask.php create mode 100644 airtime_mvc/library/propel/generator/lib/task/PropelMigrationStatusTask.php create mode 100644 airtime_mvc/library/propel/generator/lib/task/PropelMigrationTask.php create mode 100644 airtime_mvc/library/propel/generator/lib/task/PropelMigrationUpTask.php create mode 100644 airtime_mvc/library/propel/generator/lib/task/PropelSQLDiffTask.php create mode 100644 airtime_mvc/library/propel/generator/lib/task/PropelSqlBuildTask.php create mode 100644 airtime_mvc/library/propel/generator/lib/util/PropelDotGenerator.php create mode 100644 airtime_mvc/library/propel/generator/lib/util/PropelMigrationManager.php create mode 100644 airtime_mvc/library/propel/generator/lib/util/PropelPHPParser.php create mode 100644 airtime_mvc/library/propel/generator/lib/util/PropelQuickBuilder.php create mode 100644 airtime_mvc/library/propel/generator/lib/util/PropelSQLParser.php create mode 100644 airtime_mvc/library/propel/generator/lib/util/PropelSchemaValidator.php create mode 100644 airtime_mvc/library/propel/generator/lib/util/PropelSqlManager.php mode change 100755 => 100644 airtime_mvc/library/propel/generator/pear/pear-propel-gen create mode 100644 airtime_mvc/library/propel/generator/resources/xsl/dbd2propel.xsl create mode 100644 airtime_mvc/library/propel/generator/stubs/functions.php create mode 100644 airtime_mvc/library/propel/phpunit.xml.dist create mode 100644 airtime_mvc/library/propel/runtime/lib/adapter/DBSQLSRV.php delete mode 100644 airtime_mvc/library/propel/runtime/lib/adapter/MSSQL/MssqlDateTime.class.php create mode 100644 airtime_mvc/library/propel/runtime/lib/formatter/PropelSimpleArrayFormatter.php create mode 100644 airtime_mvc/library/propel/runtime/lib/parser/PropelCSVParser.php create mode 100644 airtime_mvc/library/propel/runtime/lib/parser/PropelJSONParser.php create mode 100644 airtime_mvc/library/propel/runtime/lib/parser/PropelParser.php create mode 100644 airtime_mvc/library/propel/runtime/lib/parser/PropelXMLParser.php create mode 100644 airtime_mvc/library/propel/runtime/lib/parser/PropelYAMLParser.php create mode 100644 airtime_mvc/library/propel/runtime/lib/parser/yaml/LICENSE create mode 100644 airtime_mvc/library/propel/runtime/lib/parser/yaml/sfYaml.php create mode 100644 airtime_mvc/library/propel/runtime/lib/parser/yaml/sfYamlDumper.php create mode 100644 airtime_mvc/library/propel/runtime/lib/parser/yaml/sfYamlInline.php create mode 100644 airtime_mvc/library/propel/runtime/lib/parser/yaml/sfYamlParser.php create mode 100644 airtime_mvc/library/propel/runtime/stubs/functions.php delete mode 100644 airtime_mvc/library/propel/test/README delete mode 100644 airtime_mvc/library/propel/test/bookstore-packaged-test.php create mode 100644 airtime_mvc/library/propel/test/bootstrap.php delete mode 100644 airtime_mvc/library/propel/test/etc/schema/tabletest-schema.xml rename airtime_mvc/library/propel/test/etc/xsl/{phpunit2-noframes.xsl => phpunit-noframes.xsl} (97%) create mode 100644 airtime_mvc/library/propel/test/fixtures/bookstore/behavior-add-class-schema.xml create mode 100644 airtime_mvc/library/propel/test/fixtures/bookstore/behavior-concrete-inheritance-one-to-one-schema.xml create mode 100644 airtime_mvc/library/propel/test/fixtures/generator/behavior/Foobar.php create mode 100644 airtime_mvc/library/propel/test/fixtures/generator/config/Foobar.php create mode 100644 airtime_mvc/library/propel/test/fixtures/generator/config/FoobarWithNS.php create mode 100644 airtime_mvc/library/propel/test/fixtures/reverse/mysql/build.properties create mode 100644 airtime_mvc/library/propel/test/fixtures/reverse/mysql/build/sql/schema.sql create mode 100644 airtime_mvc/library/propel/test/fixtures/reverse/mysql/build/sql/sqldb.map create mode 100644 airtime_mvc/library/propel/test/fixtures/reverse/mysql/runtime-conf.xml create mode 100644 airtime_mvc/library/propel/test/fixtures/reverse/pgsql/runtime-conf.xml create mode 100644 airtime_mvc/library/propel/test/fixtures/schemas/build.properties create mode 100644 airtime_mvc/library/propel/test/fixtures/schemas/runtime-conf.xml create mode 100644 airtime_mvc/library/propel/test/fixtures/schemas/schema.xml delete mode 100644 airtime_mvc/library/propel/test/fixtures/unique-column/column-schema.xml delete mode 100644 airtime_mvc/library/propel/test/fixtures/unique-column/table-schema.xml create mode 100755 airtime_mvc/library/propel/test/reset_tests.sh delete mode 100644 airtime_mvc/library/propel/test/speed.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/AddClassBehaviorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/AlternativeCodingStandardsBehaviorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/DelegateBehaviorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/NamespacedBehaviorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/aggregate_column/AggregateColumnBehaviorWithSchemaTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/archivable/ArchivableAndConcreteInheritanceBehaviorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/archivable/ArchivableBehaviorObjectBuilderModifierTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/archivable/ArchivableBehaviorQueryBuilderModifierTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/archivable/ArchivableBehaviorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceBehaviorNamespacedTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceBehaviorWithSchemaTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceExcludedParentBehaviorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/i18n/I18nBehaviorObjectBuilderModifierTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/i18n/I18nBehaviorPeerBuilderModifierTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/i18n/I18nBehaviorQueryBuilderModifierTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/i18n/I18nBehaviorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorWithNamespaceTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/versionable/VersionableBehaviorObjectBuilderModifierTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/versionable/VersionableBehaviorPeerBuilderModifierTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/behavior/versionable/VersionableBehaviorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectArrayColumnTypeTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectBooleanColumnTypeTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectDateTimeColumnTypeTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectEnumColumnTypeTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectLazyLoadTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectMoreRelationTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectObjectColumnTypeTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectPhpNameTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectTemporalColumnTypeTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectWithFixturesTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectWithInterfaceTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerEnumColumnTypeTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerLazyLoadTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedQueryArrayColumnTypeTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedQueryEnumColumnTypeTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedQueryObjectColumnTypeTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/OMBuilderRelatedByTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/PHP5ObjectBuilderTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/om/fixtures/ComplexColumnTypeEntityWithConstructor.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/util/DefaultEnglishPluralizerTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/util/StandardEnglishPluralizerTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/util/XmlToAppDataTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/util/innerSchema.xml create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/util/outerSchema.xml create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/builder/util/testSchema.xml create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/config/GeneratorConfigTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/model/ColumnDefaultValueTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/model/DatabaseTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/model/XMLElementTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelColumnComparatorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelDatabaseTableComparatorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelForeignKeyComparatorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelIndexComparatorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelTableColumnComparatorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelTableForeignKeyComparatorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelTableIndexComparatorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelTablePkColumnComparatorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/platform/MssqlPlatformTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/platform/MysqlPlatformMigrationMyISAMTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/platform/MysqlPlatformMigrationTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/platform/MysqlPlatformMyISAMTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/platform/MysqlPlatformTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/platform/OraclePlatformMigrationTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/platform/OraclePlatformTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/platform/PgsqlPlatformMigrationTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/platform/PgsqlPlatformTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/platform/PlatformMigrationTestProvider.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/platform/PlatformTestProvider.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/reverse/mssql/MssqlSchemaParserTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/reverse/mysql/MysqlSchemaParserTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/reverse/pgsql/PgsqlSchemaParserTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/util/PropelDotGeneratorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/util/PropelPHPParserTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/util/PropelQuickBuilderTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/util/PropelSQLParserTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/generator/util/PropelSchemaValidatorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/misc/Issue617Test.php create mode 100644 airtime_mvc/library/propel/test/testsuite/misc/Issue651Test.php create mode 100644 airtime_mvc/library/propel/test/testsuite/misc/PoisonedCacheBugTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBAdapterTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBAdapterTestAbstract.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBMSSQLTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBMySQLTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBPostgresTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelCollectionConvertTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelObjectCollectionWithFixturesTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/config/PropelConfigurationTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/exception/PropelExceptionTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelFormatterTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelSimpleArrayFormatterTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/map/GeneratedRelationMapWithSchemasTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/map/RelatedMapSymmetricalWithSchemasTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/om/BaseObjectConvertTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/om/BaseObjectHashCodeTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelCSVParserTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelJSONParserTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelParserTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelXMLParserTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelYAMLParserTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/parser/fixtures/test_data.xml create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaFluidOperatorTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/query/ExplainPlanTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaSelectTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaWithNamespaceTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaWithSchemaTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/query/SubQueryTest.php create mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/util/PropelConditionalProxyTest.php delete mode 100644 airtime_mvc/library/propel/test/testsuite/runtime/util/PropelConfigurationTest.php create mode 100644 airtime_mvc/library/propel/test/tools/helpers/DummyPlatforms.php create mode 100644 airtime_mvc/library/propel/test/tools/helpers/PlatformDatabaseBuildTimeBase.php create mode 100644 airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/AddClassBehavior.php create mode 100644 airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/AddClassBehaviorBuilder.php create mode 100644 airtime_mvc/library/propel/test/tools/helpers/namespaces/NamespacesTestBase.php create mode 100644 airtime_mvc/library/propel/test/tools/helpers/schemas/SchemasTestBase.php delete mode 100644 airtime_mvc/library/propel/test/tree-test.php diff --git a/airtime_mvc/application/configs/airtime-conf-production.php b/airtime_mvc/application/configs/airtime-conf-production.php index aaef0e371..1ebc4a9aa 100644 --- a/airtime_mvc/application/configs/airtime-conf-production.php +++ b/airtime_mvc/application/configs/airtime-conf-production.php @@ -1,5 +1,5 @@ 'airtime', ), - 'generator_version' => '1.5.2', + 'generator_version' => '1.7.0', ); $conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classmap-airtime-conf.php'); return $conf; diff --git a/airtime_mvc/application/configs/airtime-conf.php b/airtime_mvc/application/configs/airtime-conf.php index aa69b6156..ac0a800e4 100644 --- a/airtime_mvc/application/configs/airtime-conf.php +++ b/airtime_mvc/application/configs/airtime-conf.php @@ -1,6 +1,6 @@ array ( @@ -14,7 +14,7 @@ $conf = array ( ), 'default' => 'airtime', ), - 'generator_version' => '1.5.2', + 'generator_version' => '1.7.0', ); $conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classmap-airtime-conf.php'); return $conf; \ No newline at end of file diff --git a/airtime_mvc/application/configs/classmap-airtime-conf.php b/airtime_mvc/application/configs/classmap-airtime-conf.php index fb4284681..7f8b2f888 100644 --- a/airtime_mvc/application/configs/classmap-airtime-conf.php +++ b/airtime_mvc/application/configs/classmap-airtime-conf.php @@ -1,242 +1,263 @@ 'airtime/map/CcMusicDirsTableMap.php', - 'CcMusicDirsPeer' => 'airtime/CcMusicDirsPeer.php', - 'CcMusicDirs' => 'airtime/CcMusicDirs.php', - 'CcMusicDirsQuery' => 'airtime/CcMusicDirsQuery.php', - 'BaseCcMusicDirsPeer' => 'airtime/om/BaseCcMusicDirsPeer.php', - 'BaseCcMusicDirs' => 'airtime/om/BaseCcMusicDirs.php', - 'BaseCcMusicDirsQuery' => 'airtime/om/BaseCcMusicDirsQuery.php', - 'CcFilesTableMap' => 'airtime/map/CcFilesTableMap.php', - 'CcFilesPeer' => 'airtime/CcFilesPeer.php', - 'CcFiles' => 'airtime/CcFiles.php', - 'CcFilesQuery' => 'airtime/CcFilesQuery.php', - 'BaseCcFilesPeer' => 'airtime/om/BaseCcFilesPeer.php', - 'BaseCcFiles' => 'airtime/om/BaseCcFiles.php', - 'BaseCcFilesQuery' => 'airtime/om/BaseCcFilesQuery.php', - 'CcPermsTableMap' => 'airtime/map/CcPermsTableMap.php', - 'CcPermsPeer' => 'airtime/CcPermsPeer.php', - 'CcPerms' => 'airtime/CcPerms.php', - 'CcPermsQuery' => 'airtime/CcPermsQuery.php', - 'BaseCcPermsPeer' => 'airtime/om/BaseCcPermsPeer.php', - 'BaseCcPerms' => 'airtime/om/BaseCcPerms.php', - 'BaseCcPermsQuery' => 'airtime/om/BaseCcPermsQuery.php', - 'CcShowTableMap' => 'airtime/map/CcShowTableMap.php', - 'CcShowPeer' => 'airtime/CcShowPeer.php', - 'CcShow' => 'airtime/CcShow.php', - 'CcShowQuery' => 'airtime/CcShowQuery.php', - 'BaseCcShowPeer' => 'airtime/om/BaseCcShowPeer.php', - 'BaseCcShow' => 'airtime/om/BaseCcShow.php', - 'BaseCcShowQuery' => 'airtime/om/BaseCcShowQuery.php', - 'CcShowInstancesTableMap' => 'airtime/map/CcShowInstancesTableMap.php', - 'CcShowInstancesPeer' => 'airtime/CcShowInstancesPeer.php', - 'CcShowInstances' => 'airtime/CcShowInstances.php', - 'CcShowInstancesQuery' => 'airtime/CcShowInstancesQuery.php', - 'BaseCcShowInstancesPeer' => 'airtime/om/BaseCcShowInstancesPeer.php', - 'BaseCcShowInstances' => 'airtime/om/BaseCcShowInstances.php', - 'BaseCcShowInstancesQuery' => 'airtime/om/BaseCcShowInstancesQuery.php', - 'CcShowDaysTableMap' => 'airtime/map/CcShowDaysTableMap.php', - 'CcShowDaysPeer' => 'airtime/CcShowDaysPeer.php', - 'CcShowDays' => 'airtime/CcShowDays.php', - 'CcShowDaysQuery' => 'airtime/CcShowDaysQuery.php', - 'BaseCcShowDaysPeer' => 'airtime/om/BaseCcShowDaysPeer.php', - 'BaseCcShowDays' => 'airtime/om/BaseCcShowDays.php', - 'BaseCcShowDaysQuery' => 'airtime/om/BaseCcShowDaysQuery.php', - 'CcShowRebroadcastTableMap' => 'airtime/map/CcShowRebroadcastTableMap.php', - 'CcShowRebroadcastPeer' => 'airtime/CcShowRebroadcastPeer.php', - 'CcShowRebroadcast' => 'airtime/CcShowRebroadcast.php', - 'CcShowRebroadcastQuery' => 'airtime/CcShowRebroadcastQuery.php', - 'BaseCcShowRebroadcastPeer' => 'airtime/om/BaseCcShowRebroadcastPeer.php', - 'BaseCcShowRebroadcast' => 'airtime/om/BaseCcShowRebroadcast.php', - 'BaseCcShowRebroadcastQuery' => 'airtime/om/BaseCcShowRebroadcastQuery.php', - 'CcShowHostsTableMap' => 'airtime/map/CcShowHostsTableMap.php', - 'CcShowHostsPeer' => 'airtime/CcShowHostsPeer.php', - 'CcShowHosts' => 'airtime/CcShowHosts.php', - 'CcShowHostsQuery' => 'airtime/CcShowHostsQuery.php', - 'BaseCcShowHostsPeer' => 'airtime/om/BaseCcShowHostsPeer.php', - 'BaseCcShowHosts' => 'airtime/om/BaseCcShowHosts.php', - 'BaseCcShowHostsQuery' => 'airtime/om/BaseCcShowHostsQuery.php', - 'CcPlaylistTableMap' => 'airtime/map/CcPlaylistTableMap.php', - 'CcPlaylistPeer' => 'airtime/CcPlaylistPeer.php', - 'CcPlaylist' => 'airtime/CcPlaylist.php', - 'CcPlaylistQuery' => 'airtime/CcPlaylistQuery.php', - 'BaseCcPlaylistPeer' => 'airtime/om/BaseCcPlaylistPeer.php', - 'BaseCcPlaylist' => 'airtime/om/BaseCcPlaylist.php', - 'BaseCcPlaylistQuery' => 'airtime/om/BaseCcPlaylistQuery.php', - 'CcPlaylistcontentsTableMap' => 'airtime/map/CcPlaylistcontentsTableMap.php', - 'CcPlaylistcontentsPeer' => 'airtime/CcPlaylistcontentsPeer.php', - 'CcPlaylistcontents' => 'airtime/CcPlaylistcontents.php', - 'CcPlaylistcontentsQuery' => 'airtime/CcPlaylistcontentsQuery.php', - 'BaseCcPlaylistcontentsPeer' => 'airtime/om/BaseCcPlaylistcontentsPeer.php', - 'BaseCcPlaylistcontents' => 'airtime/om/BaseCcPlaylistcontents.php', - 'BaseCcPlaylistcontentsQuery' => 'airtime/om/BaseCcPlaylistcontentsQuery.php', - 'CcBlockTableMap' => 'airtime/map/CcBlockTableMap.php', - 'CcBlockPeer' => 'airtime/CcBlockPeer.php', - 'CcBlock' => 'airtime/CcBlock.php', - 'CcBlockQuery' => 'airtime/CcBlockQuery.php', - 'BaseCcBlockPeer' => 'airtime/om/BaseCcBlockPeer.php', - 'BaseCcBlock' => 'airtime/om/BaseCcBlock.php', - 'BaseCcBlockQuery' => 'airtime/om/BaseCcBlockQuery.php', - 'CcBlockcontentsTableMap' => 'airtime/map/CcBlockcontentsTableMap.php', - 'CcBlockcontentsPeer' => 'airtime/CcBlockcontentsPeer.php', - 'CcBlockcontents' => 'airtime/CcBlockcontents.php', - 'CcBlockcontentsQuery' => 'airtime/CcBlockcontentsQuery.php', - 'BaseCcBlockcontentsPeer' => 'airtime/om/BaseCcBlockcontentsPeer.php', - 'BaseCcBlockcontents' => 'airtime/om/BaseCcBlockcontents.php', - 'BaseCcBlockcontentsQuery' => 'airtime/om/BaseCcBlockcontentsQuery.php', - 'CcBlockcriteriaTableMap' => 'airtime/map/CcBlockcriteriaTableMap.php', - 'CcBlockcriteriaPeer' => 'airtime/CcBlockcriteriaPeer.php', - 'CcBlockcriteria' => 'airtime/CcBlockcriteria.php', - 'CcBlockcriteriaQuery' => 'airtime/CcBlockcriteriaQuery.php', - 'BaseCcBlockcriteriaPeer' => 'airtime/om/BaseCcBlockcriteriaPeer.php', - 'BaseCcBlockcriteria' => 'airtime/om/BaseCcBlockcriteria.php', - 'BaseCcBlockcriteriaQuery' => 'airtime/om/BaseCcBlockcriteriaQuery.php', - 'CcPrefTableMap' => 'airtime/map/CcPrefTableMap.php', - 'CcPrefPeer' => 'airtime/CcPrefPeer.php', - 'CcPref' => 'airtime/CcPref.php', - 'CcPrefQuery' => 'airtime/CcPrefQuery.php', - 'BaseCcPrefPeer' => 'airtime/om/BaseCcPrefPeer.php', - 'BaseCcPref' => 'airtime/om/BaseCcPref.php', - 'BaseCcPrefQuery' => 'airtime/om/BaseCcPrefQuery.php', - 'CcScheduleTableMap' => 'airtime/map/CcScheduleTableMap.php', - 'CcSchedulePeer' => 'airtime/CcSchedulePeer.php', - 'CcSchedule' => 'airtime/CcSchedule.php', - 'CcScheduleQuery' => 'airtime/CcScheduleQuery.php', - 'BaseCcSchedulePeer' => 'airtime/om/BaseCcSchedulePeer.php', - 'BaseCcSchedule' => 'airtime/om/BaseCcSchedule.php', - 'BaseCcScheduleQuery' => 'airtime/om/BaseCcScheduleQuery.php', - 'CcSessTableMap' => 'airtime/map/CcSessTableMap.php', - 'CcSessPeer' => 'airtime/CcSessPeer.php', - 'CcSess' => 'airtime/CcSess.php', - 'CcSessQuery' => 'airtime/CcSessQuery.php', - 'BaseCcSessPeer' => 'airtime/om/BaseCcSessPeer.php', - 'BaseCcSess' => 'airtime/om/BaseCcSess.php', - 'BaseCcSessQuery' => 'airtime/om/BaseCcSessQuery.php', - 'CcSmembTableMap' => 'airtime/map/CcSmembTableMap.php', - 'CcSmembPeer' => 'airtime/CcSmembPeer.php', - 'CcSmemb' => 'airtime/CcSmemb.php', - 'CcSmembQuery' => 'airtime/CcSmembQuery.php', - 'BaseCcSmembPeer' => 'airtime/om/BaseCcSmembPeer.php', - 'BaseCcSmemb' => 'airtime/om/BaseCcSmemb.php', - 'BaseCcSmembQuery' => 'airtime/om/BaseCcSmembQuery.php', - 'CcSubjsTableMap' => 'airtime/map/CcSubjsTableMap.php', - 'CcSubjsPeer' => 'airtime/CcSubjsPeer.php', - 'CcSubjs' => 'airtime/CcSubjs.php', - 'CcSubjsQuery' => 'airtime/CcSubjsQuery.php', - 'BaseCcSubjsPeer' => 'airtime/om/BaseCcSubjsPeer.php', - 'BaseCcSubjs' => 'airtime/om/BaseCcSubjs.php', - 'BaseCcSubjsQuery' => 'airtime/om/BaseCcSubjsQuery.php', - 'CcSubjsTokenTableMap' => 'airtime/map/CcSubjsTokenTableMap.php', - 'CcSubjsTokenPeer' => 'airtime/CcSubjsTokenPeer.php', - 'CcSubjsToken' => 'airtime/CcSubjsToken.php', - 'CcSubjsTokenQuery' => 'airtime/CcSubjsTokenQuery.php', - 'BaseCcSubjsTokenPeer' => 'airtime/om/BaseCcSubjsTokenPeer.php', - 'BaseCcSubjsToken' => 'airtime/om/BaseCcSubjsToken.php', - 'BaseCcSubjsTokenQuery' => 'airtime/om/BaseCcSubjsTokenQuery.php', - 'CcCountryTableMap' => 'airtime/map/CcCountryTableMap.php', - 'CcCountryPeer' => 'airtime/CcCountryPeer.php', - 'CcCountry' => 'airtime/CcCountry.php', - 'CcCountryQuery' => 'airtime/CcCountryQuery.php', - 'BaseCcCountryPeer' => 'airtime/om/BaseCcCountryPeer.php', - 'BaseCcCountry' => 'airtime/om/BaseCcCountry.php', - 'BaseCcCountryQuery' => 'airtime/om/BaseCcCountryQuery.php', - 'CcStreamSettingTableMap' => 'airtime/map/CcStreamSettingTableMap.php', - 'CcStreamSettingPeer' => 'airtime/CcStreamSettingPeer.php', - 'CcStreamSetting' => 'airtime/CcStreamSetting.php', - 'CcStreamSettingQuery' => 'airtime/CcStreamSettingQuery.php', - 'BaseCcStreamSettingPeer' => 'airtime/om/BaseCcStreamSettingPeer.php', - 'BaseCcStreamSetting' => 'airtime/om/BaseCcStreamSetting.php', - 'BaseCcStreamSettingQuery' => 'airtime/om/BaseCcStreamSettingQuery.php', - 'CcLoginAttemptsTableMap' => 'airtime/map/CcLoginAttemptsTableMap.php', - 'CcLoginAttemptsPeer' => 'airtime/CcLoginAttemptsPeer.php', - 'CcLoginAttempts' => 'airtime/CcLoginAttempts.php', - 'CcLoginAttemptsQuery' => 'airtime/CcLoginAttemptsQuery.php', - 'BaseCcLoginAttemptsPeer' => 'airtime/om/BaseCcLoginAttemptsPeer.php', - 'BaseCcLoginAttempts' => 'airtime/om/BaseCcLoginAttempts.php', - 'BaseCcLoginAttemptsQuery' => 'airtime/om/BaseCcLoginAttemptsQuery.php', - 'CcServiceRegisterTableMap' => 'airtime/map/CcServiceRegisterTableMap.php', - 'CcServiceRegisterPeer' => 'airtime/CcServiceRegisterPeer.php', - 'CcServiceRegister' => 'airtime/CcServiceRegister.php', - 'CcServiceRegisterQuery' => 'airtime/CcServiceRegisterQuery.php', - 'BaseCcServiceRegisterPeer' => 'airtime/om/BaseCcServiceRegisterPeer.php', - 'BaseCcServiceRegister' => 'airtime/om/BaseCcServiceRegister.php', - 'BaseCcServiceRegisterQuery' => 'airtime/om/BaseCcServiceRegisterQuery.php', - 'CcLiveLogTableMap' => 'airtime/map/CcLiveLogTableMap.php', - 'CcLiveLogPeer' => 'airtime/CcLiveLogPeer.php', - 'CcLiveLog' => 'airtime/CcLiveLog.php', - 'CcLiveLogQuery' => 'airtime/CcLiveLogQuery.php', - 'BaseCcLiveLogPeer' => 'airtime/om/BaseCcLiveLogPeer.php', - 'BaseCcLiveLog' => 'airtime/om/BaseCcLiveLog.php', - 'BaseCcLiveLogQuery' => 'airtime/om/BaseCcLiveLogQuery.php', - 'CcWebstreamTableMap' => 'airtime/map/CcWebstreamTableMap.php', - 'CcWebstreamPeer' => 'airtime/CcWebstreamPeer.php', - 'CcWebstream' => 'airtime/CcWebstream.php', - 'CcWebstreamQuery' => 'airtime/CcWebstreamQuery.php', - 'BaseCcWebstreamPeer' => 'airtime/om/BaseCcWebstreamPeer.php', - 'BaseCcWebstream' => 'airtime/om/BaseCcWebstream.php', - 'BaseCcWebstreamQuery' => 'airtime/om/BaseCcWebstreamQuery.php', - 'CcWebstreamMetadataTableMap' => 'airtime/map/CcWebstreamMetadataTableMap.php', - 'CcWebstreamMetadataPeer' => 'airtime/CcWebstreamMetadataPeer.php', - 'CcWebstreamMetadata' => 'airtime/CcWebstreamMetadata.php', - 'CcWebstreamMetadataQuery' => 'airtime/CcWebstreamMetadataQuery.php', - 'BaseCcWebstreamMetadataPeer' => 'airtime/om/BaseCcWebstreamMetadataPeer.php', - 'BaseCcWebstreamMetadata' => 'airtime/om/BaseCcWebstreamMetadata.php', - 'BaseCcWebstreamMetadataQuery' => 'airtime/om/BaseCcWebstreamMetadataQuery.php', - 'CcMountNameTableMap' => 'airtime/map/CcMountNameTableMap.php', - 'CcMountNamePeer' => 'airtime/CcMountNamePeer.php', - 'CcMountName' => 'airtime/CcMountName.php', - 'CcMountNameQuery' => 'airtime/CcMountNameQuery.php', - 'BaseCcMountNamePeer' => 'airtime/om/BaseCcMountNamePeer.php', - 'BaseCcMountName' => 'airtime/om/BaseCcMountName.php', - 'BaseCcMountNameQuery' => 'airtime/om/BaseCcMountNameQuery.php', - 'CcTimestampTableMap' => 'airtime/map/CcTimestampTableMap.php', - 'CcTimestampPeer' => 'airtime/CcTimestampPeer.php', - 'CcTimestamp' => 'airtime/CcTimestamp.php', - 'CcTimestampQuery' => 'airtime/CcTimestampQuery.php', - 'BaseCcTimestampPeer' => 'airtime/om/BaseCcTimestampPeer.php', - 'BaseCcTimestamp' => 'airtime/om/BaseCcTimestamp.php', - 'BaseCcTimestampQuery' => 'airtime/om/BaseCcTimestampQuery.php', - 'CcListenerCountTableMap' => 'airtime/map/CcListenerCountTableMap.php', - 'CcListenerCountPeer' => 'airtime/CcListenerCountPeer.php', - 'CcListenerCount' => 'airtime/CcListenerCount.php', - 'CcListenerCountQuery' => 'airtime/CcListenerCountQuery.php', - 'BaseCcListenerCountPeer' => 'airtime/om/BaseCcListenerCountPeer.php', - 'BaseCcListenerCount' => 'airtime/om/BaseCcListenerCount.php', - 'BaseCcListenerCountQuery' => 'airtime/om/BaseCcListenerCountQuery.php', - 'CcLocaleTableMap' => 'airtime/map/CcLocaleTableMap.php', - 'CcLocalePeer' => 'airtime/CcLocalePeer.php', - 'CcLocale' => 'airtime/CcLocale.php', - 'CcLocaleQuery' => 'airtime/CcLocaleQuery.php', - 'BaseCcLocalePeer' => 'airtime/om/BaseCcLocalePeer.php', - 'BaseCcLocale' => 'airtime/om/BaseCcLocale.php', - 'BaseCcLocaleQuery' => 'airtime/om/BaseCcLocaleQuery.php', - 'CcPlayoutHistoryTableMap' => 'airtime/map/CcPlayoutHistoryTableMap.php', - 'CcPlayoutHistoryPeer' => 'airtime/CcPlayoutHistoryPeer.php', - 'CcPlayoutHistory' => 'airtime/CcPlayoutHistory.php', - 'CcPlayoutHistoryQuery' => 'airtime/CcPlayoutHistoryQuery.php', - 'BaseCcPlayoutHistoryPeer' => 'airtime/om/BaseCcPlayoutHistoryPeer.php', - 'BaseCcPlayoutHistory' => 'airtime/om/BaseCcPlayoutHistory.php', - 'BaseCcPlayoutHistoryQuery' => 'airtime/om/BaseCcPlayoutHistoryQuery.php', - 'CcPlayoutHistoryMetaDataTableMap' => 'airtime/map/CcPlayoutHistoryMetaDataTableMap.php', - 'CcPlayoutHistoryMetaDataPeer' => 'airtime/CcPlayoutHistoryMetaDataPeer.php', - 'CcPlayoutHistoryMetaData' => 'airtime/CcPlayoutHistoryMetaData.php', - 'CcPlayoutHistoryMetaDataQuery' => 'airtime/CcPlayoutHistoryMetaDataQuery.php', - 'BaseCcPlayoutHistoryMetaDataPeer' => 'airtime/om/BaseCcPlayoutHistoryMetaDataPeer.php', - 'BaseCcPlayoutHistoryMetaData' => 'airtime/om/BaseCcPlayoutHistoryMetaData.php', - 'BaseCcPlayoutHistoryMetaDataQuery' => 'airtime/om/BaseCcPlayoutHistoryMetaDataQuery.php', - 'CcPlayoutHistoryTemplateTableMap' => 'airtime/map/CcPlayoutHistoryTemplateTableMap.php', - 'CcPlayoutHistoryTemplatePeer' => 'airtime/CcPlayoutHistoryTemplatePeer.php', - 'CcPlayoutHistoryTemplate' => 'airtime/CcPlayoutHistoryTemplate.php', - 'CcPlayoutHistoryTemplateQuery' => 'airtime/CcPlayoutHistoryTemplateQuery.php', - 'BaseCcPlayoutHistoryTemplatePeer' => 'airtime/om/BaseCcPlayoutHistoryTemplatePeer.php', - 'BaseCcPlayoutHistoryTemplate' => 'airtime/om/BaseCcPlayoutHistoryTemplate.php', - 'BaseCcPlayoutHistoryTemplateQuery' => 'airtime/om/BaseCcPlayoutHistoryTemplateQuery.php', - 'CcPlayoutHistoryTemplateFieldTableMap' => 'airtime/map/CcPlayoutHistoryTemplateFieldTableMap.php', - 'CcPlayoutHistoryTemplateFieldPeer' => 'airtime/CcPlayoutHistoryTemplateFieldPeer.php', - 'CcPlayoutHistoryTemplateField' => 'airtime/CcPlayoutHistoryTemplateField.php', - 'CcPlayoutHistoryTemplateFieldQuery' => 'airtime/CcPlayoutHistoryTemplateFieldQuery.php', - 'BaseCcPlayoutHistoryTemplateFieldPeer' => 'airtime/om/BaseCcPlayoutHistoryTemplateFieldPeer.php', - 'BaseCcPlayoutHistoryTemplateField' => 'airtime/om/BaseCcPlayoutHistoryTemplateField.php', - 'BaseCcPlayoutHistoryTemplateFieldQuery' => 'airtime/om/BaseCcPlayoutHistoryTemplateFieldQuery.php', + 'Airtime\\CcBlock' => 'airtime/CcBlock.php', + 'Airtime\\CcBlockPeer' => 'airtime/CcBlockPeer.php', + 'Airtime\\CcBlockQuery' => 'airtime/CcBlockQuery.php', + 'Airtime\\CcBlockcontents' => 'airtime/CcBlockcontents.php', + 'Airtime\\CcBlockcontentsPeer' => 'airtime/CcBlockcontentsPeer.php', + 'Airtime\\CcBlockcontentsQuery' => 'airtime/CcBlockcontentsQuery.php', + 'Airtime\\CcBlockcriteria' => 'airtime/CcBlockcriteria.php', + 'Airtime\\CcBlockcriteriaPeer' => 'airtime/CcBlockcriteriaPeer.php', + 'Airtime\\CcBlockcriteriaQuery' => 'airtime/CcBlockcriteriaQuery.php', + 'Airtime\\CcCountry' => 'airtime/CcCountry.php', + 'Airtime\\CcCountryPeer' => 'airtime/CcCountryPeer.php', + 'Airtime\\CcCountryQuery' => 'airtime/CcCountryQuery.php', + 'Airtime\\CcFiles' => 'airtime/CcFiles.php', + 'Airtime\\CcFilesPeer' => 'airtime/CcFilesPeer.php', + 'Airtime\\CcFilesQuery' => 'airtime/CcFilesQuery.php', + 'Airtime\\CcListenerCount' => 'airtime/CcListenerCount.php', + 'Airtime\\CcListenerCountPeer' => 'airtime/CcListenerCountPeer.php', + 'Airtime\\CcListenerCountQuery' => 'airtime/CcListenerCountQuery.php', + 'Airtime\\CcLiveLog' => 'airtime/CcLiveLog.php', + 'Airtime\\CcLiveLogPeer' => 'airtime/CcLiveLogPeer.php', + 'Airtime\\CcLiveLogQuery' => 'airtime/CcLiveLogQuery.php', + 'Airtime\\CcLocale' => 'airtime/CcLocale.php', + 'Airtime\\CcLocalePeer' => 'airtime/CcLocalePeer.php', + 'Airtime\\CcLocaleQuery' => 'airtime/CcLocaleQuery.php', + 'Airtime\\CcLoginAttempts' => 'airtime/CcLoginAttempts.php', + 'Airtime\\CcLoginAttemptsPeer' => 'airtime/CcLoginAttemptsPeer.php', + 'Airtime\\CcLoginAttemptsQuery' => 'airtime/CcLoginAttemptsQuery.php', + 'Airtime\\CcMountName' => 'airtime/CcMountName.php', + 'Airtime\\CcMountNamePeer' => 'airtime/CcMountNamePeer.php', + 'Airtime\\CcMountNameQuery' => 'airtime/CcMountNameQuery.php', + 'Airtime\\CcMusicDirs' => 'airtime/CcMusicDirs.php', + 'Airtime\\CcMusicDirsPeer' => 'airtime/CcMusicDirsPeer.php', + 'Airtime\\CcMusicDirsQuery' => 'airtime/CcMusicDirsQuery.php', + 'Airtime\\CcPlaylist' => 'airtime/CcPlaylist.php', + 'Airtime\\CcPlaylistPeer' => 'airtime/CcPlaylistPeer.php', + 'Airtime\\CcPlaylistQuery' => 'airtime/CcPlaylistQuery.php', + 'Airtime\\CcPlaylistcontents' => 'airtime/CcPlaylistcontents.php', + 'Airtime\\CcPlaylistcontentsPeer' => 'airtime/CcPlaylistcontentsPeer.php', + 'Airtime\\CcPlaylistcontentsQuery' => 'airtime/CcPlaylistcontentsQuery.php', + 'Airtime\\CcPref' => 'airtime/CcPref.php', + 'Airtime\\CcPrefPeer' => 'airtime/CcPrefPeer.php', + 'Airtime\\CcPrefQuery' => 'airtime/CcPrefQuery.php', + 'Airtime\\CcSchedule' => 'airtime/CcSchedule.php', + 'Airtime\\CcSchedulePeer' => 'airtime/CcSchedulePeer.php', + 'Airtime\\CcScheduleQuery' => 'airtime/CcScheduleQuery.php', + 'Airtime\\CcServiceRegister' => 'airtime/CcServiceRegister.php', + 'Airtime\\CcServiceRegisterPeer' => 'airtime/CcServiceRegisterPeer.php', + 'Airtime\\CcServiceRegisterQuery' => 'airtime/CcServiceRegisterQuery.php', + 'Airtime\\CcShow' => 'airtime/CcShow.php', + 'Airtime\\CcShowDays' => 'airtime/CcShowDays.php', + 'Airtime\\CcShowDaysPeer' => 'airtime/CcShowDaysPeer.php', + 'Airtime\\CcShowDaysQuery' => 'airtime/CcShowDaysQuery.php', + 'Airtime\\CcShowHosts' => 'airtime/CcShowHosts.php', + 'Airtime\\CcShowHostsPeer' => 'airtime/CcShowHostsPeer.php', + 'Airtime\\CcShowHostsQuery' => 'airtime/CcShowHostsQuery.php', + 'Airtime\\CcShowInstances' => 'airtime/CcShowInstances.php', + 'Airtime\\CcShowInstancesPeer' => 'airtime/CcShowInstancesPeer.php', + 'Airtime\\CcShowInstancesQuery' => 'airtime/CcShowInstancesQuery.php', + 'Airtime\\CcShowPeer' => 'airtime/CcShowPeer.php', + 'Airtime\\CcShowQuery' => 'airtime/CcShowQuery.php', + 'Airtime\\CcShowRebroadcast' => 'airtime/CcShowRebroadcast.php', + 'Airtime\\CcShowRebroadcastPeer' => 'airtime/CcShowRebroadcastPeer.php', + 'Airtime\\CcShowRebroadcastQuery' => 'airtime/CcShowRebroadcastQuery.php', + 'Airtime\\CcStreamSetting' => 'airtime/CcStreamSetting.php', + 'Airtime\\CcStreamSettingPeer' => 'airtime/CcStreamSettingPeer.php', + 'Airtime\\CcStreamSettingQuery' => 'airtime/CcStreamSettingQuery.php', + 'Airtime\\CcSubjs' => 'airtime/CcSubjs.php', + 'Airtime\\CcSubjsPeer' => 'airtime/CcSubjsPeer.php', + 'Airtime\\CcSubjsQuery' => 'airtime/CcSubjsQuery.php', + 'Airtime\\CcSubjsToken' => 'airtime/CcSubjsToken.php', + 'Airtime\\CcSubjsTokenPeer' => 'airtime/CcSubjsTokenPeer.php', + 'Airtime\\CcSubjsTokenQuery' => 'airtime/CcSubjsTokenQuery.php', + 'Airtime\\CcTimestamp' => 'airtime/CcTimestamp.php', + 'Airtime\\CcTimestampPeer' => 'airtime/CcTimestampPeer.php', + 'Airtime\\CcTimestampQuery' => 'airtime/CcTimestampQuery.php', + 'Airtime\\CcWebstream' => 'airtime/CcWebstream.php', + 'Airtime\\CcWebstreamMetadata' => 'airtime/CcWebstreamMetadata.php', + 'Airtime\\CcWebstreamMetadataPeer' => 'airtime/CcWebstreamMetadataPeer.php', + 'Airtime\\CcWebstreamMetadataQuery' => 'airtime/CcWebstreamMetadataQuery.php', + 'Airtime\\CcWebstreamPeer' => 'airtime/CcWebstreamPeer.php', + 'Airtime\\CcWebstreamQuery' => 'airtime/CcWebstreamQuery.php', + 'Airtime\\MediaItem' => 'airtime/MediaItem.php', + 'Airtime\\MediaItemPeer' => 'airtime/MediaItemPeer.php', + 'Airtime\\MediaItemQuery' => 'airtime/MediaItemQuery.php', + 'Airtime\\MediaItem\\AudioFile' => 'airtime/AudioFile.php', + 'Airtime\\MediaItem\\AudioFilePeer' => 'airtime/AudioFilePeer.php', + 'Airtime\\MediaItem\\AudioFileQuery' => 'airtime/AudioFileQuery.php', + 'Airtime\\MediaItem\\Block' => 'airtime/Block.php', + 'Airtime\\MediaItem\\BlockPeer' => 'airtime/BlockPeer.php', + 'Airtime\\MediaItem\\BlockQuery' => 'airtime/BlockQuery.php', + 'Airtime\\MediaItem\\MediaContents' => 'airtime/MediaContents.php', + 'Airtime\\MediaItem\\MediaContentsPeer' => 'airtime/MediaContentsPeer.php', + 'Airtime\\MediaItem\\MediaContentsQuery' => 'airtime/MediaContentsQuery.php', + 'Airtime\\MediaItem\\Playlist' => 'airtime/Playlist.php', + 'Airtime\\MediaItem\\PlaylistPeer' => 'airtime/PlaylistPeer.php', + 'Airtime\\MediaItem\\PlaylistQuery' => 'airtime/PlaylistQuery.php', + 'Airtime\\MediaItem\\Webstream' => 'airtime/Webstream.php', + 'Airtime\\MediaItem\\WebstreamPeer' => 'airtime/WebstreamPeer.php', + 'Airtime\\MediaItem\\WebstreamQuery' => 'airtime/WebstreamQuery.php', + 'Airtime\\MediaItem\\map\\AudioFileTableMap' => 'airtime/map/AudioFileTableMap.php', + 'Airtime\\MediaItem\\map\\BlockTableMap' => 'airtime/map/BlockTableMap.php', + 'Airtime\\MediaItem\\map\\MediaContentsTableMap' => 'airtime/map/MediaContentsTableMap.php', + 'Airtime\\MediaItem\\map\\PlaylistTableMap' => 'airtime/map/PlaylistTableMap.php', + 'Airtime\\MediaItem\\map\\WebstreamTableMap' => 'airtime/map/WebstreamTableMap.php', + 'Airtime\\MediaItem\\om\\BaseAudioFile' => 'airtime/om/BaseAudioFile.php', + 'Airtime\\MediaItem\\om\\BaseAudioFilePeer' => 'airtime/om/BaseAudioFilePeer.php', + 'Airtime\\MediaItem\\om\\BaseAudioFileQuery' => 'airtime/om/BaseAudioFileQuery.php', + 'Airtime\\MediaItem\\om\\BaseBlock' => 'airtime/om/BaseBlock.php', + 'Airtime\\MediaItem\\om\\BaseBlockPeer' => 'airtime/om/BaseBlockPeer.php', + 'Airtime\\MediaItem\\om\\BaseBlockQuery' => 'airtime/om/BaseBlockQuery.php', + 'Airtime\\MediaItem\\om\\BaseMediaContents' => 'airtime/om/BaseMediaContents.php', + 'Airtime\\MediaItem\\om\\BaseMediaContentsPeer' => 'airtime/om/BaseMediaContentsPeer.php', + 'Airtime\\MediaItem\\om\\BaseMediaContentsQuery' => 'airtime/om/BaseMediaContentsQuery.php', + 'Airtime\\MediaItem\\om\\BasePlaylist' => 'airtime/om/BasePlaylist.php', + 'Airtime\\MediaItem\\om\\BasePlaylistPeer' => 'airtime/om/BasePlaylistPeer.php', + 'Airtime\\MediaItem\\om\\BasePlaylistQuery' => 'airtime/om/BasePlaylistQuery.php', + 'Airtime\\MediaItem\\om\\BaseWebstream' => 'airtime/om/BaseWebstream.php', + 'Airtime\\MediaItem\\om\\BaseWebstreamPeer' => 'airtime/om/BaseWebstreamPeer.php', + 'Airtime\\MediaItem\\om\\BaseWebstreamQuery' => 'airtime/om/BaseWebstreamQuery.php', + 'Airtime\\PlayoutHistory\\CcPlayoutHistory' => 'airtime/CcPlayoutHistory.php', + 'Airtime\\PlayoutHistory\\CcPlayoutHistoryMetaData' => 'airtime/CcPlayoutHistoryMetaData.php', + 'Airtime\\PlayoutHistory\\CcPlayoutHistoryMetaDataPeer' => 'airtime/CcPlayoutHistoryMetaDataPeer.php', + 'Airtime\\PlayoutHistory\\CcPlayoutHistoryMetaDataQuery' => 'airtime/CcPlayoutHistoryMetaDataQuery.php', + 'Airtime\\PlayoutHistory\\CcPlayoutHistoryPeer' => 'airtime/CcPlayoutHistoryPeer.php', + 'Airtime\\PlayoutHistory\\CcPlayoutHistoryQuery' => 'airtime/CcPlayoutHistoryQuery.php', + 'Airtime\\PlayoutHistory\\CcPlayoutHistoryTemplate' => 'airtime/CcPlayoutHistoryTemplate.php', + 'Airtime\\PlayoutHistory\\CcPlayoutHistoryTemplateField' => 'airtime/CcPlayoutHistoryTemplateField.php', + 'Airtime\\PlayoutHistory\\CcPlayoutHistoryTemplateFieldPeer' => 'airtime/CcPlayoutHistoryTemplateFieldPeer.php', + 'Airtime\\PlayoutHistory\\CcPlayoutHistoryTemplateFieldQuery' => 'airtime/CcPlayoutHistoryTemplateFieldQuery.php', + 'Airtime\\PlayoutHistory\\CcPlayoutHistoryTemplatePeer' => 'airtime/CcPlayoutHistoryTemplatePeer.php', + 'Airtime\\PlayoutHistory\\CcPlayoutHistoryTemplateQuery' => 'airtime/CcPlayoutHistoryTemplateQuery.php', + 'Airtime\\PlayoutHistory\\map\\CcPlayoutHistoryMetaDataTableMap' => 'airtime/map/CcPlayoutHistoryMetaDataTableMap.php', + 'Airtime\\PlayoutHistory\\map\\CcPlayoutHistoryTableMap' => 'airtime/map/CcPlayoutHistoryTableMap.php', + 'Airtime\\PlayoutHistory\\map\\CcPlayoutHistoryTemplateFieldTableMap' => 'airtime/map/CcPlayoutHistoryTemplateFieldTableMap.php', + 'Airtime\\PlayoutHistory\\map\\CcPlayoutHistoryTemplateTableMap' => 'airtime/map/CcPlayoutHistoryTemplateTableMap.php', + 'Airtime\\PlayoutHistory\\om\\BaseCcPlayoutHistory' => 'airtime/om/BaseCcPlayoutHistory.php', + 'Airtime\\PlayoutHistory\\om\\BaseCcPlayoutHistoryMetaData' => 'airtime/om/BaseCcPlayoutHistoryMetaData.php', + 'Airtime\\PlayoutHistory\\om\\BaseCcPlayoutHistoryMetaDataPeer' => 'airtime/om/BaseCcPlayoutHistoryMetaDataPeer.php', + 'Airtime\\PlayoutHistory\\om\\BaseCcPlayoutHistoryMetaDataQuery' => 'airtime/om/BaseCcPlayoutHistoryMetaDataQuery.php', + 'Airtime\\PlayoutHistory\\om\\BaseCcPlayoutHistoryPeer' => 'airtime/om/BaseCcPlayoutHistoryPeer.php', + 'Airtime\\PlayoutHistory\\om\\BaseCcPlayoutHistoryQuery' => 'airtime/om/BaseCcPlayoutHistoryQuery.php', + 'Airtime\\PlayoutHistory\\om\\BaseCcPlayoutHistoryTemplate' => 'airtime/om/BaseCcPlayoutHistoryTemplate.php', + 'Airtime\\PlayoutHistory\\om\\BaseCcPlayoutHistoryTemplateField' => 'airtime/om/BaseCcPlayoutHistoryTemplateField.php', + 'Airtime\\PlayoutHistory\\om\\BaseCcPlayoutHistoryTemplateFieldPeer' => 'airtime/om/BaseCcPlayoutHistoryTemplateFieldPeer.php', + 'Airtime\\PlayoutHistory\\om\\BaseCcPlayoutHistoryTemplateFieldQuery' => 'airtime/om/BaseCcPlayoutHistoryTemplateFieldQuery.php', + 'Airtime\\PlayoutHistory\\om\\BaseCcPlayoutHistoryTemplatePeer' => 'airtime/om/BaseCcPlayoutHistoryTemplatePeer.php', + 'Airtime\\PlayoutHistory\\om\\BaseCcPlayoutHistoryTemplateQuery' => 'airtime/om/BaseCcPlayoutHistoryTemplateQuery.php', + 'Airtime\\map\\CcBlockTableMap' => 'airtime/map/CcBlockTableMap.php', + 'Airtime\\map\\CcBlockcontentsTableMap' => 'airtime/map/CcBlockcontentsTableMap.php', + 'Airtime\\map\\CcBlockcriteriaTableMap' => 'airtime/map/CcBlockcriteriaTableMap.php', + 'Airtime\\map\\CcCountryTableMap' => 'airtime/map/CcCountryTableMap.php', + 'Airtime\\map\\CcFilesTableMap' => 'airtime/map/CcFilesTableMap.php', + 'Airtime\\map\\CcListenerCountTableMap' => 'airtime/map/CcListenerCountTableMap.php', + 'Airtime\\map\\CcLiveLogTableMap' => 'airtime/map/CcLiveLogTableMap.php', + 'Airtime\\map\\CcLocaleTableMap' => 'airtime/map/CcLocaleTableMap.php', + 'Airtime\\map\\CcLoginAttemptsTableMap' => 'airtime/map/CcLoginAttemptsTableMap.php', + 'Airtime\\map\\CcMountNameTableMap' => 'airtime/map/CcMountNameTableMap.php', + 'Airtime\\map\\CcMusicDirsTableMap' => 'airtime/map/CcMusicDirsTableMap.php', + 'Airtime\\map\\CcPlaylistTableMap' => 'airtime/map/CcPlaylistTableMap.php', + 'Airtime\\map\\CcPlaylistcontentsTableMap' => 'airtime/map/CcPlaylistcontentsTableMap.php', + 'Airtime\\map\\CcPrefTableMap' => 'airtime/map/CcPrefTableMap.php', + 'Airtime\\map\\CcScheduleTableMap' => 'airtime/map/CcScheduleTableMap.php', + 'Airtime\\map\\CcServiceRegisterTableMap' => 'airtime/map/CcServiceRegisterTableMap.php', + 'Airtime\\map\\CcShowDaysTableMap' => 'airtime/map/CcShowDaysTableMap.php', + 'Airtime\\map\\CcShowHostsTableMap' => 'airtime/map/CcShowHostsTableMap.php', + 'Airtime\\map\\CcShowInstancesTableMap' => 'airtime/map/CcShowInstancesTableMap.php', + 'Airtime\\map\\CcShowRebroadcastTableMap' => 'airtime/map/CcShowRebroadcastTableMap.php', + 'Airtime\\map\\CcShowTableMap' => 'airtime/map/CcShowTableMap.php', + 'Airtime\\map\\CcStreamSettingTableMap' => 'airtime/map/CcStreamSettingTableMap.php', + 'Airtime\\map\\CcSubjsTableMap' => 'airtime/map/CcSubjsTableMap.php', + 'Airtime\\map\\CcSubjsTokenTableMap' => 'airtime/map/CcSubjsTokenTableMap.php', + 'Airtime\\map\\CcTimestampTableMap' => 'airtime/map/CcTimestampTableMap.php', + 'Airtime\\map\\CcWebstreamMetadataTableMap' => 'airtime/map/CcWebstreamMetadataTableMap.php', + 'Airtime\\map\\CcWebstreamTableMap' => 'airtime/map/CcWebstreamTableMap.php', + 'Airtime\\map\\MediaItemTableMap' => 'airtime/map/MediaItemTableMap.php', + 'Airtime\\om\\BaseCcBlock' => 'airtime/om/BaseCcBlock.php', + 'Airtime\\om\\BaseCcBlockPeer' => 'airtime/om/BaseCcBlockPeer.php', + 'Airtime\\om\\BaseCcBlockQuery' => 'airtime/om/BaseCcBlockQuery.php', + 'Airtime\\om\\BaseCcBlockcontents' => 'airtime/om/BaseCcBlockcontents.php', + 'Airtime\\om\\BaseCcBlockcontentsPeer' => 'airtime/om/BaseCcBlockcontentsPeer.php', + 'Airtime\\om\\BaseCcBlockcontentsQuery' => 'airtime/om/BaseCcBlockcontentsQuery.php', + 'Airtime\\om\\BaseCcBlockcriteria' => 'airtime/om/BaseCcBlockcriteria.php', + 'Airtime\\om\\BaseCcBlockcriteriaPeer' => 'airtime/om/BaseCcBlockcriteriaPeer.php', + 'Airtime\\om\\BaseCcBlockcriteriaQuery' => 'airtime/om/BaseCcBlockcriteriaQuery.php', + 'Airtime\\om\\BaseCcCountry' => 'airtime/om/BaseCcCountry.php', + 'Airtime\\om\\BaseCcCountryPeer' => 'airtime/om/BaseCcCountryPeer.php', + 'Airtime\\om\\BaseCcCountryQuery' => 'airtime/om/BaseCcCountryQuery.php', + 'Airtime\\om\\BaseCcFiles' => 'airtime/om/BaseCcFiles.php', + 'Airtime\\om\\BaseCcFilesPeer' => 'airtime/om/BaseCcFilesPeer.php', + 'Airtime\\om\\BaseCcFilesQuery' => 'airtime/om/BaseCcFilesQuery.php', + 'Airtime\\om\\BaseCcListenerCount' => 'airtime/om/BaseCcListenerCount.php', + 'Airtime\\om\\BaseCcListenerCountPeer' => 'airtime/om/BaseCcListenerCountPeer.php', + 'Airtime\\om\\BaseCcListenerCountQuery' => 'airtime/om/BaseCcListenerCountQuery.php', + 'Airtime\\om\\BaseCcLiveLog' => 'airtime/om/BaseCcLiveLog.php', + 'Airtime\\om\\BaseCcLiveLogPeer' => 'airtime/om/BaseCcLiveLogPeer.php', + 'Airtime\\om\\BaseCcLiveLogQuery' => 'airtime/om/BaseCcLiveLogQuery.php', + 'Airtime\\om\\BaseCcLocale' => 'airtime/om/BaseCcLocale.php', + 'Airtime\\om\\BaseCcLocalePeer' => 'airtime/om/BaseCcLocalePeer.php', + 'Airtime\\om\\BaseCcLocaleQuery' => 'airtime/om/BaseCcLocaleQuery.php', + 'Airtime\\om\\BaseCcLoginAttempts' => 'airtime/om/BaseCcLoginAttempts.php', + 'Airtime\\om\\BaseCcLoginAttemptsPeer' => 'airtime/om/BaseCcLoginAttemptsPeer.php', + 'Airtime\\om\\BaseCcLoginAttemptsQuery' => 'airtime/om/BaseCcLoginAttemptsQuery.php', + 'Airtime\\om\\BaseCcMountName' => 'airtime/om/BaseCcMountName.php', + 'Airtime\\om\\BaseCcMountNamePeer' => 'airtime/om/BaseCcMountNamePeer.php', + 'Airtime\\om\\BaseCcMountNameQuery' => 'airtime/om/BaseCcMountNameQuery.php', + 'Airtime\\om\\BaseCcMusicDirs' => 'airtime/om/BaseCcMusicDirs.php', + 'Airtime\\om\\BaseCcMusicDirsPeer' => 'airtime/om/BaseCcMusicDirsPeer.php', + 'Airtime\\om\\BaseCcMusicDirsQuery' => 'airtime/om/BaseCcMusicDirsQuery.php', + 'Airtime\\om\\BaseCcPlaylist' => 'airtime/om/BaseCcPlaylist.php', + 'Airtime\\om\\BaseCcPlaylistPeer' => 'airtime/om/BaseCcPlaylistPeer.php', + 'Airtime\\om\\BaseCcPlaylistQuery' => 'airtime/om/BaseCcPlaylistQuery.php', + 'Airtime\\om\\BaseCcPlaylistcontents' => 'airtime/om/BaseCcPlaylistcontents.php', + 'Airtime\\om\\BaseCcPlaylistcontentsPeer' => 'airtime/om/BaseCcPlaylistcontentsPeer.php', + 'Airtime\\om\\BaseCcPlaylistcontentsQuery' => 'airtime/om/BaseCcPlaylistcontentsQuery.php', + 'Airtime\\om\\BaseCcPref' => 'airtime/om/BaseCcPref.php', + 'Airtime\\om\\BaseCcPrefPeer' => 'airtime/om/BaseCcPrefPeer.php', + 'Airtime\\om\\BaseCcPrefQuery' => 'airtime/om/BaseCcPrefQuery.php', + 'Airtime\\om\\BaseCcSchedule' => 'airtime/om/BaseCcSchedule.php', + 'Airtime\\om\\BaseCcSchedulePeer' => 'airtime/om/BaseCcSchedulePeer.php', + 'Airtime\\om\\BaseCcScheduleQuery' => 'airtime/om/BaseCcScheduleQuery.php', + 'Airtime\\om\\BaseCcServiceRegister' => 'airtime/om/BaseCcServiceRegister.php', + 'Airtime\\om\\BaseCcServiceRegisterPeer' => 'airtime/om/BaseCcServiceRegisterPeer.php', + 'Airtime\\om\\BaseCcServiceRegisterQuery' => 'airtime/om/BaseCcServiceRegisterQuery.php', + 'Airtime\\om\\BaseCcShow' => 'airtime/om/BaseCcShow.php', + 'Airtime\\om\\BaseCcShowDays' => 'airtime/om/BaseCcShowDays.php', + 'Airtime\\om\\BaseCcShowDaysPeer' => 'airtime/om/BaseCcShowDaysPeer.php', + 'Airtime\\om\\BaseCcShowDaysQuery' => 'airtime/om/BaseCcShowDaysQuery.php', + 'Airtime\\om\\BaseCcShowHosts' => 'airtime/om/BaseCcShowHosts.php', + 'Airtime\\om\\BaseCcShowHostsPeer' => 'airtime/om/BaseCcShowHostsPeer.php', + 'Airtime\\om\\BaseCcShowHostsQuery' => 'airtime/om/BaseCcShowHostsQuery.php', + 'Airtime\\om\\BaseCcShowInstances' => 'airtime/om/BaseCcShowInstances.php', + 'Airtime\\om\\BaseCcShowInstancesPeer' => 'airtime/om/BaseCcShowInstancesPeer.php', + 'Airtime\\om\\BaseCcShowInstancesQuery' => 'airtime/om/BaseCcShowInstancesQuery.php', + 'Airtime\\om\\BaseCcShowPeer' => 'airtime/om/BaseCcShowPeer.php', + 'Airtime\\om\\BaseCcShowQuery' => 'airtime/om/BaseCcShowQuery.php', + 'Airtime\\om\\BaseCcShowRebroadcast' => 'airtime/om/BaseCcShowRebroadcast.php', + 'Airtime\\om\\BaseCcShowRebroadcastPeer' => 'airtime/om/BaseCcShowRebroadcastPeer.php', + 'Airtime\\om\\BaseCcShowRebroadcastQuery' => 'airtime/om/BaseCcShowRebroadcastQuery.php', + 'Airtime\\om\\BaseCcStreamSetting' => 'airtime/om/BaseCcStreamSetting.php', + 'Airtime\\om\\BaseCcStreamSettingPeer' => 'airtime/om/BaseCcStreamSettingPeer.php', + 'Airtime\\om\\BaseCcStreamSettingQuery' => 'airtime/om/BaseCcStreamSettingQuery.php', + 'Airtime\\om\\BaseCcSubjs' => 'airtime/om/BaseCcSubjs.php', + 'Airtime\\om\\BaseCcSubjsPeer' => 'airtime/om/BaseCcSubjsPeer.php', + 'Airtime\\om\\BaseCcSubjsQuery' => 'airtime/om/BaseCcSubjsQuery.php', + 'Airtime\\om\\BaseCcSubjsToken' => 'airtime/om/BaseCcSubjsToken.php', + 'Airtime\\om\\BaseCcSubjsTokenPeer' => 'airtime/om/BaseCcSubjsTokenPeer.php', + 'Airtime\\om\\BaseCcSubjsTokenQuery' => 'airtime/om/BaseCcSubjsTokenQuery.php', + 'Airtime\\om\\BaseCcTimestamp' => 'airtime/om/BaseCcTimestamp.php', + 'Airtime\\om\\BaseCcTimestampPeer' => 'airtime/om/BaseCcTimestampPeer.php', + 'Airtime\\om\\BaseCcTimestampQuery' => 'airtime/om/BaseCcTimestampQuery.php', + 'Airtime\\om\\BaseCcWebstream' => 'airtime/om/BaseCcWebstream.php', + 'Airtime\\om\\BaseCcWebstreamMetadata' => 'airtime/om/BaseCcWebstreamMetadata.php', + 'Airtime\\om\\BaseCcWebstreamMetadataPeer' => 'airtime/om/BaseCcWebstreamMetadataPeer.php', + 'Airtime\\om\\BaseCcWebstreamMetadataQuery' => 'airtime/om/BaseCcWebstreamMetadataQuery.php', + 'Airtime\\om\\BaseCcWebstreamPeer' => 'airtime/om/BaseCcWebstreamPeer.php', + 'Airtime\\om\\BaseCcWebstreamQuery' => 'airtime/om/BaseCcWebstreamQuery.php', + 'Airtime\\om\\BaseMediaItem' => 'airtime/om/BaseMediaItem.php', + 'Airtime\\om\\BaseMediaItemPeer' => 'airtime/om/BaseMediaItemPeer.php', + 'Airtime\\om\\BaseMediaItemQuery' => 'airtime/om/BaseMediaItemQuery.php', ); \ No newline at end of file diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 674e5cf23..57dc33067 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -1,5 +1,10 @@ setName('audio_file'); + $this->setPhpName('AudioFile'); + $this->setClassname('Airtime\\MediaItem\\AudioFile'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(false); + // columns + $this->addColumn('mime', 'Mime', 'VARCHAR', false, null, null); + $this->addForeignKey('directory', 'Directory', 'INTEGER', 'cc_music_dirs', 'id', false, null, null); + $this->addColumn('filepath', 'Filepath', 'LONGVARCHAR', false, 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', 'INTEGER', false, null, null); + $this->addColumn('sample_rate', 'SampleRate', 'INTEGER', 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', 'INTEGER', false, null, null); + $this->addColumn('encoded_by', 'EncodedBy', 'VARCHAR', false, 255, 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('copyright', 'Copyright', 'VARCHAR', false, 512, null); + $this->addColumn('isrc_number', 'IsrcNumber', 'VARCHAR', false, 512, null); + $this->addColumn('info_url', 'InfoUrl', 'VARCHAR', false, 512, null); + $this->addColumn('language', 'Language', 'VARCHAR', false, 512, null); + $this->addColumn('replay_gain', 'ReplayGain', 'NUMERIC', false, null, null); + $this->addColumn('cuein', 'Cuein', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('cueout', 'Cueout', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('silan_check', 'IsSilanChecked', 'BOOLEAN', false, null, false); + $this->addColumn('file_exists', 'FileExists', 'BOOLEAN', false, null, true); + $this->addColumn('hidden', 'IsHidden', 'BOOLEAN', false, null, false); + $this->addColumn('is_scheduled', 'IsScheduled', 'BOOLEAN', false, null, false); + $this->addColumn('is_playlist', 'IsPlaylist', 'BOOLEAN', false, null, false); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'media_item', 'id', true, null, null); + $this->addColumn('name', 'Name', 'VARCHAR', true, 128, null); + $this->addForeignKey('owner_id', 'OwnerId', 'INTEGER', 'cc_subjs', 'id', false, null, null); + $this->addColumn('description', 'Description', 'VARCHAR', false, 512, null); + $this->addColumn('last_played', 'LastPlayedTime', 'TIMESTAMP', false, 6, null); + $this->addColumn('play_count', 'PlayCount', 'INTEGER', false, null, 0); + $this->addColumn('length', 'Length', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcMusicDirs', 'Airtime\\CcMusicDirs', RelationMap::MANY_TO_ONE, array('directory' => 'id', ), null, null); + $this->addRelation('MediaItem', 'Airtime\\MediaItem', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcSubjs', 'Airtime\\CcSubjs', RelationMap::MANY_TO_ONE, array('owner_id' => 'id', ), null, null); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'concrete_inheritance' => array ( + 'extends' => 'media_item', + 'descendant_column' => 'descendant_class', + 'copy_data_to_parent' => 'true', + 'schema' => '', + 'excluded_parent_behavior' => 'nested_set', +), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + ); + } // getBehaviors() + +} // AudioFileTableMap diff --git a/airtime_mvc/application/models/airtime/map/BlockTableMap.php b/airtime_mvc/application/models/airtime/map/BlockTableMap.php new file mode 100644 index 000000000..35b1c9481 --- /dev/null +++ b/airtime_mvc/application/models/airtime/map/BlockTableMap.php @@ -0,0 +1,93 @@ +setName('block'); + $this->setPhpName('Block'); + $this->setClassname('Airtime\\MediaItem\\Block'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(false); + // columns + $this->addColumn('type', 'Type', 'VARCHAR', false, 7, 'static'); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'playlist', 'id', true, null, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'media_item', 'id', true, null, null); + $this->addColumn('name', 'Name', 'VARCHAR', true, 128, null); + $this->addForeignKey('owner_id', 'OwnerId', 'INTEGER', 'cc_subjs', 'id', false, null, null); + $this->addColumn('description', 'Description', 'VARCHAR', false, 512, null); + $this->addColumn('last_played', 'LastPlayedTime', 'TIMESTAMP', false, 6, null); + $this->addColumn('play_count', 'PlayCount', 'INTEGER', false, null, 0); + $this->addColumn('length', 'Length', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Playlist', 'Airtime\\MediaItem\\Playlist', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + $this->addRelation('MediaItem', 'Airtime\\MediaItem', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcSubjs', 'Airtime\\CcSubjs', RelationMap::MANY_TO_ONE, array('owner_id' => 'id', ), null, null); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'concrete_inheritance' => array ( + 'extends' => 'playlist', + 'descendant_column' => 'descendant_class', + 'copy_data_to_parent' => 'true', + 'schema' => '', + 'excluded_parent_behavior' => 'nested_set', +), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + ); + } // getBehaviors() + +} // BlockTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcBlockTableMap.php b/airtime_mvc/application/models/airtime/map/CcBlockTableMap.php index 0ce86613c..300bf782a 100644 --- a/airtime_mvc/application/models/airtime/map/CcBlockTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcBlockTableMap.php @@ -1,5 +1,9 @@ setName('cc_block'); - $this->setPhpName('CcBlock'); - $this->setClassname('CcBlock'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_block_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addColumn('NAME', 'DbName', 'VARCHAR', true, 255, ''); - $this->addColumn('MTIME', 'DbMtime', 'TIMESTAMP', false, 6, null); - $this->addColumn('UTIME', 'DbUtime', 'TIMESTAMP', false, 6, null); - $this->addForeignKey('CREATOR_ID', 'DbCreatorId', 'INTEGER', 'cc_subjs', 'ID', false, null, null); - $this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null); - $this->addColumn('LENGTH', 'DbLength', 'VARCHAR', false, null, '00:00:00'); - $this->addColumn('TYPE', 'DbType', 'VARCHAR', false, 7, 'static'); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_block'); + $this->setPhpName('CcBlock'); + $this->setClassname('Airtime\\CcBlock'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_block_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addColumn('name', 'DbName', 'VARCHAR', true, 255, ''); + $this->addColumn('mtime', 'DbMtime', 'TIMESTAMP', false, 6, null); + $this->addColumn('utime', 'DbUtime', 'TIMESTAMP', false, 6, null); + $this->addForeignKey('creator_id', 'DbCreatorId', 'INTEGER', 'cc_subjs', 'id', false, null, null); + $this->addColumn('description', 'DbDescription', 'VARCHAR', false, 512, null); + $this->addColumn('length', 'DbLength', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('type', 'DbType', 'VARCHAR', false, 7, 'static'); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('creator_id' => 'id', ), 'CASCADE', null); - $this->addRelation('CcPlaylistcontents', 'CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'block_id', ), 'CASCADE', null); - $this->addRelation('CcBlockcontents', 'CcBlockcontents', RelationMap::ONE_TO_MANY, array('id' => 'block_id', ), 'CASCADE', null); - $this->addRelation('CcBlockcriteria', 'CcBlockcriteria', RelationMap::ONE_TO_MANY, array('id' => 'block_id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcSubjs', 'Airtime\\CcSubjs', RelationMap::MANY_TO_ONE, array('creator_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcPlaylistcontents', 'Airtime\\CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'block_id', ), 'CASCADE', null, 'CcPlaylistcontentss'); + $this->addRelation('CcBlockcontents', 'Airtime\\CcBlockcontents', RelationMap::ONE_TO_MANY, array('id' => 'block_id', ), 'CASCADE', null, 'CcBlockcontentss'); + $this->addRelation('CcBlockcriteria', 'Airtime\\CcBlockcriteria', RelationMap::ONE_TO_MANY, array('id' => 'block_id', ), 'CASCADE', null, 'CcBlockcriterias'); + } // buildRelations() - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'aggregate_column' => array('name' => 'length', 'expression' => 'SUM(cliplength)', 'foreign_table' => 'cc_blockcontents', ), - ); - } // getBehaviors() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'aggregate_column' => array ( + 'name' => 'length', + 'expression' => 'SUM(cliplength)', + 'condition' => NULL, + 'foreign_table' => 'cc_blockcontents', + 'foreign_schema' => NULL, +), + ); + } // getBehaviors() } // CcBlockTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcBlockcontentsTableMap.php b/airtime_mvc/application/models/airtime/map/CcBlockcontentsTableMap.php index ec74e8b7e..9b5c8344e 100644 --- a/airtime_mvc/application/models/airtime/map/CcBlockcontentsTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcBlockcontentsTableMap.php @@ -1,5 +1,9 @@ setName('cc_blockcontents'); - $this->setPhpName('CcBlockcontents'); - $this->setClassname('CcBlockcontents'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_blockcontents_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addForeignKey('BLOCK_ID', 'DbBlockId', 'INTEGER', 'cc_block', '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('TRACKOFFSET', 'DbTrackOffset', 'REAL', true, null, 0); - $this->addColumn('CLIPLENGTH', 'DbCliplength', 'VARCHAR', false, null, '00:00:00'); - $this->addColumn('CUEIN', 'DbCuein', 'VARCHAR', false, null, '00:00:00'); - $this->addColumn('CUEOUT', 'DbCueout', 'VARCHAR', 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() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_blockcontents'); + $this->setPhpName('CcBlockcontents'); + $this->setClassname('Airtime\\CcBlockcontents'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_blockcontents_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addForeignKey('block_id', 'DbBlockId', 'INTEGER', 'cc_block', '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('trackoffset', 'DbTrackOffset', 'REAL', true, null, 0); + $this->addColumn('cliplength', 'DbCliplength', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('cuein', 'DbCuein', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('cueout', 'DbCueout', 'VARCHAR', 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('CcBlock', 'CcBlock', RelationMap::MANY_TO_ONE, array('block_id' => 'id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcFiles', 'Airtime\\CcFiles', RelationMap::MANY_TO_ONE, array('file_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcBlock', 'Airtime\\CcBlock', RelationMap::MANY_TO_ONE, array('block_id' => 'id', ), 'CASCADE', null); + } // buildRelations() - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'aggregate_column_relation' => array('foreign_table' => 'cc_block', 'update_method' => 'updateDbLength', ), - ); - } // getBehaviors() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'aggregate_column_relation' => array ( + 'foreign_table' => 'cc_block', + 'update_method' => 'updateDbLength', +), + ); + } // getBehaviors() } // CcBlockcontentsTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcBlockcriteriaTableMap.php b/airtime_mvc/application/models/airtime/map/CcBlockcriteriaTableMap.php index 6565bf259..5d33ec311 100644 --- a/airtime_mvc/application/models/airtime/map/CcBlockcriteriaTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcBlockcriteriaTableMap.php @@ -1,5 +1,9 @@ setName('cc_blockcriteria'); - $this->setPhpName('CcBlockcriteria'); - $this->setClassname('CcBlockcriteria'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_blockcriteria_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addColumn('CRITERIA', 'DbCriteria', 'VARCHAR', true, 32, null); - $this->addColumn('MODIFIER', 'DbModifier', 'VARCHAR', true, 16, null); - $this->addColumn('VALUE', 'DbValue', 'VARCHAR', true, 512, null); - $this->addColumn('EXTRA', 'DbExtra', 'VARCHAR', false, 512, null); - $this->addForeignKey('BLOCK_ID', 'DbBlockId', 'INTEGER', 'cc_block', 'ID', true, null, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_blockcriteria'); + $this->setPhpName('CcBlockcriteria'); + $this->setClassname('Airtime\\CcBlockcriteria'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_blockcriteria_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addColumn('criteria', 'DbCriteria', 'VARCHAR', true, 32, null); + $this->addColumn('modifier', 'DbModifier', 'VARCHAR', true, 16, null); + $this->addColumn('value', 'DbValue', 'VARCHAR', true, 512, null); + $this->addColumn('extra', 'DbExtra', 'VARCHAR', false, 512, null); + $this->addForeignKey('block_id', 'DbBlockId', 'INTEGER', 'cc_block', 'id', true, null, null); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcBlock', 'CcBlock', RelationMap::MANY_TO_ONE, array('block_id' => 'id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcBlock', 'Airtime\\CcBlock', RelationMap::MANY_TO_ONE, array('block_id' => 'id', ), 'CASCADE', null); + } // buildRelations() } // CcBlockcriteriaTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcCountryTableMap.php b/airtime_mvc/application/models/airtime/map/CcCountryTableMap.php index b839d0359..970c43293 100644 --- a/airtime_mvc/application/models/airtime/map/CcCountryTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcCountryTableMap.php @@ -1,5 +1,9 @@ setName('cc_country'); - $this->setPhpName('CcCountry'); - $this->setClassname('CcCountry'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(false); - // columns - $this->addPrimaryKey('ISOCODE', 'DbIsoCode', 'CHAR', true, 3, null); - $this->addColumn('NAME', 'DbName', 'VARCHAR', true, 255, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_country'); + $this->setPhpName('CcCountry'); + $this->setClassname('Airtime\\CcCountry'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(false); + // columns + $this->addPrimaryKey('isocode', 'DbIsoCode', 'CHAR', true, 3, null); + $this->addColumn('name', 'DbName', 'VARCHAR', true, 255, null); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() } // CcCountryTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php b/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php index 6f9f414dd..1ad77f333 100644 --- a/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php @@ -1,5 +1,9 @@ setName('cc_files'); - $this->setPhpName('CcFiles'); - $this->setClassname('CcFiles'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_files_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addColumn('NAME', 'DbName', 'VARCHAR', true, 255, ''); - $this->addColumn('MIME', 'DbMime', 'VARCHAR', true, 255, ''); - $this->addColumn('FTYPE', 'DbFtype', 'VARCHAR', true, 128, ''); - $this->addForeignKey('DIRECTORY', 'DbDirectory', 'INTEGER', 'cc_music_dirs', 'ID', false, null, null); - $this->addColumn('FILEPATH', 'DbFilepath', 'LONGVARCHAR', false, null, ''); - $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('UTIME', 'DbUtime', 'TIMESTAMP', false, 6, null); - $this->addColumn('LPTIME', 'DbLPtime', 'TIMESTAMP', false, 6, null); - $this->addColumn('MD5', 'DbMd5', 'CHAR', false, 32, null); - $this->addColumn('TRACK_TITLE', 'DbTrackTitle', 'VARCHAR', false, 512, null); - $this->addColumn('ARTIST_NAME', 'DbArtistName', 'VARCHAR', false, 512, null); - $this->addColumn('BIT_RATE', 'DbBitRate', 'INTEGER', false, null, null); - $this->addColumn('SAMPLE_RATE', 'DbSampleRate', 'INTEGER', false, null, null); - $this->addColumn('FORMAT', 'DbFormat', 'VARCHAR', false, 128, null); - $this->addColumn('LENGTH', 'DbLength', 'VARCHAR', false, null, '00:00:00'); - $this->addColumn('ALBUM_TITLE', 'DbAlbumTitle', 'VARCHAR', false, 512, null); - $this->addColumn('GENRE', 'DbGenre', 'VARCHAR', false, 64, null); - $this->addColumn('COMMENTS', 'DbComments', 'LONGVARCHAR', false, null, null); - $this->addColumn('YEAR', 'DbYear', 'VARCHAR', false, 16, null); - $this->addColumn('TRACK_NUMBER', 'DbTrackNumber', 'INTEGER', false, null, null); - $this->addColumn('CHANNELS', 'DbChannels', 'INTEGER', false, null, null); - $this->addColumn('URL', 'DbUrl', 'VARCHAR', false, 1024, null); - $this->addColumn('BPM', 'DbBpm', 'INTEGER', false, null, null); - $this->addColumn('RATING', 'DbRating', 'VARCHAR', false, 8, null); - $this->addColumn('ENCODED_BY', 'DbEncodedBy', 'VARCHAR', false, 255, null); - $this->addColumn('DISC_NUMBER', 'DbDiscNumber', 'VARCHAR', false, 8, null); - $this->addColumn('MOOD', 'DbMood', 'VARCHAR', false, 64, null); - $this->addColumn('LABEL', 'DbLabel', 'VARCHAR', false, 512, null); - $this->addColumn('COMPOSER', 'DbComposer', 'VARCHAR', false, 512, null); - $this->addColumn('ENCODER', 'DbEncoder', 'VARCHAR', false, 64, null); - $this->addColumn('CHECKSUM', 'DbChecksum', 'VARCHAR', false, 256, null); - $this->addColumn('LYRICS', 'DbLyrics', 'LONGVARCHAR', false, null, null); - $this->addColumn('ORCHESTRA', 'DbOrchestra', 'VARCHAR', false, 512, null); - $this->addColumn('CONDUCTOR', 'DbConductor', 'VARCHAR', false, 512, null); - $this->addColumn('LYRICIST', 'DbLyricist', 'VARCHAR', false, 512, null); - $this->addColumn('ORIGINAL_LYRICIST', 'DbOriginalLyricist', 'VARCHAR', false, 512, null); - $this->addColumn('RADIO_STATION_NAME', 'DbRadioStationName', 'VARCHAR', false, 512, null); - $this->addColumn('INFO_URL', 'DbInfoUrl', 'VARCHAR', false, 512, null); - $this->addColumn('ARTIST_URL', 'DbArtistUrl', 'VARCHAR', false, 512, null); - $this->addColumn('AUDIO_SOURCE_URL', 'DbAudioSourceUrl', 'VARCHAR', false, 512, null); - $this->addColumn('RADIO_STATION_URL', 'DbRadioStationUrl', 'VARCHAR', false, 512, null); - $this->addColumn('BUY_THIS_URL', 'DbBuyThisUrl', 'VARCHAR', false, 512, null); - $this->addColumn('ISRC_NUMBER', 'DbIsrcNumber', 'VARCHAR', false, 512, null); - $this->addColumn('CATALOG_NUMBER', 'DbCatalogNumber', 'VARCHAR', false, 512, null); - $this->addColumn('ORIGINAL_ARTIST', 'DbOriginalArtist', 'VARCHAR', false, 512, null); - $this->addColumn('COPYRIGHT', 'DbCopyright', 'VARCHAR', false, 512, null); - $this->addColumn('REPORT_DATETIME', 'DbReportDatetime', 'VARCHAR', false, 32, null); - $this->addColumn('REPORT_LOCATION', 'DbReportLocation', 'VARCHAR', false, 512, null); - $this->addColumn('REPORT_ORGANIZATION', 'DbReportOrganization', 'VARCHAR', false, 512, null); - $this->addColumn('SUBJECT', 'DbSubject', 'VARCHAR', false, 512, null); - $this->addColumn('CONTRIBUTOR', 'DbContributor', 'VARCHAR', false, 512, null); - $this->addColumn('LANGUAGE', 'DbLanguage', 'VARCHAR', false, 512, null); - $this->addColumn('FILE_EXISTS', 'DbFileExists', 'BOOLEAN', false, null, true); - $this->addColumn('SOUNDCLOUD_ID', 'DbSoundcloudId', 'INTEGER', false, null, null); - $this->addColumn('SOUNDCLOUD_ERROR_CODE', 'DbSoundcloudErrorCode', 'INTEGER', false, null, null); - $this->addColumn('SOUNDCLOUD_ERROR_MSG', 'DbSoundcloudErrorMsg', 'VARCHAR', false, 512, null); - $this->addColumn('SOUNDCLOUD_LINK_TO_FILE', 'DbSoundcloudLinkToFile', 'VARCHAR', false, 4096, null); - $this->addColumn('SOUNDCLOUD_UPLOAD_TIME', 'DbSoundCloundUploadTime', 'TIMESTAMP', false, 6, null); - $this->addColumn('REPLAY_GAIN', 'DbReplayGain', 'NUMERIC', false, null, null); - $this->addForeignKey('OWNER_ID', 'DbOwnerId', 'INTEGER', 'cc_subjs', 'ID', false, null, null); - $this->addColumn('CUEIN', 'DbCuein', 'VARCHAR', false, null, '00:00:00'); - $this->addColumn('CUEOUT', 'DbCueout', 'VARCHAR', false, null, '00:00:00'); - $this->addColumn('SILAN_CHECK', 'DbSilanCheck', 'BOOLEAN', false, null, false); - $this->addColumn('HIDDEN', 'DbHidden', 'BOOLEAN', false, null, false); - $this->addColumn('IS_SCHEDULED', 'DbIsScheduled', 'BOOLEAN', false, null, false); - $this->addColumn('IS_PLAYLIST', 'DbIsPlaylist', 'BOOLEAN', false, null, false); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_files'); + $this->setPhpName('CcFiles'); + $this->setClassname('Airtime\\CcFiles'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_files_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addColumn('name', 'DbName', 'VARCHAR', true, 255, ''); + $this->addColumn('mime', 'DbMime', 'VARCHAR', true, 255, ''); + $this->addColumn('ftype', 'DbFtype', 'VARCHAR', true, 128, ''); + $this->addForeignKey('directory', 'DbDirectory', 'INTEGER', 'cc_music_dirs', 'id', false, null, null); + $this->addColumn('filepath', 'DbFilepath', 'LONGVARCHAR', false, null, ''); + $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('utime', 'DbUtime', 'TIMESTAMP', false, 6, null); + $this->addColumn('lptime', 'DbLPtime', 'TIMESTAMP', false, 6, null); + $this->addColumn('md5', 'DbMd5', 'CHAR', false, 32, null); + $this->addColumn('track_title', 'DbTrackTitle', 'VARCHAR', false, 512, null); + $this->addColumn('artist_name', 'DbArtistName', 'VARCHAR', false, 512, null); + $this->addColumn('bit_rate', 'DbBitRate', 'INTEGER', false, null, null); + $this->addColumn('sample_rate', 'DbSampleRate', 'INTEGER', false, null, null); + $this->addColumn('format', 'DbFormat', 'VARCHAR', false, 128, null); + $this->addColumn('length', 'DbLength', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('album_title', 'DbAlbumTitle', 'VARCHAR', false, 512, null); + $this->addColumn('genre', 'DbGenre', 'VARCHAR', false, 64, null); + $this->addColumn('comments', 'DbComments', 'LONGVARCHAR', false, null, null); + $this->addColumn('year', 'DbYear', 'VARCHAR', false, 16, null); + $this->addColumn('track_number', 'DbTrackNumber', 'INTEGER', false, null, null); + $this->addColumn('channels', 'DbChannels', 'INTEGER', false, null, null); + $this->addColumn('url', 'DbUrl', 'VARCHAR', false, 1024, null); + $this->addColumn('bpm', 'DbBpm', 'INTEGER', false, null, null); + $this->addColumn('rating', 'DbRating', 'VARCHAR', false, 8, null); + $this->addColumn('encoded_by', 'DbEncodedBy', 'VARCHAR', false, 255, null); + $this->addColumn('disc_number', 'DbDiscNumber', 'VARCHAR', false, 8, null); + $this->addColumn('mood', 'DbMood', 'VARCHAR', false, 64, null); + $this->addColumn('label', 'DbLabel', 'VARCHAR', false, 512, null); + $this->addColumn('composer', 'DbComposer', 'VARCHAR', false, 512, null); + $this->addColumn('encoder', 'DbEncoder', 'VARCHAR', false, 64, null); + $this->addColumn('checksum', 'DbChecksum', 'VARCHAR', false, 256, null); + $this->addColumn('lyrics', 'DbLyrics', 'LONGVARCHAR', false, null, null); + $this->addColumn('orchestra', 'DbOrchestra', 'VARCHAR', false, 512, null); + $this->addColumn('conductor', 'DbConductor', 'VARCHAR', false, 512, null); + $this->addColumn('lyricist', 'DbLyricist', 'VARCHAR', false, 512, null); + $this->addColumn('original_lyricist', 'DbOriginalLyricist', 'VARCHAR', false, 512, null); + $this->addColumn('radio_station_name', 'DbRadioStationName', 'VARCHAR', false, 512, null); + $this->addColumn('info_url', 'DbInfoUrl', 'VARCHAR', false, 512, null); + $this->addColumn('artist_url', 'DbArtistUrl', 'VARCHAR', false, 512, null); + $this->addColumn('audio_source_url', 'DbAudioSourceUrl', 'VARCHAR', false, 512, null); + $this->addColumn('radio_station_url', 'DbRadioStationUrl', 'VARCHAR', false, 512, null); + $this->addColumn('buy_this_url', 'DbBuyThisUrl', 'VARCHAR', false, 512, null); + $this->addColumn('isrc_number', 'DbIsrcNumber', 'VARCHAR', false, 512, null); + $this->addColumn('catalog_number', 'DbCatalogNumber', 'VARCHAR', false, 512, null); + $this->addColumn('original_artist', 'DbOriginalArtist', 'VARCHAR', false, 512, null); + $this->addColumn('copyright', 'DbCopyright', 'VARCHAR', false, 512, null); + $this->addColumn('report_datetime', 'DbReportDatetime', 'VARCHAR', false, 32, null); + $this->addColumn('report_location', 'DbReportLocation', 'VARCHAR', false, 512, null); + $this->addColumn('report_organization', 'DbReportOrganization', 'VARCHAR', false, 512, null); + $this->addColumn('subject', 'DbSubject', 'VARCHAR', false, 512, null); + $this->addColumn('contributor', 'DbContributor', 'VARCHAR', false, 512, null); + $this->addColumn('language', 'DbLanguage', 'VARCHAR', false, 512, null); + $this->addColumn('file_exists', 'DbFileExists', 'BOOLEAN', false, null, true); + $this->addColumn('soundcloud_id', 'DbSoundcloudId', 'INTEGER', false, null, null); + $this->addColumn('soundcloud_error_code', 'DbSoundcloudErrorCode', 'INTEGER', false, null, null); + $this->addColumn('soundcloud_error_msg', 'DbSoundcloudErrorMsg', 'VARCHAR', false, 512, null); + $this->addColumn('soundcloud_link_to_file', 'DbSoundcloudLinkToFile', 'VARCHAR', false, 4096, null); + $this->addColumn('soundcloud_upload_time', 'DbSoundCloundUploadTime', 'TIMESTAMP', false, 6, null); + $this->addColumn('replay_gain', 'DbReplayGain', 'NUMERIC', false, null, null); + $this->addForeignKey('owner_id', 'DbOwnerId', 'INTEGER', 'cc_subjs', 'id', false, null, null); + $this->addColumn('cuein', 'DbCuein', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('cueout', 'DbCueout', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('silan_check', 'DbSilanCheck', 'BOOLEAN', false, null, false); + $this->addColumn('hidden', 'DbHidden', 'BOOLEAN', false, null, false); + $this->addColumn('is_scheduled', 'DbIsScheduled', 'BOOLEAN', false, null, false); + $this->addColumn('is_playlist', 'DbIsPlaylist', 'BOOLEAN', false, null, false); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('FkOwner', 'CcSubjs', RelationMap::MANY_TO_ONE, array('owner_id' => 'id', ), null, null); - $this->addRelation('CcSubjsRelatedByDbEditedby', 'CcSubjs', RelationMap::MANY_TO_ONE, array('editedby' => 'id', ), null, null); - $this->addRelation('CcMusicDirs', 'CcMusicDirs', RelationMap::MANY_TO_ONE, array('directory' => 'id', ), null, null); - $this->addRelation('CcShowInstances', 'CcShowInstances', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null); - $this->addRelation('CcPlaylistcontents', 'CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null); - $this->addRelation('CcBlockcontents', 'CcBlockcontents', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null); - $this->addRelation('CcSchedule', 'CcSchedule', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null); - $this->addRelation('CcPlayoutHistory', 'CcPlayoutHistory', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('FkOwner', 'Airtime\\CcSubjs', RelationMap::MANY_TO_ONE, array('owner_id' => 'id', ), null, null); + $this->addRelation('CcSubjsRelatedByDbEditedby', 'Airtime\\CcSubjs', RelationMap::MANY_TO_ONE, array('editedby' => 'id', ), null, null); + $this->addRelation('CcMusicDirs', 'Airtime\\CcMusicDirs', RelationMap::MANY_TO_ONE, array('directory' => 'id', ), null, null); + $this->addRelation('CcShowInstances', 'Airtime\\CcShowInstances', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null, 'CcShowInstancess'); + $this->addRelation('CcPlaylistcontents', 'Airtime\\CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null, 'CcPlaylistcontentss'); + $this->addRelation('CcBlockcontents', 'Airtime\\CcBlockcontents', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null, 'CcBlockcontentss'); + $this->addRelation('CcSchedule', 'Airtime\\CcSchedule', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null, 'CcSchedules'); + $this->addRelation('CcPlayoutHistory', 'Airtime\\PlayoutHistory\\CcPlayoutHistory', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null, 'CcPlayoutHistorys'); + } // buildRelations() } // CcFilesTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcListenerCountTableMap.php b/airtime_mvc/application/models/airtime/map/CcListenerCountTableMap.php index 2b9476a75..4e57b33fd 100644 --- a/airtime_mvc/application/models/airtime/map/CcListenerCountTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcListenerCountTableMap.php @@ -1,5 +1,9 @@ setName('cc_listener_count'); - $this->setPhpName('CcListenerCount'); - $this->setClassname('CcListenerCount'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_listener_count_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addForeignKey('TIMESTAMP_ID', 'DbTimestampId', 'INTEGER', 'cc_timestamp', 'ID', true, null, null); - $this->addForeignKey('MOUNT_NAME_ID', 'DbMountNameId', 'INTEGER', 'cc_mount_name', 'ID', true, null, null); - $this->addColumn('LISTENER_COUNT', 'DbListenerCount', 'INTEGER', true, null, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_listener_count'); + $this->setPhpName('CcListenerCount'); + $this->setClassname('Airtime\\CcListenerCount'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_listener_count_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addForeignKey('timestamp_id', 'DbTimestampId', 'INTEGER', 'cc_timestamp', 'id', true, null, null); + $this->addForeignKey('mount_name_id', 'DbMountNameId', 'INTEGER', 'cc_mount_name', 'id', true, null, null); + $this->addColumn('listener_count', 'DbListenerCount', 'INTEGER', true, null, null); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcTimestamp', 'CcTimestamp', RelationMap::MANY_TO_ONE, array('timestamp_id' => 'id', ), 'CASCADE', null); - $this->addRelation('CcMountName', 'CcMountName', RelationMap::MANY_TO_ONE, array('mount_name_id' => 'id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcTimestamp', 'Airtime\\CcTimestamp', RelationMap::MANY_TO_ONE, array('timestamp_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcMountName', 'Airtime\\CcMountName', RelationMap::MANY_TO_ONE, array('mount_name_id' => 'id', ), 'CASCADE', null); + } // buildRelations() } // CcListenerCountTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcLiveLogTableMap.php b/airtime_mvc/application/models/airtime/map/CcLiveLogTableMap.php index 4c8c2f088..a8a6d5a9f 100644 --- a/airtime_mvc/application/models/airtime/map/CcLiveLogTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcLiveLogTableMap.php @@ -1,5 +1,9 @@ setName('cc_live_log'); - $this->setPhpName('CcLiveLog'); - $this->setClassname('CcLiveLog'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_live_log_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addColumn('STATE', 'DbState', 'VARCHAR', true, 32, null); - $this->addColumn('START_TIME', 'DbStartTime', 'TIMESTAMP', true, null, null); - $this->addColumn('END_TIME', 'DbEndTime', 'TIMESTAMP', false, null, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_live_log'); + $this->setPhpName('CcLiveLog'); + $this->setClassname('Airtime\\CcLiveLog'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_live_log_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addColumn('state', 'DbState', 'VARCHAR', true, 32, null); + $this->addColumn('start_time', 'DbStartTime', 'TIMESTAMP', true, null, null); + $this->addColumn('end_time', 'DbEndTime', 'TIMESTAMP', false, null, null); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() } // CcLiveLogTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcLocaleTableMap.php b/airtime_mvc/application/models/airtime/map/CcLocaleTableMap.php index e6b51fc12..b28e9ceb0 100644 --- a/airtime_mvc/application/models/airtime/map/CcLocaleTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcLocaleTableMap.php @@ -1,5 +1,9 @@ setName('cc_locale'); - $this->setPhpName('CcLocale'); - $this->setClassname('CcLocale'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_locale_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addColumn('LOCALE_CODE', 'DbLocaleCode', 'VARCHAR', true, 16, null); - $this->addColumn('LOCALE_LANG', 'DbLocaleLang', 'VARCHAR', true, 128, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_locale'); + $this->setPhpName('CcLocale'); + $this->setClassname('Airtime\\CcLocale'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_locale_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addColumn('locale_code', 'DbLocaleCode', 'VARCHAR', true, 16, null); + $this->addColumn('locale_lang', 'DbLocaleLang', 'VARCHAR', true, 128, null); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() } // CcLocaleTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcLoginAttemptsTableMap.php b/airtime_mvc/application/models/airtime/map/CcLoginAttemptsTableMap.php index 32ce73743..ac54a9f92 100644 --- a/airtime_mvc/application/models/airtime/map/CcLoginAttemptsTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcLoginAttemptsTableMap.php @@ -1,5 +1,9 @@ setName('cc_login_attempts'); - $this->setPhpName('CcLoginAttempts'); - $this->setClassname('CcLoginAttempts'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(false); - // columns - $this->addPrimaryKey('IP', 'DbIP', 'VARCHAR', true, 32, null); - $this->addColumn('ATTEMPTS', 'DbAttempts', 'INTEGER', false, null, 0); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_login_attempts'); + $this->setPhpName('CcLoginAttempts'); + $this->setClassname('Airtime\\CcLoginAttempts'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(false); + // columns + $this->addPrimaryKey('ip', 'DbIP', 'VARCHAR', true, 32, null); + $this->addColumn('attempts', 'DbAttempts', 'INTEGER', false, null, 0); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() } // CcLoginAttemptsTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcMountNameTableMap.php b/airtime_mvc/application/models/airtime/map/CcMountNameTableMap.php index f07bc5403..21ae60ffc 100644 --- a/airtime_mvc/application/models/airtime/map/CcMountNameTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcMountNameTableMap.php @@ -1,5 +1,9 @@ setName('cc_mount_name'); - $this->setPhpName('CcMountName'); - $this->setClassname('CcMountName'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_mount_name_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addColumn('MOUNT_NAME', 'DbMountName', 'VARCHAR', true, 255, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_mount_name'); + $this->setPhpName('CcMountName'); + $this->setClassname('Airtime\\CcMountName'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_mount_name_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addColumn('mount_name', 'DbMountName', 'VARCHAR', true, null, null); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcListenerCount', 'CcListenerCount', RelationMap::ONE_TO_MANY, array('id' => 'mount_name_id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcListenerCount', 'Airtime\\CcListenerCount', RelationMap::ONE_TO_MANY, array('id' => 'mount_name_id', ), 'CASCADE', null, 'CcListenerCounts'); + } // buildRelations() } // CcMountNameTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcMusicDirsTableMap.php b/airtime_mvc/application/models/airtime/map/CcMusicDirsTableMap.php index 5af51394e..ddce796a7 100644 --- a/airtime_mvc/application/models/airtime/map/CcMusicDirsTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcMusicDirsTableMap.php @@ -1,5 +1,9 @@ setName('cc_music_dirs'); - $this->setPhpName('CcMusicDirs'); - $this->setClassname('CcMusicDirs'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_music_dirs_id_seq'); - // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('DIRECTORY', 'Directory', 'LONGVARCHAR', false, null, null); - $this->addColumn('TYPE', 'Type', 'VARCHAR', false, 255, null); - $this->addColumn('EXISTS', 'Exists', 'BOOLEAN', false, null, true); - $this->addColumn('WATCHED', 'Watched', 'BOOLEAN', false, null, true); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_music_dirs'); + $this->setPhpName('CcMusicDirs'); + $this->setClassname('Airtime\\CcMusicDirs'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_music_dirs_id_seq'); + // columns + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('directory', 'Directory', 'LONGVARCHAR', false, null, null); + $this->addColumn('type', 'Type', 'VARCHAR', false, 255, null); + $this->addColumn('exists', 'Exists', 'BOOLEAN', false, null, true); + $this->addColumn('watched', 'Watched', 'BOOLEAN', false, null, true); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcFiles', 'CcFiles', RelationMap::ONE_TO_MANY, array('id' => 'directory', ), null, null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcFiles', 'Airtime\\CcFiles', RelationMap::ONE_TO_MANY, array('id' => 'directory', ), null, null, 'CcFiless'); + $this->addRelation('AudioFile', 'Airtime\\MediaItem\\AudioFile', RelationMap::ONE_TO_MANY, array('id' => 'directory', ), null, null, 'AudioFiles'); + } // buildRelations() } // CcMusicDirsTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcPermsTableMap.php b/airtime_mvc/application/models/airtime/map/CcPermsTableMap.php index 481d17c96..5b95cf707 100644 --- a/airtime_mvc/application/models/airtime/map/CcPermsTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcPermsTableMap.php @@ -1,5 +1,9 @@ setName('cc_perms'); - $this->setPhpName('CcPerms'); - $this->setClassname('CcPerms'); - $this->setPackage('airtime'); - $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() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_perms'); + $this->setPhpName('CcPerms'); + $this->setClassname('Airtime\\CcPerms'); + $this->setPackage('airtime'); + $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() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcSubjs', 'Airtime\\CcSubjs', RelationMap::MANY_TO_ONE, array('subj' => 'id', ), 'CASCADE', null); + } // buildRelations() } // CcPermsTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcPlaylistTableMap.php b/airtime_mvc/application/models/airtime/map/CcPlaylistTableMap.php index 8dba50bbd..a53e55793 100644 --- a/airtime_mvc/application/models/airtime/map/CcPlaylistTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcPlaylistTableMap.php @@ -1,5 +1,9 @@ setName('cc_playlist'); - $this->setPhpName('CcPlaylist'); - $this->setClassname('CcPlaylist'); - $this->setPackage('airtime'); - $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('MTIME', 'DbMtime', 'TIMESTAMP', false, 6, null); - $this->addColumn('UTIME', 'DbUtime', 'TIMESTAMP', false, 6, null); - $this->addForeignKey('CREATOR_ID', 'DbCreatorId', 'INTEGER', 'cc_subjs', 'ID', false, null, null); - $this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null); - $this->addColumn('LENGTH', 'DbLength', 'VARCHAR', false, null, '00:00:00'); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_playlist'); + $this->setPhpName('CcPlaylist'); + $this->setClassname('Airtime\\CcPlaylist'); + $this->setPackage('airtime'); + $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('mtime', 'DbMtime', 'TIMESTAMP', false, 6, null); + $this->addColumn('utime', 'DbUtime', 'TIMESTAMP', false, 6, null); + $this->addForeignKey('creator_id', 'DbCreatorId', 'INTEGER', 'cc_subjs', 'id', false, null, null); + $this->addColumn('description', 'DbDescription', 'VARCHAR', false, 512, null); + $this->addColumn('length', 'DbLength', 'VARCHAR', false, null, '00:00:00'); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('creator_id' => 'id', ), 'CASCADE', null); - $this->addRelation('CcPlaylistcontents', 'CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'playlist_id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcSubjs', 'Airtime\\CcSubjs', RelationMap::MANY_TO_ONE, array('creator_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcPlaylistcontents', 'Airtime\\CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'playlist_id', ), 'CASCADE', null, 'CcPlaylistcontentss'); + } // buildRelations() - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'aggregate_column' => array('name' => 'length', 'expression' => 'SUM(cliplength)', 'foreign_table' => 'cc_playlistcontents', ), - ); - } // getBehaviors() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'aggregate_column' => array ( + 'name' => 'length', + 'expression' => 'SUM(cliplength)', + 'condition' => NULL, + 'foreign_table' => 'cc_playlistcontents', + 'foreign_schema' => NULL, +), + ); + } // getBehaviors() } // CcPlaylistTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcPlaylistcontentsTableMap.php b/airtime_mvc/application/models/airtime/map/CcPlaylistcontentsTableMap.php index 3122f64d5..6b06f61e2 100644 --- a/airtime_mvc/application/models/airtime/map/CcPlaylistcontentsTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcPlaylistcontentsTableMap.php @@ -1,5 +1,9 @@ setName('cc_playlistcontents'); - $this->setPhpName('CcPlaylistcontents'); - $this->setClassname('CcPlaylistcontents'); - $this->setPackage('airtime'); - $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->addForeignKey('BLOCK_ID', 'DbBlockId', 'INTEGER', 'cc_block', 'ID', false, null, null); - $this->addColumn('STREAM_ID', 'DbStreamId', 'INTEGER', false, null, null); - $this->addColumn('TYPE', 'DbType', 'SMALLINT', true, null, 0); - $this->addColumn('POSITION', 'DbPosition', 'INTEGER', false, null, null); - $this->addColumn('TRACKOFFSET', 'DbTrackOffset', 'REAL', true, null, 0); - $this->addColumn('CLIPLENGTH', 'DbCliplength', 'VARCHAR', false, null, '00:00:00'); - $this->addColumn('CUEIN', 'DbCuein', 'VARCHAR', false, null, '00:00:00'); - $this->addColumn('CUEOUT', 'DbCueout', 'VARCHAR', 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() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_playlistcontents'); + $this->setPhpName('CcPlaylistcontents'); + $this->setClassname('Airtime\\CcPlaylistcontents'); + $this->setPackage('airtime'); + $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->addForeignKey('block_id', 'DbBlockId', 'INTEGER', 'cc_block', 'id', false, null, null); + $this->addColumn('stream_id', 'DbStreamId', 'INTEGER', false, null, null); + $this->addColumn('type', 'DbType', 'SMALLINT', true, null, 0); + $this->addColumn('position', 'DbPosition', 'INTEGER', false, null, null); + $this->addColumn('trackoffset', 'DbTrackOffset', 'REAL', true, null, 0); + $this->addColumn('cliplength', 'DbCliplength', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('cuein', 'DbCuein', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('cueout', 'DbCueout', 'VARCHAR', 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('CcBlock', 'CcBlock', RelationMap::MANY_TO_ONE, array('block_id' => 'id', ), 'CASCADE', null); - $this->addRelation('CcPlaylist', 'CcPlaylist', RelationMap::MANY_TO_ONE, array('playlist_id' => 'id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcFiles', 'Airtime\\CcFiles', RelationMap::MANY_TO_ONE, array('file_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcBlock', 'Airtime\\CcBlock', RelationMap::MANY_TO_ONE, array('block_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcPlaylist', 'Airtime\\CcPlaylist', RelationMap::MANY_TO_ONE, array('playlist_id' => 'id', ), 'CASCADE', null); + } // buildRelations() - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'aggregate_column_relation' => array('foreign_table' => 'cc_playlist', 'update_method' => 'updateDbLength', ), - ); - } // getBehaviors() + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'aggregate_column_relation' => array ( + 'foreign_table' => 'cc_playlist', + 'update_method' => 'updateDbLength', +), + ); + } // getBehaviors() } // CcPlaylistcontentsTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryMetaDataTableMap.php b/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryMetaDataTableMap.php index 8e937f6e5..609e20b06 100644 --- a/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryMetaDataTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryMetaDataTableMap.php @@ -1,5 +1,9 @@ setName('cc_playout_history_metadata'); - $this->setPhpName('CcPlayoutHistoryMetaData'); - $this->setClassname('CcPlayoutHistoryMetaData'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_playout_history_metadata_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addForeignKey('HISTORY_ID', 'DbHistoryId', 'INTEGER', 'cc_playout_history', 'ID', true, null, null); - $this->addColumn('KEY', 'DbKey', 'VARCHAR', true, 128, null); - $this->addColumn('VALUE', 'DbValue', 'VARCHAR', true, 128, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_playout_history_metadata'); + $this->setPhpName('CcPlayoutHistoryMetaData'); + $this->setClassname('Airtime\\PlayoutHistory\\CcPlayoutHistoryMetaData'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_playout_history_metadata_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addForeignKey('history_id', 'DbHistoryId', 'INTEGER', 'cc_playout_history', 'id', true, null, null); + $this->addColumn('key', 'DbKey', 'VARCHAR', true, 128, null); + $this->addColumn('value', 'DbValue', 'VARCHAR', true, 128, null); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcPlayoutHistory', 'CcPlayoutHistory', RelationMap::MANY_TO_ONE, array('history_id' => 'id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcPlayoutHistory', 'Airtime\\PlayoutHistory\\CcPlayoutHistory', RelationMap::MANY_TO_ONE, array('history_id' => 'id', ), 'CASCADE', null); + } // buildRelations() } // CcPlayoutHistoryMetaDataTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryTableMap.php b/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryTableMap.php index 23696f18d..d37a22be0 100644 --- a/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryTableMap.php @@ -1,5 +1,9 @@ setName('cc_playout_history'); - $this->setPhpName('CcPlayoutHistory'); - $this->setClassname('CcPlayoutHistory'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_playout_history_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addForeignKey('FILE_ID', 'DbFileId', 'INTEGER', 'cc_files', 'ID', false, null, null); - $this->addColumn('STARTS', 'DbStarts', 'TIMESTAMP', true, null, null); - $this->addColumn('ENDS', 'DbEnds', 'TIMESTAMP', false, null, null); - $this->addForeignKey('INSTANCE_ID', 'DbInstanceId', 'INTEGER', 'cc_show_instances', 'ID', false, null, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_playout_history'); + $this->setPhpName('CcPlayoutHistory'); + $this->setClassname('Airtime\\PlayoutHistory\\CcPlayoutHistory'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_playout_history_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addForeignKey('file_id', 'DbFileId', 'INTEGER', 'cc_files', 'id', false, null, null); + $this->addColumn('starts', 'DbStarts', 'TIMESTAMP', true, null, null); + $this->addColumn('ends', 'DbEnds', 'TIMESTAMP', false, null, null); + $this->addForeignKey('instance_id', 'DbInstanceId', 'INTEGER', 'cc_show_instances', 'id', false, null, null); + // 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('CcShowInstances', 'CcShowInstances', RelationMap::MANY_TO_ONE, array('instance_id' => 'id', ), 'SET NULL', null); - $this->addRelation('CcPlayoutHistoryMetaData', 'CcPlayoutHistoryMetaData', RelationMap::ONE_TO_MANY, array('id' => 'history_id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcFiles', 'Airtime\\CcFiles', RelationMap::MANY_TO_ONE, array('file_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcShowInstances', 'Airtime\\CcShowInstances', RelationMap::MANY_TO_ONE, array('instance_id' => 'id', ), 'SET NULL', null); + $this->addRelation('CcPlayoutHistoryMetaData', 'Airtime\\PlayoutHistory\\CcPlayoutHistoryMetaData', RelationMap::ONE_TO_MANY, array('id' => 'history_id', ), 'CASCADE', null, 'CcPlayoutHistoryMetaDatas'); + } // buildRelations() } // CcPlayoutHistoryTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryTemplateFieldTableMap.php b/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryTemplateFieldTableMap.php index f68db26a1..3e3ee2ecd 100644 --- a/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryTemplateFieldTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryTemplateFieldTableMap.php @@ -1,5 +1,9 @@ setName('cc_playout_history_template_field'); - $this->setPhpName('CcPlayoutHistoryTemplateField'); - $this->setClassname('CcPlayoutHistoryTemplateField'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_playout_history_template_field_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addForeignKey('TEMPLATE_ID', 'DbTemplateId', 'INTEGER', 'cc_playout_history_template', 'ID', true, null, null); - $this->addColumn('NAME', 'DbName', 'VARCHAR', true, 128, null); - $this->addColumn('LABEL', 'DbLabel', 'VARCHAR', true, 128, null); - $this->addColumn('TYPE', 'DbType', 'VARCHAR', true, 128, null); - $this->addColumn('IS_FILE_MD', 'DbIsFileMD', 'BOOLEAN', true, null, false); - $this->addColumn('POSITION', 'DbPosition', 'INTEGER', true, null, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_playout_history_template_field'); + $this->setPhpName('CcPlayoutHistoryTemplateField'); + $this->setClassname('Airtime\\PlayoutHistory\\CcPlayoutHistoryTemplateField'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_playout_history_template_field_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addForeignKey('template_id', 'DbTemplateId', 'INTEGER', 'cc_playout_history_template', 'id', true, null, null); + $this->addColumn('name', 'DbName', 'VARCHAR', true, 128, null); + $this->addColumn('label', 'DbLabel', 'VARCHAR', true, 128, null); + $this->addColumn('type', 'DbType', 'VARCHAR', true, 128, null); + $this->addColumn('is_file_md', 'DbIsFileMD', 'BOOLEAN', true, null, false); + $this->addColumn('position', 'DbPosition', 'INTEGER', true, null, null); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcPlayoutHistoryTemplate', 'CcPlayoutHistoryTemplate', RelationMap::MANY_TO_ONE, array('template_id' => 'id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcPlayoutHistoryTemplate', 'Airtime\\PlayoutHistory\\CcPlayoutHistoryTemplate', RelationMap::MANY_TO_ONE, array('template_id' => 'id', ), 'CASCADE', null); + } // buildRelations() } // CcPlayoutHistoryTemplateFieldTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryTemplateTableMap.php b/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryTemplateTableMap.php index e5aea573d..aa4c40e78 100644 --- a/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryTemplateTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryTemplateTableMap.php @@ -1,5 +1,9 @@ setName('cc_playout_history_template'); - $this->setPhpName('CcPlayoutHistoryTemplate'); - $this->setClassname('CcPlayoutHistoryTemplate'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_playout_history_template_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addColumn('NAME', 'DbName', 'VARCHAR', true, 128, null); - $this->addColumn('TYPE', 'DbType', 'VARCHAR', true, 35, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_playout_history_template'); + $this->setPhpName('CcPlayoutHistoryTemplate'); + $this->setClassname('Airtime\\PlayoutHistory\\CcPlayoutHistoryTemplate'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_playout_history_template_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addColumn('name', 'DbName', 'VARCHAR', true, 128, null); + $this->addColumn('type', 'DbType', 'VARCHAR', true, 35, null); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcPlayoutHistoryTemplateField', 'CcPlayoutHistoryTemplateField', RelationMap::ONE_TO_MANY, array('id' => 'template_id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcPlayoutHistoryTemplateField', 'Airtime\\PlayoutHistory\\CcPlayoutHistoryTemplateField', RelationMap::ONE_TO_MANY, array('id' => 'template_id', ), 'CASCADE', null, 'CcPlayoutHistoryTemplateFields'); + } // buildRelations() } // CcPlayoutHistoryTemplateTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcPrefTableMap.php b/airtime_mvc/application/models/airtime/map/CcPrefTableMap.php index 1d22a122d..a5cfc8336 100644 --- a/airtime_mvc/application/models/airtime/map/CcPrefTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcPrefTableMap.php @@ -1,5 +1,9 @@ setName('cc_pref'); - $this->setPhpName('CcPref'); - $this->setClassname('CcPref'); - $this->setPackage('airtime'); - $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() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_pref'); + $this->setPhpName('CcPref'); + $this->setClassname('Airtime\\CcPref'); + $this->setPackage('airtime'); + $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() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcSubjs', 'Airtime\\CcSubjs', RelationMap::MANY_TO_ONE, array('subjid' => 'id', ), 'CASCADE', null); + } // buildRelations() } // CcPrefTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcScheduleTableMap.php b/airtime_mvc/application/models/airtime/map/CcScheduleTableMap.php index 54d25cdb8..cef0f171a 100644 --- a/airtime_mvc/application/models/airtime/map/CcScheduleTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcScheduleTableMap.php @@ -1,5 +1,9 @@ setName('cc_schedule'); - $this->setPhpName('CcSchedule'); - $this->setClassname('CcSchedule'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_schedule_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addColumn('STARTS', 'DbStarts', 'TIMESTAMP', true, null, null); - $this->addColumn('ENDS', 'DbEnds', 'TIMESTAMP', true, null, null); - $this->addForeignKey('FILE_ID', 'DbFileId', 'INTEGER', 'cc_files', 'ID', false, null, null); - $this->addForeignKey('STREAM_ID', 'DbStreamId', 'INTEGER', 'cc_webstream', 'ID', false, null, null); - $this->addColumn('CLIP_LENGTH', 'DbClipLength', 'VARCHAR', false, null, '00:00:00'); - $this->addColumn('FADE_IN', 'DbFadeIn', 'TIME', false, null, '00:00:00'); - $this->addColumn('FADE_OUT', 'DbFadeOut', 'TIME', false, null, '00:00:00'); - $this->addColumn('CUE_IN', 'DbCueIn', 'VARCHAR', true, null, null); - $this->addColumn('CUE_OUT', 'DbCueOut', 'VARCHAR', true, null, null); - $this->addColumn('MEDIA_ITEM_PLAYED', 'DbMediaItemPlayed', 'BOOLEAN', false, null, false); - $this->addForeignKey('INSTANCE_ID', 'DbInstanceId', 'INTEGER', 'cc_show_instances', 'ID', true, null, null); - $this->addColumn('PLAYOUT_STATUS', 'DbPlayoutStatus', 'SMALLINT', true, null, 1); - $this->addColumn('BROADCASTED', 'DbBroadcasted', 'SMALLINT', true, null, 0); - $this->addColumn('POSITION', 'DbPosition', 'INTEGER', true, null, 0); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_schedule'); + $this->setPhpName('CcSchedule'); + $this->setClassname('Airtime\\CcSchedule'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_schedule_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addColumn('starts', 'DbStarts', 'TIMESTAMP', true, null, null); + $this->addColumn('ends', 'DbEnds', 'TIMESTAMP', true, null, null); + $this->addForeignKey('file_id', 'DbFileId', 'INTEGER', 'cc_files', 'id', false, null, null); + $this->addForeignKey('stream_id', 'DbStreamId', 'INTEGER', 'cc_webstream', 'id', false, null, null); + $this->addColumn('clip_length', 'DbClipLength', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('fade_in', 'DbFadeIn', 'TIME', false, null, '00:00:00'); + $this->addColumn('fade_out', 'DbFadeOut', 'TIME', false, null, '00:00:00'); + $this->addColumn('cue_in', 'DbCueIn', 'VARCHAR', true, null, null); + $this->addColumn('cue_out', 'DbCueOut', 'VARCHAR', true, null, null); + $this->addColumn('media_item_played', 'DbMediaItemPlayed', 'BOOLEAN', false, null, false); + $this->addForeignKey('instance_id', 'DbInstanceId', 'INTEGER', 'cc_show_instances', 'id', true, null, null); + $this->addColumn('playout_status', 'DbPlayoutStatus', 'SMALLINT', true, null, 1); + $this->addColumn('broadcasted', 'DbBroadcasted', 'SMALLINT', true, null, 0); + $this->addColumn('position', 'DbPosition', 'INTEGER', true, null, 0); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcShowInstances', 'CcShowInstances', RelationMap::MANY_TO_ONE, array('instance_id' => 'id', ), 'CASCADE', null); - $this->addRelation('CcFiles', 'CcFiles', RelationMap::MANY_TO_ONE, array('file_id' => 'id', ), 'CASCADE', null); - $this->addRelation('CcWebstream', 'CcWebstream', RelationMap::MANY_TO_ONE, array('stream_id' => 'id', ), 'CASCADE', null); - $this->addRelation('CcWebstreamMetadata', 'CcWebstreamMetadata', RelationMap::ONE_TO_MANY, array('id' => 'instance_id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcShowInstances', 'Airtime\\CcShowInstances', RelationMap::MANY_TO_ONE, array('instance_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcFiles', 'Airtime\\CcFiles', RelationMap::MANY_TO_ONE, array('file_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcWebstream', 'Airtime\\CcWebstream', RelationMap::MANY_TO_ONE, array('stream_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcWebstreamMetadata', 'Airtime\\CcWebstreamMetadata', RelationMap::ONE_TO_MANY, array('id' => 'instance_id', ), 'CASCADE', null, 'CcWebstreamMetadatas'); + } // buildRelations() } // CcScheduleTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcServiceRegisterTableMap.php b/airtime_mvc/application/models/airtime/map/CcServiceRegisterTableMap.php index f4eae5e60..791c21dff 100644 --- a/airtime_mvc/application/models/airtime/map/CcServiceRegisterTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcServiceRegisterTableMap.php @@ -1,5 +1,9 @@ setName('cc_service_register'); - $this->setPhpName('CcServiceRegister'); - $this->setClassname('CcServiceRegister'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(false); - // columns - $this->addPrimaryKey('NAME', 'DbName', 'VARCHAR', true, 32, null); - $this->addColumn('IP', 'DbIp', 'VARCHAR', true, 18, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_service_register'); + $this->setPhpName('CcServiceRegister'); + $this->setClassname('Airtime\\CcServiceRegister'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(false); + // columns + $this->addPrimaryKey('name', 'DbName', 'VARCHAR', true, 32, null); + $this->addColumn('ip', 'DbIp', 'VARCHAR', true, 18, null); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() } // CcServiceRegisterTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcSessTableMap.php b/airtime_mvc/application/models/airtime/map/CcSessTableMap.php index 66605b4eb..03ff8ae4a 100644 --- a/airtime_mvc/application/models/airtime/map/CcSessTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcSessTableMap.php @@ -1,5 +1,9 @@ setName('cc_sess'); - $this->setPhpName('CcSess'); - $this->setClassname('CcSess'); - $this->setPackage('airtime'); - $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() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_sess'); + $this->setPhpName('CcSess'); + $this->setClassname('Airtime\\CcSess'); + $this->setPackage('airtime'); + $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() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcSubjs', 'Airtime\\CcSubjs', RelationMap::MANY_TO_ONE, array('userid' => 'id', ), 'CASCADE', null); + } // buildRelations() } // CcSessTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcShowDaysTableMap.php b/airtime_mvc/application/models/airtime/map/CcShowDaysTableMap.php index 7d6b8a10e..d53d114cf 100644 --- a/airtime_mvc/application/models/airtime/map/CcShowDaysTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcShowDaysTableMap.php @@ -1,5 +1,9 @@ setName('cc_show_days'); - $this->setPhpName('CcShowDays'); - $this->setClassname('CcShowDays'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_show_days_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $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('TIMEZONE', 'DbTimezone', 'VARCHAR', true, 255, null); - $this->addColumn('DURATION', 'DbDuration', 'VARCHAR', true, 255, null); - $this->addColumn('DAY', 'DbDay', 'TINYINT', false, null, null); - $this->addColumn('REPEAT_TYPE', 'DbRepeatType', 'TINYINT', true, null, null); - $this->addColumn('NEXT_POP_DATE', 'DbNextPopDate', 'DATE', false, null, null); - $this->addForeignKey('SHOW_ID', 'DbShowId', 'INTEGER', 'cc_show', 'ID', true, null, null); - $this->addColumn('RECORD', 'DbRecord', 'TINYINT', false, null, 0); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_show_days'); + $this->setPhpName('CcShowDays'); + $this->setClassname('Airtime\\CcShowDays'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_show_days_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $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('timezone', 'DbTimezone', 'VARCHAR', true, null, null); + $this->addColumn('duration', 'DbDuration', 'VARCHAR', true, null, null); + $this->addColumn('day', 'DbDay', 'TINYINT', false, null, null); + $this->addColumn('repeat_type', 'DbRepeatType', 'TINYINT', true, null, null); + $this->addColumn('next_pop_date', 'DbNextPopDate', 'DATE', false, null, null); + $this->addForeignKey('show_id', 'DbShowId', 'INTEGER', 'cc_show', 'id', true, null, null); + $this->addColumn('record', 'DbRecord', 'TINYINT', false, null, 0); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcShow', 'CcShow', RelationMap::MANY_TO_ONE, array('show_id' => 'id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcShow', 'Airtime\\CcShow', RelationMap::MANY_TO_ONE, array('show_id' => 'id', ), 'CASCADE', null); + } // buildRelations() } // CcShowDaysTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcShowHostsTableMap.php b/airtime_mvc/application/models/airtime/map/CcShowHostsTableMap.php index c76efdbd3..d1fe6f0da 100644 --- a/airtime_mvc/application/models/airtime/map/CcShowHostsTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcShowHostsTableMap.php @@ -1,5 +1,9 @@ setName('cc_show_hosts'); - $this->setPhpName('CcShowHosts'); - $this->setClassname('CcShowHosts'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_show_hosts_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addForeignKey('SHOW_ID', 'DbShow', 'INTEGER', 'cc_show', 'ID', true, null, null); - $this->addForeignKey('SUBJS_ID', 'DbHost', 'INTEGER', 'cc_subjs', 'ID', true, null, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_show_hosts'); + $this->setPhpName('CcShowHosts'); + $this->setClassname('Airtime\\CcShowHosts'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_show_hosts_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addForeignKey('show_id', 'DbShow', 'INTEGER', 'cc_show', 'id', true, null, null); + $this->addForeignKey('subjs_id', 'DbHost', 'INTEGER', 'cc_subjs', 'id', true, null, null); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcShow', 'CcShow', RelationMap::MANY_TO_ONE, array('show_id' => 'id', ), 'CASCADE', null); - $this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('subjs_id' => 'id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcShow', 'Airtime\\CcShow', RelationMap::MANY_TO_ONE, array('show_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcSubjs', 'Airtime\\CcSubjs', RelationMap::MANY_TO_ONE, array('subjs_id' => 'id', ), 'CASCADE', null); + } // buildRelations() } // CcShowHostsTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcShowInstancesTableMap.php b/airtime_mvc/application/models/airtime/map/CcShowInstancesTableMap.php index c55e86080..f6b63fce1 100644 --- a/airtime_mvc/application/models/airtime/map/CcShowInstancesTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcShowInstancesTableMap.php @@ -1,5 +1,9 @@ setName('cc_show_instances'); - $this->setPhpName('CcShowInstances'); - $this->setClassname('CcShowInstances'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_show_instances_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addColumn('STARTS', 'DbStarts', 'TIMESTAMP', true, null, null); - $this->addColumn('ENDS', 'DbEnds', 'TIMESTAMP', true, null, null); - $this->addForeignKey('SHOW_ID', 'DbShowId', 'INTEGER', 'cc_show', 'ID', true, null, null); - $this->addColumn('RECORD', 'DbRecord', 'TINYINT', false, null, 0); - $this->addColumn('REBROADCAST', 'DbRebroadcast', 'TINYINT', false, null, 0); - $this->addForeignKey('INSTANCE_ID', 'DbOriginalShow', 'INTEGER', 'cc_show_instances', 'ID', false, null, null); - $this->addForeignKey('FILE_ID', 'DbRecordedFile', 'INTEGER', 'cc_files', 'ID', false, null, null); - $this->addColumn('TIME_FILLED', 'DbTimeFilled', 'VARCHAR', false, null, '00:00:00'); - $this->addColumn('CREATED', 'DbCreated', 'TIMESTAMP', true, null, null); - $this->addColumn('LAST_SCHEDULED', 'DbLastScheduled', 'TIMESTAMP', false, null, null); - $this->addColumn('MODIFIED_INSTANCE', 'DbModifiedInstance', 'BOOLEAN', true, null, false); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_show_instances'); + $this->setPhpName('CcShowInstances'); + $this->setClassname('Airtime\\CcShowInstances'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_show_instances_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addColumn('starts', 'DbStarts', 'TIMESTAMP', true, null, null); + $this->addColumn('ends', 'DbEnds', 'TIMESTAMP', true, null, null); + $this->addForeignKey('show_id', 'DbShowId', 'INTEGER', 'cc_show', 'id', true, null, null); + $this->addColumn('record', 'DbRecord', 'TINYINT', false, null, 0); + $this->addColumn('rebroadcast', 'DbRebroadcast', 'TINYINT', false, null, 0); + $this->addForeignKey('instance_id', 'DbOriginalShow', 'INTEGER', 'cc_show_instances', 'id', false, null, null); + $this->addForeignKey('file_id', 'DbRecordedFile', 'INTEGER', 'cc_files', 'id', false, null, null); + $this->addColumn('time_filled', 'DbTimeFilled', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('created', 'DbCreated', 'TIMESTAMP', true, null, null); + $this->addColumn('last_scheduled', 'DbLastScheduled', 'TIMESTAMP', false, null, null); + $this->addColumn('modified_instance', 'DbModifiedInstance', 'BOOLEAN', true, null, false); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcShow', 'CcShow', RelationMap::MANY_TO_ONE, array('show_id' => 'id', ), 'CASCADE', null); - $this->addRelation('CcShowInstancesRelatedByDbOriginalShow', 'CcShowInstances', RelationMap::MANY_TO_ONE, array('instance_id' => 'id', ), 'CASCADE', null); - $this->addRelation('CcFiles', 'CcFiles', RelationMap::MANY_TO_ONE, array('file_id' => 'id', ), 'CASCADE', null); - $this->addRelation('CcShowInstancesRelatedByDbId', 'CcShowInstances', RelationMap::ONE_TO_MANY, array('id' => 'instance_id', ), 'CASCADE', null); - $this->addRelation('CcSchedule', 'CcSchedule', RelationMap::ONE_TO_MANY, array('id' => 'instance_id', ), 'CASCADE', null); - $this->addRelation('CcPlayoutHistory', 'CcPlayoutHistory', RelationMap::ONE_TO_MANY, array('id' => 'instance_id', ), 'SET NULL', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcShow', 'Airtime\\CcShow', RelationMap::MANY_TO_ONE, array('show_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcShowInstancesRelatedByDbOriginalShow', 'Airtime\\CcShowInstances', RelationMap::MANY_TO_ONE, array('instance_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcFiles', 'Airtime\\CcFiles', RelationMap::MANY_TO_ONE, array('file_id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcShowInstancesRelatedByDbId', 'Airtime\\CcShowInstances', RelationMap::ONE_TO_MANY, array('id' => 'instance_id', ), 'CASCADE', null, 'CcShowInstancessRelatedByDbId'); + $this->addRelation('CcSchedule', 'Airtime\\CcSchedule', RelationMap::ONE_TO_MANY, array('id' => 'instance_id', ), 'CASCADE', null, 'CcSchedules'); + $this->addRelation('CcPlayoutHistory', 'Airtime\\PlayoutHistory\\CcPlayoutHistory', RelationMap::ONE_TO_MANY, array('id' => 'instance_id', ), 'SET NULL', null, 'CcPlayoutHistorys'); + } // buildRelations() } // CcShowInstancesTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcShowRebroadcastTableMap.php b/airtime_mvc/application/models/airtime/map/CcShowRebroadcastTableMap.php index 60a9ba980..2dce606aa 100644 --- a/airtime_mvc/application/models/airtime/map/CcShowRebroadcastTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcShowRebroadcastTableMap.php @@ -1,5 +1,9 @@ setName('cc_show_rebroadcast'); - $this->setPhpName('CcShowRebroadcast'); - $this->setClassname('CcShowRebroadcast'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_show_rebroadcast_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addColumn('DAY_OFFSET', 'DbDayOffset', 'VARCHAR', true, 255, null); - $this->addColumn('START_TIME', 'DbStartTime', 'TIME', true, null, null); - $this->addForeignKey('SHOW_ID', 'DbShowId', 'INTEGER', 'cc_show', 'ID', true, null, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_show_rebroadcast'); + $this->setPhpName('CcShowRebroadcast'); + $this->setClassname('Airtime\\CcShowRebroadcast'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_show_rebroadcast_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addColumn('day_offset', 'DbDayOffset', 'VARCHAR', true, null, null); + $this->addColumn('start_time', 'DbStartTime', 'TIME', true, null, null); + $this->addForeignKey('show_id', 'DbShowId', 'INTEGER', 'cc_show', 'id', true, null, null); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcShow', 'CcShow', RelationMap::MANY_TO_ONE, array('show_id' => 'id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcShow', 'Airtime\\CcShow', RelationMap::MANY_TO_ONE, array('show_id' => 'id', ), 'CASCADE', null); + } // buildRelations() } // CcShowRebroadcastTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcShowTableMap.php b/airtime_mvc/application/models/airtime/map/CcShowTableMap.php index 8a2686670..e0ed6c694 100644 --- a/airtime_mvc/application/models/airtime/map/CcShowTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcShowTableMap.php @@ -1,5 +1,9 @@ setName('cc_show'); - $this->setPhpName('CcShow'); - $this->setClassname('CcShow'); - $this->setPackage('airtime'); - $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('URL', 'DbUrl', 'VARCHAR', false, 255, ''); - $this->addColumn('GENRE', 'DbGenre', 'VARCHAR', false, 255, ''); - $this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null); - $this->addColumn('COLOR', 'DbColor', 'VARCHAR', false, 6, null); - $this->addColumn('BACKGROUND_COLOR', 'DbBackgroundColor', 'VARCHAR', false, 6, null); - $this->addColumn('LIVE_STREAM_USING_AIRTIME_AUTH', 'DbLiveStreamUsingAirtimeAuth', 'BOOLEAN', false, null, false); - $this->addColumn('LIVE_STREAM_USING_CUSTOM_AUTH', 'DbLiveStreamUsingCustomAuth', 'BOOLEAN', false, null, false); - $this->addColumn('LIVE_STREAM_USER', 'DbLiveStreamUser', 'VARCHAR', false, 255, null); - $this->addColumn('LIVE_STREAM_PASS', 'DbLiveStreamPass', 'VARCHAR', false, 255, null); - $this->addColumn('LINKED', 'DbLinked', 'BOOLEAN', true, null, false); - $this->addColumn('IS_LINKABLE', 'DbIsLinkable', 'BOOLEAN', true, null, true); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_show'); + $this->setPhpName('CcShow'); + $this->setClassname('Airtime\\CcShow'); + $this->setPackage('airtime'); + $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('url', 'DbUrl', 'VARCHAR', false, 255, ''); + $this->addColumn('genre', 'DbGenre', 'VARCHAR', false, 255, ''); + $this->addColumn('description', 'DbDescription', 'VARCHAR', false, 512, null); + $this->addColumn('color', 'DbColor', 'VARCHAR', false, 6, null); + $this->addColumn('background_color', 'DbBackgroundColor', 'VARCHAR', false, 6, null); + $this->addColumn('live_stream_using_airtime_auth', 'DbLiveStreamUsingAirtimeAuth', 'BOOLEAN', false, null, false); + $this->addColumn('live_stream_using_custom_auth', 'DbLiveStreamUsingCustomAuth', 'BOOLEAN', false, null, false); + $this->addColumn('live_stream_user', 'DbLiveStreamUser', 'VARCHAR', false, 255, null); + $this->addColumn('live_stream_pass', 'DbLiveStreamPass', 'VARCHAR', false, 255, null); + $this->addColumn('linked', 'DbLinked', 'BOOLEAN', true, null, false); + $this->addColumn('is_linkable', 'DbIsLinkable', 'BOOLEAN', true, null, true); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcShowInstances', 'CcShowInstances', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null); - $this->addRelation('CcShowDays', 'CcShowDays', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null); - $this->addRelation('CcShowRebroadcast', 'CcShowRebroadcast', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null); - $this->addRelation('CcShowHosts', 'CcShowHosts', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcShowInstances', 'Airtime\\CcShowInstances', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null, 'CcShowInstancess'); + $this->addRelation('CcShowDays', 'Airtime\\CcShowDays', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null, 'CcShowDayss'); + $this->addRelation('CcShowRebroadcast', 'Airtime\\CcShowRebroadcast', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null, 'CcShowRebroadcasts'); + $this->addRelation('CcShowHosts', 'Airtime\\CcShowHosts', RelationMap::ONE_TO_MANY, array('id' => 'show_id', ), 'CASCADE', null, 'CcShowHostss'); + } // buildRelations() } // CcShowTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcSmembTableMap.php b/airtime_mvc/application/models/airtime/map/CcSmembTableMap.php index 236cdd016..666b16d86 100644 --- a/airtime_mvc/application/models/airtime/map/CcSmembTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcSmembTableMap.php @@ -1,5 +1,9 @@ setName('cc_smemb'); - $this->setPhpName('CcSmemb'); - $this->setClassname('CcSmemb'); - $this->setPackage('airtime'); - $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() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_smemb'); + $this->setPhpName('CcSmemb'); + $this->setClassname('Airtime\\CcSmemb'); + $this->setPackage('airtime'); + $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() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() } // CcSmembTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcStreamSettingTableMap.php b/airtime_mvc/application/models/airtime/map/CcStreamSettingTableMap.php index d401ce096..8f9e7ed2a 100644 --- a/airtime_mvc/application/models/airtime/map/CcStreamSettingTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcStreamSettingTableMap.php @@ -1,5 +1,9 @@ setName('cc_stream_setting'); - $this->setPhpName('CcStreamSetting'); - $this->setClassname('CcStreamSetting'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(false); - // columns - $this->addPrimaryKey('KEYNAME', 'DbKeyName', 'VARCHAR', true, 64, null); - $this->addColumn('VALUE', 'DbValue', 'VARCHAR', false, 255, null); - $this->addColumn('TYPE', 'DbType', 'VARCHAR', true, 16, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_stream_setting'); + $this->setPhpName('CcStreamSetting'); + $this->setClassname('Airtime\\CcStreamSetting'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(false); + // columns + $this->addPrimaryKey('keyname', 'DbKeyName', 'VARCHAR', true, 64, null); + $this->addColumn('value', 'DbValue', 'VARCHAR', false, 255, null); + $this->addColumn('type', 'DbType', 'VARCHAR', true, 16, null); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() } // CcStreamSettingTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcSubjsTableMap.php b/airtime_mvc/application/models/airtime/map/CcSubjsTableMap.php index d4f83529a..1333998f0 100644 --- a/airtime_mvc/application/models/airtime/map/CcSubjsTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcSubjsTableMap.php @@ -1,5 +1,9 @@ setName('cc_subjs'); - $this->setPhpName('CcSubjs'); - $this->setClassname('CcSubjs'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_subjs_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addColumn('LOGIN', 'DbLogin', 'VARCHAR', true, 255, ''); - $this->addColumn('PASS', 'DbPass', 'VARCHAR', true, 255, ''); - $this->addColumn('TYPE', 'DbType', 'CHAR', true, 1, 'U'); - $this->addColumn('FIRST_NAME', 'DbFirstName', 'VARCHAR', true, 255, ''); - $this->addColumn('LAST_NAME', 'DbLastName', 'VARCHAR', true, 255, ''); - $this->addColumn('LASTLOGIN', 'DbLastlogin', 'TIMESTAMP', false, null, null); - $this->addColumn('LASTFAIL', 'DbLastfail', 'TIMESTAMP', false, null, null); - $this->addColumn('SKYPE_CONTACT', 'DbSkypeContact', 'VARCHAR', false, 255, null); - $this->addColumn('JABBER_CONTACT', 'DbJabberContact', 'VARCHAR', false, 255, null); - $this->addColumn('EMAIL', 'DbEmail', 'VARCHAR', false, 255, null); - $this->addColumn('CELL_PHONE', 'DbCellPhone', 'VARCHAR', false, 255, null); - $this->addColumn('LOGIN_ATTEMPTS', 'DbLoginAttempts', 'INTEGER', false, null, 0); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_subjs'); + $this->setPhpName('CcSubjs'); + $this->setClassname('Airtime\\CcSubjs'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_subjs_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addColumn('login', 'DbLogin', 'VARCHAR', true, 255, ''); + $this->addColumn('pass', 'DbPass', 'VARCHAR', true, 255, ''); + $this->addColumn('type', 'DbType', 'CHAR', true, 1, 'U'); + $this->addColumn('first_name', 'DbFirstName', 'VARCHAR', true, 255, ''); + $this->addColumn('last_name', 'DbLastName', 'VARCHAR', true, 255, ''); + $this->addColumn('lastlogin', 'DbLastlogin', 'TIMESTAMP', false, null, null); + $this->addColumn('lastfail', 'DbLastfail', 'TIMESTAMP', false, null, null); + $this->addColumn('skype_contact', 'DbSkypeContact', 'VARCHAR', false, null, null); + $this->addColumn('jabber_contact', 'DbJabberContact', 'VARCHAR', false, null, null); + $this->addColumn('email', 'DbEmail', 'VARCHAR', false, null, null); + $this->addColumn('cell_phone', 'DbCellPhone', 'VARCHAR', false, null, null); + $this->addColumn('login_attempts', 'DbLoginAttempts', 'INTEGER', false, null, 0); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcFilesRelatedByDbOwnerId', 'CcFiles', RelationMap::ONE_TO_MANY, array('id' => 'owner_id', ), null, null); - $this->addRelation('CcFilesRelatedByDbEditedby', '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('CcShowHosts', 'CcShowHosts', RelationMap::ONE_TO_MANY, array('id' => 'subjs_id', ), 'CASCADE', null); - $this->addRelation('CcPlaylist', 'CcPlaylist', RelationMap::ONE_TO_MANY, array('id' => 'creator_id', ), 'CASCADE', null); - $this->addRelation('CcBlock', 'CcBlock', RelationMap::ONE_TO_MANY, array('id' => 'creator_id', ), 'CASCADE', 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); - $this->addRelation('CcSubjsToken', 'CcSubjsToken', RelationMap::ONE_TO_MANY, array('id' => 'user_id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcFilesRelatedByDbOwnerId', 'Airtime\\CcFiles', RelationMap::ONE_TO_MANY, array('id' => 'owner_id', ), null, null, 'CcFilessRelatedByDbOwnerId'); + $this->addRelation('CcFilesRelatedByDbEditedby', 'Airtime\\CcFiles', RelationMap::ONE_TO_MANY, array('id' => 'editedby', ), null, null, 'CcFilessRelatedByDbEditedby'); + $this->addRelation('CcShowHosts', 'Airtime\\CcShowHosts', RelationMap::ONE_TO_MANY, array('id' => 'subjs_id', ), 'CASCADE', null, 'CcShowHostss'); + $this->addRelation('CcPlaylist', 'Airtime\\CcPlaylist', RelationMap::ONE_TO_MANY, array('id' => 'creator_id', ), 'CASCADE', null, 'CcPlaylists'); + $this->addRelation('CcBlock', 'Airtime\\CcBlock', RelationMap::ONE_TO_MANY, array('id' => 'creator_id', ), 'CASCADE', null, 'CcBlocks'); + $this->addRelation('CcPref', 'Airtime\\CcPref', RelationMap::ONE_TO_MANY, array('id' => 'subjid', ), 'CASCADE', null, 'CcPrefs'); + $this->addRelation('CcSubjsToken', 'Airtime\\CcSubjsToken', RelationMap::ONE_TO_MANY, array('id' => 'user_id', ), 'CASCADE', null, 'CcSubjsTokens'); + $this->addRelation('MediaItem', 'Airtime\\MediaItem', RelationMap::ONE_TO_MANY, array('id' => 'owner_id', ), null, null, 'MediaItems'); + $this->addRelation('AudioFile', 'Airtime\\MediaItem\\AudioFile', RelationMap::ONE_TO_MANY, array('id' => 'owner_id', ), null, null, 'AudioFiles'); + $this->addRelation('Webstream', 'Airtime\\MediaItem\\Webstream', RelationMap::ONE_TO_MANY, array('id' => 'owner_id', ), null, null, 'Webstreams'); + $this->addRelation('Playlist', 'Airtime\\MediaItem\\Playlist', RelationMap::ONE_TO_MANY, array('id' => 'owner_id', ), null, null, 'Playlists'); + $this->addRelation('Block', 'Airtime\\MediaItem\\Block', RelationMap::ONE_TO_MANY, array('id' => 'owner_id', ), null, null, 'Blocks'); + } // buildRelations() } // CcSubjsTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcSubjsTokenTableMap.php b/airtime_mvc/application/models/airtime/map/CcSubjsTokenTableMap.php index 2aeb7ad64..4a8b65ae6 100644 --- a/airtime_mvc/application/models/airtime/map/CcSubjsTokenTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcSubjsTokenTableMap.php @@ -1,5 +1,9 @@ setName('cc_subjs_token'); - $this->setPhpName('CcSubjsToken'); - $this->setClassname('CcSubjsToken'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_subjs_token_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addForeignKey('USER_ID', 'DbUserId', 'INTEGER', 'cc_subjs', 'ID', true, null, null); - $this->addColumn('ACTION', 'DbAction', 'VARCHAR', true, 255, null); - $this->addColumn('TOKEN', 'DbToken', 'VARCHAR', true, 40, null); - $this->addColumn('CREATED', 'DbCreated', 'TIMESTAMP', true, null, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_subjs_token'); + $this->setPhpName('CcSubjsToken'); + $this->setClassname('Airtime\\CcSubjsToken'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_subjs_token_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addForeignKey('user_id', 'DbUserId', 'INTEGER', 'cc_subjs', 'id', true, null, null); + $this->addColumn('action', 'DbAction', 'VARCHAR', true, 255, null); + $this->addColumn('token', 'DbToken', 'VARCHAR', true, 40, null); + $this->addColumn('created', 'DbCreated', 'TIMESTAMP', true, null, null); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('user_id' => 'id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcSubjs', 'Airtime\\CcSubjs', RelationMap::MANY_TO_ONE, array('user_id' => 'id', ), 'CASCADE', null); + } // buildRelations() } // CcSubjsTokenTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcTimestampTableMap.php b/airtime_mvc/application/models/airtime/map/CcTimestampTableMap.php index 6df327d36..9b35e04b3 100644 --- a/airtime_mvc/application/models/airtime/map/CcTimestampTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcTimestampTableMap.php @@ -1,5 +1,9 @@ setName('cc_timestamp'); - $this->setPhpName('CcTimestamp'); - $this->setClassname('CcTimestamp'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_timestamp_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addColumn('TIMESTAMP', 'DbTimestamp', 'TIMESTAMP', true, null, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_timestamp'); + $this->setPhpName('CcTimestamp'); + $this->setClassname('Airtime\\CcTimestamp'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_timestamp_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addColumn('timestamp', 'DbTimestamp', 'TIMESTAMP', true, null, null); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcListenerCount', 'CcListenerCount', RelationMap::ONE_TO_MANY, array('id' => 'timestamp_id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcListenerCount', 'Airtime\\CcListenerCount', RelationMap::ONE_TO_MANY, array('id' => 'timestamp_id', ), 'CASCADE', null, 'CcListenerCounts'); + } // buildRelations() } // CcTimestampTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcWebstreamMetadataTableMap.php b/airtime_mvc/application/models/airtime/map/CcWebstreamMetadataTableMap.php index 305d8189a..029497c03 100644 --- a/airtime_mvc/application/models/airtime/map/CcWebstreamMetadataTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcWebstreamMetadataTableMap.php @@ -1,5 +1,9 @@ setName('cc_webstream_metadata'); - $this->setPhpName('CcWebstreamMetadata'); - $this->setClassname('CcWebstreamMetadata'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_webstream_metadata_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addForeignKey('INSTANCE_ID', 'DbInstanceId', 'INTEGER', 'cc_schedule', 'ID', true, null, null); - $this->addColumn('START_TIME', 'DbStartTime', 'TIMESTAMP', true, null, null); - $this->addColumn('LIQUIDSOAP_DATA', 'DbLiquidsoapData', 'VARCHAR', true, 1024, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_webstream_metadata'); + $this->setPhpName('CcWebstreamMetadata'); + $this->setClassname('Airtime\\CcWebstreamMetadata'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_webstream_metadata_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addForeignKey('instance_id', 'DbInstanceId', 'INTEGER', 'cc_schedule', 'id', true, null, null); + $this->addColumn('start_time', 'DbStartTime', 'TIMESTAMP', true, null, null); + $this->addColumn('liquidsoap_data', 'DbLiquidsoapData', 'VARCHAR', true, 1024, null); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcSchedule', 'CcSchedule', RelationMap::MANY_TO_ONE, array('instance_id' => 'id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcSchedule', 'Airtime\\CcSchedule', RelationMap::MANY_TO_ONE, array('instance_id' => 'id', ), 'CASCADE', null); + } // buildRelations() } // CcWebstreamMetadataTableMap diff --git a/airtime_mvc/application/models/airtime/map/CcWebstreamTableMap.php b/airtime_mvc/application/models/airtime/map/CcWebstreamTableMap.php index c4b28a516..29073eead 100644 --- a/airtime_mvc/application/models/airtime/map/CcWebstreamTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcWebstreamTableMap.php @@ -1,5 +1,9 @@ setName('cc_webstream'); - $this->setPhpName('CcWebstream'); - $this->setClassname('CcWebstream'); - $this->setPackage('airtime'); - $this->setUseIdGenerator(true); - $this->setPrimaryKeyMethodInfo('cc_webstream_id_seq'); - // columns - $this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null); - $this->addColumn('NAME', 'DbName', 'VARCHAR', true, 255, null); - $this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', true, 255, null); - $this->addColumn('URL', 'DbUrl', 'VARCHAR', true, 512, null); - $this->addColumn('LENGTH', 'DbLength', 'VARCHAR', true, null, '00:00:00'); - $this->addColumn('CREATOR_ID', 'DbCreatorId', 'INTEGER', true, null, null); - $this->addColumn('MTIME', 'DbMtime', 'TIMESTAMP', true, 6, null); - $this->addColumn('UTIME', 'DbUtime', 'TIMESTAMP', true, 6, null); - $this->addColumn('LPTIME', 'DbLPtime', 'TIMESTAMP', false, 6, null); - $this->addColumn('MIME', 'DbMime', 'VARCHAR', false, 255, null); - // validators - } // initialize() + /** + * Initialize the table attributes, columns and validators + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('cc_webstream'); + $this->setPhpName('CcWebstream'); + $this->setClassname('Airtime\\CcWebstream'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('cc_webstream_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addColumn('name', 'DbName', 'VARCHAR', true, 255, null); + $this->addColumn('description', 'DbDescription', 'VARCHAR', true, 255, null); + $this->addColumn('url', 'DbUrl', 'VARCHAR', true, 512, null); + $this->addColumn('length', 'DbLength', 'VARCHAR', true, null, '00:00:00'); + $this->addColumn('creator_id', 'DbCreatorId', 'INTEGER', true, null, null); + $this->addColumn('mtime', 'DbMtime', 'TIMESTAMP', true, 6, null); + $this->addColumn('utime', 'DbUtime', 'TIMESTAMP', true, 6, null); + $this->addColumn('lptime', 'DbLPtime', 'TIMESTAMP', false, 6, null); + $this->addColumn('mime', 'DbMime', 'VARCHAR', false, null, null); + // validators + } // initialize() - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CcSchedule', 'CcSchedule', RelationMap::ONE_TO_MANY, array('id' => 'stream_id', ), 'CASCADE', null); - } // buildRelations() + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcSchedule', 'Airtime\\CcSchedule', RelationMap::ONE_TO_MANY, array('id' => 'stream_id', ), 'CASCADE', null, 'CcSchedules'); + } // buildRelations() } // CcWebstreamTableMap diff --git a/airtime_mvc/application/models/airtime/map/MediaContentsTableMap.php b/airtime_mvc/application/models/airtime/map/MediaContentsTableMap.php new file mode 100644 index 000000000..f53320a05 --- /dev/null +++ b/airtime_mvc/application/models/airtime/map/MediaContentsTableMap.php @@ -0,0 +1,66 @@ +setName('media_contents'); + $this->setPhpName('MediaContents'); + $this->setClassname('Airtime\\MediaItem\\MediaContents'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('media_contents_id_seq'); + // columns + $this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null); + $this->addForeignKey('media_id', 'MediaId', 'INTEGER', 'media_item', 'id', false, null, null); + $this->addColumn('position', 'Position', 'INTEGER', false, null, null); + $this->addColumn('trackoffset', 'TrackOffset', 'REAL', true, null, 0); + $this->addColumn('cliplength', 'Cliplength', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('cuein', 'Cuein', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('cueout', 'Cueout', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('fadein', 'Fadein', 'TIME', false, null, '00:00:00'); + $this->addColumn('fadeout', 'Fadeout', 'TIME', false, null, '00:00:00'); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('MediaItem', 'Airtime\\MediaItem', RelationMap::MANY_TO_ONE, array('media_id' => 'id', ), 'CASCADE', null); + } // buildRelations() + +} // MediaContentsTableMap diff --git a/airtime_mvc/application/models/airtime/map/MediaItemTableMap.php b/airtime_mvc/application/models/airtime/map/MediaItemTableMap.php new file mode 100644 index 000000000..d56650708 --- /dev/null +++ b/airtime_mvc/application/models/airtime/map/MediaItemTableMap.php @@ -0,0 +1,92 @@ +setName('media_item'); + $this->setPhpName('MediaItem'); + $this->setClassname('Airtime\\MediaItem'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(true); + $this->setPrimaryKeyMethodInfo('media_item_id_seq'); + // columns + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); + $this->addColumn('name', 'Name', 'VARCHAR', true, 128, null); + $this->addForeignKey('owner_id', 'OwnerId', 'INTEGER', 'cc_subjs', 'id', false, null, null); + $this->addColumn('description', 'Description', 'VARCHAR', false, 512, null); + $this->addColumn('last_played', 'LastPlayedTime', 'TIMESTAMP', false, 6, null); + $this->addColumn('play_count', 'PlayCount', 'INTEGER', false, null, 0); + $this->addColumn('length', 'Length', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('descendant_class', 'DescendantClass', 'VARCHAR', false, 100, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CcSubjs', 'Airtime\\CcSubjs', RelationMap::MANY_TO_ONE, array('owner_id' => 'id', ), null, null); + $this->addRelation('MediaContents', 'Airtime\\MediaItem\\MediaContents', RelationMap::ONE_TO_MANY, array('id' => 'media_id', ), 'CASCADE', null, 'MediaContentss'); + $this->addRelation('AudioFile', 'Airtime\\MediaItem\\AudioFile', RelationMap::ONE_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + $this->addRelation('Webstream', 'Airtime\\MediaItem\\Webstream', RelationMap::ONE_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + $this->addRelation('Playlist', 'Airtime\\MediaItem\\Playlist', RelationMap::ONE_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + $this->addRelation('Block', 'Airtime\\MediaItem\\Block', RelationMap::ONE_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'concrete_inheritance_parent' => array ( + 'descendant_column' => 'descendant_class', +), + ); + } // getBehaviors() + +} // MediaItemTableMap diff --git a/airtime_mvc/application/models/airtime/map/PlaylistTableMap.php b/airtime_mvc/application/models/airtime/map/PlaylistTableMap.php new file mode 100644 index 000000000..000646310 --- /dev/null +++ b/airtime_mvc/application/models/airtime/map/PlaylistTableMap.php @@ -0,0 +1,95 @@ +setName('playlist'); + $this->setPhpName('Playlist'); + $this->setClassname('Airtime\\MediaItem\\Playlist'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'media_item', 'id', true, null, null); + $this->addColumn('name', 'Name', 'VARCHAR', true, 128, null); + $this->addForeignKey('owner_id', 'OwnerId', 'INTEGER', 'cc_subjs', 'id', false, null, null); + $this->addColumn('description', 'Description', 'VARCHAR', false, 512, null); + $this->addColumn('last_played', 'LastPlayedTime', 'TIMESTAMP', false, 6, null); + $this->addColumn('play_count', 'PlayCount', 'INTEGER', false, null, 0); + $this->addColumn('length', 'Length', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('descendant_class', 'DescendantClass', 'VARCHAR', false, 100, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('MediaItem', 'Airtime\\MediaItem', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcSubjs', 'Airtime\\CcSubjs', RelationMap::MANY_TO_ONE, array('owner_id' => 'id', ), null, null); + $this->addRelation('Block', 'Airtime\\MediaItem\\Block', RelationMap::ONE_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'concrete_inheritance' => array ( + 'extends' => 'media_item', + 'descendant_column' => 'descendant_class', + 'copy_data_to_parent' => 'true', + 'schema' => '', + 'excluded_parent_behavior' => 'nested_set', +), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + 'concrete_inheritance_parent' => array ( + 'descendant_column' => 'descendant_class', +), + ); + } // getBehaviors() + +} // PlaylistTableMap diff --git a/airtime_mvc/application/models/airtime/map/WebstreamTableMap.php b/airtime_mvc/application/models/airtime/map/WebstreamTableMap.php new file mode 100644 index 000000000..678032090 --- /dev/null +++ b/airtime_mvc/application/models/airtime/map/WebstreamTableMap.php @@ -0,0 +1,92 @@ +setName('webstream'); + $this->setPhpName('Webstream'); + $this->setClassname('Airtime\\MediaItem\\Webstream'); + $this->setPackage('airtime'); + $this->setUseIdGenerator(false); + // columns + $this->addColumn('mime', 'Mime', 'VARCHAR', false, null, null); + $this->addColumn('url', 'Url', 'VARCHAR', true, 512, null); + $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'media_item', 'id', true, null, null); + $this->addColumn('name', 'Name', 'VARCHAR', true, 128, null); + $this->addForeignKey('owner_id', 'OwnerId', 'INTEGER', 'cc_subjs', 'id', false, null, null); + $this->addColumn('description', 'Description', 'VARCHAR', false, 512, null); + $this->addColumn('last_played', 'LastPlayedTime', 'TIMESTAMP', false, 6, null); + $this->addColumn('play_count', 'PlayCount', 'INTEGER', false, null, 0); + $this->addColumn('length', 'Length', 'VARCHAR', false, null, '00:00:00'); + $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); + // validators + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('MediaItem', 'Airtime\\MediaItem', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + $this->addRelation('CcSubjs', 'Airtime\\CcSubjs', RelationMap::MANY_TO_ONE, array('owner_id' => 'id', ), null, null); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'concrete_inheritance' => array ( + 'extends' => 'media_item', + 'descendant_column' => 'descendant_class', + 'copy_data_to_parent' => 'true', + 'schema' => '', + 'excluded_parent_behavior' => 'nested_set', +), + 'timestampable' => array ( + 'create_column' => 'created_at', + 'update_column' => 'updated_at', + 'disable_updated_at' => 'false', +), + ); + } // getBehaviors() + +} // WebstreamTableMap diff --git a/airtime_mvc/application/models/airtime/om/BaseAudioFile.php b/airtime_mvc/application/models/airtime/om/BaseAudioFile.php new file mode 100644 index 000000000..5b6c5471c --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseAudioFile.php @@ -0,0 +1,3588 @@ +filepath = ''; + $this->cuein = '00:00:00'; + $this->cueout = '00:00:00'; + $this->silan_check = false; + $this->file_exists = true; + $this->hidden = false; + $this->is_scheduled = false; + $this->is_playlist = false; + $this->play_count = 0; + $this->length = '00:00:00'; + } + + /** + * Initializes internal state of BaseAudioFile object. + * @see applyDefaults() + */ + public function __construct() + { + parent::__construct(); + $this->applyDefaultValues(); + } + + /** + * Get the [mime] column value. + * + * @return string + */ + public function getMime() + { + + return $this->mime; + } + + /** + * Get the [directory] column value. + * + * @return int + */ + public function getDirectory() + { + + return $this->directory; + } + + /** + * Get the [filepath] column value. + * + * @return string + */ + public function getFilepath() + { + + return $this->filepath; + } + + /** + * 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 int + */ + public function getBitRate() + { + + return $this->bit_rate; + } + + /** + * Get the [sample_rate] column value. + * + * @return int + */ + public function getSampleRate() + { + + return $this->sample_rate; + } + + /** + * 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 int + */ + public function getBpm() + { + + return $this->bpm; + } + + /** + * Get the [encoded_by] column value. + * + * @return string + */ + public function getEncodedBy() + { + + return $this->encoded_by; + } + + /** + * 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 [copyright] column value. + * + * @return string + */ + public function getCopyright() + { + + return $this->copyright; + } + + /** + * Get the [isrc_number] column value. + * + * @return string + */ + public function getIsrcNumber() + { + + return $this->isrc_number; + } + + /** + * Get the [info_url] column value. + * + * @return string + */ + public function getInfoUrl() + { + + return $this->info_url; + } + + /** + * Get the [language] column value. + * + * @return string + */ + public function getLanguage() + { + + return $this->language; + } + + /** + * Get the [replay_gain] column value. + * + * @return string + */ + public function getReplayGain() + { + + return $this->replay_gain; + } + + /** + * Get the [cuein] column value. + * + * @return string + */ + public function getCuein() + { + + return $this->cuein; + } + + /** + * Get the [cueout] column value. + * + * @return string + */ + public function getCueout() + { + + return $this->cueout; + } + + /** + * Get the [silan_check] column value. + * + * @return boolean + */ + public function getIsSilanChecked() + { + + return $this->silan_check; + } + + /** + * Get the [file_exists] column value. + * + * @return boolean + */ + public function getFileExists() + { + + return $this->file_exists; + } + + /** + * Get the [hidden] column value. + * + * @return boolean + */ + public function getIsHidden() + { + + return $this->hidden; + } + + /** + * Get the [is_scheduled] column value. + * + * @return boolean + */ + public function getIsScheduled() + { + + return $this->is_scheduled; + } + + /** + * Get the [is_playlist] column value. + * + * @return boolean + */ + public function getIsPlaylist() + { + + return $this->is_playlist; + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [name] column value. + * + * @return string + */ + public function getName() + { + + return $this->name; + } + + /** + * Get the [owner_id] column value. + * + * @return int + */ + public function getOwnerId() + { + + return $this->owner_id; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [optionally formatted] temporal [last_played] 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 getLastPlayedTime($format = 'Y-m-d H:i:s') + { + if ($this->last_played === null) { + return null; + } + + + try { + $dt = new DateTime($this->last_played); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->last_played, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [play_count] column value. + * + * @return int + */ + public function getPlayCount() + { + + return $this->play_count; + } + + /** + * Get the [length] column value. + * + * @return string + */ + public function getLength() + { + + return $this->length; + } + + /** + * Get the [optionally formatted] temporal [created_at] 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 getCreatedAt($format = 'Y-m-d H:i:s') + { + if ($this->created_at === null) { + return null; + } + + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [optionally formatted] temporal [updated_at] 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 getUpdatedAt($format = 'Y-m-d H:i:s') + { + if ($this->updated_at === null) { + return null; + } + + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Set the value of [mime] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setMime($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->mime !== $v) { + $this->mime = $v; + $this->modifiedColumns[] = AudioFilePeer::MIME; + } + + + return $this; + } // setMime() + + /** + * Set the value of [directory] column. + * + * @param int $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setDirectory($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->directory !== $v) { + $this->directory = $v; + $this->modifiedColumns[] = AudioFilePeer::DIRECTORY; + } + + if ($this->aCcMusicDirs !== null && $this->aCcMusicDirs->getId() !== $v) { + $this->aCcMusicDirs = null; + } + + + return $this; + } // setDirectory() + + /** + * Set the value of [filepath] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setFilepath($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->filepath !== $v) { + $this->filepath = $v; + $this->modifiedColumns[] = AudioFilePeer::FILEPATH; + } + + + return $this; + } // setFilepath() + + /** + * Set the value of [md5] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setMd5($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->md5 !== $v) { + $this->md5 = $v; + $this->modifiedColumns[] = AudioFilePeer::MD5; + } + + + return $this; + } // setMd5() + + /** + * Set the value of [track_title] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setTrackTitle($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->track_title !== $v) { + $this->track_title = $v; + $this->modifiedColumns[] = AudioFilePeer::TRACK_TITLE; + } + + + return $this; + } // setTrackTitle() + + /** + * Set the value of [artist_name] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setArtistName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->artist_name !== $v) { + $this->artist_name = $v; + $this->modifiedColumns[] = AudioFilePeer::ARTIST_NAME; + } + + + return $this; + } // setArtistName() + + /** + * Set the value of [bit_rate] column. + * + * @param int $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setBitRate($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->bit_rate !== $v) { + $this->bit_rate = $v; + $this->modifiedColumns[] = AudioFilePeer::BIT_RATE; + } + + + return $this; + } // setBitRate() + + /** + * Set the value of [sample_rate] column. + * + * @param int $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setSampleRate($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->sample_rate !== $v) { + $this->sample_rate = $v; + $this->modifiedColumns[] = AudioFilePeer::SAMPLE_RATE; + } + + + return $this; + } // setSampleRate() + + /** + * Set the value of [album_title] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setAlbumTitle($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->album_title !== $v) { + $this->album_title = $v; + $this->modifiedColumns[] = AudioFilePeer::ALBUM_TITLE; + } + + + return $this; + } // setAlbumTitle() + + /** + * Set the value of [genre] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setGenre($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->genre !== $v) { + $this->genre = $v; + $this->modifiedColumns[] = AudioFilePeer::GENRE; + } + + + return $this; + } // setGenre() + + /** + * Set the value of [comments] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setComments($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->comments !== $v) { + $this->comments = $v; + $this->modifiedColumns[] = AudioFilePeer::COMMENTS; + } + + + return $this; + } // setComments() + + /** + * Set the value of [year] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setYear($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->year !== $v) { + $this->year = $v; + $this->modifiedColumns[] = AudioFilePeer::YEAR; + } + + + return $this; + } // setYear() + + /** + * Set the value of [track_number] column. + * + * @param int $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setTrackNumber($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->track_number !== $v) { + $this->track_number = $v; + $this->modifiedColumns[] = AudioFilePeer::TRACK_NUMBER; + } + + + return $this; + } // setTrackNumber() + + /** + * Set the value of [channels] column. + * + * @param int $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setChannels($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->channels !== $v) { + $this->channels = $v; + $this->modifiedColumns[] = AudioFilePeer::CHANNELS; + } + + + return $this; + } // setChannels() + + /** + * Set the value of [url] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setUrl($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->url !== $v) { + $this->url = $v; + $this->modifiedColumns[] = AudioFilePeer::URL; + } + + + return $this; + } // setUrl() + + /** + * Set the value of [bpm] column. + * + * @param int $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setBpm($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->bpm !== $v) { + $this->bpm = $v; + $this->modifiedColumns[] = AudioFilePeer::BPM; + } + + + return $this; + } // setBpm() + + /** + * Set the value of [encoded_by] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setEncodedBy($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->encoded_by !== $v) { + $this->encoded_by = $v; + $this->modifiedColumns[] = AudioFilePeer::ENCODED_BY; + } + + + return $this; + } // setEncodedBy() + + /** + * Set the value of [mood] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setMood($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->mood !== $v) { + $this->mood = $v; + $this->modifiedColumns[] = AudioFilePeer::MOOD; + } + + + return $this; + } // setMood() + + /** + * Set the value of [label] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setLabel($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->label !== $v) { + $this->label = $v; + $this->modifiedColumns[] = AudioFilePeer::LABEL; + } + + + return $this; + } // setLabel() + + /** + * Set the value of [composer] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setComposer($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->composer !== $v) { + $this->composer = $v; + $this->modifiedColumns[] = AudioFilePeer::COMPOSER; + } + + + return $this; + } // setComposer() + + /** + * Set the value of [copyright] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setCopyright($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->copyright !== $v) { + $this->copyright = $v; + $this->modifiedColumns[] = AudioFilePeer::COPYRIGHT; + } + + + return $this; + } // setCopyright() + + /** + * Set the value of [isrc_number] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setIsrcNumber($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->isrc_number !== $v) { + $this->isrc_number = $v; + $this->modifiedColumns[] = AudioFilePeer::ISRC_NUMBER; + } + + + return $this; + } // setIsrcNumber() + + /** + * Set the value of [info_url] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setInfoUrl($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->info_url !== $v) { + $this->info_url = $v; + $this->modifiedColumns[] = AudioFilePeer::INFO_URL; + } + + + return $this; + } // setInfoUrl() + + /** + * Set the value of [language] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setLanguage($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->language !== $v) { + $this->language = $v; + $this->modifiedColumns[] = AudioFilePeer::LANGUAGE; + } + + + return $this; + } // setLanguage() + + /** + * Set the value of [replay_gain] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setReplayGain($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->replay_gain !== $v) { + $this->replay_gain = $v; + $this->modifiedColumns[] = AudioFilePeer::REPLAY_GAIN; + } + + + return $this; + } // setReplayGain() + + /** + * Set the value of [cuein] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setCuein($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->cuein !== $v) { + $this->cuein = $v; + $this->modifiedColumns[] = AudioFilePeer::CUEIN; + } + + + return $this; + } // setCuein() + + /** + * Set the value of [cueout] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setCueout($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->cueout !== $v) { + $this->cueout = $v; + $this->modifiedColumns[] = AudioFilePeer::CUEOUT; + } + + + return $this; + } // setCueout() + + /** + * Sets the value of the [silan_check] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return AudioFile The current object (for fluent API support) + */ + public function setIsSilanChecked($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->silan_check !== $v) { + $this->silan_check = $v; + $this->modifiedColumns[] = AudioFilePeer::SILAN_CHECK; + } + + + return $this; + } // setIsSilanChecked() + + /** + * Sets the value of the [file_exists] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return AudioFile The current object (for fluent API support) + */ + public function setFileExists($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->file_exists !== $v) { + $this->file_exists = $v; + $this->modifiedColumns[] = AudioFilePeer::FILE_EXISTS; + } + + + return $this; + } // setFileExists() + + /** + * Sets the value of the [hidden] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return AudioFile The current object (for fluent API support) + */ + public function setIsHidden($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->hidden !== $v) { + $this->hidden = $v; + $this->modifiedColumns[] = AudioFilePeer::HIDDEN; + } + + + return $this; + } // setIsHidden() + + /** + * Sets the value of the [is_scheduled] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return AudioFile The current object (for fluent API support) + */ + public function setIsScheduled($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_scheduled !== $v) { + $this->is_scheduled = $v; + $this->modifiedColumns[] = AudioFilePeer::IS_SCHEDULED; + } + + + return $this; + } // setIsScheduled() + + /** + * Sets the value of the [is_playlist] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return AudioFile The current object (for fluent API support) + */ + public function setIsPlaylist($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_playlist !== $v) { + $this->is_playlist = $v; + $this->modifiedColumns[] = AudioFilePeer::IS_PLAYLIST; + } + + + return $this; + } // setIsPlaylist() + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = AudioFilePeer::ID; + } + + if ($this->aMediaItem !== null && $this->aMediaItem->getId() !== $v) { + $this->aMediaItem = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = AudioFilePeer::NAME; + } + + + return $this; + } // setName() + + /** + * Set the value of [owner_id] column. + * + * @param int $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setOwnerId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->owner_id !== $v) { + $this->owner_id = $v; + $this->modifiedColumns[] = AudioFilePeer::OWNER_ID; + } + + if ($this->aCcSubjs !== null && $this->aCcSubjs->getDbId() !== $v) { + $this->aCcSubjs = null; + } + + + return $this; + } // setOwnerId() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = AudioFilePeer::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Sets the value of [last_played] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return AudioFile The current object (for fluent API support) + */ + public function setLastPlayedTime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->last_played !== null || $dt !== null) { + $currentDateAsString = ($this->last_played !== null && $tmpDt = new DateTime($this->last_played)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->last_played = $newDateAsString; + $this->modifiedColumns[] = AudioFilePeer::LAST_PLAYED; + } + } // if either are not null + + + return $this; + } // setLastPlayedTime() + + /** + * Set the value of [play_count] column. + * + * @param int $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setPlayCount($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->play_count !== $v) { + $this->play_count = $v; + $this->modifiedColumns[] = AudioFilePeer::PLAY_COUNT; + } + + + return $this; + } // setPlayCount() + + /** + * Set the value of [length] column. + * + * @param string $v new value + * @return AudioFile The current object (for fluent API support) + */ + public function setLength($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->length !== $v) { + $this->length = $v; + $this->modifiedColumns[] = AudioFilePeer::LENGTH; + } + + + return $this; + } // setLength() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return AudioFile The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->created_at !== null || $dt !== null) { + $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->created_at = $newDateAsString; + $this->modifiedColumns[] = AudioFilePeer::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return AudioFile The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->updated_at !== null || $dt !== null) { + $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->updated_at = $newDateAsString; + $this->modifiedColumns[] = AudioFilePeer::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * 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->filepath !== '') { + return false; + } + + if ($this->cuein !== '00:00:00') { + return false; + } + + if ($this->cueout !== '00:00:00') { + return false; + } + + if ($this->silan_check !== false) { + return false; + } + + if ($this->file_exists !== true) { + return false; + } + + if ($this->hidden !== false) { + return false; + } + + if ($this->is_scheduled !== false) { + return false; + } + + if ($this->is_playlist !== false) { + return false; + } + + if ($this->play_count !== 0) { + return false; + } + + if ($this->length !== '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 resultset 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->mime = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null; + $this->directory = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->filepath = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->md5 = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->track_title = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->artist_name = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->bit_rate = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; + $this->sample_rate = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null; + $this->album_title = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->genre = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->comments = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; + $this->year = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null; + $this->track_number = ($row[$startcol + 12] !== null) ? (int) $row[$startcol + 12] : null; + $this->channels = ($row[$startcol + 13] !== null) ? (int) $row[$startcol + 13] : null; + $this->url = ($row[$startcol + 14] !== null) ? (string) $row[$startcol + 14] : null; + $this->bpm = ($row[$startcol + 15] !== null) ? (int) $row[$startcol + 15] : null; + $this->encoded_by = ($row[$startcol + 16] !== null) ? (string) $row[$startcol + 16] : null; + $this->mood = ($row[$startcol + 17] !== null) ? (string) $row[$startcol + 17] : null; + $this->label = ($row[$startcol + 18] !== null) ? (string) $row[$startcol + 18] : null; + $this->composer = ($row[$startcol + 19] !== null) ? (string) $row[$startcol + 19] : null; + $this->copyright = ($row[$startcol + 20] !== null) ? (string) $row[$startcol + 20] : null; + $this->isrc_number = ($row[$startcol + 21] !== null) ? (string) $row[$startcol + 21] : null; + $this->info_url = ($row[$startcol + 22] !== null) ? (string) $row[$startcol + 22] : null; + $this->language = ($row[$startcol + 23] !== null) ? (string) $row[$startcol + 23] : null; + $this->replay_gain = ($row[$startcol + 24] !== null) ? (string) $row[$startcol + 24] : null; + $this->cuein = ($row[$startcol + 25] !== null) ? (string) $row[$startcol + 25] : null; + $this->cueout = ($row[$startcol + 26] !== null) ? (string) $row[$startcol + 26] : null; + $this->silan_check = ($row[$startcol + 27] !== null) ? (boolean) $row[$startcol + 27] : null; + $this->file_exists = ($row[$startcol + 28] !== null) ? (boolean) $row[$startcol + 28] : null; + $this->hidden = ($row[$startcol + 29] !== null) ? (boolean) $row[$startcol + 29] : null; + $this->is_scheduled = ($row[$startcol + 30] !== null) ? (boolean) $row[$startcol + 30] : null; + $this->is_playlist = ($row[$startcol + 31] !== null) ? (boolean) $row[$startcol + 31] : null; + $this->id = ($row[$startcol + 32] !== null) ? (int) $row[$startcol + 32] : null; + $this->name = ($row[$startcol + 33] !== null) ? (string) $row[$startcol + 33] : null; + $this->owner_id = ($row[$startcol + 34] !== null) ? (int) $row[$startcol + 34] : null; + $this->description = ($row[$startcol + 35] !== null) ? (string) $row[$startcol + 35] : null; + $this->last_played = ($row[$startcol + 36] !== null) ? (string) $row[$startcol + 36] : null; + $this->play_count = ($row[$startcol + 37] !== null) ? (int) $row[$startcol + 37] : null; + $this->length = ($row[$startcol + 38] !== null) ? (string) $row[$startcol + 38] : null; + $this->created_at = ($row[$startcol + 39] !== null) ? (string) $row[$startcol + 39] : null; + $this->updated_at = ($row[$startcol + 40] !== null) ? (string) $row[$startcol + 40] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 41; // 41 = AudioFilePeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating AudioFile 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->aCcMusicDirs !== null && $this->directory !== $this->aCcMusicDirs->getId()) { + $this->aCcMusicDirs = null; + } + if ($this->aMediaItem !== null && $this->id !== $this->aMediaItem->getId()) { + $this->aMediaItem = null; + } + if ($this->aCcSubjs !== null && $this->owner_id !== $this->aCcSubjs->getDbId()) { + $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(AudioFilePeer::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 = AudioFilePeer::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->aCcMusicDirs = null; + $this->aMediaItem = null; + $this->aCcSubjs = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(AudioFilePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = AudioFileQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + // concrete_inheritance behavior + $this->getParentOrCreate($con)->delete($con); + + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(AudioFilePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + // concrete_inheritance behavior + $parent = $this->getSyncParent($con); + $parent->save($con); + $this->setPrimaryKey($parent->getPrimaryKey()); + + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AudioFilePeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AudioFilePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AudioFilePeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + AudioFilePeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcMusicDirs !== null) { + if ($this->aCcMusicDirs->isModified() || $this->aCcMusicDirs->isNew()) { + $affectedRows += $this->aCcMusicDirs->save($con); + } + $this->setCcMusicDirs($this->aCcMusicDirs); + } + + if ($this->aMediaItem !== null) { + if ($this->aMediaItem->isModified() || $this->aMediaItem->isNew()) { + $affectedRows += $this->aMediaItem->save($con); + } + $this->setMediaItem($this->aMediaItem); + } + + if ($this->aCcSubjs !== null) { + if ($this->aCcSubjs->isModified() || $this->aCcSubjs->isNew()) { + $affectedRows += $this->aCcSubjs->save($con); + } + $this->setCcSubjs($this->aCcSubjs); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(AudioFilePeer::MIME)) { + $modifiedColumns[':p' . $index++] = '"mime"'; + } + if ($this->isColumnModified(AudioFilePeer::DIRECTORY)) { + $modifiedColumns[':p' . $index++] = '"directory"'; + } + if ($this->isColumnModified(AudioFilePeer::FILEPATH)) { + $modifiedColumns[':p' . $index++] = '"filepath"'; + } + if ($this->isColumnModified(AudioFilePeer::MD5)) { + $modifiedColumns[':p' . $index++] = '"md5"'; + } + if ($this->isColumnModified(AudioFilePeer::TRACK_TITLE)) { + $modifiedColumns[':p' . $index++] = '"track_title"'; + } + if ($this->isColumnModified(AudioFilePeer::ARTIST_NAME)) { + $modifiedColumns[':p' . $index++] = '"artist_name"'; + } + if ($this->isColumnModified(AudioFilePeer::BIT_RATE)) { + $modifiedColumns[':p' . $index++] = '"bit_rate"'; + } + if ($this->isColumnModified(AudioFilePeer::SAMPLE_RATE)) { + $modifiedColumns[':p' . $index++] = '"sample_rate"'; + } + if ($this->isColumnModified(AudioFilePeer::ALBUM_TITLE)) { + $modifiedColumns[':p' . $index++] = '"album_title"'; + } + if ($this->isColumnModified(AudioFilePeer::GENRE)) { + $modifiedColumns[':p' . $index++] = '"genre"'; + } + if ($this->isColumnModified(AudioFilePeer::COMMENTS)) { + $modifiedColumns[':p' . $index++] = '"comments"'; + } + if ($this->isColumnModified(AudioFilePeer::YEAR)) { + $modifiedColumns[':p' . $index++] = '"year"'; + } + if ($this->isColumnModified(AudioFilePeer::TRACK_NUMBER)) { + $modifiedColumns[':p' . $index++] = '"track_number"'; + } + if ($this->isColumnModified(AudioFilePeer::CHANNELS)) { + $modifiedColumns[':p' . $index++] = '"channels"'; + } + if ($this->isColumnModified(AudioFilePeer::URL)) { + $modifiedColumns[':p' . $index++] = '"url"'; + } + if ($this->isColumnModified(AudioFilePeer::BPM)) { + $modifiedColumns[':p' . $index++] = '"bpm"'; + } + if ($this->isColumnModified(AudioFilePeer::ENCODED_BY)) { + $modifiedColumns[':p' . $index++] = '"encoded_by"'; + } + if ($this->isColumnModified(AudioFilePeer::MOOD)) { + $modifiedColumns[':p' . $index++] = '"mood"'; + } + if ($this->isColumnModified(AudioFilePeer::LABEL)) { + $modifiedColumns[':p' . $index++] = '"label"'; + } + if ($this->isColumnModified(AudioFilePeer::COMPOSER)) { + $modifiedColumns[':p' . $index++] = '"composer"'; + } + if ($this->isColumnModified(AudioFilePeer::COPYRIGHT)) { + $modifiedColumns[':p' . $index++] = '"copyright"'; + } + if ($this->isColumnModified(AudioFilePeer::ISRC_NUMBER)) { + $modifiedColumns[':p' . $index++] = '"isrc_number"'; + } + if ($this->isColumnModified(AudioFilePeer::INFO_URL)) { + $modifiedColumns[':p' . $index++] = '"info_url"'; + } + if ($this->isColumnModified(AudioFilePeer::LANGUAGE)) { + $modifiedColumns[':p' . $index++] = '"language"'; + } + if ($this->isColumnModified(AudioFilePeer::REPLAY_GAIN)) { + $modifiedColumns[':p' . $index++] = '"replay_gain"'; + } + if ($this->isColumnModified(AudioFilePeer::CUEIN)) { + $modifiedColumns[':p' . $index++] = '"cuein"'; + } + if ($this->isColumnModified(AudioFilePeer::CUEOUT)) { + $modifiedColumns[':p' . $index++] = '"cueout"'; + } + if ($this->isColumnModified(AudioFilePeer::SILAN_CHECK)) { + $modifiedColumns[':p' . $index++] = '"silan_check"'; + } + if ($this->isColumnModified(AudioFilePeer::FILE_EXISTS)) { + $modifiedColumns[':p' . $index++] = '"file_exists"'; + } + if ($this->isColumnModified(AudioFilePeer::HIDDEN)) { + $modifiedColumns[':p' . $index++] = '"hidden"'; + } + if ($this->isColumnModified(AudioFilePeer::IS_SCHEDULED)) { + $modifiedColumns[':p' . $index++] = '"is_scheduled"'; + } + if ($this->isColumnModified(AudioFilePeer::IS_PLAYLIST)) { + $modifiedColumns[':p' . $index++] = '"is_playlist"'; + } + if ($this->isColumnModified(AudioFilePeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(AudioFilePeer::NAME)) { + $modifiedColumns[':p' . $index++] = '"name"'; + } + if ($this->isColumnModified(AudioFilePeer::OWNER_ID)) { + $modifiedColumns[':p' . $index++] = '"owner_id"'; + } + if ($this->isColumnModified(AudioFilePeer::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = '"description"'; + } + if ($this->isColumnModified(AudioFilePeer::LAST_PLAYED)) { + $modifiedColumns[':p' . $index++] = '"last_played"'; + } + if ($this->isColumnModified(AudioFilePeer::PLAY_COUNT)) { + $modifiedColumns[':p' . $index++] = '"play_count"'; + } + if ($this->isColumnModified(AudioFilePeer::LENGTH)) { + $modifiedColumns[':p' . $index++] = '"length"'; + } + if ($this->isColumnModified(AudioFilePeer::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = '"created_at"'; + } + if ($this->isColumnModified(AudioFilePeer::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = '"updated_at"'; + } + + $sql = sprintf( + 'INSERT INTO "audio_file" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"mime"': + $stmt->bindValue($identifier, $this->mime, PDO::PARAM_STR); + break; + case '"directory"': + $stmt->bindValue($identifier, $this->directory, PDO::PARAM_INT); + break; + case '"filepath"': + $stmt->bindValue($identifier, $this->filepath, PDO::PARAM_STR); + break; + case '"md5"': + $stmt->bindValue($identifier, $this->md5, PDO::PARAM_STR); + break; + case '"track_title"': + $stmt->bindValue($identifier, $this->track_title, PDO::PARAM_STR); + break; + case '"artist_name"': + $stmt->bindValue($identifier, $this->artist_name, PDO::PARAM_STR); + break; + case '"bit_rate"': + $stmt->bindValue($identifier, $this->bit_rate, PDO::PARAM_INT); + break; + case '"sample_rate"': + $stmt->bindValue($identifier, $this->sample_rate, PDO::PARAM_INT); + break; + case '"album_title"': + $stmt->bindValue($identifier, $this->album_title, PDO::PARAM_STR); + break; + case '"genre"': + $stmt->bindValue($identifier, $this->genre, PDO::PARAM_STR); + break; + case '"comments"': + $stmt->bindValue($identifier, $this->comments, PDO::PARAM_STR); + break; + case '"year"': + $stmt->bindValue($identifier, $this->year, PDO::PARAM_STR); + break; + case '"track_number"': + $stmt->bindValue($identifier, $this->track_number, PDO::PARAM_INT); + break; + case '"channels"': + $stmt->bindValue($identifier, $this->channels, PDO::PARAM_INT); + break; + case '"url"': + $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR); + break; + case '"bpm"': + $stmt->bindValue($identifier, $this->bpm, PDO::PARAM_INT); + break; + case '"encoded_by"': + $stmt->bindValue($identifier, $this->encoded_by, PDO::PARAM_STR); + break; + case '"mood"': + $stmt->bindValue($identifier, $this->mood, PDO::PARAM_STR); + break; + case '"label"': + $stmt->bindValue($identifier, $this->label, PDO::PARAM_STR); + break; + case '"composer"': + $stmt->bindValue($identifier, $this->composer, PDO::PARAM_STR); + break; + case '"copyright"': + $stmt->bindValue($identifier, $this->copyright, PDO::PARAM_STR); + break; + case '"isrc_number"': + $stmt->bindValue($identifier, $this->isrc_number, PDO::PARAM_STR); + break; + case '"info_url"': + $stmt->bindValue($identifier, $this->info_url, PDO::PARAM_STR); + break; + case '"language"': + $stmt->bindValue($identifier, $this->language, PDO::PARAM_STR); + break; + case '"replay_gain"': + $stmt->bindValue($identifier, $this->replay_gain, PDO::PARAM_INT); + break; + case '"cuein"': + $stmt->bindValue($identifier, $this->cuein, PDO::PARAM_STR); + break; + case '"cueout"': + $stmt->bindValue($identifier, $this->cueout, PDO::PARAM_STR); + break; + case '"silan_check"': + $stmt->bindValue($identifier, $this->silan_check, PDO::PARAM_BOOL); + break; + case '"file_exists"': + $stmt->bindValue($identifier, $this->file_exists, PDO::PARAM_BOOL); + break; + case '"hidden"': + $stmt->bindValue($identifier, $this->hidden, PDO::PARAM_BOOL); + break; + case '"is_scheduled"': + $stmt->bindValue($identifier, $this->is_scheduled, PDO::PARAM_BOOL); + break; + case '"is_playlist"': + $stmt->bindValue($identifier, $this->is_playlist, PDO::PARAM_BOOL); + break; + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"name"': + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); + break; + case '"owner_id"': + $stmt->bindValue($identifier, $this->owner_id, PDO::PARAM_INT); + break; + case '"description"': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case '"last_played"': + $stmt->bindValue($identifier, $this->last_played, PDO::PARAM_STR); + break; + case '"play_count"': + $stmt->bindValue($identifier, $this->play_count, PDO::PARAM_INT); + break; + case '"length"': + $stmt->bindValue($identifier, $this->length, PDO::PARAM_STR); + break; + case '"created_at"': + $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + break; + case '"updated_at"': + $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcMusicDirs !== null) { + if (!$this->aCcMusicDirs->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcMusicDirs->getValidationFailures()); + } + } + + if ($this->aMediaItem !== null) { + if (!$this->aMediaItem->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aMediaItem->getValidationFailures()); + } + } + + if ($this->aCcSubjs !== null) { + if (!$this->aCcSubjs->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcSubjs->getValidationFailures()); + } + } + + + if (($retval = AudioFilePeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = AudioFilePeer::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->getMime(); + break; + case 1: + return $this->getDirectory(); + break; + case 2: + return $this->getFilepath(); + break; + case 3: + return $this->getMd5(); + break; + case 4: + return $this->getTrackTitle(); + break; + case 5: + return $this->getArtistName(); + break; + case 6: + return $this->getBitRate(); + break; + case 7: + return $this->getSampleRate(); + break; + case 8: + return $this->getAlbumTitle(); + break; + case 9: + return $this->getGenre(); + break; + case 10: + return $this->getComments(); + break; + case 11: + return $this->getYear(); + break; + case 12: + return $this->getTrackNumber(); + break; + case 13: + return $this->getChannels(); + break; + case 14: + return $this->getUrl(); + break; + case 15: + return $this->getBpm(); + break; + case 16: + return $this->getEncodedBy(); + break; + case 17: + return $this->getMood(); + break; + case 18: + return $this->getLabel(); + break; + case 19: + return $this->getComposer(); + break; + case 20: + return $this->getCopyright(); + break; + case 21: + return $this->getIsrcNumber(); + break; + case 22: + return $this->getInfoUrl(); + break; + case 23: + return $this->getLanguage(); + break; + case 24: + return $this->getReplayGain(); + break; + case 25: + return $this->getCuein(); + break; + case 26: + return $this->getCueout(); + break; + case 27: + return $this->getIsSilanChecked(); + break; + case 28: + return $this->getFileExists(); + break; + case 29: + return $this->getIsHidden(); + break; + case 30: + return $this->getIsScheduled(); + break; + case 31: + return $this->getIsPlaylist(); + break; + case 32: + return $this->getId(); + break; + case 33: + return $this->getName(); + break; + case 34: + return $this->getOwnerId(); + break; + case 35: + return $this->getDescription(); + break; + case 36: + return $this->getLastPlayedTime(); + break; + case 37: + return $this->getPlayCount(); + break; + case 38: + return $this->getLength(); + break; + case 39: + return $this->getCreatedAt(); + break; + case 40: + return $this->getUpdatedAt(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['AudioFile'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['AudioFile'][$this->getPrimaryKey()] = true; + $keys = AudioFilePeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getMime(), + $keys[1] => $this->getDirectory(), + $keys[2] => $this->getFilepath(), + $keys[3] => $this->getMd5(), + $keys[4] => $this->getTrackTitle(), + $keys[5] => $this->getArtistName(), + $keys[6] => $this->getBitRate(), + $keys[7] => $this->getSampleRate(), + $keys[8] => $this->getAlbumTitle(), + $keys[9] => $this->getGenre(), + $keys[10] => $this->getComments(), + $keys[11] => $this->getYear(), + $keys[12] => $this->getTrackNumber(), + $keys[13] => $this->getChannels(), + $keys[14] => $this->getUrl(), + $keys[15] => $this->getBpm(), + $keys[16] => $this->getEncodedBy(), + $keys[17] => $this->getMood(), + $keys[18] => $this->getLabel(), + $keys[19] => $this->getComposer(), + $keys[20] => $this->getCopyright(), + $keys[21] => $this->getIsrcNumber(), + $keys[22] => $this->getInfoUrl(), + $keys[23] => $this->getLanguage(), + $keys[24] => $this->getReplayGain(), + $keys[25] => $this->getCuein(), + $keys[26] => $this->getCueout(), + $keys[27] => $this->getIsSilanChecked(), + $keys[28] => $this->getFileExists(), + $keys[29] => $this->getIsHidden(), + $keys[30] => $this->getIsScheduled(), + $keys[31] => $this->getIsPlaylist(), + $keys[32] => $this->getId(), + $keys[33] => $this->getName(), + $keys[34] => $this->getOwnerId(), + $keys[35] => $this->getDescription(), + $keys[36] => $this->getLastPlayedTime(), + $keys[37] => $this->getPlayCount(), + $keys[38] => $this->getLength(), + $keys[39] => $this->getCreatedAt(), + $keys[40] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcMusicDirs) { + $result['CcMusicDirs'] = $this->aCcMusicDirs->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aMediaItem) { + $result['MediaItem'] = $this->aMediaItem->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aCcSubjs) { + $result['CcSubjs'] = $this->aCcSubjs->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = AudioFilePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setMime($value); + break; + case 1: + $this->setDirectory($value); + break; + case 2: + $this->setFilepath($value); + break; + case 3: + $this->setMd5($value); + break; + case 4: + $this->setTrackTitle($value); + break; + case 5: + $this->setArtistName($value); + break; + case 6: + $this->setBitRate($value); + break; + case 7: + $this->setSampleRate($value); + break; + case 8: + $this->setAlbumTitle($value); + break; + case 9: + $this->setGenre($value); + break; + case 10: + $this->setComments($value); + break; + case 11: + $this->setYear($value); + break; + case 12: + $this->setTrackNumber($value); + break; + case 13: + $this->setChannels($value); + break; + case 14: + $this->setUrl($value); + break; + case 15: + $this->setBpm($value); + break; + case 16: + $this->setEncodedBy($value); + break; + case 17: + $this->setMood($value); + break; + case 18: + $this->setLabel($value); + break; + case 19: + $this->setComposer($value); + break; + case 20: + $this->setCopyright($value); + break; + case 21: + $this->setIsrcNumber($value); + break; + case 22: + $this->setInfoUrl($value); + break; + case 23: + $this->setLanguage($value); + break; + case 24: + $this->setReplayGain($value); + break; + case 25: + $this->setCuein($value); + break; + case 26: + $this->setCueout($value); + break; + case 27: + $this->setIsSilanChecked($value); + break; + case 28: + $this->setFileExists($value); + break; + case 29: + $this->setIsHidden($value); + break; + case 30: + $this->setIsScheduled($value); + break; + case 31: + $this->setIsPlaylist($value); + break; + case 32: + $this->setId($value); + break; + case 33: + $this->setName($value); + break; + case 34: + $this->setOwnerId($value); + break; + case 35: + $this->setDescription($value); + break; + case 36: + $this->setLastPlayedTime($value); + break; + case 37: + $this->setPlayCount($value); + break; + case 38: + $this->setLength($value); + break; + case 39: + $this->setCreatedAt($value); + break; + case 40: + $this->setUpdatedAt($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 BasePeer::TYPE_PHPNAME + * + * @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 = AudioFilePeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setMime($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDirectory($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setFilepath($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setMd5($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setTrackTitle($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setArtistName($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setBitRate($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setSampleRate($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setAlbumTitle($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setGenre($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setComments($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setYear($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setTrackNumber($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setChannels($arr[$keys[13]]); + if (array_key_exists($keys[14], $arr)) $this->setUrl($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setBpm($arr[$keys[15]]); + if (array_key_exists($keys[16], $arr)) $this->setEncodedBy($arr[$keys[16]]); + if (array_key_exists($keys[17], $arr)) $this->setMood($arr[$keys[17]]); + if (array_key_exists($keys[18], $arr)) $this->setLabel($arr[$keys[18]]); + if (array_key_exists($keys[19], $arr)) $this->setComposer($arr[$keys[19]]); + if (array_key_exists($keys[20], $arr)) $this->setCopyright($arr[$keys[20]]); + if (array_key_exists($keys[21], $arr)) $this->setIsrcNumber($arr[$keys[21]]); + if (array_key_exists($keys[22], $arr)) $this->setInfoUrl($arr[$keys[22]]); + if (array_key_exists($keys[23], $arr)) $this->setLanguage($arr[$keys[23]]); + if (array_key_exists($keys[24], $arr)) $this->setReplayGain($arr[$keys[24]]); + if (array_key_exists($keys[25], $arr)) $this->setCuein($arr[$keys[25]]); + if (array_key_exists($keys[26], $arr)) $this->setCueout($arr[$keys[26]]); + if (array_key_exists($keys[27], $arr)) $this->setIsSilanChecked($arr[$keys[27]]); + if (array_key_exists($keys[28], $arr)) $this->setFileExists($arr[$keys[28]]); + if (array_key_exists($keys[29], $arr)) $this->setIsHidden($arr[$keys[29]]); + if (array_key_exists($keys[30], $arr)) $this->setIsScheduled($arr[$keys[30]]); + if (array_key_exists($keys[31], $arr)) $this->setIsPlaylist($arr[$keys[31]]); + if (array_key_exists($keys[32], $arr)) $this->setId($arr[$keys[32]]); + if (array_key_exists($keys[33], $arr)) $this->setName($arr[$keys[33]]); + if (array_key_exists($keys[34], $arr)) $this->setOwnerId($arr[$keys[34]]); + if (array_key_exists($keys[35], $arr)) $this->setDescription($arr[$keys[35]]); + if (array_key_exists($keys[36], $arr)) $this->setLastPlayedTime($arr[$keys[36]]); + if (array_key_exists($keys[37], $arr)) $this->setPlayCount($arr[$keys[37]]); + if (array_key_exists($keys[38], $arr)) $this->setLength($arr[$keys[38]]); + if (array_key_exists($keys[39], $arr)) $this->setCreatedAt($arr[$keys[39]]); + if (array_key_exists($keys[40], $arr)) $this->setUpdatedAt($arr[$keys[40]]); + } + + /** + * 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(AudioFilePeer::DATABASE_NAME); + + if ($this->isColumnModified(AudioFilePeer::MIME)) $criteria->add(AudioFilePeer::MIME, $this->mime); + if ($this->isColumnModified(AudioFilePeer::DIRECTORY)) $criteria->add(AudioFilePeer::DIRECTORY, $this->directory); + if ($this->isColumnModified(AudioFilePeer::FILEPATH)) $criteria->add(AudioFilePeer::FILEPATH, $this->filepath); + if ($this->isColumnModified(AudioFilePeer::MD5)) $criteria->add(AudioFilePeer::MD5, $this->md5); + if ($this->isColumnModified(AudioFilePeer::TRACK_TITLE)) $criteria->add(AudioFilePeer::TRACK_TITLE, $this->track_title); + if ($this->isColumnModified(AudioFilePeer::ARTIST_NAME)) $criteria->add(AudioFilePeer::ARTIST_NAME, $this->artist_name); + if ($this->isColumnModified(AudioFilePeer::BIT_RATE)) $criteria->add(AudioFilePeer::BIT_RATE, $this->bit_rate); + if ($this->isColumnModified(AudioFilePeer::SAMPLE_RATE)) $criteria->add(AudioFilePeer::SAMPLE_RATE, $this->sample_rate); + if ($this->isColumnModified(AudioFilePeer::ALBUM_TITLE)) $criteria->add(AudioFilePeer::ALBUM_TITLE, $this->album_title); + if ($this->isColumnModified(AudioFilePeer::GENRE)) $criteria->add(AudioFilePeer::GENRE, $this->genre); + if ($this->isColumnModified(AudioFilePeer::COMMENTS)) $criteria->add(AudioFilePeer::COMMENTS, $this->comments); + if ($this->isColumnModified(AudioFilePeer::YEAR)) $criteria->add(AudioFilePeer::YEAR, $this->year); + if ($this->isColumnModified(AudioFilePeer::TRACK_NUMBER)) $criteria->add(AudioFilePeer::TRACK_NUMBER, $this->track_number); + if ($this->isColumnModified(AudioFilePeer::CHANNELS)) $criteria->add(AudioFilePeer::CHANNELS, $this->channels); + if ($this->isColumnModified(AudioFilePeer::URL)) $criteria->add(AudioFilePeer::URL, $this->url); + if ($this->isColumnModified(AudioFilePeer::BPM)) $criteria->add(AudioFilePeer::BPM, $this->bpm); + if ($this->isColumnModified(AudioFilePeer::ENCODED_BY)) $criteria->add(AudioFilePeer::ENCODED_BY, $this->encoded_by); + if ($this->isColumnModified(AudioFilePeer::MOOD)) $criteria->add(AudioFilePeer::MOOD, $this->mood); + if ($this->isColumnModified(AudioFilePeer::LABEL)) $criteria->add(AudioFilePeer::LABEL, $this->label); + if ($this->isColumnModified(AudioFilePeer::COMPOSER)) $criteria->add(AudioFilePeer::COMPOSER, $this->composer); + if ($this->isColumnModified(AudioFilePeer::COPYRIGHT)) $criteria->add(AudioFilePeer::COPYRIGHT, $this->copyright); + if ($this->isColumnModified(AudioFilePeer::ISRC_NUMBER)) $criteria->add(AudioFilePeer::ISRC_NUMBER, $this->isrc_number); + if ($this->isColumnModified(AudioFilePeer::INFO_URL)) $criteria->add(AudioFilePeer::INFO_URL, $this->info_url); + if ($this->isColumnModified(AudioFilePeer::LANGUAGE)) $criteria->add(AudioFilePeer::LANGUAGE, $this->language); + if ($this->isColumnModified(AudioFilePeer::REPLAY_GAIN)) $criteria->add(AudioFilePeer::REPLAY_GAIN, $this->replay_gain); + if ($this->isColumnModified(AudioFilePeer::CUEIN)) $criteria->add(AudioFilePeer::CUEIN, $this->cuein); + if ($this->isColumnModified(AudioFilePeer::CUEOUT)) $criteria->add(AudioFilePeer::CUEOUT, $this->cueout); + if ($this->isColumnModified(AudioFilePeer::SILAN_CHECK)) $criteria->add(AudioFilePeer::SILAN_CHECK, $this->silan_check); + if ($this->isColumnModified(AudioFilePeer::FILE_EXISTS)) $criteria->add(AudioFilePeer::FILE_EXISTS, $this->file_exists); + if ($this->isColumnModified(AudioFilePeer::HIDDEN)) $criteria->add(AudioFilePeer::HIDDEN, $this->hidden); + if ($this->isColumnModified(AudioFilePeer::IS_SCHEDULED)) $criteria->add(AudioFilePeer::IS_SCHEDULED, $this->is_scheduled); + if ($this->isColumnModified(AudioFilePeer::IS_PLAYLIST)) $criteria->add(AudioFilePeer::IS_PLAYLIST, $this->is_playlist); + if ($this->isColumnModified(AudioFilePeer::ID)) $criteria->add(AudioFilePeer::ID, $this->id); + if ($this->isColumnModified(AudioFilePeer::NAME)) $criteria->add(AudioFilePeer::NAME, $this->name); + if ($this->isColumnModified(AudioFilePeer::OWNER_ID)) $criteria->add(AudioFilePeer::OWNER_ID, $this->owner_id); + if ($this->isColumnModified(AudioFilePeer::DESCRIPTION)) $criteria->add(AudioFilePeer::DESCRIPTION, $this->description); + if ($this->isColumnModified(AudioFilePeer::LAST_PLAYED)) $criteria->add(AudioFilePeer::LAST_PLAYED, $this->last_played); + if ($this->isColumnModified(AudioFilePeer::PLAY_COUNT)) $criteria->add(AudioFilePeer::PLAY_COUNT, $this->play_count); + if ($this->isColumnModified(AudioFilePeer::LENGTH)) $criteria->add(AudioFilePeer::LENGTH, $this->length); + if ($this->isColumnModified(AudioFilePeer::CREATED_AT)) $criteria->add(AudioFilePeer::CREATED_AT, $this->created_at); + if ($this->isColumnModified(AudioFilePeer::UPDATED_AT)) $criteria->add(AudioFilePeer::UPDATED_AT, $this->updated_at); + + 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(AudioFilePeer::DATABASE_NAME); + $criteria->add(AudioFilePeer::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 AudioFile (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setMime($this->getMime()); + $copyObj->setDirectory($this->getDirectory()); + $copyObj->setFilepath($this->getFilepath()); + $copyObj->setMd5($this->getMd5()); + $copyObj->setTrackTitle($this->getTrackTitle()); + $copyObj->setArtistName($this->getArtistName()); + $copyObj->setBitRate($this->getBitRate()); + $copyObj->setSampleRate($this->getSampleRate()); + $copyObj->setAlbumTitle($this->getAlbumTitle()); + $copyObj->setGenre($this->getGenre()); + $copyObj->setComments($this->getComments()); + $copyObj->setYear($this->getYear()); + $copyObj->setTrackNumber($this->getTrackNumber()); + $copyObj->setChannels($this->getChannels()); + $copyObj->setUrl($this->getUrl()); + $copyObj->setBpm($this->getBpm()); + $copyObj->setEncodedBy($this->getEncodedBy()); + $copyObj->setMood($this->getMood()); + $copyObj->setLabel($this->getLabel()); + $copyObj->setComposer($this->getComposer()); + $copyObj->setCopyright($this->getCopyright()); + $copyObj->setIsrcNumber($this->getIsrcNumber()); + $copyObj->setInfoUrl($this->getInfoUrl()); + $copyObj->setLanguage($this->getLanguage()); + $copyObj->setReplayGain($this->getReplayGain()); + $copyObj->setCuein($this->getCuein()); + $copyObj->setCueout($this->getCueout()); + $copyObj->setIsSilanChecked($this->getIsSilanChecked()); + $copyObj->setFileExists($this->getFileExists()); + $copyObj->setIsHidden($this->getIsHidden()); + $copyObj->setIsScheduled($this->getIsScheduled()); + $copyObj->setIsPlaylist($this->getIsPlaylist()); + $copyObj->setName($this->getName()); + $copyObj->setOwnerId($this->getOwnerId()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setLastPlayedTime($this->getLastPlayedTime()); + $copyObj->setPlayCount($this->getPlayCount()); + $copyObj->setLength($this->getLength()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + $relObj = $this->getMediaItem(); + if ($relObj) { + $copyObj->setMediaItem($relObj->copy($deepCopy)); + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 AudioFile 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 AudioFilePeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new AudioFilePeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a CcMusicDirs object. + * + * @param CcMusicDirs $v + * @return AudioFile The current object (for fluent API support) + * @throws PropelException + */ + public function setCcMusicDirs(CcMusicDirs $v = null) + { + if ($v === null) { + $this->setDirectory(NULL); + } else { + $this->setDirectory($v->getId()); + } + + $this->aCcMusicDirs = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcMusicDirs object, it will not be re-added. + if ($v !== null) { + $v->addAudioFile($this); + } + + + return $this; + } + + + /** + * Get the associated CcMusicDirs object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcMusicDirs The associated CcMusicDirs object. + * @throws PropelException + */ + public function getCcMusicDirs(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcMusicDirs === null && ($this->directory !== null) && $doQuery) { + $this->aCcMusicDirs = CcMusicDirsQuery::create()->findPk($this->directory, $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->aCcMusicDirs->addAudioFiles($this); + */ + } + + return $this->aCcMusicDirs; + } + + /** + * Declares an association between this object and a MediaItem object. + * + * @param MediaItem $v + * @return AudioFile The current object (for fluent API support) + * @throws PropelException + */ + public function setMediaItem(MediaItem $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aMediaItem = $v; + + // Add binding for other direction of this 1:1 relationship. + if ($v !== null) { + $v->setAudioFile($this); + } + + + return $this; + } + + + /** + * Get the associated MediaItem object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return MediaItem The associated MediaItem object. + * @throws PropelException + */ + public function getMediaItem(PropelPDO $con = null, $doQuery = true) + { + if ($this->aMediaItem === null && ($this->id !== null) && $doQuery) { + $this->aMediaItem = MediaItemQuery::create()->findPk($this->id, $con); + // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association. + $this->aMediaItem->setAudioFile($this); + } + + return $this->aMediaItem; + } + + /** + * Declares an association between this object and a CcSubjs object. + * + * @param CcSubjs $v + * @return AudioFile The current object (for fluent API support) + * @throws PropelException + */ + public function setCcSubjs(CcSubjs $v = null) + { + if ($v === null) { + $this->setOwnerId(NULL); + } else { + $this->setOwnerId($v->getDbId()); + } + + $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->addAudioFile($this); + } + + + return $this; + } + + + /** + * Get the associated CcSubjs object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getCcSubjs(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcSubjs === null && ($this->owner_id !== null) && $doQuery) { + $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->owner_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->aCcSubjs->addAudioFiles($this); + */ + } + + return $this->aCcSubjs; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->mime = null; + $this->directory = null; + $this->filepath = null; + $this->md5 = null; + $this->track_title = null; + $this->artist_name = null; + $this->bit_rate = null; + $this->sample_rate = 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->encoded_by = null; + $this->mood = null; + $this->label = null; + $this->composer = null; + $this->copyright = null; + $this->isrc_number = null; + $this->info_url = null; + $this->language = null; + $this->replay_gain = null; + $this->cuein = null; + $this->cueout = null; + $this->silan_check = null; + $this->file_exists = null; + $this->hidden = null; + $this->is_scheduled = null; + $this->is_playlist = null; + $this->id = null; + $this->name = null; + $this->owner_id = null; + $this->description = null; + $this->last_played = null; + $this->play_count = null; + $this->length = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCcMusicDirs instanceof Persistent) { + $this->aCcMusicDirs->clearAllReferences($deep); + } + if ($this->aMediaItem instanceof Persistent) { + $this->aMediaItem->clearAllReferences($deep); + } + if ($this->aCcSubjs instanceof Persistent) { + $this->aCcSubjs->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + $this->aCcMusicDirs = null; + $this->aMediaItem = null; + $this->aCcSubjs = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(AudioFilePeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + + // concrete_inheritance behavior + + /** + * Get or Create the parent MediaItem object of the current object + * + * @return MediaItem The parent object + */ + public function getParentOrCreate($con = null) + { + if ($this->isNew()) { + if ($this->isPrimaryKeyNull()) { + //this prevent issue with deep copy & save parent object + if (null === ($parent = $this->getMediaItem($con))) { + $parent = new MediaItem(); + } + $parent->setDescendantClass('Airtime\MediaItem\AudioFile'); + + return $parent; + } else { + $parent = MediaItemQuery::create()->findPk($this->getPrimaryKey(), $con); + if (null === $parent || null !== $parent->getDescendantClass()) { + $parent = new MediaItem(); + $parent->setPrimaryKey($this->getPrimaryKey()); + $parent->setDescendantClass('Airtime\MediaItem\AudioFile'); + } + + return $parent; + } + } + + return MediaItemQuery::create()->findPk($this->getPrimaryKey(), $con); + } + + /** + * Create or Update the parent MediaItem object + * And return its primary key + * + * @return int The primary key of the parent object + */ + public function getSyncParent($con = null) + { + $parent = $this->getParentOrCreate($con); + $parent->setName($this->getName()); + $parent->setOwnerId($this->getOwnerId()); + $parent->setDescription($this->getDescription()); + $parent->setLastPlayedTime($this->getLastPlayedTime()); + $parent->setPlayCount($this->getPlayCount()); + $parent->setLength($this->getLength()); + $parent->setCreatedAt($this->getCreatedAt()); + $parent->setUpdatedAt($this->getUpdatedAt()); + if ($this->getCcSubjs() && $this->getCcSubjs()->isNew()) { + $parent->setCcSubjs($this->getCcSubjs()); + } + + return $parent; + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return AudioFile The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AudioFilePeer::UPDATED_AT; + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseAudioFilePeer.php b/airtime_mvc/application/models/airtime/om/BaseAudioFilePeer.php new file mode 100644 index 000000000..c7a69d2a9 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseAudioFilePeer.php @@ -0,0 +1,1945 @@ + array ('Mime', 'Directory', 'Filepath', 'Md5', 'TrackTitle', 'ArtistName', 'BitRate', 'SampleRate', 'AlbumTitle', 'Genre', 'Comments', 'Year', 'TrackNumber', 'Channels', 'Url', 'Bpm', 'EncodedBy', 'Mood', 'Label', 'Composer', 'Copyright', 'IsrcNumber', 'InfoUrl', 'Language', 'ReplayGain', 'Cuein', 'Cueout', 'IsSilanChecked', 'FileExists', 'IsHidden', 'IsScheduled', 'IsPlaylist', 'Id', 'Name', 'OwnerId', 'Description', 'LastPlayedTime', 'PlayCount', 'Length', 'CreatedAt', 'UpdatedAt', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('mime', 'directory', 'filepath', 'md5', 'trackTitle', 'artistName', 'bitRate', 'sampleRate', 'albumTitle', 'genre', 'comments', 'year', 'trackNumber', 'channels', 'url', 'bpm', 'encodedBy', 'mood', 'label', 'composer', 'copyright', 'isrcNumber', 'infoUrl', 'language', 'replayGain', 'cuein', 'cueout', 'isSilanChecked', 'fileExists', 'isHidden', 'isScheduled', 'isPlaylist', 'id', 'name', 'ownerId', 'description', 'lastPlayedTime', 'playCount', 'length', 'createdAt', 'updatedAt', ), + BasePeer::TYPE_COLNAME => array (AudioFilePeer::MIME, AudioFilePeer::DIRECTORY, AudioFilePeer::FILEPATH, AudioFilePeer::MD5, AudioFilePeer::TRACK_TITLE, AudioFilePeer::ARTIST_NAME, AudioFilePeer::BIT_RATE, AudioFilePeer::SAMPLE_RATE, AudioFilePeer::ALBUM_TITLE, AudioFilePeer::GENRE, AudioFilePeer::COMMENTS, AudioFilePeer::YEAR, AudioFilePeer::TRACK_NUMBER, AudioFilePeer::CHANNELS, AudioFilePeer::URL, AudioFilePeer::BPM, AudioFilePeer::ENCODED_BY, AudioFilePeer::MOOD, AudioFilePeer::LABEL, AudioFilePeer::COMPOSER, AudioFilePeer::COPYRIGHT, AudioFilePeer::ISRC_NUMBER, AudioFilePeer::INFO_URL, AudioFilePeer::LANGUAGE, AudioFilePeer::REPLAY_GAIN, AudioFilePeer::CUEIN, AudioFilePeer::CUEOUT, AudioFilePeer::SILAN_CHECK, AudioFilePeer::FILE_EXISTS, AudioFilePeer::HIDDEN, AudioFilePeer::IS_SCHEDULED, AudioFilePeer::IS_PLAYLIST, AudioFilePeer::ID, AudioFilePeer::NAME, AudioFilePeer::OWNER_ID, AudioFilePeer::DESCRIPTION, AudioFilePeer::LAST_PLAYED, AudioFilePeer::PLAY_COUNT, AudioFilePeer::LENGTH, AudioFilePeer::CREATED_AT, AudioFilePeer::UPDATED_AT, ), + BasePeer::TYPE_RAW_COLNAME => array ('MIME', 'DIRECTORY', 'FILEPATH', 'MD5', 'TRACK_TITLE', 'ARTIST_NAME', 'BIT_RATE', 'SAMPLE_RATE', 'ALBUM_TITLE', 'GENRE', 'COMMENTS', 'YEAR', 'TRACK_NUMBER', 'CHANNELS', 'URL', 'BPM', 'ENCODED_BY', 'MOOD', 'LABEL', 'COMPOSER', 'COPYRIGHT', 'ISRC_NUMBER', 'INFO_URL', 'LANGUAGE', 'REPLAY_GAIN', 'CUEIN', 'CUEOUT', 'SILAN_CHECK', 'FILE_EXISTS', 'HIDDEN', 'IS_SCHEDULED', 'IS_PLAYLIST', 'ID', 'NAME', 'OWNER_ID', 'DESCRIPTION', 'LAST_PLAYED', 'PLAY_COUNT', 'LENGTH', 'CREATED_AT', 'UPDATED_AT', ), + BasePeer::TYPE_FIELDNAME => array ('mime', 'directory', 'filepath', 'md5', 'track_title', 'artist_name', 'bit_rate', 'sample_rate', 'album_title', 'genre', 'comments', 'year', 'track_number', 'channels', 'url', 'bpm', 'encoded_by', 'mood', 'label', 'composer', 'copyright', 'isrc_number', 'info_url', 'language', 'replay_gain', 'cuein', 'cueout', 'silan_check', 'file_exists', 'hidden', 'is_scheduled', 'is_playlist', 'id', 'name', 'owner_id', 'description', 'last_played', 'play_count', 'length', 'created_at', 'updated_at', ), + 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, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. AudioFilePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('Mime' => 0, 'Directory' => 1, 'Filepath' => 2, 'Md5' => 3, 'TrackTitle' => 4, 'ArtistName' => 5, 'BitRate' => 6, 'SampleRate' => 7, 'AlbumTitle' => 8, 'Genre' => 9, 'Comments' => 10, 'Year' => 11, 'TrackNumber' => 12, 'Channels' => 13, 'Url' => 14, 'Bpm' => 15, 'EncodedBy' => 16, 'Mood' => 17, 'Label' => 18, 'Composer' => 19, 'Copyright' => 20, 'IsrcNumber' => 21, 'InfoUrl' => 22, 'Language' => 23, 'ReplayGain' => 24, 'Cuein' => 25, 'Cueout' => 26, 'IsSilanChecked' => 27, 'FileExists' => 28, 'IsHidden' => 29, 'IsScheduled' => 30, 'IsPlaylist' => 31, 'Id' => 32, 'Name' => 33, 'OwnerId' => 34, 'Description' => 35, 'LastPlayedTime' => 36, 'PlayCount' => 37, 'Length' => 38, 'CreatedAt' => 39, 'UpdatedAt' => 40, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('mime' => 0, 'directory' => 1, 'filepath' => 2, 'md5' => 3, 'trackTitle' => 4, 'artistName' => 5, 'bitRate' => 6, 'sampleRate' => 7, 'albumTitle' => 8, 'genre' => 9, 'comments' => 10, 'year' => 11, 'trackNumber' => 12, 'channels' => 13, 'url' => 14, 'bpm' => 15, 'encodedBy' => 16, 'mood' => 17, 'label' => 18, 'composer' => 19, 'copyright' => 20, 'isrcNumber' => 21, 'infoUrl' => 22, 'language' => 23, 'replayGain' => 24, 'cuein' => 25, 'cueout' => 26, 'isSilanChecked' => 27, 'fileExists' => 28, 'isHidden' => 29, 'isScheduled' => 30, 'isPlaylist' => 31, 'id' => 32, 'name' => 33, 'ownerId' => 34, 'description' => 35, 'lastPlayedTime' => 36, 'playCount' => 37, 'length' => 38, 'createdAt' => 39, 'updatedAt' => 40, ), + BasePeer::TYPE_COLNAME => array (AudioFilePeer::MIME => 0, AudioFilePeer::DIRECTORY => 1, AudioFilePeer::FILEPATH => 2, AudioFilePeer::MD5 => 3, AudioFilePeer::TRACK_TITLE => 4, AudioFilePeer::ARTIST_NAME => 5, AudioFilePeer::BIT_RATE => 6, AudioFilePeer::SAMPLE_RATE => 7, AudioFilePeer::ALBUM_TITLE => 8, AudioFilePeer::GENRE => 9, AudioFilePeer::COMMENTS => 10, AudioFilePeer::YEAR => 11, AudioFilePeer::TRACK_NUMBER => 12, AudioFilePeer::CHANNELS => 13, AudioFilePeer::URL => 14, AudioFilePeer::BPM => 15, AudioFilePeer::ENCODED_BY => 16, AudioFilePeer::MOOD => 17, AudioFilePeer::LABEL => 18, AudioFilePeer::COMPOSER => 19, AudioFilePeer::COPYRIGHT => 20, AudioFilePeer::ISRC_NUMBER => 21, AudioFilePeer::INFO_URL => 22, AudioFilePeer::LANGUAGE => 23, AudioFilePeer::REPLAY_GAIN => 24, AudioFilePeer::CUEIN => 25, AudioFilePeer::CUEOUT => 26, AudioFilePeer::SILAN_CHECK => 27, AudioFilePeer::FILE_EXISTS => 28, AudioFilePeer::HIDDEN => 29, AudioFilePeer::IS_SCHEDULED => 30, AudioFilePeer::IS_PLAYLIST => 31, AudioFilePeer::ID => 32, AudioFilePeer::NAME => 33, AudioFilePeer::OWNER_ID => 34, AudioFilePeer::DESCRIPTION => 35, AudioFilePeer::LAST_PLAYED => 36, AudioFilePeer::PLAY_COUNT => 37, AudioFilePeer::LENGTH => 38, AudioFilePeer::CREATED_AT => 39, AudioFilePeer::UPDATED_AT => 40, ), + BasePeer::TYPE_RAW_COLNAME => array ('MIME' => 0, 'DIRECTORY' => 1, 'FILEPATH' => 2, 'MD5' => 3, 'TRACK_TITLE' => 4, 'ARTIST_NAME' => 5, 'BIT_RATE' => 6, 'SAMPLE_RATE' => 7, 'ALBUM_TITLE' => 8, 'GENRE' => 9, 'COMMENTS' => 10, 'YEAR' => 11, 'TRACK_NUMBER' => 12, 'CHANNELS' => 13, 'URL' => 14, 'BPM' => 15, 'ENCODED_BY' => 16, 'MOOD' => 17, 'LABEL' => 18, 'COMPOSER' => 19, 'COPYRIGHT' => 20, 'ISRC_NUMBER' => 21, 'INFO_URL' => 22, 'LANGUAGE' => 23, 'REPLAY_GAIN' => 24, 'CUEIN' => 25, 'CUEOUT' => 26, 'SILAN_CHECK' => 27, 'FILE_EXISTS' => 28, 'HIDDEN' => 29, 'IS_SCHEDULED' => 30, 'IS_PLAYLIST' => 31, 'ID' => 32, 'NAME' => 33, 'OWNER_ID' => 34, 'DESCRIPTION' => 35, 'LAST_PLAYED' => 36, 'PLAY_COUNT' => 37, 'LENGTH' => 38, 'CREATED_AT' => 39, 'UPDATED_AT' => 40, ), + BasePeer::TYPE_FIELDNAME => array ('mime' => 0, 'directory' => 1, 'filepath' => 2, 'md5' => 3, 'track_title' => 4, 'artist_name' => 5, 'bit_rate' => 6, 'sample_rate' => 7, 'album_title' => 8, 'genre' => 9, 'comments' => 10, 'year' => 11, 'track_number' => 12, 'channels' => 13, 'url' => 14, 'bpm' => 15, 'encoded_by' => 16, 'mood' => 17, 'label' => 18, 'composer' => 19, 'copyright' => 20, 'isrc_number' => 21, 'info_url' => 22, 'language' => 23, 'replay_gain' => 24, 'cuein' => 25, 'cueout' => 26, 'silan_check' => 27, 'file_exists' => 28, 'hidden' => 29, 'is_scheduled' => 30, 'is_playlist' => 31, 'id' => 32, 'name' => 33, 'owner_id' => 34, 'description' => 35, 'last_played' => 36, 'play_count' => 37, 'length' => 38, 'created_at' => 39, 'updated_at' => 40, ), + 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, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = AudioFilePeer::getFieldNames($toType); + $key = isset(AudioFilePeer::$fieldKeys[$fromType][$name]) ? AudioFilePeer::$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(AudioFilePeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, AudioFilePeer::$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 AudioFilePeer::$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. AudioFilePeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(AudioFilePeer::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(AudioFilePeer::MIME); + $criteria->addSelectColumn(AudioFilePeer::DIRECTORY); + $criteria->addSelectColumn(AudioFilePeer::FILEPATH); + $criteria->addSelectColumn(AudioFilePeer::MD5); + $criteria->addSelectColumn(AudioFilePeer::TRACK_TITLE); + $criteria->addSelectColumn(AudioFilePeer::ARTIST_NAME); + $criteria->addSelectColumn(AudioFilePeer::BIT_RATE); + $criteria->addSelectColumn(AudioFilePeer::SAMPLE_RATE); + $criteria->addSelectColumn(AudioFilePeer::ALBUM_TITLE); + $criteria->addSelectColumn(AudioFilePeer::GENRE); + $criteria->addSelectColumn(AudioFilePeer::COMMENTS); + $criteria->addSelectColumn(AudioFilePeer::YEAR); + $criteria->addSelectColumn(AudioFilePeer::TRACK_NUMBER); + $criteria->addSelectColumn(AudioFilePeer::CHANNELS); + $criteria->addSelectColumn(AudioFilePeer::URL); + $criteria->addSelectColumn(AudioFilePeer::BPM); + $criteria->addSelectColumn(AudioFilePeer::ENCODED_BY); + $criteria->addSelectColumn(AudioFilePeer::MOOD); + $criteria->addSelectColumn(AudioFilePeer::LABEL); + $criteria->addSelectColumn(AudioFilePeer::COMPOSER); + $criteria->addSelectColumn(AudioFilePeer::COPYRIGHT); + $criteria->addSelectColumn(AudioFilePeer::ISRC_NUMBER); + $criteria->addSelectColumn(AudioFilePeer::INFO_URL); + $criteria->addSelectColumn(AudioFilePeer::LANGUAGE); + $criteria->addSelectColumn(AudioFilePeer::REPLAY_GAIN); + $criteria->addSelectColumn(AudioFilePeer::CUEIN); + $criteria->addSelectColumn(AudioFilePeer::CUEOUT); + $criteria->addSelectColumn(AudioFilePeer::SILAN_CHECK); + $criteria->addSelectColumn(AudioFilePeer::FILE_EXISTS); + $criteria->addSelectColumn(AudioFilePeer::HIDDEN); + $criteria->addSelectColumn(AudioFilePeer::IS_SCHEDULED); + $criteria->addSelectColumn(AudioFilePeer::IS_PLAYLIST); + $criteria->addSelectColumn(AudioFilePeer::ID); + $criteria->addSelectColumn(AudioFilePeer::NAME); + $criteria->addSelectColumn(AudioFilePeer::OWNER_ID); + $criteria->addSelectColumn(AudioFilePeer::DESCRIPTION); + $criteria->addSelectColumn(AudioFilePeer::LAST_PLAYED); + $criteria->addSelectColumn(AudioFilePeer::PLAY_COUNT); + $criteria->addSelectColumn(AudioFilePeer::LENGTH); + $criteria->addSelectColumn(AudioFilePeer::CREATED_AT); + $criteria->addSelectColumn(AudioFilePeer::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.mime'); + $criteria->addSelectColumn($alias . '.directory'); + $criteria->addSelectColumn($alias . '.filepath'); + $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 . '.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 . '.encoded_by'); + $criteria->addSelectColumn($alias . '.mood'); + $criteria->addSelectColumn($alias . '.label'); + $criteria->addSelectColumn($alias . '.composer'); + $criteria->addSelectColumn($alias . '.copyright'); + $criteria->addSelectColumn($alias . '.isrc_number'); + $criteria->addSelectColumn($alias . '.info_url'); + $criteria->addSelectColumn($alias . '.language'); + $criteria->addSelectColumn($alias . '.replay_gain'); + $criteria->addSelectColumn($alias . '.cuein'); + $criteria->addSelectColumn($alias . '.cueout'); + $criteria->addSelectColumn($alias . '.silan_check'); + $criteria->addSelectColumn($alias . '.file_exists'); + $criteria->addSelectColumn($alias . '.hidden'); + $criteria->addSelectColumn($alias . '.is_scheduled'); + $criteria->addSelectColumn($alias . '.is_playlist'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.name'); + $criteria->addSelectColumn($alias . '.owner_id'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.last_played'); + $criteria->addSelectColumn($alias . '.play_count'); + $criteria->addSelectColumn($alias . '.length'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); + } + } + + /** + * 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(AudioFilePeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + AudioFilePeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(AudioFilePeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(AudioFilePeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return AudioFile + * @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 = AudioFilePeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 AudioFilePeer::populateObjects(AudioFilePeer::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 directly (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(AudioFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + AudioFilePeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(AudioFilePeer::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 AudioFile $obj A AudioFile object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getId(); + } // if key === null + AudioFilePeer::$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 AudioFile object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof AudioFile) { + $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 AudioFile object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(AudioFilePeer::$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 AudioFile 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(AudioFilePeer::$instances[$key])) { + return AudioFilePeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (AudioFilePeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + AudioFilePeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to audio_file + * 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 + 32] === null) { + return null; + } + + return (string) $row[$startcol + 32]; + } + + /** + * 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 + 32]; + } + + /** + * 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 = AudioFilePeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = AudioFilePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = AudioFilePeer::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; + AudioFilePeer::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 (AudioFile object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = AudioFilePeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = AudioFilePeer::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 + AudioFilePeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = AudioFilePeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + AudioFilePeer::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + + /** + * Returns the number of rows matching criteria, joining the related CcMusicDirs 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 doCountJoinCcMusicDirs(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(AudioFilePeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + AudioFilePeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(AudioFilePeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(AudioFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(AudioFilePeer::DIRECTORY, CcMusicDirsPeer::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 MediaItem 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 doCountJoinMediaItem(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(AudioFilePeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + AudioFilePeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(AudioFilePeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(AudioFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(AudioFilePeer::ID, MediaItemPeer::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 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(AudioFilePeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + AudioFilePeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(AudioFilePeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(AudioFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(AudioFilePeer::OWNER_ID, 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 AudioFile objects pre-filled with their CcMusicDirs 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 AudioFile objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcMusicDirs(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(AudioFilePeer::DATABASE_NAME); + } + + AudioFilePeer::addSelectColumns($criteria); + $startcol = AudioFilePeer::NUM_HYDRATE_COLUMNS; + CcMusicDirsPeer::addSelectColumns($criteria); + + $criteria->addJoin(AudioFilePeer::DIRECTORY, CcMusicDirsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = AudioFilePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = AudioFilePeer::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 = AudioFilePeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + AudioFilePeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcMusicDirsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcMusicDirsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcMusicDirsPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcMusicDirsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (AudioFile) to $obj2 (CcMusicDirs) + $obj2->addAudioFile($obj1); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of AudioFile objects pre-filled with their MediaItem 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 AudioFile objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinMediaItem(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(AudioFilePeer::DATABASE_NAME); + } + + AudioFilePeer::addSelectColumns($criteria); + $startcol = AudioFilePeer::NUM_HYDRATE_COLUMNS; + MediaItemPeer::addSelectColumns($criteria); + + $criteria->addJoin(AudioFilePeer::ID, MediaItemPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = AudioFilePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = AudioFilePeer::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 = AudioFilePeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + AudioFilePeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = MediaItemPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = MediaItemPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = MediaItemPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + MediaItemPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (AudioFile) to $obj2 (MediaItem) + // one to one relationship + $obj1->setMediaItem($obj2); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of AudioFile 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 AudioFile 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(AudioFilePeer::DATABASE_NAME); + } + + AudioFilePeer::addSelectColumns($criteria); + $startcol = AudioFilePeer::NUM_HYDRATE_COLUMNS; + CcSubjsPeer::addSelectColumns($criteria); + + $criteria->addJoin(AudioFilePeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = AudioFilePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = AudioFilePeer::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 = AudioFilePeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + AudioFilePeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (AudioFile) to $obj2 (CcSubjs) + $obj2->addAudioFile($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(AudioFilePeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + AudioFilePeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(AudioFilePeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(AudioFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(AudioFilePeer::DIRECTORY, CcMusicDirsPeer::ID, $join_behavior); + + $criteria->addJoin(AudioFilePeer::ID, MediaItemPeer::ID, $join_behavior); + + $criteria->addJoin(AudioFilePeer::OWNER_ID, 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 AudioFile 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 AudioFile 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(AudioFilePeer::DATABASE_NAME); + } + + AudioFilePeer::addSelectColumns($criteria); + $startcol2 = AudioFilePeer::NUM_HYDRATE_COLUMNS; + + CcMusicDirsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcMusicDirsPeer::NUM_HYDRATE_COLUMNS; + + MediaItemPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + MediaItemPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol5 = $startcol4 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(AudioFilePeer::DIRECTORY, CcMusicDirsPeer::ID, $join_behavior); + + $criteria->addJoin(AudioFilePeer::ID, MediaItemPeer::ID, $join_behavior); + + $criteria->addJoin(AudioFilePeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = AudioFilePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = AudioFilePeer::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 = AudioFilePeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + AudioFilePeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcMusicDirs rows + + $key2 = CcMusicDirsPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcMusicDirsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcMusicDirsPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcMusicDirsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (AudioFile) to the collection in $obj2 (CcMusicDirs) + $obj2->addAudioFile($obj1); + } // if joined row not null + + // Add objects for joined MediaItem rows + + $key3 = MediaItemPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = MediaItemPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = MediaItemPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + MediaItemPeer::addInstanceToPool($obj3, $key3); + } // if obj3 loaded + + // Add the $obj1 (AudioFile) to the collection in $obj3 (MediaItem) + $obj1->setMediaItem($obj3); + } // if joined row not null + + // Add objects for joined CcSubjs rows + + $key4 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol4); + if ($key4 !== null) { + $obj4 = CcSubjsPeer::getInstanceFromPool($key4); + if (!$obj4) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj4 = new $cls(); + $obj4->hydrate($row, $startcol4); + CcSubjsPeer::addInstanceToPool($obj4, $key4); + } // if obj4 loaded + + // Add the $obj1 (AudioFile) to the collection in $obj4 (CcSubjs) + $obj4->addAudioFile($obj1); + } // if joined row not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining the related CcMusicDirs 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 doCountJoinAllExceptCcMusicDirs(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(AudioFilePeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + AudioFilePeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(AudioFilePeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(AudioFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(AudioFilePeer::ID, MediaItemPeer::ID, $join_behavior); + + $criteria->addJoin(AudioFilePeer::OWNER_ID, 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; + } + + + /** + * Returns the number of rows matching criteria, joining the related MediaItem 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 doCountJoinAllExceptMediaItem(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(AudioFilePeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + AudioFilePeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(AudioFilePeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(AudioFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(AudioFilePeer::DIRECTORY, CcMusicDirsPeer::ID, $join_behavior); + + $criteria->addJoin(AudioFilePeer::OWNER_ID, 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; + } + + + /** + * 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 doCountJoinAllExceptCcSubjs(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(AudioFilePeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + AudioFilePeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(AudioFilePeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(AudioFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(AudioFilePeer::DIRECTORY, CcMusicDirsPeer::ID, $join_behavior); + + $criteria->addJoin(AudioFilePeer::ID, MediaItemPeer::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 AudioFile objects pre-filled with all related objects except CcMusicDirs. + * + * @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 AudioFile objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcMusicDirs(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(AudioFilePeer::DATABASE_NAME); + } + + AudioFilePeer::addSelectColumns($criteria); + $startcol2 = AudioFilePeer::NUM_HYDRATE_COLUMNS; + + MediaItemPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + MediaItemPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(AudioFilePeer::ID, MediaItemPeer::ID, $join_behavior); + + $criteria->addJoin(AudioFilePeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = AudioFilePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = AudioFilePeer::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 = AudioFilePeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + AudioFilePeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined MediaItem rows + + $key2 = MediaItemPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = MediaItemPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = MediaItemPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + MediaItemPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (AudioFile) to the collection in $obj2 (MediaItem) + $obj1->setMediaItem($obj2); + + } // if joined row is not null + + // Add objects for joined CcSubjs rows + + $key3 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcSubjsPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcSubjsPeer::addInstanceToPool($obj3, $key3); + } // if $obj3 already loaded + + // Add the $obj1 (AudioFile) to the collection in $obj3 (CcSubjs) + $obj3->addAudioFile($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of AudioFile objects pre-filled with all related objects except MediaItem. + * + * @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 AudioFile objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptMediaItem(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(AudioFilePeer::DATABASE_NAME); + } + + AudioFilePeer::addSelectColumns($criteria); + $startcol2 = AudioFilePeer::NUM_HYDRATE_COLUMNS; + + CcMusicDirsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcMusicDirsPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(AudioFilePeer::DIRECTORY, CcMusicDirsPeer::ID, $join_behavior); + + $criteria->addJoin(AudioFilePeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = AudioFilePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = AudioFilePeer::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 = AudioFilePeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + AudioFilePeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcMusicDirs rows + + $key2 = CcMusicDirsPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcMusicDirsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcMusicDirsPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcMusicDirsPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (AudioFile) to the collection in $obj2 (CcMusicDirs) + $obj2->addAudioFile($obj1); + + } // if joined row is not null + + // Add objects for joined CcSubjs rows + + $key3 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcSubjsPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcSubjsPeer::addInstanceToPool($obj3, $key3); + } // if $obj3 already loaded + + // Add the $obj1 (AudioFile) to the collection in $obj3 (CcSubjs) + $obj3->addAudioFile($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of AudioFile objects pre-filled with all related objects except CcSubjs. + * + * @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 AudioFile objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcSubjs(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(AudioFilePeer::DATABASE_NAME); + } + + AudioFilePeer::addSelectColumns($criteria); + $startcol2 = AudioFilePeer::NUM_HYDRATE_COLUMNS; + + CcMusicDirsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcMusicDirsPeer::NUM_HYDRATE_COLUMNS; + + MediaItemPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + MediaItemPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(AudioFilePeer::DIRECTORY, CcMusicDirsPeer::ID, $join_behavior); + + $criteria->addJoin(AudioFilePeer::ID, MediaItemPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = AudioFilePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = AudioFilePeer::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 = AudioFilePeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + AudioFilePeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcMusicDirs rows + + $key2 = CcMusicDirsPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcMusicDirsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcMusicDirsPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcMusicDirsPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (AudioFile) to the collection in $obj2 (CcMusicDirs) + $obj2->addAudioFile($obj1); + + } // if joined row is not null + + // Add objects for joined MediaItem rows + + $key3 = MediaItemPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = MediaItemPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = MediaItemPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + MediaItemPeer::addInstanceToPool($obj3, $key3); + } // if $obj3 already loaded + + // Add the $obj1 (AudioFile) to the collection in $obj3 (MediaItem) + $obj1->setMediaItem($obj3); + + } // 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(AudioFilePeer::DATABASE_NAME)->getTable(AudioFilePeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseAudioFilePeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseAudioFilePeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\MediaItem\map\AudioFileTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return AudioFilePeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a AudioFile or Criteria object. + * + * @param mixed $values Criteria or AudioFile 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(AudioFilePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from AudioFile object + } + + + // Set the correct dbName + $criteria->setDbName(AudioFilePeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a AudioFile or Criteria object. + * + * @param mixed $values Criteria or AudioFile 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(AudioFilePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(AudioFilePeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(AudioFilePeer::ID); + $value = $criteria->remove(AudioFilePeer::ID); + if ($value) { + $selectCriteria->add(AudioFilePeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(AudioFilePeer::TABLE_NAME); + } + + } else { // $values is AudioFile object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(AudioFilePeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the audio_file table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(AudioFilePeer::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(AudioFilePeer::TABLE_NAME, $con, AudioFilePeer::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). + AudioFilePeer::clearInstancePool(); + AudioFilePeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a AudioFile or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or AudioFile 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(AudioFilePeer::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. + AudioFilePeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof AudioFile) { // it's a model object + // invalidate the cache for this single object + AudioFilePeer::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(AudioFilePeer::DATABASE_NAME); + $criteria->add(AudioFilePeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + AudioFilePeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(AudioFilePeer::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); + AudioFilePeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given AudioFile 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 AudioFile $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(AudioFilePeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(AudioFilePeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(AudioFilePeer::DATABASE_NAME, AudioFilePeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return AudioFile + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = AudioFilePeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(AudioFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(AudioFilePeer::DATABASE_NAME); + $criteria->add(AudioFilePeer::ID, $pk); + + $v = AudioFilePeer::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 + * @return AudioFile[] + * @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(AudioFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(AudioFilePeer::DATABASE_NAME); + $criteria->add(AudioFilePeer::ID, $pks, Criteria::IN); + $objs = AudioFilePeer::doSelect($criteria, $con); + } + + return $objs; + } + +} // BaseAudioFilePeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseAudioFilePeer::buildTableMap(); + diff --git a/airtime_mvc/application/models/airtime/om/BaseAudioFileQuery.php b/airtime_mvc/application/models/airtime/om/BaseAudioFileQuery.php new file mode 100644 index 000000000..4fa82a2fe --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseAudioFileQuery.php @@ -0,0 +1,2074 @@ +mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return AudioFile|AudioFile[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = AudioFilePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(AudioFilePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return AudioFile A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return AudioFile A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "mime", "directory", "filepath", "md5", "track_title", "artist_name", "bit_rate", "sample_rate", "album_title", "genre", "comments", "year", "track_number", "channels", "url", "bpm", "encoded_by", "mood", "label", "composer", "copyright", "isrc_number", "info_url", "language", "replay_gain", "cuein", "cueout", "silan_check", "file_exists", "hidden", "is_scheduled", "is_playlist", "id", "name", "owner_id", "description", "last_played", "play_count", "length", "created_at", "updated_at" FROM "audio_file" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new AudioFile(); + $obj->hydrate($row); + AudioFilePeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return AudioFile|AudioFile[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($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|AudioFile[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($stmt); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(AudioFilePeer::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 AudioFileQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(AudioFilePeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the mime column + * + * Example usage: + * + * $query->filterByMime('fooValue'); // WHERE mime = 'fooValue' + * $query->filterByMime('%fooValue%'); // WHERE mime LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::MIME, $mime, $comparison); + } + + /** + * Filter the query on the directory column + * + * Example usage: + * + * $query->filterByDirectory(1234); // WHERE directory = 1234 + * $query->filterByDirectory(array(12, 34)); // WHERE directory IN (12, 34) + * $query->filterByDirectory(array('min' => 12)); // WHERE directory >= 12 + * $query->filterByDirectory(array('max' => 12)); // WHERE directory <= 12 + * + * + * @see filterByCcMusicDirs() + * + * @param mixed $directory The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function filterByDirectory($directory = null, $comparison = null) + { + if (is_array($directory)) { + $useMinMax = false; + if (isset($directory['min'])) { + $this->addUsingAlias(AudioFilePeer::DIRECTORY, $directory['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($directory['max'])) { + $this->addUsingAlias(AudioFilePeer::DIRECTORY, $directory['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AudioFilePeer::DIRECTORY, $directory, $comparison); + } + + /** + * Filter the query on the filepath column + * + * Example usage: + * + * $query->filterByFilepath('fooValue'); // WHERE filepath = 'fooValue' + * $query->filterByFilepath('%fooValue%'); // WHERE filepath LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::FILEPATH, $filepath, $comparison); + } + + /** + * Filter the query on the md5 column + * + * Example usage: + * + * $query->filterByMd5('fooValue'); // WHERE md5 = 'fooValue' + * $query->filterByMd5('%fooValue%'); // WHERE md5 LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::MD5, $md5, $comparison); + } + + /** + * Filter the query on the track_title column + * + * Example usage: + * + * $query->filterByTrackTitle('fooValue'); // WHERE track_title = 'fooValue' + * $query->filterByTrackTitle('%fooValue%'); // WHERE track_title LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::TRACK_TITLE, $trackTitle, $comparison); + } + + /** + * Filter the query on the artist_name column + * + * Example usage: + * + * $query->filterByArtistName('fooValue'); // WHERE artist_name = 'fooValue' + * $query->filterByArtistName('%fooValue%'); // WHERE artist_name LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::ARTIST_NAME, $artistName, $comparison); + } + + /** + * Filter the query on the bit_rate column + * + * Example usage: + * + * $query->filterByBitRate(1234); // WHERE bit_rate = 1234 + * $query->filterByBitRate(array(12, 34)); // WHERE bit_rate IN (12, 34) + * $query->filterByBitRate(array('min' => 12)); // WHERE bit_rate >= 12 + * $query->filterByBitRate(array('max' => 12)); // WHERE bit_rate <= 12 + * + * + * @param mixed $bitRate The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function filterByBitRate($bitRate = null, $comparison = null) + { + if (is_array($bitRate)) { + $useMinMax = false; + if (isset($bitRate['min'])) { + $this->addUsingAlias(AudioFilePeer::BIT_RATE, $bitRate['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($bitRate['max'])) { + $this->addUsingAlias(AudioFilePeer::BIT_RATE, $bitRate['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AudioFilePeer::BIT_RATE, $bitRate, $comparison); + } + + /** + * Filter the query on the sample_rate column + * + * Example usage: + * + * $query->filterBySampleRate(1234); // WHERE sample_rate = 1234 + * $query->filterBySampleRate(array(12, 34)); // WHERE sample_rate IN (12, 34) + * $query->filterBySampleRate(array('min' => 12)); // WHERE sample_rate >= 12 + * $query->filterBySampleRate(array('max' => 12)); // WHERE sample_rate <= 12 + * + * + * @param mixed $sampleRate The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function filterBySampleRate($sampleRate = null, $comparison = null) + { + if (is_array($sampleRate)) { + $useMinMax = false; + if (isset($sampleRate['min'])) { + $this->addUsingAlias(AudioFilePeer::SAMPLE_RATE, $sampleRate['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($sampleRate['max'])) { + $this->addUsingAlias(AudioFilePeer::SAMPLE_RATE, $sampleRate['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AudioFilePeer::SAMPLE_RATE, $sampleRate, $comparison); + } + + /** + * Filter the query on the album_title column + * + * Example usage: + * + * $query->filterByAlbumTitle('fooValue'); // WHERE album_title = 'fooValue' + * $query->filterByAlbumTitle('%fooValue%'); // WHERE album_title LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::ALBUM_TITLE, $albumTitle, $comparison); + } + + /** + * Filter the query on the genre column + * + * Example usage: + * + * $query->filterByGenre('fooValue'); // WHERE genre = 'fooValue' + * $query->filterByGenre('%fooValue%'); // WHERE genre LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::GENRE, $genre, $comparison); + } + + /** + * Filter the query on the comments column + * + * Example usage: + * + * $query->filterByComments('fooValue'); // WHERE comments = 'fooValue' + * $query->filterByComments('%fooValue%'); // WHERE comments LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::COMMENTS, $comments, $comparison); + } + + /** + * Filter the query on the year column + * + * Example usage: + * + * $query->filterByYear('fooValue'); // WHERE year = 'fooValue' + * $query->filterByYear('%fooValue%'); // WHERE year LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::YEAR, $year, $comparison); + } + + /** + * Filter the query on the track_number column + * + * Example usage: + * + * $query->filterByTrackNumber(1234); // WHERE track_number = 1234 + * $query->filterByTrackNumber(array(12, 34)); // WHERE track_number IN (12, 34) + * $query->filterByTrackNumber(array('min' => 12)); // WHERE track_number >= 12 + * $query->filterByTrackNumber(array('max' => 12)); // WHERE track_number <= 12 + * + * + * @param mixed $trackNumber The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery 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(AudioFilePeer::TRACK_NUMBER, $trackNumber['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($trackNumber['max'])) { + $this->addUsingAlias(AudioFilePeer::TRACK_NUMBER, $trackNumber['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AudioFilePeer::TRACK_NUMBER, $trackNumber, $comparison); + } + + /** + * Filter the query on the channels column + * + * Example usage: + * + * $query->filterByChannels(1234); // WHERE channels = 1234 + * $query->filterByChannels(array(12, 34)); // WHERE channels IN (12, 34) + * $query->filterByChannels(array('min' => 12)); // WHERE channels >= 12 + * $query->filterByChannels(array('max' => 12)); // WHERE channels <= 12 + * + * + * @param mixed $channels The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery 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(AudioFilePeer::CHANNELS, $channels['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($channels['max'])) { + $this->addUsingAlias(AudioFilePeer::CHANNELS, $channels['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AudioFilePeer::CHANNELS, $channels, $comparison); + } + + /** + * Filter the query on the url column + * + * Example usage: + * + * $query->filterByUrl('fooValue'); // WHERE url = 'fooValue' + * $query->filterByUrl('%fooValue%'); // WHERE url LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::URL, $url, $comparison); + } + + /** + * Filter the query on the bpm column + * + * Example usage: + * + * $query->filterByBpm(1234); // WHERE bpm = 1234 + * $query->filterByBpm(array(12, 34)); // WHERE bpm IN (12, 34) + * $query->filterByBpm(array('min' => 12)); // WHERE bpm >= 12 + * $query->filterByBpm(array('max' => 12)); // WHERE bpm <= 12 + * + * + * @param mixed $bpm The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function filterByBpm($bpm = null, $comparison = null) + { + if (is_array($bpm)) { + $useMinMax = false; + if (isset($bpm['min'])) { + $this->addUsingAlias(AudioFilePeer::BPM, $bpm['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($bpm['max'])) { + $this->addUsingAlias(AudioFilePeer::BPM, $bpm['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AudioFilePeer::BPM, $bpm, $comparison); + } + + /** + * Filter the query on the encoded_by column + * + * Example usage: + * + * $query->filterByEncodedBy('fooValue'); // WHERE encoded_by = 'fooValue' + * $query->filterByEncodedBy('%fooValue%'); // WHERE encoded_by LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::ENCODED_BY, $encodedBy, $comparison); + } + + /** + * Filter the query on the mood column + * + * Example usage: + * + * $query->filterByMood('fooValue'); // WHERE mood = 'fooValue' + * $query->filterByMood('%fooValue%'); // WHERE mood LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::MOOD, $mood, $comparison); + } + + /** + * Filter the query on the label column + * + * Example usage: + * + * $query->filterByLabel('fooValue'); // WHERE label = 'fooValue' + * $query->filterByLabel('%fooValue%'); // WHERE label LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::LABEL, $label, $comparison); + } + + /** + * Filter the query on the composer column + * + * Example usage: + * + * $query->filterByComposer('fooValue'); // WHERE composer = 'fooValue' + * $query->filterByComposer('%fooValue%'); // WHERE composer LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::COMPOSER, $composer, $comparison); + } + + /** + * Filter the query on the copyright column + * + * Example usage: + * + * $query->filterByCopyright('fooValue'); // WHERE copyright = 'fooValue' + * $query->filterByCopyright('%fooValue%'); // WHERE copyright LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::COPYRIGHT, $copyright, $comparison); + } + + /** + * Filter the query on the isrc_number column + * + * Example usage: + * + * $query->filterByIsrcNumber('fooValue'); // WHERE isrc_number = 'fooValue' + * $query->filterByIsrcNumber('%fooValue%'); // WHERE isrc_number LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::ISRC_NUMBER, $isrcNumber, $comparison); + } + + /** + * Filter the query on the info_url column + * + * Example usage: + * + * $query->filterByInfoUrl('fooValue'); // WHERE info_url = 'fooValue' + * $query->filterByInfoUrl('%fooValue%'); // WHERE info_url LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::INFO_URL, $infoUrl, $comparison); + } + + /** + * Filter the query on the language column + * + * Example usage: + * + * $query->filterByLanguage('fooValue'); // WHERE language = 'fooValue' + * $query->filterByLanguage('%fooValue%'); // WHERE language LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::LANGUAGE, $language, $comparison); + } + + /** + * Filter the query on the replay_gain column + * + * Example usage: + * + * $query->filterByReplayGain(1234); // WHERE replay_gain = 1234 + * $query->filterByReplayGain(array(12, 34)); // WHERE replay_gain IN (12, 34) + * $query->filterByReplayGain(array('min' => 12)); // WHERE replay_gain >= 12 + * $query->filterByReplayGain(array('max' => 12)); // WHERE replay_gain <= 12 + * + * + * @param mixed $replayGain The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function filterByReplayGain($replayGain = null, $comparison = null) + { + if (is_array($replayGain)) { + $useMinMax = false; + if (isset($replayGain['min'])) { + $this->addUsingAlias(AudioFilePeer::REPLAY_GAIN, $replayGain['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($replayGain['max'])) { + $this->addUsingAlias(AudioFilePeer::REPLAY_GAIN, $replayGain['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AudioFilePeer::REPLAY_GAIN, $replayGain, $comparison); + } + + /** + * Filter the query on the cuein column + * + * Example usage: + * + * $query->filterByCuein('fooValue'); // WHERE cuein = 'fooValue' + * $query->filterByCuein('%fooValue%'); // WHERE cuein LIKE '%fooValue%' + * + * + * @param string $cuein 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 AudioFileQuery The current query, for fluid interface + */ + public function filterByCuein($cuein = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($cuein)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $cuein)) { + $cuein = str_replace('*', '%', $cuein); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(AudioFilePeer::CUEIN, $cuein, $comparison); + } + + /** + * Filter the query on the cueout column + * + * Example usage: + * + * $query->filterByCueout('fooValue'); // WHERE cueout = 'fooValue' + * $query->filterByCueout('%fooValue%'); // WHERE cueout LIKE '%fooValue%' + * + * + * @param string $cueout 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 AudioFileQuery The current query, for fluid interface + */ + public function filterByCueout($cueout = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($cueout)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $cueout)) { + $cueout = str_replace('*', '%', $cueout); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(AudioFilePeer::CUEOUT, $cueout, $comparison); + } + + /** + * Filter the query on the silan_check column + * + * Example usage: + * + * $query->filterByIsSilanChecked(true); // WHERE silan_check = true + * $query->filterByIsSilanChecked('yes'); // WHERE silan_check = true + * + * + * @param boolean|string $isSilanChecked The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function filterByIsSilanChecked($isSilanChecked = null, $comparison = null) + { + if (is_string($isSilanChecked)) { + $isSilanChecked = in_array(strtolower($isSilanChecked), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(AudioFilePeer::SILAN_CHECK, $isSilanChecked, $comparison); + } + + /** + * Filter the query on the file_exists column + * + * Example usage: + * + * $query->filterByFileExists(true); // WHERE file_exists = true + * $query->filterByFileExists('yes'); // WHERE file_exists = true + * + * + * @param boolean|string $fileExists The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function filterByFileExists($fileExists = null, $comparison = null) + { + if (is_string($fileExists)) { + $fileExists = in_array(strtolower($fileExists), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(AudioFilePeer::FILE_EXISTS, $fileExists, $comparison); + } + + /** + * Filter the query on the hidden column + * + * Example usage: + * + * $query->filterByIsHidden(true); // WHERE hidden = true + * $query->filterByIsHidden('yes'); // WHERE hidden = true + * + * + * @param boolean|string $isHidden The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function filterByIsHidden($isHidden = null, $comparison = null) + { + if (is_string($isHidden)) { + $isHidden = in_array(strtolower($isHidden), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(AudioFilePeer::HIDDEN, $isHidden, $comparison); + } + + /** + * Filter the query on the is_scheduled column + * + * Example usage: + * + * $query->filterByIsScheduled(true); // WHERE is_scheduled = true + * $query->filterByIsScheduled('yes'); // WHERE is_scheduled = true + * + * + * @param boolean|string $isScheduled The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function filterByIsScheduled($isScheduled = null, $comparison = null) + { + if (is_string($isScheduled)) { + $isScheduled = in_array(strtolower($isScheduled), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(AudioFilePeer::IS_SCHEDULED, $isScheduled, $comparison); + } + + /** + * Filter the query on the is_playlist column + * + * Example usage: + * + * $query->filterByIsPlaylist(true); // WHERE is_playlist = true + * $query->filterByIsPlaylist('yes'); // WHERE is_playlist = true + * + * + * @param boolean|string $isPlaylist The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function filterByIsPlaylist($isPlaylist = null, $comparison = null) + { + if (is_string($isPlaylist)) { + $isPlaylist = in_array(strtolower($isPlaylist), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(AudioFilePeer::IS_PLAYLIST, $isPlaylist, $comparison); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 + * + * + * @see filterByMediaItem() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(AudioFilePeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(AudioFilePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AudioFilePeer::ID, $id, $comparison); + } + + /** + * Filter the query on the name column + * + * Example usage: + * + * $query->filterByName('fooValue'); // WHERE name = 'fooValue' + * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' + * + * + * @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 AudioFileQuery 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(AudioFilePeer::NAME, $name, $comparison); + } + + /** + * Filter the query on the owner_id column + * + * Example usage: + * + * $query->filterByOwnerId(1234); // WHERE owner_id = 1234 + * $query->filterByOwnerId(array(12, 34)); // WHERE owner_id IN (12, 34) + * $query->filterByOwnerId(array('min' => 12)); // WHERE owner_id >= 12 + * $query->filterByOwnerId(array('max' => 12)); // WHERE owner_id <= 12 + * + * + * @see filterByCcSubjs() + * + * @param mixed $ownerId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function filterByOwnerId($ownerId = null, $comparison = null) + { + if (is_array($ownerId)) { + $useMinMax = false; + if (isset($ownerId['min'])) { + $this->addUsingAlias(AudioFilePeer::OWNER_ID, $ownerId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($ownerId['max'])) { + $this->addUsingAlias(AudioFilePeer::OWNER_ID, $ownerId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AudioFilePeer::OWNER_ID, $ownerId, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description 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 AudioFileQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(AudioFilePeer::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the last_played column + * + * Example usage: + * + * $query->filterByLastPlayedTime('2011-03-14'); // WHERE last_played = '2011-03-14' + * $query->filterByLastPlayedTime('now'); // WHERE last_played = '2011-03-14' + * $query->filterByLastPlayedTime(array('max' => 'yesterday')); // WHERE last_played < '2011-03-13' + * + * + * @param mixed $lastPlayedTime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function filterByLastPlayedTime($lastPlayedTime = null, $comparison = null) + { + if (is_array($lastPlayedTime)) { + $useMinMax = false; + if (isset($lastPlayedTime['min'])) { + $this->addUsingAlias(AudioFilePeer::LAST_PLAYED, $lastPlayedTime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($lastPlayedTime['max'])) { + $this->addUsingAlias(AudioFilePeer::LAST_PLAYED, $lastPlayedTime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AudioFilePeer::LAST_PLAYED, $lastPlayedTime, $comparison); + } + + /** + * Filter the query on the play_count column + * + * Example usage: + * + * $query->filterByPlayCount(1234); // WHERE play_count = 1234 + * $query->filterByPlayCount(array(12, 34)); // WHERE play_count IN (12, 34) + * $query->filterByPlayCount(array('min' => 12)); // WHERE play_count >= 12 + * $query->filterByPlayCount(array('max' => 12)); // WHERE play_count <= 12 + * + * + * @param mixed $playCount The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function filterByPlayCount($playCount = null, $comparison = null) + { + if (is_array($playCount)) { + $useMinMax = false; + if (isset($playCount['min'])) { + $this->addUsingAlias(AudioFilePeer::PLAY_COUNT, $playCount['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($playCount['max'])) { + $this->addUsingAlias(AudioFilePeer::PLAY_COUNT, $playCount['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AudioFilePeer::PLAY_COUNT, $playCount, $comparison); + } + + /** + * Filter the query on the length column + * + * Example usage: + * + * $query->filterByLength('fooValue'); // WHERE length = 'fooValue' + * $query->filterByLength('%fooValue%'); // WHERE length LIKE '%fooValue%' + * + * + * @param string $length 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 AudioFileQuery The current query, for fluid interface + */ + public function filterByLength($length = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($length)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $length)) { + $length = str_replace('*', '%', $length); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(AudioFilePeer::LENGTH, $length, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at < '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(AudioFilePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(AudioFilePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AudioFilePeer::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at < '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(AudioFilePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(AudioFilePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AudioFilePeer::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related CcMusicDirs object + * + * @param CcMusicDirs|PropelObjectCollection $ccMusicDirs The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcMusicDirs($ccMusicDirs, $comparison = null) + { + if ($ccMusicDirs instanceof CcMusicDirs) { + return $this + ->addUsingAlias(AudioFilePeer::DIRECTORY, $ccMusicDirs->getId(), $comparison); + } elseif ($ccMusicDirs instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(AudioFilePeer::DIRECTORY, $ccMusicDirs->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByCcMusicDirs() only accepts arguments of type CcMusicDirs or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcMusicDirs relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function joinCcMusicDirs($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcMusicDirs'); + + // 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, 'CcMusicDirs'); + } + + return $this; + } + + /** + * Use the CcMusicDirs relation CcMusicDirs 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 \Airtime\CcMusicDirsQuery A secondary query class using the current class as primary query + */ + public function useCcMusicDirsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcMusicDirs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcMusicDirs', '\Airtime\CcMusicDirsQuery'); + } + + /** + * Filter the query by a related MediaItem object + * + * @param MediaItem|PropelObjectCollection $mediaItem The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByMediaItem($mediaItem, $comparison = null) + { + if ($mediaItem instanceof MediaItem) { + return $this + ->addUsingAlias(AudioFilePeer::ID, $mediaItem->getId(), $comparison); + } elseif ($mediaItem instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(AudioFilePeer::ID, $mediaItem->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByMediaItem() only accepts arguments of type MediaItem or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the MediaItem relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function joinMediaItem($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('MediaItem'); + + // 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, 'MediaItem'); + } + + return $this; + } + + /** + * Use the MediaItem relation MediaItem 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 \Airtime\MediaItemQuery A secondary query class using the current class as primary query + */ + public function useMediaItemQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinMediaItem($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'MediaItem', '\Airtime\MediaItemQuery'); + } + + /** + * Filter the query by a related CcSubjs object + * + * @param CcSubjs|PropelObjectCollection $ccSubjs The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return AudioFileQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcSubjs($ccSubjs, $comparison = null) + { + if ($ccSubjs instanceof CcSubjs) { + return $this + ->addUsingAlias(AudioFilePeer::OWNER_ID, $ccSubjs->getDbId(), $comparison); + } elseif ($ccSubjs instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(AudioFilePeer::OWNER_ID, $ccSubjs->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcSubjs() only accepts arguments of type CcSubjs or PropelCollection'); + } + } + + /** + * 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 AudioFileQuery The current query, for fluid interface + */ + public function joinCcSubjs($relationAlias = null, $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 \Airtime\CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSubjs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', '\Airtime\CcSubjsQuery'); + } + + /** + * Exclude object from result + * + * @param AudioFile $audioFile Object to remove from the list of results + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function prune($audioFile = null) + { + if ($audioFile) { + $this->addUsingAlias(AudioFilePeer::ID, $audioFile->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(AudioFilePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AudioFilePeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AudioFilePeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(AudioFilePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(AudioFilePeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return AudioFileQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(AudioFilePeer::CREATED_AT); + } +} diff --git a/airtime_mvc/application/models/airtime/om/BaseBlock.php b/airtime_mvc/application/models/airtime/om/BaseBlock.php new file mode 100644 index 000000000..06e16f41a --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseBlock.php @@ -0,0 +1,1769 @@ +type = 'static'; + $this->play_count = 0; + $this->length = '00:00:00'; + } + + /** + * Initializes internal state of BaseBlock object. + * @see applyDefaults() + */ + public function __construct() + { + parent::__construct(); + $this->applyDefaultValues(); + } + + /** + * Get the [type] column value. + * + * @return string + */ + public function getType() + { + + return $this->type; + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [name] column value. + * + * @return string + */ + public function getName() + { + + return $this->name; + } + + /** + * Get the [owner_id] column value. + * + * @return int + */ + public function getOwnerId() + { + + return $this->owner_id; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [optionally formatted] temporal [last_played] 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 getLastPlayedTime($format = 'Y-m-d H:i:s') + { + if ($this->last_played === null) { + return null; + } + + + try { + $dt = new DateTime($this->last_played); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->last_played, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [play_count] column value. + * + * @return int + */ + public function getPlayCount() + { + + return $this->play_count; + } + + /** + * Get the [length] column value. + * + * @return string + */ + public function getLength() + { + + return $this->length; + } + + /** + * Get the [optionally formatted] temporal [created_at] 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 getCreatedAt($format = 'Y-m-d H:i:s') + { + if ($this->created_at === null) { + return null; + } + + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [optionally formatted] temporal [updated_at] 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 getUpdatedAt($format = 'Y-m-d H:i:s') + { + if ($this->updated_at === null) { + return null; + } + + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Set the value of [type] column. + * + * @param string $v new value + * @return Block The current object (for fluent API support) + */ + public function setType($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->type !== $v) { + $this->type = $v; + $this->modifiedColumns[] = BlockPeer::TYPE; + } + + + return $this; + } // setType() + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return Block The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = BlockPeer::ID; + } + + if ($this->aPlaylist !== null && $this->aPlaylist->getId() !== $v) { + $this->aPlaylist = null; + } + + if ($this->aMediaItem !== null && $this->aMediaItem->getId() !== $v) { + $this->aMediaItem = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return Block The current object (for fluent API support) + */ + public function setName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = BlockPeer::NAME; + } + + + return $this; + } // setName() + + /** + * Set the value of [owner_id] column. + * + * @param int $v new value + * @return Block The current object (for fluent API support) + */ + public function setOwnerId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->owner_id !== $v) { + $this->owner_id = $v; + $this->modifiedColumns[] = BlockPeer::OWNER_ID; + } + + if ($this->aCcSubjs !== null && $this->aCcSubjs->getDbId() !== $v) { + $this->aCcSubjs = null; + } + + + return $this; + } // setOwnerId() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return Block The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = BlockPeer::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Sets the value of [last_played] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return Block The current object (for fluent API support) + */ + public function setLastPlayedTime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->last_played !== null || $dt !== null) { + $currentDateAsString = ($this->last_played !== null && $tmpDt = new DateTime($this->last_played)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->last_played = $newDateAsString; + $this->modifiedColumns[] = BlockPeer::LAST_PLAYED; + } + } // if either are not null + + + return $this; + } // setLastPlayedTime() + + /** + * Set the value of [play_count] column. + * + * @param int $v new value + * @return Block The current object (for fluent API support) + */ + public function setPlayCount($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->play_count !== $v) { + $this->play_count = $v; + $this->modifiedColumns[] = BlockPeer::PLAY_COUNT; + } + + + return $this; + } // setPlayCount() + + /** + * Set the value of [length] column. + * + * @param string $v new value + * @return Block The current object (for fluent API support) + */ + public function setLength($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->length !== $v) { + $this->length = $v; + $this->modifiedColumns[] = BlockPeer::LENGTH; + } + + + return $this; + } // setLength() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return Block The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->created_at !== null || $dt !== null) { + $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->created_at = $newDateAsString; + $this->modifiedColumns[] = BlockPeer::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return Block The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->updated_at !== null || $dt !== null) { + $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->updated_at = $newDateAsString; + $this->modifiedColumns[] = BlockPeer::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * 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->type !== 'static') { + return false; + } + + if ($this->play_count !== 0) { + return false; + } + + if ($this->length !== '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 resultset 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->type = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null; + $this->id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->name = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->owner_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; + $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->last_played = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->play_count = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; + $this->length = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; + $this->created_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->updated_at = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 10; // 10 = BlockPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating Block 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->aPlaylist !== null && $this->id !== $this->aPlaylist->getId()) { + $this->aPlaylist = null; + } + if ($this->aMediaItem !== null && $this->id !== $this->aMediaItem->getId()) { + $this->aMediaItem = null; + } + if ($this->aCcSubjs !== null && $this->owner_id !== $this->aCcSubjs->getDbId()) { + $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(BlockPeer::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 = BlockPeer::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->aPlaylist = null; + $this->aMediaItem = null; + $this->aCcSubjs = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(BlockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = BlockQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + // concrete_inheritance behavior + $this->getParentOrCreate($con)->delete($con); + + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(BlockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + // concrete_inheritance behavior + $parent = $this->getSyncParent($con); + $parent->save($con); + $this->setPrimaryKey($parent->getPrimaryKey()); + + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(BlockPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(BlockPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(BlockPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + BlockPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aPlaylist !== null) { + if ($this->aPlaylist->isModified() || $this->aPlaylist->isNew()) { + $affectedRows += $this->aPlaylist->save($con); + } + $this->setPlaylist($this->aPlaylist); + } + + if ($this->aMediaItem !== null) { + if ($this->aMediaItem->isModified() || $this->aMediaItem->isNew()) { + $affectedRows += $this->aMediaItem->save($con); + } + $this->setMediaItem($this->aMediaItem); + } + + if ($this->aCcSubjs !== null) { + if ($this->aCcSubjs->isModified() || $this->aCcSubjs->isNew()) { + $affectedRows += $this->aCcSubjs->save($con); + } + $this->setCcSubjs($this->aCcSubjs); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(BlockPeer::TYPE)) { + $modifiedColumns[':p' . $index++] = '"type"'; + } + if ($this->isColumnModified(BlockPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(BlockPeer::NAME)) { + $modifiedColumns[':p' . $index++] = '"name"'; + } + if ($this->isColumnModified(BlockPeer::OWNER_ID)) { + $modifiedColumns[':p' . $index++] = '"owner_id"'; + } + if ($this->isColumnModified(BlockPeer::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = '"description"'; + } + if ($this->isColumnModified(BlockPeer::LAST_PLAYED)) { + $modifiedColumns[':p' . $index++] = '"last_played"'; + } + if ($this->isColumnModified(BlockPeer::PLAY_COUNT)) { + $modifiedColumns[':p' . $index++] = '"play_count"'; + } + if ($this->isColumnModified(BlockPeer::LENGTH)) { + $modifiedColumns[':p' . $index++] = '"length"'; + } + if ($this->isColumnModified(BlockPeer::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = '"created_at"'; + } + if ($this->isColumnModified(BlockPeer::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = '"updated_at"'; + } + + $sql = sprintf( + 'INSERT INTO "block" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"type"': + $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR); + break; + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"name"': + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); + break; + case '"owner_id"': + $stmt->bindValue($identifier, $this->owner_id, PDO::PARAM_INT); + break; + case '"description"': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case '"last_played"': + $stmt->bindValue($identifier, $this->last_played, PDO::PARAM_STR); + break; + case '"play_count"': + $stmt->bindValue($identifier, $this->play_count, PDO::PARAM_INT); + break; + case '"length"': + $stmt->bindValue($identifier, $this->length, PDO::PARAM_STR); + break; + case '"created_at"': + $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + break; + case '"updated_at"': + $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aPlaylist !== null) { + if (!$this->aPlaylist->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aPlaylist->getValidationFailures()); + } + } + + if ($this->aMediaItem !== null) { + if (!$this->aMediaItem->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aMediaItem->getValidationFailures()); + } + } + + if ($this->aCcSubjs !== null) { + if (!$this->aCcSubjs->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcSubjs->getValidationFailures()); + } + } + + + if (($retval = BlockPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = BlockPeer::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->getType(); + break; + case 1: + return $this->getId(); + break; + case 2: + return $this->getName(); + break; + case 3: + return $this->getOwnerId(); + break; + case 4: + return $this->getDescription(); + break; + case 5: + return $this->getLastPlayedTime(); + break; + case 6: + return $this->getPlayCount(); + break; + case 7: + return $this->getLength(); + break; + case 8: + return $this->getCreatedAt(); + break; + case 9: + return $this->getUpdatedAt(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['Block'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['Block'][$this->getPrimaryKey()] = true; + $keys = BlockPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getType(), + $keys[1] => $this->getId(), + $keys[2] => $this->getName(), + $keys[3] => $this->getOwnerId(), + $keys[4] => $this->getDescription(), + $keys[5] => $this->getLastPlayedTime(), + $keys[6] => $this->getPlayCount(), + $keys[7] => $this->getLength(), + $keys[8] => $this->getCreatedAt(), + $keys[9] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aPlaylist) { + $result['Playlist'] = $this->aPlaylist->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aMediaItem) { + $result['MediaItem'] = $this->aMediaItem->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aCcSubjs) { + $result['CcSubjs'] = $this->aCcSubjs->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = BlockPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setType($value); + break; + case 1: + $this->setId($value); + break; + case 2: + $this->setName($value); + break; + case 3: + $this->setOwnerId($value); + break; + case 4: + $this->setDescription($value); + break; + case 5: + $this->setLastPlayedTime($value); + break; + case 6: + $this->setPlayCount($value); + break; + case 7: + $this->setLength($value); + break; + case 8: + $this->setCreatedAt($value); + break; + case 9: + $this->setUpdatedAt($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 BasePeer::TYPE_PHPNAME + * + * @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 = BlockPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setType($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setName($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setOwnerId($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setLastPlayedTime($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setPlayCount($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setLength($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setCreatedAt($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setUpdatedAt($arr[$keys[9]]); + } + + /** + * 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(BlockPeer::DATABASE_NAME); + + if ($this->isColumnModified(BlockPeer::TYPE)) $criteria->add(BlockPeer::TYPE, $this->type); + if ($this->isColumnModified(BlockPeer::ID)) $criteria->add(BlockPeer::ID, $this->id); + if ($this->isColumnModified(BlockPeer::NAME)) $criteria->add(BlockPeer::NAME, $this->name); + if ($this->isColumnModified(BlockPeer::OWNER_ID)) $criteria->add(BlockPeer::OWNER_ID, $this->owner_id); + if ($this->isColumnModified(BlockPeer::DESCRIPTION)) $criteria->add(BlockPeer::DESCRIPTION, $this->description); + if ($this->isColumnModified(BlockPeer::LAST_PLAYED)) $criteria->add(BlockPeer::LAST_PLAYED, $this->last_played); + if ($this->isColumnModified(BlockPeer::PLAY_COUNT)) $criteria->add(BlockPeer::PLAY_COUNT, $this->play_count); + if ($this->isColumnModified(BlockPeer::LENGTH)) $criteria->add(BlockPeer::LENGTH, $this->length); + if ($this->isColumnModified(BlockPeer::CREATED_AT)) $criteria->add(BlockPeer::CREATED_AT, $this->created_at); + if ($this->isColumnModified(BlockPeer::UPDATED_AT)) $criteria->add(BlockPeer::UPDATED_AT, $this->updated_at); + + 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(BlockPeer::DATABASE_NAME); + $criteria->add(BlockPeer::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 Block (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setType($this->getType()); + $copyObj->setName($this->getName()); + $copyObj->setOwnerId($this->getOwnerId()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setLastPlayedTime($this->getLastPlayedTime()); + $copyObj->setPlayCount($this->getPlayCount()); + $copyObj->setLength($this->getLength()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + $relObj = $this->getPlaylist(); + if ($relObj) { + $copyObj->setPlaylist($relObj->copy($deepCopy)); + } + + $relObj = $this->getMediaItem(); + if ($relObj) { + $copyObj->setMediaItem($relObj->copy($deepCopy)); + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 Block 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 BlockPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new BlockPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a Playlist object. + * + * @param Playlist $v + * @return Block The current object (for fluent API support) + * @throws PropelException + */ + public function setPlaylist(Playlist $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aPlaylist = $v; + + // Add binding for other direction of this 1:1 relationship. + if ($v !== null) { + $v->setBlock($this); + } + + + return $this; + } + + + /** + * Get the associated Playlist object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return Playlist The associated Playlist object. + * @throws PropelException + */ + public function getPlaylist(PropelPDO $con = null, $doQuery = true) + { + if ($this->aPlaylist === null && ($this->id !== null) && $doQuery) { + $this->aPlaylist = PlaylistQuery::create()->findPk($this->id, $con); + // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association. + $this->aPlaylist->setBlock($this); + } + + return $this->aPlaylist; + } + + /** + * Declares an association between this object and a MediaItem object. + * + * @param MediaItem $v + * @return Block The current object (for fluent API support) + * @throws PropelException + */ + public function setMediaItem(MediaItem $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aMediaItem = $v; + + // Add binding for other direction of this 1:1 relationship. + if ($v !== null) { + $v->setBlock($this); + } + + + return $this; + } + + + /** + * Get the associated MediaItem object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return MediaItem The associated MediaItem object. + * @throws PropelException + */ + public function getMediaItem(PropelPDO $con = null, $doQuery = true) + { + if ($this->aMediaItem === null && ($this->id !== null) && $doQuery) { + $this->aMediaItem = MediaItemQuery::create()->findPk($this->id, $con); + // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association. + $this->aMediaItem->setBlock($this); + } + + return $this->aMediaItem; + } + + /** + * Declares an association between this object and a CcSubjs object. + * + * @param CcSubjs $v + * @return Block The current object (for fluent API support) + * @throws PropelException + */ + public function setCcSubjs(CcSubjs $v = null) + { + if ($v === null) { + $this->setOwnerId(NULL); + } else { + $this->setOwnerId($v->getDbId()); + } + + $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->addBlock($this); + } + + + return $this; + } + + + /** + * Get the associated CcSubjs object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getCcSubjs(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcSubjs === null && ($this->owner_id !== null) && $doQuery) { + $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->owner_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->aCcSubjs->addBlocks($this); + */ + } + + return $this->aCcSubjs; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->type = null; + $this->id = null; + $this->name = null; + $this->owner_id = null; + $this->description = null; + $this->last_played = null; + $this->play_count = null; + $this->length = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aPlaylist instanceof Persistent) { + $this->aPlaylist->clearAllReferences($deep); + } + if ($this->aMediaItem instanceof Persistent) { + $this->aMediaItem->clearAllReferences($deep); + } + if ($this->aCcSubjs instanceof Persistent) { + $this->aCcSubjs->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + $this->aPlaylist = null; + $this->aMediaItem = null; + $this->aCcSubjs = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(BlockPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + + // concrete_inheritance behavior + + /** + * Get or Create the parent Playlist object of the current object + * + * @return Playlist The parent object + */ + public function getParentOrCreate($con = null) + { + if ($this->isNew()) { + if ($this->isPrimaryKeyNull()) { + //this prevent issue with deep copy & save parent object + if (null === ($parent = $this->getPlaylist($con))) { + $parent = new Playlist(); + } + $parent->setDescendantClass('Airtime\MediaItem\Block'); + + return $parent; + } else { + $parent = PlaylistQuery::create()->findPk($this->getPrimaryKey(), $con); + if (null === $parent || null !== $parent->getDescendantClass()) { + $parent = new Playlist(); + $parent->setPrimaryKey($this->getPrimaryKey()); + $parent->setDescendantClass('Airtime\MediaItem\Block'); + } + + return $parent; + } + } + + return PlaylistQuery::create()->findPk($this->getPrimaryKey(), $con); + } + + /** + * Create or Update the parent Playlist object + * And return its primary key + * + * @return int The primary key of the parent object + */ + public function getSyncParent($con = null) + { + $parent = $this->getParentOrCreate($con); + $parent->setName($this->getName()); + $parent->setOwnerId($this->getOwnerId()); + $parent->setDescription($this->getDescription()); + $parent->setLastPlayedTime($this->getLastPlayedTime()); + $parent->setPlayCount($this->getPlayCount()); + $parent->setLength($this->getLength()); + $parent->setCreatedAt($this->getCreatedAt()); + $parent->setUpdatedAt($this->getUpdatedAt()); + if ($this->getCcSubjs() && $this->getCcSubjs()->isNew()) { + $parent->setCcSubjs($this->getCcSubjs()); + } + + return $parent; + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Block The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = BlockPeer::UPDATED_AT; + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseBlockPeer.php b/airtime_mvc/application/models/airtime/om/BaseBlockPeer.php new file mode 100644 index 000000000..59829b5e9 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseBlockPeer.php @@ -0,0 +1,1791 @@ + array ('Type', 'Id', 'Name', 'OwnerId', 'Description', 'LastPlayedTime', 'PlayCount', 'Length', 'CreatedAt', 'UpdatedAt', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('type', 'id', 'name', 'ownerId', 'description', 'lastPlayedTime', 'playCount', 'length', 'createdAt', 'updatedAt', ), + BasePeer::TYPE_COLNAME => array (BlockPeer::TYPE, BlockPeer::ID, BlockPeer::NAME, BlockPeer::OWNER_ID, BlockPeer::DESCRIPTION, BlockPeer::LAST_PLAYED, BlockPeer::PLAY_COUNT, BlockPeer::LENGTH, BlockPeer::CREATED_AT, BlockPeer::UPDATED_AT, ), + BasePeer::TYPE_RAW_COLNAME => array ('TYPE', 'ID', 'NAME', 'OWNER_ID', 'DESCRIPTION', 'LAST_PLAYED', 'PLAY_COUNT', 'LENGTH', 'CREATED_AT', 'UPDATED_AT', ), + BasePeer::TYPE_FIELDNAME => array ('type', 'id', 'name', 'owner_id', 'description', 'last_played', 'play_count', 'length', 'created_at', 'updated_at', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. BlockPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('Type' => 0, 'Id' => 1, 'Name' => 2, 'OwnerId' => 3, 'Description' => 4, 'LastPlayedTime' => 5, 'PlayCount' => 6, 'Length' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('type' => 0, 'id' => 1, 'name' => 2, 'ownerId' => 3, 'description' => 4, 'lastPlayedTime' => 5, 'playCount' => 6, 'length' => 7, 'createdAt' => 8, 'updatedAt' => 9, ), + BasePeer::TYPE_COLNAME => array (BlockPeer::TYPE => 0, BlockPeer::ID => 1, BlockPeer::NAME => 2, BlockPeer::OWNER_ID => 3, BlockPeer::DESCRIPTION => 4, BlockPeer::LAST_PLAYED => 5, BlockPeer::PLAY_COUNT => 6, BlockPeer::LENGTH => 7, BlockPeer::CREATED_AT => 8, BlockPeer::UPDATED_AT => 9, ), + BasePeer::TYPE_RAW_COLNAME => array ('TYPE' => 0, 'ID' => 1, 'NAME' => 2, 'OWNER_ID' => 3, 'DESCRIPTION' => 4, 'LAST_PLAYED' => 5, 'PLAY_COUNT' => 6, 'LENGTH' => 7, 'CREATED_AT' => 8, 'UPDATED_AT' => 9, ), + BasePeer::TYPE_FIELDNAME => array ('type' => 0, 'id' => 1, 'name' => 2, 'owner_id' => 3, 'description' => 4, 'last_played' => 5, 'play_count' => 6, 'length' => 7, 'created_at' => 8, 'updated_at' => 9, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = BlockPeer::getFieldNames($toType); + $key = isset(BlockPeer::$fieldKeys[$fromType][$name]) ? BlockPeer::$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(BlockPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, BlockPeer::$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 BlockPeer::$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. BlockPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(BlockPeer::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(BlockPeer::TYPE); + $criteria->addSelectColumn(BlockPeer::ID); + $criteria->addSelectColumn(BlockPeer::NAME); + $criteria->addSelectColumn(BlockPeer::OWNER_ID); + $criteria->addSelectColumn(BlockPeer::DESCRIPTION); + $criteria->addSelectColumn(BlockPeer::LAST_PLAYED); + $criteria->addSelectColumn(BlockPeer::PLAY_COUNT); + $criteria->addSelectColumn(BlockPeer::LENGTH); + $criteria->addSelectColumn(BlockPeer::CREATED_AT); + $criteria->addSelectColumn(BlockPeer::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.type'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.name'); + $criteria->addSelectColumn($alias . '.owner_id'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.last_played'); + $criteria->addSelectColumn($alias . '.play_count'); + $criteria->addSelectColumn($alias . '.length'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); + } + } + + /** + * 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(BlockPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + BlockPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(BlockPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(BlockPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return Block + * @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 = BlockPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 BlockPeer::populateObjects(BlockPeer::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 directly (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(BlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + BlockPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(BlockPeer::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 Block $obj A Block object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getId(); + } // if key === null + BlockPeer::$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 Block object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof Block) { + $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 Block object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(BlockPeer::$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 Block 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(BlockPeer::$instances[$key])) { + return BlockPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (BlockPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + BlockPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to block + * 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 + 1] === null) { + return null; + } + + return (string) $row[$startcol + 1]; + } + + /** + * 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 + 1]; + } + + /** + * 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 = BlockPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = BlockPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = BlockPeer::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; + BlockPeer::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 (Block object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = BlockPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = BlockPeer::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 + BlockPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = BlockPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + BlockPeer::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + + /** + * Returns the number of rows matching criteria, joining the related Playlist 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 doCountJoinPlaylist(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(BlockPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + BlockPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(BlockPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(BlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(BlockPeer::ID, PlaylistPeer::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 MediaItem 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 doCountJoinMediaItem(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(BlockPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + BlockPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(BlockPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(BlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(BlockPeer::ID, MediaItemPeer::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 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(BlockPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + BlockPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(BlockPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(BlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(BlockPeer::OWNER_ID, 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 Block objects pre-filled with their Playlist 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 Block objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinPlaylist(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(BlockPeer::DATABASE_NAME); + } + + BlockPeer::addSelectColumns($criteria); + $startcol = BlockPeer::NUM_HYDRATE_COLUMNS; + PlaylistPeer::addSelectColumns($criteria); + + $criteria->addJoin(BlockPeer::ID, PlaylistPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = BlockPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = BlockPeer::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 = BlockPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + BlockPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = PlaylistPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = PlaylistPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = PlaylistPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + PlaylistPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (Block) to $obj2 (Playlist) + // one to one relationship + $obj1->setPlaylist($obj2); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of Block objects pre-filled with their MediaItem 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 Block objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinMediaItem(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(BlockPeer::DATABASE_NAME); + } + + BlockPeer::addSelectColumns($criteria); + $startcol = BlockPeer::NUM_HYDRATE_COLUMNS; + MediaItemPeer::addSelectColumns($criteria); + + $criteria->addJoin(BlockPeer::ID, MediaItemPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = BlockPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = BlockPeer::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 = BlockPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + BlockPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = MediaItemPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = MediaItemPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = MediaItemPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + MediaItemPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (Block) to $obj2 (MediaItem) + // one to one relationship + $obj1->setMediaItem($obj2); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of Block 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 Block 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(BlockPeer::DATABASE_NAME); + } + + BlockPeer::addSelectColumns($criteria); + $startcol = BlockPeer::NUM_HYDRATE_COLUMNS; + CcSubjsPeer::addSelectColumns($criteria); + + $criteria->addJoin(BlockPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = BlockPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = BlockPeer::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 = BlockPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + BlockPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (Block) to $obj2 (CcSubjs) + $obj2->addBlock($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(BlockPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + BlockPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(BlockPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(BlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(BlockPeer::ID, PlaylistPeer::ID, $join_behavior); + + $criteria->addJoin(BlockPeer::ID, MediaItemPeer::ID, $join_behavior); + + $criteria->addJoin(BlockPeer::OWNER_ID, 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 Block 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 Block 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(BlockPeer::DATABASE_NAME); + } + + BlockPeer::addSelectColumns($criteria); + $startcol2 = BlockPeer::NUM_HYDRATE_COLUMNS; + + PlaylistPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + PlaylistPeer::NUM_HYDRATE_COLUMNS; + + MediaItemPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + MediaItemPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol5 = $startcol4 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(BlockPeer::ID, PlaylistPeer::ID, $join_behavior); + + $criteria->addJoin(BlockPeer::ID, MediaItemPeer::ID, $join_behavior); + + $criteria->addJoin(BlockPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = BlockPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = BlockPeer::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 = BlockPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + BlockPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined Playlist rows + + $key2 = PlaylistPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = PlaylistPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = PlaylistPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + PlaylistPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (Block) to the collection in $obj2 (Playlist) + $obj1->setPlaylist($obj2); + } // if joined row not null + + // Add objects for joined MediaItem rows + + $key3 = MediaItemPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = MediaItemPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = MediaItemPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + MediaItemPeer::addInstanceToPool($obj3, $key3); + } // if obj3 loaded + + // Add the $obj1 (Block) to the collection in $obj3 (MediaItem) + $obj1->setMediaItem($obj3); + } // if joined row not null + + // Add objects for joined CcSubjs rows + + $key4 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol4); + if ($key4 !== null) { + $obj4 = CcSubjsPeer::getInstanceFromPool($key4); + if (!$obj4) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj4 = new $cls(); + $obj4->hydrate($row, $startcol4); + CcSubjsPeer::addInstanceToPool($obj4, $key4); + } // if obj4 loaded + + // Add the $obj1 (Block) to the collection in $obj4 (CcSubjs) + $obj4->addBlock($obj1); + } // if joined row not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining the related Playlist 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 doCountJoinAllExceptPlaylist(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(BlockPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + BlockPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(BlockPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(BlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(BlockPeer::ID, MediaItemPeer::ID, $join_behavior); + + $criteria->addJoin(BlockPeer::OWNER_ID, 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; + } + + + /** + * Returns the number of rows matching criteria, joining the related MediaItem 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 doCountJoinAllExceptMediaItem(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(BlockPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + BlockPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(BlockPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(BlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(BlockPeer::ID, PlaylistPeer::ID, $join_behavior); + + $criteria->addJoin(BlockPeer::OWNER_ID, 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; + } + + + /** + * 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 doCountJoinAllExceptCcSubjs(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(BlockPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + BlockPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(BlockPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(BlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(BlockPeer::ID, PlaylistPeer::ID, $join_behavior); + + $criteria->addJoin(BlockPeer::ID, MediaItemPeer::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 Block objects pre-filled with all related objects except Playlist. + * + * @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 Block objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptPlaylist(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(BlockPeer::DATABASE_NAME); + } + + BlockPeer::addSelectColumns($criteria); + $startcol2 = BlockPeer::NUM_HYDRATE_COLUMNS; + + MediaItemPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + MediaItemPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(BlockPeer::ID, MediaItemPeer::ID, $join_behavior); + + $criteria->addJoin(BlockPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = BlockPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = BlockPeer::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 = BlockPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + BlockPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined MediaItem rows + + $key2 = MediaItemPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = MediaItemPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = MediaItemPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + MediaItemPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (Block) to the collection in $obj2 (MediaItem) + $obj1->setMediaItem($obj2); + + } // if joined row is not null + + // Add objects for joined CcSubjs rows + + $key3 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcSubjsPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcSubjsPeer::addInstanceToPool($obj3, $key3); + } // if $obj3 already loaded + + // Add the $obj1 (Block) to the collection in $obj3 (CcSubjs) + $obj3->addBlock($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of Block objects pre-filled with all related objects except MediaItem. + * + * @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 Block objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptMediaItem(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(BlockPeer::DATABASE_NAME); + } + + BlockPeer::addSelectColumns($criteria); + $startcol2 = BlockPeer::NUM_HYDRATE_COLUMNS; + + PlaylistPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + PlaylistPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(BlockPeer::ID, PlaylistPeer::ID, $join_behavior); + + $criteria->addJoin(BlockPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = BlockPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = BlockPeer::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 = BlockPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + BlockPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined Playlist rows + + $key2 = PlaylistPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = PlaylistPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = PlaylistPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + PlaylistPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (Block) to the collection in $obj2 (Playlist) + $obj1->setPlaylist($obj2); + + } // if joined row is not null + + // Add objects for joined CcSubjs rows + + $key3 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcSubjsPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcSubjsPeer::addInstanceToPool($obj3, $key3); + } // if $obj3 already loaded + + // Add the $obj1 (Block) to the collection in $obj3 (CcSubjs) + $obj3->addBlock($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of Block objects pre-filled with all related objects except CcSubjs. + * + * @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 Block objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcSubjs(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(BlockPeer::DATABASE_NAME); + } + + BlockPeer::addSelectColumns($criteria); + $startcol2 = BlockPeer::NUM_HYDRATE_COLUMNS; + + PlaylistPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + PlaylistPeer::NUM_HYDRATE_COLUMNS; + + MediaItemPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + MediaItemPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(BlockPeer::ID, PlaylistPeer::ID, $join_behavior); + + $criteria->addJoin(BlockPeer::ID, MediaItemPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = BlockPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = BlockPeer::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 = BlockPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + BlockPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined Playlist rows + + $key2 = PlaylistPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = PlaylistPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = PlaylistPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + PlaylistPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (Block) to the collection in $obj2 (Playlist) + $obj1->setPlaylist($obj2); + + } // if joined row is not null + + // Add objects for joined MediaItem rows + + $key3 = MediaItemPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = MediaItemPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = MediaItemPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + MediaItemPeer::addInstanceToPool($obj3, $key3); + } // if $obj3 already loaded + + // Add the $obj1 (Block) to the collection in $obj3 (MediaItem) + $obj1->setMediaItem($obj3); + + } // 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(BlockPeer::DATABASE_NAME)->getTable(BlockPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseBlockPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseBlockPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\MediaItem\map\BlockTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return BlockPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a Block or Criteria object. + * + * @param mixed $values Criteria or Block 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(BlockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from Block object + } + + + // Set the correct dbName + $criteria->setDbName(BlockPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a Block or Criteria object. + * + * @param mixed $values Criteria or Block 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(BlockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(BlockPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(BlockPeer::ID); + $value = $criteria->remove(BlockPeer::ID); + if ($value) { + $selectCriteria->add(BlockPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(BlockPeer::TABLE_NAME); + } + + } else { // $values is Block object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(BlockPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the block table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(BlockPeer::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(BlockPeer::TABLE_NAME, $con, BlockPeer::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). + BlockPeer::clearInstancePool(); + BlockPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a Block or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or Block 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(BlockPeer::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. + BlockPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof Block) { // it's a model object + // invalidate the cache for this single object + BlockPeer::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(BlockPeer::DATABASE_NAME); + $criteria->add(BlockPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + BlockPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(BlockPeer::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); + BlockPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given Block 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 Block $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(BlockPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(BlockPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(BlockPeer::DATABASE_NAME, BlockPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return Block + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = BlockPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(BlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(BlockPeer::DATABASE_NAME); + $criteria->add(BlockPeer::ID, $pk); + + $v = BlockPeer::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 + * @return Block[] + * @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(BlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(BlockPeer::DATABASE_NAME); + $criteria->add(BlockPeer::ID, $pks, Criteria::IN); + $objs = BlockPeer::doSelect($criteria, $con); + } + + return $objs; + } + +} // BaseBlockPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseBlockPeer::buildTableMap(); + diff --git a/airtime_mvc/application/models/airtime/om/BaseBlockQuery.php b/airtime_mvc/application/models/airtime/om/BaseBlockQuery.php new file mode 100644 index 000000000..798a9e546 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseBlockQuery.php @@ -0,0 +1,970 @@ +mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return Block|Block[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = BlockPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(BlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Block A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Block A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "type", "id", "name", "owner_id", "description", "last_played", "play_count", "length", "created_at", "updated_at" FROM "block" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new Block(); + $obj->hydrate($row); + BlockPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Block|Block[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($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|Block[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($stmt); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return BlockQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(BlockPeer::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 BlockQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(BlockPeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the type column + * + * Example usage: + * + * $query->filterByType('fooValue'); // WHERE type = 'fooValue' + * $query->filterByType('%fooValue%'); // WHERE type LIKE '%fooValue%' + * + * + * @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 BlockQuery 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(BlockPeer::TYPE, $type, $comparison); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 + * + * + * @see filterByPlaylist() + * + * @see filterByMediaItem() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return BlockQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(BlockPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(BlockPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(BlockPeer::ID, $id, $comparison); + } + + /** + * Filter the query on the name column + * + * Example usage: + * + * $query->filterByName('fooValue'); // WHERE name = 'fooValue' + * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' + * + * + * @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 BlockQuery 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(BlockPeer::NAME, $name, $comparison); + } + + /** + * Filter the query on the owner_id column + * + * Example usage: + * + * $query->filterByOwnerId(1234); // WHERE owner_id = 1234 + * $query->filterByOwnerId(array(12, 34)); // WHERE owner_id IN (12, 34) + * $query->filterByOwnerId(array('min' => 12)); // WHERE owner_id >= 12 + * $query->filterByOwnerId(array('max' => 12)); // WHERE owner_id <= 12 + * + * + * @see filterByCcSubjs() + * + * @param mixed $ownerId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return BlockQuery The current query, for fluid interface + */ + public function filterByOwnerId($ownerId = null, $comparison = null) + { + if (is_array($ownerId)) { + $useMinMax = false; + if (isset($ownerId['min'])) { + $this->addUsingAlias(BlockPeer::OWNER_ID, $ownerId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($ownerId['max'])) { + $this->addUsingAlias(BlockPeer::OWNER_ID, $ownerId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(BlockPeer::OWNER_ID, $ownerId, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description 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 BlockQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(BlockPeer::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the last_played column + * + * Example usage: + * + * $query->filterByLastPlayedTime('2011-03-14'); // WHERE last_played = '2011-03-14' + * $query->filterByLastPlayedTime('now'); // WHERE last_played = '2011-03-14' + * $query->filterByLastPlayedTime(array('max' => 'yesterday')); // WHERE last_played < '2011-03-13' + * + * + * @param mixed $lastPlayedTime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return BlockQuery The current query, for fluid interface + */ + public function filterByLastPlayedTime($lastPlayedTime = null, $comparison = null) + { + if (is_array($lastPlayedTime)) { + $useMinMax = false; + if (isset($lastPlayedTime['min'])) { + $this->addUsingAlias(BlockPeer::LAST_PLAYED, $lastPlayedTime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($lastPlayedTime['max'])) { + $this->addUsingAlias(BlockPeer::LAST_PLAYED, $lastPlayedTime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(BlockPeer::LAST_PLAYED, $lastPlayedTime, $comparison); + } + + /** + * Filter the query on the play_count column + * + * Example usage: + * + * $query->filterByPlayCount(1234); // WHERE play_count = 1234 + * $query->filterByPlayCount(array(12, 34)); // WHERE play_count IN (12, 34) + * $query->filterByPlayCount(array('min' => 12)); // WHERE play_count >= 12 + * $query->filterByPlayCount(array('max' => 12)); // WHERE play_count <= 12 + * + * + * @param mixed $playCount The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return BlockQuery The current query, for fluid interface + */ + public function filterByPlayCount($playCount = null, $comparison = null) + { + if (is_array($playCount)) { + $useMinMax = false; + if (isset($playCount['min'])) { + $this->addUsingAlias(BlockPeer::PLAY_COUNT, $playCount['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($playCount['max'])) { + $this->addUsingAlias(BlockPeer::PLAY_COUNT, $playCount['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(BlockPeer::PLAY_COUNT, $playCount, $comparison); + } + + /** + * Filter the query on the length column + * + * Example usage: + * + * $query->filterByLength('fooValue'); // WHERE length = 'fooValue' + * $query->filterByLength('%fooValue%'); // WHERE length LIKE '%fooValue%' + * + * + * @param string $length 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 BlockQuery The current query, for fluid interface + */ + public function filterByLength($length = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($length)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $length)) { + $length = str_replace('*', '%', $length); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(BlockPeer::LENGTH, $length, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at < '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return BlockQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(BlockPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(BlockPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(BlockPeer::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at < '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return BlockQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(BlockPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(BlockPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(BlockPeer::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related Playlist object + * + * @param Playlist|PropelObjectCollection $playlist The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return BlockQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByPlaylist($playlist, $comparison = null) + { + if ($playlist instanceof Playlist) { + return $this + ->addUsingAlias(BlockPeer::ID, $playlist->getId(), $comparison); + } elseif ($playlist instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(BlockPeer::ID, $playlist->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByPlaylist() only accepts arguments of type Playlist or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the Playlist relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return BlockQuery The current query, for fluid interface + */ + public function joinPlaylist($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Playlist'); + + // 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, 'Playlist'); + } + + return $this; + } + + /** + * Use the Playlist relation Playlist 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 \Airtime\MediaItem\PlaylistQuery A secondary query class using the current class as primary query + */ + public function usePlaylistQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinPlaylist($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Playlist', '\Airtime\MediaItem\PlaylistQuery'); + } + + /** + * Filter the query by a related MediaItem object + * + * @param MediaItem|PropelObjectCollection $mediaItem The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return BlockQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByMediaItem($mediaItem, $comparison = null) + { + if ($mediaItem instanceof MediaItem) { + return $this + ->addUsingAlias(BlockPeer::ID, $mediaItem->getId(), $comparison); + } elseif ($mediaItem instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(BlockPeer::ID, $mediaItem->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByMediaItem() only accepts arguments of type MediaItem or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the MediaItem relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return BlockQuery The current query, for fluid interface + */ + public function joinMediaItem($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('MediaItem'); + + // 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, 'MediaItem'); + } + + return $this; + } + + /** + * Use the MediaItem relation MediaItem 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 \Airtime\MediaItemQuery A secondary query class using the current class as primary query + */ + public function useMediaItemQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinMediaItem($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'MediaItem', '\Airtime\MediaItemQuery'); + } + + /** + * Filter the query by a related CcSubjs object + * + * @param CcSubjs|PropelObjectCollection $ccSubjs The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return BlockQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcSubjs($ccSubjs, $comparison = null) + { + if ($ccSubjs instanceof CcSubjs) { + return $this + ->addUsingAlias(BlockPeer::OWNER_ID, $ccSubjs->getDbId(), $comparison); + } elseif ($ccSubjs instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(BlockPeer::OWNER_ID, $ccSubjs->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcSubjs() only accepts arguments of type CcSubjs or PropelCollection'); + } + } + + /** + * 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 BlockQuery The current query, for fluid interface + */ + public function joinCcSubjs($relationAlias = null, $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 \Airtime\CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSubjs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', '\Airtime\CcSubjsQuery'); + } + + /** + * Exclude object from result + * + * @param Block $block Object to remove from the list of results + * + * @return BlockQuery The current query, for fluid interface + */ + public function prune($block = null) + { + if ($block) { + $this->addUsingAlias(BlockPeer::ID, $block->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return BlockQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(BlockPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return BlockQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(BlockPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return BlockQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(BlockPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return BlockQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(BlockPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return BlockQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(BlockPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return BlockQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(BlockPeer::CREATED_AT); + } +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcAccess.php b/airtime_mvc/application/models/airtime/om/BaseCcAccess.php deleted file mode 100644 index 8f2de9dca..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcAccess.php +++ /dev/null @@ -1,1236 +0,0 @@ -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->getDbId() !== $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->getDbId()) { - $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 true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->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->getDbId()); - } - - $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/airtime_mvc/application/models/airtime/om/BaseCcAccessPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcAccessPeer.php deleted file mode 100644 index c14312b14..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcAccessPeer.php +++ /dev/null @@ -1,1008 +0,0 @@ - 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/airtime_mvc/application/models/airtime/om/BaseCcAccessQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcAccessQuery.php deleted file mode 100644 index 652550f18..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcAccessQuery.php +++ /dev/null @@ -1,477 +0,0 @@ -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->getDbId(), $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/airtime_mvc/application/models/airtime/om/BaseCcBackup.php b/airtime_mvc/application/models/airtime/om/BaseCcBackup.php deleted file mode 100644 index 41be024bb..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcBackup.php +++ /dev/null @@ -1,956 +0,0 @@ -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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - 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/airtime_mvc/application/models/airtime/om/BaseCcBackupPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcBackupPeer.php deleted file mode 100644 index 304acc302..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcBackupPeer.php +++ /dev/null @@ -1,750 +0,0 @@ - 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/airtime_mvc/application/models/airtime/om/BaseCcBackupQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcBackupQuery.php deleted file mode 100644 index 2e80333fb..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcBackupQuery.php +++ /dev/null @@ -1,292 +0,0 @@ -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/airtime_mvc/application/models/airtime/om/BaseCcBlock.php b/airtime_mvc/application/models/airtime/om/BaseCcBlock.php index f9c900c81..cb2410271 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcBlock.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcBlock.php @@ -1,1783 +1,2370 @@ name = ''; - $this->length = '00:00:00'; - $this->type = 'static'; - } - - /** - * Initializes internal state of BaseCcBlock 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 [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 [optionally formatted] temporal [utime] 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 getDbUtime($format = 'Y-m-d H:i:s') - { - if ($this->utime === null) { - return null; - } - - - - try { - $dt = new DateTime($this->utime); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->utime, 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_id] column value. - * - * @return int - */ - public function getDbCreatorId() - { - return $this->creator_id; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDbDescription() - { - return $this->description; - } - - /** - * Get the [length] column value. - * - * @return string - */ - public function getDbLength() - { - return $this->length; - } - - /** - * Get the [type] column value. - * - * @return string - */ - public function getDbType() - { - return $this->type; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcBlock 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[] = CcBlockPeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [name] column. - * - * @param string $v new value - * @return CcBlock 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[] = CcBlockPeer::NAME; - } - - return $this; - } // setDbName() - - /** - * 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 CcBlock 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[] = CcBlockPeer::MTIME; - } - } // if either are not null - - return $this; - } // setDbMtime() - - /** - * Sets the value of [utime] 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 CcBlock The current object (for fluent API support) - */ - public function setDbUtime($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->utime !== null || $dt !== null ) { - // (nested ifs are a little easier to read in this case) - - $currNorm = ($this->utime !== null && $tmpDt = new DateTime($this->utime)) ? $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->utime = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); - $this->modifiedColumns[] = CcBlockPeer::UTIME; - } - } // if either are not null - - return $this; - } // setDbUtime() - - /** - * Set the value of [creator_id] column. - * - * @param int $v new value - * @return CcBlock The current object (for fluent API support) - */ - public function setDbCreatorId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->creator_id !== $v) { - $this->creator_id = $v; - $this->modifiedColumns[] = CcBlockPeer::CREATOR_ID; - } - - if ($this->aCcSubjs !== null && $this->aCcSubjs->getDbId() !== $v) { - $this->aCcSubjs = null; - } - - return $this; - } // setDbCreatorId() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return CcBlock 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[] = CcBlockPeer::DESCRIPTION; - } - - return $this; - } // setDbDescription() - - /** - * Set the value of [length] column. - * - * @param string $v new value - * @return CcBlock The current object (for fluent API support) - */ - public function setDbLength($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->length !== $v || $this->isNew()) { - $this->length = $v; - $this->modifiedColumns[] = CcBlockPeer::LENGTH; - } - - return $this; - } // setDbLength() - - /** - * Set the value of [type] column. - * - * @param string $v new value - * @return CcBlock The current object (for fluent API support) - */ - public function setDbType($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->type !== $v || $this->isNew()) { - $this->type = $v; - $this->modifiedColumns[] = CcBlockPeer::TYPE; - } - - return $this; - } // setDbType() - - /** - * 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->length !== '00:00:00') { - return false; - } - - if ($this->type !== 'static') { - 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->mtime = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->utime = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->creator_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->description = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->length = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->type = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 8; // 8 = CcBlockPeer::NUM_COLUMNS - CcBlockPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcBlock 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->creator_id !== $this->aCcSubjs->getDbId()) { - $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(CcBlockPeer::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 = CcBlockPeer::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; - - $this->collCcBlockcontentss = null; - - $this->collCcBlockcriterias = 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(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcBlockQuery::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(CcBlockPeer::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); - CcBlockPeer::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[] = CcBlockPeer::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(CcBlockPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcBlockPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows += 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows += CcBlockPeer::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); - } - } - } - - if ($this->collCcBlockcontentss !== null) { - foreach ($this->collCcBlockcontentss as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->collCcBlockcriterias !== null) { - foreach ($this->collCcBlockcriterias 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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcSubjs !== null) { - if (!$this->aCcSubjs->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcSubjs->getValidationFailures()); - } - } - - - if (($retval = CcBlockPeer::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()); - } - } - } - - if ($this->collCcBlockcontentss !== null) { - foreach ($this->collCcBlockcontentss as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCcBlockcriterias !== null) { - foreach ($this->collCcBlockcriterias 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 = CcBlockPeer::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->getDbMtime(); - break; - case 3: - return $this->getDbUtime(); - break; - case 4: - return $this->getDbCreatorId(); - break; - case 5: - return $this->getDbDescription(); - break; - case 6: - return $this->getDbLength(); - break; - case 7: - return $this->getDbType(); - 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 = CcBlockPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbName(), - $keys[2] => $this->getDbMtime(), - $keys[3] => $this->getDbUtime(), - $keys[4] => $this->getDbCreatorId(), - $keys[5] => $this->getDbDescription(), - $keys[6] => $this->getDbLength(), - $keys[7] => $this->getDbType(), - ); - 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 = CcBlockPeer::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->setDbMtime($value); - break; - case 3: - $this->setDbUtime($value); - break; - case 4: - $this->setDbCreatorId($value); - break; - case 5: - $this->setDbDescription($value); - break; - case 6: - $this->setDbLength($value); - break; - case 7: - $this->setDbType($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 = CcBlockPeer::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->setDbMtime($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbUtime($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbCreatorId($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbDescription($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDbLength($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setDbType($arr[$keys[7]]); - } - - /** - * 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(CcBlockPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcBlockPeer::ID)) $criteria->add(CcBlockPeer::ID, $this->id); - if ($this->isColumnModified(CcBlockPeer::NAME)) $criteria->add(CcBlockPeer::NAME, $this->name); - if ($this->isColumnModified(CcBlockPeer::MTIME)) $criteria->add(CcBlockPeer::MTIME, $this->mtime); - if ($this->isColumnModified(CcBlockPeer::UTIME)) $criteria->add(CcBlockPeer::UTIME, $this->utime); - if ($this->isColumnModified(CcBlockPeer::CREATOR_ID)) $criteria->add(CcBlockPeer::CREATOR_ID, $this->creator_id); - if ($this->isColumnModified(CcBlockPeer::DESCRIPTION)) $criteria->add(CcBlockPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(CcBlockPeer::LENGTH)) $criteria->add(CcBlockPeer::LENGTH, $this->length); - if ($this->isColumnModified(CcBlockPeer::TYPE)) $criteria->add(CcBlockPeer::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(CcBlockPeer::DATABASE_NAME); - $criteria->add(CcBlockPeer::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 CcBlock (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->setDbMtime($this->mtime); - $copyObj->setDbUtime($this->utime); - $copyObj->setDbCreatorId($this->creator_id); - $copyObj->setDbDescription($this->description); - $copyObj->setDbLength($this->length); - $copyObj->setDbType($this->type); - - if ($deepCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // 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)); - } - } - - foreach ($this->getCcBlockcontentss() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcBlockcontents($relObj->copy($deepCopy)); - } - } - - foreach ($this->getCcBlockcriterias() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcBlockcriteria($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 CcBlock 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 CcBlockPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcBlockPeer(); - } - return self::$peer; - } - - /** - * Declares an association between this object and a CcSubjs object. - * - * @param CcSubjs $v - * @return CcBlock The current object (for fluent API support) - * @throws PropelException - */ - public function setCcSubjs(CcSubjs $v = null) - { - if ($v === null) { - $this->setDbCreatorId(NULL); - } else { - $this->setDbCreatorId($v->getDbId()); - } - - $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->addCcBlock($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->creator_id !== null)) { - $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->creator_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->aCcSubjs->addCcBlocks($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 CcBlock 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) - ->filterByCcBlock($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 - ->filterByCcBlock($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->setCcBlock($this); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcBlock is new, it will return - * an empty collection; or if this CcBlock 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 CcBlock. - * - * @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); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcBlock is new, it will return - * an empty collection; or if this CcBlock 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 CcBlock. - * - * @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 out the collCcBlockcontentss 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 addCcBlockcontentss() - */ - public function clearCcBlockcontentss() - { - $this->collCcBlockcontentss = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcBlockcontentss collection. - * - * By default this just sets the collCcBlockcontentss collection to an empty array (like clearcollCcBlockcontentss()); - * 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 initCcBlockcontentss() - { - $this->collCcBlockcontentss = new PropelObjectCollection(); - $this->collCcBlockcontentss->setModel('CcBlockcontents'); - } - - /** - * Gets an array of CcBlockcontents 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 CcBlock 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 CcBlockcontents[] List of CcBlockcontents objects - * @throws PropelException - */ - public function getCcBlockcontentss($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcBlockcontentss || null !== $criteria) { - if ($this->isNew() && null === $this->collCcBlockcontentss) { - // return empty collection - $this->initCcBlockcontentss(); - } else { - $collCcBlockcontentss = CcBlockcontentsQuery::create(null, $criteria) - ->filterByCcBlock($this) - ->find($con); - if (null !== $criteria) { - return $collCcBlockcontentss; - } - $this->collCcBlockcontentss = $collCcBlockcontentss; - } - } - return $this->collCcBlockcontentss; - } - - /** - * Returns the number of related CcBlockcontents objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcBlockcontents objects. - * @throws PropelException - */ - public function countCcBlockcontentss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcBlockcontentss || null !== $criteria) { - if ($this->isNew() && null === $this->collCcBlockcontentss) { - return 0; - } else { - $query = CcBlockcontentsQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcBlock($this) - ->count($con); - } - } else { - return count($this->collCcBlockcontentss); - } - } - - /** - * Method called to associate a CcBlockcontents object to this object - * through the CcBlockcontents foreign key attribute. - * - * @param CcBlockcontents $l CcBlockcontents - * @return void - * @throws PropelException - */ - public function addCcBlockcontents(CcBlockcontents $l) - { - if ($this->collCcBlockcontentss === null) { - $this->initCcBlockcontentss(); - } - if (!$this->collCcBlockcontentss->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcBlockcontentss[]= $l; - $l->setCcBlock($this); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcBlock is new, it will return - * an empty collection; or if this CcBlock has previously - * been saved, it will retrieve related CcBlockcontentss 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 CcBlock. - * - * @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 CcBlockcontents[] List of CcBlockcontents objects - */ - public function getCcBlockcontentssJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcBlockcontentsQuery::create(null, $criteria); - $query->joinWith('CcFiles', $join_behavior); - - return $this->getCcBlockcontentss($query, $con); - } - - /** - * Clears out the collCcBlockcriterias 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 addCcBlockcriterias() - */ - public function clearCcBlockcriterias() - { - $this->collCcBlockcriterias = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcBlockcriterias collection. - * - * By default this just sets the collCcBlockcriterias collection to an empty array (like clearcollCcBlockcriterias()); - * 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 initCcBlockcriterias() - { - $this->collCcBlockcriterias = new PropelObjectCollection(); - $this->collCcBlockcriterias->setModel('CcBlockcriteria'); - } - - /** - * Gets an array of CcBlockcriteria 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 CcBlock 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 CcBlockcriteria[] List of CcBlockcriteria objects - * @throws PropelException - */ - public function getCcBlockcriterias($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcBlockcriterias || null !== $criteria) { - if ($this->isNew() && null === $this->collCcBlockcriterias) { - // return empty collection - $this->initCcBlockcriterias(); - } else { - $collCcBlockcriterias = CcBlockcriteriaQuery::create(null, $criteria) - ->filterByCcBlock($this) - ->find($con); - if (null !== $criteria) { - return $collCcBlockcriterias; - } - $this->collCcBlockcriterias = $collCcBlockcriterias; - } - } - return $this->collCcBlockcriterias; - } - - /** - * Returns the number of related CcBlockcriteria objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcBlockcriteria objects. - * @throws PropelException - */ - public function countCcBlockcriterias(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcBlockcriterias || null !== $criteria) { - if ($this->isNew() && null === $this->collCcBlockcriterias) { - return 0; - } else { - $query = CcBlockcriteriaQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcBlock($this) - ->count($con); - } - } else { - return count($this->collCcBlockcriterias); - } - } - - /** - * Method called to associate a CcBlockcriteria object to this object - * through the CcBlockcriteria foreign key attribute. - * - * @param CcBlockcriteria $l CcBlockcriteria - * @return void - * @throws PropelException - */ - public function addCcBlockcriteria(CcBlockcriteria $l) - { - if ($this->collCcBlockcriterias === null) { - $this->initCcBlockcriterias(); - } - if (!$this->collCcBlockcriterias->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcBlockcriterias[]= $l; - $l->setCcBlock($this); - } - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->name = null; - $this->mtime = null; - $this->utime = null; - $this->creator_id = null; - $this->description = null; - $this->length = null; - $this->type = 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 ($this->collCcBlockcontentss) { - foreach ((array) $this->collCcBlockcontentss as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCcBlockcriterias) { - foreach ((array) $this->collCcBlockcriterias as $o) { - $o->clearAllReferences($deep); - } - } - } // if ($deep) - - $this->collCcPlaylistcontentss = null; - $this->collCcBlockcontentss = null; - $this->collCcBlockcriterias = null; - $this->aCcSubjs = null; - } - - // aggregate_column behavior - - /** - * Computes the value of the aggregate column length - * - * @param PropelPDO $con A connection object - * - * @return mixed The scalar result from the aggregate query - */ - public function computeDbLength(PropelPDO $con) - { - $stmt = $con->prepare('SELECT SUM(cliplength) FROM "cc_blockcontents" WHERE cc_blockcontents.BLOCK_ID = :p1'); - $stmt->bindValue(':p1', $this->getDbId()); - $stmt->execute(); - return $stmt->fetchColumn(); - } - - /** - * Updates the aggregate column length - * - * @param PropelPDO $con A connection object - */ - public function updateDbLength(PropelPDO $con) - { - $this->setDbLength($this->computeDbLength($con)); - $this->save($con); - } - - /** - * 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); - } - -} // BaseCcBlock + /** + * Peer class name + */ + const PEER = 'Airtime\\CcBlockPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcBlockPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the name field. + * Note: this column has a database default value of: '' + * @var string + */ + protected $name; + + /** + * The value for the mtime field. + * @var string + */ + protected $mtime; + + /** + * The value for the utime field. + * @var string + */ + protected $utime; + + /** + * The value for the creator_id field. + * @var int + */ + protected $creator_id; + + /** + * The value for the description field. + * @var string + */ + protected $description; + + /** + * The value for the length field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $length; + + /** + * The value for the type field. + * Note: this column has a database default value of: 'static' + * @var string + */ + protected $type; + + /** + * @var CcSubjs + */ + protected $aCcSubjs; + + /** + * @var PropelObjectCollection|CcPlaylistcontents[] Collection to store aggregation of CcPlaylistcontents objects. + */ + protected $collCcPlaylistcontentss; + protected $collCcPlaylistcontentssPartial; + + /** + * @var PropelObjectCollection|CcBlockcontents[] Collection to store aggregation of CcBlockcontents objects. + */ + protected $collCcBlockcontentss; + protected $collCcBlockcontentssPartial; + + /** + * @var PropelObjectCollection|CcBlockcriteria[] Collection to store aggregation of CcBlockcriteria objects. + */ + protected $collCcBlockcriterias; + protected $collCcBlockcriteriasPartial; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccPlaylistcontentssScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccBlockcontentssScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccBlockcriteriasScheduledForDeletion = null; + + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->name = ''; + $this->length = '00:00:00'; + $this->type = 'static'; + } + + /** + * Initializes internal state of BaseCcBlock 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 [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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [optionally formatted] temporal [utime] 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 getDbUtime($format = 'Y-m-d H:i:s') + { + if ($this->utime === null) { + return null; + } + + + try { + $dt = new DateTime($this->utime); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->utime, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [creator_id] column value. + * + * @return int + */ + public function getDbCreatorId() + { + + return $this->creator_id; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDbDescription() + { + + return $this->description; + } + + /** + * Get the [length] column value. + * + * @return string + */ + public function getDbLength() + { + + return $this->length; + } + + /** + * Get the [type] column value. + * + * @return string + */ + public function getDbType() + { + + return $this->type; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcBlock The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcBlockPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return CcBlock The current object (for fluent API support) + */ + public function setDbName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = CcBlockPeer::NAME; + } + + + return $this; + } // setDbName() + + /** + * 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 strings are treated as null. + * @return CcBlock The current object (for fluent API support) + */ + public function setDbMtime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->mtime !== null || $dt !== null) { + $currentDateAsString = ($this->mtime !== null && $tmpDt = new DateTime($this->mtime)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->mtime = $newDateAsString; + $this->modifiedColumns[] = CcBlockPeer::MTIME; + } + } // if either are not null + + + return $this; + } // setDbMtime() + + /** + * Sets the value of [utime] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return CcBlock The current object (for fluent API support) + */ + public function setDbUtime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->utime !== null || $dt !== null) { + $currentDateAsString = ($this->utime !== null && $tmpDt = new DateTime($this->utime)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->utime = $newDateAsString; + $this->modifiedColumns[] = CcBlockPeer::UTIME; + } + } // if either are not null + + + return $this; + } // setDbUtime() + + /** + * Set the value of [creator_id] column. + * + * @param int $v new value + * @return CcBlock The current object (for fluent API support) + */ + public function setDbCreatorId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->creator_id !== $v) { + $this->creator_id = $v; + $this->modifiedColumns[] = CcBlockPeer::CREATOR_ID; + } + + if ($this->aCcSubjs !== null && $this->aCcSubjs->getDbId() !== $v) { + $this->aCcSubjs = null; + } + + + return $this; + } // setDbCreatorId() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return CcBlock The current object (for fluent API support) + */ + public function setDbDescription($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = CcBlockPeer::DESCRIPTION; + } + + + return $this; + } // setDbDescription() + + /** + * Set the value of [length] column. + * + * @param string $v new value + * @return CcBlock The current object (for fluent API support) + */ + public function setDbLength($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->length !== $v) { + $this->length = $v; + $this->modifiedColumns[] = CcBlockPeer::LENGTH; + } + + + return $this; + } // setDbLength() + + /** + * Set the value of [type] column. + * + * @param string $v new value + * @return CcBlock The current object (for fluent API support) + */ + public function setDbType($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->type !== $v) { + $this->type = $v; + $this->modifiedColumns[] = CcBlockPeer::TYPE; + } + + + return $this; + } // setDbType() + + /** + * 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->length !== '00:00:00') { + return false; + } + + if ($this->type !== 'static') { + 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 resultset 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->mtime = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->utime = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->creator_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; + $this->description = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->length = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->type = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 8; // 8 = CcBlockPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcBlock 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->creator_id !== $this->aCcSubjs->getDbId()) { + $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(CcBlockPeer::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 = CcBlockPeer::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; + + $this->collCcBlockcontentss = null; + + $this->collCcBlockcriterias = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcBlockQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcBlockPeer::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); + // aggregate_column behavior + if (null !== $this->collCcBlockcontentss) { + $this->setDbLength($this->computeDbLength($con)); + if ($this->isModified()) { + $this->save($con); + } + } + + CcBlockPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding 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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->ccPlaylistcontentssScheduledForDeletion !== null) { + if (!$this->ccPlaylistcontentssScheduledForDeletion->isEmpty()) { + CcPlaylistcontentsQuery::create() + ->filterByPrimaryKeys($this->ccPlaylistcontentssScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccPlaylistcontentssScheduledForDeletion = null; + } + } + + if ($this->collCcPlaylistcontentss !== null) { + foreach ($this->collCcPlaylistcontentss as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ccBlockcontentssScheduledForDeletion !== null) { + if (!$this->ccBlockcontentssScheduledForDeletion->isEmpty()) { + CcBlockcontentsQuery::create() + ->filterByPrimaryKeys($this->ccBlockcontentssScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccBlockcontentssScheduledForDeletion = null; + } + } + + if ($this->collCcBlockcontentss !== null) { + foreach ($this->collCcBlockcontentss as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ccBlockcriteriasScheduledForDeletion !== null) { + if (!$this->ccBlockcriteriasScheduledForDeletion->isEmpty()) { + CcBlockcriteriaQuery::create() + ->filterByPrimaryKeys($this->ccBlockcriteriasScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccBlockcriteriasScheduledForDeletion = null; + } + } + + if ($this->collCcBlockcriterias !== null) { + foreach ($this->collCcBlockcriterias as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcBlockPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcBlockPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_block_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcBlockPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcBlockPeer::NAME)) { + $modifiedColumns[':p' . $index++] = '"name"'; + } + if ($this->isColumnModified(CcBlockPeer::MTIME)) { + $modifiedColumns[':p' . $index++] = '"mtime"'; + } + if ($this->isColumnModified(CcBlockPeer::UTIME)) { + $modifiedColumns[':p' . $index++] = '"utime"'; + } + if ($this->isColumnModified(CcBlockPeer::CREATOR_ID)) { + $modifiedColumns[':p' . $index++] = '"creator_id"'; + } + if ($this->isColumnModified(CcBlockPeer::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = '"description"'; + } + if ($this->isColumnModified(CcBlockPeer::LENGTH)) { + $modifiedColumns[':p' . $index++] = '"length"'; + } + if ($this->isColumnModified(CcBlockPeer::TYPE)) { + $modifiedColumns[':p' . $index++] = '"type"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_block" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"name"': + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); + break; + case '"mtime"': + $stmt->bindValue($identifier, $this->mtime, PDO::PARAM_STR); + break; + case '"utime"': + $stmt->bindValue($identifier, $this->utime, PDO::PARAM_STR); + break; + case '"creator_id"': + $stmt->bindValue($identifier, $this->creator_id, PDO::PARAM_INT); + break; + case '"description"': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case '"length"': + $stmt->bindValue($identifier, $this->length, PDO::PARAM_STR); + break; + case '"type"': + $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding 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 = CcBlockPeer::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()); + } + } + } + + if ($this->collCcBlockcontentss !== null) { + foreach ($this->collCcBlockcontentss as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collCcBlockcriterias !== null) { + foreach ($this->collCcBlockcriterias 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcBlockPeer::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->getDbMtime(); + break; + case 3: + return $this->getDbUtime(); + break; + case 4: + return $this->getDbCreatorId(); + break; + case 5: + return $this->getDbDescription(); + break; + case 6: + return $this->getDbLength(); + break; + case 7: + return $this->getDbType(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcBlock'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcBlock'][$this->getPrimaryKey()] = true; + $keys = CcBlockPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbName(), + $keys[2] => $this->getDbMtime(), + $keys[3] => $this->getDbUtime(), + $keys[4] => $this->getDbCreatorId(), + $keys[5] => $this->getDbDescription(), + $keys[6] => $this->getDbLength(), + $keys[7] => $this->getDbType(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcSubjs) { + $result['CcSubjs'] = $this->aCcSubjs->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collCcPlaylistcontentss) { + $result['CcPlaylistcontentss'] = $this->collCcPlaylistcontentss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCcBlockcontentss) { + $result['CcBlockcontentss'] = $this->collCcBlockcontentss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCcBlockcriterias) { + $result['CcBlockcriterias'] = $this->collCcBlockcriterias->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcBlockPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbMtime($value); + break; + case 3: + $this->setDbUtime($value); + break; + case 4: + $this->setDbCreatorId($value); + break; + case 5: + $this->setDbDescription($value); + break; + case 6: + $this->setDbLength($value); + break; + case 7: + $this->setDbType($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcBlockPeer::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->setDbMtime($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbUtime($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbCreatorId($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbDescription($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbLength($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbType($arr[$keys[7]]); + } + + /** + * 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(CcBlockPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcBlockPeer::ID)) $criteria->add(CcBlockPeer::ID, $this->id); + if ($this->isColumnModified(CcBlockPeer::NAME)) $criteria->add(CcBlockPeer::NAME, $this->name); + if ($this->isColumnModified(CcBlockPeer::MTIME)) $criteria->add(CcBlockPeer::MTIME, $this->mtime); + if ($this->isColumnModified(CcBlockPeer::UTIME)) $criteria->add(CcBlockPeer::UTIME, $this->utime); + if ($this->isColumnModified(CcBlockPeer::CREATOR_ID)) $criteria->add(CcBlockPeer::CREATOR_ID, $this->creator_id); + if ($this->isColumnModified(CcBlockPeer::DESCRIPTION)) $criteria->add(CcBlockPeer::DESCRIPTION, $this->description); + if ($this->isColumnModified(CcBlockPeer::LENGTH)) $criteria->add(CcBlockPeer::LENGTH, $this->length); + if ($this->isColumnModified(CcBlockPeer::TYPE)) $criteria->add(CcBlockPeer::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(CcBlockPeer::DATABASE_NAME); + $criteria->add(CcBlockPeer::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 CcBlock (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbName($this->getDbName()); + $copyObj->setDbMtime($this->getDbMtime()); + $copyObj->setDbUtime($this->getDbUtime()); + $copyObj->setDbCreatorId($this->getDbCreatorId()); + $copyObj->setDbDescription($this->getDbDescription()); + $copyObj->setDbLength($this->getDbLength()); + $copyObj->setDbType($this->getDbType()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + 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)); + } + } + + foreach ($this->getCcBlockcontentss() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcBlockcontents($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCcBlockcriterias() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcBlockcriteria($relObj->copy($deepCopy)); + } + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcBlock 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 CcBlockPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcBlockPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a CcSubjs object. + * + * @param CcSubjs $v + * @return CcBlock The current object (for fluent API support) + * @throws PropelException + */ + public function setCcSubjs(CcSubjs $v = null) + { + if ($v === null) { + $this->setDbCreatorId(NULL); + } else { + $this->setDbCreatorId($v->getDbId()); + } + + $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->addCcBlock($this); + } + + + return $this; + } + + + /** + * Get the associated CcSubjs object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getCcSubjs(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcSubjs === null && ($this->creator_id !== null) && $doQuery) { + $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->creator_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->aCcSubjs->addCcBlocks($this); + */ + } + + return $this->aCcSubjs; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('CcPlaylistcontents' == $relationName) { + $this->initCcPlaylistcontentss(); + } + if ('CcBlockcontents' == $relationName) { + $this->initCcBlockcontentss(); + } + if ('CcBlockcriteria' == $relationName) { + $this->initCcBlockcriterias(); + } + } + + /** + * 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 CcBlock The current object (for fluent API support) + * @see addCcPlaylistcontentss() + */ + public function clearCcPlaylistcontentss() + { + $this->collCcPlaylistcontentss = null; // important to set this to null since that means it is uninitialized + $this->collCcPlaylistcontentssPartial = null; + + return $this; + } + + /** + * reset is the collCcPlaylistcontentss collection loaded partially + * + * @return void + */ + public function resetPartialCcPlaylistcontentss($v = true) + { + $this->collCcPlaylistcontentssPartial = $v; + } + + /** + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcPlaylistcontentss($overrideExisting = true) + { + if (null !== $this->collCcPlaylistcontentss && !$overrideExisting) { + return; + } + $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 CcBlock 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 PropelObjectCollection|CcPlaylistcontents[] List of CcPlaylistcontents objects + * @throws PropelException + */ + public function getCcPlaylistcontentss($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcPlaylistcontentssPartial && !$this->isNew(); + if (null === $this->collCcPlaylistcontentss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPlaylistcontentss) { + // return empty collection + $this->initCcPlaylistcontentss(); + } else { + $collCcPlaylistcontentss = CcPlaylistcontentsQuery::create(null, $criteria) + ->filterByCcBlock($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcPlaylistcontentssPartial && count($collCcPlaylistcontentss)) { + $this->initCcPlaylistcontentss(false); + + foreach ($collCcPlaylistcontentss as $obj) { + if (false == $this->collCcPlaylistcontentss->contains($obj)) { + $this->collCcPlaylistcontentss->append($obj); + } + } + + $this->collCcPlaylistcontentssPartial = true; + } + + $collCcPlaylistcontentss->getInternalIterator()->rewind(); + + return $collCcPlaylistcontentss; + } + + if ($partial && $this->collCcPlaylistcontentss) { + foreach ($this->collCcPlaylistcontentss as $obj) { + if ($obj->isNew()) { + $collCcPlaylistcontentss[] = $obj; + } + } + } + + $this->collCcPlaylistcontentss = $collCcPlaylistcontentss; + $this->collCcPlaylistcontentssPartial = false; + } + } + + return $this->collCcPlaylistcontentss; + } + + /** + * Sets a collection of CcPlaylistcontents objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccPlaylistcontentss A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcBlock The current object (for fluent API support) + */ + public function setCcPlaylistcontentss(PropelCollection $ccPlaylistcontentss, PropelPDO $con = null) + { + $ccPlaylistcontentssToDelete = $this->getCcPlaylistcontentss(new Criteria(), $con)->diff($ccPlaylistcontentss); + + + $this->ccPlaylistcontentssScheduledForDeletion = $ccPlaylistcontentssToDelete; + + foreach ($ccPlaylistcontentssToDelete as $ccPlaylistcontentsRemoved) { + $ccPlaylistcontentsRemoved->setCcBlock(null); + } + + $this->collCcPlaylistcontentss = null; + foreach ($ccPlaylistcontentss as $ccPlaylistcontents) { + $this->addCcPlaylistcontents($ccPlaylistcontents); + } + + $this->collCcPlaylistcontentss = $ccPlaylistcontentss; + $this->collCcPlaylistcontentssPartial = false; + + return $this; + } + + /** + * 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) + { + $partial = $this->collCcPlaylistcontentssPartial && !$this->isNew(); + if (null === $this->collCcPlaylistcontentss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPlaylistcontentss) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcPlaylistcontentss()); + } + $query = CcPlaylistcontentsQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcBlock($this) + ->count($con); + } + + 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 CcBlock The current object (for fluent API support) + */ + public function addCcPlaylistcontents(CcPlaylistcontents $l) + { + if ($this->collCcPlaylistcontentss === null) { + $this->initCcPlaylistcontentss(); + $this->collCcPlaylistcontentssPartial = true; + } + + if (!in_array($l, $this->collCcPlaylistcontentss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcPlaylistcontents($l); + + if ($this->ccPlaylistcontentssScheduledForDeletion and $this->ccPlaylistcontentssScheduledForDeletion->contains($l)) { + $this->ccPlaylistcontentssScheduledForDeletion->remove($this->ccPlaylistcontentssScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcPlaylistcontents $ccPlaylistcontents The ccPlaylistcontents object to add. + */ + protected function doAddCcPlaylistcontents($ccPlaylistcontents) + { + $this->collCcPlaylistcontentss[]= $ccPlaylistcontents; + $ccPlaylistcontents->setCcBlock($this); + } + + /** + * @param CcPlaylistcontents $ccPlaylistcontents The ccPlaylistcontents object to remove. + * @return CcBlock The current object (for fluent API support) + */ + public function removeCcPlaylistcontents($ccPlaylistcontents) + { + if ($this->getCcPlaylistcontentss()->contains($ccPlaylistcontents)) { + $this->collCcPlaylistcontentss->remove($this->collCcPlaylistcontentss->search($ccPlaylistcontents)); + if (null === $this->ccPlaylistcontentssScheduledForDeletion) { + $this->ccPlaylistcontentssScheduledForDeletion = clone $this->collCcPlaylistcontentss; + $this->ccPlaylistcontentssScheduledForDeletion->clear(); + } + $this->ccPlaylistcontentssScheduledForDeletion[]= $ccPlaylistcontents; + $ccPlaylistcontents->setCcBlock(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcBlock is new, it will return + * an empty collection; or if this CcBlock 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 CcBlock. + * + * @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 PropelObjectCollection|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); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcBlock is new, it will return + * an empty collection; or if this CcBlock 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 CcBlock. + * + * @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 PropelObjectCollection|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 out the collCcBlockcontentss 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 CcBlock The current object (for fluent API support) + * @see addCcBlockcontentss() + */ + public function clearCcBlockcontentss() + { + $this->collCcBlockcontentss = null; // important to set this to null since that means it is uninitialized + $this->collCcBlockcontentssPartial = null; + + return $this; + } + + /** + * reset is the collCcBlockcontentss collection loaded partially + * + * @return void + */ + public function resetPartialCcBlockcontentss($v = true) + { + $this->collCcBlockcontentssPartial = $v; + } + + /** + * Initializes the collCcBlockcontentss collection. + * + * By default this just sets the collCcBlockcontentss collection to an empty array (like clearcollCcBlockcontentss()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcBlockcontentss($overrideExisting = true) + { + if (null !== $this->collCcBlockcontentss && !$overrideExisting) { + return; + } + $this->collCcBlockcontentss = new PropelObjectCollection(); + $this->collCcBlockcontentss->setModel('CcBlockcontents'); + } + + /** + * Gets an array of CcBlockcontents 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 CcBlock 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 PropelObjectCollection|CcBlockcontents[] List of CcBlockcontents objects + * @throws PropelException + */ + public function getCcBlockcontentss($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcBlockcontentssPartial && !$this->isNew(); + if (null === $this->collCcBlockcontentss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcBlockcontentss) { + // return empty collection + $this->initCcBlockcontentss(); + } else { + $collCcBlockcontentss = CcBlockcontentsQuery::create(null, $criteria) + ->filterByCcBlock($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcBlockcontentssPartial && count($collCcBlockcontentss)) { + $this->initCcBlockcontentss(false); + + foreach ($collCcBlockcontentss as $obj) { + if (false == $this->collCcBlockcontentss->contains($obj)) { + $this->collCcBlockcontentss->append($obj); + } + } + + $this->collCcBlockcontentssPartial = true; + } + + $collCcBlockcontentss->getInternalIterator()->rewind(); + + return $collCcBlockcontentss; + } + + if ($partial && $this->collCcBlockcontentss) { + foreach ($this->collCcBlockcontentss as $obj) { + if ($obj->isNew()) { + $collCcBlockcontentss[] = $obj; + } + } + } + + $this->collCcBlockcontentss = $collCcBlockcontentss; + $this->collCcBlockcontentssPartial = false; + } + } + + return $this->collCcBlockcontentss; + } + + /** + * Sets a collection of CcBlockcontents objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccBlockcontentss A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcBlock The current object (for fluent API support) + */ + public function setCcBlockcontentss(PropelCollection $ccBlockcontentss, PropelPDO $con = null) + { + $ccBlockcontentssToDelete = $this->getCcBlockcontentss(new Criteria(), $con)->diff($ccBlockcontentss); + + + $this->ccBlockcontentssScheduledForDeletion = $ccBlockcontentssToDelete; + + foreach ($ccBlockcontentssToDelete as $ccBlockcontentsRemoved) { + $ccBlockcontentsRemoved->setCcBlock(null); + } + + $this->collCcBlockcontentss = null; + foreach ($ccBlockcontentss as $ccBlockcontents) { + $this->addCcBlockcontents($ccBlockcontents); + } + + $this->collCcBlockcontentss = $ccBlockcontentss; + $this->collCcBlockcontentssPartial = false; + + return $this; + } + + /** + * Returns the number of related CcBlockcontents objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcBlockcontents objects. + * @throws PropelException + */ + public function countCcBlockcontentss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcBlockcontentssPartial && !$this->isNew(); + if (null === $this->collCcBlockcontentss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcBlockcontentss) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcBlockcontentss()); + } + $query = CcBlockcontentsQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcBlock($this) + ->count($con); + } + + return count($this->collCcBlockcontentss); + } + + /** + * Method called to associate a CcBlockcontents object to this object + * through the CcBlockcontents foreign key attribute. + * + * @param CcBlockcontents $l CcBlockcontents + * @return CcBlock The current object (for fluent API support) + */ + public function addCcBlockcontents(CcBlockcontents $l) + { + if ($this->collCcBlockcontentss === null) { + $this->initCcBlockcontentss(); + $this->collCcBlockcontentssPartial = true; + } + + if (!in_array($l, $this->collCcBlockcontentss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcBlockcontents($l); + + if ($this->ccBlockcontentssScheduledForDeletion and $this->ccBlockcontentssScheduledForDeletion->contains($l)) { + $this->ccBlockcontentssScheduledForDeletion->remove($this->ccBlockcontentssScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcBlockcontents $ccBlockcontents The ccBlockcontents object to add. + */ + protected function doAddCcBlockcontents($ccBlockcontents) + { + $this->collCcBlockcontentss[]= $ccBlockcontents; + $ccBlockcontents->setCcBlock($this); + } + + /** + * @param CcBlockcontents $ccBlockcontents The ccBlockcontents object to remove. + * @return CcBlock The current object (for fluent API support) + */ + public function removeCcBlockcontents($ccBlockcontents) + { + if ($this->getCcBlockcontentss()->contains($ccBlockcontents)) { + $this->collCcBlockcontentss->remove($this->collCcBlockcontentss->search($ccBlockcontents)); + if (null === $this->ccBlockcontentssScheduledForDeletion) { + $this->ccBlockcontentssScheduledForDeletion = clone $this->collCcBlockcontentss; + $this->ccBlockcontentssScheduledForDeletion->clear(); + } + $this->ccBlockcontentssScheduledForDeletion[]= $ccBlockcontents; + $ccBlockcontents->setCcBlock(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcBlock is new, it will return + * an empty collection; or if this CcBlock has previously + * been saved, it will retrieve related CcBlockcontentss 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 CcBlock. + * + * @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 PropelObjectCollection|CcBlockcontents[] List of CcBlockcontents objects + */ + public function getCcBlockcontentssJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcBlockcontentsQuery::create(null, $criteria); + $query->joinWith('CcFiles', $join_behavior); + + return $this->getCcBlockcontentss($query, $con); + } + + /** + * Clears out the collCcBlockcriterias 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 CcBlock The current object (for fluent API support) + * @see addCcBlockcriterias() + */ + public function clearCcBlockcriterias() + { + $this->collCcBlockcriterias = null; // important to set this to null since that means it is uninitialized + $this->collCcBlockcriteriasPartial = null; + + return $this; + } + + /** + * reset is the collCcBlockcriterias collection loaded partially + * + * @return void + */ + public function resetPartialCcBlockcriterias($v = true) + { + $this->collCcBlockcriteriasPartial = $v; + } + + /** + * Initializes the collCcBlockcriterias collection. + * + * By default this just sets the collCcBlockcriterias collection to an empty array (like clearcollCcBlockcriterias()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcBlockcriterias($overrideExisting = true) + { + if (null !== $this->collCcBlockcriterias && !$overrideExisting) { + return; + } + $this->collCcBlockcriterias = new PropelObjectCollection(); + $this->collCcBlockcriterias->setModel('CcBlockcriteria'); + } + + /** + * Gets an array of CcBlockcriteria 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 CcBlock 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 PropelObjectCollection|CcBlockcriteria[] List of CcBlockcriteria objects + * @throws PropelException + */ + public function getCcBlockcriterias($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcBlockcriteriasPartial && !$this->isNew(); + if (null === $this->collCcBlockcriterias || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcBlockcriterias) { + // return empty collection + $this->initCcBlockcriterias(); + } else { + $collCcBlockcriterias = CcBlockcriteriaQuery::create(null, $criteria) + ->filterByCcBlock($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcBlockcriteriasPartial && count($collCcBlockcriterias)) { + $this->initCcBlockcriterias(false); + + foreach ($collCcBlockcriterias as $obj) { + if (false == $this->collCcBlockcriterias->contains($obj)) { + $this->collCcBlockcriterias->append($obj); + } + } + + $this->collCcBlockcriteriasPartial = true; + } + + $collCcBlockcriterias->getInternalIterator()->rewind(); + + return $collCcBlockcriterias; + } + + if ($partial && $this->collCcBlockcriterias) { + foreach ($this->collCcBlockcriterias as $obj) { + if ($obj->isNew()) { + $collCcBlockcriterias[] = $obj; + } + } + } + + $this->collCcBlockcriterias = $collCcBlockcriterias; + $this->collCcBlockcriteriasPartial = false; + } + } + + return $this->collCcBlockcriterias; + } + + /** + * Sets a collection of CcBlockcriteria objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccBlockcriterias A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcBlock The current object (for fluent API support) + */ + public function setCcBlockcriterias(PropelCollection $ccBlockcriterias, PropelPDO $con = null) + { + $ccBlockcriteriasToDelete = $this->getCcBlockcriterias(new Criteria(), $con)->diff($ccBlockcriterias); + + + $this->ccBlockcriteriasScheduledForDeletion = $ccBlockcriteriasToDelete; + + foreach ($ccBlockcriteriasToDelete as $ccBlockcriteriaRemoved) { + $ccBlockcriteriaRemoved->setCcBlock(null); + } + + $this->collCcBlockcriterias = null; + foreach ($ccBlockcriterias as $ccBlockcriteria) { + $this->addCcBlockcriteria($ccBlockcriteria); + } + + $this->collCcBlockcriterias = $ccBlockcriterias; + $this->collCcBlockcriteriasPartial = false; + + return $this; + } + + /** + * Returns the number of related CcBlockcriteria objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcBlockcriteria objects. + * @throws PropelException + */ + public function countCcBlockcriterias(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcBlockcriteriasPartial && !$this->isNew(); + if (null === $this->collCcBlockcriterias || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcBlockcriterias) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcBlockcriterias()); + } + $query = CcBlockcriteriaQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcBlock($this) + ->count($con); + } + + return count($this->collCcBlockcriterias); + } + + /** + * Method called to associate a CcBlockcriteria object to this object + * through the CcBlockcriteria foreign key attribute. + * + * @param CcBlockcriteria $l CcBlockcriteria + * @return CcBlock The current object (for fluent API support) + */ + public function addCcBlockcriteria(CcBlockcriteria $l) + { + if ($this->collCcBlockcriterias === null) { + $this->initCcBlockcriterias(); + $this->collCcBlockcriteriasPartial = true; + } + + if (!in_array($l, $this->collCcBlockcriterias->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcBlockcriteria($l); + + if ($this->ccBlockcriteriasScheduledForDeletion and $this->ccBlockcriteriasScheduledForDeletion->contains($l)) { + $this->ccBlockcriteriasScheduledForDeletion->remove($this->ccBlockcriteriasScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcBlockcriteria $ccBlockcriteria The ccBlockcriteria object to add. + */ + protected function doAddCcBlockcriteria($ccBlockcriteria) + { + $this->collCcBlockcriterias[]= $ccBlockcriteria; + $ccBlockcriteria->setCcBlock($this); + } + + /** + * @param CcBlockcriteria $ccBlockcriteria The ccBlockcriteria object to remove. + * @return CcBlock The current object (for fluent API support) + */ + public function removeCcBlockcriteria($ccBlockcriteria) + { + if ($this->getCcBlockcriterias()->contains($ccBlockcriteria)) { + $this->collCcBlockcriterias->remove($this->collCcBlockcriterias->search($ccBlockcriteria)); + if (null === $this->ccBlockcriteriasScheduledForDeletion) { + $this->ccBlockcriteriasScheduledForDeletion = clone $this->collCcBlockcriterias; + $this->ccBlockcriteriasScheduledForDeletion->clear(); + } + $this->ccBlockcriteriasScheduledForDeletion[]= clone $ccBlockcriteria; + $ccBlockcriteria->setCcBlock(null); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->name = null; + $this->mtime = null; + $this->utime = null; + $this->creator_id = null; + $this->description = null; + $this->length = null; + $this->type = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->collCcPlaylistcontentss) { + foreach ($this->collCcPlaylistcontentss as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcBlockcontentss) { + foreach ($this->collCcBlockcontentss as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcBlockcriterias) { + foreach ($this->collCcBlockcriterias as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->aCcSubjs instanceof Persistent) { + $this->aCcSubjs->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + if ($this->collCcPlaylistcontentss instanceof PropelCollection) { + $this->collCcPlaylistcontentss->clearIterator(); + } + $this->collCcPlaylistcontentss = null; + if ($this->collCcBlockcontentss instanceof PropelCollection) { + $this->collCcBlockcontentss->clearIterator(); + } + $this->collCcBlockcontentss = null; + if ($this->collCcBlockcriterias instanceof PropelCollection) { + $this->collCcBlockcriterias->clearIterator(); + } + $this->collCcBlockcriterias = null; + $this->aCcSubjs = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcBlockPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + + // aggregate_column behavior + + /** + * Computes the value of the aggregate column length * + * @param PropelPDO $con A connection object + * + * @return mixed The scalar result from the aggregate query + */ + public function computeDbLength(PropelPDO $con) + { + $stmt = $con->prepare('SELECT SUM(cliplength) FROM "cc_blockcontents" WHERE cc_blockcontents.block_id = :p1'); + $stmt->bindValue(':p1', $this->getDbId()); + $stmt->execute(); + + return $stmt->fetchColumn(); + } + + /** + * Updates the aggregate column length * + * @param PropelPDO $con A connection object + */ + public function updateDbLength(PropelPDO $con) + { + $this->setDbLength($this->computeDbLength($con)); + $this->save($con); + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcBlockPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcBlockPeer.php index 48003ffc5..7a036bf75 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcBlockPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcBlockPeer.php @@ -1,1008 +1,1050 @@ array ('DbId', 'DbName', 'DbMtime', 'DbUtime', 'DbCreatorId', 'DbDescription', 'DbLength', 'DbType', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbMtime', 'dbUtime', 'dbCreatorId', 'dbDescription', 'dbLength', 'dbType', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::MTIME, self::UTIME, self::CREATOR_ID, self::DESCRIPTION, self::LENGTH, self::TYPE, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'MTIME', 'UTIME', 'CREATOR_ID', 'DESCRIPTION', 'LENGTH', 'TYPE', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'mtime', 'utime', 'creator_id', 'description', 'length', 'type', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) - ); - - /** - * 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, 'DbMtime' => 2, 'DbUtime' => 3, 'DbCreatorId' => 4, 'DbDescription' => 5, 'DbLength' => 6, 'DbType' => 7, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbMtime' => 2, 'dbUtime' => 3, 'dbCreatorId' => 4, 'dbDescription' => 5, 'dbLength' => 6, 'dbType' => 7, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::MTIME => 2, self::UTIME => 3, self::CREATOR_ID => 4, self::DESCRIPTION => 5, self::LENGTH => 6, self::TYPE => 7, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'MTIME' => 2, 'UTIME' => 3, 'CREATOR_ID' => 4, 'DESCRIPTION' => 5, 'LENGTH' => 6, 'TYPE' => 7, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'mtime' => 2, 'utime' => 3, 'creator_id' => 4, 'description' => 5, 'length' => 6, 'type' => 7, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) - ); - - /** - * 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. CcBlockPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcBlockPeer::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(CcBlockPeer::ID); - $criteria->addSelectColumn(CcBlockPeer::NAME); - $criteria->addSelectColumn(CcBlockPeer::MTIME); - $criteria->addSelectColumn(CcBlockPeer::UTIME); - $criteria->addSelectColumn(CcBlockPeer::CREATOR_ID); - $criteria->addSelectColumn(CcBlockPeer::DESCRIPTION); - $criteria->addSelectColumn(CcBlockPeer::LENGTH); - $criteria->addSelectColumn(CcBlockPeer::TYPE); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.NAME'); - $criteria->addSelectColumn($alias . '.MTIME'); - $criteria->addSelectColumn($alias . '.UTIME'); - $criteria->addSelectColumn($alias . '.CREATOR_ID'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.LENGTH'); - $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(CcBlockPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcBlockPeer::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(CcBlockPeer::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 CcBlock - * @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 = CcBlockPeer::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 CcBlockPeer::populateObjects(CcBlockPeer::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(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcBlockPeer::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 CcBlock $value A CcBlock object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcBlock $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 CcBlock object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcBlock) { - $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 CcBlock 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 CcBlock 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_block - * 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(); - // Invalidate objects in CcBlockcontentsPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcBlockcontentsPeer::clearInstancePool(); - // Invalidate objects in CcBlockcriteriaPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcBlockcriteriaPeer::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 = CcBlockPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcBlockPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcBlockPeer::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; - CcBlockPeer::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 (CcBlock object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcBlockPeer::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 + CcBlockPeer::NUM_COLUMNS; - } else { - $cls = CcBlockPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcBlockPeer::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(CcBlockPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcBlockPeer::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(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcBlockPeer::CREATOR_ID, 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 CcBlock 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 CcBlock 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); - } - - CcBlockPeer::addSelectColumns($criteria); - $startcol = (CcBlockPeer::NUM_COLUMNS - CcBlockPeer::NUM_LAZY_LOAD_COLUMNS); - CcSubjsPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcBlockPeer::CREATOR_ID, CcSubjsPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcBlockPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcBlockPeer::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 = CcBlockPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcBlockPeer::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 (CcBlock) to $obj2 (CcSubjs) - $obj2->addCcBlock($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(CcBlockPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcBlockPeer::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(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcBlockPeer::CREATOR_ID, 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 CcBlock 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 CcBlock 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); - } - - CcBlockPeer::addSelectColumns($criteria); - $startcol2 = (CcBlockPeer::NUM_COLUMNS - CcBlockPeer::NUM_LAZY_LOAD_COLUMNS); - - CcSubjsPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcSubjsPeer::NUM_COLUMNS - CcSubjsPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcBlockPeer::CREATOR_ID, CcSubjsPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcBlockPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcBlockPeer::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 = CcBlockPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcBlockPeer::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 (CcBlock) to the collection in $obj2 (CcSubjs) - $obj2->addCcBlock($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(BaseCcBlockPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcBlockPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcBlockTableMap()); - } - } - - /** - * 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 ? CcBlockPeer::CLASS_DEFAULT : CcBlockPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcBlock or Criteria object. - * - * @param mixed $values Criteria or CcBlock 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(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcBlock object - } - - if ($criteria->containsKey(CcBlockPeer::ID) && $criteria->keyContainsValue(CcBlockPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcBlockPeer::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 CcBlock or Criteria object. - * - * @param mixed $values Criteria or CcBlock 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(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcBlockPeer::ID); - $value = $criteria->remove(CcBlockPeer::ID); - if ($value) { - $selectCriteria->add(CcBlockPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcBlockPeer::TABLE_NAME); - } - - } else { // $values is CcBlock 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_block 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(CcBlockPeer::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(CcBlockPeer::TABLE_NAME, $con, CcBlockPeer::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). - CcBlockPeer::clearInstancePool(); - CcBlockPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcBlock or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcBlock 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(CcBlockPeer::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. - CcBlockPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcBlock) { // it's a model object - // invalidate the cache for this single object - CcBlockPeer::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(CcBlockPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcBlockPeer::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); - CcBlockPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcBlock 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 CcBlock $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(CcBlock $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcBlockPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcBlockPeer::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(CcBlockPeer::DATABASE_NAME, CcBlockPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcBlock - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcBlockPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcBlockPeer::DATABASE_NAME); - $criteria->add(CcBlockPeer::ID, $pk); - - $v = CcBlockPeer::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(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcBlockPeer::DATABASE_NAME); - $criteria->add(CcBlockPeer::ID, $pks, Criteria::IN); - $objs = CcBlockPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcBlockPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_block'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcBlock'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcBlockTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 8; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 8; + + /** the column name for the id field */ + const ID = 'cc_block.id'; + + /** the column name for the name field */ + const NAME = 'cc_block.name'; + + /** the column name for the mtime field */ + const MTIME = 'cc_block.mtime'; + + /** the column name for the utime field */ + const UTIME = 'cc_block.utime'; + + /** the column name for the creator_id field */ + const CREATOR_ID = 'cc_block.creator_id'; + + /** the column name for the description field */ + const DESCRIPTION = 'cc_block.description'; + + /** the column name for the length field */ + const LENGTH = 'cc_block.length'; + + /** the column name for the type field */ + const TYPE = 'cc_block.type'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcBlock objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcBlock[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcBlockPeer::$fieldNames[CcBlockPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbMtime', 'DbUtime', 'DbCreatorId', 'DbDescription', 'DbLength', 'DbType', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbMtime', 'dbUtime', 'dbCreatorId', 'dbDescription', 'dbLength', 'dbType', ), + BasePeer::TYPE_COLNAME => array (CcBlockPeer::ID, CcBlockPeer::NAME, CcBlockPeer::MTIME, CcBlockPeer::UTIME, CcBlockPeer::CREATOR_ID, CcBlockPeer::DESCRIPTION, CcBlockPeer::LENGTH, CcBlockPeer::TYPE, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'MTIME', 'UTIME', 'CREATOR_ID', 'DESCRIPTION', 'LENGTH', 'TYPE', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'mtime', 'utime', 'creator_id', 'description', 'length', 'type', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcBlockPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbMtime' => 2, 'DbUtime' => 3, 'DbCreatorId' => 4, 'DbDescription' => 5, 'DbLength' => 6, 'DbType' => 7, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbMtime' => 2, 'dbUtime' => 3, 'dbCreatorId' => 4, 'dbDescription' => 5, 'dbLength' => 6, 'dbType' => 7, ), + BasePeer::TYPE_COLNAME => array (CcBlockPeer::ID => 0, CcBlockPeer::NAME => 1, CcBlockPeer::MTIME => 2, CcBlockPeer::UTIME => 3, CcBlockPeer::CREATOR_ID => 4, CcBlockPeer::DESCRIPTION => 5, CcBlockPeer::LENGTH => 6, CcBlockPeer::TYPE => 7, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'MTIME' => 2, 'UTIME' => 3, 'CREATOR_ID' => 4, 'DESCRIPTION' => 5, 'LENGTH' => 6, 'TYPE' => 7, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'mtime' => 2, 'utime' => 3, 'creator_id' => 4, 'description' => 5, 'length' => 6, 'type' => 7, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcBlockPeer::getFieldNames($toType); + $key = isset(CcBlockPeer::$fieldKeys[$fromType][$name]) ? CcBlockPeer::$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(CcBlockPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcBlockPeer::$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 CcBlockPeer::$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. CcBlockPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcBlockPeer::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(CcBlockPeer::ID); + $criteria->addSelectColumn(CcBlockPeer::NAME); + $criteria->addSelectColumn(CcBlockPeer::MTIME); + $criteria->addSelectColumn(CcBlockPeer::UTIME); + $criteria->addSelectColumn(CcBlockPeer::CREATOR_ID); + $criteria->addSelectColumn(CcBlockPeer::DESCRIPTION); + $criteria->addSelectColumn(CcBlockPeer::LENGTH); + $criteria->addSelectColumn(CcBlockPeer::TYPE); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.name'); + $criteria->addSelectColumn($alias . '.mtime'); + $criteria->addSelectColumn($alias . '.utime'); + $criteria->addSelectColumn($alias . '.creator_id'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.length'); + $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(CcBlockPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcBlockPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcBlockPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcBlockPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcBlock + * @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 = CcBlockPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcBlockPeer::populateObjects(CcBlockPeer::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 directly (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(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcBlockPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcBlockPeer::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 CcBlock $obj A CcBlock object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcBlockPeer::$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 CcBlock object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcBlock) { + $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 CcBlock object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcBlockPeer::$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 CcBlock 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(CcBlockPeer::$instances[$key])) { + return CcBlockPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcBlockPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcBlockPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_block + * 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(); + // Invalidate objects in CcBlockcontentsPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcBlockcontentsPeer::clearInstancePool(); + // Invalidate objects in CcBlockcriteriaPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcBlockcriteriaPeer::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 = CcBlockPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcBlockPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcBlockPeer::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; + CcBlockPeer::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 (CcBlock object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcBlockPeer::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 + CcBlockPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcBlockPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcBlockPeer::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(CcBlockPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcBlockPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcBlockPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcBlockPeer::CREATOR_ID, 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 CcBlock 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 CcBlock 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(CcBlockPeer::DATABASE_NAME); + } + + CcBlockPeer::addSelectColumns($criteria); + $startcol = CcBlockPeer::NUM_HYDRATE_COLUMNS; + CcSubjsPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcBlockPeer::CREATOR_ID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcBlockPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcBlockPeer::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 = CcBlockPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcBlockPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcBlock) to $obj2 (CcSubjs) + $obj2->addCcBlock($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(CcBlockPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcBlockPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcBlockPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcBlockPeer::CREATOR_ID, 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 CcBlock 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 CcBlock 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(CcBlockPeer::DATABASE_NAME); + } + + CcBlockPeer::addSelectColumns($criteria); + $startcol2 = CcBlockPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcBlockPeer::CREATOR_ID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcBlockPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcBlockPeer::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 = CcBlockPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcBlockPeer::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(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcBlock) to the collection in $obj2 (CcSubjs) + $obj2->addCcBlock($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(CcBlockPeer::DATABASE_NAME)->getTable(CcBlockPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcBlockPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcBlockPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcBlockTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcBlockPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcBlock or Criteria object. + * + * @param mixed $values Criteria or CcBlock 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(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcBlock object + } + + if ($criteria->containsKey(CcBlockPeer::ID) && $criteria->keyContainsValue(CcBlockPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcBlockPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcBlockPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcBlock or Criteria object. + * + * @param mixed $values Criteria or CcBlock 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(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcBlockPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcBlockPeer::ID); + $value = $criteria->remove(CcBlockPeer::ID); + if ($value) { + $selectCriteria->add(CcBlockPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcBlockPeer::TABLE_NAME); + } + + } else { // $values is CcBlock object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcBlockPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_block table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcBlockPeer::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(CcBlockPeer::TABLE_NAME, $con, CcBlockPeer::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). + CcBlockPeer::clearInstancePool(); + CcBlockPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcBlock or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcBlock 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(CcBlockPeer::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. + CcBlockPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcBlock) { // it's a model object + // invalidate the cache for this single object + CcBlockPeer::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(CcBlockPeer::DATABASE_NAME); + $criteria->add(CcBlockPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcBlockPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcBlockPeer::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); + CcBlockPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcBlock 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 CcBlock $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcBlockPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcBlockPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcBlockPeer::DATABASE_NAME, CcBlockPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcBlock + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcBlockPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcBlockPeer::DATABASE_NAME); + $criteria->add(CcBlockPeer::ID, $pk); + + $v = CcBlockPeer::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 + * @return CcBlock[] + * @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(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcBlockPeer::DATABASE_NAME); + $criteria->add(CcBlockPeer::ID, $pks, Criteria::IN); + $objs = CcBlockPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcBlockPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcBlockQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcBlockQuery.php index 100efd61e..bd3bb0f31 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcBlockQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcBlockQuery.php @@ -1,646 +1,883 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcBlock|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcBlockPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcBlock|CcBlock[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcBlockPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcBlockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcBlockQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcBlockPeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcBlock A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcBlockQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcBlockPeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcBlock A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "name", "mtime", "utime", "creator_id", "description", "length", "type" FROM "cc_block" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcBlock(); + $obj->hydrate($row); + CcBlockPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcBlockQuery 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(CcBlockPeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * 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 CcBlockQuery 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(CcBlockPeer::NAME, $dbName, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcBlock|CcBlock[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * 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 CcBlockQuery 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(CcBlockPeer::MTIME, $dbMtime['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbMtime['max'])) { - $this->addUsingAlias(CcBlockPeer::MTIME, $dbMtime['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcBlockPeer::MTIME, $dbMtime, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query on the utime column - * - * @param string|array $dbUtime 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 CcBlockQuery The current query, for fluid interface - */ - public function filterByDbUtime($dbUtime = null, $comparison = null) - { - if (is_array($dbUtime)) { - $useMinMax = false; - if (isset($dbUtime['min'])) { - $this->addUsingAlias(CcBlockPeer::UTIME, $dbUtime['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbUtime['max'])) { - $this->addUsingAlias(CcBlockPeer::UTIME, $dbUtime['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcBlockPeer::UTIME, $dbUtime, $comparison); - } + /** + * 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|CcBlock[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query on the creator_id column - * - * @param int|array $dbCreatorId 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 CcBlockQuery The current query, for fluid interface - */ - public function filterByDbCreatorId($dbCreatorId = null, $comparison = null) - { - if (is_array($dbCreatorId)) { - $useMinMax = false; - if (isset($dbCreatorId['min'])) { - $this->addUsingAlias(CcBlockPeer::CREATOR_ID, $dbCreatorId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbCreatorId['max'])) { - $this->addUsingAlias(CcBlockPeer::CREATOR_ID, $dbCreatorId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcBlockPeer::CREATOR_ID, $dbCreatorId, $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * 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 CcBlockQuery 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(CcBlockPeer::DESCRIPTION, $dbDescription, $comparison); - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcBlockQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { - /** - * Filter the query on the length column - * - * @param string $dbLength 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 CcBlockQuery The current query, for fluid interface - */ - public function filterByDbLength($dbLength = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbLength)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbLength)) { - $dbLength = str_replace('*', '%', $dbLength); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcBlockPeer::LENGTH, $dbLength, $comparison); - } + return $this->addUsingAlias(CcBlockPeer::ID, $key, Criteria::EQUAL); + } - /** - * Filter the query on the type column - * - * @param string $dbType The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcBlockQuery The current query, for fluid interface - */ - public function filterByDbType($dbType = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbType)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbType)) { - $dbType = str_replace('*', '%', $dbType); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcBlockPeer::TYPE, $dbType, $comparison); - } + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return CcBlockQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { - /** - * 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 CcBlockQuery The current query, for fluid interface - */ - public function filterByCcSubjs($ccSubjs, $comparison = null) - { - return $this - ->addUsingAlias(CcBlockPeer::CREATOR_ID, $ccSubjs->getDbId(), $comparison); - } + return $this->addUsingAlias(CcBlockPeer::ID, $keys, Criteria::IN); + } - /** - * 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 CcBlockQuery 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; - } + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcBlockPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcBlockPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * 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'); - } + return $this->addUsingAlias(CcBlockPeer::ID, $dbId, $comparison); + } - /** - * 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 CcBlockQuery The current query, for fluid interface - */ - public function filterByCcPlaylistcontents($ccPlaylistcontents, $comparison = null) - { - return $this - ->addUsingAlias(CcBlockPeer::ID, $ccPlaylistcontents->getDbBlockId(), $comparison); - } + /** + * Filter the query on the name column + * + * Example usage: + * + * $query->filterByDbName('fooValue'); // WHERE name = 'fooValue' + * $query->filterByDbName('%fooValue%'); // WHERE name LIKE '%fooValue%' + * + * + * @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 CcBlockQuery 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; + } + } - /** - * 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 CcBlockQuery 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; - } + return $this->addUsingAlias(CcBlockPeer::NAME, $dbName, $comparison); + } - /** - * 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'); - } + /** + * Filter the query on the mtime column + * + * Example usage: + * + * $query->filterByDbMtime('2011-03-14'); // WHERE mtime = '2011-03-14' + * $query->filterByDbMtime('now'); // WHERE mtime = '2011-03-14' + * $query->filterByDbMtime(array('max' => 'yesterday')); // WHERE mtime < '2011-03-13' + * + * + * @param mixed $dbMtime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockQuery 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(CcBlockPeer::MTIME, $dbMtime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbMtime['max'])) { + $this->addUsingAlias(CcBlockPeer::MTIME, $dbMtime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Filter the query by a related CcBlockcontents object - * - * @param CcBlockcontents $ccBlockcontents the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcBlockQuery The current query, for fluid interface - */ - public function filterByCcBlockcontents($ccBlockcontents, $comparison = null) - { - return $this - ->addUsingAlias(CcBlockPeer::ID, $ccBlockcontents->getDbBlockId(), $comparison); - } + return $this->addUsingAlias(CcBlockPeer::MTIME, $dbMtime, $comparison); + } - /** - * Adds a JOIN clause to the query using the CcBlockcontents relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcBlockQuery The current query, for fluid interface - */ - public function joinCcBlockcontents($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcBlockcontents'); - - // 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, 'CcBlockcontents'); - } - - return $this; - } + /** + * Filter the query on the utime column + * + * Example usage: + * + * $query->filterByDbUtime('2011-03-14'); // WHERE utime = '2011-03-14' + * $query->filterByDbUtime('now'); // WHERE utime = '2011-03-14' + * $query->filterByDbUtime(array('max' => 'yesterday')); // WHERE utime < '2011-03-13' + * + * + * @param mixed $dbUtime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockQuery The current query, for fluid interface + */ + public function filterByDbUtime($dbUtime = null, $comparison = null) + { + if (is_array($dbUtime)) { + $useMinMax = false; + if (isset($dbUtime['min'])) { + $this->addUsingAlias(CcBlockPeer::UTIME, $dbUtime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbUtime['max'])) { + $this->addUsingAlias(CcBlockPeer::UTIME, $dbUtime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Use the CcBlockcontents relation CcBlockcontents 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 CcBlockcontentsQuery A secondary query class using the current class as primary query - */ - public function useCcBlockcontentsQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcBlockcontents($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcBlockcontents', 'CcBlockcontentsQuery'); - } + return $this->addUsingAlias(CcBlockPeer::UTIME, $dbUtime, $comparison); + } - /** - * Filter the query by a related CcBlockcriteria object - * - * @param CcBlockcriteria $ccBlockcriteria the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcBlockQuery The current query, for fluid interface - */ - public function filterByCcBlockcriteria($ccBlockcriteria, $comparison = null) - { - return $this - ->addUsingAlias(CcBlockPeer::ID, $ccBlockcriteria->getDbBlockId(), $comparison); - } + /** + * Filter the query on the creator_id column + * + * Example usage: + * + * $query->filterByDbCreatorId(1234); // WHERE creator_id = 1234 + * $query->filterByDbCreatorId(array(12, 34)); // WHERE creator_id IN (12, 34) + * $query->filterByDbCreatorId(array('min' => 12)); // WHERE creator_id >= 12 + * $query->filterByDbCreatorId(array('max' => 12)); // WHERE creator_id <= 12 + * + * + * @see filterByCcSubjs() + * + * @param mixed $dbCreatorId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockQuery The current query, for fluid interface + */ + public function filterByDbCreatorId($dbCreatorId = null, $comparison = null) + { + if (is_array($dbCreatorId)) { + $useMinMax = false; + if (isset($dbCreatorId['min'])) { + $this->addUsingAlias(CcBlockPeer::CREATOR_ID, $dbCreatorId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbCreatorId['max'])) { + $this->addUsingAlias(CcBlockPeer::CREATOR_ID, $dbCreatorId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Adds a JOIN clause to the query using the CcBlockcriteria relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcBlockQuery The current query, for fluid interface - */ - public function joinCcBlockcriteria($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcBlockcriteria'); - - // 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, 'CcBlockcriteria'); - } - - return $this; - } + return $this->addUsingAlias(CcBlockPeer::CREATOR_ID, $dbCreatorId, $comparison); + } - /** - * Use the CcBlockcriteria relation CcBlockcriteria 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 CcBlockcriteriaQuery A secondary query class using the current class as primary query - */ - public function useCcBlockcriteriaQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcBlockcriteria($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcBlockcriteria', 'CcBlockcriteriaQuery'); - } + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDbDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDbDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @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 CcBlockQuery 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; + } + } - /** - * Exclude object from result - * - * @param CcBlock $ccBlock Object to remove from the list of results - * - * @return CcBlockQuery The current query, for fluid interface - */ - public function prune($ccBlock = null) - { - if ($ccBlock) { - $this->addUsingAlias(CcBlockPeer::ID, $ccBlock->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + return $this->addUsingAlias(CcBlockPeer::DESCRIPTION, $dbDescription, $comparison); + } -} // BaseCcBlockQuery + /** + * Filter the query on the length column + * + * Example usage: + * + * $query->filterByDbLength('fooValue'); // WHERE length = 'fooValue' + * $query->filterByDbLength('%fooValue%'); // WHERE length LIKE '%fooValue%' + * + * + * @param string $dbLength 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 CcBlockQuery The current query, for fluid interface + */ + public function filterByDbLength($dbLength = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLength)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLength)) { + $dbLength = str_replace('*', '%', $dbLength); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcBlockPeer::LENGTH, $dbLength, $comparison); + } + + /** + * Filter the query on the type column + * + * Example usage: + * + * $query->filterByDbType('fooValue'); // WHERE type = 'fooValue' + * $query->filterByDbType('%fooValue%'); // WHERE type LIKE '%fooValue%' + * + * + * @param string $dbType The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockQuery The current query, for fluid interface + */ + public function filterByDbType($dbType = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbType)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbType)) { + $dbType = str_replace('*', '%', $dbType); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcBlockPeer::TYPE, $dbType, $comparison); + } + + /** + * Filter the query by a related CcSubjs object + * + * @param CcSubjs|PropelObjectCollection $ccSubjs The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcSubjs($ccSubjs, $comparison = null) + { + if ($ccSubjs instanceof CcSubjs) { + return $this + ->addUsingAlias(CcBlockPeer::CREATOR_ID, $ccSubjs->getDbId(), $comparison); + } elseif ($ccSubjs instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcBlockPeer::CREATOR_ID, $ccSubjs->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcSubjs() only accepts arguments of type CcSubjs or PropelCollection'); + } + } + + /** + * 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 CcBlockQuery The current query, for fluid interface + */ + public function joinCcSubjs($relationAlias = null, $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 \Airtime\CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSubjs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', '\Airtime\CcSubjsQuery'); + } + + /** + * Filter the query by a related CcPlaylistcontents object + * + * @param CcPlaylistcontents|PropelObjectCollection $ccPlaylistcontents the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcPlaylistcontents($ccPlaylistcontents, $comparison = null) + { + if ($ccPlaylistcontents instanceof CcPlaylistcontents) { + return $this + ->addUsingAlias(CcBlockPeer::ID, $ccPlaylistcontents->getDbBlockId(), $comparison); + } elseif ($ccPlaylistcontents instanceof PropelObjectCollection) { + return $this + ->useCcPlaylistcontentsQuery() + ->filterByPrimaryKeys($ccPlaylistcontents->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcPlaylistcontents() only accepts arguments of type CcPlaylistcontents or PropelCollection'); + } + } + + /** + * 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 CcBlockQuery The current query, for fluid interface + */ + public function joinCcPlaylistcontents($relationAlias = null, $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 \Airtime\CcPlaylistcontentsQuery A secondary query class using the current class as primary query + */ + public function useCcPlaylistcontentsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcPlaylistcontents($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPlaylistcontents', '\Airtime\CcPlaylistcontentsQuery'); + } + + /** + * Filter the query by a related CcBlockcontents object + * + * @param CcBlockcontents|PropelObjectCollection $ccBlockcontents the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcBlockcontents($ccBlockcontents, $comparison = null) + { + if ($ccBlockcontents instanceof CcBlockcontents) { + return $this + ->addUsingAlias(CcBlockPeer::ID, $ccBlockcontents->getDbBlockId(), $comparison); + } elseif ($ccBlockcontents instanceof PropelObjectCollection) { + return $this + ->useCcBlockcontentsQuery() + ->filterByPrimaryKeys($ccBlockcontents->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcBlockcontents() only accepts arguments of type CcBlockcontents or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcBlockcontents relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcBlockQuery The current query, for fluid interface + */ + public function joinCcBlockcontents($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcBlockcontents'); + + // 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, 'CcBlockcontents'); + } + + return $this; + } + + /** + * Use the CcBlockcontents relation CcBlockcontents 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 \Airtime\CcBlockcontentsQuery A secondary query class using the current class as primary query + */ + public function useCcBlockcontentsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcBlockcontents($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcBlockcontents', '\Airtime\CcBlockcontentsQuery'); + } + + /** + * Filter the query by a related CcBlockcriteria object + * + * @param CcBlockcriteria|PropelObjectCollection $ccBlockcriteria the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcBlockcriteria($ccBlockcriteria, $comparison = null) + { + if ($ccBlockcriteria instanceof CcBlockcriteria) { + return $this + ->addUsingAlias(CcBlockPeer::ID, $ccBlockcriteria->getDbBlockId(), $comparison); + } elseif ($ccBlockcriteria instanceof PropelObjectCollection) { + return $this + ->useCcBlockcriteriaQuery() + ->filterByPrimaryKeys($ccBlockcriteria->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcBlockcriteria() only accepts arguments of type CcBlockcriteria or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcBlockcriteria relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcBlockQuery The current query, for fluid interface + */ + public function joinCcBlockcriteria($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcBlockcriteria'); + + // 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, 'CcBlockcriteria'); + } + + return $this; + } + + /** + * Use the CcBlockcriteria relation CcBlockcriteria 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 \Airtime\CcBlockcriteriaQuery A secondary query class using the current class as primary query + */ + public function useCcBlockcriteriaQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcBlockcriteria($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcBlockcriteria', '\Airtime\CcBlockcriteriaQuery'); + } + + /** + * Exclude object from result + * + * @param CcBlock $ccBlock Object to remove from the list of results + * + * @return CcBlockQuery The current query, for fluid interface + */ + public function prune($ccBlock = null) + { + if ($ccBlock) { + $this->addUsingAlias(CcBlockPeer::ID, $ccBlock->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcBlockcontents.php b/airtime_mvc/application/models/airtime/om/BaseCcBlockcontents.php index f2e6fb6d1..cd80c03fa 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcBlockcontents.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcBlockcontents.php @@ -1,1462 +1,1634 @@ trackoffset = 0; - $this->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 BaseCcBlockcontents 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 [block_id] column value. - * - * @return int - */ - public function getDbBlockId() - { - return $this->block_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 [trackoffset] column value. - * - * @return double - */ - public function getDbTrackOffset() - { - return $this->trackoffset; - } - - /** - * Get the [cliplength] column value. - * - * @return string - */ - public function getDbCliplength() - { - return $this->cliplength; - } - - /** - * Get the [cuein] column value. - * - * @return string - */ - public function getDbCuein() - { - return $this->cuein; - } - - /** - * Get the [cueout] column value. - * - * @return string - */ - public function getDbCueout() - { - return $this->cueout; - } - - /** - * 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 CcBlockcontents 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[] = CcBlockcontentsPeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [block_id] column. - * - * @param int $v new value - * @return CcBlockcontents The current object (for fluent API support) - */ - public function setDbBlockId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->block_id !== $v) { - $this->block_id = $v; - $this->modifiedColumns[] = CcBlockcontentsPeer::BLOCK_ID; - } - - if ($this->aCcBlock !== null && $this->aCcBlock->getDbId() !== $v) { - $this->aCcBlock = null; - } - - return $this; - } // setDbBlockId() - - /** - * Set the value of [file_id] column. - * - * @param int $v new value - * @return CcBlockcontents 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[] = CcBlockcontentsPeer::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 CcBlockcontents 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[] = CcBlockcontentsPeer::POSITION; - } - - return $this; - } // setDbPosition() - - /** - * Set the value of [trackoffset] column. - * - * @param double $v new value - * @return CcBlockcontents The current object (for fluent API support) - */ - public function setDbTrackOffset($v) - { - if ($v !== null) { - $v = (double) $v; - } - - if ($this->trackoffset !== $v || $this->isNew()) { - $this->trackoffset = $v; - $this->modifiedColumns[] = CcBlockcontentsPeer::TRACKOFFSET; - } - - return $this; - } // setDbTrackOffset() - - /** - * Set the value of [cliplength] column. - * - * @param string $v new value - * @return CcBlockcontents The current object (for fluent API support) - */ - public function setDbCliplength($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->cliplength !== $v || $this->isNew()) { - $this->cliplength = $v; - $this->modifiedColumns[] = CcBlockcontentsPeer::CLIPLENGTH; - } - - return $this; - } // setDbCliplength() - - /** - * Set the value of [cuein] column. - * - * @param string $v new value - * @return CcBlockcontents The current object (for fluent API support) - */ - public function setDbCuein($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->cuein !== $v || $this->isNew()) { - $this->cuein = $v; - $this->modifiedColumns[] = CcBlockcontentsPeer::CUEIN; - } - - return $this; - } // setDbCuein() - - /** - * Set the value of [cueout] column. - * - * @param string $v new value - * @return CcBlockcontents The current object (for fluent API support) - */ - public function setDbCueout($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->cueout !== $v || $this->isNew()) { - $this->cueout = $v; - $this->modifiedColumns[] = CcBlockcontentsPeer::CUEOUT; - } - - 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 CcBlockcontents 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[] = CcBlockcontentsPeer::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 CcBlockcontents 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[] = CcBlockcontentsPeer::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->trackoffset !== 0) { - return false; - } - - 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->block_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->trackoffset = ($row[$startcol + 4] !== null) ? (double) $row[$startcol + 4] : null; - $this->cliplength = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->cuein = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->cueout = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->fadein = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; - $this->fadeout = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 10; // 10 = CcBlockcontentsPeer::NUM_COLUMNS - CcBlockcontentsPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcBlockcontents 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->aCcBlock !== null && $this->block_id !== $this->aCcBlock->getDbId()) { - $this->aCcBlock = 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(CcBlockcontentsPeer::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 = CcBlockcontentsPeer::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->aCcBlock = 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(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcBlockcontentsQuery::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(CcBlockcontentsPeer::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); - // aggregate_column_relation behavior - $this->updateRelatedCcBlock($con); - CcBlockcontentsPeer::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->aCcBlock !== null) { - if ($this->aCcBlock->isModified() || $this->aCcBlock->isNew()) { - $affectedRows += $this->aCcBlock->save($con); - } - $this->setCcBlock($this->aCcBlock); - } - - if ($this->isNew() ) { - $this->modifiedColumns[] = CcBlockcontentsPeer::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(CcBlockcontentsPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcBlockcontentsPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows += 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows += CcBlockcontentsPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcFiles !== null) { - if (!$this->aCcFiles->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcFiles->getValidationFailures()); - } - } - - if ($this->aCcBlock !== null) { - if (!$this->aCcBlock->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcBlock->getValidationFailures()); - } - } - - - if (($retval = CcBlockcontentsPeer::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 = CcBlockcontentsPeer::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->getDbBlockId(); - break; - case 2: - return $this->getDbFileId(); - break; - case 3: - return $this->getDbPosition(); - break; - case 4: - return $this->getDbTrackOffset(); - break; - case 5: - return $this->getDbCliplength(); - break; - case 6: - return $this->getDbCuein(); - break; - case 7: - return $this->getDbCueout(); - break; - case 8: - return $this->getDbFadein(); - break; - case 9: - 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 = CcBlockcontentsPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbBlockId(), - $keys[2] => $this->getDbFileId(), - $keys[3] => $this->getDbPosition(), - $keys[4] => $this->getDbTrackOffset(), - $keys[5] => $this->getDbCliplength(), - $keys[6] => $this->getDbCuein(), - $keys[7] => $this->getDbCueout(), - $keys[8] => $this->getDbFadein(), - $keys[9] => $this->getDbFadeout(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCcFiles) { - $result['CcFiles'] = $this->aCcFiles->toArray($keyType, $includeLazyLoadColumns, true); - } - if (null !== $this->aCcBlock) { - $result['CcBlock'] = $this->aCcBlock->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 = CcBlockcontentsPeer::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->setDbBlockId($value); - break; - case 2: - $this->setDbFileId($value); - break; - case 3: - $this->setDbPosition($value); - break; - case 4: - $this->setDbTrackOffset($value); - break; - case 5: - $this->setDbCliplength($value); - break; - case 6: - $this->setDbCuein($value); - break; - case 7: - $this->setDbCueout($value); - break; - case 8: - $this->setDbFadein($value); - break; - case 9: - $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 = CcBlockcontentsPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbBlockId($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->setDbTrackOffset($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbCliplength($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDbCuein($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setDbCueout($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setDbFadein($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setDbFadeout($arr[$keys[9]]); - } - - /** - * 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(CcBlockcontentsPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcBlockcontentsPeer::ID)) $criteria->add(CcBlockcontentsPeer::ID, $this->id); - if ($this->isColumnModified(CcBlockcontentsPeer::BLOCK_ID)) $criteria->add(CcBlockcontentsPeer::BLOCK_ID, $this->block_id); - if ($this->isColumnModified(CcBlockcontentsPeer::FILE_ID)) $criteria->add(CcBlockcontentsPeer::FILE_ID, $this->file_id); - if ($this->isColumnModified(CcBlockcontentsPeer::POSITION)) $criteria->add(CcBlockcontentsPeer::POSITION, $this->position); - if ($this->isColumnModified(CcBlockcontentsPeer::TRACKOFFSET)) $criteria->add(CcBlockcontentsPeer::TRACKOFFSET, $this->trackoffset); - if ($this->isColumnModified(CcBlockcontentsPeer::CLIPLENGTH)) $criteria->add(CcBlockcontentsPeer::CLIPLENGTH, $this->cliplength); - if ($this->isColumnModified(CcBlockcontentsPeer::CUEIN)) $criteria->add(CcBlockcontentsPeer::CUEIN, $this->cuein); - if ($this->isColumnModified(CcBlockcontentsPeer::CUEOUT)) $criteria->add(CcBlockcontentsPeer::CUEOUT, $this->cueout); - if ($this->isColumnModified(CcBlockcontentsPeer::FADEIN)) $criteria->add(CcBlockcontentsPeer::FADEIN, $this->fadein); - if ($this->isColumnModified(CcBlockcontentsPeer::FADEOUT)) $criteria->add(CcBlockcontentsPeer::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(CcBlockcontentsPeer::DATABASE_NAME); - $criteria->add(CcBlockcontentsPeer::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 CcBlockcontents (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->setDbBlockId($this->block_id); - $copyObj->setDbFileId($this->file_id); - $copyObj->setDbPosition($this->position); - $copyObj->setDbTrackOffset($this->trackoffset); - $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 CcBlockcontents 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 CcBlockcontentsPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcBlockcontentsPeer(); - } - return self::$peer; - } - - /** - * Declares an association between this object and a CcFiles object. - * - * @param CcFiles $v - * @return CcBlockcontents 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->addCcBlockcontents($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->addCcBlockcontentss($this); - */ - } - return $this->aCcFiles; - } - - /** - * Declares an association between this object and a CcBlock object. - * - * @param CcBlock $v - * @return CcBlockcontents The current object (for fluent API support) - * @throws PropelException - */ - public function setCcBlock(CcBlock $v = null) - { - // aggregate_column_relation behavior - if (null !== $this->aCcBlock && $v !== $this->aCcBlock) { - $this->oldCcBlock = $this->aCcBlock; - } - if ($v === null) { - $this->setDbBlockId(NULL); - } else { - $this->setDbBlockId($v->getDbId()); - } - - $this->aCcBlock = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcBlock object, it will not be re-added. - if ($v !== null) { - $v->addCcBlockcontents($this); - } - - return $this; - } - - - /** - * Get the associated CcBlock object - * - * @param PropelPDO Optional Connection object. - * @return CcBlock The associated CcBlock object. - * @throws PropelException - */ - public function getCcBlock(PropelPDO $con = null) - { - if ($this->aCcBlock === null && ($this->block_id !== null)) { - $this->aCcBlock = CcBlockQuery::create()->findPk($this->block_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->aCcBlock->addCcBlockcontentss($this); - */ - } - return $this->aCcBlock; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->block_id = null; - $this->file_id = null; - $this->position = null; - $this->trackoffset = 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->aCcBlock = null; - } - - // aggregate_column_relation behavior - - /** - * Update the aggregate column in the related CcBlock object - * - * @param PropelPDO $con A connection object - */ - protected function updateRelatedCcBlock(PropelPDO $con) - { - if ($ccBlock = $this->getCcBlock()) { - $ccBlock->updateDbLength($con); - } - if ($this->oldCcBlock) { - $this->oldCcBlock->updateDbLength($con); - $this->oldCcBlock = 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); - } - -} // BaseCcBlockcontents + /** + * Peer class name + */ + const PEER = 'Airtime\\CcBlockcontentsPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcBlockcontentsPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the block_id field. + * @var int + */ + protected $block_id; + + /** + * The value for the file_id field. + * @var int + */ + protected $file_id; + + /** + * The value for the position field. + * @var int + */ + protected $position; + + /** + * The value for the trackoffset field. + * Note: this column has a database default value of: 0 + * @var double + */ + protected $trackoffset; + + /** + * The value for the cliplength field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $cliplength; + + /** + * The value for the cuein field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $cuein; + + /** + * The value for the cueout field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $cueout; + + /** + * The value for the fadein field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $fadein; + + /** + * The value for the fadeout field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $fadeout; + + /** + * @var CcFiles + */ + protected $aCcFiles; + + /** + * @var CcBlock + */ + protected $aCcBlock; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + // aggregate_column_relation behavior + protected $oldCcBlock; + + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->trackoffset = 0; + $this->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 BaseCcBlockcontents 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 [block_id] column value. + * + * @return int + */ + public function getDbBlockId() + { + + return $this->block_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 [trackoffset] column value. + * + * @return double + */ + public function getDbTrackOffset() + { + + return $this->trackoffset; + } + + /** + * Get the [cliplength] column value. + * + * @return string + */ + public function getDbCliplength() + { + + return $this->cliplength; + } + + /** + * Get the [cuein] column value. + * + * @return string + */ + public function getDbCuein() + { + + return $this->cuein; + } + + /** + * Get the [cueout] column value. + * + * @return string + */ + public function getDbCueout() + { + + return $this->cueout; + } + + /** + * 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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + 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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcBlockcontents The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcBlockcontentsPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [block_id] column. + * + * @param int $v new value + * @return CcBlockcontents The current object (for fluent API support) + */ + public function setDbBlockId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->block_id !== $v) { + $this->block_id = $v; + $this->modifiedColumns[] = CcBlockcontentsPeer::BLOCK_ID; + } + + if ($this->aCcBlock !== null && $this->aCcBlock->getDbId() !== $v) { + $this->aCcBlock = null; + } + + + return $this; + } // setDbBlockId() + + /** + * Set the value of [file_id] column. + * + * @param int $v new value + * @return CcBlockcontents The current object (for fluent API support) + */ + public function setDbFileId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->file_id !== $v) { + $this->file_id = $v; + $this->modifiedColumns[] = CcBlockcontentsPeer::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 CcBlockcontents The current object (for fluent API support) + */ + public function setDbPosition($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = CcBlockcontentsPeer::POSITION; + } + + + return $this; + } // setDbPosition() + + /** + * Set the value of [trackoffset] column. + * + * @param double $v new value + * @return CcBlockcontents The current object (for fluent API support) + */ + public function setDbTrackOffset($v) + { + if ($v !== null && is_numeric($v)) { + $v = (double) $v; + } + + if ($this->trackoffset !== $v) { + $this->trackoffset = $v; + $this->modifiedColumns[] = CcBlockcontentsPeer::TRACKOFFSET; + } + + + return $this; + } // setDbTrackOffset() + + /** + * Set the value of [cliplength] column. + * + * @param string $v new value + * @return CcBlockcontents The current object (for fluent API support) + */ + public function setDbCliplength($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->cliplength !== $v) { + $this->cliplength = $v; + $this->modifiedColumns[] = CcBlockcontentsPeer::CLIPLENGTH; + } + + + return $this; + } // setDbCliplength() + + /** + * Set the value of [cuein] column. + * + * @param string $v new value + * @return CcBlockcontents The current object (for fluent API support) + */ + public function setDbCuein($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->cuein !== $v) { + $this->cuein = $v; + $this->modifiedColumns[] = CcBlockcontentsPeer::CUEIN; + } + + + return $this; + } // setDbCuein() + + /** + * Set the value of [cueout] column. + * + * @param string $v new value + * @return CcBlockcontents The current object (for fluent API support) + */ + public function setDbCueout($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->cueout !== $v) { + $this->cueout = $v; + $this->modifiedColumns[] = CcBlockcontentsPeer::CUEOUT; + } + + + 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 strings are treated as null. + * @return CcBlockcontents The current object (for fluent API support) + */ + public function setDbFadein($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->fadein !== null || $dt !== null) { + $currentDateAsString = ($this->fadein !== null && $tmpDt = new DateTime($this->fadein)) ? $tmpDt->format('H:i:s') : null; + $newDateAsString = $dt ? $dt->format('H:i:s') : null; + if ( ($currentDateAsString !== $newDateAsString) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) { + $this->fadein = $newDateAsString; + $this->modifiedColumns[] = CcBlockcontentsPeer::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 strings are treated as null. + * @return CcBlockcontents The current object (for fluent API support) + */ + public function setDbFadeout($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->fadeout !== null || $dt !== null) { + $currentDateAsString = ($this->fadeout !== null && $tmpDt = new DateTime($this->fadeout)) ? $tmpDt->format('H:i:s') : null; + $newDateAsString = $dt ? $dt->format('H:i:s') : null; + if ( ($currentDateAsString !== $newDateAsString) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) { + $this->fadeout = $newDateAsString; + $this->modifiedColumns[] = CcBlockcontentsPeer::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->trackoffset !== 0) { + return false; + } + + 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 resultset 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->block_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->trackoffset = ($row[$startcol + 4] !== null) ? (double) $row[$startcol + 4] : null; + $this->cliplength = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->cuein = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->cueout = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; + $this->fadein = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->fadeout = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 10; // 10 = CcBlockcontentsPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcBlockcontents 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->aCcBlock !== null && $this->block_id !== $this->aCcBlock->getDbId()) { + $this->aCcBlock = 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(CcBlockcontentsPeer::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 = CcBlockcontentsPeer::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->aCcBlock = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcBlockcontentsQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcBlockcontentsPeer::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); + // aggregate_column_relation behavior + $this->updateRelatedCcBlock($con); + CcBlockcontentsPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding 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->aCcBlock !== null) { + if ($this->aCcBlock->isModified() || $this->aCcBlock->isNew()) { + $affectedRows += $this->aCcBlock->save($con); + } + $this->setCcBlock($this->aCcBlock); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcBlockcontentsPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcBlockcontentsPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_blockcontents_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcBlockcontentsPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcBlockcontentsPeer::BLOCK_ID)) { + $modifiedColumns[':p' . $index++] = '"block_id"'; + } + if ($this->isColumnModified(CcBlockcontentsPeer::FILE_ID)) { + $modifiedColumns[':p' . $index++] = '"file_id"'; + } + if ($this->isColumnModified(CcBlockcontentsPeer::POSITION)) { + $modifiedColumns[':p' . $index++] = '"position"'; + } + if ($this->isColumnModified(CcBlockcontentsPeer::TRACKOFFSET)) { + $modifiedColumns[':p' . $index++] = '"trackoffset"'; + } + if ($this->isColumnModified(CcBlockcontentsPeer::CLIPLENGTH)) { + $modifiedColumns[':p' . $index++] = '"cliplength"'; + } + if ($this->isColumnModified(CcBlockcontentsPeer::CUEIN)) { + $modifiedColumns[':p' . $index++] = '"cuein"'; + } + if ($this->isColumnModified(CcBlockcontentsPeer::CUEOUT)) { + $modifiedColumns[':p' . $index++] = '"cueout"'; + } + if ($this->isColumnModified(CcBlockcontentsPeer::FADEIN)) { + $modifiedColumns[':p' . $index++] = '"fadein"'; + } + if ($this->isColumnModified(CcBlockcontentsPeer::FADEOUT)) { + $modifiedColumns[':p' . $index++] = '"fadeout"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_blockcontents" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"block_id"': + $stmt->bindValue($identifier, $this->block_id, PDO::PARAM_INT); + break; + case '"file_id"': + $stmt->bindValue($identifier, $this->file_id, PDO::PARAM_INT); + break; + case '"position"': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case '"trackoffset"': + $stmt->bindValue($identifier, $this->trackoffset, PDO::PARAM_STR); + break; + case '"cliplength"': + $stmt->bindValue($identifier, $this->cliplength, PDO::PARAM_STR); + break; + case '"cuein"': + $stmt->bindValue($identifier, $this->cuein, PDO::PARAM_STR); + break; + case '"cueout"': + $stmt->bindValue($identifier, $this->cueout, PDO::PARAM_STR); + break; + case '"fadein"': + $stmt->bindValue($identifier, $this->fadein, PDO::PARAM_STR); + break; + case '"fadeout"': + $stmt->bindValue($identifier, $this->fadeout, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding 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->aCcBlock !== null) { + if (!$this->aCcBlock->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcBlock->getValidationFailures()); + } + } + + + if (($retval = CcBlockcontentsPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcBlockcontentsPeer::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->getDbBlockId(); + break; + case 2: + return $this->getDbFileId(); + break; + case 3: + return $this->getDbPosition(); + break; + case 4: + return $this->getDbTrackOffset(); + break; + case 5: + return $this->getDbCliplength(); + break; + case 6: + return $this->getDbCuein(); + break; + case 7: + return $this->getDbCueout(); + break; + case 8: + return $this->getDbFadein(); + break; + case 9: + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcBlockcontents'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcBlockcontents'][$this->getPrimaryKey()] = true; + $keys = CcBlockcontentsPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbBlockId(), + $keys[2] => $this->getDbFileId(), + $keys[3] => $this->getDbPosition(), + $keys[4] => $this->getDbTrackOffset(), + $keys[5] => $this->getDbCliplength(), + $keys[6] => $this->getDbCuein(), + $keys[7] => $this->getDbCueout(), + $keys[8] => $this->getDbFadein(), + $keys[9] => $this->getDbFadeout(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcFiles) { + $result['CcFiles'] = $this->aCcFiles->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aCcBlock) { + $result['CcBlock'] = $this->aCcBlock->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcBlockcontentsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbBlockId($value); + break; + case 2: + $this->setDbFileId($value); + break; + case 3: + $this->setDbPosition($value); + break; + case 4: + $this->setDbTrackOffset($value); + break; + case 5: + $this->setDbCliplength($value); + break; + case 6: + $this->setDbCuein($value); + break; + case 7: + $this->setDbCueout($value); + break; + case 8: + $this->setDbFadein($value); + break; + case 9: + $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 BasePeer::TYPE_PHPNAME + * + * @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 = CcBlockcontentsPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbBlockId($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->setDbTrackOffset($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbCliplength($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbCuein($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbCueout($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setDbFadein($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDbFadeout($arr[$keys[9]]); + } + + /** + * 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(CcBlockcontentsPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcBlockcontentsPeer::ID)) $criteria->add(CcBlockcontentsPeer::ID, $this->id); + if ($this->isColumnModified(CcBlockcontentsPeer::BLOCK_ID)) $criteria->add(CcBlockcontentsPeer::BLOCK_ID, $this->block_id); + if ($this->isColumnModified(CcBlockcontentsPeer::FILE_ID)) $criteria->add(CcBlockcontentsPeer::FILE_ID, $this->file_id); + if ($this->isColumnModified(CcBlockcontentsPeer::POSITION)) $criteria->add(CcBlockcontentsPeer::POSITION, $this->position); + if ($this->isColumnModified(CcBlockcontentsPeer::TRACKOFFSET)) $criteria->add(CcBlockcontentsPeer::TRACKOFFSET, $this->trackoffset); + if ($this->isColumnModified(CcBlockcontentsPeer::CLIPLENGTH)) $criteria->add(CcBlockcontentsPeer::CLIPLENGTH, $this->cliplength); + if ($this->isColumnModified(CcBlockcontentsPeer::CUEIN)) $criteria->add(CcBlockcontentsPeer::CUEIN, $this->cuein); + if ($this->isColumnModified(CcBlockcontentsPeer::CUEOUT)) $criteria->add(CcBlockcontentsPeer::CUEOUT, $this->cueout); + if ($this->isColumnModified(CcBlockcontentsPeer::FADEIN)) $criteria->add(CcBlockcontentsPeer::FADEIN, $this->fadein); + if ($this->isColumnModified(CcBlockcontentsPeer::FADEOUT)) $criteria->add(CcBlockcontentsPeer::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(CcBlockcontentsPeer::DATABASE_NAME); + $criteria->add(CcBlockcontentsPeer::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 CcBlockcontents (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbBlockId($this->getDbBlockId()); + $copyObj->setDbFileId($this->getDbFileId()); + $copyObj->setDbPosition($this->getDbPosition()); + $copyObj->setDbTrackOffset($this->getDbTrackOffset()); + $copyObj->setDbCliplength($this->getDbCliplength()); + $copyObj->setDbCuein($this->getDbCuein()); + $copyObj->setDbCueout($this->getDbCueout()); + $copyObj->setDbFadein($this->getDbFadein()); + $copyObj->setDbFadeout($this->getDbFadeout()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcBlockcontents 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 CcBlockcontentsPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcBlockcontentsPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a CcFiles object. + * + * @param CcFiles $v + * @return CcBlockcontents 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->addCcBlockcontents($this); + } + + + return $this; + } + + + /** + * Get the associated CcFiles object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcFiles The associated CcFiles object. + * @throws PropelException + */ + public function getCcFiles(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcFiles === null && ($this->file_id !== null) && $doQuery) { + $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->addCcBlockcontentss($this); + */ + } + + return $this->aCcFiles; + } + + /** + * Declares an association between this object and a CcBlock object. + * + * @param CcBlock $v + * @return CcBlockcontents The current object (for fluent API support) + * @throws PropelException + */ + public function setCcBlock(CcBlock $v = null) + { + // aggregate_column_relation behavior + if (null !== $this->aCcBlock && $v !== $this->aCcBlock) { + $this->oldCcBlock = $this->aCcBlock; + } + if ($v === null) { + $this->setDbBlockId(NULL); + } else { + $this->setDbBlockId($v->getDbId()); + } + + $this->aCcBlock = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcBlock object, it will not be re-added. + if ($v !== null) { + $v->addCcBlockcontents($this); + } + + + return $this; + } + + + /** + * Get the associated CcBlock object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcBlock The associated CcBlock object. + * @throws PropelException + */ + public function getCcBlock(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcBlock === null && ($this->block_id !== null) && $doQuery) { + $this->aCcBlock = CcBlockQuery::create()->findPk($this->block_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->aCcBlock->addCcBlockcontentss($this); + */ + } + + return $this->aCcBlock; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->block_id = null; + $this->file_id = null; + $this->position = null; + $this->trackoffset = null; + $this->cliplength = null; + $this->cuein = null; + $this->cueout = null; + $this->fadein = null; + $this->fadeout = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCcFiles instanceof Persistent) { + $this->aCcFiles->clearAllReferences($deep); + } + if ($this->aCcBlock instanceof Persistent) { + $this->aCcBlock->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + $this->aCcFiles = null; + $this->aCcBlock = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcBlockcontentsPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + + // aggregate_column_relation behavior + + /** + * Update the aggregate column in the related CcBlock object + * + * @param PropelPDO $con A connection object + */ + protected function updateRelatedCcBlock(PropelPDO $con) + { + if ($ccBlock = $this->getCcBlock()) { + if (!$ccBlock->isAlreadyInSave()) { + $ccBlock->updateDbLength($con); + } + } + if ($this->oldCcBlock) { + $this->oldCcBlock->updateDbLength($con); + $this->oldCcBlock = null; + } + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcBlockcontentsPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcBlockcontentsPeer.php index 6cdb1e265..0deddc615 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcBlockcontentsPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcBlockcontentsPeer.php @@ -1,1396 +1,1442 @@ array ('DbId', 'DbBlockId', 'DbFileId', 'DbPosition', 'DbTrackOffset', 'DbCliplength', 'DbCuein', 'DbCueout', 'DbFadein', 'DbFadeout', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbBlockId', 'dbFileId', 'dbPosition', 'dbTrackOffset', 'dbCliplength', 'dbCuein', 'dbCueout', 'dbFadein', 'dbFadeout', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::BLOCK_ID, self::FILE_ID, self::POSITION, self::TRACKOFFSET, self::CLIPLENGTH, self::CUEIN, self::CUEOUT, self::FADEIN, self::FADEOUT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'BLOCK_ID', 'FILE_ID', 'POSITION', 'TRACKOFFSET', 'CLIPLENGTH', 'CUEIN', 'CUEOUT', 'FADEIN', 'FADEOUT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'block_id', 'file_id', 'position', 'trackoffset', 'cliplength', 'cuein', 'cueout', 'fadein', 'fadeout', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) - ); - - /** - * 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, 'DbBlockId' => 1, 'DbFileId' => 2, 'DbPosition' => 3, 'DbTrackOffset' => 4, 'DbCliplength' => 5, 'DbCuein' => 6, 'DbCueout' => 7, 'DbFadein' => 8, 'DbFadeout' => 9, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbBlockId' => 1, 'dbFileId' => 2, 'dbPosition' => 3, 'dbTrackOffset' => 4, 'dbCliplength' => 5, 'dbCuein' => 6, 'dbCueout' => 7, 'dbFadein' => 8, 'dbFadeout' => 9, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::BLOCK_ID => 1, self::FILE_ID => 2, self::POSITION => 3, self::TRACKOFFSET => 4, self::CLIPLENGTH => 5, self::CUEIN => 6, self::CUEOUT => 7, self::FADEIN => 8, self::FADEOUT => 9, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'BLOCK_ID' => 1, 'FILE_ID' => 2, 'POSITION' => 3, 'TRACKOFFSET' => 4, 'CLIPLENGTH' => 5, 'CUEIN' => 6, 'CUEOUT' => 7, 'FADEIN' => 8, 'FADEOUT' => 9, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'block_id' => 1, 'file_id' => 2, 'position' => 3, 'trackoffset' => 4, 'cliplength' => 5, 'cuein' => 6, 'cueout' => 7, 'fadein' => 8, 'fadeout' => 9, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) - ); - - /** - * 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. CcBlockcontentsPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcBlockcontentsPeer::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(CcBlockcontentsPeer::ID); - $criteria->addSelectColumn(CcBlockcontentsPeer::BLOCK_ID); - $criteria->addSelectColumn(CcBlockcontentsPeer::FILE_ID); - $criteria->addSelectColumn(CcBlockcontentsPeer::POSITION); - $criteria->addSelectColumn(CcBlockcontentsPeer::TRACKOFFSET); - $criteria->addSelectColumn(CcBlockcontentsPeer::CLIPLENGTH); - $criteria->addSelectColumn(CcBlockcontentsPeer::CUEIN); - $criteria->addSelectColumn(CcBlockcontentsPeer::CUEOUT); - $criteria->addSelectColumn(CcBlockcontentsPeer::FADEIN); - $criteria->addSelectColumn(CcBlockcontentsPeer::FADEOUT); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.BLOCK_ID'); - $criteria->addSelectColumn($alias . '.FILE_ID'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.TRACKOFFSET'); - $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(CcBlockcontentsPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcBlockcontentsPeer::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(CcBlockcontentsPeer::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 CcBlockcontents - * @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 = CcBlockcontentsPeer::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 CcBlockcontentsPeer::populateObjects(CcBlockcontentsPeer::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(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcBlockcontentsPeer::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 CcBlockcontents $value A CcBlockcontents object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcBlockcontents $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 CcBlockcontents object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcBlockcontents) { - $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 CcBlockcontents 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 CcBlockcontents 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_blockcontents - * 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 = CcBlockcontentsPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcBlockcontentsPeer::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; - CcBlockcontentsPeer::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 (CcBlockcontents object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcBlockcontentsPeer::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 + CcBlockcontentsPeer::NUM_COLUMNS; - } else { - $cls = CcBlockcontentsPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcBlockcontentsPeer::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(CcBlockcontentsPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcBlockcontentsPeer::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(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcBlockcontentsPeer::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 CcBlock 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 doCountJoinCcBlock(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(CcBlockcontentsPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcBlockcontentsPeer::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(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::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 CcBlockcontents 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 CcBlockcontents 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); - } - - CcBlockcontentsPeer::addSelectColumns($criteria); - $startcol = (CcBlockcontentsPeer::NUM_COLUMNS - CcBlockcontentsPeer::NUM_LAZY_LOAD_COLUMNS); - CcFilesPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcBlockcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcBlockcontentsPeer::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 = CcBlockcontentsPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcBlockcontentsPeer::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 (CcBlockcontents) to $obj2 (CcFiles) - $obj2->addCcBlockcontents($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcBlockcontents objects pre-filled with their CcBlock 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 CcBlockcontents objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCcBlock(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); - } - - CcBlockcontentsPeer::addSelectColumns($criteria); - $startcol = (CcBlockcontentsPeer::NUM_COLUMNS - CcBlockcontentsPeer::NUM_LAZY_LOAD_COLUMNS); - CcBlockPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcBlockcontentsPeer::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 = CcBlockcontentsPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcBlockcontentsPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcBlockPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcBlockPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcBlockPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcBlockcontents) to $obj2 (CcBlock) - $obj2->addCcBlockcontents($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(CcBlockcontentsPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcBlockcontentsPeer::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(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcBlockcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::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 CcBlockcontents 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 CcBlockcontents 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); - } - - CcBlockcontentsPeer::addSelectColumns($criteria); - $startcol2 = (CcBlockcontentsPeer::NUM_COLUMNS - CcBlockcontentsPeer::NUM_LAZY_LOAD_COLUMNS); - - CcFilesPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); - - CcBlockPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + (CcBlockPeer::NUM_COLUMNS - CcBlockPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcBlockcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcBlockcontentsPeer::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 = CcBlockcontentsPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcBlockcontentsPeer::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 (CcBlockcontents) to the collection in $obj2 (CcFiles) - $obj2->addCcBlockcontents($obj1); - } // if joined row not null - - // Add objects for joined CcBlock rows - - $key3 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CcBlockPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CcBlockPeer::getOMClass(false); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CcBlockPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (CcBlockcontents) to the collection in $obj3 (CcBlock) - $obj3->addCcBlockcontents($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(CcBlockcontentsPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcBlockcontentsPeer::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(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::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 CcBlock 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 doCountJoinAllExceptCcBlock(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(CcBlockcontentsPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcBlockcontentsPeer::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(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcBlockcontentsPeer::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 CcBlockcontents 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 CcBlockcontents 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); - } - - CcBlockcontentsPeer::addSelectColumns($criteria); - $startcol2 = (CcBlockcontentsPeer::NUM_COLUMNS - CcBlockcontentsPeer::NUM_LAZY_LOAD_COLUMNS); - - CcBlockPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcBlockPeer::NUM_COLUMNS - CcBlockPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcBlockcontentsPeer::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 = CcBlockcontentsPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcBlockcontentsPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcBlock rows - - $key2 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcBlockPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcBlockPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcBlockPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (CcBlockcontents) to the collection in $obj2 (CcBlock) - $obj2->addCcBlockcontents($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcBlockcontents objects pre-filled with all related objects except CcBlock. - * - * @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 CcBlockcontents objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCcBlock(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); - } - - CcBlockcontentsPeer::addSelectColumns($criteria); - $startcol2 = (CcBlockcontentsPeer::NUM_COLUMNS - CcBlockcontentsPeer::NUM_LAZY_LOAD_COLUMNS); - - CcFilesPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcBlockcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcBlockcontentsPeer::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 = CcBlockcontentsPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcBlockcontentsPeer::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 (CcBlockcontents) to the collection in $obj2 (CcFiles) - $obj2->addCcBlockcontents($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(BaseCcBlockcontentsPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcBlockcontentsPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcBlockcontentsTableMap()); - } - } - - /** - * 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 ? CcBlockcontentsPeer::CLASS_DEFAULT : CcBlockcontentsPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcBlockcontents or Criteria object. - * - * @param mixed $values Criteria or CcBlockcontents 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(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcBlockcontents object - } - - if ($criteria->containsKey(CcBlockcontentsPeer::ID) && $criteria->keyContainsValue(CcBlockcontentsPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcBlockcontentsPeer::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 CcBlockcontents or Criteria object. - * - * @param mixed $values Criteria or CcBlockcontents 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(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcBlockcontentsPeer::ID); - $value = $criteria->remove(CcBlockcontentsPeer::ID); - if ($value) { - $selectCriteria->add(CcBlockcontentsPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcBlockcontentsPeer::TABLE_NAME); - } - - } else { // $values is CcBlockcontents 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_blockcontents 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(CcBlockcontentsPeer::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(CcBlockcontentsPeer::TABLE_NAME, $con, CcBlockcontentsPeer::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). - CcBlockcontentsPeer::clearInstancePool(); - CcBlockcontentsPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcBlockcontents or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcBlockcontents 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(CcBlockcontentsPeer::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. - CcBlockcontentsPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcBlockcontents) { // it's a model object - // invalidate the cache for this single object - CcBlockcontentsPeer::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(CcBlockcontentsPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcBlockcontentsPeer::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); - CcBlockcontentsPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcBlockcontents 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 CcBlockcontents $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(CcBlockcontents $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcBlockcontentsPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcBlockcontentsPeer::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(CcBlockcontentsPeer::DATABASE_NAME, CcBlockcontentsPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcBlockcontents - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcBlockcontentsPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcBlockcontentsPeer::DATABASE_NAME); - $criteria->add(CcBlockcontentsPeer::ID, $pk); - - $v = CcBlockcontentsPeer::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(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcBlockcontentsPeer::DATABASE_NAME); - $criteria->add(CcBlockcontentsPeer::ID, $pks, Criteria::IN); - $objs = CcBlockcontentsPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcBlockcontentsPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_blockcontents'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcBlockcontents'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcBlockcontentsTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 10; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 10; + + /** the column name for the id field */ + const ID = 'cc_blockcontents.id'; + + /** the column name for the block_id field */ + const BLOCK_ID = 'cc_blockcontents.block_id'; + + /** the column name for the file_id field */ + const FILE_ID = 'cc_blockcontents.file_id'; + + /** the column name for the position field */ + const POSITION = 'cc_blockcontents.position'; + + /** the column name for the trackoffset field */ + const TRACKOFFSET = 'cc_blockcontents.trackoffset'; + + /** the column name for the cliplength field */ + const CLIPLENGTH = 'cc_blockcontents.cliplength'; + + /** the column name for the cuein field */ + const CUEIN = 'cc_blockcontents.cuein'; + + /** the column name for the cueout field */ + const CUEOUT = 'cc_blockcontents.cueout'; + + /** the column name for the fadein field */ + const FADEIN = 'cc_blockcontents.fadein'; + + /** the column name for the fadeout field */ + const FADEOUT = 'cc_blockcontents.fadeout'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcBlockcontents objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcBlockcontents[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcBlockcontentsPeer::$fieldNames[CcBlockcontentsPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbBlockId', 'DbFileId', 'DbPosition', 'DbTrackOffset', 'DbCliplength', 'DbCuein', 'DbCueout', 'DbFadein', 'DbFadeout', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbBlockId', 'dbFileId', 'dbPosition', 'dbTrackOffset', 'dbCliplength', 'dbCuein', 'dbCueout', 'dbFadein', 'dbFadeout', ), + BasePeer::TYPE_COLNAME => array (CcBlockcontentsPeer::ID, CcBlockcontentsPeer::BLOCK_ID, CcBlockcontentsPeer::FILE_ID, CcBlockcontentsPeer::POSITION, CcBlockcontentsPeer::TRACKOFFSET, CcBlockcontentsPeer::CLIPLENGTH, CcBlockcontentsPeer::CUEIN, CcBlockcontentsPeer::CUEOUT, CcBlockcontentsPeer::FADEIN, CcBlockcontentsPeer::FADEOUT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'BLOCK_ID', 'FILE_ID', 'POSITION', 'TRACKOFFSET', 'CLIPLENGTH', 'CUEIN', 'CUEOUT', 'FADEIN', 'FADEOUT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'block_id', 'file_id', 'position', 'trackoffset', 'cliplength', 'cuein', 'cueout', 'fadein', 'fadeout', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcBlockcontentsPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbBlockId' => 1, 'DbFileId' => 2, 'DbPosition' => 3, 'DbTrackOffset' => 4, 'DbCliplength' => 5, 'DbCuein' => 6, 'DbCueout' => 7, 'DbFadein' => 8, 'DbFadeout' => 9, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbBlockId' => 1, 'dbFileId' => 2, 'dbPosition' => 3, 'dbTrackOffset' => 4, 'dbCliplength' => 5, 'dbCuein' => 6, 'dbCueout' => 7, 'dbFadein' => 8, 'dbFadeout' => 9, ), + BasePeer::TYPE_COLNAME => array (CcBlockcontentsPeer::ID => 0, CcBlockcontentsPeer::BLOCK_ID => 1, CcBlockcontentsPeer::FILE_ID => 2, CcBlockcontentsPeer::POSITION => 3, CcBlockcontentsPeer::TRACKOFFSET => 4, CcBlockcontentsPeer::CLIPLENGTH => 5, CcBlockcontentsPeer::CUEIN => 6, CcBlockcontentsPeer::CUEOUT => 7, CcBlockcontentsPeer::FADEIN => 8, CcBlockcontentsPeer::FADEOUT => 9, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'BLOCK_ID' => 1, 'FILE_ID' => 2, 'POSITION' => 3, 'TRACKOFFSET' => 4, 'CLIPLENGTH' => 5, 'CUEIN' => 6, 'CUEOUT' => 7, 'FADEIN' => 8, 'FADEOUT' => 9, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'block_id' => 1, 'file_id' => 2, 'position' => 3, 'trackoffset' => 4, 'cliplength' => 5, 'cuein' => 6, 'cueout' => 7, 'fadein' => 8, 'fadeout' => 9, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcBlockcontentsPeer::getFieldNames($toType); + $key = isset(CcBlockcontentsPeer::$fieldKeys[$fromType][$name]) ? CcBlockcontentsPeer::$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(CcBlockcontentsPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcBlockcontentsPeer::$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 CcBlockcontentsPeer::$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. CcBlockcontentsPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcBlockcontentsPeer::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(CcBlockcontentsPeer::ID); + $criteria->addSelectColumn(CcBlockcontentsPeer::BLOCK_ID); + $criteria->addSelectColumn(CcBlockcontentsPeer::FILE_ID); + $criteria->addSelectColumn(CcBlockcontentsPeer::POSITION); + $criteria->addSelectColumn(CcBlockcontentsPeer::TRACKOFFSET); + $criteria->addSelectColumn(CcBlockcontentsPeer::CLIPLENGTH); + $criteria->addSelectColumn(CcBlockcontentsPeer::CUEIN); + $criteria->addSelectColumn(CcBlockcontentsPeer::CUEOUT); + $criteria->addSelectColumn(CcBlockcontentsPeer::FADEIN); + $criteria->addSelectColumn(CcBlockcontentsPeer::FADEOUT); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.block_id'); + $criteria->addSelectColumn($alias . '.file_id'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.trackoffset'); + $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(CcBlockcontentsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcBlockcontentsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcBlockcontentsPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcBlockcontentsPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcBlockcontents + * @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 = CcBlockcontentsPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcBlockcontentsPeer::populateObjects(CcBlockcontentsPeer::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 directly (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(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcBlockcontentsPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcBlockcontentsPeer::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 CcBlockcontents $obj A CcBlockcontents object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcBlockcontentsPeer::$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 CcBlockcontents object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcBlockcontents) { + $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 CcBlockcontents object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcBlockcontentsPeer::$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 CcBlockcontents 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(CcBlockcontentsPeer::$instances[$key])) { + return CcBlockcontentsPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcBlockcontentsPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcBlockcontentsPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_blockcontents + * 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 = CcBlockcontentsPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcBlockcontentsPeer::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; + CcBlockcontentsPeer::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 (CcBlockcontents object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcBlockcontentsPeer::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 + CcBlockcontentsPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcBlockcontentsPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcBlockcontentsPeer::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(CcBlockcontentsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcBlockcontentsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcBlockcontentsPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcBlockcontentsPeer::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 CcBlock 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 doCountJoinCcBlock(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(CcBlockcontentsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcBlockcontentsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcBlockcontentsPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::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 CcBlockcontents 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 CcBlockcontents 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(CcBlockcontentsPeer::DATABASE_NAME); + } + + CcBlockcontentsPeer::addSelectColumns($criteria); + $startcol = CcBlockcontentsPeer::NUM_HYDRATE_COLUMNS; + CcFilesPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcBlockcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcBlockcontentsPeer::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 = CcBlockcontentsPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcBlockcontentsPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcFilesPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcFilesPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcFilesPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcBlockcontents) to $obj2 (CcFiles) + $obj2->addCcBlockcontents($obj1); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcBlockcontents objects pre-filled with their CcBlock 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 CcBlockcontents objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcBlock(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(CcBlockcontentsPeer::DATABASE_NAME); + } + + CcBlockcontentsPeer::addSelectColumns($criteria); + $startcol = CcBlockcontentsPeer::NUM_HYDRATE_COLUMNS; + CcBlockPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcBlockcontentsPeer::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 = CcBlockcontentsPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcBlockcontentsPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcBlockPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcBlockPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcBlockPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcBlockcontents) to $obj2 (CcBlock) + $obj2->addCcBlockcontents($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(CcBlockcontentsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcBlockcontentsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcBlockcontentsPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcBlockcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::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 CcBlockcontents 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 CcBlockcontents 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(CcBlockcontentsPeer::DATABASE_NAME); + } + + CcBlockcontentsPeer::addSelectColumns($criteria); + $startcol2 = CcBlockcontentsPeer::NUM_HYDRATE_COLUMNS; + + CcFilesPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcFilesPeer::NUM_HYDRATE_COLUMNS; + + CcBlockPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcBlockPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcBlockcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcBlockcontentsPeer::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 = CcBlockcontentsPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcBlockcontentsPeer::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(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcFilesPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcBlockcontents) to the collection in $obj2 (CcFiles) + $obj2->addCcBlockcontents($obj1); + } // if joined row not null + + // Add objects for joined CcBlock rows + + $key3 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcBlockPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcBlockPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcBlockPeer::addInstanceToPool($obj3, $key3); + } // if obj3 loaded + + // Add the $obj1 (CcBlockcontents) to the collection in $obj3 (CcBlock) + $obj3->addCcBlockcontents($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(CcBlockcontentsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcBlockcontentsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(CcBlockcontentsPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::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 CcBlock 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 doCountJoinAllExceptCcBlock(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(CcBlockcontentsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcBlockcontentsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(CcBlockcontentsPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcBlockcontentsPeer::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 CcBlockcontents 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 CcBlockcontents 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(CcBlockcontentsPeer::DATABASE_NAME); + } + + CcBlockcontentsPeer::addSelectColumns($criteria); + $startcol2 = CcBlockcontentsPeer::NUM_HYDRATE_COLUMNS; + + CcBlockPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcBlockPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcBlockcontentsPeer::BLOCK_ID, CcBlockPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcBlockcontentsPeer::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 = CcBlockcontentsPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcBlockcontentsPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcBlock rows + + $key2 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcBlockPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcBlockPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcBlockPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcBlockcontents) to the collection in $obj2 (CcBlock) + $obj2->addCcBlockcontents($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcBlockcontents objects pre-filled with all related objects except CcBlock. + * + * @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 CcBlockcontents objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcBlock(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(CcBlockcontentsPeer::DATABASE_NAME); + } + + CcBlockcontentsPeer::addSelectColumns($criteria); + $startcol2 = CcBlockcontentsPeer::NUM_HYDRATE_COLUMNS; + + CcFilesPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcFilesPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcBlockcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcBlockcontentsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcBlockcontentsPeer::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 = CcBlockcontentsPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcBlockcontentsPeer::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(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcFilesPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcBlockcontents) to the collection in $obj2 (CcFiles) + $obj2->addCcBlockcontents($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(CcBlockcontentsPeer::DATABASE_NAME)->getTable(CcBlockcontentsPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcBlockcontentsPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcBlockcontentsPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcBlockcontentsTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcBlockcontentsPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcBlockcontents or Criteria object. + * + * @param mixed $values Criteria or CcBlockcontents 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(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcBlockcontents object + } + + if ($criteria->containsKey(CcBlockcontentsPeer::ID) && $criteria->keyContainsValue(CcBlockcontentsPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcBlockcontentsPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcBlockcontentsPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcBlockcontents or Criteria object. + * + * @param mixed $values Criteria or CcBlockcontents 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(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcBlockcontentsPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcBlockcontentsPeer::ID); + $value = $criteria->remove(CcBlockcontentsPeer::ID); + if ($value) { + $selectCriteria->add(CcBlockcontentsPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcBlockcontentsPeer::TABLE_NAME); + } + + } else { // $values is CcBlockcontents object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcBlockcontentsPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_blockcontents table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcBlockcontentsPeer::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(CcBlockcontentsPeer::TABLE_NAME, $con, CcBlockcontentsPeer::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). + CcBlockcontentsPeer::clearInstancePool(); + CcBlockcontentsPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcBlockcontents or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcBlockcontents 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(CcBlockcontentsPeer::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. + CcBlockcontentsPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcBlockcontents) { // it's a model object + // invalidate the cache for this single object + CcBlockcontentsPeer::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(CcBlockcontentsPeer::DATABASE_NAME); + $criteria->add(CcBlockcontentsPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcBlockcontentsPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcBlockcontentsPeer::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); + CcBlockcontentsPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcBlockcontents 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 CcBlockcontents $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcBlockcontentsPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcBlockcontentsPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcBlockcontentsPeer::DATABASE_NAME, CcBlockcontentsPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcBlockcontents + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcBlockcontentsPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcBlockcontentsPeer::DATABASE_NAME); + $criteria->add(CcBlockcontentsPeer::ID, $pk); + + $v = CcBlockcontentsPeer::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 + * @return CcBlockcontents[] + * @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(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcBlockcontentsPeer::DATABASE_NAME); + $criteria->add(CcBlockcontentsPeer::ID, $pks, Criteria::IN); + $objs = CcBlockcontentsPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcBlockcontentsPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcBlockcontentsQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcBlockcontentsQuery.php index f648e3640..a98b2846f 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcBlockcontentsQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcBlockcontentsQuery.php @@ -1,675 +1,921 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcBlockcontents|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcBlockcontentsPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcBlockcontents|CcBlockcontents[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcBlockcontentsPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcBlockcontentsQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcBlockcontentsPeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcBlockcontents A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcBlockcontentsQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcBlockcontentsPeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcBlockcontents A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "block_id", "file_id", "position", "trackoffset", "cliplength", "cuein", "cueout", "fadein", "fadeout" FROM "cc_blockcontents" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcBlockcontents(); + $obj->hydrate($row); + CcBlockcontentsPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcBlockcontentsQuery 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(CcBlockcontentsPeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * Filter the query on the block_id column - * - * @param int|array $dbBlockId 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 CcBlockcontentsQuery The current query, for fluid interface - */ - public function filterByDbBlockId($dbBlockId = null, $comparison = null) - { - if (is_array($dbBlockId)) { - $useMinMax = false; - if (isset($dbBlockId['min'])) { - $this->addUsingAlias(CcBlockcontentsPeer::BLOCK_ID, $dbBlockId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbBlockId['max'])) { - $this->addUsingAlias(CcBlockcontentsPeer::BLOCK_ID, $dbBlockId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcBlockcontentsPeer::BLOCK_ID, $dbBlockId, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcBlockcontents|CcBlockcontents[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * 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 CcBlockcontentsQuery 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(CcBlockcontentsPeer::FILE_ID, $dbFileId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbFileId['max'])) { - $this->addUsingAlias(CcBlockcontentsPeer::FILE_ID, $dbFileId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcBlockcontentsPeer::FILE_ID, $dbFileId, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * 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 CcBlockcontentsQuery 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(CcBlockcontentsPeer::POSITION, $dbPosition['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbPosition['max'])) { - $this->addUsingAlias(CcBlockcontentsPeer::POSITION, $dbPosition['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcBlockcontentsPeer::POSITION, $dbPosition, $comparison); - } + /** + * 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|CcBlockcontents[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query on the trackoffset column - * - * @param double|array $dbTrackOffset 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 CcBlockcontentsQuery The current query, for fluid interface - */ - public function filterByDbTrackOffset($dbTrackOffset = null, $comparison = null) - { - if (is_array($dbTrackOffset)) { - $useMinMax = false; - if (isset($dbTrackOffset['min'])) { - $this->addUsingAlias(CcBlockcontentsPeer::TRACKOFFSET, $dbTrackOffset['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbTrackOffset['max'])) { - $this->addUsingAlias(CcBlockcontentsPeer::TRACKOFFSET, $dbTrackOffset['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcBlockcontentsPeer::TRACKOFFSET, $dbTrackOffset, $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Filter the query on the cliplength column - * - * @param string $dbCliplength 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 CcBlockcontentsQuery The current query, for fluid interface - */ - public function filterByDbCliplength($dbCliplength = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbCliplength)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbCliplength)) { - $dbCliplength = str_replace('*', '%', $dbCliplength); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcBlockcontentsPeer::CLIPLENGTH, $dbCliplength, $comparison); - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcBlockcontentsQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { - /** - * Filter the query on the cuein column - * - * @param string $dbCuein 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 CcBlockcontentsQuery The current query, for fluid interface - */ - public function filterByDbCuein($dbCuein = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbCuein)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbCuein)) { - $dbCuein = str_replace('*', '%', $dbCuein); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcBlockcontentsPeer::CUEIN, $dbCuein, $comparison); - } + return $this->addUsingAlias(CcBlockcontentsPeer::ID, $key, Criteria::EQUAL); + } - /** - * Filter the query on the cueout column - * - * @param string $dbCueout 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 CcBlockcontentsQuery The current query, for fluid interface - */ - public function filterByDbCueout($dbCueout = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbCueout)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbCueout)) { - $dbCueout = str_replace('*', '%', $dbCueout); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcBlockcontentsPeer::CUEOUT, $dbCueout, $comparison); - } + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return CcBlockcontentsQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { - /** - * 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 CcBlockcontentsQuery 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(CcBlockcontentsPeer::FADEIN, $dbFadein['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbFadein['max'])) { - $this->addUsingAlias(CcBlockcontentsPeer::FADEIN, $dbFadein['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcBlockcontentsPeer::FADEIN, $dbFadein, $comparison); - } + return $this->addUsingAlias(CcBlockcontentsPeer::ID, $keys, Criteria::IN); + } - /** - * 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 CcBlockcontentsQuery 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(CcBlockcontentsPeer::FADEOUT, $dbFadeout['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbFadeout['max'])) { - $this->addUsingAlias(CcBlockcontentsPeer::FADEOUT, $dbFadeout['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcBlockcontentsPeer::FADEOUT, $dbFadeout, $comparison); - } + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockcontentsQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcBlockcontentsPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcBlockcontentsPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * 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 CcBlockcontentsQuery The current query, for fluid interface - */ - public function filterByCcFiles($ccFiles, $comparison = null) - { - return $this - ->addUsingAlias(CcBlockcontentsPeer::FILE_ID, $ccFiles->getDbId(), $comparison); - } + return $this->addUsingAlias(CcBlockcontentsPeer::ID, $dbId, $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 CcBlockcontentsQuery 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; - } + /** + * Filter the query on the block_id column + * + * Example usage: + * + * $query->filterByDbBlockId(1234); // WHERE block_id = 1234 + * $query->filterByDbBlockId(array(12, 34)); // WHERE block_id IN (12, 34) + * $query->filterByDbBlockId(array('min' => 12)); // WHERE block_id >= 12 + * $query->filterByDbBlockId(array('max' => 12)); // WHERE block_id <= 12 + * + * + * @see filterByCcBlock() + * + * @param mixed $dbBlockId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockcontentsQuery The current query, for fluid interface + */ + public function filterByDbBlockId($dbBlockId = null, $comparison = null) + { + if (is_array($dbBlockId)) { + $useMinMax = false; + if (isset($dbBlockId['min'])) { + $this->addUsingAlias(CcBlockcontentsPeer::BLOCK_ID, $dbBlockId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbBlockId['max'])) { + $this->addUsingAlias(CcBlockcontentsPeer::BLOCK_ID, $dbBlockId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * 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'); - } + return $this->addUsingAlias(CcBlockcontentsPeer::BLOCK_ID, $dbBlockId, $comparison); + } - /** - * Filter the query by a related CcBlock object - * - * @param CcBlock $ccBlock the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcBlockcontentsQuery The current query, for fluid interface - */ - public function filterByCcBlock($ccBlock, $comparison = null) - { - return $this - ->addUsingAlias(CcBlockcontentsPeer::BLOCK_ID, $ccBlock->getDbId(), $comparison); - } + /** + * Filter the query on the file_id column + * + * Example usage: + * + * $query->filterByDbFileId(1234); // WHERE file_id = 1234 + * $query->filterByDbFileId(array(12, 34)); // WHERE file_id IN (12, 34) + * $query->filterByDbFileId(array('min' => 12)); // WHERE file_id >= 12 + * $query->filterByDbFileId(array('max' => 12)); // WHERE file_id <= 12 + * + * + * @see filterByCcFiles() + * + * @param mixed $dbFileId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockcontentsQuery 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(CcBlockcontentsPeer::FILE_ID, $dbFileId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbFileId['max'])) { + $this->addUsingAlias(CcBlockcontentsPeer::FILE_ID, $dbFileId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Adds a JOIN clause to the query using the CcBlock relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcBlockcontentsQuery The current query, for fluid interface - */ - public function joinCcBlock($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcBlock'); - - // 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, 'CcBlock'); - } - - return $this; - } + return $this->addUsingAlias(CcBlockcontentsPeer::FILE_ID, $dbFileId, $comparison); + } - /** - * Use the CcBlock relation CcBlock 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 CcBlockQuery A secondary query class using the current class as primary query - */ - public function useCcBlockQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcBlock($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcBlock', 'CcBlockQuery'); - } + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByDbPosition(1234); // WHERE position = 1234 + * $query->filterByDbPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByDbPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByDbPosition(array('max' => 12)); // WHERE position <= 12 + * + * + * @param mixed $dbPosition The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockcontentsQuery 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(CcBlockcontentsPeer::POSITION, $dbPosition['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbPosition['max'])) { + $this->addUsingAlias(CcBlockcontentsPeer::POSITION, $dbPosition['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Exclude object from result - * - * @param CcBlockcontents $ccBlockcontents Object to remove from the list of results - * - * @return CcBlockcontentsQuery The current query, for fluid interface - */ - public function prune($ccBlockcontents = null) - { - if ($ccBlockcontents) { - $this->addUsingAlias(CcBlockcontentsPeer::ID, $ccBlockcontents->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + return $this->addUsingAlias(CcBlockcontentsPeer::POSITION, $dbPosition, $comparison); + } - /** - * Code to execute before every DELETE statement - * - * @param PropelPDO $con The connection object used by the query - */ - protected function basePreDelete(PropelPDO $con) - { - // aggregate_column_relation behavior - $this->findRelatedCcBlocks($con); - - return $this->preDelete($con); - } + /** + * Filter the query on the trackoffset column + * + * Example usage: + * + * $query->filterByDbTrackOffset(1234); // WHERE trackoffset = 1234 + * $query->filterByDbTrackOffset(array(12, 34)); // WHERE trackoffset IN (12, 34) + * $query->filterByDbTrackOffset(array('min' => 12)); // WHERE trackoffset >= 12 + * $query->filterByDbTrackOffset(array('max' => 12)); // WHERE trackoffset <= 12 + * + * + * @param mixed $dbTrackOffset The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockcontentsQuery The current query, for fluid interface + */ + public function filterByDbTrackOffset($dbTrackOffset = null, $comparison = null) + { + if (is_array($dbTrackOffset)) { + $useMinMax = false; + if (isset($dbTrackOffset['min'])) { + $this->addUsingAlias(CcBlockcontentsPeer::TRACKOFFSET, $dbTrackOffset['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbTrackOffset['max'])) { + $this->addUsingAlias(CcBlockcontentsPeer::TRACKOFFSET, $dbTrackOffset['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Code to execute after every DELETE statement - * - * @param int $affectedRows the number of deleted rows - * @param PropelPDO $con The connection object used by the query - */ - protected function basePostDelete($affectedRows, PropelPDO $con) - { - // aggregate_column_relation behavior - $this->updateRelatedCcBlocks($con); - - return $this->postDelete($affectedRows, $con); - } + return $this->addUsingAlias(CcBlockcontentsPeer::TRACKOFFSET, $dbTrackOffset, $comparison); + } - /** - * Code to execute before every UPDATE statement - * - * @param array $values The associatiove array of columns and values for the update - * @param PropelPDO $con The connection object used by the query - * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), ortherwise it is a series of save() calls on all the found objects - */ - protected function basePreUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false) - { - // aggregate_column_relation behavior - $this->findRelatedCcBlocks($con); - - return $this->preUpdate($values, $con, $forceIndividualSaves); - } + /** + * Filter the query on the cliplength column + * + * Example usage: + * + * $query->filterByDbCliplength('fooValue'); // WHERE cliplength = 'fooValue' + * $query->filterByDbCliplength('%fooValue%'); // WHERE cliplength LIKE '%fooValue%' + * + * + * @param string $dbCliplength 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 CcBlockcontentsQuery The current query, for fluid interface + */ + public function filterByDbCliplength($dbCliplength = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbCliplength)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbCliplength)) { + $dbCliplength = str_replace('*', '%', $dbCliplength); + $comparison = Criteria::LIKE; + } + } - /** - * Code to execute after every UPDATE statement - * - * @param int $affectedRows the number of udated rows - * @param PropelPDO $con The connection object used by the query - */ - protected function basePostUpdate($affectedRows, PropelPDO $con) - { - // aggregate_column_relation behavior - $this->updateRelatedCcBlocks($con); - - return $this->postUpdate($affectedRows, $con); - } + return $this->addUsingAlias(CcBlockcontentsPeer::CLIPLENGTH, $dbCliplength, $comparison); + } - // aggregate_column_relation behavior - - /** - * Finds the related CcBlock objects and keep them for later - * - * @param PropelPDO $con A connection object - */ - protected function findRelatedCcBlocks($con) - { - $criteria = clone $this; - if ($this->useAliasInSQL) { - $alias = $this->getModelAlias(); - $criteria->removeAlias($alias); - } else { - $alias = ''; - } - $this->ccBlocks = CcBlockQuery::create() - ->joinCcBlockcontents($alias) - ->mergeWith($criteria) - ->find($con); - } - - protected function updateRelatedCcBlocks($con) - { - foreach ($this->ccBlocks as $ccBlock) { - $ccBlock->updateDbLength($con); - } - $this->ccBlocks = array(); - } + /** + * Filter the query on the cuein column + * + * Example usage: + * + * $query->filterByDbCuein('fooValue'); // WHERE cuein = 'fooValue' + * $query->filterByDbCuein('%fooValue%'); // WHERE cuein LIKE '%fooValue%' + * + * + * @param string $dbCuein 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 CcBlockcontentsQuery The current query, for fluid interface + */ + public function filterByDbCuein($dbCuein = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbCuein)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbCuein)) { + $dbCuein = str_replace('*', '%', $dbCuein); + $comparison = Criteria::LIKE; + } + } -} // BaseCcBlockcontentsQuery + return $this->addUsingAlias(CcBlockcontentsPeer::CUEIN, $dbCuein, $comparison); + } + + /** + * Filter the query on the cueout column + * + * Example usage: + * + * $query->filterByDbCueout('fooValue'); // WHERE cueout = 'fooValue' + * $query->filterByDbCueout('%fooValue%'); // WHERE cueout LIKE '%fooValue%' + * + * + * @param string $dbCueout 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 CcBlockcontentsQuery The current query, for fluid interface + */ + public function filterByDbCueout($dbCueout = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbCueout)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbCueout)) { + $dbCueout = str_replace('*', '%', $dbCueout); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcBlockcontentsPeer::CUEOUT, $dbCueout, $comparison); + } + + /** + * Filter the query on the fadein column + * + * Example usage: + * + * $query->filterByDbFadein('2011-03-14'); // WHERE fadein = '2011-03-14' + * $query->filterByDbFadein('now'); // WHERE fadein = '2011-03-14' + * $query->filterByDbFadein(array('max' => 'yesterday')); // WHERE fadein < '2011-03-13' + * + * + * @param mixed $dbFadein The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockcontentsQuery 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(CcBlockcontentsPeer::FADEIN, $dbFadein['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbFadein['max'])) { + $this->addUsingAlias(CcBlockcontentsPeer::FADEIN, $dbFadein['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcBlockcontentsPeer::FADEIN, $dbFadein, $comparison); + } + + /** + * Filter the query on the fadeout column + * + * Example usage: + * + * $query->filterByDbFadeout('2011-03-14'); // WHERE fadeout = '2011-03-14' + * $query->filterByDbFadeout('now'); // WHERE fadeout = '2011-03-14' + * $query->filterByDbFadeout(array('max' => 'yesterday')); // WHERE fadeout < '2011-03-13' + * + * + * @param mixed $dbFadeout The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockcontentsQuery 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(CcBlockcontentsPeer::FADEOUT, $dbFadeout['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbFadeout['max'])) { + $this->addUsingAlias(CcBlockcontentsPeer::FADEOUT, $dbFadeout['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcBlockcontentsPeer::FADEOUT, $dbFadeout, $comparison); + } + + /** + * Filter the query by a related CcFiles object + * + * @param CcFiles|PropelObjectCollection $ccFiles The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockcontentsQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcFiles($ccFiles, $comparison = null) + { + if ($ccFiles instanceof CcFiles) { + return $this + ->addUsingAlias(CcBlockcontentsPeer::FILE_ID, $ccFiles->getDbId(), $comparison); + } elseif ($ccFiles instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcBlockcontentsPeer::FILE_ID, $ccFiles->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcFiles() only accepts arguments of type CcFiles or PropelCollection'); + } + } + + /** + * 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 CcBlockcontentsQuery The current query, for fluid interface + */ + public function joinCcFiles($relationAlias = null, $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 \Airtime\CcFilesQuery A secondary query class using the current class as primary query + */ + public function useCcFilesQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcFiles($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcFiles', '\Airtime\CcFilesQuery'); + } + + /** + * Filter the query by a related CcBlock object + * + * @param CcBlock|PropelObjectCollection $ccBlock The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockcontentsQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcBlock($ccBlock, $comparison = null) + { + if ($ccBlock instanceof CcBlock) { + return $this + ->addUsingAlias(CcBlockcontentsPeer::BLOCK_ID, $ccBlock->getDbId(), $comparison); + } elseif ($ccBlock instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcBlockcontentsPeer::BLOCK_ID, $ccBlock->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcBlock() only accepts arguments of type CcBlock or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcBlock relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcBlockcontentsQuery The current query, for fluid interface + */ + public function joinCcBlock($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcBlock'); + + // 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, 'CcBlock'); + } + + return $this; + } + + /** + * Use the CcBlock relation CcBlock 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 \Airtime\CcBlockQuery A secondary query class using the current class as primary query + */ + public function useCcBlockQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcBlock($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcBlock', '\Airtime\CcBlockQuery'); + } + + /** + * Exclude object from result + * + * @param CcBlockcontents $ccBlockcontents Object to remove from the list of results + * + * @return CcBlockcontentsQuery The current query, for fluid interface + */ + public function prune($ccBlockcontents = null) + { + if ($ccBlockcontents) { + $this->addUsingAlias(CcBlockcontentsPeer::ID, $ccBlockcontents->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Code to execute before every DELETE statement + * + * @param PropelPDO $con The connection object used by the query + */ + protected function basePreDelete(PropelPDO $con) + { + // aggregate_column_relation behavior + $this->findRelatedCcBlocks($con); + + return $this->preDelete($con); + } + + /** + * Code to execute after every DELETE statement + * + * @param int $affectedRows the number of deleted rows + * @param PropelPDO $con The connection object used by the query + */ + protected function basePostDelete($affectedRows, PropelPDO $con) + { + // aggregate_column_relation behavior + $this->updateRelatedCcBlocks($con); + + return $this->postDelete($affectedRows, $con); + } + + /** + * Code to execute before every UPDATE statement + * + * @param array $values The associative array of columns and values for the update + * @param PropelPDO $con The connection object used by the query + * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), otherwise it is a series of save() calls on all the found objects + */ + protected function basePreUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false) + { + // aggregate_column_relation behavior + $this->findRelatedCcBlocks($con); + + return $this->preUpdate($values, $con, $forceIndividualSaves); + } + + /** + * Code to execute after every UPDATE statement + * + * @param int $affectedRows the number of updated rows + * @param PropelPDO $con The connection object used by the query + */ + protected function basePostUpdate($affectedRows, PropelPDO $con) + { + // aggregate_column_relation behavior + $this->updateRelatedCcBlocks($con); + + return $this->postUpdate($affectedRows, $con); + } + + // aggregate_column_relation behavior + + /** + * Finds the related CcBlock objects and keep them for later + * + * @param PropelPDO $con A connection object + */ + protected function findRelatedCcBlocks($con) + { + $criteria = clone $this; + if ($this->useAliasInSQL) { + $alias = $this->getModelAlias(); + $criteria->removeAlias($alias); + } else { + $alias = ''; + } + $this->ccBlocks = CcBlockQuery::create() + ->joinCcBlockcontents($alias) + ->mergeWith($criteria) + ->find($con); + } + + protected function updateRelatedCcBlocks($con) + { + foreach ($this->ccBlocks as $ccBlock) { + $ccBlock->updateDbLength($con); + } + $this->ccBlocks = array(); + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteria.php b/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteria.php index 2982a3b86..67706f104 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteria.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteria.php @@ -1,1001 +1,1179 @@ id; - } - - /** - * Get the [criteria] column value. - * - * @return string - */ - public function getDbCriteria() - { - return $this->criteria; - } - - /** - * Get the [modifier] column value. - * - * @return string - */ - public function getDbModifier() - { - return $this->modifier; - } - - /** - * Get the [value] column value. - * - * @return string - */ - public function getDbValue() - { - return $this->value; - } - - /** - * Get the [extra] column value. - * - * @return string - */ - public function getDbExtra() - { - return $this->extra; - } - - /** - * Get the [block_id] column value. - * - * @return int - */ - public function getDbBlockId() - { - return $this->block_id; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcBlockcriteria 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[] = CcBlockcriteriaPeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [criteria] column. - * - * @param string $v new value - * @return CcBlockcriteria The current object (for fluent API support) - */ - public function setDbCriteria($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->criteria !== $v) { - $this->criteria = $v; - $this->modifiedColumns[] = CcBlockcriteriaPeer::CRITERIA; - } - - return $this; - } // setDbCriteria() - - /** - * Set the value of [modifier] column. - * - * @param string $v new value - * @return CcBlockcriteria The current object (for fluent API support) - */ - public function setDbModifier($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->modifier !== $v) { - $this->modifier = $v; - $this->modifiedColumns[] = CcBlockcriteriaPeer::MODIFIER; - } - - return $this; - } // setDbModifier() - - /** - * Set the value of [value] column. - * - * @param string $v new value - * @return CcBlockcriteria The current object (for fluent API support) - */ - public function setDbValue($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->value !== $v) { - $this->value = $v; - $this->modifiedColumns[] = CcBlockcriteriaPeer::VALUE; - } - - return $this; - } // setDbValue() - - /** - * Set the value of [extra] column. - * - * @param string $v new value - * @return CcBlockcriteria The current object (for fluent API support) - */ - public function setDbExtra($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->extra !== $v) { - $this->extra = $v; - $this->modifiedColumns[] = CcBlockcriteriaPeer::EXTRA; - } - - return $this; - } // setDbExtra() - - /** - * Set the value of [block_id] column. - * - * @param int $v new value - * @return CcBlockcriteria The current object (for fluent API support) - */ - public function setDbBlockId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->block_id !== $v) { - $this->block_id = $v; - $this->modifiedColumns[] = CcBlockcriteriaPeer::BLOCK_ID; - } - - if ($this->aCcBlock !== null && $this->aCcBlock->getDbId() !== $v) { - $this->aCcBlock = null; - } - - return $this; - } // setDbBlockId() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return TRUE - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->criteria = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->modifier = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->value = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->extra = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->block_id = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 6; // 6 = CcBlockcriteriaPeer::NUM_COLUMNS - CcBlockcriteriaPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcBlockcriteria 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->aCcBlock !== null && $this->block_id !== $this->aCcBlock->getDbId()) { - $this->aCcBlock = 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(CcBlockcriteriaPeer::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 = CcBlockcriteriaPeer::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->aCcBlock = 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(CcBlockcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcBlockcriteriaQuery::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(CcBlockcriteriaPeer::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); - CcBlockcriteriaPeer::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->aCcBlock !== null) { - if ($this->aCcBlock->isModified() || $this->aCcBlock->isNew()) { - $affectedRows += $this->aCcBlock->save($con); - } - $this->setCcBlock($this->aCcBlock); - } - - if ($this->isNew() ) { - $this->modifiedColumns[] = CcBlockcriteriaPeer::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(CcBlockcriteriaPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcBlockcriteriaPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows += 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows += CcBlockcriteriaPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcBlock !== null) { - if (!$this->aCcBlock->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcBlock->getValidationFailures()); - } - } - - - if (($retval = CcBlockcriteriaPeer::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 = CcBlockcriteriaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch($pos) { - case 0: - return $this->getDbId(); - break; - case 1: - return $this->getDbCriteria(); - break; - case 2: - return $this->getDbModifier(); - break; - case 3: - return $this->getDbValue(); - break; - case 4: - return $this->getDbExtra(); - break; - case 5: - return $this->getDbBlockId(); - 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 = CcBlockcriteriaPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbCriteria(), - $keys[2] => $this->getDbModifier(), - $keys[3] => $this->getDbValue(), - $keys[4] => $this->getDbExtra(), - $keys[5] => $this->getDbBlockId(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCcBlock) { - $result['CcBlock'] = $this->aCcBlock->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 = CcBlockcriteriaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - return $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch($pos) { - case 0: - $this->setDbId($value); - break; - case 1: - $this->setDbCriteria($value); - break; - case 2: - $this->setDbModifier($value); - break; - case 3: - $this->setDbValue($value); - break; - case 4: - $this->setDbExtra($value); - break; - case 5: - $this->setDbBlockId($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 = CcBlockcriteriaPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbCriteria($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbModifier($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbValue($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbExtra($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbBlockId($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(CcBlockcriteriaPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcBlockcriteriaPeer::ID)) $criteria->add(CcBlockcriteriaPeer::ID, $this->id); - if ($this->isColumnModified(CcBlockcriteriaPeer::CRITERIA)) $criteria->add(CcBlockcriteriaPeer::CRITERIA, $this->criteria); - if ($this->isColumnModified(CcBlockcriteriaPeer::MODIFIER)) $criteria->add(CcBlockcriteriaPeer::MODIFIER, $this->modifier); - if ($this->isColumnModified(CcBlockcriteriaPeer::VALUE)) $criteria->add(CcBlockcriteriaPeer::VALUE, $this->value); - if ($this->isColumnModified(CcBlockcriteriaPeer::EXTRA)) $criteria->add(CcBlockcriteriaPeer::EXTRA, $this->extra); - if ($this->isColumnModified(CcBlockcriteriaPeer::BLOCK_ID)) $criteria->add(CcBlockcriteriaPeer::BLOCK_ID, $this->block_id); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(CcBlockcriteriaPeer::DATABASE_NAME); - $criteria->add(CcBlockcriteriaPeer::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 CcBlockcriteria (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false) - { - $copyObj->setDbCriteria($this->criteria); - $copyObj->setDbModifier($this->modifier); - $copyObj->setDbValue($this->value); - $copyObj->setDbExtra($this->extra); - $copyObj->setDbBlockId($this->block_id); - - $copyObj->setNew(true); - $copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return CcBlockcriteria 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 CcBlockcriteriaPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcBlockcriteriaPeer(); - } - return self::$peer; - } - - /** - * Declares an association between this object and a CcBlock object. - * - * @param CcBlock $v - * @return CcBlockcriteria The current object (for fluent API support) - * @throws PropelException - */ - public function setCcBlock(CcBlock $v = null) - { - if ($v === null) { - $this->setDbBlockId(NULL); - } else { - $this->setDbBlockId($v->getDbId()); - } - - $this->aCcBlock = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcBlock object, it will not be re-added. - if ($v !== null) { - $v->addCcBlockcriteria($this); - } - - return $this; - } - - - /** - * Get the associated CcBlock object - * - * @param PropelPDO Optional Connection object. - * @return CcBlock The associated CcBlock object. - * @throws PropelException - */ - public function getCcBlock(PropelPDO $con = null) - { - if ($this->aCcBlock === null && ($this->block_id !== null)) { - $this->aCcBlock = CcBlockQuery::create()->findPk($this->block_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->aCcBlock->addCcBlockcriterias($this); - */ - } - return $this->aCcBlock; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->criteria = null; - $this->modifier = null; - $this->value = null; - $this->extra = null; - $this->block_id = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all collections of referencing foreign keys. - * - * This method is a user-space workaround for PHP's inability to garbage collect objects - * with circular references. This is currently necessary when using Propel in certain - * daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all associated objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep) { - } // if ($deep) - - $this->aCcBlock = 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); - } - -} // BaseCcBlockcriteria + /** + * Peer class name + */ + const PEER = 'Airtime\\CcBlockcriteriaPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcBlockcriteriaPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the criteria field. + * @var string + */ + protected $criteria; + + /** + * The value for the modifier field. + * @var string + */ + protected $modifier; + + /** + * The value for the value field. + * @var string + */ + protected $value; + + /** + * The value for the extra field. + * @var string + */ + protected $extra; + + /** + * The value for the block_id field. + * @var int + */ + protected $block_id; + + /** + * @var CcBlock + */ + protected $aCcBlock; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * Get the [id] column value. + * + * @return int + */ + public function getDbId() + { + + return $this->id; + } + + /** + * Get the [criteria] column value. + * + * @return string + */ + public function getDbCriteria() + { + + return $this->criteria; + } + + /** + * Get the [modifier] column value. + * + * @return string + */ + public function getDbModifier() + { + + return $this->modifier; + } + + /** + * Get the [value] column value. + * + * @return string + */ + public function getDbValue() + { + + return $this->value; + } + + /** + * Get the [extra] column value. + * + * @return string + */ + public function getDbExtra() + { + + return $this->extra; + } + + /** + * Get the [block_id] column value. + * + * @return int + */ + public function getDbBlockId() + { + + return $this->block_id; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcBlockcriteria The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcBlockcriteriaPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [criteria] column. + * + * @param string $v new value + * @return CcBlockcriteria The current object (for fluent API support) + */ + public function setDbCriteria($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->criteria !== $v) { + $this->criteria = $v; + $this->modifiedColumns[] = CcBlockcriteriaPeer::CRITERIA; + } + + + return $this; + } // setDbCriteria() + + /** + * Set the value of [modifier] column. + * + * @param string $v new value + * @return CcBlockcriteria The current object (for fluent API support) + */ + public function setDbModifier($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->modifier !== $v) { + $this->modifier = $v; + $this->modifiedColumns[] = CcBlockcriteriaPeer::MODIFIER; + } + + + return $this; + } // setDbModifier() + + /** + * Set the value of [value] column. + * + * @param string $v new value + * @return CcBlockcriteria The current object (for fluent API support) + */ + public function setDbValue($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->value !== $v) { + $this->value = $v; + $this->modifiedColumns[] = CcBlockcriteriaPeer::VALUE; + } + + + return $this; + } // setDbValue() + + /** + * Set the value of [extra] column. + * + * @param string $v new value + * @return CcBlockcriteria The current object (for fluent API support) + */ + public function setDbExtra($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->extra !== $v) { + $this->extra = $v; + $this->modifiedColumns[] = CcBlockcriteriaPeer::EXTRA; + } + + + return $this; + } // setDbExtra() + + /** + * Set the value of [block_id] column. + * + * @param int $v new value + * @return CcBlockcriteria The current object (for fluent API support) + */ + public function setDbBlockId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->block_id !== $v) { + $this->block_id = $v; + $this->modifiedColumns[] = CcBlockcriteriaPeer::BLOCK_ID; + } + + if ($this->aCcBlock !== null && $this->aCcBlock->getDbId() !== $v) { + $this->aCcBlock = null; + } + + + return $this; + } // setDbBlockId() + + /** + * 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 resultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false) + { + try { + + $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; + $this->criteria = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->modifier = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->value = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->extra = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->block_id = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 6; // 6 = CcBlockcriteriaPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcBlockcriteria 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->aCcBlock !== null && $this->block_id !== $this->aCcBlock->getDbId()) { + $this->aCcBlock = 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(CcBlockcriteriaPeer::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 = CcBlockcriteriaPeer::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->aCcBlock = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(CcBlockcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcBlockcriteriaQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcBlockcriteriaPeer::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); + CcBlockcriteriaPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcBlock !== null) { + if ($this->aCcBlock->isModified() || $this->aCcBlock->isNew()) { + $affectedRows += $this->aCcBlock->save($con); + } + $this->setCcBlock($this->aCcBlock); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcBlockcriteriaPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcBlockcriteriaPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_blockcriteria_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcBlockcriteriaPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcBlockcriteriaPeer::CRITERIA)) { + $modifiedColumns[':p' . $index++] = '"criteria"'; + } + if ($this->isColumnModified(CcBlockcriteriaPeer::MODIFIER)) { + $modifiedColumns[':p' . $index++] = '"modifier"'; + } + if ($this->isColumnModified(CcBlockcriteriaPeer::VALUE)) { + $modifiedColumns[':p' . $index++] = '"value"'; + } + if ($this->isColumnModified(CcBlockcriteriaPeer::EXTRA)) { + $modifiedColumns[':p' . $index++] = '"extra"'; + } + if ($this->isColumnModified(CcBlockcriteriaPeer::BLOCK_ID)) { + $modifiedColumns[':p' . $index++] = '"block_id"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_blockcriteria" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"criteria"': + $stmt->bindValue($identifier, $this->criteria, PDO::PARAM_STR); + break; + case '"modifier"': + $stmt->bindValue($identifier, $this->modifier, PDO::PARAM_STR); + break; + case '"value"': + $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); + break; + case '"extra"': + $stmt->bindValue($identifier, $this->extra, PDO::PARAM_STR); + break; + case '"block_id"': + $stmt->bindValue($identifier, $this->block_id, PDO::PARAM_INT); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcBlock !== null) { + if (!$this->aCcBlock->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcBlock->getValidationFailures()); + } + } + + + if (($retval = CcBlockcriteriaPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcBlockcriteriaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getDbId(); + break; + case 1: + return $this->getDbCriteria(); + break; + case 2: + return $this->getDbModifier(); + break; + case 3: + return $this->getDbValue(); + break; + case 4: + return $this->getDbExtra(); + break; + case 5: + return $this->getDbBlockId(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcBlockcriteria'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcBlockcriteria'][$this->getPrimaryKey()] = true; + $keys = CcBlockcriteriaPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbCriteria(), + $keys[2] => $this->getDbModifier(), + $keys[3] => $this->getDbValue(), + $keys[4] => $this->getDbExtra(), + $keys[5] => $this->getDbBlockId(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcBlock) { + $result['CcBlock'] = $this->aCcBlock->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcBlockcriteriaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setDbId($value); + break; + case 1: + $this->setDbCriteria($value); + break; + case 2: + $this->setDbModifier($value); + break; + case 3: + $this->setDbValue($value); + break; + case 4: + $this->setDbExtra($value); + break; + case 5: + $this->setDbBlockId($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcBlockcriteriaPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbCriteria($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbModifier($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbValue($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbExtra($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbBlockId($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(CcBlockcriteriaPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcBlockcriteriaPeer::ID)) $criteria->add(CcBlockcriteriaPeer::ID, $this->id); + if ($this->isColumnModified(CcBlockcriteriaPeer::CRITERIA)) $criteria->add(CcBlockcriteriaPeer::CRITERIA, $this->criteria); + if ($this->isColumnModified(CcBlockcriteriaPeer::MODIFIER)) $criteria->add(CcBlockcriteriaPeer::MODIFIER, $this->modifier); + if ($this->isColumnModified(CcBlockcriteriaPeer::VALUE)) $criteria->add(CcBlockcriteriaPeer::VALUE, $this->value); + if ($this->isColumnModified(CcBlockcriteriaPeer::EXTRA)) $criteria->add(CcBlockcriteriaPeer::EXTRA, $this->extra); + if ($this->isColumnModified(CcBlockcriteriaPeer::BLOCK_ID)) $criteria->add(CcBlockcriteriaPeer::BLOCK_ID, $this->block_id); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(CcBlockcriteriaPeer::DATABASE_NAME); + $criteria->add(CcBlockcriteriaPeer::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 CcBlockcriteria (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbCriteria($this->getDbCriteria()); + $copyObj->setDbModifier($this->getDbModifier()); + $copyObj->setDbValue($this->getDbValue()); + $copyObj->setDbExtra($this->getDbExtra()); + $copyObj->setDbBlockId($this->getDbBlockId()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcBlockcriteria 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 CcBlockcriteriaPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcBlockcriteriaPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a CcBlock object. + * + * @param CcBlock $v + * @return CcBlockcriteria The current object (for fluent API support) + * @throws PropelException + */ + public function setCcBlock(CcBlock $v = null) + { + if ($v === null) { + $this->setDbBlockId(NULL); + } else { + $this->setDbBlockId($v->getDbId()); + } + + $this->aCcBlock = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcBlock object, it will not be re-added. + if ($v !== null) { + $v->addCcBlockcriteria($this); + } + + + return $this; + } + + + /** + * Get the associated CcBlock object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcBlock The associated CcBlock object. + * @throws PropelException + */ + public function getCcBlock(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcBlock === null && ($this->block_id !== null) && $doQuery) { + $this->aCcBlock = CcBlockQuery::create()->findPk($this->block_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->aCcBlock->addCcBlockcriterias($this); + */ + } + + return $this->aCcBlock; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->criteria = null; + $this->modifier = null; + $this->value = null; + $this->extra = null; + $this->block_id = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCcBlock instanceof Persistent) { + $this->aCcBlock->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + $this->aCcBlock = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcBlockcriteriaPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteriaPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteriaPeer.php index a523024ad..3509f2918 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteriaPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteriaPeer.php @@ -1,989 +1,1028 @@ array ('DbId', 'DbCriteria', 'DbModifier', 'DbValue', 'DbExtra', 'DbBlockId', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbCriteria', 'dbModifier', 'dbValue', 'dbExtra', 'dbBlockId', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::CRITERIA, self::MODIFIER, self::VALUE, self::EXTRA, self::BLOCK_ID, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CRITERIA', 'MODIFIER', 'VALUE', 'EXTRA', 'BLOCK_ID', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'criteria', 'modifier', 'value', 'extra', 'block_id', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbCriteria' => 1, 'DbModifier' => 2, 'DbValue' => 3, 'DbExtra' => 4, 'DbBlockId' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbCriteria' => 1, 'dbModifier' => 2, 'dbValue' => 3, 'dbExtra' => 4, 'dbBlockId' => 5, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::CRITERIA => 1, self::MODIFIER => 2, self::VALUE => 3, self::EXTRA => 4, self::BLOCK_ID => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CRITERIA' => 1, 'MODIFIER' => 2, 'VALUE' => 3, 'EXTRA' => 4, 'BLOCK_ID' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'criteria' => 1, 'modifier' => 2, 'value' => 3, 'extra' => 4, 'block_id' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - static public function translateFieldName($name, $fromType, $toType) - { - $toNames = self::getFieldNames($toType); - $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); - } - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - */ - - static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, self::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - return self::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. CcBlockcriteriaPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcBlockcriteriaPeer::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(CcBlockcriteriaPeer::ID); - $criteria->addSelectColumn(CcBlockcriteriaPeer::CRITERIA); - $criteria->addSelectColumn(CcBlockcriteriaPeer::MODIFIER); - $criteria->addSelectColumn(CcBlockcriteriaPeer::VALUE); - $criteria->addSelectColumn(CcBlockcriteriaPeer::EXTRA); - $criteria->addSelectColumn(CcBlockcriteriaPeer::BLOCK_ID); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.CRITERIA'); - $criteria->addSelectColumn($alias . '.MODIFIER'); - $criteria->addSelectColumn($alias . '.VALUE'); - $criteria->addSelectColumn($alias . '.EXTRA'); - $criteria->addSelectColumn($alias . '.BLOCK_ID'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CcBlockcriteriaPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcBlockcriteriaPeer::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(CcBlockcriteriaPeer::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 CcBlockcriteria - * @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 = CcBlockcriteriaPeer::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 CcBlockcriteriaPeer::populateObjects(CcBlockcriteriaPeer::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(CcBlockcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcBlockcriteriaPeer::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 CcBlockcriteria $value A CcBlockcriteria object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcBlockcriteria $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 CcBlockcriteria object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcBlockcriteria) { - $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 CcBlockcriteria 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 CcBlockcriteria 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_blockcriteria - * 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 = CcBlockcriteriaPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcBlockcriteriaPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcBlockcriteriaPeer::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; - CcBlockcriteriaPeer::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 (CcBlockcriteria object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcBlockcriteriaPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcBlockcriteriaPeer::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 + CcBlockcriteriaPeer::NUM_COLUMNS; - } else { - $cls = CcBlockcriteriaPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcBlockcriteriaPeer::addInstanceToPool($obj, $key); - } - return array($obj, $col); - } - - /** - * Returns the number of rows matching criteria, joining the related CcBlock 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 doCountJoinCcBlock(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(CcBlockcriteriaPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcBlockcriteriaPeer::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(CcBlockcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcBlockcriteriaPeer::BLOCK_ID, CcBlockPeer::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 CcBlockcriteria objects pre-filled with their CcBlock 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 CcBlockcriteria objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCcBlock(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); - } - - CcBlockcriteriaPeer::addSelectColumns($criteria); - $startcol = (CcBlockcriteriaPeer::NUM_COLUMNS - CcBlockcriteriaPeer::NUM_LAZY_LOAD_COLUMNS); - CcBlockPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcBlockcriteriaPeer::BLOCK_ID, CcBlockPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcBlockcriteriaPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcBlockcriteriaPeer::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 = CcBlockcriteriaPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcBlockcriteriaPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcBlockPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcBlockPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcBlockPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcBlockcriteria) to $obj2 (CcBlock) - $obj2->addCcBlockcriteria($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(CcBlockcriteriaPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcBlockcriteriaPeer::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(CcBlockcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcBlockcriteriaPeer::BLOCK_ID, CcBlockPeer::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 CcBlockcriteria 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 CcBlockcriteria 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); - } - - CcBlockcriteriaPeer::addSelectColumns($criteria); - $startcol2 = (CcBlockcriteriaPeer::NUM_COLUMNS - CcBlockcriteriaPeer::NUM_LAZY_LOAD_COLUMNS); - - CcBlockPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcBlockPeer::NUM_COLUMNS - CcBlockPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcBlockcriteriaPeer::BLOCK_ID, CcBlockPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcBlockcriteriaPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcBlockcriteriaPeer::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 = CcBlockcriteriaPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcBlockcriteriaPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcBlock rows - - $key2 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcBlockPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcBlockPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcBlockPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (CcBlockcriteria) to the collection in $obj2 (CcBlock) - $obj2->addCcBlockcriteria($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(BaseCcBlockcriteriaPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcBlockcriteriaPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcBlockcriteriaTableMap()); - } - } - - /** - * 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 ? CcBlockcriteriaPeer::CLASS_DEFAULT : CcBlockcriteriaPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcBlockcriteria or Criteria object. - * - * @param mixed $values Criteria or CcBlockcriteria 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(CcBlockcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcBlockcriteria object - } - - if ($criteria->containsKey(CcBlockcriteriaPeer::ID) && $criteria->keyContainsValue(CcBlockcriteriaPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcBlockcriteriaPeer::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 CcBlockcriteria or Criteria object. - * - * @param mixed $values Criteria or CcBlockcriteria 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(CcBlockcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcBlockcriteriaPeer::ID); - $value = $criteria->remove(CcBlockcriteriaPeer::ID); - if ($value) { - $selectCriteria->add(CcBlockcriteriaPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcBlockcriteriaPeer::TABLE_NAME); - } - - } else { // $values is CcBlockcriteria 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_blockcriteria 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(CcBlockcriteriaPeer::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(CcBlockcriteriaPeer::TABLE_NAME, $con, CcBlockcriteriaPeer::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). - CcBlockcriteriaPeer::clearInstancePool(); - CcBlockcriteriaPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcBlockcriteria or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcBlockcriteria 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(CcBlockcriteriaPeer::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. - CcBlockcriteriaPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcBlockcriteria) { // it's a model object - // invalidate the cache for this single object - CcBlockcriteriaPeer::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(CcBlockcriteriaPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcBlockcriteriaPeer::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); - CcBlockcriteriaPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcBlockcriteria 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 CcBlockcriteria $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(CcBlockcriteria $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcBlockcriteriaPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcBlockcriteriaPeer::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(CcBlockcriteriaPeer::DATABASE_NAME, CcBlockcriteriaPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcBlockcriteria - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcBlockcriteriaPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcBlockcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcBlockcriteriaPeer::DATABASE_NAME); - $criteria->add(CcBlockcriteriaPeer::ID, $pk); - - $v = CcBlockcriteriaPeer::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(CcBlockcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcBlockcriteriaPeer::DATABASE_NAME); - $criteria->add(CcBlockcriteriaPeer::ID, $pks, Criteria::IN); - $objs = CcBlockcriteriaPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcBlockcriteriaPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_blockcriteria'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcBlockcriteria'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcBlockcriteriaTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 6; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 6; + + /** the column name for the id field */ + const ID = 'cc_blockcriteria.id'; + + /** the column name for the criteria field */ + const CRITERIA = 'cc_blockcriteria.criteria'; + + /** the column name for the modifier field */ + const MODIFIER = 'cc_blockcriteria.modifier'; + + /** the column name for the value field */ + const VALUE = 'cc_blockcriteria.value'; + + /** the column name for the extra field */ + const EXTRA = 'cc_blockcriteria.extra'; + + /** the column name for the block_id field */ + const BLOCK_ID = 'cc_blockcriteria.block_id'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcBlockcriteria objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcBlockcriteria[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcBlockcriteriaPeer::$fieldNames[CcBlockcriteriaPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbCriteria', 'DbModifier', 'DbValue', 'DbExtra', 'DbBlockId', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbCriteria', 'dbModifier', 'dbValue', 'dbExtra', 'dbBlockId', ), + BasePeer::TYPE_COLNAME => array (CcBlockcriteriaPeer::ID, CcBlockcriteriaPeer::CRITERIA, CcBlockcriteriaPeer::MODIFIER, CcBlockcriteriaPeer::VALUE, CcBlockcriteriaPeer::EXTRA, CcBlockcriteriaPeer::BLOCK_ID, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CRITERIA', 'MODIFIER', 'VALUE', 'EXTRA', 'BLOCK_ID', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'criteria', 'modifier', 'value', 'extra', 'block_id', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcBlockcriteriaPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbCriteria' => 1, 'DbModifier' => 2, 'DbValue' => 3, 'DbExtra' => 4, 'DbBlockId' => 5, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbCriteria' => 1, 'dbModifier' => 2, 'dbValue' => 3, 'dbExtra' => 4, 'dbBlockId' => 5, ), + BasePeer::TYPE_COLNAME => array (CcBlockcriteriaPeer::ID => 0, CcBlockcriteriaPeer::CRITERIA => 1, CcBlockcriteriaPeer::MODIFIER => 2, CcBlockcriteriaPeer::VALUE => 3, CcBlockcriteriaPeer::EXTRA => 4, CcBlockcriteriaPeer::BLOCK_ID => 5, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CRITERIA' => 1, 'MODIFIER' => 2, 'VALUE' => 3, 'EXTRA' => 4, 'BLOCK_ID' => 5, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'criteria' => 1, 'modifier' => 2, 'value' => 3, 'extra' => 4, 'block_id' => 5, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) + ); + + /** + * Translates a fieldname to another type + * + * @param string $name field name + * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME + * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM + * @param string $toType One of the class type constants + * @return string translated name of the field. + * @throws PropelException - if the specified name could not be found in the fieldname mappings. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcBlockcriteriaPeer::getFieldNames($toType); + $key = isset(CcBlockcriteriaPeer::$fieldKeys[$fromType][$name]) ? CcBlockcriteriaPeer::$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(CcBlockcriteriaPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcBlockcriteriaPeer::$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 CcBlockcriteriaPeer::$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. CcBlockcriteriaPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcBlockcriteriaPeer::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(CcBlockcriteriaPeer::ID); + $criteria->addSelectColumn(CcBlockcriteriaPeer::CRITERIA); + $criteria->addSelectColumn(CcBlockcriteriaPeer::MODIFIER); + $criteria->addSelectColumn(CcBlockcriteriaPeer::VALUE); + $criteria->addSelectColumn(CcBlockcriteriaPeer::EXTRA); + $criteria->addSelectColumn(CcBlockcriteriaPeer::BLOCK_ID); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.criteria'); + $criteria->addSelectColumn($alias . '.modifier'); + $criteria->addSelectColumn($alias . '.value'); + $criteria->addSelectColumn($alias . '.extra'); + $criteria->addSelectColumn($alias . '.block_id'); + } + } + + /** + * Returns the number of rows matching criteria. + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. + * @param PropelPDO $con + * @return int Number of matching rows. + */ + public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) + { + // we may modify criteria, so copy it first + $criteria = clone $criteria; + + // We need to set the primary table name, since in the case that there are no WHERE columns + // it will be impossible for the BasePeer::createSelectSql() method to determine which + // tables go into the FROM clause. + $criteria->setPrimaryTableName(CcBlockcriteriaPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcBlockcriteriaPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcBlockcriteriaPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcBlockcriteriaPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcBlockcriteria + * @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 = CcBlockcriteriaPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcBlockcriteriaPeer::populateObjects(CcBlockcriteriaPeer::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 directly (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(CcBlockcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcBlockcriteriaPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcBlockcriteriaPeer::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 CcBlockcriteria $obj A CcBlockcriteria object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcBlockcriteriaPeer::$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 CcBlockcriteria object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcBlockcriteria) { + $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 CcBlockcriteria object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcBlockcriteriaPeer::$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 CcBlockcriteria 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(CcBlockcriteriaPeer::$instances[$key])) { + return CcBlockcriteriaPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcBlockcriteriaPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcBlockcriteriaPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_blockcriteria + * 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 = CcBlockcriteriaPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcBlockcriteriaPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcBlockcriteriaPeer::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; + CcBlockcriteriaPeer::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 (CcBlockcriteria object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcBlockcriteriaPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcBlockcriteriaPeer::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 + CcBlockcriteriaPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcBlockcriteriaPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcBlockcriteriaPeer::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + + /** + * Returns the number of rows matching criteria, joining the related CcBlock 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 doCountJoinCcBlock(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(CcBlockcriteriaPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcBlockcriteriaPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcBlockcriteriaPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcBlockcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcBlockcriteriaPeer::BLOCK_ID, CcBlockPeer::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 CcBlockcriteria objects pre-filled with their CcBlock 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 CcBlockcriteria objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcBlock(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(CcBlockcriteriaPeer::DATABASE_NAME); + } + + CcBlockcriteriaPeer::addSelectColumns($criteria); + $startcol = CcBlockcriteriaPeer::NUM_HYDRATE_COLUMNS; + CcBlockPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcBlockcriteriaPeer::BLOCK_ID, CcBlockPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcBlockcriteriaPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcBlockcriteriaPeer::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 = CcBlockcriteriaPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcBlockcriteriaPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcBlockPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcBlockPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcBlockPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcBlockcriteria) to $obj2 (CcBlock) + $obj2->addCcBlockcriteria($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(CcBlockcriteriaPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcBlockcriteriaPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcBlockcriteriaPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcBlockcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcBlockcriteriaPeer::BLOCK_ID, CcBlockPeer::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 CcBlockcriteria 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 CcBlockcriteria 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(CcBlockcriteriaPeer::DATABASE_NAME); + } + + CcBlockcriteriaPeer::addSelectColumns($criteria); + $startcol2 = CcBlockcriteriaPeer::NUM_HYDRATE_COLUMNS; + + CcBlockPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcBlockPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcBlockcriteriaPeer::BLOCK_ID, CcBlockPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcBlockcriteriaPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcBlockcriteriaPeer::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 = CcBlockcriteriaPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcBlockcriteriaPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcBlock rows + + $key2 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcBlockPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcBlockPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcBlockPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcBlockcriteria) to the collection in $obj2 (CcBlock) + $obj2->addCcBlockcriteria($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(CcBlockcriteriaPeer::DATABASE_NAME)->getTable(CcBlockcriteriaPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcBlockcriteriaPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcBlockcriteriaPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcBlockcriteriaTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcBlockcriteriaPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcBlockcriteria or Criteria object. + * + * @param mixed $values Criteria or CcBlockcriteria 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(CcBlockcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcBlockcriteria object + } + + if ($criteria->containsKey(CcBlockcriteriaPeer::ID) && $criteria->keyContainsValue(CcBlockcriteriaPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcBlockcriteriaPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcBlockcriteriaPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcBlockcriteria or Criteria object. + * + * @param mixed $values Criteria or CcBlockcriteria 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(CcBlockcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcBlockcriteriaPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcBlockcriteriaPeer::ID); + $value = $criteria->remove(CcBlockcriteriaPeer::ID); + if ($value) { + $selectCriteria->add(CcBlockcriteriaPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcBlockcriteriaPeer::TABLE_NAME); + } + + } else { // $values is CcBlockcriteria object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcBlockcriteriaPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_blockcriteria table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcBlockcriteriaPeer::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(CcBlockcriteriaPeer::TABLE_NAME, $con, CcBlockcriteriaPeer::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). + CcBlockcriteriaPeer::clearInstancePool(); + CcBlockcriteriaPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcBlockcriteria or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcBlockcriteria 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(CcBlockcriteriaPeer::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. + CcBlockcriteriaPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcBlockcriteria) { // it's a model object + // invalidate the cache for this single object + CcBlockcriteriaPeer::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(CcBlockcriteriaPeer::DATABASE_NAME); + $criteria->add(CcBlockcriteriaPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcBlockcriteriaPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcBlockcriteriaPeer::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); + CcBlockcriteriaPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcBlockcriteria 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 CcBlockcriteria $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcBlockcriteriaPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcBlockcriteriaPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcBlockcriteriaPeer::DATABASE_NAME, CcBlockcriteriaPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcBlockcriteria + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcBlockcriteriaPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcBlockcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcBlockcriteriaPeer::DATABASE_NAME); + $criteria->add(CcBlockcriteriaPeer::ID, $pk); + + $v = CcBlockcriteriaPeer::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 + * @return CcBlockcriteria[] + * @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(CcBlockcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcBlockcriteriaPeer::DATABASE_NAME); + $criteria->add(CcBlockcriteriaPeer::ID, $pks, Criteria::IN); + $objs = CcBlockcriteriaPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcBlockcriteriaPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteriaQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteriaQuery.php index 9baabbd74..6de069098 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteriaQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcBlockcriteriaQuery.php @@ -1,372 +1,552 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcBlockcriteria|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcBlockcriteriaPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcBlockcriteria|CcBlockcriteria[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcBlockcriteriaPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcBlockcriteriaPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcBlockcriteriaQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcBlockcriteriaPeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcBlockcriteria A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcBlockcriteriaQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcBlockcriteriaPeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcBlockcriteria A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "criteria", "modifier", "value", "extra", "block_id" FROM "cc_blockcriteria" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcBlockcriteria(); + $obj->hydrate($row); + CcBlockcriteriaPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcBlockcriteriaQuery 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(CcBlockcriteriaPeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * Filter the query on the criteria column - * - * @param string $dbCriteria The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcBlockcriteriaQuery The current query, for fluid interface - */ - public function filterByDbCriteria($dbCriteria = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbCriteria)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbCriteria)) { - $dbCriteria = str_replace('*', '%', $dbCriteria); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcBlockcriteriaPeer::CRITERIA, $dbCriteria, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcBlockcriteria|CcBlockcriteria[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Filter the query on the modifier column - * - * @param string $dbModifier The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcBlockcriteriaQuery The current query, for fluid interface - */ - public function filterByDbModifier($dbModifier = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbModifier)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbModifier)) { - $dbModifier = str_replace('*', '%', $dbModifier); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcBlockcriteriaPeer::MODIFIER, $dbModifier, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query on the value column - * - * @param string $dbValue The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcBlockcriteriaQuery The current query, for fluid interface - */ - public function filterByDbValue($dbValue = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbValue)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbValue)) { - $dbValue = str_replace('*', '%', $dbValue); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcBlockcriteriaPeer::VALUE, $dbValue, $comparison); - } + /** + * 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|CcBlockcriteria[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query on the extra column - * - * @param string $dbExtra The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcBlockcriteriaQuery The current query, for fluid interface - */ - public function filterByDbExtra($dbExtra = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbExtra)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbExtra)) { - $dbExtra = str_replace('*', '%', $dbExtra); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcBlockcriteriaPeer::EXTRA, $dbExtra, $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Filter the query on the block_id column - * - * @param int|array $dbBlockId 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 CcBlockcriteriaQuery The current query, for fluid interface - */ - public function filterByDbBlockId($dbBlockId = null, $comparison = null) - { - if (is_array($dbBlockId)) { - $useMinMax = false; - if (isset($dbBlockId['min'])) { - $this->addUsingAlias(CcBlockcriteriaPeer::BLOCK_ID, $dbBlockId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbBlockId['max'])) { - $this->addUsingAlias(CcBlockcriteriaPeer::BLOCK_ID, $dbBlockId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcBlockcriteriaPeer::BLOCK_ID, $dbBlockId, $comparison); - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcBlockcriteriaQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { - /** - * Filter the query by a related CcBlock object - * - * @param CcBlock $ccBlock the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcBlockcriteriaQuery The current query, for fluid interface - */ - public function filterByCcBlock($ccBlock, $comparison = null) - { - return $this - ->addUsingAlias(CcBlockcriteriaPeer::BLOCK_ID, $ccBlock->getDbId(), $comparison); - } + return $this->addUsingAlias(CcBlockcriteriaPeer::ID, $key, Criteria::EQUAL); + } - /** - * Adds a JOIN clause to the query using the CcBlock relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcBlockcriteriaQuery The current query, for fluid interface - */ - public function joinCcBlock($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcBlock'); - - // 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, 'CcBlock'); - } - - return $this; - } + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return CcBlockcriteriaQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { - /** - * Use the CcBlock relation CcBlock 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 CcBlockQuery A secondary query class using the current class as primary query - */ - public function useCcBlockQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcBlock($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcBlock', 'CcBlockQuery'); - } + return $this->addUsingAlias(CcBlockcriteriaPeer::ID, $keys, Criteria::IN); + } - /** - * Exclude object from result - * - * @param CcBlockcriteria $ccBlockcriteria Object to remove from the list of results - * - * @return CcBlockcriteriaQuery The current query, for fluid interface - */ - public function prune($ccBlockcriteria = null) - { - if ($ccBlockcriteria) { - $this->addUsingAlias(CcBlockcriteriaPeer::ID, $ccBlockcriteria->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockcriteriaQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcBlockcriteriaPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcBlockcriteriaPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } -} // BaseCcBlockcriteriaQuery + return $this->addUsingAlias(CcBlockcriteriaPeer::ID, $dbId, $comparison); + } + + /** + * Filter the query on the criteria column + * + * Example usage: + * + * $query->filterByDbCriteria('fooValue'); // WHERE criteria = 'fooValue' + * $query->filterByDbCriteria('%fooValue%'); // WHERE criteria LIKE '%fooValue%' + * + * + * @param string $dbCriteria The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockcriteriaQuery The current query, for fluid interface + */ + public function filterByDbCriteria($dbCriteria = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbCriteria)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbCriteria)) { + $dbCriteria = str_replace('*', '%', $dbCriteria); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcBlockcriteriaPeer::CRITERIA, $dbCriteria, $comparison); + } + + /** + * Filter the query on the modifier column + * + * Example usage: + * + * $query->filterByDbModifier('fooValue'); // WHERE modifier = 'fooValue' + * $query->filterByDbModifier('%fooValue%'); // WHERE modifier LIKE '%fooValue%' + * + * + * @param string $dbModifier The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockcriteriaQuery The current query, for fluid interface + */ + public function filterByDbModifier($dbModifier = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbModifier)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbModifier)) { + $dbModifier = str_replace('*', '%', $dbModifier); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcBlockcriteriaPeer::MODIFIER, $dbModifier, $comparison); + } + + /** + * Filter the query on the value column + * + * Example usage: + * + * $query->filterByDbValue('fooValue'); // WHERE value = 'fooValue' + * $query->filterByDbValue('%fooValue%'); // WHERE value LIKE '%fooValue%' + * + * + * @param string $dbValue The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockcriteriaQuery The current query, for fluid interface + */ + public function filterByDbValue($dbValue = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbValue)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbValue)) { + $dbValue = str_replace('*', '%', $dbValue); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcBlockcriteriaPeer::VALUE, $dbValue, $comparison); + } + + /** + * Filter the query on the extra column + * + * Example usage: + * + * $query->filterByDbExtra('fooValue'); // WHERE extra = 'fooValue' + * $query->filterByDbExtra('%fooValue%'); // WHERE extra LIKE '%fooValue%' + * + * + * @param string $dbExtra The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockcriteriaQuery The current query, for fluid interface + */ + public function filterByDbExtra($dbExtra = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbExtra)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbExtra)) { + $dbExtra = str_replace('*', '%', $dbExtra); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcBlockcriteriaPeer::EXTRA, $dbExtra, $comparison); + } + + /** + * Filter the query on the block_id column + * + * Example usage: + * + * $query->filterByDbBlockId(1234); // WHERE block_id = 1234 + * $query->filterByDbBlockId(array(12, 34)); // WHERE block_id IN (12, 34) + * $query->filterByDbBlockId(array('min' => 12)); // WHERE block_id >= 12 + * $query->filterByDbBlockId(array('max' => 12)); // WHERE block_id <= 12 + * + * + * @see filterByCcBlock() + * + * @param mixed $dbBlockId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockcriteriaQuery The current query, for fluid interface + */ + public function filterByDbBlockId($dbBlockId = null, $comparison = null) + { + if (is_array($dbBlockId)) { + $useMinMax = false; + if (isset($dbBlockId['min'])) { + $this->addUsingAlias(CcBlockcriteriaPeer::BLOCK_ID, $dbBlockId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbBlockId['max'])) { + $this->addUsingAlias(CcBlockcriteriaPeer::BLOCK_ID, $dbBlockId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcBlockcriteriaPeer::BLOCK_ID, $dbBlockId, $comparison); + } + + /** + * Filter the query by a related CcBlock object + * + * @param CcBlock|PropelObjectCollection $ccBlock The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcBlockcriteriaQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcBlock($ccBlock, $comparison = null) + { + if ($ccBlock instanceof CcBlock) { + return $this + ->addUsingAlias(CcBlockcriteriaPeer::BLOCK_ID, $ccBlock->getDbId(), $comparison); + } elseif ($ccBlock instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcBlockcriteriaPeer::BLOCK_ID, $ccBlock->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcBlock() only accepts arguments of type CcBlock or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcBlock relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcBlockcriteriaQuery The current query, for fluid interface + */ + public function joinCcBlock($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcBlock'); + + // 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, 'CcBlock'); + } + + return $this; + } + + /** + * Use the CcBlock relation CcBlock 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 \Airtime\CcBlockQuery A secondary query class using the current class as primary query + */ + public function useCcBlockQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcBlock($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcBlock', '\Airtime\CcBlockQuery'); + } + + /** + * Exclude object from result + * + * @param CcBlockcriteria $ccBlockcriteria Object to remove from the list of results + * + * @return CcBlockcriteriaQuery The current query, for fluid interface + */ + public function prune($ccBlockcriteria = null) + { + if ($ccBlockcriteria) { + $this->addUsingAlias(CcBlockcriteriaPeer::ID, $ccBlockcriteria->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcCountry.php b/airtime_mvc/application/models/airtime/om/BaseCcCountry.php index 3f92c5493..dc4d0924d 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcCountry.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcCountry.php @@ -1,708 +1,828 @@ isocode; - } - - /** - * Get the [name] column value. - * - * @return string - */ - public function getDbName() - { - return $this->name; - } - - /** - * Set the value of [isocode] column. - * - * @param string $v new value - * @return CcCountry The current object (for fluent API support) - */ - public function setDbIsoCode($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->isocode !== $v) { - $this->isocode = $v; - $this->modifiedColumns[] = CcCountryPeer::ISOCODE; - } - - return $this; - } // setDbIsoCode() - - /** - * Set the value of [name] column. - * - * @param string $v new value - * @return CcCountry The current object (for fluent API support) - */ - public function setDbName($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->name !== $v) { - $this->name = $v; - $this->modifiedColumns[] = CcCountryPeer::NAME; - } - - return $this; - } // setDbName() - - /** - * 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->isocode = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null; - $this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 2; // 2 = CcCountryPeer::NUM_COLUMNS - CcCountryPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcCountry 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(CcCountryPeer::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 = CcCountryPeer::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(CcCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcCountryQuery::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(CcCountryPeer::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); - CcCountryPeer::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 = CcCountryPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CcCountryPeer::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 = CcCountryPeer::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->getDbIsoCode(); - break; - case 1: - return $this->getDbName(); - 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 = CcCountryPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbIsoCode(), - $keys[1] => $this->getDbName(), - ); - 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 = CcCountryPeer::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->setDbIsoCode($value); - break; - case 1: - $this->setDbName($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 = CcCountryPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbIsoCode($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbName($arr[$keys[1]]); - } - - /** - * 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(CcCountryPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcCountryPeer::ISOCODE)) $criteria->add(CcCountryPeer::ISOCODE, $this->isocode); - if ($this->isColumnModified(CcCountryPeer::NAME)) $criteria->add(CcCountryPeer::NAME, $this->name); - - 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(CcCountryPeer::DATABASE_NAME); - $criteria->add(CcCountryPeer::ISOCODE, $this->isocode); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return string - */ - public function getPrimaryKey() - { - return $this->getDbIsoCode(); - } - - /** - * Generic method to set the primary key (isocode column). - * - * @param string $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setDbIsoCode($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - return null === $this->getDbIsoCode(); - } - - /** - * 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 CcCountry (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->setDbIsoCode($this->isocode); - $copyObj->setDbName($this->name); - - $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 CcCountry 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 CcCountryPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcCountryPeer(); - } - return self::$peer; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->isocode = null; - $this->name = 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); - } - -} // BaseCcCountry + /** + * Peer class name + */ + const PEER = 'Airtime\\CcCountryPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcCountryPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the isocode field. + * @var string + */ + protected $isocode; + + /** + * The value for the name field. + * @var string + */ + protected $name; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * Get the [isocode] column value. + * + * @return string + */ + public function getDbIsoCode() + { + + return $this->isocode; + } + + /** + * Get the [name] column value. + * + * @return string + */ + public function getDbName() + { + + return $this->name; + } + + /** + * Set the value of [isocode] column. + * + * @param string $v new value + * @return CcCountry The current object (for fluent API support) + */ + public function setDbIsoCode($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->isocode !== $v) { + $this->isocode = $v; + $this->modifiedColumns[] = CcCountryPeer::ISOCODE; + } + + + return $this; + } // setDbIsoCode() + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return CcCountry The current object (for fluent API support) + */ + public function setDbName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = CcCountryPeer::NAME; + } + + + return $this; + } // setDbName() + + /** + * 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 resultset 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->isocode = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null; + $this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 2; // 2 = CcCountryPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcCountry 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(CcCountryPeer::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 = CcCountryPeer::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 + * @throws Exception + * @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(CcCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcCountryQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcCountryPeer::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); + CcCountryPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcCountryPeer::ISOCODE)) { + $modifiedColumns[':p' . $index++] = '"isocode"'; + } + if ($this->isColumnModified(CcCountryPeer::NAME)) { + $modifiedColumns[':p' . $index++] = '"name"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_country" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"isocode"': + $stmt->bindValue($identifier, $this->isocode, PDO::PARAM_STR); + break; + case '"name"': + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcCountryPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcCountryPeer::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->getDbIsoCode(); + break; + case 1: + return $this->getDbName(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) + { + if (isset($alreadyDumpedObjects['CcCountry'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcCountry'][$this->getPrimaryKey()] = true; + $keys = CcCountryPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbIsoCode(), + $keys[1] => $this->getDbName(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcCountryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbIsoCode($value); + break; + case 1: + $this->setDbName($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcCountryPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbIsoCode($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbName($arr[$keys[1]]); + } + + /** + * 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(CcCountryPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcCountryPeer::ISOCODE)) $criteria->add(CcCountryPeer::ISOCODE, $this->isocode); + if ($this->isColumnModified(CcCountryPeer::NAME)) $criteria->add(CcCountryPeer::NAME, $this->name); + + 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(CcCountryPeer::DATABASE_NAME); + $criteria->add(CcCountryPeer::ISOCODE, $this->isocode); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getDbIsoCode(); + } + + /** + * Generic method to set the primary key (isocode column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setDbIsoCode($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getDbIsoCode(); + } + + /** + * 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 CcCountry (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbName($this->getDbName()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setDbIsoCode(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 CcCountry 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 CcCountryPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcCountryPeer(); + } + + return self::$peer; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->isocode = null; + $this->name = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcCountryPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcCountryPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcCountryPeer.php index ee16e55bf..acbab650a 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcCountryPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcCountryPeer.php @@ -1,731 +1,765 @@ array ('DbIsoCode', 'DbName', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbIsoCode', 'dbName', ), - BasePeer::TYPE_COLNAME => array (self::ISOCODE, self::NAME, ), - BasePeer::TYPE_RAW_COLNAME => array ('ISOCODE', 'NAME', ), - BasePeer::TYPE_FIELDNAME => array ('isocode', 'name', ), - BasePeer::TYPE_NUM => array (0, 1, ) - ); - - /** - * 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 ('DbIsoCode' => 0, 'DbName' => 1, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbIsoCode' => 0, 'dbName' => 1, ), - BasePeer::TYPE_COLNAME => array (self::ISOCODE => 0, self::NAME => 1, ), - BasePeer::TYPE_RAW_COLNAME => array ('ISOCODE' => 0, 'NAME' => 1, ), - BasePeer::TYPE_FIELDNAME => array ('isocode' => 0, 'name' => 1, ), - BasePeer::TYPE_NUM => array (0, 1, ) - ); - - /** - * 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. CcCountryPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcCountryPeer::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(CcCountryPeer::ISOCODE); - $criteria->addSelectColumn(CcCountryPeer::NAME); - } else { - $criteria->addSelectColumn($alias . '.ISOCODE'); - $criteria->addSelectColumn($alias . '.NAME'); - } - } - - /** - * 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(CcCountryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcCountryPeer::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(CcCountryPeer::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 CcCountry - * @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 = CcCountryPeer::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 CcCountryPeer::populateObjects(CcCountryPeer::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(CcCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcCountryPeer::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 CcCountry $value A CcCountry object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcCountry $obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getDbIsoCode(); - } // 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 CcCountry object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcCountry) { - $key = (string) $value->getDbIsoCode(); - } 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 CcCountry 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 CcCountry 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_country - * 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 = CcCountryPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcCountryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcCountryPeer::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; - CcCountryPeer::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 (CcCountry object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcCountryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcCountryPeer::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 + CcCountryPeer::NUM_COLUMNS; - } else { - $cls = CcCountryPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcCountryPeer::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(BaseCcCountryPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcCountryPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcCountryTableMap()); - } - } - - /** - * 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 ? CcCountryPeer::CLASS_DEFAULT : CcCountryPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcCountry or Criteria object. - * - * @param mixed $values Criteria or CcCountry 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(CcCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcCountry 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 CcCountry or Criteria object. - * - * @param mixed $values Criteria or CcCountry 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(CcCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcCountryPeer::ISOCODE); - $value = $criteria->remove(CcCountryPeer::ISOCODE); - if ($value) { - $selectCriteria->add(CcCountryPeer::ISOCODE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcCountryPeer::TABLE_NAME); - } - - } else { // $values is CcCountry 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_country 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(CcCountryPeer::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(CcCountryPeer::TABLE_NAME, $con, CcCountryPeer::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). - CcCountryPeer::clearInstancePool(); - CcCountryPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcCountry or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcCountry 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(CcCountryPeer::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. - CcCountryPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcCountry) { // it's a model object - // invalidate the cache for this single object - CcCountryPeer::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(CcCountryPeer::ISOCODE, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcCountryPeer::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); - CcCountryPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcCountry 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 CcCountry $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(CcCountry $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcCountryPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcCountryPeer::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(CcCountryPeer::DATABASE_NAME, CcCountryPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param string $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcCountry - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcCountryPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcCountryPeer::DATABASE_NAME); - $criteria->add(CcCountryPeer::ISOCODE, $pk); - - $v = CcCountryPeer::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(CcCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcCountryPeer::DATABASE_NAME); - $criteria->add(CcCountryPeer::ISOCODE, $pks, Criteria::IN); - $objs = CcCountryPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcCountryPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_country'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcCountry'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcCountryTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 2; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 2; + + /** the column name for the isocode field */ + const ISOCODE = 'cc_country.isocode'; + + /** the column name for the name field */ + const NAME = 'cc_country.name'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcCountry objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcCountry[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcCountryPeer::$fieldNames[CcCountryPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbIsoCode', 'DbName', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbIsoCode', 'dbName', ), + BasePeer::TYPE_COLNAME => array (CcCountryPeer::ISOCODE, CcCountryPeer::NAME, ), + BasePeer::TYPE_RAW_COLNAME => array ('ISOCODE', 'NAME', ), + BasePeer::TYPE_FIELDNAME => array ('isocode', 'name', ), + BasePeer::TYPE_NUM => array (0, 1, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcCountryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbIsoCode' => 0, 'DbName' => 1, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbIsoCode' => 0, 'dbName' => 1, ), + BasePeer::TYPE_COLNAME => array (CcCountryPeer::ISOCODE => 0, CcCountryPeer::NAME => 1, ), + BasePeer::TYPE_RAW_COLNAME => array ('ISOCODE' => 0, 'NAME' => 1, ), + BasePeer::TYPE_FIELDNAME => array ('isocode' => 0, 'name' => 1, ), + BasePeer::TYPE_NUM => array (0, 1, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcCountryPeer::getFieldNames($toType); + $key = isset(CcCountryPeer::$fieldKeys[$fromType][$name]) ? CcCountryPeer::$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(CcCountryPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcCountryPeer::$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 CcCountryPeer::$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. CcCountryPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcCountryPeer::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(CcCountryPeer::ISOCODE); + $criteria->addSelectColumn(CcCountryPeer::NAME); + } else { + $criteria->addSelectColumn($alias . '.isocode'); + $criteria->addSelectColumn($alias . '.name'); + } + } + + /** + * 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(CcCountryPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcCountryPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcCountryPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcCountryPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcCountry + * @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 = CcCountryPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcCountryPeer::populateObjects(CcCountryPeer::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 directly (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(CcCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcCountryPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcCountryPeer::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 CcCountry $obj A CcCountry object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbIsoCode(); + } // if key === null + CcCountryPeer::$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 CcCountry object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcCountry) { + $key = (string) $value->getDbIsoCode(); + } 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 CcCountry object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcCountryPeer::$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 CcCountry 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(CcCountryPeer::$instances[$key])) { + return CcCountryPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcCountryPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcCountryPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_country + * 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 = CcCountryPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcCountryPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcCountryPeer::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; + CcCountryPeer::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 (CcCountry object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcCountryPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcCountryPeer::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 + CcCountryPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcCountryPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcCountryPeer::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(CcCountryPeer::DATABASE_NAME)->getTable(CcCountryPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcCountryPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcCountryPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcCountryTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcCountryPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcCountry or Criteria object. + * + * @param mixed $values Criteria or CcCountry 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(CcCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcCountry object + } + + + // Set the correct dbName + $criteria->setDbName(CcCountryPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcCountry or Criteria object. + * + * @param mixed $values Criteria or CcCountry 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(CcCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcCountryPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcCountryPeer::ISOCODE); + $value = $criteria->remove(CcCountryPeer::ISOCODE); + if ($value) { + $selectCriteria->add(CcCountryPeer::ISOCODE, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcCountryPeer::TABLE_NAME); + } + + } else { // $values is CcCountry object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcCountryPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_country table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcCountryPeer::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(CcCountryPeer::TABLE_NAME, $con, CcCountryPeer::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). + CcCountryPeer::clearInstancePool(); + CcCountryPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcCountry or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcCountry 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(CcCountryPeer::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. + CcCountryPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcCountry) { // it's a model object + // invalidate the cache for this single object + CcCountryPeer::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(CcCountryPeer::DATABASE_NAME); + $criteria->add(CcCountryPeer::ISOCODE, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcCountryPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcCountryPeer::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); + CcCountryPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcCountry 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 CcCountry $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcCountryPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcCountryPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcCountryPeer::DATABASE_NAME, CcCountryPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param string $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcCountry + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcCountryPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcCountryPeer::DATABASE_NAME); + $criteria->add(CcCountryPeer::ISOCODE, $pk); + + $v = CcCountryPeer::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 + * @return CcCountry[] + * @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(CcCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcCountryPeer::DATABASE_NAME); + $criteria->add(CcCountryPeer::ISOCODE, $pks, Criteria::IN); + $objs = CcCountryPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcCountryPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcCountryQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcCountryQuery.php index 4e634ea19..353be4dfb 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcCountryQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcCountryQuery.php @@ -1,196 +1,309 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcCountry|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcCountryPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcCountry|CcCountry[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcCountryPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcCountryQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcCountryPeer::ISOCODE, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcCountry A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbIsoCode($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcCountryQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcCountryPeer::ISOCODE, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcCountry A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "isocode", "name" FROM "cc_country" WHERE "isocode" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcCountry(); + $obj->hydrate($row); + CcCountryPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * Filter the query on the isocode column - * - * @param string $dbIsoCode 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 CcCountryQuery The current query, for fluid interface - */ - public function filterByDbIsoCode($dbIsoCode = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbIsoCode)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbIsoCode)) { - $dbIsoCode = str_replace('*', '%', $dbIsoCode); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcCountryPeer::ISOCODE, $dbIsoCode, $comparison); - } + return $obj; + } - /** - * 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 CcCountryQuery 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(CcCountryPeer::NAME, $dbName, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcCountry|CcCountry[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Exclude object from result - * - * @param CcCountry $ccCountry Object to remove from the list of results - * - * @return CcCountryQuery The current query, for fluid interface - */ - public function prune($ccCountry = null) - { - if ($ccCountry) { - $this->addUsingAlias(CcCountryPeer::ISOCODE, $ccCountry->getDbIsoCode(), Criteria::NOT_EQUAL); - } - - return $this; - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } -} // BaseCcCountryQuery + /** + * 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|CcCountry[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($stmt); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcCountryQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(CcCountryPeer::ISOCODE, $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 CcCountryQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(CcCountryPeer::ISOCODE, $keys, Criteria::IN); + } + + /** + * Filter the query on the isocode column + * + * Example usage: + * + * $query->filterByDbIsoCode('fooValue'); // WHERE isocode = 'fooValue' + * $query->filterByDbIsoCode('%fooValue%'); // WHERE isocode LIKE '%fooValue%' + * + * + * @param string $dbIsoCode 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 CcCountryQuery The current query, for fluid interface + */ + public function filterByDbIsoCode($dbIsoCode = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbIsoCode)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbIsoCode)) { + $dbIsoCode = str_replace('*', '%', $dbIsoCode); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcCountryPeer::ISOCODE, $dbIsoCode, $comparison); + } + + /** + * Filter the query on the name column + * + * Example usage: + * + * $query->filterByDbName('fooValue'); // WHERE name = 'fooValue' + * $query->filterByDbName('%fooValue%'); // WHERE name LIKE '%fooValue%' + * + * + * @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 CcCountryQuery 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(CcCountryPeer::NAME, $dbName, $comparison); + } + + /** + * Exclude object from result + * + * @param CcCountry $ccCountry Object to remove from the list of results + * + * @return CcCountryQuery The current query, for fluid interface + */ + public function prune($ccCountry = null) + { + if ($ccCountry) { + $this->addUsingAlias(CcCountryPeer::ISOCODE, $ccCountry->getDbIsoCode(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFileTag.php b/airtime_mvc/application/models/airtime/om/BaseCcFileTag.php deleted file mode 100644 index eea6b63e0..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcFileTag.php +++ /dev/null @@ -1,936 +0,0 @@ -id; - } - - /** - * Get the [file_id] column value. - * - * @return int - */ - public function getDbFileId() - { - return $this->file_id; - } - - /** - * Get the [tag_id] column value. - * - * @return int - */ - public function getDbTagId() - { - return $this->tag_id; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcFileTag 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[] = CcFileTagPeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [file_id] column. - * - * @param int $v new value - * @return CcFileTag 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[] = CcFileTagPeer::FILE_ID; - } - - if ($this->aCcFiles !== null && $this->aCcFiles->getDbId() !== $v) { - $this->aCcFiles = null; - } - - return $this; - } // setDbFileId() - - /** - * Set the value of [tag_id] column. - * - * @param int $v new value - * @return CcFileTag The current object (for fluent API support) - */ - public function setDbTagId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->tag_id !== $v) { - $this->tag_id = $v; - $this->modifiedColumns[] = CcFileTagPeer::TAG_ID; - } - - if ($this->aCcTag !== null && $this->aCcTag->getDbId() !== $v) { - $this->aCcTag = null; - } - - return $this; - } // setDbTagId() - - /** - * 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->file_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->tag_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 3; // 3 = CcFileTagPeer::NUM_COLUMNS - CcFileTagPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcFileTag 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->aCcFiles !== null && $this->file_id !== $this->aCcFiles->getDbId()) { - $this->aCcFiles = null; - } - if ($this->aCcTag !== null && $this->tag_id !== $this->aCcTag->getDbId()) { - $this->aCcTag = 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(CcFileTagPeer::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 = CcFileTagPeer::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->aCcTag = 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(CcFileTagPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcFileTagQuery::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(CcFileTagPeer::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); - CcFileTagPeer::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->aCcTag !== null) { - if ($this->aCcTag->isModified() || $this->aCcTag->isNew()) { - $affectedRows += $this->aCcTag->save($con); - } - $this->setCcTag($this->aCcTag); - } - - if ($this->isNew() ) { - $this->modifiedColumns[] = CcFileTagPeer::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(CcFileTagPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcFileTagPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows += 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows += CcFileTagPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcFiles !== null) { - if (!$this->aCcFiles->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcFiles->getValidationFailures()); - } - } - - if ($this->aCcTag !== null) { - if (!$this->aCcTag->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcTag->getValidationFailures()); - } - } - - - if (($retval = CcFileTagPeer::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 = CcFileTagPeer::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->getDbFileId(); - break; - case 2: - return $this->getDbTagId(); - 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 = CcFileTagPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbFileId(), - $keys[2] => $this->getDbTagId(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCcFiles) { - $result['CcFiles'] = $this->aCcFiles->toArray($keyType, $includeLazyLoadColumns, true); - } - if (null !== $this->aCcTag) { - $result['CcTag'] = $this->aCcTag->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 = CcFileTagPeer::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->setDbFileId($value); - break; - case 2: - $this->setDbTagId($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 = CcFileTagPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbFileId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbTagId($arr[$keys[2]]); - } - - /** - * 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(CcFileTagPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcFileTagPeer::ID)) $criteria->add(CcFileTagPeer::ID, $this->id); - if ($this->isColumnModified(CcFileTagPeer::FILE_ID)) $criteria->add(CcFileTagPeer::FILE_ID, $this->file_id); - if ($this->isColumnModified(CcFileTagPeer::TAG_ID)) $criteria->add(CcFileTagPeer::TAG_ID, $this->tag_id); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(CcFileTagPeer::DATABASE_NAME); - $criteria->add(CcFileTagPeer::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 CcFileTag (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->setDbFileId($this->file_id); - $copyObj->setDbTagId($this->tag_id); - - $copyObj->setNew(true); - $copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return CcFileTag 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 CcFileTagPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcFileTagPeer(); - } - return self::$peer; - } - - /** - * Declares an association between this object and a CcFiles object. - * - * @param CcFiles $v - * @return CcFileTag 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->addCcFileTag($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->addCcFileTags($this); - */ - } - return $this->aCcFiles; - } - - /** - * Declares an association between this object and a CcTag object. - * - * @param CcTag $v - * @return CcFileTag The current object (for fluent API support) - * @throws PropelException - */ - public function setCcTag(CcTag $v = null) - { - if ($v === null) { - $this->setDbTagId(NULL); - } else { - $this->setDbTagId($v->getDbId()); - } - - $this->aCcTag = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcTag object, it will not be re-added. - if ($v !== null) { - $v->addCcFileTag($this); - } - - return $this; - } - - - /** - * Get the associated CcTag object - * - * @param PropelPDO Optional Connection object. - * @return CcTag The associated CcTag object. - * @throws PropelException - */ - public function getCcTag(PropelPDO $con = null) - { - if ($this->aCcTag === null && ($this->tag_id !== null)) { - $this->aCcTag = CcTagQuery::create()->findPk($this->tag_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->aCcTag->addCcFileTags($this); - */ - } - return $this->aCcTag; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->file_id = null; - $this->tag_id = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all collections of referencing foreign keys. - * - * This method is a user-space workaround for PHP's inability to garbage collect objects - * with circular references. This is currently necessary when using Propel in certain - * daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all associated objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep) { - } // if ($deep) - - $this->aCcFiles = null; - $this->aCcTag = 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); - } - -} // BaseCcFileTag diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFileTagPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcFileTagPeer.php deleted file mode 100644 index e4454a44f..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcFileTagPeer.php +++ /dev/null @@ -1,1365 +0,0 @@ - array ('DbId', 'DbFileId', 'DbTagId', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbFileId', 'dbTagId', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::FILE_ID, self::TAG_ID, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FILE_ID', 'TAG_ID', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'file_id', 'tag_id', ), - BasePeer::TYPE_NUM => array (0, 1, 2, ) - ); - - /** - * 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, 'DbFileId' => 1, 'DbTagId' => 2, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbFileId' => 1, 'dbTagId' => 2, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::FILE_ID => 1, self::TAG_ID => 2, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FILE_ID' => 1, 'TAG_ID' => 2, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'file_id' => 1, 'tag_id' => 2, ), - BasePeer::TYPE_NUM => array (0, 1, 2, ) - ); - - /** - * 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. CcFileTagPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcFileTagPeer::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(CcFileTagPeer::ID); - $criteria->addSelectColumn(CcFileTagPeer::FILE_ID); - $criteria->addSelectColumn(CcFileTagPeer::TAG_ID); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.FILE_ID'); - $criteria->addSelectColumn($alias . '.TAG_ID'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CcFileTagPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcFileTagPeer::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(CcFileTagPeer::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 CcFileTag - * @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 = CcFileTagPeer::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 CcFileTagPeer::populateObjects(CcFileTagPeer::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(CcFileTagPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcFileTagPeer::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 CcFileTag $value A CcFileTag object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcFileTag $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 CcFileTag object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcFileTag) { - $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 CcFileTag 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 CcFileTag 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_file_tag - * 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 = CcFileTagPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcFileTagPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcFileTagPeer::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; - CcFileTagPeer::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 (CcFileTag object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcFileTagPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcFileTagPeer::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 + CcFileTagPeer::NUM_COLUMNS; - } else { - $cls = CcFileTagPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcFileTagPeer::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(CcFileTagPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcFileTagPeer::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(CcFileTagPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcFileTagPeer::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 CcTag 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 doCountJoinCcTag(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(CcFileTagPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcFileTagPeer::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(CcFileTagPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcFileTagPeer::TAG_ID, CcTagPeer::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 CcFileTag 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 CcFileTag 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); - } - - CcFileTagPeer::addSelectColumns($criteria); - $startcol = (CcFileTagPeer::NUM_COLUMNS - CcFileTagPeer::NUM_LAZY_LOAD_COLUMNS); - CcFilesPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcFileTagPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcFileTagPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcFileTagPeer::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 = CcFileTagPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcFileTagPeer::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 (CcFileTag) to $obj2 (CcFiles) - $obj2->addCcFileTag($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcFileTag objects pre-filled with their CcTag 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 CcFileTag objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCcTag(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); - } - - CcFileTagPeer::addSelectColumns($criteria); - $startcol = (CcFileTagPeer::NUM_COLUMNS - CcFileTagPeer::NUM_LAZY_LOAD_COLUMNS); - CcTagPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcFileTagPeer::TAG_ID, CcTagPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcFileTagPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcFileTagPeer::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 = CcFileTagPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcFileTagPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CcTagPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcTagPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcTagPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcTagPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcFileTag) to $obj2 (CcTag) - $obj2->addCcFileTag($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(CcFileTagPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcFileTagPeer::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(CcFileTagPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcFileTagPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $criteria->addJoin(CcFileTagPeer::TAG_ID, CcTagPeer::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 CcFileTag 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 CcFileTag 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); - } - - CcFileTagPeer::addSelectColumns($criteria); - $startcol2 = (CcFileTagPeer::NUM_COLUMNS - CcFileTagPeer::NUM_LAZY_LOAD_COLUMNS); - - CcFilesPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); - - CcTagPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + (CcTagPeer::NUM_COLUMNS - CcTagPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcFileTagPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $criteria->addJoin(CcFileTagPeer::TAG_ID, CcTagPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcFileTagPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcFileTagPeer::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 = CcFileTagPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcFileTagPeer::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 (CcFileTag) to the collection in $obj2 (CcFiles) - $obj2->addCcFileTag($obj1); - } // if joined row not null - - // Add objects for joined CcTag rows - - $key3 = CcTagPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CcTagPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CcTagPeer::getOMClass(false); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CcTagPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (CcFileTag) to the collection in $obj3 (CcTag) - $obj3->addCcFileTag($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(CcFileTagPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcFileTagPeer::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(CcFileTagPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcFileTagPeer::TAG_ID, CcTagPeer::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 CcTag 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 doCountJoinAllExceptCcTag(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(CcFileTagPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcFileTagPeer::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(CcFileTagPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcFileTagPeer::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 CcFileTag 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 CcFileTag 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); - } - - CcFileTagPeer::addSelectColumns($criteria); - $startcol2 = (CcFileTagPeer::NUM_COLUMNS - CcFileTagPeer::NUM_LAZY_LOAD_COLUMNS); - - CcTagPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcTagPeer::NUM_COLUMNS - CcTagPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcFileTagPeer::TAG_ID, CcTagPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcFileTagPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcFileTagPeer::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 = CcFileTagPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcFileTagPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcTag rows - - $key2 = CcTagPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcTagPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcTagPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcTagPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (CcFileTag) to the collection in $obj2 (CcTag) - $obj2->addCcFileTag($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcFileTag objects pre-filled with all related objects except CcTag. - * - * @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 CcFileTag objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCcTag(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); - } - - CcFileTagPeer::addSelectColumns($criteria); - $startcol2 = (CcFileTagPeer::NUM_COLUMNS - CcFileTagPeer::NUM_LAZY_LOAD_COLUMNS); - - CcFilesPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcFileTagPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcFileTagPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcFileTagPeer::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 = CcFileTagPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcFileTagPeer::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 (CcFileTag) to the collection in $obj2 (CcFiles) - $obj2->addCcFileTag($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(BaseCcFileTagPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcFileTagPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcFileTagTableMap()); - } - } - - /** - * 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 ? CcFileTagPeer::CLASS_DEFAULT : CcFileTagPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcFileTag or Criteria object. - * - * @param mixed $values Criteria or CcFileTag 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(CcFileTagPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcFileTag object - } - - if ($criteria->containsKey(CcFileTagPeer::ID) && $criteria->keyContainsValue(CcFileTagPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcFileTagPeer::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 CcFileTag or Criteria object. - * - * @param mixed $values Criteria or CcFileTag 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(CcFileTagPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcFileTagPeer::ID); - $value = $criteria->remove(CcFileTagPeer::ID); - if ($value) { - $selectCriteria->add(CcFileTagPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcFileTagPeer::TABLE_NAME); - } - - } else { // $values is CcFileTag 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_file_tag 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(CcFileTagPeer::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(CcFileTagPeer::TABLE_NAME, $con, CcFileTagPeer::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). - CcFileTagPeer::clearInstancePool(); - CcFileTagPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcFileTag or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcFileTag 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(CcFileTagPeer::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. - CcFileTagPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcFileTag) { // it's a model object - // invalidate the cache for this single object - CcFileTagPeer::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(CcFileTagPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcFileTagPeer::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); - CcFileTagPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcFileTag 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 CcFileTag $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(CcFileTag $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcFileTagPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcFileTagPeer::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(CcFileTagPeer::DATABASE_NAME, CcFileTagPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcFileTag - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcFileTagPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcFileTagPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcFileTagPeer::DATABASE_NAME); - $criteria->add(CcFileTagPeer::ID, $pk); - - $v = CcFileTagPeer::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(CcFileTagPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcFileTagPeer::DATABASE_NAME); - $criteria->add(CcFileTagPeer::ID, $pks, Criteria::IN); - $objs = CcFileTagPeer::doSelect($criteria, $con); - } - return $objs; - } - -} // BaseCcFileTagPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseCcFileTagPeer::buildTableMap(); - diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFileTagQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcFileTagQuery.php deleted file mode 100644 index 991c4e05a..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcFileTagQuery.php +++ /dev/null @@ -1,371 +0,0 @@ -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 CcFileTag|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcFileTagPeer::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 CcFileTagQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcFileTagPeer::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 CcFileTagQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcFileTagPeer::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 CcFileTagQuery 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(CcFileTagPeer::ID, $dbId, $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 CcFileTagQuery 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(CcFileTagPeer::FILE_ID, $dbFileId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbFileId['max'])) { - $this->addUsingAlias(CcFileTagPeer::FILE_ID, $dbFileId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFileTagPeer::FILE_ID, $dbFileId, $comparison); - } - - /** - * Filter the query on the tag_id column - * - * @param int|array $dbTagId 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 CcFileTagQuery The current query, for fluid interface - */ - public function filterByDbTagId($dbTagId = null, $comparison = null) - { - if (is_array($dbTagId)) { - $useMinMax = false; - if (isset($dbTagId['min'])) { - $this->addUsingAlias(CcFileTagPeer::TAG_ID, $dbTagId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbTagId['max'])) { - $this->addUsingAlias(CcFileTagPeer::TAG_ID, $dbTagId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFileTagPeer::TAG_ID, $dbTagId, $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 CcFileTagQuery The current query, for fluid interface - */ - public function filterByCcFiles($ccFiles, $comparison = null) - { - return $this - ->addUsingAlias(CcFileTagPeer::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 CcFileTagQuery The current query, for fluid interface - */ - public function joinCcFiles($relationAlias = '', $joinType = Criteria::INNER_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::INNER_JOIN) - { - return $this - ->joinCcFiles($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcFiles', 'CcFilesQuery'); - } - - /** - * Filter the query by a related CcTag object - * - * @param CcTag $ccTag the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcFileTagQuery The current query, for fluid interface - */ - public function filterByCcTag($ccTag, $comparison = null) - { - return $this - ->addUsingAlias(CcFileTagPeer::TAG_ID, $ccTag->getDbId(), $comparison); - } - - /** - * Adds a JOIN clause to the query using the CcTag relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcFileTagQuery The current query, for fluid interface - */ - public function joinCcTag($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcTag'); - - // 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, 'CcTag'); - } - - return $this; - } - - /** - * Use the CcTag relation CcTag 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 CcTagQuery A secondary query class using the current class as primary query - */ - public function useCcTagQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcTag($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcTag', 'CcTagQuery'); - } - - /** - * Exclude object from result - * - * @param CcFileTag $ccFileTag Object to remove from the list of results - * - * @return CcFileTagQuery The current query, for fluid interface - */ - public function prune($ccFileTag = null) - { - if ($ccFileTag) { - $this->addUsingAlias(CcFileTagPeer::ID, $ccFileTag->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } - -} // BaseCcFileTagQuery diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFiles.php b/airtime_mvc/application/models/airtime/om/BaseCcFiles.php index 38d147c07..c3fd8b4ed 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcFiles.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcFiles.php @@ -1,5472 +1,6836 @@ name = ''; - $this->mime = ''; - $this->ftype = ''; - $this->filepath = ''; - $this->state = 'empty'; - $this->currentlyaccessing = 0; - $this->length = '00:00:00'; - $this->file_exists = true; - $this->cuein = '00:00:00'; - $this->cueout = '00:00:00'; - $this->silan_check = false; - $this->hidden = false; - $this->is_scheduled = false; - $this->is_playlist = false; - } - - /** - * 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 [name] column value. - * - * @return string - */ - public function getDbName() - { - return $this->name; - } - - /** - * Get the [mime] column value. - * - * @return string - */ - public function getDbMime() - { - return $this->mime; - } - - /** - * Get the [ftype] column value. - * - * @return string - */ - public function getDbFtype() - { - return $this->ftype; - } - - /** - * Get the [directory] column value. - * - * @return int - */ - public function getDbDirectory() - { - return $this->directory; - } - - /** - * Get the [filepath] column value. - * - * @return string - */ - public function getDbFilepath() - { - return $this->filepath; - } - - /** - * 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 [optionally formatted] temporal [utime] 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 getDbUtime($format = 'Y-m-d H:i:s') - { - if ($this->utime === null) { - return null; - } - - - - try { - $dt = new DateTime($this->utime); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->utime, 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 [lptime] 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 getDbLPtime($format = 'Y-m-d H:i:s') - { - if ($this->lptime === null) { - return null; - } - - - - try { - $dt = new DateTime($this->lptime); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->lptime, 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 getDbMd5() - { - return $this->md5; - } - - /** - * Get the [track_title] column value. - * - * @return string - */ - public function getDbTrackTitle() - { - return $this->track_title; - } - - /** - * Get the [artist_name] column value. - * - * @return string - */ - public function getDbArtistName() - { - return $this->artist_name; - } - - /** - * Get the [bit_rate] column value. - * - * @return int - */ - public function getDbBitRate() - { - return $this->bit_rate; - } - - /** - * Get the [sample_rate] column value. - * - * @return int - */ - public function getDbSampleRate() - { - return $this->sample_rate; - } - - /** - * Get the [format] column value. - * - * @return string - */ - public function getDbFormat() - { - return $this->format; - } - - /** - * Get the [length] column value. - * - * @return string - */ - public function getDbLength() - { - return $this->length; - } - - /** - * Get the [album_title] column value. - * - * @return string - */ - public function getDbAlbumTitle() - { - return $this->album_title; - } - - /** - * Get the [genre] column value. - * - * @return string - */ - public function getDbGenre() - { - return $this->genre; - } - - /** - * Get the [comments] column value. - * - * @return string - */ - public function getDbComments() - { - return $this->comments; - } - - /** - * Get the [year] column value. - * - * @return string - */ - public function getDbYear() - { - return $this->year; - } - - /** - * Get the [track_number] column value. - * - * @return int - */ - public function getDbTrackNumber() - { - return $this->track_number; - } - - /** - * Get the [channels] column value. - * - * @return int - */ - public function getDbChannels() - { - return $this->channels; - } - - /** - * Get the [url] column value. - * - * @return string - */ - public function getDbUrl() - { - return $this->url; - } - - /** - * Get the [bpm] column value. - * - * @return int - */ - public function getDbBpm() - { - return $this->bpm; - } - - /** - * Get the [rating] column value. - * - * @return string - */ - public function getDbRating() - { - return $this->rating; - } - - /** - * Get the [encoded_by] column value. - * - * @return string - */ - public function getDbEncodedBy() - { - return $this->encoded_by; - } - - /** - * Get the [disc_number] column value. - * - * @return string - */ - public function getDbDiscNumber() - { - return $this->disc_number; - } - - /** - * Get the [mood] column value. - * - * @return string - */ - public function getDbMood() - { - return $this->mood; - } - - /** - * Get the [label] column value. - * - * @return string - */ - public function getDbLabel() - { - return $this->label; - } - - /** - * Get the [composer] column value. - * - * @return string - */ - public function getDbComposer() - { - return $this->composer; - } - - /** - * Get the [encoder] column value. - * - * @return string - */ - public function getDbEncoder() - { - return $this->encoder; - } - - /** - * Get the [checksum] column value. - * - * @return string - */ - public function getDbChecksum() - { - return $this->checksum; - } - - /** - * Get the [lyrics] column value. - * - * @return string - */ - public function getDbLyrics() - { - return $this->lyrics; - } - - /** - * Get the [orchestra] column value. - * - * @return string - */ - public function getDbOrchestra() - { - return $this->orchestra; - } - - /** - * Get the [conductor] column value. - * - * @return string - */ - public function getDbConductor() - { - return $this->conductor; - } - - /** - * Get the [lyricist] column value. - * - * @return string - */ - public function getDbLyricist() - { - return $this->lyricist; - } - - /** - * Get the [original_lyricist] column value. - * - * @return string - */ - public function getDbOriginalLyricist() - { - return $this->original_lyricist; - } - - /** - * Get the [radio_station_name] column value. - * - * @return string - */ - public function getDbRadioStationName() - { - return $this->radio_station_name; - } - - /** - * Get the [info_url] column value. - * - * @return string - */ - public function getDbInfoUrl() - { - return $this->info_url; - } - - /** - * Get the [artist_url] column value. - * - * @return string - */ - public function getDbArtistUrl() - { - return $this->artist_url; - } - - /** - * Get the [audio_source_url] column value. - * - * @return string - */ - public function getDbAudioSourceUrl() - { - return $this->audio_source_url; - } - - /** - * Get the [radio_station_url] column value. - * - * @return string - */ - public function getDbRadioStationUrl() - { - return $this->radio_station_url; - } - - /** - * Get the [buy_this_url] column value. - * - * @return string - */ - public function getDbBuyThisUrl() - { - return $this->buy_this_url; - } - - /** - * Get the [isrc_number] column value. - * - * @return string - */ - public function getDbIsrcNumber() - { - return $this->isrc_number; - } - - /** - * Get the [catalog_number] column value. - * - * @return string - */ - public function getDbCatalogNumber() - { - return $this->catalog_number; - } - - /** - * Get the [original_artist] column value. - * - * @return string - */ - public function getDbOriginalArtist() - { - return $this->original_artist; - } - - /** - * Get the [copyright] column value. - * - * @return string - */ - public function getDbCopyright() - { - return $this->copyright; - } - - /** - * Get the [report_datetime] column value. - * - * @return string - */ - public function getDbReportDatetime() - { - return $this->report_datetime; - } - - /** - * Get the [report_location] column value. - * - * @return string - */ - public function getDbReportLocation() - { - return $this->report_location; - } - - /** - * Get the [report_organization] column value. - * - * @return string - */ - public function getDbReportOrganization() - { - return $this->report_organization; - } - - /** - * Get the [subject] column value. - * - * @return string - */ - public function getDbSubject() - { - return $this->subject; - } - - /** - * Get the [contributor] column value. - * - * @return string - */ - public function getDbContributor() - { - return $this->contributor; - } - - /** - * Get the [language] column value. - * - * @return string - */ - public function getDbLanguage() - { - return $this->language; - } - - /** - * Get the [file_exists] column value. - * - * @return boolean - */ - public function getDbFileExists() - { - return $this->file_exists; - } - - /** - * Get the [soundcloud_id] column value. - * - * @return int - */ - public function getDbSoundcloudId() - { - return $this->soundcloud_id; - } - - /** - * Get the [soundcloud_error_code] column value. - * - * @return int - */ - public function getDbSoundcloudErrorCode() - { - return $this->soundcloud_error_code; - } - - /** - * Get the [soundcloud_error_msg] column value. - * - * @return string - */ - public function getDbSoundcloudErrorMsg() - { - return $this->soundcloud_error_msg; - } - - /** - * Get the [soundcloud_link_to_file] column value. - * - * @return string - */ - public function getDbSoundcloudLinkToFile() - { - return $this->soundcloud_link_to_file; - } - - /** - * Get the [optionally formatted] temporal [soundcloud_upload_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 getDbSoundCloundUploadTime($format = 'Y-m-d H:i:s') - { - if ($this->soundcloud_upload_time === null) { - return null; - } - - - - try { - $dt = new DateTime($this->soundcloud_upload_time); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->soundcloud_upload_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 [replay_gain] column value. - * - * @return string - */ - public function getDbReplayGain() - { - return $this->replay_gain; - } - - /** - * Get the [owner_id] column value. - * - * @return int - */ - public function getDbOwnerId() - { - return $this->owner_id; - } - - /** - * Get the [cuein] column value. - * - * @return string - */ - public function getDbCuein() - { - return $this->cuein; - } - - /** - * Get the [cueout] column value. - * - * @return string - */ - public function getDbCueout() - { - return $this->cueout; - } - - /** - * Get the [silan_check] column value. - * - * @return boolean - */ - public function getDbSilanCheck() - { - return $this->silan_check; - } - - /** - * Get the [hidden] column value. - * - * @return boolean - */ - public function getDbHidden() - { - return $this->hidden; - } - - /** - * Get the [is_scheduled] column value. - * - * @return boolean - */ - public function getDbIsScheduled() - { - return $this->is_scheduled; - } - - /** - * Get the [is_playlist] column value. - * - * @return boolean - */ - public function getDbIsPlaylist() - { - return $this->is_playlist; - } - - /** - * 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 [name] column. - * - * @param string $v new value - * @return CcFiles 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[] = CcFilesPeer::NAME; - } - - return $this; - } // setDbName() - - /** - * Set the value of [mime] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbMime($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->mime !== $v || $this->isNew()) { - $this->mime = $v; - $this->modifiedColumns[] = CcFilesPeer::MIME; - } - - return $this; - } // setDbMime() - - /** - * Set the value of [ftype] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbFtype($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->ftype !== $v || $this->isNew()) { - $this->ftype = $v; - $this->modifiedColumns[] = CcFilesPeer::FTYPE; - } - - return $this; - } // setDbFtype() - - /** - * Set the value of [directory] column. - * - * @param int $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbDirectory($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->directory !== $v) { - $this->directory = $v; - $this->modifiedColumns[] = CcFilesPeer::DIRECTORY; - } - - if ($this->aCcMusicDirs !== null && $this->aCcMusicDirs->getId() !== $v) { - $this->aCcMusicDirs = null; - } - - return $this; - } // setDbDirectory() - - /** - * Set the value of [filepath] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbFilepath($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->filepath !== $v || $this->isNew()) { - $this->filepath = $v; - $this->modifiedColumns[] = CcFilesPeer::FILEPATH; - } - - return $this; - } // setDbFilepath() - - /** - * Set the value of [state] column. - * - * @param string $v new value - * @return CcFiles 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[] = CcFilesPeer::STATE; - } - - return $this; - } // setDbState() - - /** - * Set the value of [currentlyaccessing] column. - * - * @param int $v new value - * @return CcFiles 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[] = CcFilesPeer::CURRENTLYACCESSING; - } - - return $this; - } // setDbCurrentlyaccessing() - - /** - * Set the value of [editedby] column. - * - * @param int $v new value - * @return CcFiles 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[] = CcFilesPeer::EDITEDBY; - } - - if ($this->aCcSubjsRelatedByDbEditedby !== null && $this->aCcSubjsRelatedByDbEditedby->getDbId() !== $v) { - $this->aCcSubjsRelatedByDbEditedby = 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 CcFiles 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[] = CcFilesPeer::MTIME; - } - } // if either are not null - - return $this; - } // setDbMtime() - - /** - * Sets the value of [utime] 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 setDbUtime($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->utime !== null || $dt !== null ) { - // (nested ifs are a little easier to read in this case) - - $currNorm = ($this->utime !== null && $tmpDt = new DateTime($this->utime)) ? $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->utime = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); - $this->modifiedColumns[] = CcFilesPeer::UTIME; - } - } // if either are not null - - return $this; - } // setDbUtime() - - /** - * Sets the value of [lptime] 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 setDbLPtime($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->lptime !== null || $dt !== null ) { - // (nested ifs are a little easier to read in this case) - - $currNorm = ($this->lptime !== null && $tmpDt = new DateTime($this->lptime)) ? $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->lptime = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); - $this->modifiedColumns[] = CcFilesPeer::LPTIME; - } - } // if either are not null - - return $this; - } // setDbLPtime() - - /** - * Set the value of [md5] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbMd5($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->md5 !== $v) { - $this->md5 = $v; - $this->modifiedColumns[] = CcFilesPeer::MD5; - } - - return $this; - } // setDbMd5() - - /** - * Set the value of [track_title] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbTrackTitle($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->track_title !== $v) { - $this->track_title = $v; - $this->modifiedColumns[] = CcFilesPeer::TRACK_TITLE; - } - - return $this; - } // setDbTrackTitle() - - /** - * Set the value of [artist_name] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbArtistName($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->artist_name !== $v) { - $this->artist_name = $v; - $this->modifiedColumns[] = CcFilesPeer::ARTIST_NAME; - } - - return $this; - } // setDbArtistName() - - /** - * Set the value of [bit_rate] column. - * - * @param int $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbBitRate($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->bit_rate !== $v) { - $this->bit_rate = $v; - $this->modifiedColumns[] = CcFilesPeer::BIT_RATE; - } - - return $this; - } // setDbBitRate() - - /** - * Set the value of [sample_rate] column. - * - * @param int $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbSampleRate($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->sample_rate !== $v) { - $this->sample_rate = $v; - $this->modifiedColumns[] = CcFilesPeer::SAMPLE_RATE; - } - - return $this; - } // setDbSampleRate() - - /** - * Set the value of [format] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbFormat($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->format !== $v) { - $this->format = $v; - $this->modifiedColumns[] = CcFilesPeer::FORMAT; - } - - return $this; - } // setDbFormat() - - /** - * Set the value of [length] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbLength($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->length !== $v || $this->isNew()) { - $this->length = $v; - $this->modifiedColumns[] = CcFilesPeer::LENGTH; - } - - 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 setDbAlbumTitle($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->album_title !== $v) { - $this->album_title = $v; - $this->modifiedColumns[] = CcFilesPeer::ALBUM_TITLE; - } - - return $this; - } // setDbAlbumTitle() - - /** - * Set the value of [genre] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbGenre($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->genre !== $v) { - $this->genre = $v; - $this->modifiedColumns[] = CcFilesPeer::GENRE; - } - - return $this; - } // setDbGenre() - - /** - * Set the value of [comments] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbComments($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->comments !== $v) { - $this->comments = $v; - $this->modifiedColumns[] = CcFilesPeer::COMMENTS; - } - - return $this; - } // setDbComments() - - /** - * Set the value of [year] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbYear($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->year !== $v) { - $this->year = $v; - $this->modifiedColumns[] = CcFilesPeer::YEAR; - } - - return $this; - } // setDbYear() - - /** - * Set the value of [track_number] column. - * - * @param int $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbTrackNumber($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->track_number !== $v) { - $this->track_number = $v; - $this->modifiedColumns[] = CcFilesPeer::TRACK_NUMBER; - } - - return $this; - } // setDbTrackNumber() - - /** - * Set the value of [channels] column. - * - * @param int $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbChannels($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->channels !== $v) { - $this->channels = $v; - $this->modifiedColumns[] = CcFilesPeer::CHANNELS; - } - - return $this; - } // setDbChannels() - - /** - * Set the value of [url] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbUrl($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->url !== $v) { - $this->url = $v; - $this->modifiedColumns[] = CcFilesPeer::URL; - } - - return $this; - } // setDbUrl() - - /** - * Set the value of [bpm] column. - * - * @param int $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbBpm($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->bpm !== $v) { - $this->bpm = $v; - $this->modifiedColumns[] = CcFilesPeer::BPM; - } - - return $this; - } // setDbBpm() - - /** - * Set the value of [rating] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbRating($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->rating !== $v) { - $this->rating = $v; - $this->modifiedColumns[] = CcFilesPeer::RATING; - } - - return $this; - } // setDbRating() - - /** - * Set the value of [encoded_by] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbEncodedBy($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->encoded_by !== $v) { - $this->encoded_by = $v; - $this->modifiedColumns[] = CcFilesPeer::ENCODED_BY; - } - - return $this; - } // setDbEncodedBy() - - /** - * Set the value of [disc_number] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbDiscNumber($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->disc_number !== $v) { - $this->disc_number = $v; - $this->modifiedColumns[] = CcFilesPeer::DISC_NUMBER; - } - - return $this; - } // setDbDiscNumber() - - /** - * Set the value of [mood] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbMood($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->mood !== $v) { - $this->mood = $v; - $this->modifiedColumns[] = CcFilesPeer::MOOD; - } - - return $this; - } // setDbMood() - - /** - * Set the value of [label] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbLabel($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->label !== $v) { - $this->label = $v; - $this->modifiedColumns[] = CcFilesPeer::LABEL; - } - - return $this; - } // setDbLabel() - - /** - * Set the value of [composer] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbComposer($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->composer !== $v) { - $this->composer = $v; - $this->modifiedColumns[] = CcFilesPeer::COMPOSER; - } - - return $this; - } // setDbComposer() - - /** - * Set the value of [encoder] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbEncoder($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->encoder !== $v) { - $this->encoder = $v; - $this->modifiedColumns[] = CcFilesPeer::ENCODER; - } - - return $this; - } // setDbEncoder() - - /** - * Set the value of [checksum] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbChecksum($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->checksum !== $v) { - $this->checksum = $v; - $this->modifiedColumns[] = CcFilesPeer::CHECKSUM; - } - - return $this; - } // setDbChecksum() - - /** - * Set the value of [lyrics] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbLyrics($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->lyrics !== $v) { - $this->lyrics = $v; - $this->modifiedColumns[] = CcFilesPeer::LYRICS; - } - - return $this; - } // setDbLyrics() - - /** - * Set the value of [orchestra] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbOrchestra($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->orchestra !== $v) { - $this->orchestra = $v; - $this->modifiedColumns[] = CcFilesPeer::ORCHESTRA; - } - - return $this; - } // setDbOrchestra() - - /** - * Set the value of [conductor] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbConductor($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->conductor !== $v) { - $this->conductor = $v; - $this->modifiedColumns[] = CcFilesPeer::CONDUCTOR; - } - - return $this; - } // setDbConductor() - - /** - * Set the value of [lyricist] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbLyricist($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->lyricist !== $v) { - $this->lyricist = $v; - $this->modifiedColumns[] = CcFilesPeer::LYRICIST; - } - - return $this; - } // setDbLyricist() - - /** - * Set the value of [original_lyricist] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbOriginalLyricist($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->original_lyricist !== $v) { - $this->original_lyricist = $v; - $this->modifiedColumns[] = CcFilesPeer::ORIGINAL_LYRICIST; - } - - return $this; - } // setDbOriginalLyricist() - - /** - * Set the value of [radio_station_name] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbRadioStationName($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; - } // setDbRadioStationName() - - /** - * Set the value of [info_url] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbInfoUrl($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->info_url !== $v) { - $this->info_url = $v; - $this->modifiedColumns[] = CcFilesPeer::INFO_URL; - } - - return $this; - } // setDbInfoUrl() - - /** - * Set the value of [artist_url] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbArtistUrl($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->artist_url !== $v) { - $this->artist_url = $v; - $this->modifiedColumns[] = CcFilesPeer::ARTIST_URL; - } - - return $this; - } // setDbArtistUrl() - - /** - * Set the value of [audio_source_url] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbAudioSourceUrl($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; - } // setDbAudioSourceUrl() - - /** - * Set the value of [radio_station_url] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbRadioStationUrl($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; - } // setDbRadioStationUrl() - - /** - * Set the value of [buy_this_url] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbBuyThisUrl($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; - } // setDbBuyThisUrl() - - /** - * Set the value of [isrc_number] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbIsrcNumber($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->isrc_number !== $v) { - $this->isrc_number = $v; - $this->modifiedColumns[] = CcFilesPeer::ISRC_NUMBER; - } - - return $this; - } // setDbIsrcNumber() - - /** - * Set the value of [catalog_number] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbCatalogNumber($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->catalog_number !== $v) { - $this->catalog_number = $v; - $this->modifiedColumns[] = CcFilesPeer::CATALOG_NUMBER; - } - - return $this; - } // setDbCatalogNumber() - - /** - * Set the value of [original_artist] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbOriginalArtist($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->original_artist !== $v) { - $this->original_artist = $v; - $this->modifiedColumns[] = CcFilesPeer::ORIGINAL_ARTIST; - } - - return $this; - } // setDbOriginalArtist() - - /** - * Set the value of [copyright] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbCopyright($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->copyright !== $v) { - $this->copyright = $v; - $this->modifiedColumns[] = CcFilesPeer::COPYRIGHT; - } - - return $this; - } // setDbCopyright() - - /** - * Set the value of [report_datetime] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbReportDatetime($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->report_datetime !== $v) { - $this->report_datetime = $v; - $this->modifiedColumns[] = CcFilesPeer::REPORT_DATETIME; - } - - return $this; - } // setDbReportDatetime() - - /** - * Set the value of [report_location] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbReportLocation($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->report_location !== $v) { - $this->report_location = $v; - $this->modifiedColumns[] = CcFilesPeer::REPORT_LOCATION; - } - - return $this; - } // setDbReportLocation() - - /** - * Set the value of [report_organization] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbReportOrganization($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->report_organization !== $v) { - $this->report_organization = $v; - $this->modifiedColumns[] = CcFilesPeer::REPORT_ORGANIZATION; - } - - return $this; - } // setDbReportOrganization() - - /** - * Set the value of [subject] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbSubject($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->subject !== $v) { - $this->subject = $v; - $this->modifiedColumns[] = CcFilesPeer::SUBJECT; - } - - return $this; - } // setDbSubject() - - /** - * Set the value of [contributor] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbContributor($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->contributor !== $v) { - $this->contributor = $v; - $this->modifiedColumns[] = CcFilesPeer::CONTRIBUTOR; - } - - return $this; - } // setDbContributor() - - /** - * Set the value of [language] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbLanguage($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->language !== $v) { - $this->language = $v; - $this->modifiedColumns[] = CcFilesPeer::LANGUAGE; - } - - return $this; - } // setDbLanguage() - - /** - * Set the value of [file_exists] column. - * - * @param boolean $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbFileExists($v) - { - if ($v !== null) { - $v = (boolean) $v; - } - - if ($this->file_exists !== $v || $this->isNew()) { - $this->file_exists = $v; - $this->modifiedColumns[] = CcFilesPeer::FILE_EXISTS; - } - - return $this; - } // setDbFileExists() - - /** - * Set the value of [soundcloud_id] column. - * - * @param int $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbSoundcloudId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->soundcloud_id !== $v) { - $this->soundcloud_id = $v; - $this->modifiedColumns[] = CcFilesPeer::SOUNDCLOUD_ID; - } - - return $this; - } // setDbSoundcloudId() - - /** - * Set the value of [soundcloud_error_code] column. - * - * @param int $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbSoundcloudErrorCode($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->soundcloud_error_code !== $v) { - $this->soundcloud_error_code = $v; - $this->modifiedColumns[] = CcFilesPeer::SOUNDCLOUD_ERROR_CODE; - } - - return $this; - } // setDbSoundcloudErrorCode() - - /** - * Set the value of [soundcloud_error_msg] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbSoundcloudErrorMsg($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->soundcloud_error_msg !== $v) { - $this->soundcloud_error_msg = $v; - $this->modifiedColumns[] = CcFilesPeer::SOUNDCLOUD_ERROR_MSG; - } - - return $this; - } // setDbSoundcloudErrorMsg() - - /** - * Set the value of [soundcloud_link_to_file] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbSoundcloudLinkToFile($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->soundcloud_link_to_file !== $v) { - $this->soundcloud_link_to_file = $v; - $this->modifiedColumns[] = CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE; - } - - return $this; - } // setDbSoundcloudLinkToFile() - - /** - * Sets the value of [soundcloud_upload_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 CcFiles The current object (for fluent API support) - */ - public function setDbSoundCloundUploadTime($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->soundcloud_upload_time !== null || $dt !== null ) { - // (nested ifs are a little easier to read in this case) - - $currNorm = ($this->soundcloud_upload_time !== null && $tmpDt = new DateTime($this->soundcloud_upload_time)) ? $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->soundcloud_upload_time = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); - $this->modifiedColumns[] = CcFilesPeer::SOUNDCLOUD_UPLOAD_TIME; - } - } // if either are not null - - return $this; - } // setDbSoundCloundUploadTime() - - /** - * Set the value of [replay_gain] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbReplayGain($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->replay_gain !== $v) { - $this->replay_gain = $v; - $this->modifiedColumns[] = CcFilesPeer::REPLAY_GAIN; - } - - return $this; - } // setDbReplayGain() - - /** - * Set the value of [owner_id] column. - * - * @param int $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbOwnerId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->owner_id !== $v) { - $this->owner_id = $v; - $this->modifiedColumns[] = CcFilesPeer::OWNER_ID; - } - - if ($this->aFkOwner !== null && $this->aFkOwner->getDbId() !== $v) { - $this->aFkOwner = null; - } - - return $this; - } // setDbOwnerId() - - /** - * Set the value of [cuein] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbCuein($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->cuein !== $v || $this->isNew()) { - $this->cuein = $v; - $this->modifiedColumns[] = CcFilesPeer::CUEIN; - } - - return $this; - } // setDbCuein() - - /** - * Set the value of [cueout] column. - * - * @param string $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbCueout($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->cueout !== $v || $this->isNew()) { - $this->cueout = $v; - $this->modifiedColumns[] = CcFilesPeer::CUEOUT; - } - - return $this; - } // setDbCueout() - - /** - * Set the value of [silan_check] column. - * - * @param boolean $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbSilanCheck($v) - { - if ($v !== null) { - $v = (boolean) $v; - } - - if ($this->silan_check !== $v || $this->isNew()) { - $this->silan_check = $v; - $this->modifiedColumns[] = CcFilesPeer::SILAN_CHECK; - } - - return $this; - } // setDbSilanCheck() - - /** - * Set the value of [hidden] column. - * - * @param boolean $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbHidden($v) - { - if ($v !== null) { - $v = (boolean) $v; - } - - if ($this->hidden !== $v || $this->isNew()) { - $this->hidden = $v; - $this->modifiedColumns[] = CcFilesPeer::HIDDEN; - } - - return $this; - } // setDbHidden() - - /** - * Set the value of [is_scheduled] column. - * - * @param boolean $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbIsScheduled($v) - { - if ($v !== null) { - $v = (boolean) $v; - } - - if ($this->is_scheduled !== $v || $this->isNew()) { - $this->is_scheduled = $v; - $this->modifiedColumns[] = CcFilesPeer::IS_SCHEDULED; - } - - return $this; - } // setDbIsScheduled() - - /** - * Set the value of [is_playlist] column. - * - * @param boolean $v new value - * @return CcFiles The current object (for fluent API support) - */ - public function setDbIsPlaylist($v) - { - if ($v !== null) { - $v = (boolean) $v; - } - - if ($this->is_playlist !== $v || $this->isNew()) { - $this->is_playlist = $v; - $this->modifiedColumns[] = CcFilesPeer::IS_PLAYLIST; - } - - return $this; - } // setDbIsPlaylist() - - /** - * 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; - } - - if ($this->length !== '00:00:00') { - return false; - } - - if ($this->file_exists !== true) { - return false; - } - - if ($this->cuein !== '00:00:00') { - return false; - } - - if ($this->cueout !== '00:00:00') { - return false; - } - - if ($this->silan_check !== false) { - return false; - } - - if ($this->hidden !== false) { - return false; - } - - if ($this->is_scheduled !== false) { - return false; - } - - if ($this->is_playlist !== false) { - 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->mime = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->ftype = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->directory = ($row[$startcol + 4] !== null) ? (int) $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->utime = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; - $this->lptime = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null; - $this->md5 = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null; - $this->track_title = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null; - $this->artist_name = ($row[$startcol + 14] !== null) ? (string) $row[$startcol + 14] : null; - $this->bit_rate = ($row[$startcol + 15] !== null) ? (int) $row[$startcol + 15] : null; - $this->sample_rate = ($row[$startcol + 16] !== null) ? (int) $row[$startcol + 16] : null; - $this->format = ($row[$startcol + 17] !== null) ? (string) $row[$startcol + 17] : null; - $this->length = ($row[$startcol + 18] !== null) ? (string) $row[$startcol + 18] : null; - $this->album_title = ($row[$startcol + 19] !== null) ? (string) $row[$startcol + 19] : null; - $this->genre = ($row[$startcol + 20] !== null) ? (string) $row[$startcol + 20] : null; - $this->comments = ($row[$startcol + 21] !== null) ? (string) $row[$startcol + 21] : null; - $this->year = ($row[$startcol + 22] !== null) ? (string) $row[$startcol + 22] : null; - $this->track_number = ($row[$startcol + 23] !== null) ? (int) $row[$startcol + 23] : null; - $this->channels = ($row[$startcol + 24] !== null) ? (int) $row[$startcol + 24] : null; - $this->url = ($row[$startcol + 25] !== null) ? (string) $row[$startcol + 25] : null; - $this->bpm = ($row[$startcol + 26] !== null) ? (int) $row[$startcol + 26] : null; - $this->rating = ($row[$startcol + 27] !== null) ? (string) $row[$startcol + 27] : null; - $this->encoded_by = ($row[$startcol + 28] !== null) ? (string) $row[$startcol + 28] : null; - $this->disc_number = ($row[$startcol + 29] !== null) ? (string) $row[$startcol + 29] : null; - $this->mood = ($row[$startcol + 30] !== null) ? (string) $row[$startcol + 30] : null; - $this->label = ($row[$startcol + 31] !== null) ? (string) $row[$startcol + 31] : null; - $this->composer = ($row[$startcol + 32] !== null) ? (string) $row[$startcol + 32] : null; - $this->encoder = ($row[$startcol + 33] !== null) ? (string) $row[$startcol + 33] : null; - $this->checksum = ($row[$startcol + 34] !== null) ? (string) $row[$startcol + 34] : null; - $this->lyrics = ($row[$startcol + 35] !== null) ? (string) $row[$startcol + 35] : null; - $this->orchestra = ($row[$startcol + 36] !== null) ? (string) $row[$startcol + 36] : null; - $this->conductor = ($row[$startcol + 37] !== null) ? (string) $row[$startcol + 37] : null; - $this->lyricist = ($row[$startcol + 38] !== null) ? (string) $row[$startcol + 38] : null; - $this->original_lyricist = ($row[$startcol + 39] !== null) ? (string) $row[$startcol + 39] : null; - $this->radio_station_name = ($row[$startcol + 40] !== null) ? (string) $row[$startcol + 40] : null; - $this->info_url = ($row[$startcol + 41] !== null) ? (string) $row[$startcol + 41] : null; - $this->artist_url = ($row[$startcol + 42] !== null) ? (string) $row[$startcol + 42] : null; - $this->audio_source_url = ($row[$startcol + 43] !== null) ? (string) $row[$startcol + 43] : null; - $this->radio_station_url = ($row[$startcol + 44] !== null) ? (string) $row[$startcol + 44] : null; - $this->buy_this_url = ($row[$startcol + 45] !== null) ? (string) $row[$startcol + 45] : null; - $this->isrc_number = ($row[$startcol + 46] !== null) ? (string) $row[$startcol + 46] : null; - $this->catalog_number = ($row[$startcol + 47] !== null) ? (string) $row[$startcol + 47] : null; - $this->original_artist = ($row[$startcol + 48] !== null) ? (string) $row[$startcol + 48] : null; - $this->copyright = ($row[$startcol + 49] !== null) ? (string) $row[$startcol + 49] : null; - $this->report_datetime = ($row[$startcol + 50] !== null) ? (string) $row[$startcol + 50] : null; - $this->report_location = ($row[$startcol + 51] !== null) ? (string) $row[$startcol + 51] : null; - $this->report_organization = ($row[$startcol + 52] !== null) ? (string) $row[$startcol + 52] : null; - $this->subject = ($row[$startcol + 53] !== null) ? (string) $row[$startcol + 53] : null; - $this->contributor = ($row[$startcol + 54] !== null) ? (string) $row[$startcol + 54] : null; - $this->language = ($row[$startcol + 55] !== null) ? (string) $row[$startcol + 55] : null; - $this->file_exists = ($row[$startcol + 56] !== null) ? (boolean) $row[$startcol + 56] : null; - $this->soundcloud_id = ($row[$startcol + 57] !== null) ? (int) $row[$startcol + 57] : null; - $this->soundcloud_error_code = ($row[$startcol + 58] !== null) ? (int) $row[$startcol + 58] : null; - $this->soundcloud_error_msg = ($row[$startcol + 59] !== null) ? (string) $row[$startcol + 59] : null; - $this->soundcloud_link_to_file = ($row[$startcol + 60] !== null) ? (string) $row[$startcol + 60] : null; - $this->soundcloud_upload_time = ($row[$startcol + 61] !== null) ? (string) $row[$startcol + 61] : null; - $this->replay_gain = ($row[$startcol + 62] !== null) ? (string) $row[$startcol + 62] : null; - $this->owner_id = ($row[$startcol + 63] !== null) ? (int) $row[$startcol + 63] : null; - $this->cuein = ($row[$startcol + 64] !== null) ? (string) $row[$startcol + 64] : null; - $this->cueout = ($row[$startcol + 65] !== null) ? (string) $row[$startcol + 65] : null; - $this->silan_check = ($row[$startcol + 66] !== null) ? (boolean) $row[$startcol + 66] : null; - $this->hidden = ($row[$startcol + 67] !== null) ? (boolean) $row[$startcol + 67] : null; - $this->is_scheduled = ($row[$startcol + 68] !== null) ? (boolean) $row[$startcol + 68] : null; - $this->is_playlist = ($row[$startcol + 69] !== null) ? (boolean) $row[$startcol + 69] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 70; // 70 = 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->aCcMusicDirs !== null && $this->directory !== $this->aCcMusicDirs->getId()) { - $this->aCcMusicDirs = null; - } - if ($this->aCcSubjsRelatedByDbEditedby !== null && $this->editedby !== $this->aCcSubjsRelatedByDbEditedby->getDbId()) { - $this->aCcSubjsRelatedByDbEditedby = null; - } - if ($this->aFkOwner !== null && $this->owner_id !== $this->aFkOwner->getDbId()) { - $this->aFkOwner = 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->aFkOwner = null; - $this->aCcSubjsRelatedByDbEditedby = null; - $this->aCcMusicDirs = null; - $this->collCcShowInstancess = null; - - $this->collCcPlaylistcontentss = null; - - $this->collCcBlockcontentss = null; - - $this->collCcSchedules = null; - - $this->collCcPlayoutHistorys = 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->aFkOwner !== null) { - if ($this->aFkOwner->isModified() || $this->aFkOwner->isNew()) { - $affectedRows += $this->aFkOwner->save($con); - } - $this->setFkOwner($this->aFkOwner); - } - - if ($this->aCcSubjsRelatedByDbEditedby !== null) { - if ($this->aCcSubjsRelatedByDbEditedby->isModified() || $this->aCcSubjsRelatedByDbEditedby->isNew()) { - $affectedRows += $this->aCcSubjsRelatedByDbEditedby->save($con); - } - $this->setCcSubjsRelatedByDbEditedby($this->aCcSubjsRelatedByDbEditedby); - } - - if ($this->aCcMusicDirs !== null) { - if ($this->aCcMusicDirs->isModified() || $this->aCcMusicDirs->isNew()) { - $affectedRows += $this->aCcMusicDirs->save($con); - } - $this->setCcMusicDirs($this->aCcMusicDirs); - } - - 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->collCcShowInstancess !== null) { - foreach ($this->collCcShowInstancess as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->collCcPlaylistcontentss !== null) { - foreach ($this->collCcPlaylistcontentss as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->collCcBlockcontentss !== null) { - foreach ($this->collCcBlockcontentss as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->collCcSchedules !== null) { - foreach ($this->collCcSchedules as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->collCcPlayoutHistorys !== null) { - foreach ($this->collCcPlayoutHistorys 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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aFkOwner !== null) { - if (!$this->aFkOwner->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aFkOwner->getValidationFailures()); - } - } - - if ($this->aCcSubjsRelatedByDbEditedby !== null) { - if (!$this->aCcSubjsRelatedByDbEditedby->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcSubjsRelatedByDbEditedby->getValidationFailures()); - } - } - - if ($this->aCcMusicDirs !== null) { - if (!$this->aCcMusicDirs->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcMusicDirs->getValidationFailures()); - } - } - - - if (($retval = CcFilesPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collCcShowInstancess !== null) { - foreach ($this->collCcShowInstancess as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCcPlaylistcontentss !== null) { - foreach ($this->collCcPlaylistcontentss as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCcBlockcontentss !== null) { - foreach ($this->collCcBlockcontentss as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCcSchedules !== null) { - foreach ($this->collCcSchedules as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCcPlayoutHistorys !== null) { - foreach ($this->collCcPlayoutHistorys 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->getDbName(); - break; - case 2: - return $this->getDbMime(); - break; - case 3: - return $this->getDbFtype(); - break; - case 4: - return $this->getDbDirectory(); - break; - case 5: - return $this->getDbFilepath(); - break; - case 6: - return $this->getDbState(); - break; - case 7: - return $this->getDbCurrentlyaccessing(); - break; - case 8: - return $this->getDbEditedby(); - break; - case 9: - return $this->getDbMtime(); - break; - case 10: - return $this->getDbUtime(); - break; - case 11: - return $this->getDbLPtime(); - break; - case 12: - return $this->getDbMd5(); - break; - case 13: - return $this->getDbTrackTitle(); - break; - case 14: - return $this->getDbArtistName(); - break; - case 15: - return $this->getDbBitRate(); - break; - case 16: - return $this->getDbSampleRate(); - break; - case 17: - return $this->getDbFormat(); - break; - case 18: - return $this->getDbLength(); - break; - case 19: - return $this->getDbAlbumTitle(); - break; - case 20: - return $this->getDbGenre(); - break; - case 21: - return $this->getDbComments(); - break; - case 22: - return $this->getDbYear(); - break; - case 23: - return $this->getDbTrackNumber(); - break; - case 24: - return $this->getDbChannels(); - break; - case 25: - return $this->getDbUrl(); - break; - case 26: - return $this->getDbBpm(); - break; - case 27: - return $this->getDbRating(); - break; - case 28: - return $this->getDbEncodedBy(); - break; - case 29: - return $this->getDbDiscNumber(); - break; - case 30: - return $this->getDbMood(); - break; - case 31: - return $this->getDbLabel(); - break; - case 32: - return $this->getDbComposer(); - break; - case 33: - return $this->getDbEncoder(); - break; - case 34: - return $this->getDbChecksum(); - break; - case 35: - return $this->getDbLyrics(); - break; - case 36: - return $this->getDbOrchestra(); - break; - case 37: - return $this->getDbConductor(); - break; - case 38: - return $this->getDbLyricist(); - break; - case 39: - return $this->getDbOriginalLyricist(); - break; - case 40: - return $this->getDbRadioStationName(); - break; - case 41: - return $this->getDbInfoUrl(); - break; - case 42: - return $this->getDbArtistUrl(); - break; - case 43: - return $this->getDbAudioSourceUrl(); - break; - case 44: - return $this->getDbRadioStationUrl(); - break; - case 45: - return $this->getDbBuyThisUrl(); - break; - case 46: - return $this->getDbIsrcNumber(); - break; - case 47: - return $this->getDbCatalogNumber(); - break; - case 48: - return $this->getDbOriginalArtist(); - break; - case 49: - return $this->getDbCopyright(); - break; - case 50: - return $this->getDbReportDatetime(); - break; - case 51: - return $this->getDbReportLocation(); - break; - case 52: - return $this->getDbReportOrganization(); - break; - case 53: - return $this->getDbSubject(); - break; - case 54: - return $this->getDbContributor(); - break; - case 55: - return $this->getDbLanguage(); - break; - case 56: - return $this->getDbFileExists(); - break; - case 57: - return $this->getDbSoundcloudId(); - break; - case 58: - return $this->getDbSoundcloudErrorCode(); - break; - case 59: - return $this->getDbSoundcloudErrorMsg(); - break; - case 60: - return $this->getDbSoundcloudLinkToFile(); - break; - case 61: - return $this->getDbSoundCloundUploadTime(); - break; - case 62: - return $this->getDbReplayGain(); - break; - case 63: - return $this->getDbOwnerId(); - break; - case 64: - return $this->getDbCuein(); - break; - case 65: - return $this->getDbCueout(); - break; - case 66: - return $this->getDbSilanCheck(); - break; - case 67: - return $this->getDbHidden(); - break; - case 68: - return $this->getDbIsScheduled(); - break; - case 69: - return $this->getDbIsPlaylist(); - 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->getDbName(), - $keys[2] => $this->getDbMime(), - $keys[3] => $this->getDbFtype(), - $keys[4] => $this->getDbDirectory(), - $keys[5] => $this->getDbFilepath(), - $keys[6] => $this->getDbState(), - $keys[7] => $this->getDbCurrentlyaccessing(), - $keys[8] => $this->getDbEditedby(), - $keys[9] => $this->getDbMtime(), - $keys[10] => $this->getDbUtime(), - $keys[11] => $this->getDbLPtime(), - $keys[12] => $this->getDbMd5(), - $keys[13] => $this->getDbTrackTitle(), - $keys[14] => $this->getDbArtistName(), - $keys[15] => $this->getDbBitRate(), - $keys[16] => $this->getDbSampleRate(), - $keys[17] => $this->getDbFormat(), - $keys[18] => $this->getDbLength(), - $keys[19] => $this->getDbAlbumTitle(), - $keys[20] => $this->getDbGenre(), - $keys[21] => $this->getDbComments(), - $keys[22] => $this->getDbYear(), - $keys[23] => $this->getDbTrackNumber(), - $keys[24] => $this->getDbChannels(), - $keys[25] => $this->getDbUrl(), - $keys[26] => $this->getDbBpm(), - $keys[27] => $this->getDbRating(), - $keys[28] => $this->getDbEncodedBy(), - $keys[29] => $this->getDbDiscNumber(), - $keys[30] => $this->getDbMood(), - $keys[31] => $this->getDbLabel(), - $keys[32] => $this->getDbComposer(), - $keys[33] => $this->getDbEncoder(), - $keys[34] => $this->getDbChecksum(), - $keys[35] => $this->getDbLyrics(), - $keys[36] => $this->getDbOrchestra(), - $keys[37] => $this->getDbConductor(), - $keys[38] => $this->getDbLyricist(), - $keys[39] => $this->getDbOriginalLyricist(), - $keys[40] => $this->getDbRadioStationName(), - $keys[41] => $this->getDbInfoUrl(), - $keys[42] => $this->getDbArtistUrl(), - $keys[43] => $this->getDbAudioSourceUrl(), - $keys[44] => $this->getDbRadioStationUrl(), - $keys[45] => $this->getDbBuyThisUrl(), - $keys[46] => $this->getDbIsrcNumber(), - $keys[47] => $this->getDbCatalogNumber(), - $keys[48] => $this->getDbOriginalArtist(), - $keys[49] => $this->getDbCopyright(), - $keys[50] => $this->getDbReportDatetime(), - $keys[51] => $this->getDbReportLocation(), - $keys[52] => $this->getDbReportOrganization(), - $keys[53] => $this->getDbSubject(), - $keys[54] => $this->getDbContributor(), - $keys[55] => $this->getDbLanguage(), - $keys[56] => $this->getDbFileExists(), - $keys[57] => $this->getDbSoundcloudId(), - $keys[58] => $this->getDbSoundcloudErrorCode(), - $keys[59] => $this->getDbSoundcloudErrorMsg(), - $keys[60] => $this->getDbSoundcloudLinkToFile(), - $keys[61] => $this->getDbSoundCloundUploadTime(), - $keys[62] => $this->getDbReplayGain(), - $keys[63] => $this->getDbOwnerId(), - $keys[64] => $this->getDbCuein(), - $keys[65] => $this->getDbCueout(), - $keys[66] => $this->getDbSilanCheck(), - $keys[67] => $this->getDbHidden(), - $keys[68] => $this->getDbIsScheduled(), - $keys[69] => $this->getDbIsPlaylist(), - ); - if ($includeForeignObjects) { - if (null !== $this->aFkOwner) { - $result['FkOwner'] = $this->aFkOwner->toArray($keyType, $includeLazyLoadColumns, true); - } - if (null !== $this->aCcSubjsRelatedByDbEditedby) { - $result['CcSubjsRelatedByDbEditedby'] = $this->aCcSubjsRelatedByDbEditedby->toArray($keyType, $includeLazyLoadColumns, true); - } - if (null !== $this->aCcMusicDirs) { - $result['CcMusicDirs'] = $this->aCcMusicDirs->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->setDbName($value); - break; - case 2: - $this->setDbMime($value); - break; - case 3: - $this->setDbFtype($value); - break; - case 4: - $this->setDbDirectory($value); - break; - case 5: - $this->setDbFilepath($value); - break; - case 6: - $this->setDbState($value); - break; - case 7: - $this->setDbCurrentlyaccessing($value); - break; - case 8: - $this->setDbEditedby($value); - break; - case 9: - $this->setDbMtime($value); - break; - case 10: - $this->setDbUtime($value); - break; - case 11: - $this->setDbLPtime($value); - break; - case 12: - $this->setDbMd5($value); - break; - case 13: - $this->setDbTrackTitle($value); - break; - case 14: - $this->setDbArtistName($value); - break; - case 15: - $this->setDbBitRate($value); - break; - case 16: - $this->setDbSampleRate($value); - break; - case 17: - $this->setDbFormat($value); - break; - case 18: - $this->setDbLength($value); - break; - case 19: - $this->setDbAlbumTitle($value); - break; - case 20: - $this->setDbGenre($value); - break; - case 21: - $this->setDbComments($value); - break; - case 22: - $this->setDbYear($value); - break; - case 23: - $this->setDbTrackNumber($value); - break; - case 24: - $this->setDbChannels($value); - break; - case 25: - $this->setDbUrl($value); - break; - case 26: - $this->setDbBpm($value); - break; - case 27: - $this->setDbRating($value); - break; - case 28: - $this->setDbEncodedBy($value); - break; - case 29: - $this->setDbDiscNumber($value); - break; - case 30: - $this->setDbMood($value); - break; - case 31: - $this->setDbLabel($value); - break; - case 32: - $this->setDbComposer($value); - break; - case 33: - $this->setDbEncoder($value); - break; - case 34: - $this->setDbChecksum($value); - break; - case 35: - $this->setDbLyrics($value); - break; - case 36: - $this->setDbOrchestra($value); - break; - case 37: - $this->setDbConductor($value); - break; - case 38: - $this->setDbLyricist($value); - break; - case 39: - $this->setDbOriginalLyricist($value); - break; - case 40: - $this->setDbRadioStationName($value); - break; - case 41: - $this->setDbInfoUrl($value); - break; - case 42: - $this->setDbArtistUrl($value); - break; - case 43: - $this->setDbAudioSourceUrl($value); - break; - case 44: - $this->setDbRadioStationUrl($value); - break; - case 45: - $this->setDbBuyThisUrl($value); - break; - case 46: - $this->setDbIsrcNumber($value); - break; - case 47: - $this->setDbCatalogNumber($value); - break; - case 48: - $this->setDbOriginalArtist($value); - break; - case 49: - $this->setDbCopyright($value); - break; - case 50: - $this->setDbReportDatetime($value); - break; - case 51: - $this->setDbReportLocation($value); - break; - case 52: - $this->setDbReportOrganization($value); - break; - case 53: - $this->setDbSubject($value); - break; - case 54: - $this->setDbContributor($value); - break; - case 55: - $this->setDbLanguage($value); - break; - case 56: - $this->setDbFileExists($value); - break; - case 57: - $this->setDbSoundcloudId($value); - break; - case 58: - $this->setDbSoundcloudErrorCode($value); - break; - case 59: - $this->setDbSoundcloudErrorMsg($value); - break; - case 60: - $this->setDbSoundcloudLinkToFile($value); - break; - case 61: - $this->setDbSoundCloundUploadTime($value); - break; - case 62: - $this->setDbReplayGain($value); - break; - case 63: - $this->setDbOwnerId($value); - break; - case 64: - $this->setDbCuein($value); - break; - case 65: - $this->setDbCueout($value); - break; - case 66: - $this->setDbSilanCheck($value); - break; - case 67: - $this->setDbHidden($value); - break; - case 68: - $this->setDbIsScheduled($value); - break; - case 69: - $this->setDbIsPlaylist($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->setDbName($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbMime($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbFtype($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbDirectory($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbFilepath($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDbState($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setDbCurrentlyaccessing($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setDbEditedby($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setDbMtime($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setDbUtime($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setDbLPtime($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setDbMd5($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setDbTrackTitle($arr[$keys[13]]); - if (array_key_exists($keys[14], $arr)) $this->setDbArtistName($arr[$keys[14]]); - if (array_key_exists($keys[15], $arr)) $this->setDbBitRate($arr[$keys[15]]); - if (array_key_exists($keys[16], $arr)) $this->setDbSampleRate($arr[$keys[16]]); - if (array_key_exists($keys[17], $arr)) $this->setDbFormat($arr[$keys[17]]); - if (array_key_exists($keys[18], $arr)) $this->setDbLength($arr[$keys[18]]); - if (array_key_exists($keys[19], $arr)) $this->setDbAlbumTitle($arr[$keys[19]]); - if (array_key_exists($keys[20], $arr)) $this->setDbGenre($arr[$keys[20]]); - if (array_key_exists($keys[21], $arr)) $this->setDbComments($arr[$keys[21]]); - if (array_key_exists($keys[22], $arr)) $this->setDbYear($arr[$keys[22]]); - if (array_key_exists($keys[23], $arr)) $this->setDbTrackNumber($arr[$keys[23]]); - if (array_key_exists($keys[24], $arr)) $this->setDbChannels($arr[$keys[24]]); - if (array_key_exists($keys[25], $arr)) $this->setDbUrl($arr[$keys[25]]); - if (array_key_exists($keys[26], $arr)) $this->setDbBpm($arr[$keys[26]]); - if (array_key_exists($keys[27], $arr)) $this->setDbRating($arr[$keys[27]]); - if (array_key_exists($keys[28], $arr)) $this->setDbEncodedBy($arr[$keys[28]]); - if (array_key_exists($keys[29], $arr)) $this->setDbDiscNumber($arr[$keys[29]]); - if (array_key_exists($keys[30], $arr)) $this->setDbMood($arr[$keys[30]]); - if (array_key_exists($keys[31], $arr)) $this->setDbLabel($arr[$keys[31]]); - if (array_key_exists($keys[32], $arr)) $this->setDbComposer($arr[$keys[32]]); - if (array_key_exists($keys[33], $arr)) $this->setDbEncoder($arr[$keys[33]]); - if (array_key_exists($keys[34], $arr)) $this->setDbChecksum($arr[$keys[34]]); - if (array_key_exists($keys[35], $arr)) $this->setDbLyrics($arr[$keys[35]]); - if (array_key_exists($keys[36], $arr)) $this->setDbOrchestra($arr[$keys[36]]); - if (array_key_exists($keys[37], $arr)) $this->setDbConductor($arr[$keys[37]]); - if (array_key_exists($keys[38], $arr)) $this->setDbLyricist($arr[$keys[38]]); - if (array_key_exists($keys[39], $arr)) $this->setDbOriginalLyricist($arr[$keys[39]]); - if (array_key_exists($keys[40], $arr)) $this->setDbRadioStationName($arr[$keys[40]]); - if (array_key_exists($keys[41], $arr)) $this->setDbInfoUrl($arr[$keys[41]]); - if (array_key_exists($keys[42], $arr)) $this->setDbArtistUrl($arr[$keys[42]]); - if (array_key_exists($keys[43], $arr)) $this->setDbAudioSourceUrl($arr[$keys[43]]); - if (array_key_exists($keys[44], $arr)) $this->setDbRadioStationUrl($arr[$keys[44]]); - if (array_key_exists($keys[45], $arr)) $this->setDbBuyThisUrl($arr[$keys[45]]); - if (array_key_exists($keys[46], $arr)) $this->setDbIsrcNumber($arr[$keys[46]]); - if (array_key_exists($keys[47], $arr)) $this->setDbCatalogNumber($arr[$keys[47]]); - if (array_key_exists($keys[48], $arr)) $this->setDbOriginalArtist($arr[$keys[48]]); - if (array_key_exists($keys[49], $arr)) $this->setDbCopyright($arr[$keys[49]]); - if (array_key_exists($keys[50], $arr)) $this->setDbReportDatetime($arr[$keys[50]]); - if (array_key_exists($keys[51], $arr)) $this->setDbReportLocation($arr[$keys[51]]); - if (array_key_exists($keys[52], $arr)) $this->setDbReportOrganization($arr[$keys[52]]); - if (array_key_exists($keys[53], $arr)) $this->setDbSubject($arr[$keys[53]]); - if (array_key_exists($keys[54], $arr)) $this->setDbContributor($arr[$keys[54]]); - if (array_key_exists($keys[55], $arr)) $this->setDbLanguage($arr[$keys[55]]); - if (array_key_exists($keys[56], $arr)) $this->setDbFileExists($arr[$keys[56]]); - if (array_key_exists($keys[57], $arr)) $this->setDbSoundcloudId($arr[$keys[57]]); - if (array_key_exists($keys[58], $arr)) $this->setDbSoundcloudErrorCode($arr[$keys[58]]); - if (array_key_exists($keys[59], $arr)) $this->setDbSoundcloudErrorMsg($arr[$keys[59]]); - if (array_key_exists($keys[60], $arr)) $this->setDbSoundcloudLinkToFile($arr[$keys[60]]); - if (array_key_exists($keys[61], $arr)) $this->setDbSoundCloundUploadTime($arr[$keys[61]]); - if (array_key_exists($keys[62], $arr)) $this->setDbReplayGain($arr[$keys[62]]); - if (array_key_exists($keys[63], $arr)) $this->setDbOwnerId($arr[$keys[63]]); - if (array_key_exists($keys[64], $arr)) $this->setDbCuein($arr[$keys[64]]); - if (array_key_exists($keys[65], $arr)) $this->setDbCueout($arr[$keys[65]]); - if (array_key_exists($keys[66], $arr)) $this->setDbSilanCheck($arr[$keys[66]]); - if (array_key_exists($keys[67], $arr)) $this->setDbHidden($arr[$keys[67]]); - if (array_key_exists($keys[68], $arr)) $this->setDbIsScheduled($arr[$keys[68]]); - if (array_key_exists($keys[69], $arr)) $this->setDbIsPlaylist($arr[$keys[69]]); - } - - /** - * 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::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::DIRECTORY)) $criteria->add(CcFilesPeer::DIRECTORY, $this->directory); - 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::UTIME)) $criteria->add(CcFilesPeer::UTIME, $this->utime); - if ($this->isColumnModified(CcFilesPeer::LPTIME)) $criteria->add(CcFilesPeer::LPTIME, $this->lptime); - 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); - if ($this->isColumnModified(CcFilesPeer::FILE_EXISTS)) $criteria->add(CcFilesPeer::FILE_EXISTS, $this->file_exists); - if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_ID)) $criteria->add(CcFilesPeer::SOUNDCLOUD_ID, $this->soundcloud_id); - if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_ERROR_CODE)) $criteria->add(CcFilesPeer::SOUNDCLOUD_ERROR_CODE, $this->soundcloud_error_code); - if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_ERROR_MSG)) $criteria->add(CcFilesPeer::SOUNDCLOUD_ERROR_MSG, $this->soundcloud_error_msg); - if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE)) $criteria->add(CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE, $this->soundcloud_link_to_file); - if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_UPLOAD_TIME)) $criteria->add(CcFilesPeer::SOUNDCLOUD_UPLOAD_TIME, $this->soundcloud_upload_time); - if ($this->isColumnModified(CcFilesPeer::REPLAY_GAIN)) $criteria->add(CcFilesPeer::REPLAY_GAIN, $this->replay_gain); - if ($this->isColumnModified(CcFilesPeer::OWNER_ID)) $criteria->add(CcFilesPeer::OWNER_ID, $this->owner_id); - if ($this->isColumnModified(CcFilesPeer::CUEIN)) $criteria->add(CcFilesPeer::CUEIN, $this->cuein); - if ($this->isColumnModified(CcFilesPeer::CUEOUT)) $criteria->add(CcFilesPeer::CUEOUT, $this->cueout); - if ($this->isColumnModified(CcFilesPeer::SILAN_CHECK)) $criteria->add(CcFilesPeer::SILAN_CHECK, $this->silan_check); - if ($this->isColumnModified(CcFilesPeer::HIDDEN)) $criteria->add(CcFilesPeer::HIDDEN, $this->hidden); - if ($this->isColumnModified(CcFilesPeer::IS_SCHEDULED)) $criteria->add(CcFilesPeer::IS_SCHEDULED, $this->is_scheduled); - if ($this->isColumnModified(CcFilesPeer::IS_PLAYLIST)) $criteria->add(CcFilesPeer::IS_PLAYLIST, $this->is_playlist); - - 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->setDbName($this->name); - $copyObj->setDbMime($this->mime); - $copyObj->setDbFtype($this->ftype); - $copyObj->setDbDirectory($this->directory); - $copyObj->setDbFilepath($this->filepath); - $copyObj->setDbState($this->state); - $copyObj->setDbCurrentlyaccessing($this->currentlyaccessing); - $copyObj->setDbEditedby($this->editedby); - $copyObj->setDbMtime($this->mtime); - $copyObj->setDbUtime($this->utime); - $copyObj->setDbLPtime($this->lptime); - $copyObj->setDbMd5($this->md5); - $copyObj->setDbTrackTitle($this->track_title); - $copyObj->setDbArtistName($this->artist_name); - $copyObj->setDbBitRate($this->bit_rate); - $copyObj->setDbSampleRate($this->sample_rate); - $copyObj->setDbFormat($this->format); - $copyObj->setDbLength($this->length); - $copyObj->setDbAlbumTitle($this->album_title); - $copyObj->setDbGenre($this->genre); - $copyObj->setDbComments($this->comments); - $copyObj->setDbYear($this->year); - $copyObj->setDbTrackNumber($this->track_number); - $copyObj->setDbChannels($this->channels); - $copyObj->setDbUrl($this->url); - $copyObj->setDbBpm($this->bpm); - $copyObj->setDbRating($this->rating); - $copyObj->setDbEncodedBy($this->encoded_by); - $copyObj->setDbDiscNumber($this->disc_number); - $copyObj->setDbMood($this->mood); - $copyObj->setDbLabel($this->label); - $copyObj->setDbComposer($this->composer); - $copyObj->setDbEncoder($this->encoder); - $copyObj->setDbChecksum($this->checksum); - $copyObj->setDbLyrics($this->lyrics); - $copyObj->setDbOrchestra($this->orchestra); - $copyObj->setDbConductor($this->conductor); - $copyObj->setDbLyricist($this->lyricist); - $copyObj->setDbOriginalLyricist($this->original_lyricist); - $copyObj->setDbRadioStationName($this->radio_station_name); - $copyObj->setDbInfoUrl($this->info_url); - $copyObj->setDbArtistUrl($this->artist_url); - $copyObj->setDbAudioSourceUrl($this->audio_source_url); - $copyObj->setDbRadioStationUrl($this->radio_station_url); - $copyObj->setDbBuyThisUrl($this->buy_this_url); - $copyObj->setDbIsrcNumber($this->isrc_number); - $copyObj->setDbCatalogNumber($this->catalog_number); - $copyObj->setDbOriginalArtist($this->original_artist); - $copyObj->setDbCopyright($this->copyright); - $copyObj->setDbReportDatetime($this->report_datetime); - $copyObj->setDbReportLocation($this->report_location); - $copyObj->setDbReportOrganization($this->report_organization); - $copyObj->setDbSubject($this->subject); - $copyObj->setDbContributor($this->contributor); - $copyObj->setDbLanguage($this->language); - $copyObj->setDbFileExists($this->file_exists); - $copyObj->setDbSoundcloudId($this->soundcloud_id); - $copyObj->setDbSoundcloudErrorCode($this->soundcloud_error_code); - $copyObj->setDbSoundcloudErrorMsg($this->soundcloud_error_msg); - $copyObj->setDbSoundcloudLinkToFile($this->soundcloud_link_to_file); - $copyObj->setDbSoundCloundUploadTime($this->soundcloud_upload_time); - $copyObj->setDbReplayGain($this->replay_gain); - $copyObj->setDbOwnerId($this->owner_id); - $copyObj->setDbCuein($this->cuein); - $copyObj->setDbCueout($this->cueout); - $copyObj->setDbSilanCheck($this->silan_check); - $copyObj->setDbHidden($this->hidden); - $copyObj->setDbIsScheduled($this->is_scheduled); - $copyObj->setDbIsPlaylist($this->is_playlist); - - 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->getCcShowInstancess() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcShowInstances($relObj->copy($deepCopy)); - } - } - - 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)); - } - } - - foreach ($this->getCcBlockcontentss() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcBlockcontents($relObj->copy($deepCopy)); - } - } - - foreach ($this->getCcSchedules() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcSchedule($relObj->copy($deepCopy)); - } - } - - foreach ($this->getCcPlayoutHistorys() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcPlayoutHistory($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 setFkOwner(CcSubjs $v = null) - { - if ($v === null) { - $this->setDbOwnerId(NULL); - } else { - $this->setDbOwnerId($v->getDbId()); - } - - $this->aFkOwner = $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->addCcFilesRelatedByDbOwnerId($this); - } - - return $this; - } - - - /** - * Get the associated CcSubjs object - * - * @param PropelPDO Optional Connection object. - * @return CcSubjs The associated CcSubjs object. - * @throws PropelException - */ - public function getFkOwner(PropelPDO $con = null) - { - if ($this->aFkOwner === null && ($this->owner_id !== null)) { - $this->aFkOwner = CcSubjsQuery::create()->findPk($this->owner_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->aFkOwner->addCcFilessRelatedByDbOwnerId($this); - */ - } - return $this->aFkOwner; - } - - /** - * 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 setCcSubjsRelatedByDbEditedby(CcSubjs $v = null) - { - if ($v === null) { - $this->setDbEditedby(NULL); - } else { - $this->setDbEditedby($v->getDbId()); - } - - $this->aCcSubjsRelatedByDbEditedby = $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->addCcFilesRelatedByDbEditedby($this); - } - - return $this; - } - - - /** - * Get the associated CcSubjs object - * - * @param PropelPDO Optional Connection object. - * @return CcSubjs The associated CcSubjs object. - * @throws PropelException - */ - public function getCcSubjsRelatedByDbEditedby(PropelPDO $con = null) - { - if ($this->aCcSubjsRelatedByDbEditedby === null && ($this->editedby !== null)) { - $this->aCcSubjsRelatedByDbEditedby = 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->aCcSubjsRelatedByDbEditedby->addCcFilessRelatedByDbEditedby($this); - */ - } - return $this->aCcSubjsRelatedByDbEditedby; - } - - /** - * Declares an association between this object and a CcMusicDirs object. - * - * @param CcMusicDirs $v - * @return CcFiles The current object (for fluent API support) - * @throws PropelException - */ - public function setCcMusicDirs(CcMusicDirs $v = null) - { - if ($v === null) { - $this->setDbDirectory(NULL); - } else { - $this->setDbDirectory($v->getId()); - } - - $this->aCcMusicDirs = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcMusicDirs object, it will not be re-added. - if ($v !== null) { - $v->addCcFiles($this); - } - - return $this; - } - - - /** - * Get the associated CcMusicDirs object - * - * @param PropelPDO Optional Connection object. - * @return CcMusicDirs The associated CcMusicDirs object. - * @throws PropelException - */ - public function getCcMusicDirs(PropelPDO $con = null) - { - if ($this->aCcMusicDirs === null && ($this->directory !== null)) { - $this->aCcMusicDirs = CcMusicDirsQuery::create()->findPk($this->directory, $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->aCcMusicDirs->addCcFiless($this); - */ - } - return $this->aCcMusicDirs; - } - - /** - * Clears out the collCcShowInstancess 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 addCcShowInstancess() - */ - public function clearCcShowInstancess() - { - $this->collCcShowInstancess = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcShowInstancess collection. - * - * By default this just sets the collCcShowInstancess collection to an empty array (like clearcollCcShowInstancess()); - * 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 initCcShowInstancess() - { - $this->collCcShowInstancess = new PropelObjectCollection(); - $this->collCcShowInstancess->setModel('CcShowInstances'); - } - - /** - * Gets an array of CcShowInstances 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 CcShowInstances[] List of CcShowInstances objects - * @throws PropelException - */ - public function getCcShowInstancess($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcShowInstancess || null !== $criteria) { - if ($this->isNew() && null === $this->collCcShowInstancess) { - // return empty collection - $this->initCcShowInstancess(); - } else { - $collCcShowInstancess = CcShowInstancesQuery::create(null, $criteria) - ->filterByCcFiles($this) - ->find($con); - if (null !== $criteria) { - return $collCcShowInstancess; - } - $this->collCcShowInstancess = $collCcShowInstancess; - } - } - return $this->collCcShowInstancess; - } - - /** - * Returns the number of related CcShowInstances objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcShowInstances objects. - * @throws PropelException - */ - public function countCcShowInstancess(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcShowInstancess || null !== $criteria) { - if ($this->isNew() && null === $this->collCcShowInstancess) { - return 0; - } else { - $query = CcShowInstancesQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcFiles($this) - ->count($con); - } - } else { - return count($this->collCcShowInstancess); - } - } - - /** - * Method called to associate a CcShowInstances object to this object - * through the CcShowInstances foreign key attribute. - * - * @param CcShowInstances $l CcShowInstances - * @return void - * @throws PropelException - */ - public function addCcShowInstances(CcShowInstances $l) - { - if ($this->collCcShowInstancess === null) { - $this->initCcShowInstancess(); - } - if (!$this->collCcShowInstancess->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcShowInstancess[]= $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 CcShowInstancess 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 CcShowInstances[] List of CcShowInstances objects - */ - public function getCcShowInstancessJoinCcShow($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcShowInstancesQuery::create(null, $criteria); - $query->joinWith('CcShow', $join_behavior); - - return $this->getCcShowInstancess($query, $con); - } - - - /** - * 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 CcShowInstancess 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 CcShowInstances[] List of CcShowInstances objects - */ - public function getCcShowInstancessJoinCcShowInstancesRelatedByDbOriginalShow($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcShowInstancesQuery::create(null, $criteria); - $query->joinWith('CcShowInstancesRelatedByDbOriginalShow', $join_behavior); - - return $this->getCcShowInstancess($query, $con); - } - - /** - * 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 getCcPlaylistcontentssJoinCcBlock($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcPlaylistcontentsQuery::create(null, $criteria); - $query->joinWith('CcBlock', $join_behavior); - - return $this->getCcPlaylistcontentss($query, $con); - } - - - /** - * 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 out the collCcBlockcontentss 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 addCcBlockcontentss() - */ - public function clearCcBlockcontentss() - { - $this->collCcBlockcontentss = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcBlockcontentss collection. - * - * By default this just sets the collCcBlockcontentss collection to an empty array (like clearcollCcBlockcontentss()); - * 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 initCcBlockcontentss() - { - $this->collCcBlockcontentss = new PropelObjectCollection(); - $this->collCcBlockcontentss->setModel('CcBlockcontents'); - } - - /** - * Gets an array of CcBlockcontents 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 CcBlockcontents[] List of CcBlockcontents objects - * @throws PropelException - */ - public function getCcBlockcontentss($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcBlockcontentss || null !== $criteria) { - if ($this->isNew() && null === $this->collCcBlockcontentss) { - // return empty collection - $this->initCcBlockcontentss(); - } else { - $collCcBlockcontentss = CcBlockcontentsQuery::create(null, $criteria) - ->filterByCcFiles($this) - ->find($con); - if (null !== $criteria) { - return $collCcBlockcontentss; - } - $this->collCcBlockcontentss = $collCcBlockcontentss; - } - } - return $this->collCcBlockcontentss; - } - - /** - * Returns the number of related CcBlockcontents objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcBlockcontents objects. - * @throws PropelException - */ - public function countCcBlockcontentss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcBlockcontentss || null !== $criteria) { - if ($this->isNew() && null === $this->collCcBlockcontentss) { - return 0; - } else { - $query = CcBlockcontentsQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcFiles($this) - ->count($con); - } - } else { - return count($this->collCcBlockcontentss); - } - } - - /** - * Method called to associate a CcBlockcontents object to this object - * through the CcBlockcontents foreign key attribute. - * - * @param CcBlockcontents $l CcBlockcontents - * @return void - * @throws PropelException - */ - public function addCcBlockcontents(CcBlockcontents $l) - { - if ($this->collCcBlockcontentss === null) { - $this->initCcBlockcontentss(); - } - if (!$this->collCcBlockcontentss->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcBlockcontentss[]= $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 CcBlockcontentss 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 CcBlockcontents[] List of CcBlockcontents objects - */ - public function getCcBlockcontentssJoinCcBlock($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcBlockcontentsQuery::create(null, $criteria); - $query->joinWith('CcBlock', $join_behavior); - - return $this->getCcBlockcontentss($query, $con); - } - - /** - * Clears out the collCcSchedules 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 addCcSchedules() - */ - public function clearCcSchedules() - { - $this->collCcSchedules = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcSchedules collection. - * - * By default this just sets the collCcSchedules collection to an empty array (like clearcollCcSchedules()); - * 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 initCcSchedules() - { - $this->collCcSchedules = new PropelObjectCollection(); - $this->collCcSchedules->setModel('CcSchedule'); - } - - /** - * Gets an array of CcSchedule 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 CcSchedule[] List of CcSchedule objects - * @throws PropelException - */ - public function getCcSchedules($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcSchedules || null !== $criteria) { - if ($this->isNew() && null === $this->collCcSchedules) { - // return empty collection - $this->initCcSchedules(); - } else { - $collCcSchedules = CcScheduleQuery::create(null, $criteria) - ->filterByCcFiles($this) - ->find($con); - if (null !== $criteria) { - return $collCcSchedules; - } - $this->collCcSchedules = $collCcSchedules; - } - } - return $this->collCcSchedules; - } - - /** - * Returns the number of related CcSchedule objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcSchedule objects. - * @throws PropelException - */ - public function countCcSchedules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcSchedules || null !== $criteria) { - if ($this->isNew() && null === $this->collCcSchedules) { - return 0; - } else { - $query = CcScheduleQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcFiles($this) - ->count($con); - } - } else { - return count($this->collCcSchedules); - } - } - - /** - * Method called to associate a CcSchedule object to this object - * through the CcSchedule foreign key attribute. - * - * @param CcSchedule $l CcSchedule - * @return void - * @throws PropelException - */ - public function addCcSchedule(CcSchedule $l) - { - if ($this->collCcSchedules === null) { - $this->initCcSchedules(); - } - if (!$this->collCcSchedules->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcSchedules[]= $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 CcSchedules 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 CcSchedule[] List of CcSchedule objects - */ - public function getCcSchedulesJoinCcShowInstances($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcScheduleQuery::create(null, $criteria); - $query->joinWith('CcShowInstances', $join_behavior); - - return $this->getCcSchedules($query, $con); - } - - - /** - * 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 CcSchedules 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 CcSchedule[] List of CcSchedule objects - */ - public function getCcSchedulesJoinCcWebstream($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcScheduleQuery::create(null, $criteria); - $query->joinWith('CcWebstream', $join_behavior); - - return $this->getCcSchedules($query, $con); - } - - /** - * Clears out the collCcPlayoutHistorys 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 addCcPlayoutHistorys() - */ - public function clearCcPlayoutHistorys() - { - $this->collCcPlayoutHistorys = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcPlayoutHistorys collection. - * - * By default this just sets the collCcPlayoutHistorys collection to an empty array (like clearcollCcPlayoutHistorys()); - * 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 initCcPlayoutHistorys() - { - $this->collCcPlayoutHistorys = new PropelObjectCollection(); - $this->collCcPlayoutHistorys->setModel('CcPlayoutHistory'); - } - - /** - * Gets an array of CcPlayoutHistory 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 CcPlayoutHistory[] List of CcPlayoutHistory objects - * @throws PropelException - */ - public function getCcPlayoutHistorys($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcPlayoutHistorys || null !== $criteria) { - if ($this->isNew() && null === $this->collCcPlayoutHistorys) { - // return empty collection - $this->initCcPlayoutHistorys(); - } else { - $collCcPlayoutHistorys = CcPlayoutHistoryQuery::create(null, $criteria) - ->filterByCcFiles($this) - ->find($con); - if (null !== $criteria) { - return $collCcPlayoutHistorys; - } - $this->collCcPlayoutHistorys = $collCcPlayoutHistorys; - } - } - return $this->collCcPlayoutHistorys; - } - - /** - * Returns the number of related CcPlayoutHistory objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcPlayoutHistory objects. - * @throws PropelException - */ - public function countCcPlayoutHistorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcPlayoutHistorys || null !== $criteria) { - if ($this->isNew() && null === $this->collCcPlayoutHistorys) { - return 0; - } else { - $query = CcPlayoutHistoryQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcFiles($this) - ->count($con); - } - } else { - return count($this->collCcPlayoutHistorys); - } - } - - /** - * Method called to associate a CcPlayoutHistory object to this object - * through the CcPlayoutHistory foreign key attribute. - * - * @param CcPlayoutHistory $l CcPlayoutHistory - * @return void - * @throws PropelException - */ - public function addCcPlayoutHistory(CcPlayoutHistory $l) - { - if ($this->collCcPlayoutHistorys === null) { - $this->initCcPlayoutHistorys(); - } - if (!$this->collCcPlayoutHistorys->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcPlayoutHistorys[]= $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 CcPlayoutHistorys 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 CcPlayoutHistory[] List of CcPlayoutHistory objects - */ - public function getCcPlayoutHistorysJoinCcShowInstances($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcPlayoutHistoryQuery::create(null, $criteria); - $query->joinWith('CcShowInstances', $join_behavior); - - return $this->getCcPlayoutHistorys($query, $con); - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->name = null; - $this->mime = null; - $this->ftype = null; - $this->directory = null; - $this->filepath = null; - $this->state = null; - $this->currentlyaccessing = null; - $this->editedby = null; - $this->mtime = null; - $this->utime = null; - $this->lptime = 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->file_exists = null; - $this->soundcloud_id = null; - $this->soundcloud_error_code = null; - $this->soundcloud_error_msg = null; - $this->soundcloud_link_to_file = null; - $this->soundcloud_upload_time = null; - $this->replay_gain = null; - $this->owner_id = null; - $this->cuein = null; - $this->cueout = null; - $this->silan_check = null; - $this->hidden = null; - $this->is_scheduled = null; - $this->is_playlist = 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->collCcShowInstancess) { - foreach ((array) $this->collCcShowInstancess as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCcPlaylistcontentss) { - foreach ((array) $this->collCcPlaylistcontentss as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCcBlockcontentss) { - foreach ((array) $this->collCcBlockcontentss as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCcSchedules) { - foreach ((array) $this->collCcSchedules as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCcPlayoutHistorys) { - foreach ((array) $this->collCcPlayoutHistorys as $o) { - $o->clearAllReferences($deep); - } - } - } // if ($deep) - - $this->collCcShowInstancess = null; - $this->collCcPlaylistcontentss = null; - $this->collCcBlockcontentss = null; - $this->collCcSchedules = null; - $this->collCcPlayoutHistorys = null; - $this->aFkOwner = null; - $this->aCcSubjsRelatedByDbEditedby = null; - $this->aCcMusicDirs = 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 + /** + * Peer class name + */ + const PEER = 'Airtime\\CcFilesPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcFilesPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the name field. + * Note: this column has a database default value of: '' + * @var string + */ + protected $name; + + /** + * The value for the mime field. + * Note: this column has a database default value of: '' + * @var string + */ + protected $mime; + + /** + * The value for the ftype field. + * Note: this column has a database default value of: '' + * @var string + */ + protected $ftype; + + /** + * The value for the directory field. + * @var int + */ + protected $directory; + + /** + * The value for the filepath field. + * Note: this column has a database default value of: '' + * @var string + */ + protected $filepath; + + /** + * The value for the state field. + * Note: this column has a database default value of: 'empty' + * @var string + */ + protected $state; + + /** + * The value for the currentlyaccessing field. + * Note: this column has a database default value of: 0 + * @var int + */ + protected $currentlyaccessing; + + /** + * The value for the editedby field. + * @var int + */ + protected $editedby; + + /** + * The value for the mtime field. + * @var string + */ + protected $mtime; + + /** + * The value for the utime field. + * @var string + */ + protected $utime; + + /** + * The value for the lptime field. + * @var string + */ + protected $lptime; + + /** + * The value for the md5 field. + * @var string + */ + protected $md5; + + /** + * The value for the track_title field. + * @var string + */ + protected $track_title; + + /** + * The value for the artist_name field. + * @var string + */ + protected $artist_name; + + /** + * The value for the bit_rate field. + * @var int + */ + protected $bit_rate; + + /** + * The value for the sample_rate field. + * @var int + */ + protected $sample_rate; + + /** + * The value for the format field. + * @var string + */ + protected $format; + + /** + * The value for the length field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $length; + + /** + * The value for the album_title field. + * @var string + */ + protected $album_title; + + /** + * The value for the genre field. + * @var string + */ + protected $genre; + + /** + * The value for the comments field. + * @var string + */ + protected $comments; + + /** + * The value for the year field. + * @var string + */ + protected $year; + + /** + * The value for the track_number field. + * @var int + */ + protected $track_number; + + /** + * The value for the channels field. + * @var int + */ + protected $channels; + + /** + * The value for the url field. + * @var string + */ + protected $url; + + /** + * The value for the bpm field. + * @var int + */ + protected $bpm; + + /** + * The value for the rating field. + * @var string + */ + protected $rating; + + /** + * The value for the encoded_by field. + * @var string + */ + protected $encoded_by; + + /** + * The value for the disc_number field. + * @var string + */ + protected $disc_number; + + /** + * The value for the mood field. + * @var string + */ + protected $mood; + + /** + * The value for the label field. + * @var string + */ + protected $label; + + /** + * The value for the composer field. + * @var string + */ + protected $composer; + + /** + * The value for the encoder field. + * @var string + */ + protected $encoder; + + /** + * The value for the checksum field. + * @var string + */ + protected $checksum; + + /** + * The value for the lyrics field. + * @var string + */ + protected $lyrics; + + /** + * The value for the orchestra field. + * @var string + */ + protected $orchestra; + + /** + * The value for the conductor field. + * @var string + */ + protected $conductor; + + /** + * The value for the lyricist field. + * @var string + */ + protected $lyricist; + + /** + * The value for the original_lyricist field. + * @var string + */ + protected $original_lyricist; + + /** + * The value for the radio_station_name field. + * @var string + */ + protected $radio_station_name; + + /** + * The value for the info_url field. + * @var string + */ + protected $info_url; + + /** + * The value for the artist_url field. + * @var string + */ + protected $artist_url; + + /** + * The value for the audio_source_url field. + * @var string + */ + protected $audio_source_url; + + /** + * The value for the radio_station_url field. + * @var string + */ + protected $radio_station_url; + + /** + * The value for the buy_this_url field. + * @var string + */ + protected $buy_this_url; + + /** + * The value for the isrc_number field. + * @var string + */ + protected $isrc_number; + + /** + * The value for the catalog_number field. + * @var string + */ + protected $catalog_number; + + /** + * The value for the original_artist field. + * @var string + */ + protected $original_artist; + + /** + * The value for the copyright field. + * @var string + */ + protected $copyright; + + /** + * The value for the report_datetime field. + * @var string + */ + protected $report_datetime; + + /** + * The value for the report_location field. + * @var string + */ + protected $report_location; + + /** + * The value for the report_organization field. + * @var string + */ + protected $report_organization; + + /** + * The value for the subject field. + * @var string + */ + protected $subject; + + /** + * The value for the contributor field. + * @var string + */ + protected $contributor; + + /** + * The value for the language field. + * @var string + */ + protected $language; + + /** + * The value for the file_exists field. + * Note: this column has a database default value of: true + * @var boolean + */ + protected $file_exists; + + /** + * The value for the soundcloud_id field. + * @var int + */ + protected $soundcloud_id; + + /** + * The value for the soundcloud_error_code field. + * @var int + */ + protected $soundcloud_error_code; + + /** + * The value for the soundcloud_error_msg field. + * @var string + */ + protected $soundcloud_error_msg; + + /** + * The value for the soundcloud_link_to_file field. + * @var string + */ + protected $soundcloud_link_to_file; + + /** + * The value for the soundcloud_upload_time field. + * @var string + */ + protected $soundcloud_upload_time; + + /** + * The value for the replay_gain field. + * @var string + */ + protected $replay_gain; + + /** + * The value for the owner_id field. + * @var int + */ + protected $owner_id; + + /** + * The value for the cuein field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $cuein; + + /** + * The value for the cueout field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $cueout; + + /** + * The value for the silan_check field. + * Note: this column has a database default value of: false + * @var boolean + */ + protected $silan_check; + + /** + * The value for the hidden field. + * Note: this column has a database default value of: false + * @var boolean + */ + protected $hidden; + + /** + * The value for the is_scheduled field. + * Note: this column has a database default value of: false + * @var boolean + */ + protected $is_scheduled; + + /** + * The value for the is_playlist field. + * Note: this column has a database default value of: false + * @var boolean + */ + protected $is_playlist; + + /** + * @var CcSubjs + */ + protected $aFkOwner; + + /** + * @var CcSubjs + */ + protected $aCcSubjsRelatedByDbEditedby; + + /** + * @var CcMusicDirs + */ + protected $aCcMusicDirs; + + /** + * @var PropelObjectCollection|CcShowInstances[] Collection to store aggregation of CcShowInstances objects. + */ + protected $collCcShowInstancess; + protected $collCcShowInstancessPartial; + + /** + * @var PropelObjectCollection|CcPlaylistcontents[] Collection to store aggregation of CcPlaylistcontents objects. + */ + protected $collCcPlaylistcontentss; + protected $collCcPlaylistcontentssPartial; + + /** + * @var PropelObjectCollection|CcBlockcontents[] Collection to store aggregation of CcBlockcontents objects. + */ + protected $collCcBlockcontentss; + protected $collCcBlockcontentssPartial; + + /** + * @var PropelObjectCollection|CcSchedule[] Collection to store aggregation of CcSchedule objects. + */ + protected $collCcSchedules; + protected $collCcSchedulesPartial; + + /** + * @var PropelObjectCollection|CcPlayoutHistory[] Collection to store aggregation of CcPlayoutHistory objects. + */ + protected $collCcPlayoutHistorys; + protected $collCcPlayoutHistorysPartial; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccShowInstancessScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccPlaylistcontentssScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccBlockcontentssScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccSchedulesScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccPlayoutHistorysScheduledForDeletion = null; + + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->name = ''; + $this->mime = ''; + $this->ftype = ''; + $this->filepath = ''; + $this->state = 'empty'; + $this->currentlyaccessing = 0; + $this->length = '00:00:00'; + $this->file_exists = true; + $this->cuein = '00:00:00'; + $this->cueout = '00:00:00'; + $this->silan_check = false; + $this->hidden = false; + $this->is_scheduled = false; + $this->is_playlist = false; + } + + /** + * 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 [name] column value. + * + * @return string + */ + public function getDbName() + { + + return $this->name; + } + + /** + * Get the [mime] column value. + * + * @return string + */ + public function getDbMime() + { + + return $this->mime; + } + + /** + * Get the [ftype] column value. + * + * @return string + */ + public function getDbFtype() + { + + return $this->ftype; + } + + /** + * Get the [directory] column value. + * + * @return int + */ + public function getDbDirectory() + { + + return $this->directory; + } + + /** + * Get the [filepath] column value. + * + * @return string + */ + public function getDbFilepath() + { + + return $this->filepath; + } + + /** + * 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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [optionally formatted] temporal [utime] 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 getDbUtime($format = 'Y-m-d H:i:s') + { + if ($this->utime === null) { + return null; + } + + + try { + $dt = new DateTime($this->utime); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->utime, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [optionally formatted] temporal [lptime] 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 getDbLPtime($format = 'Y-m-d H:i:s') + { + if ($this->lptime === null) { + return null; + } + + + try { + $dt = new DateTime($this->lptime); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->lptime, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [md5] column value. + * + * @return string + */ + public function getDbMd5() + { + + return $this->md5; + } + + /** + * Get the [track_title] column value. + * + * @return string + */ + public function getDbTrackTitle() + { + + return $this->track_title; + } + + /** + * Get the [artist_name] column value. + * + * @return string + */ + public function getDbArtistName() + { + + return $this->artist_name; + } + + /** + * Get the [bit_rate] column value. + * + * @return int + */ + public function getDbBitRate() + { + + return $this->bit_rate; + } + + /** + * Get the [sample_rate] column value. + * + * @return int + */ + public function getDbSampleRate() + { + + return $this->sample_rate; + } + + /** + * Get the [format] column value. + * + * @return string + */ + public function getDbFormat() + { + + return $this->format; + } + + /** + * Get the [length] column value. + * + * @return string + */ + public function getDbLength() + { + + return $this->length; + } + + /** + * Get the [album_title] column value. + * + * @return string + */ + public function getDbAlbumTitle() + { + + return $this->album_title; + } + + /** + * Get the [genre] column value. + * + * @return string + */ + public function getDbGenre() + { + + return $this->genre; + } + + /** + * Get the [comments] column value. + * + * @return string + */ + public function getDbComments() + { + + return $this->comments; + } + + /** + * Get the [year] column value. + * + * @return string + */ + public function getDbYear() + { + + return $this->year; + } + + /** + * Get the [track_number] column value. + * + * @return int + */ + public function getDbTrackNumber() + { + + return $this->track_number; + } + + /** + * Get the [channels] column value. + * + * @return int + */ + public function getDbChannels() + { + + return $this->channels; + } + + /** + * Get the [url] column value. + * + * @return string + */ + public function getDbUrl() + { + + return $this->url; + } + + /** + * Get the [bpm] column value. + * + * @return int + */ + public function getDbBpm() + { + + return $this->bpm; + } + + /** + * Get the [rating] column value. + * + * @return string + */ + public function getDbRating() + { + + return $this->rating; + } + + /** + * Get the [encoded_by] column value. + * + * @return string + */ + public function getDbEncodedBy() + { + + return $this->encoded_by; + } + + /** + * Get the [disc_number] column value. + * + * @return string + */ + public function getDbDiscNumber() + { + + return $this->disc_number; + } + + /** + * Get the [mood] column value. + * + * @return string + */ + public function getDbMood() + { + + return $this->mood; + } + + /** + * Get the [label] column value. + * + * @return string + */ + public function getDbLabel() + { + + return $this->label; + } + + /** + * Get the [composer] column value. + * + * @return string + */ + public function getDbComposer() + { + + return $this->composer; + } + + /** + * Get the [encoder] column value. + * + * @return string + */ + public function getDbEncoder() + { + + return $this->encoder; + } + + /** + * Get the [checksum] column value. + * + * @return string + */ + public function getDbChecksum() + { + + return $this->checksum; + } + + /** + * Get the [lyrics] column value. + * + * @return string + */ + public function getDbLyrics() + { + + return $this->lyrics; + } + + /** + * Get the [orchestra] column value. + * + * @return string + */ + public function getDbOrchestra() + { + + return $this->orchestra; + } + + /** + * Get the [conductor] column value. + * + * @return string + */ + public function getDbConductor() + { + + return $this->conductor; + } + + /** + * Get the [lyricist] column value. + * + * @return string + */ + public function getDbLyricist() + { + + return $this->lyricist; + } + + /** + * Get the [original_lyricist] column value. + * + * @return string + */ + public function getDbOriginalLyricist() + { + + return $this->original_lyricist; + } + + /** + * Get the [radio_station_name] column value. + * + * @return string + */ + public function getDbRadioStationName() + { + + return $this->radio_station_name; + } + + /** + * Get the [info_url] column value. + * + * @return string + */ + public function getDbInfoUrl() + { + + return $this->info_url; + } + + /** + * Get the [artist_url] column value. + * + * @return string + */ + public function getDbArtistUrl() + { + + return $this->artist_url; + } + + /** + * Get the [audio_source_url] column value. + * + * @return string + */ + public function getDbAudioSourceUrl() + { + + return $this->audio_source_url; + } + + /** + * Get the [radio_station_url] column value. + * + * @return string + */ + public function getDbRadioStationUrl() + { + + return $this->radio_station_url; + } + + /** + * Get the [buy_this_url] column value. + * + * @return string + */ + public function getDbBuyThisUrl() + { + + return $this->buy_this_url; + } + + /** + * Get the [isrc_number] column value. + * + * @return string + */ + public function getDbIsrcNumber() + { + + return $this->isrc_number; + } + + /** + * Get the [catalog_number] column value. + * + * @return string + */ + public function getDbCatalogNumber() + { + + return $this->catalog_number; + } + + /** + * Get the [original_artist] column value. + * + * @return string + */ + public function getDbOriginalArtist() + { + + return $this->original_artist; + } + + /** + * Get the [copyright] column value. + * + * @return string + */ + public function getDbCopyright() + { + + return $this->copyright; + } + + /** + * Get the [report_datetime] column value. + * + * @return string + */ + public function getDbReportDatetime() + { + + return $this->report_datetime; + } + + /** + * Get the [report_location] column value. + * + * @return string + */ + public function getDbReportLocation() + { + + return $this->report_location; + } + + /** + * Get the [report_organization] column value. + * + * @return string + */ + public function getDbReportOrganization() + { + + return $this->report_organization; + } + + /** + * Get the [subject] column value. + * + * @return string + */ + public function getDbSubject() + { + + return $this->subject; + } + + /** + * Get the [contributor] column value. + * + * @return string + */ + public function getDbContributor() + { + + return $this->contributor; + } + + /** + * Get the [language] column value. + * + * @return string + */ + public function getDbLanguage() + { + + return $this->language; + } + + /** + * Get the [file_exists] column value. + * + * @return boolean + */ + public function getDbFileExists() + { + + return $this->file_exists; + } + + /** + * Get the [soundcloud_id] column value. + * + * @return int + */ + public function getDbSoundcloudId() + { + + return $this->soundcloud_id; + } + + /** + * Get the [soundcloud_error_code] column value. + * + * @return int + */ + public function getDbSoundcloudErrorCode() + { + + return $this->soundcloud_error_code; + } + + /** + * Get the [soundcloud_error_msg] column value. + * + * @return string + */ + public function getDbSoundcloudErrorMsg() + { + + return $this->soundcloud_error_msg; + } + + /** + * Get the [soundcloud_link_to_file] column value. + * + * @return string + */ + public function getDbSoundcloudLinkToFile() + { + + return $this->soundcloud_link_to_file; + } + + /** + * Get the [optionally formatted] temporal [soundcloud_upload_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 getDbSoundCloundUploadTime($format = 'Y-m-d H:i:s') + { + if ($this->soundcloud_upload_time === null) { + return null; + } + + + try { + $dt = new DateTime($this->soundcloud_upload_time); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->soundcloud_upload_time, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [replay_gain] column value. + * + * @return string + */ + public function getDbReplayGain() + { + + return $this->replay_gain; + } + + /** + * Get the [owner_id] column value. + * + * @return int + */ + public function getDbOwnerId() + { + + return $this->owner_id; + } + + /** + * Get the [cuein] column value. + * + * @return string + */ + public function getDbCuein() + { + + return $this->cuein; + } + + /** + * Get the [cueout] column value. + * + * @return string + */ + public function getDbCueout() + { + + return $this->cueout; + } + + /** + * Get the [silan_check] column value. + * + * @return boolean + */ + public function getDbSilanCheck() + { + + return $this->silan_check; + } + + /** + * Get the [hidden] column value. + * + * @return boolean + */ + public function getDbHidden() + { + + return $this->hidden; + } + + /** + * Get the [is_scheduled] column value. + * + * @return boolean + */ + public function getDbIsScheduled() + { + + return $this->is_scheduled; + } + + /** + * Get the [is_playlist] column value. + * + * @return boolean + */ + public function getDbIsPlaylist() + { + + return $this->is_playlist; + } + + /** + * 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 && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcFilesPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = CcFilesPeer::NAME; + } + + + return $this; + } // setDbName() + + /** + * Set the value of [mime] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbMime($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->mime !== $v) { + $this->mime = $v; + $this->modifiedColumns[] = CcFilesPeer::MIME; + } + + + return $this; + } // setDbMime() + + /** + * Set the value of [ftype] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbFtype($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->ftype !== $v) { + $this->ftype = $v; + $this->modifiedColumns[] = CcFilesPeer::FTYPE; + } + + + return $this; + } // setDbFtype() + + /** + * Set the value of [directory] column. + * + * @param int $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbDirectory($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->directory !== $v) { + $this->directory = $v; + $this->modifiedColumns[] = CcFilesPeer::DIRECTORY; + } + + if ($this->aCcMusicDirs !== null && $this->aCcMusicDirs->getId() !== $v) { + $this->aCcMusicDirs = null; + } + + + return $this; + } // setDbDirectory() + + /** + * Set the value of [filepath] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbFilepath($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->filepath !== $v) { + $this->filepath = $v; + $this->modifiedColumns[] = CcFilesPeer::FILEPATH; + } + + + return $this; + } // setDbFilepath() + + /** + * Set the value of [state] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbState($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->state !== $v) { + $this->state = $v; + $this->modifiedColumns[] = CcFilesPeer::STATE; + } + + + return $this; + } // setDbState() + + /** + * Set the value of [currentlyaccessing] column. + * + * @param int $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbCurrentlyaccessing($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->currentlyaccessing !== $v) { + $this->currentlyaccessing = $v; + $this->modifiedColumns[] = CcFilesPeer::CURRENTLYACCESSING; + } + + + return $this; + } // setDbCurrentlyaccessing() + + /** + * Set the value of [editedby] column. + * + * @param int $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbEditedby($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->editedby !== $v) { + $this->editedby = $v; + $this->modifiedColumns[] = CcFilesPeer::EDITEDBY; + } + + if ($this->aCcSubjsRelatedByDbEditedby !== null && $this->aCcSubjsRelatedByDbEditedby->getDbId() !== $v) { + $this->aCcSubjsRelatedByDbEditedby = 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 strings are treated as null. + * @return CcFiles The current object (for fluent API support) + */ + public function setDbMtime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->mtime !== null || $dt !== null) { + $currentDateAsString = ($this->mtime !== null && $tmpDt = new DateTime($this->mtime)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->mtime = $newDateAsString; + $this->modifiedColumns[] = CcFilesPeer::MTIME; + } + } // if either are not null + + + return $this; + } // setDbMtime() + + /** + * Sets the value of [utime] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return CcFiles The current object (for fluent API support) + */ + public function setDbUtime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->utime !== null || $dt !== null) { + $currentDateAsString = ($this->utime !== null && $tmpDt = new DateTime($this->utime)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->utime = $newDateAsString; + $this->modifiedColumns[] = CcFilesPeer::UTIME; + } + } // if either are not null + + + return $this; + } // setDbUtime() + + /** + * Sets the value of [lptime] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return CcFiles The current object (for fluent API support) + */ + public function setDbLPtime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->lptime !== null || $dt !== null) { + $currentDateAsString = ($this->lptime !== null && $tmpDt = new DateTime($this->lptime)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->lptime = $newDateAsString; + $this->modifiedColumns[] = CcFilesPeer::LPTIME; + } + } // if either are not null + + + return $this; + } // setDbLPtime() + + /** + * Set the value of [md5] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbMd5($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->md5 !== $v) { + $this->md5 = $v; + $this->modifiedColumns[] = CcFilesPeer::MD5; + } + + + return $this; + } // setDbMd5() + + /** + * Set the value of [track_title] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbTrackTitle($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->track_title !== $v) { + $this->track_title = $v; + $this->modifiedColumns[] = CcFilesPeer::TRACK_TITLE; + } + + + return $this; + } // setDbTrackTitle() + + /** + * Set the value of [artist_name] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbArtistName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->artist_name !== $v) { + $this->artist_name = $v; + $this->modifiedColumns[] = CcFilesPeer::ARTIST_NAME; + } + + + return $this; + } // setDbArtistName() + + /** + * Set the value of [bit_rate] column. + * + * @param int $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbBitRate($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->bit_rate !== $v) { + $this->bit_rate = $v; + $this->modifiedColumns[] = CcFilesPeer::BIT_RATE; + } + + + return $this; + } // setDbBitRate() + + /** + * Set the value of [sample_rate] column. + * + * @param int $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbSampleRate($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->sample_rate !== $v) { + $this->sample_rate = $v; + $this->modifiedColumns[] = CcFilesPeer::SAMPLE_RATE; + } + + + return $this; + } // setDbSampleRate() + + /** + * Set the value of [format] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbFormat($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->format !== $v) { + $this->format = $v; + $this->modifiedColumns[] = CcFilesPeer::FORMAT; + } + + + return $this; + } // setDbFormat() + + /** + * Set the value of [length] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbLength($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->length !== $v) { + $this->length = $v; + $this->modifiedColumns[] = CcFilesPeer::LENGTH; + } + + + 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 setDbAlbumTitle($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->album_title !== $v) { + $this->album_title = $v; + $this->modifiedColumns[] = CcFilesPeer::ALBUM_TITLE; + } + + + return $this; + } // setDbAlbumTitle() + + /** + * Set the value of [genre] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbGenre($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->genre !== $v) { + $this->genre = $v; + $this->modifiedColumns[] = CcFilesPeer::GENRE; + } + + + return $this; + } // setDbGenre() + + /** + * Set the value of [comments] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbComments($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->comments !== $v) { + $this->comments = $v; + $this->modifiedColumns[] = CcFilesPeer::COMMENTS; + } + + + return $this; + } // setDbComments() + + /** + * Set the value of [year] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbYear($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->year !== $v) { + $this->year = $v; + $this->modifiedColumns[] = CcFilesPeer::YEAR; + } + + + return $this; + } // setDbYear() + + /** + * Set the value of [track_number] column. + * + * @param int $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbTrackNumber($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->track_number !== $v) { + $this->track_number = $v; + $this->modifiedColumns[] = CcFilesPeer::TRACK_NUMBER; + } + + + return $this; + } // setDbTrackNumber() + + /** + * Set the value of [channels] column. + * + * @param int $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbChannels($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->channels !== $v) { + $this->channels = $v; + $this->modifiedColumns[] = CcFilesPeer::CHANNELS; + } + + + return $this; + } // setDbChannels() + + /** + * Set the value of [url] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbUrl($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->url !== $v) { + $this->url = $v; + $this->modifiedColumns[] = CcFilesPeer::URL; + } + + + return $this; + } // setDbUrl() + + /** + * Set the value of [bpm] column. + * + * @param int $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbBpm($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->bpm !== $v) { + $this->bpm = $v; + $this->modifiedColumns[] = CcFilesPeer::BPM; + } + + + return $this; + } // setDbBpm() + + /** + * Set the value of [rating] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbRating($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->rating !== $v) { + $this->rating = $v; + $this->modifiedColumns[] = CcFilesPeer::RATING; + } + + + return $this; + } // setDbRating() + + /** + * Set the value of [encoded_by] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbEncodedBy($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->encoded_by !== $v) { + $this->encoded_by = $v; + $this->modifiedColumns[] = CcFilesPeer::ENCODED_BY; + } + + + return $this; + } // setDbEncodedBy() + + /** + * Set the value of [disc_number] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbDiscNumber($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->disc_number !== $v) { + $this->disc_number = $v; + $this->modifiedColumns[] = CcFilesPeer::DISC_NUMBER; + } + + + return $this; + } // setDbDiscNumber() + + /** + * Set the value of [mood] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbMood($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->mood !== $v) { + $this->mood = $v; + $this->modifiedColumns[] = CcFilesPeer::MOOD; + } + + + return $this; + } // setDbMood() + + /** + * Set the value of [label] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbLabel($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->label !== $v) { + $this->label = $v; + $this->modifiedColumns[] = CcFilesPeer::LABEL; + } + + + return $this; + } // setDbLabel() + + /** + * Set the value of [composer] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbComposer($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->composer !== $v) { + $this->composer = $v; + $this->modifiedColumns[] = CcFilesPeer::COMPOSER; + } + + + return $this; + } // setDbComposer() + + /** + * Set the value of [encoder] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbEncoder($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->encoder !== $v) { + $this->encoder = $v; + $this->modifiedColumns[] = CcFilesPeer::ENCODER; + } + + + return $this; + } // setDbEncoder() + + /** + * Set the value of [checksum] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbChecksum($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->checksum !== $v) { + $this->checksum = $v; + $this->modifiedColumns[] = CcFilesPeer::CHECKSUM; + } + + + return $this; + } // setDbChecksum() + + /** + * Set the value of [lyrics] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbLyrics($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->lyrics !== $v) { + $this->lyrics = $v; + $this->modifiedColumns[] = CcFilesPeer::LYRICS; + } + + + return $this; + } // setDbLyrics() + + /** + * Set the value of [orchestra] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbOrchestra($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->orchestra !== $v) { + $this->orchestra = $v; + $this->modifiedColumns[] = CcFilesPeer::ORCHESTRA; + } + + + return $this; + } // setDbOrchestra() + + /** + * Set the value of [conductor] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbConductor($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->conductor !== $v) { + $this->conductor = $v; + $this->modifiedColumns[] = CcFilesPeer::CONDUCTOR; + } + + + return $this; + } // setDbConductor() + + /** + * Set the value of [lyricist] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbLyricist($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->lyricist !== $v) { + $this->lyricist = $v; + $this->modifiedColumns[] = CcFilesPeer::LYRICIST; + } + + + return $this; + } // setDbLyricist() + + /** + * Set the value of [original_lyricist] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbOriginalLyricist($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->original_lyricist !== $v) { + $this->original_lyricist = $v; + $this->modifiedColumns[] = CcFilesPeer::ORIGINAL_LYRICIST; + } + + + return $this; + } // setDbOriginalLyricist() + + /** + * Set the value of [radio_station_name] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbRadioStationName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->radio_station_name !== $v) { + $this->radio_station_name = $v; + $this->modifiedColumns[] = CcFilesPeer::RADIO_STATION_NAME; + } + + + return $this; + } // setDbRadioStationName() + + /** + * Set the value of [info_url] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbInfoUrl($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->info_url !== $v) { + $this->info_url = $v; + $this->modifiedColumns[] = CcFilesPeer::INFO_URL; + } + + + return $this; + } // setDbInfoUrl() + + /** + * Set the value of [artist_url] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbArtistUrl($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->artist_url !== $v) { + $this->artist_url = $v; + $this->modifiedColumns[] = CcFilesPeer::ARTIST_URL; + } + + + return $this; + } // setDbArtistUrl() + + /** + * Set the value of [audio_source_url] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbAudioSourceUrl($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->audio_source_url !== $v) { + $this->audio_source_url = $v; + $this->modifiedColumns[] = CcFilesPeer::AUDIO_SOURCE_URL; + } + + + return $this; + } // setDbAudioSourceUrl() + + /** + * Set the value of [radio_station_url] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbRadioStationUrl($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->radio_station_url !== $v) { + $this->radio_station_url = $v; + $this->modifiedColumns[] = CcFilesPeer::RADIO_STATION_URL; + } + + + return $this; + } // setDbRadioStationUrl() + + /** + * Set the value of [buy_this_url] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbBuyThisUrl($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->buy_this_url !== $v) { + $this->buy_this_url = $v; + $this->modifiedColumns[] = CcFilesPeer::BUY_THIS_URL; + } + + + return $this; + } // setDbBuyThisUrl() + + /** + * Set the value of [isrc_number] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbIsrcNumber($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->isrc_number !== $v) { + $this->isrc_number = $v; + $this->modifiedColumns[] = CcFilesPeer::ISRC_NUMBER; + } + + + return $this; + } // setDbIsrcNumber() + + /** + * Set the value of [catalog_number] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbCatalogNumber($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->catalog_number !== $v) { + $this->catalog_number = $v; + $this->modifiedColumns[] = CcFilesPeer::CATALOG_NUMBER; + } + + + return $this; + } // setDbCatalogNumber() + + /** + * Set the value of [original_artist] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbOriginalArtist($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->original_artist !== $v) { + $this->original_artist = $v; + $this->modifiedColumns[] = CcFilesPeer::ORIGINAL_ARTIST; + } + + + return $this; + } // setDbOriginalArtist() + + /** + * Set the value of [copyright] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbCopyright($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->copyright !== $v) { + $this->copyright = $v; + $this->modifiedColumns[] = CcFilesPeer::COPYRIGHT; + } + + + return $this; + } // setDbCopyright() + + /** + * Set the value of [report_datetime] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbReportDatetime($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->report_datetime !== $v) { + $this->report_datetime = $v; + $this->modifiedColumns[] = CcFilesPeer::REPORT_DATETIME; + } + + + return $this; + } // setDbReportDatetime() + + /** + * Set the value of [report_location] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbReportLocation($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->report_location !== $v) { + $this->report_location = $v; + $this->modifiedColumns[] = CcFilesPeer::REPORT_LOCATION; + } + + + return $this; + } // setDbReportLocation() + + /** + * Set the value of [report_organization] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbReportOrganization($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->report_organization !== $v) { + $this->report_organization = $v; + $this->modifiedColumns[] = CcFilesPeer::REPORT_ORGANIZATION; + } + + + return $this; + } // setDbReportOrganization() + + /** + * Set the value of [subject] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbSubject($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->subject !== $v) { + $this->subject = $v; + $this->modifiedColumns[] = CcFilesPeer::SUBJECT; + } + + + return $this; + } // setDbSubject() + + /** + * Set the value of [contributor] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbContributor($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->contributor !== $v) { + $this->contributor = $v; + $this->modifiedColumns[] = CcFilesPeer::CONTRIBUTOR; + } + + + return $this; + } // setDbContributor() + + /** + * Set the value of [language] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbLanguage($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->language !== $v) { + $this->language = $v; + $this->modifiedColumns[] = CcFilesPeer::LANGUAGE; + } + + + return $this; + } // setDbLanguage() + + /** + * Sets the value of the [file_exists] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbFileExists($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->file_exists !== $v) { + $this->file_exists = $v; + $this->modifiedColumns[] = CcFilesPeer::FILE_EXISTS; + } + + + return $this; + } // setDbFileExists() + + /** + * Set the value of [soundcloud_id] column. + * + * @param int $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbSoundcloudId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->soundcloud_id !== $v) { + $this->soundcloud_id = $v; + $this->modifiedColumns[] = CcFilesPeer::SOUNDCLOUD_ID; + } + + + return $this; + } // setDbSoundcloudId() + + /** + * Set the value of [soundcloud_error_code] column. + * + * @param int $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbSoundcloudErrorCode($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->soundcloud_error_code !== $v) { + $this->soundcloud_error_code = $v; + $this->modifiedColumns[] = CcFilesPeer::SOUNDCLOUD_ERROR_CODE; + } + + + return $this; + } // setDbSoundcloudErrorCode() + + /** + * Set the value of [soundcloud_error_msg] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbSoundcloudErrorMsg($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->soundcloud_error_msg !== $v) { + $this->soundcloud_error_msg = $v; + $this->modifiedColumns[] = CcFilesPeer::SOUNDCLOUD_ERROR_MSG; + } + + + return $this; + } // setDbSoundcloudErrorMsg() + + /** + * Set the value of [soundcloud_link_to_file] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbSoundcloudLinkToFile($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->soundcloud_link_to_file !== $v) { + $this->soundcloud_link_to_file = $v; + $this->modifiedColumns[] = CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE; + } + + + return $this; + } // setDbSoundcloudLinkToFile() + + /** + * Sets the value of [soundcloud_upload_time] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return CcFiles The current object (for fluent API support) + */ + public function setDbSoundCloundUploadTime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->soundcloud_upload_time !== null || $dt !== null) { + $currentDateAsString = ($this->soundcloud_upload_time !== null && $tmpDt = new DateTime($this->soundcloud_upload_time)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->soundcloud_upload_time = $newDateAsString; + $this->modifiedColumns[] = CcFilesPeer::SOUNDCLOUD_UPLOAD_TIME; + } + } // if either are not null + + + return $this; + } // setDbSoundCloundUploadTime() + + /** + * Set the value of [replay_gain] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbReplayGain($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->replay_gain !== $v) { + $this->replay_gain = $v; + $this->modifiedColumns[] = CcFilesPeer::REPLAY_GAIN; + } + + + return $this; + } // setDbReplayGain() + + /** + * Set the value of [owner_id] column. + * + * @param int $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbOwnerId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->owner_id !== $v) { + $this->owner_id = $v; + $this->modifiedColumns[] = CcFilesPeer::OWNER_ID; + } + + if ($this->aFkOwner !== null && $this->aFkOwner->getDbId() !== $v) { + $this->aFkOwner = null; + } + + + return $this; + } // setDbOwnerId() + + /** + * Set the value of [cuein] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbCuein($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->cuein !== $v) { + $this->cuein = $v; + $this->modifiedColumns[] = CcFilesPeer::CUEIN; + } + + + return $this; + } // setDbCuein() + + /** + * Set the value of [cueout] column. + * + * @param string $v new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbCueout($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->cueout !== $v) { + $this->cueout = $v; + $this->modifiedColumns[] = CcFilesPeer::CUEOUT; + } + + + return $this; + } // setDbCueout() + + /** + * Sets the value of the [silan_check] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbSilanCheck($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->silan_check !== $v) { + $this->silan_check = $v; + $this->modifiedColumns[] = CcFilesPeer::SILAN_CHECK; + } + + + return $this; + } // setDbSilanCheck() + + /** + * Sets the value of the [hidden] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbHidden($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->hidden !== $v) { + $this->hidden = $v; + $this->modifiedColumns[] = CcFilesPeer::HIDDEN; + } + + + return $this; + } // setDbHidden() + + /** + * Sets the value of the [is_scheduled] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbIsScheduled($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_scheduled !== $v) { + $this->is_scheduled = $v; + $this->modifiedColumns[] = CcFilesPeer::IS_SCHEDULED; + } + + + return $this; + } // setDbIsScheduled() + + /** + * Sets the value of the [is_playlist] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return CcFiles The current object (for fluent API support) + */ + public function setDbIsPlaylist($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_playlist !== $v) { + $this->is_playlist = $v; + $this->modifiedColumns[] = CcFilesPeer::IS_PLAYLIST; + } + + + return $this; + } // setDbIsPlaylist() + + /** + * 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; + } + + if ($this->length !== '00:00:00') { + return false; + } + + if ($this->file_exists !== true) { + return false; + } + + if ($this->cuein !== '00:00:00') { + return false; + } + + if ($this->cueout !== '00:00:00') { + return false; + } + + if ($this->silan_check !== false) { + return false; + } + + if ($this->hidden !== false) { + return false; + } + + if ($this->is_scheduled !== false) { + return false; + } + + if ($this->is_playlist !== false) { + 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 resultset 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->mime = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->ftype = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->directory = ($row[$startcol + 4] !== null) ? (int) $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->utime = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; + $this->lptime = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null; + $this->md5 = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null; + $this->track_title = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null; + $this->artist_name = ($row[$startcol + 14] !== null) ? (string) $row[$startcol + 14] : null; + $this->bit_rate = ($row[$startcol + 15] !== null) ? (int) $row[$startcol + 15] : null; + $this->sample_rate = ($row[$startcol + 16] !== null) ? (int) $row[$startcol + 16] : null; + $this->format = ($row[$startcol + 17] !== null) ? (string) $row[$startcol + 17] : null; + $this->length = ($row[$startcol + 18] !== null) ? (string) $row[$startcol + 18] : null; + $this->album_title = ($row[$startcol + 19] !== null) ? (string) $row[$startcol + 19] : null; + $this->genre = ($row[$startcol + 20] !== null) ? (string) $row[$startcol + 20] : null; + $this->comments = ($row[$startcol + 21] !== null) ? (string) $row[$startcol + 21] : null; + $this->year = ($row[$startcol + 22] !== null) ? (string) $row[$startcol + 22] : null; + $this->track_number = ($row[$startcol + 23] !== null) ? (int) $row[$startcol + 23] : null; + $this->channels = ($row[$startcol + 24] !== null) ? (int) $row[$startcol + 24] : null; + $this->url = ($row[$startcol + 25] !== null) ? (string) $row[$startcol + 25] : null; + $this->bpm = ($row[$startcol + 26] !== null) ? (int) $row[$startcol + 26] : null; + $this->rating = ($row[$startcol + 27] !== null) ? (string) $row[$startcol + 27] : null; + $this->encoded_by = ($row[$startcol + 28] !== null) ? (string) $row[$startcol + 28] : null; + $this->disc_number = ($row[$startcol + 29] !== null) ? (string) $row[$startcol + 29] : null; + $this->mood = ($row[$startcol + 30] !== null) ? (string) $row[$startcol + 30] : null; + $this->label = ($row[$startcol + 31] !== null) ? (string) $row[$startcol + 31] : null; + $this->composer = ($row[$startcol + 32] !== null) ? (string) $row[$startcol + 32] : null; + $this->encoder = ($row[$startcol + 33] !== null) ? (string) $row[$startcol + 33] : null; + $this->checksum = ($row[$startcol + 34] !== null) ? (string) $row[$startcol + 34] : null; + $this->lyrics = ($row[$startcol + 35] !== null) ? (string) $row[$startcol + 35] : null; + $this->orchestra = ($row[$startcol + 36] !== null) ? (string) $row[$startcol + 36] : null; + $this->conductor = ($row[$startcol + 37] !== null) ? (string) $row[$startcol + 37] : null; + $this->lyricist = ($row[$startcol + 38] !== null) ? (string) $row[$startcol + 38] : null; + $this->original_lyricist = ($row[$startcol + 39] !== null) ? (string) $row[$startcol + 39] : null; + $this->radio_station_name = ($row[$startcol + 40] !== null) ? (string) $row[$startcol + 40] : null; + $this->info_url = ($row[$startcol + 41] !== null) ? (string) $row[$startcol + 41] : null; + $this->artist_url = ($row[$startcol + 42] !== null) ? (string) $row[$startcol + 42] : null; + $this->audio_source_url = ($row[$startcol + 43] !== null) ? (string) $row[$startcol + 43] : null; + $this->radio_station_url = ($row[$startcol + 44] !== null) ? (string) $row[$startcol + 44] : null; + $this->buy_this_url = ($row[$startcol + 45] !== null) ? (string) $row[$startcol + 45] : null; + $this->isrc_number = ($row[$startcol + 46] !== null) ? (string) $row[$startcol + 46] : null; + $this->catalog_number = ($row[$startcol + 47] !== null) ? (string) $row[$startcol + 47] : null; + $this->original_artist = ($row[$startcol + 48] !== null) ? (string) $row[$startcol + 48] : null; + $this->copyright = ($row[$startcol + 49] !== null) ? (string) $row[$startcol + 49] : null; + $this->report_datetime = ($row[$startcol + 50] !== null) ? (string) $row[$startcol + 50] : null; + $this->report_location = ($row[$startcol + 51] !== null) ? (string) $row[$startcol + 51] : null; + $this->report_organization = ($row[$startcol + 52] !== null) ? (string) $row[$startcol + 52] : null; + $this->subject = ($row[$startcol + 53] !== null) ? (string) $row[$startcol + 53] : null; + $this->contributor = ($row[$startcol + 54] !== null) ? (string) $row[$startcol + 54] : null; + $this->language = ($row[$startcol + 55] !== null) ? (string) $row[$startcol + 55] : null; + $this->file_exists = ($row[$startcol + 56] !== null) ? (boolean) $row[$startcol + 56] : null; + $this->soundcloud_id = ($row[$startcol + 57] !== null) ? (int) $row[$startcol + 57] : null; + $this->soundcloud_error_code = ($row[$startcol + 58] !== null) ? (int) $row[$startcol + 58] : null; + $this->soundcloud_error_msg = ($row[$startcol + 59] !== null) ? (string) $row[$startcol + 59] : null; + $this->soundcloud_link_to_file = ($row[$startcol + 60] !== null) ? (string) $row[$startcol + 60] : null; + $this->soundcloud_upload_time = ($row[$startcol + 61] !== null) ? (string) $row[$startcol + 61] : null; + $this->replay_gain = ($row[$startcol + 62] !== null) ? (string) $row[$startcol + 62] : null; + $this->owner_id = ($row[$startcol + 63] !== null) ? (int) $row[$startcol + 63] : null; + $this->cuein = ($row[$startcol + 64] !== null) ? (string) $row[$startcol + 64] : null; + $this->cueout = ($row[$startcol + 65] !== null) ? (string) $row[$startcol + 65] : null; + $this->silan_check = ($row[$startcol + 66] !== null) ? (boolean) $row[$startcol + 66] : null; + $this->hidden = ($row[$startcol + 67] !== null) ? (boolean) $row[$startcol + 67] : null; + $this->is_scheduled = ($row[$startcol + 68] !== null) ? (boolean) $row[$startcol + 68] : null; + $this->is_playlist = ($row[$startcol + 69] !== null) ? (boolean) $row[$startcol + 69] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 70; // 70 = CcFilesPeer::NUM_HYDRATE_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->aCcMusicDirs !== null && $this->directory !== $this->aCcMusicDirs->getId()) { + $this->aCcMusicDirs = null; + } + if ($this->aCcSubjsRelatedByDbEditedby !== null && $this->editedby !== $this->aCcSubjsRelatedByDbEditedby->getDbId()) { + $this->aCcSubjsRelatedByDbEditedby = null; + } + if ($this->aFkOwner !== null && $this->owner_id !== $this->aFkOwner->getDbId()) { + $this->aFkOwner = 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->aFkOwner = null; + $this->aCcSubjsRelatedByDbEditedby = null; + $this->aCcMusicDirs = null; + $this->collCcShowInstancess = null; + + $this->collCcPlaylistcontentss = null; + + $this->collCcBlockcontentss = null; + + $this->collCcSchedules = null; + + $this->collCcPlayoutHistorys = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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 { + $deleteQuery = CcFilesQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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 (Exception $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aFkOwner !== null) { + if ($this->aFkOwner->isModified() || $this->aFkOwner->isNew()) { + $affectedRows += $this->aFkOwner->save($con); + } + $this->setFkOwner($this->aFkOwner); + } + + if ($this->aCcSubjsRelatedByDbEditedby !== null) { + if ($this->aCcSubjsRelatedByDbEditedby->isModified() || $this->aCcSubjsRelatedByDbEditedby->isNew()) { + $affectedRows += $this->aCcSubjsRelatedByDbEditedby->save($con); + } + $this->setCcSubjsRelatedByDbEditedby($this->aCcSubjsRelatedByDbEditedby); + } + + if ($this->aCcMusicDirs !== null) { + if ($this->aCcMusicDirs->isModified() || $this->aCcMusicDirs->isNew()) { + $affectedRows += $this->aCcMusicDirs->save($con); + } + $this->setCcMusicDirs($this->aCcMusicDirs); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->ccShowInstancessScheduledForDeletion !== null) { + if (!$this->ccShowInstancessScheduledForDeletion->isEmpty()) { + CcShowInstancesQuery::create() + ->filterByPrimaryKeys($this->ccShowInstancessScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccShowInstancessScheduledForDeletion = null; + } + } + + if ($this->collCcShowInstancess !== null) { + foreach ($this->collCcShowInstancess as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ccPlaylistcontentssScheduledForDeletion !== null) { + if (!$this->ccPlaylistcontentssScheduledForDeletion->isEmpty()) { + CcPlaylistcontentsQuery::create() + ->filterByPrimaryKeys($this->ccPlaylistcontentssScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccPlaylistcontentssScheduledForDeletion = null; + } + } + + if ($this->collCcPlaylistcontentss !== null) { + foreach ($this->collCcPlaylistcontentss as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ccBlockcontentssScheduledForDeletion !== null) { + if (!$this->ccBlockcontentssScheduledForDeletion->isEmpty()) { + CcBlockcontentsQuery::create() + ->filterByPrimaryKeys($this->ccBlockcontentssScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccBlockcontentssScheduledForDeletion = null; + } + } + + if ($this->collCcBlockcontentss !== null) { + foreach ($this->collCcBlockcontentss as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ccSchedulesScheduledForDeletion !== null) { + if (!$this->ccSchedulesScheduledForDeletion->isEmpty()) { + CcScheduleQuery::create() + ->filterByPrimaryKeys($this->ccSchedulesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccSchedulesScheduledForDeletion = null; + } + } + + if ($this->collCcSchedules !== null) { + foreach ($this->collCcSchedules as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ccPlayoutHistorysScheduledForDeletion !== null) { + if (!$this->ccPlayoutHistorysScheduledForDeletion->isEmpty()) { + CcPlayoutHistoryQuery::create() + ->filterByPrimaryKeys($this->ccPlayoutHistorysScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccPlayoutHistorysScheduledForDeletion = null; + } + } + + if ($this->collCcPlayoutHistorys !== null) { + foreach ($this->collCcPlayoutHistorys as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcFilesPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcFilesPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_files_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcFilesPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcFilesPeer::NAME)) { + $modifiedColumns[':p' . $index++] = '"name"'; + } + if ($this->isColumnModified(CcFilesPeer::MIME)) { + $modifiedColumns[':p' . $index++] = '"mime"'; + } + if ($this->isColumnModified(CcFilesPeer::FTYPE)) { + $modifiedColumns[':p' . $index++] = '"ftype"'; + } + if ($this->isColumnModified(CcFilesPeer::DIRECTORY)) { + $modifiedColumns[':p' . $index++] = '"directory"'; + } + if ($this->isColumnModified(CcFilesPeer::FILEPATH)) { + $modifiedColumns[':p' . $index++] = '"filepath"'; + } + if ($this->isColumnModified(CcFilesPeer::STATE)) { + $modifiedColumns[':p' . $index++] = '"state"'; + } + if ($this->isColumnModified(CcFilesPeer::CURRENTLYACCESSING)) { + $modifiedColumns[':p' . $index++] = '"currentlyaccessing"'; + } + if ($this->isColumnModified(CcFilesPeer::EDITEDBY)) { + $modifiedColumns[':p' . $index++] = '"editedby"'; + } + if ($this->isColumnModified(CcFilesPeer::MTIME)) { + $modifiedColumns[':p' . $index++] = '"mtime"'; + } + if ($this->isColumnModified(CcFilesPeer::UTIME)) { + $modifiedColumns[':p' . $index++] = '"utime"'; + } + if ($this->isColumnModified(CcFilesPeer::LPTIME)) { + $modifiedColumns[':p' . $index++] = '"lptime"'; + } + if ($this->isColumnModified(CcFilesPeer::MD5)) { + $modifiedColumns[':p' . $index++] = '"md5"'; + } + if ($this->isColumnModified(CcFilesPeer::TRACK_TITLE)) { + $modifiedColumns[':p' . $index++] = '"track_title"'; + } + if ($this->isColumnModified(CcFilesPeer::ARTIST_NAME)) { + $modifiedColumns[':p' . $index++] = '"artist_name"'; + } + if ($this->isColumnModified(CcFilesPeer::BIT_RATE)) { + $modifiedColumns[':p' . $index++] = '"bit_rate"'; + } + if ($this->isColumnModified(CcFilesPeer::SAMPLE_RATE)) { + $modifiedColumns[':p' . $index++] = '"sample_rate"'; + } + if ($this->isColumnModified(CcFilesPeer::FORMAT)) { + $modifiedColumns[':p' . $index++] = '"format"'; + } + if ($this->isColumnModified(CcFilesPeer::LENGTH)) { + $modifiedColumns[':p' . $index++] = '"length"'; + } + if ($this->isColumnModified(CcFilesPeer::ALBUM_TITLE)) { + $modifiedColumns[':p' . $index++] = '"album_title"'; + } + if ($this->isColumnModified(CcFilesPeer::GENRE)) { + $modifiedColumns[':p' . $index++] = '"genre"'; + } + if ($this->isColumnModified(CcFilesPeer::COMMENTS)) { + $modifiedColumns[':p' . $index++] = '"comments"'; + } + if ($this->isColumnModified(CcFilesPeer::YEAR)) { + $modifiedColumns[':p' . $index++] = '"year"'; + } + if ($this->isColumnModified(CcFilesPeer::TRACK_NUMBER)) { + $modifiedColumns[':p' . $index++] = '"track_number"'; + } + if ($this->isColumnModified(CcFilesPeer::CHANNELS)) { + $modifiedColumns[':p' . $index++] = '"channels"'; + } + if ($this->isColumnModified(CcFilesPeer::URL)) { + $modifiedColumns[':p' . $index++] = '"url"'; + } + if ($this->isColumnModified(CcFilesPeer::BPM)) { + $modifiedColumns[':p' . $index++] = '"bpm"'; + } + if ($this->isColumnModified(CcFilesPeer::RATING)) { + $modifiedColumns[':p' . $index++] = '"rating"'; + } + if ($this->isColumnModified(CcFilesPeer::ENCODED_BY)) { + $modifiedColumns[':p' . $index++] = '"encoded_by"'; + } + if ($this->isColumnModified(CcFilesPeer::DISC_NUMBER)) { + $modifiedColumns[':p' . $index++] = '"disc_number"'; + } + if ($this->isColumnModified(CcFilesPeer::MOOD)) { + $modifiedColumns[':p' . $index++] = '"mood"'; + } + if ($this->isColumnModified(CcFilesPeer::LABEL)) { + $modifiedColumns[':p' . $index++] = '"label"'; + } + if ($this->isColumnModified(CcFilesPeer::COMPOSER)) { + $modifiedColumns[':p' . $index++] = '"composer"'; + } + if ($this->isColumnModified(CcFilesPeer::ENCODER)) { + $modifiedColumns[':p' . $index++] = '"encoder"'; + } + if ($this->isColumnModified(CcFilesPeer::CHECKSUM)) { + $modifiedColumns[':p' . $index++] = '"checksum"'; + } + if ($this->isColumnModified(CcFilesPeer::LYRICS)) { + $modifiedColumns[':p' . $index++] = '"lyrics"'; + } + if ($this->isColumnModified(CcFilesPeer::ORCHESTRA)) { + $modifiedColumns[':p' . $index++] = '"orchestra"'; + } + if ($this->isColumnModified(CcFilesPeer::CONDUCTOR)) { + $modifiedColumns[':p' . $index++] = '"conductor"'; + } + if ($this->isColumnModified(CcFilesPeer::LYRICIST)) { + $modifiedColumns[':p' . $index++] = '"lyricist"'; + } + if ($this->isColumnModified(CcFilesPeer::ORIGINAL_LYRICIST)) { + $modifiedColumns[':p' . $index++] = '"original_lyricist"'; + } + if ($this->isColumnModified(CcFilesPeer::RADIO_STATION_NAME)) { + $modifiedColumns[':p' . $index++] = '"radio_station_name"'; + } + if ($this->isColumnModified(CcFilesPeer::INFO_URL)) { + $modifiedColumns[':p' . $index++] = '"info_url"'; + } + if ($this->isColumnModified(CcFilesPeer::ARTIST_URL)) { + $modifiedColumns[':p' . $index++] = '"artist_url"'; + } + if ($this->isColumnModified(CcFilesPeer::AUDIO_SOURCE_URL)) { + $modifiedColumns[':p' . $index++] = '"audio_source_url"'; + } + if ($this->isColumnModified(CcFilesPeer::RADIO_STATION_URL)) { + $modifiedColumns[':p' . $index++] = '"radio_station_url"'; + } + if ($this->isColumnModified(CcFilesPeer::BUY_THIS_URL)) { + $modifiedColumns[':p' . $index++] = '"buy_this_url"'; + } + if ($this->isColumnModified(CcFilesPeer::ISRC_NUMBER)) { + $modifiedColumns[':p' . $index++] = '"isrc_number"'; + } + if ($this->isColumnModified(CcFilesPeer::CATALOG_NUMBER)) { + $modifiedColumns[':p' . $index++] = '"catalog_number"'; + } + if ($this->isColumnModified(CcFilesPeer::ORIGINAL_ARTIST)) { + $modifiedColumns[':p' . $index++] = '"original_artist"'; + } + if ($this->isColumnModified(CcFilesPeer::COPYRIGHT)) { + $modifiedColumns[':p' . $index++] = '"copyright"'; + } + if ($this->isColumnModified(CcFilesPeer::REPORT_DATETIME)) { + $modifiedColumns[':p' . $index++] = '"report_datetime"'; + } + if ($this->isColumnModified(CcFilesPeer::REPORT_LOCATION)) { + $modifiedColumns[':p' . $index++] = '"report_location"'; + } + if ($this->isColumnModified(CcFilesPeer::REPORT_ORGANIZATION)) { + $modifiedColumns[':p' . $index++] = '"report_organization"'; + } + if ($this->isColumnModified(CcFilesPeer::SUBJECT)) { + $modifiedColumns[':p' . $index++] = '"subject"'; + } + if ($this->isColumnModified(CcFilesPeer::CONTRIBUTOR)) { + $modifiedColumns[':p' . $index++] = '"contributor"'; + } + if ($this->isColumnModified(CcFilesPeer::LANGUAGE)) { + $modifiedColumns[':p' . $index++] = '"language"'; + } + if ($this->isColumnModified(CcFilesPeer::FILE_EXISTS)) { + $modifiedColumns[':p' . $index++] = '"file_exists"'; + } + if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_ID)) { + $modifiedColumns[':p' . $index++] = '"soundcloud_id"'; + } + if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_ERROR_CODE)) { + $modifiedColumns[':p' . $index++] = '"soundcloud_error_code"'; + } + if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_ERROR_MSG)) { + $modifiedColumns[':p' . $index++] = '"soundcloud_error_msg"'; + } + if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE)) { + $modifiedColumns[':p' . $index++] = '"soundcloud_link_to_file"'; + } + if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_UPLOAD_TIME)) { + $modifiedColumns[':p' . $index++] = '"soundcloud_upload_time"'; + } + if ($this->isColumnModified(CcFilesPeer::REPLAY_GAIN)) { + $modifiedColumns[':p' . $index++] = '"replay_gain"'; + } + if ($this->isColumnModified(CcFilesPeer::OWNER_ID)) { + $modifiedColumns[':p' . $index++] = '"owner_id"'; + } + if ($this->isColumnModified(CcFilesPeer::CUEIN)) { + $modifiedColumns[':p' . $index++] = '"cuein"'; + } + if ($this->isColumnModified(CcFilesPeer::CUEOUT)) { + $modifiedColumns[':p' . $index++] = '"cueout"'; + } + if ($this->isColumnModified(CcFilesPeer::SILAN_CHECK)) { + $modifiedColumns[':p' . $index++] = '"silan_check"'; + } + if ($this->isColumnModified(CcFilesPeer::HIDDEN)) { + $modifiedColumns[':p' . $index++] = '"hidden"'; + } + if ($this->isColumnModified(CcFilesPeer::IS_SCHEDULED)) { + $modifiedColumns[':p' . $index++] = '"is_scheduled"'; + } + if ($this->isColumnModified(CcFilesPeer::IS_PLAYLIST)) { + $modifiedColumns[':p' . $index++] = '"is_playlist"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_files" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"name"': + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); + break; + case '"mime"': + $stmt->bindValue($identifier, $this->mime, PDO::PARAM_STR); + break; + case '"ftype"': + $stmt->bindValue($identifier, $this->ftype, PDO::PARAM_STR); + break; + case '"directory"': + $stmt->bindValue($identifier, $this->directory, PDO::PARAM_INT); + break; + case '"filepath"': + $stmt->bindValue($identifier, $this->filepath, PDO::PARAM_STR); + break; + case '"state"': + $stmt->bindValue($identifier, $this->state, PDO::PARAM_STR); + break; + case '"currentlyaccessing"': + $stmt->bindValue($identifier, $this->currentlyaccessing, PDO::PARAM_INT); + break; + case '"editedby"': + $stmt->bindValue($identifier, $this->editedby, PDO::PARAM_INT); + break; + case '"mtime"': + $stmt->bindValue($identifier, $this->mtime, PDO::PARAM_STR); + break; + case '"utime"': + $stmt->bindValue($identifier, $this->utime, PDO::PARAM_STR); + break; + case '"lptime"': + $stmt->bindValue($identifier, $this->lptime, PDO::PARAM_STR); + break; + case '"md5"': + $stmt->bindValue($identifier, $this->md5, PDO::PARAM_STR); + break; + case '"track_title"': + $stmt->bindValue($identifier, $this->track_title, PDO::PARAM_STR); + break; + case '"artist_name"': + $stmt->bindValue($identifier, $this->artist_name, PDO::PARAM_STR); + break; + case '"bit_rate"': + $stmt->bindValue($identifier, $this->bit_rate, PDO::PARAM_INT); + break; + case '"sample_rate"': + $stmt->bindValue($identifier, $this->sample_rate, PDO::PARAM_INT); + break; + case '"format"': + $stmt->bindValue($identifier, $this->format, PDO::PARAM_STR); + break; + case '"length"': + $stmt->bindValue($identifier, $this->length, PDO::PARAM_STR); + break; + case '"album_title"': + $stmt->bindValue($identifier, $this->album_title, PDO::PARAM_STR); + break; + case '"genre"': + $stmt->bindValue($identifier, $this->genre, PDO::PARAM_STR); + break; + case '"comments"': + $stmt->bindValue($identifier, $this->comments, PDO::PARAM_STR); + break; + case '"year"': + $stmt->bindValue($identifier, $this->year, PDO::PARAM_STR); + break; + case '"track_number"': + $stmt->bindValue($identifier, $this->track_number, PDO::PARAM_INT); + break; + case '"channels"': + $stmt->bindValue($identifier, $this->channels, PDO::PARAM_INT); + break; + case '"url"': + $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR); + break; + case '"bpm"': + $stmt->bindValue($identifier, $this->bpm, PDO::PARAM_INT); + break; + case '"rating"': + $stmt->bindValue($identifier, $this->rating, PDO::PARAM_STR); + break; + case '"encoded_by"': + $stmt->bindValue($identifier, $this->encoded_by, PDO::PARAM_STR); + break; + case '"disc_number"': + $stmt->bindValue($identifier, $this->disc_number, PDO::PARAM_STR); + break; + case '"mood"': + $stmt->bindValue($identifier, $this->mood, PDO::PARAM_STR); + break; + case '"label"': + $stmt->bindValue($identifier, $this->label, PDO::PARAM_STR); + break; + case '"composer"': + $stmt->bindValue($identifier, $this->composer, PDO::PARAM_STR); + break; + case '"encoder"': + $stmt->bindValue($identifier, $this->encoder, PDO::PARAM_STR); + break; + case '"checksum"': + $stmt->bindValue($identifier, $this->checksum, PDO::PARAM_STR); + break; + case '"lyrics"': + $stmt->bindValue($identifier, $this->lyrics, PDO::PARAM_STR); + break; + case '"orchestra"': + $stmt->bindValue($identifier, $this->orchestra, PDO::PARAM_STR); + break; + case '"conductor"': + $stmt->bindValue($identifier, $this->conductor, PDO::PARAM_STR); + break; + case '"lyricist"': + $stmt->bindValue($identifier, $this->lyricist, PDO::PARAM_STR); + break; + case '"original_lyricist"': + $stmt->bindValue($identifier, $this->original_lyricist, PDO::PARAM_STR); + break; + case '"radio_station_name"': + $stmt->bindValue($identifier, $this->radio_station_name, PDO::PARAM_STR); + break; + case '"info_url"': + $stmt->bindValue($identifier, $this->info_url, PDO::PARAM_STR); + break; + case '"artist_url"': + $stmt->bindValue($identifier, $this->artist_url, PDO::PARAM_STR); + break; + case '"audio_source_url"': + $stmt->bindValue($identifier, $this->audio_source_url, PDO::PARAM_STR); + break; + case '"radio_station_url"': + $stmt->bindValue($identifier, $this->radio_station_url, PDO::PARAM_STR); + break; + case '"buy_this_url"': + $stmt->bindValue($identifier, $this->buy_this_url, PDO::PARAM_STR); + break; + case '"isrc_number"': + $stmt->bindValue($identifier, $this->isrc_number, PDO::PARAM_STR); + break; + case '"catalog_number"': + $stmt->bindValue($identifier, $this->catalog_number, PDO::PARAM_STR); + break; + case '"original_artist"': + $stmt->bindValue($identifier, $this->original_artist, PDO::PARAM_STR); + break; + case '"copyright"': + $stmt->bindValue($identifier, $this->copyright, PDO::PARAM_STR); + break; + case '"report_datetime"': + $stmt->bindValue($identifier, $this->report_datetime, PDO::PARAM_STR); + break; + case '"report_location"': + $stmt->bindValue($identifier, $this->report_location, PDO::PARAM_STR); + break; + case '"report_organization"': + $stmt->bindValue($identifier, $this->report_organization, PDO::PARAM_STR); + break; + case '"subject"': + $stmt->bindValue($identifier, $this->subject, PDO::PARAM_STR); + break; + case '"contributor"': + $stmt->bindValue($identifier, $this->contributor, PDO::PARAM_STR); + break; + case '"language"': + $stmt->bindValue($identifier, $this->language, PDO::PARAM_STR); + break; + case '"file_exists"': + $stmt->bindValue($identifier, $this->file_exists, PDO::PARAM_BOOL); + break; + case '"soundcloud_id"': + $stmt->bindValue($identifier, $this->soundcloud_id, PDO::PARAM_INT); + break; + case '"soundcloud_error_code"': + $stmt->bindValue($identifier, $this->soundcloud_error_code, PDO::PARAM_INT); + break; + case '"soundcloud_error_msg"': + $stmt->bindValue($identifier, $this->soundcloud_error_msg, PDO::PARAM_STR); + break; + case '"soundcloud_link_to_file"': + $stmt->bindValue($identifier, $this->soundcloud_link_to_file, PDO::PARAM_STR); + break; + case '"soundcloud_upload_time"': + $stmt->bindValue($identifier, $this->soundcloud_upload_time, PDO::PARAM_STR); + break; + case '"replay_gain"': + $stmt->bindValue($identifier, $this->replay_gain, PDO::PARAM_INT); + break; + case '"owner_id"': + $stmt->bindValue($identifier, $this->owner_id, PDO::PARAM_INT); + break; + case '"cuein"': + $stmt->bindValue($identifier, $this->cuein, PDO::PARAM_STR); + break; + case '"cueout"': + $stmt->bindValue($identifier, $this->cueout, PDO::PARAM_STR); + break; + case '"silan_check"': + $stmt->bindValue($identifier, $this->silan_check, PDO::PARAM_BOOL); + break; + case '"hidden"': + $stmt->bindValue($identifier, $this->hidden, PDO::PARAM_BOOL); + break; + case '"is_scheduled"': + $stmt->bindValue($identifier, $this->is_scheduled, PDO::PARAM_BOOL); + break; + case '"is_playlist"': + $stmt->bindValue($identifier, $this->is_playlist, PDO::PARAM_BOOL); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aFkOwner !== null) { + if (!$this->aFkOwner->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aFkOwner->getValidationFailures()); + } + } + + if ($this->aCcSubjsRelatedByDbEditedby !== null) { + if (!$this->aCcSubjsRelatedByDbEditedby->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcSubjsRelatedByDbEditedby->getValidationFailures()); + } + } + + if ($this->aCcMusicDirs !== null) { + if (!$this->aCcMusicDirs->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcMusicDirs->getValidationFailures()); + } + } + + + if (($retval = CcFilesPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collCcShowInstancess !== null) { + foreach ($this->collCcShowInstancess as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collCcPlaylistcontentss !== null) { + foreach ($this->collCcPlaylistcontentss as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collCcBlockcontentss !== null) { + foreach ($this->collCcBlockcontentss as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collCcSchedules !== null) { + foreach ($this->collCcSchedules as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collCcPlayoutHistorys !== null) { + foreach ($this->collCcPlayoutHistorys 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @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->getDbName(); + break; + case 2: + return $this->getDbMime(); + break; + case 3: + return $this->getDbFtype(); + break; + case 4: + return $this->getDbDirectory(); + break; + case 5: + return $this->getDbFilepath(); + break; + case 6: + return $this->getDbState(); + break; + case 7: + return $this->getDbCurrentlyaccessing(); + break; + case 8: + return $this->getDbEditedby(); + break; + case 9: + return $this->getDbMtime(); + break; + case 10: + return $this->getDbUtime(); + break; + case 11: + return $this->getDbLPtime(); + break; + case 12: + return $this->getDbMd5(); + break; + case 13: + return $this->getDbTrackTitle(); + break; + case 14: + return $this->getDbArtistName(); + break; + case 15: + return $this->getDbBitRate(); + break; + case 16: + return $this->getDbSampleRate(); + break; + case 17: + return $this->getDbFormat(); + break; + case 18: + return $this->getDbLength(); + break; + case 19: + return $this->getDbAlbumTitle(); + break; + case 20: + return $this->getDbGenre(); + break; + case 21: + return $this->getDbComments(); + break; + case 22: + return $this->getDbYear(); + break; + case 23: + return $this->getDbTrackNumber(); + break; + case 24: + return $this->getDbChannels(); + break; + case 25: + return $this->getDbUrl(); + break; + case 26: + return $this->getDbBpm(); + break; + case 27: + return $this->getDbRating(); + break; + case 28: + return $this->getDbEncodedBy(); + break; + case 29: + return $this->getDbDiscNumber(); + break; + case 30: + return $this->getDbMood(); + break; + case 31: + return $this->getDbLabel(); + break; + case 32: + return $this->getDbComposer(); + break; + case 33: + return $this->getDbEncoder(); + break; + case 34: + return $this->getDbChecksum(); + break; + case 35: + return $this->getDbLyrics(); + break; + case 36: + return $this->getDbOrchestra(); + break; + case 37: + return $this->getDbConductor(); + break; + case 38: + return $this->getDbLyricist(); + break; + case 39: + return $this->getDbOriginalLyricist(); + break; + case 40: + return $this->getDbRadioStationName(); + break; + case 41: + return $this->getDbInfoUrl(); + break; + case 42: + return $this->getDbArtistUrl(); + break; + case 43: + return $this->getDbAudioSourceUrl(); + break; + case 44: + return $this->getDbRadioStationUrl(); + break; + case 45: + return $this->getDbBuyThisUrl(); + break; + case 46: + return $this->getDbIsrcNumber(); + break; + case 47: + return $this->getDbCatalogNumber(); + break; + case 48: + return $this->getDbOriginalArtist(); + break; + case 49: + return $this->getDbCopyright(); + break; + case 50: + return $this->getDbReportDatetime(); + break; + case 51: + return $this->getDbReportLocation(); + break; + case 52: + return $this->getDbReportOrganization(); + break; + case 53: + return $this->getDbSubject(); + break; + case 54: + return $this->getDbContributor(); + break; + case 55: + return $this->getDbLanguage(); + break; + case 56: + return $this->getDbFileExists(); + break; + case 57: + return $this->getDbSoundcloudId(); + break; + case 58: + return $this->getDbSoundcloudErrorCode(); + break; + case 59: + return $this->getDbSoundcloudErrorMsg(); + break; + case 60: + return $this->getDbSoundcloudLinkToFile(); + break; + case 61: + return $this->getDbSoundCloundUploadTime(); + break; + case 62: + return $this->getDbReplayGain(); + break; + case 63: + return $this->getDbOwnerId(); + break; + case 64: + return $this->getDbCuein(); + break; + case 65: + return $this->getDbCueout(); + break; + case 66: + return $this->getDbSilanCheck(); + break; + case 67: + return $this->getDbHidden(); + break; + case 68: + return $this->getDbIsScheduled(); + break; + case 69: + return $this->getDbIsPlaylist(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcFiles'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcFiles'][$this->getPrimaryKey()] = true; + $keys = CcFilesPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbName(), + $keys[2] => $this->getDbMime(), + $keys[3] => $this->getDbFtype(), + $keys[4] => $this->getDbDirectory(), + $keys[5] => $this->getDbFilepath(), + $keys[6] => $this->getDbState(), + $keys[7] => $this->getDbCurrentlyaccessing(), + $keys[8] => $this->getDbEditedby(), + $keys[9] => $this->getDbMtime(), + $keys[10] => $this->getDbUtime(), + $keys[11] => $this->getDbLPtime(), + $keys[12] => $this->getDbMd5(), + $keys[13] => $this->getDbTrackTitle(), + $keys[14] => $this->getDbArtistName(), + $keys[15] => $this->getDbBitRate(), + $keys[16] => $this->getDbSampleRate(), + $keys[17] => $this->getDbFormat(), + $keys[18] => $this->getDbLength(), + $keys[19] => $this->getDbAlbumTitle(), + $keys[20] => $this->getDbGenre(), + $keys[21] => $this->getDbComments(), + $keys[22] => $this->getDbYear(), + $keys[23] => $this->getDbTrackNumber(), + $keys[24] => $this->getDbChannels(), + $keys[25] => $this->getDbUrl(), + $keys[26] => $this->getDbBpm(), + $keys[27] => $this->getDbRating(), + $keys[28] => $this->getDbEncodedBy(), + $keys[29] => $this->getDbDiscNumber(), + $keys[30] => $this->getDbMood(), + $keys[31] => $this->getDbLabel(), + $keys[32] => $this->getDbComposer(), + $keys[33] => $this->getDbEncoder(), + $keys[34] => $this->getDbChecksum(), + $keys[35] => $this->getDbLyrics(), + $keys[36] => $this->getDbOrchestra(), + $keys[37] => $this->getDbConductor(), + $keys[38] => $this->getDbLyricist(), + $keys[39] => $this->getDbOriginalLyricist(), + $keys[40] => $this->getDbRadioStationName(), + $keys[41] => $this->getDbInfoUrl(), + $keys[42] => $this->getDbArtistUrl(), + $keys[43] => $this->getDbAudioSourceUrl(), + $keys[44] => $this->getDbRadioStationUrl(), + $keys[45] => $this->getDbBuyThisUrl(), + $keys[46] => $this->getDbIsrcNumber(), + $keys[47] => $this->getDbCatalogNumber(), + $keys[48] => $this->getDbOriginalArtist(), + $keys[49] => $this->getDbCopyright(), + $keys[50] => $this->getDbReportDatetime(), + $keys[51] => $this->getDbReportLocation(), + $keys[52] => $this->getDbReportOrganization(), + $keys[53] => $this->getDbSubject(), + $keys[54] => $this->getDbContributor(), + $keys[55] => $this->getDbLanguage(), + $keys[56] => $this->getDbFileExists(), + $keys[57] => $this->getDbSoundcloudId(), + $keys[58] => $this->getDbSoundcloudErrorCode(), + $keys[59] => $this->getDbSoundcloudErrorMsg(), + $keys[60] => $this->getDbSoundcloudLinkToFile(), + $keys[61] => $this->getDbSoundCloundUploadTime(), + $keys[62] => $this->getDbReplayGain(), + $keys[63] => $this->getDbOwnerId(), + $keys[64] => $this->getDbCuein(), + $keys[65] => $this->getDbCueout(), + $keys[66] => $this->getDbSilanCheck(), + $keys[67] => $this->getDbHidden(), + $keys[68] => $this->getDbIsScheduled(), + $keys[69] => $this->getDbIsPlaylist(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aFkOwner) { + $result['FkOwner'] = $this->aFkOwner->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aCcSubjsRelatedByDbEditedby) { + $result['CcSubjsRelatedByDbEditedby'] = $this->aCcSubjsRelatedByDbEditedby->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aCcMusicDirs) { + $result['CcMusicDirs'] = $this->aCcMusicDirs->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collCcShowInstancess) { + $result['CcShowInstancess'] = $this->collCcShowInstancess->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCcPlaylistcontentss) { + $result['CcPlaylistcontentss'] = $this->collCcPlaylistcontentss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCcBlockcontentss) { + $result['CcBlockcontentss'] = $this->collCcBlockcontentss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCcSchedules) { + $result['CcSchedules'] = $this->collCcSchedules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCcPlayoutHistorys) { + $result['CcPlayoutHistorys'] = $this->collCcPlayoutHistorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcFilesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbMime($value); + break; + case 3: + $this->setDbFtype($value); + break; + case 4: + $this->setDbDirectory($value); + break; + case 5: + $this->setDbFilepath($value); + break; + case 6: + $this->setDbState($value); + break; + case 7: + $this->setDbCurrentlyaccessing($value); + break; + case 8: + $this->setDbEditedby($value); + break; + case 9: + $this->setDbMtime($value); + break; + case 10: + $this->setDbUtime($value); + break; + case 11: + $this->setDbLPtime($value); + break; + case 12: + $this->setDbMd5($value); + break; + case 13: + $this->setDbTrackTitle($value); + break; + case 14: + $this->setDbArtistName($value); + break; + case 15: + $this->setDbBitRate($value); + break; + case 16: + $this->setDbSampleRate($value); + break; + case 17: + $this->setDbFormat($value); + break; + case 18: + $this->setDbLength($value); + break; + case 19: + $this->setDbAlbumTitle($value); + break; + case 20: + $this->setDbGenre($value); + break; + case 21: + $this->setDbComments($value); + break; + case 22: + $this->setDbYear($value); + break; + case 23: + $this->setDbTrackNumber($value); + break; + case 24: + $this->setDbChannels($value); + break; + case 25: + $this->setDbUrl($value); + break; + case 26: + $this->setDbBpm($value); + break; + case 27: + $this->setDbRating($value); + break; + case 28: + $this->setDbEncodedBy($value); + break; + case 29: + $this->setDbDiscNumber($value); + break; + case 30: + $this->setDbMood($value); + break; + case 31: + $this->setDbLabel($value); + break; + case 32: + $this->setDbComposer($value); + break; + case 33: + $this->setDbEncoder($value); + break; + case 34: + $this->setDbChecksum($value); + break; + case 35: + $this->setDbLyrics($value); + break; + case 36: + $this->setDbOrchestra($value); + break; + case 37: + $this->setDbConductor($value); + break; + case 38: + $this->setDbLyricist($value); + break; + case 39: + $this->setDbOriginalLyricist($value); + break; + case 40: + $this->setDbRadioStationName($value); + break; + case 41: + $this->setDbInfoUrl($value); + break; + case 42: + $this->setDbArtistUrl($value); + break; + case 43: + $this->setDbAudioSourceUrl($value); + break; + case 44: + $this->setDbRadioStationUrl($value); + break; + case 45: + $this->setDbBuyThisUrl($value); + break; + case 46: + $this->setDbIsrcNumber($value); + break; + case 47: + $this->setDbCatalogNumber($value); + break; + case 48: + $this->setDbOriginalArtist($value); + break; + case 49: + $this->setDbCopyright($value); + break; + case 50: + $this->setDbReportDatetime($value); + break; + case 51: + $this->setDbReportLocation($value); + break; + case 52: + $this->setDbReportOrganization($value); + break; + case 53: + $this->setDbSubject($value); + break; + case 54: + $this->setDbContributor($value); + break; + case 55: + $this->setDbLanguage($value); + break; + case 56: + $this->setDbFileExists($value); + break; + case 57: + $this->setDbSoundcloudId($value); + break; + case 58: + $this->setDbSoundcloudErrorCode($value); + break; + case 59: + $this->setDbSoundcloudErrorMsg($value); + break; + case 60: + $this->setDbSoundcloudLinkToFile($value); + break; + case 61: + $this->setDbSoundCloundUploadTime($value); + break; + case 62: + $this->setDbReplayGain($value); + break; + case 63: + $this->setDbOwnerId($value); + break; + case 64: + $this->setDbCuein($value); + break; + case 65: + $this->setDbCueout($value); + break; + case 66: + $this->setDbSilanCheck($value); + break; + case 67: + $this->setDbHidden($value); + break; + case 68: + $this->setDbIsScheduled($value); + break; + case 69: + $this->setDbIsPlaylist($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 BasePeer::TYPE_PHPNAME + * + * @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->setDbName($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbMime($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbFtype($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbDirectory($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbFilepath($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbState($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbCurrentlyaccessing($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setDbEditedby($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDbMtime($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setDbUtime($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setDbLPtime($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setDbMd5($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setDbTrackTitle($arr[$keys[13]]); + if (array_key_exists($keys[14], $arr)) $this->setDbArtistName($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setDbBitRate($arr[$keys[15]]); + if (array_key_exists($keys[16], $arr)) $this->setDbSampleRate($arr[$keys[16]]); + if (array_key_exists($keys[17], $arr)) $this->setDbFormat($arr[$keys[17]]); + if (array_key_exists($keys[18], $arr)) $this->setDbLength($arr[$keys[18]]); + if (array_key_exists($keys[19], $arr)) $this->setDbAlbumTitle($arr[$keys[19]]); + if (array_key_exists($keys[20], $arr)) $this->setDbGenre($arr[$keys[20]]); + if (array_key_exists($keys[21], $arr)) $this->setDbComments($arr[$keys[21]]); + if (array_key_exists($keys[22], $arr)) $this->setDbYear($arr[$keys[22]]); + if (array_key_exists($keys[23], $arr)) $this->setDbTrackNumber($arr[$keys[23]]); + if (array_key_exists($keys[24], $arr)) $this->setDbChannels($arr[$keys[24]]); + if (array_key_exists($keys[25], $arr)) $this->setDbUrl($arr[$keys[25]]); + if (array_key_exists($keys[26], $arr)) $this->setDbBpm($arr[$keys[26]]); + if (array_key_exists($keys[27], $arr)) $this->setDbRating($arr[$keys[27]]); + if (array_key_exists($keys[28], $arr)) $this->setDbEncodedBy($arr[$keys[28]]); + if (array_key_exists($keys[29], $arr)) $this->setDbDiscNumber($arr[$keys[29]]); + if (array_key_exists($keys[30], $arr)) $this->setDbMood($arr[$keys[30]]); + if (array_key_exists($keys[31], $arr)) $this->setDbLabel($arr[$keys[31]]); + if (array_key_exists($keys[32], $arr)) $this->setDbComposer($arr[$keys[32]]); + if (array_key_exists($keys[33], $arr)) $this->setDbEncoder($arr[$keys[33]]); + if (array_key_exists($keys[34], $arr)) $this->setDbChecksum($arr[$keys[34]]); + if (array_key_exists($keys[35], $arr)) $this->setDbLyrics($arr[$keys[35]]); + if (array_key_exists($keys[36], $arr)) $this->setDbOrchestra($arr[$keys[36]]); + if (array_key_exists($keys[37], $arr)) $this->setDbConductor($arr[$keys[37]]); + if (array_key_exists($keys[38], $arr)) $this->setDbLyricist($arr[$keys[38]]); + if (array_key_exists($keys[39], $arr)) $this->setDbOriginalLyricist($arr[$keys[39]]); + if (array_key_exists($keys[40], $arr)) $this->setDbRadioStationName($arr[$keys[40]]); + if (array_key_exists($keys[41], $arr)) $this->setDbInfoUrl($arr[$keys[41]]); + if (array_key_exists($keys[42], $arr)) $this->setDbArtistUrl($arr[$keys[42]]); + if (array_key_exists($keys[43], $arr)) $this->setDbAudioSourceUrl($arr[$keys[43]]); + if (array_key_exists($keys[44], $arr)) $this->setDbRadioStationUrl($arr[$keys[44]]); + if (array_key_exists($keys[45], $arr)) $this->setDbBuyThisUrl($arr[$keys[45]]); + if (array_key_exists($keys[46], $arr)) $this->setDbIsrcNumber($arr[$keys[46]]); + if (array_key_exists($keys[47], $arr)) $this->setDbCatalogNumber($arr[$keys[47]]); + if (array_key_exists($keys[48], $arr)) $this->setDbOriginalArtist($arr[$keys[48]]); + if (array_key_exists($keys[49], $arr)) $this->setDbCopyright($arr[$keys[49]]); + if (array_key_exists($keys[50], $arr)) $this->setDbReportDatetime($arr[$keys[50]]); + if (array_key_exists($keys[51], $arr)) $this->setDbReportLocation($arr[$keys[51]]); + if (array_key_exists($keys[52], $arr)) $this->setDbReportOrganization($arr[$keys[52]]); + if (array_key_exists($keys[53], $arr)) $this->setDbSubject($arr[$keys[53]]); + if (array_key_exists($keys[54], $arr)) $this->setDbContributor($arr[$keys[54]]); + if (array_key_exists($keys[55], $arr)) $this->setDbLanguage($arr[$keys[55]]); + if (array_key_exists($keys[56], $arr)) $this->setDbFileExists($arr[$keys[56]]); + if (array_key_exists($keys[57], $arr)) $this->setDbSoundcloudId($arr[$keys[57]]); + if (array_key_exists($keys[58], $arr)) $this->setDbSoundcloudErrorCode($arr[$keys[58]]); + if (array_key_exists($keys[59], $arr)) $this->setDbSoundcloudErrorMsg($arr[$keys[59]]); + if (array_key_exists($keys[60], $arr)) $this->setDbSoundcloudLinkToFile($arr[$keys[60]]); + if (array_key_exists($keys[61], $arr)) $this->setDbSoundCloundUploadTime($arr[$keys[61]]); + if (array_key_exists($keys[62], $arr)) $this->setDbReplayGain($arr[$keys[62]]); + if (array_key_exists($keys[63], $arr)) $this->setDbOwnerId($arr[$keys[63]]); + if (array_key_exists($keys[64], $arr)) $this->setDbCuein($arr[$keys[64]]); + if (array_key_exists($keys[65], $arr)) $this->setDbCueout($arr[$keys[65]]); + if (array_key_exists($keys[66], $arr)) $this->setDbSilanCheck($arr[$keys[66]]); + if (array_key_exists($keys[67], $arr)) $this->setDbHidden($arr[$keys[67]]); + if (array_key_exists($keys[68], $arr)) $this->setDbIsScheduled($arr[$keys[68]]); + if (array_key_exists($keys[69], $arr)) $this->setDbIsPlaylist($arr[$keys[69]]); + } + + /** + * 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::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::DIRECTORY)) $criteria->add(CcFilesPeer::DIRECTORY, $this->directory); + 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::UTIME)) $criteria->add(CcFilesPeer::UTIME, $this->utime); + if ($this->isColumnModified(CcFilesPeer::LPTIME)) $criteria->add(CcFilesPeer::LPTIME, $this->lptime); + 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); + if ($this->isColumnModified(CcFilesPeer::FILE_EXISTS)) $criteria->add(CcFilesPeer::FILE_EXISTS, $this->file_exists); + if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_ID)) $criteria->add(CcFilesPeer::SOUNDCLOUD_ID, $this->soundcloud_id); + if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_ERROR_CODE)) $criteria->add(CcFilesPeer::SOUNDCLOUD_ERROR_CODE, $this->soundcloud_error_code); + if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_ERROR_MSG)) $criteria->add(CcFilesPeer::SOUNDCLOUD_ERROR_MSG, $this->soundcloud_error_msg); + if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE)) $criteria->add(CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE, $this->soundcloud_link_to_file); + if ($this->isColumnModified(CcFilesPeer::SOUNDCLOUD_UPLOAD_TIME)) $criteria->add(CcFilesPeer::SOUNDCLOUD_UPLOAD_TIME, $this->soundcloud_upload_time); + if ($this->isColumnModified(CcFilesPeer::REPLAY_GAIN)) $criteria->add(CcFilesPeer::REPLAY_GAIN, $this->replay_gain); + if ($this->isColumnModified(CcFilesPeer::OWNER_ID)) $criteria->add(CcFilesPeer::OWNER_ID, $this->owner_id); + if ($this->isColumnModified(CcFilesPeer::CUEIN)) $criteria->add(CcFilesPeer::CUEIN, $this->cuein); + if ($this->isColumnModified(CcFilesPeer::CUEOUT)) $criteria->add(CcFilesPeer::CUEOUT, $this->cueout); + if ($this->isColumnModified(CcFilesPeer::SILAN_CHECK)) $criteria->add(CcFilesPeer::SILAN_CHECK, $this->silan_check); + if ($this->isColumnModified(CcFilesPeer::HIDDEN)) $criteria->add(CcFilesPeer::HIDDEN, $this->hidden); + if ($this->isColumnModified(CcFilesPeer::IS_SCHEDULED)) $criteria->add(CcFilesPeer::IS_SCHEDULED, $this->is_scheduled); + if ($this->isColumnModified(CcFilesPeer::IS_PLAYLIST)) $criteria->add(CcFilesPeer::IS_PLAYLIST, $this->is_playlist); + + 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. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbName($this->getDbName()); + $copyObj->setDbMime($this->getDbMime()); + $copyObj->setDbFtype($this->getDbFtype()); + $copyObj->setDbDirectory($this->getDbDirectory()); + $copyObj->setDbFilepath($this->getDbFilepath()); + $copyObj->setDbState($this->getDbState()); + $copyObj->setDbCurrentlyaccessing($this->getDbCurrentlyaccessing()); + $copyObj->setDbEditedby($this->getDbEditedby()); + $copyObj->setDbMtime($this->getDbMtime()); + $copyObj->setDbUtime($this->getDbUtime()); + $copyObj->setDbLPtime($this->getDbLPtime()); + $copyObj->setDbMd5($this->getDbMd5()); + $copyObj->setDbTrackTitle($this->getDbTrackTitle()); + $copyObj->setDbArtistName($this->getDbArtistName()); + $copyObj->setDbBitRate($this->getDbBitRate()); + $copyObj->setDbSampleRate($this->getDbSampleRate()); + $copyObj->setDbFormat($this->getDbFormat()); + $copyObj->setDbLength($this->getDbLength()); + $copyObj->setDbAlbumTitle($this->getDbAlbumTitle()); + $copyObj->setDbGenre($this->getDbGenre()); + $copyObj->setDbComments($this->getDbComments()); + $copyObj->setDbYear($this->getDbYear()); + $copyObj->setDbTrackNumber($this->getDbTrackNumber()); + $copyObj->setDbChannels($this->getDbChannels()); + $copyObj->setDbUrl($this->getDbUrl()); + $copyObj->setDbBpm($this->getDbBpm()); + $copyObj->setDbRating($this->getDbRating()); + $copyObj->setDbEncodedBy($this->getDbEncodedBy()); + $copyObj->setDbDiscNumber($this->getDbDiscNumber()); + $copyObj->setDbMood($this->getDbMood()); + $copyObj->setDbLabel($this->getDbLabel()); + $copyObj->setDbComposer($this->getDbComposer()); + $copyObj->setDbEncoder($this->getDbEncoder()); + $copyObj->setDbChecksum($this->getDbChecksum()); + $copyObj->setDbLyrics($this->getDbLyrics()); + $copyObj->setDbOrchestra($this->getDbOrchestra()); + $copyObj->setDbConductor($this->getDbConductor()); + $copyObj->setDbLyricist($this->getDbLyricist()); + $copyObj->setDbOriginalLyricist($this->getDbOriginalLyricist()); + $copyObj->setDbRadioStationName($this->getDbRadioStationName()); + $copyObj->setDbInfoUrl($this->getDbInfoUrl()); + $copyObj->setDbArtistUrl($this->getDbArtistUrl()); + $copyObj->setDbAudioSourceUrl($this->getDbAudioSourceUrl()); + $copyObj->setDbRadioStationUrl($this->getDbRadioStationUrl()); + $copyObj->setDbBuyThisUrl($this->getDbBuyThisUrl()); + $copyObj->setDbIsrcNumber($this->getDbIsrcNumber()); + $copyObj->setDbCatalogNumber($this->getDbCatalogNumber()); + $copyObj->setDbOriginalArtist($this->getDbOriginalArtist()); + $copyObj->setDbCopyright($this->getDbCopyright()); + $copyObj->setDbReportDatetime($this->getDbReportDatetime()); + $copyObj->setDbReportLocation($this->getDbReportLocation()); + $copyObj->setDbReportOrganization($this->getDbReportOrganization()); + $copyObj->setDbSubject($this->getDbSubject()); + $copyObj->setDbContributor($this->getDbContributor()); + $copyObj->setDbLanguage($this->getDbLanguage()); + $copyObj->setDbFileExists($this->getDbFileExists()); + $copyObj->setDbSoundcloudId($this->getDbSoundcloudId()); + $copyObj->setDbSoundcloudErrorCode($this->getDbSoundcloudErrorCode()); + $copyObj->setDbSoundcloudErrorMsg($this->getDbSoundcloudErrorMsg()); + $copyObj->setDbSoundcloudLinkToFile($this->getDbSoundcloudLinkToFile()); + $copyObj->setDbSoundCloundUploadTime($this->getDbSoundCloundUploadTime()); + $copyObj->setDbReplayGain($this->getDbReplayGain()); + $copyObj->setDbOwnerId($this->getDbOwnerId()); + $copyObj->setDbCuein($this->getDbCuein()); + $copyObj->setDbCueout($this->getDbCueout()); + $copyObj->setDbSilanCheck($this->getDbSilanCheck()); + $copyObj->setDbHidden($this->getDbHidden()); + $copyObj->setDbIsScheduled($this->getDbIsScheduled()); + $copyObj->setDbIsPlaylist($this->getDbIsPlaylist()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + foreach ($this->getCcShowInstancess() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcShowInstances($relObj->copy($deepCopy)); + } + } + + 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)); + } + } + + foreach ($this->getCcBlockcontentss() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcBlockcontents($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCcSchedules() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcSchedule($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCcPlayoutHistorys() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcPlayoutHistory($relObj->copy($deepCopy)); + } + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 setFkOwner(CcSubjs $v = null) + { + if ($v === null) { + $this->setDbOwnerId(NULL); + } else { + $this->setDbOwnerId($v->getDbId()); + } + + $this->aFkOwner = $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->addCcFilesRelatedByDbOwnerId($this); + } + + + return $this; + } + + + /** + * Get the associated CcSubjs object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getFkOwner(PropelPDO $con = null, $doQuery = true) + { + if ($this->aFkOwner === null && ($this->owner_id !== null) && $doQuery) { + $this->aFkOwner = CcSubjsQuery::create()->findPk($this->owner_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->aFkOwner->addCcFilessRelatedByDbOwnerId($this); + */ + } + + return $this->aFkOwner; + } + + /** + * 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 setCcSubjsRelatedByDbEditedby(CcSubjs $v = null) + { + if ($v === null) { + $this->setDbEditedby(NULL); + } else { + $this->setDbEditedby($v->getDbId()); + } + + $this->aCcSubjsRelatedByDbEditedby = $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->addCcFilesRelatedByDbEditedby($this); + } + + + return $this; + } + + + /** + * Get the associated CcSubjs object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getCcSubjsRelatedByDbEditedby(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcSubjsRelatedByDbEditedby === null && ($this->editedby !== null) && $doQuery) { + $this->aCcSubjsRelatedByDbEditedby = 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->aCcSubjsRelatedByDbEditedby->addCcFilessRelatedByDbEditedby($this); + */ + } + + return $this->aCcSubjsRelatedByDbEditedby; + } + + /** + * Declares an association between this object and a CcMusicDirs object. + * + * @param CcMusicDirs $v + * @return CcFiles The current object (for fluent API support) + * @throws PropelException + */ + public function setCcMusicDirs(CcMusicDirs $v = null) + { + if ($v === null) { + $this->setDbDirectory(NULL); + } else { + $this->setDbDirectory($v->getId()); + } + + $this->aCcMusicDirs = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcMusicDirs object, it will not be re-added. + if ($v !== null) { + $v->addCcFiles($this); + } + + + return $this; + } + + + /** + * Get the associated CcMusicDirs object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcMusicDirs The associated CcMusicDirs object. + * @throws PropelException + */ + public function getCcMusicDirs(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcMusicDirs === null && ($this->directory !== null) && $doQuery) { + $this->aCcMusicDirs = CcMusicDirsQuery::create()->findPk($this->directory, $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->aCcMusicDirs->addCcFiless($this); + */ + } + + return $this->aCcMusicDirs; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('CcShowInstances' == $relationName) { + $this->initCcShowInstancess(); + } + if ('CcPlaylistcontents' == $relationName) { + $this->initCcPlaylistcontentss(); + } + if ('CcBlockcontents' == $relationName) { + $this->initCcBlockcontentss(); + } + if ('CcSchedule' == $relationName) { + $this->initCcSchedules(); + } + if ('CcPlayoutHistory' == $relationName) { + $this->initCcPlayoutHistorys(); + } + } + + /** + * Clears out the collCcShowInstancess 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 CcFiles The current object (for fluent API support) + * @see addCcShowInstancess() + */ + public function clearCcShowInstancess() + { + $this->collCcShowInstancess = null; // important to set this to null since that means it is uninitialized + $this->collCcShowInstancessPartial = null; + + return $this; + } + + /** + * reset is the collCcShowInstancess collection loaded partially + * + * @return void + */ + public function resetPartialCcShowInstancess($v = true) + { + $this->collCcShowInstancessPartial = $v; + } + + /** + * Initializes the collCcShowInstancess collection. + * + * By default this just sets the collCcShowInstancess collection to an empty array (like clearcollCcShowInstancess()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcShowInstancess($overrideExisting = true) + { + if (null !== $this->collCcShowInstancess && !$overrideExisting) { + return; + } + $this->collCcShowInstancess = new PropelObjectCollection(); + $this->collCcShowInstancess->setModel('CcShowInstances'); + } + + /** + * Gets an array of CcShowInstances 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 PropelObjectCollection|CcShowInstances[] List of CcShowInstances objects + * @throws PropelException + */ + public function getCcShowInstancess($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcShowInstancessPartial && !$this->isNew(); + if (null === $this->collCcShowInstancess || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcShowInstancess) { + // return empty collection + $this->initCcShowInstancess(); + } else { + $collCcShowInstancess = CcShowInstancesQuery::create(null, $criteria) + ->filterByCcFiles($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcShowInstancessPartial && count($collCcShowInstancess)) { + $this->initCcShowInstancess(false); + + foreach ($collCcShowInstancess as $obj) { + if (false == $this->collCcShowInstancess->contains($obj)) { + $this->collCcShowInstancess->append($obj); + } + } + + $this->collCcShowInstancessPartial = true; + } + + $collCcShowInstancess->getInternalIterator()->rewind(); + + return $collCcShowInstancess; + } + + if ($partial && $this->collCcShowInstancess) { + foreach ($this->collCcShowInstancess as $obj) { + if ($obj->isNew()) { + $collCcShowInstancess[] = $obj; + } + } + } + + $this->collCcShowInstancess = $collCcShowInstancess; + $this->collCcShowInstancessPartial = false; + } + } + + return $this->collCcShowInstancess; + } + + /** + * Sets a collection of CcShowInstances objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccShowInstancess A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcFiles The current object (for fluent API support) + */ + public function setCcShowInstancess(PropelCollection $ccShowInstancess, PropelPDO $con = null) + { + $ccShowInstancessToDelete = $this->getCcShowInstancess(new Criteria(), $con)->diff($ccShowInstancess); + + + $this->ccShowInstancessScheduledForDeletion = $ccShowInstancessToDelete; + + foreach ($ccShowInstancessToDelete as $ccShowInstancesRemoved) { + $ccShowInstancesRemoved->setCcFiles(null); + } + + $this->collCcShowInstancess = null; + foreach ($ccShowInstancess as $ccShowInstances) { + $this->addCcShowInstances($ccShowInstances); + } + + $this->collCcShowInstancess = $ccShowInstancess; + $this->collCcShowInstancessPartial = false; + + return $this; + } + + /** + * Returns the number of related CcShowInstances objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcShowInstances objects. + * @throws PropelException + */ + public function countCcShowInstancess(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcShowInstancessPartial && !$this->isNew(); + if (null === $this->collCcShowInstancess || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcShowInstancess) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcShowInstancess()); + } + $query = CcShowInstancesQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcFiles($this) + ->count($con); + } + + return count($this->collCcShowInstancess); + } + + /** + * Method called to associate a CcShowInstances object to this object + * through the CcShowInstances foreign key attribute. + * + * @param CcShowInstances $l CcShowInstances + * @return CcFiles The current object (for fluent API support) + */ + public function addCcShowInstances(CcShowInstances $l) + { + if ($this->collCcShowInstancess === null) { + $this->initCcShowInstancess(); + $this->collCcShowInstancessPartial = true; + } + + if (!in_array($l, $this->collCcShowInstancess->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcShowInstances($l); + + if ($this->ccShowInstancessScheduledForDeletion and $this->ccShowInstancessScheduledForDeletion->contains($l)) { + $this->ccShowInstancessScheduledForDeletion->remove($this->ccShowInstancessScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcShowInstances $ccShowInstances The ccShowInstances object to add. + */ + protected function doAddCcShowInstances($ccShowInstances) + { + $this->collCcShowInstancess[]= $ccShowInstances; + $ccShowInstances->setCcFiles($this); + } + + /** + * @param CcShowInstances $ccShowInstances The ccShowInstances object to remove. + * @return CcFiles The current object (for fluent API support) + */ + public function removeCcShowInstances($ccShowInstances) + { + if ($this->getCcShowInstancess()->contains($ccShowInstances)) { + $this->collCcShowInstancess->remove($this->collCcShowInstancess->search($ccShowInstances)); + if (null === $this->ccShowInstancessScheduledForDeletion) { + $this->ccShowInstancessScheduledForDeletion = clone $this->collCcShowInstancess; + $this->ccShowInstancessScheduledForDeletion->clear(); + } + $this->ccShowInstancessScheduledForDeletion[]= $ccShowInstances; + $ccShowInstances->setCcFiles(null); + } + + return $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 CcShowInstancess 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 PropelObjectCollection|CcShowInstances[] List of CcShowInstances objects + */ + public function getCcShowInstancessJoinCcShow($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcShowInstancesQuery::create(null, $criteria); + $query->joinWith('CcShow', $join_behavior); + + return $this->getCcShowInstancess($query, $con); + } + + + /** + * 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 CcShowInstancess 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 PropelObjectCollection|CcShowInstances[] List of CcShowInstances objects + */ + public function getCcShowInstancessJoinCcShowInstancesRelatedByDbOriginalShow($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcShowInstancesQuery::create(null, $criteria); + $query->joinWith('CcShowInstancesRelatedByDbOriginalShow', $join_behavior); + + return $this->getCcShowInstancess($query, $con); + } + + /** + * 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 CcFiles The current object (for fluent API support) + * @see addCcPlaylistcontentss() + */ + public function clearCcPlaylistcontentss() + { + $this->collCcPlaylistcontentss = null; // important to set this to null since that means it is uninitialized + $this->collCcPlaylistcontentssPartial = null; + + return $this; + } + + /** + * reset is the collCcPlaylistcontentss collection loaded partially + * + * @return void + */ + public function resetPartialCcPlaylistcontentss($v = true) + { + $this->collCcPlaylistcontentssPartial = $v; + } + + /** + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcPlaylistcontentss($overrideExisting = true) + { + if (null !== $this->collCcPlaylistcontentss && !$overrideExisting) { + return; + } + $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 PropelObjectCollection|CcPlaylistcontents[] List of CcPlaylistcontents objects + * @throws PropelException + */ + public function getCcPlaylistcontentss($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcPlaylistcontentssPartial && !$this->isNew(); + if (null === $this->collCcPlaylistcontentss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPlaylistcontentss) { + // return empty collection + $this->initCcPlaylistcontentss(); + } else { + $collCcPlaylistcontentss = CcPlaylistcontentsQuery::create(null, $criteria) + ->filterByCcFiles($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcPlaylistcontentssPartial && count($collCcPlaylistcontentss)) { + $this->initCcPlaylistcontentss(false); + + foreach ($collCcPlaylistcontentss as $obj) { + if (false == $this->collCcPlaylistcontentss->contains($obj)) { + $this->collCcPlaylistcontentss->append($obj); + } + } + + $this->collCcPlaylistcontentssPartial = true; + } + + $collCcPlaylistcontentss->getInternalIterator()->rewind(); + + return $collCcPlaylistcontentss; + } + + if ($partial && $this->collCcPlaylistcontentss) { + foreach ($this->collCcPlaylistcontentss as $obj) { + if ($obj->isNew()) { + $collCcPlaylistcontentss[] = $obj; + } + } + } + + $this->collCcPlaylistcontentss = $collCcPlaylistcontentss; + $this->collCcPlaylistcontentssPartial = false; + } + } + + return $this->collCcPlaylistcontentss; + } + + /** + * Sets a collection of CcPlaylistcontents objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccPlaylistcontentss A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcFiles The current object (for fluent API support) + */ + public function setCcPlaylistcontentss(PropelCollection $ccPlaylistcontentss, PropelPDO $con = null) + { + $ccPlaylistcontentssToDelete = $this->getCcPlaylistcontentss(new Criteria(), $con)->diff($ccPlaylistcontentss); + + + $this->ccPlaylistcontentssScheduledForDeletion = $ccPlaylistcontentssToDelete; + + foreach ($ccPlaylistcontentssToDelete as $ccPlaylistcontentsRemoved) { + $ccPlaylistcontentsRemoved->setCcFiles(null); + } + + $this->collCcPlaylistcontentss = null; + foreach ($ccPlaylistcontentss as $ccPlaylistcontents) { + $this->addCcPlaylistcontents($ccPlaylistcontents); + } + + $this->collCcPlaylistcontentss = $ccPlaylistcontentss; + $this->collCcPlaylistcontentssPartial = false; + + return $this; + } + + /** + * 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) + { + $partial = $this->collCcPlaylistcontentssPartial && !$this->isNew(); + if (null === $this->collCcPlaylistcontentss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPlaylistcontentss) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcPlaylistcontentss()); + } + $query = CcPlaylistcontentsQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcFiles($this) + ->count($con); + } + + 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 CcFiles The current object (for fluent API support) + */ + public function addCcPlaylistcontents(CcPlaylistcontents $l) + { + if ($this->collCcPlaylistcontentss === null) { + $this->initCcPlaylistcontentss(); + $this->collCcPlaylistcontentssPartial = true; + } + + if (!in_array($l, $this->collCcPlaylistcontentss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcPlaylistcontents($l); + + if ($this->ccPlaylistcontentssScheduledForDeletion and $this->ccPlaylistcontentssScheduledForDeletion->contains($l)) { + $this->ccPlaylistcontentssScheduledForDeletion->remove($this->ccPlaylistcontentssScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcPlaylistcontents $ccPlaylistcontents The ccPlaylistcontents object to add. + */ + protected function doAddCcPlaylistcontents($ccPlaylistcontents) + { + $this->collCcPlaylistcontentss[]= $ccPlaylistcontents; + $ccPlaylistcontents->setCcFiles($this); + } + + /** + * @param CcPlaylistcontents $ccPlaylistcontents The ccPlaylistcontents object to remove. + * @return CcFiles The current object (for fluent API support) + */ + public function removeCcPlaylistcontents($ccPlaylistcontents) + { + if ($this->getCcPlaylistcontentss()->contains($ccPlaylistcontents)) { + $this->collCcPlaylistcontentss->remove($this->collCcPlaylistcontentss->search($ccPlaylistcontents)); + if (null === $this->ccPlaylistcontentssScheduledForDeletion) { + $this->ccPlaylistcontentssScheduledForDeletion = clone $this->collCcPlaylistcontentss; + $this->ccPlaylistcontentssScheduledForDeletion->clear(); + } + $this->ccPlaylistcontentssScheduledForDeletion[]= $ccPlaylistcontents; + $ccPlaylistcontents->setCcFiles(null); + } + + return $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 PropelObjectCollection|CcPlaylistcontents[] List of CcPlaylistcontents objects + */ + public function getCcPlaylistcontentssJoinCcBlock($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcPlaylistcontentsQuery::create(null, $criteria); + $query->joinWith('CcBlock', $join_behavior); + + return $this->getCcPlaylistcontentss($query, $con); + } + + + /** + * 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 PropelObjectCollection|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 out the collCcBlockcontentss 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 CcFiles The current object (for fluent API support) + * @see addCcBlockcontentss() + */ + public function clearCcBlockcontentss() + { + $this->collCcBlockcontentss = null; // important to set this to null since that means it is uninitialized + $this->collCcBlockcontentssPartial = null; + + return $this; + } + + /** + * reset is the collCcBlockcontentss collection loaded partially + * + * @return void + */ + public function resetPartialCcBlockcontentss($v = true) + { + $this->collCcBlockcontentssPartial = $v; + } + + /** + * Initializes the collCcBlockcontentss collection. + * + * By default this just sets the collCcBlockcontentss collection to an empty array (like clearcollCcBlockcontentss()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcBlockcontentss($overrideExisting = true) + { + if (null !== $this->collCcBlockcontentss && !$overrideExisting) { + return; + } + $this->collCcBlockcontentss = new PropelObjectCollection(); + $this->collCcBlockcontentss->setModel('CcBlockcontents'); + } + + /** + * Gets an array of CcBlockcontents 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 PropelObjectCollection|CcBlockcontents[] List of CcBlockcontents objects + * @throws PropelException + */ + public function getCcBlockcontentss($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcBlockcontentssPartial && !$this->isNew(); + if (null === $this->collCcBlockcontentss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcBlockcontentss) { + // return empty collection + $this->initCcBlockcontentss(); + } else { + $collCcBlockcontentss = CcBlockcontentsQuery::create(null, $criteria) + ->filterByCcFiles($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcBlockcontentssPartial && count($collCcBlockcontentss)) { + $this->initCcBlockcontentss(false); + + foreach ($collCcBlockcontentss as $obj) { + if (false == $this->collCcBlockcontentss->contains($obj)) { + $this->collCcBlockcontentss->append($obj); + } + } + + $this->collCcBlockcontentssPartial = true; + } + + $collCcBlockcontentss->getInternalIterator()->rewind(); + + return $collCcBlockcontentss; + } + + if ($partial && $this->collCcBlockcontentss) { + foreach ($this->collCcBlockcontentss as $obj) { + if ($obj->isNew()) { + $collCcBlockcontentss[] = $obj; + } + } + } + + $this->collCcBlockcontentss = $collCcBlockcontentss; + $this->collCcBlockcontentssPartial = false; + } + } + + return $this->collCcBlockcontentss; + } + + /** + * Sets a collection of CcBlockcontents objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccBlockcontentss A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcFiles The current object (for fluent API support) + */ + public function setCcBlockcontentss(PropelCollection $ccBlockcontentss, PropelPDO $con = null) + { + $ccBlockcontentssToDelete = $this->getCcBlockcontentss(new Criteria(), $con)->diff($ccBlockcontentss); + + + $this->ccBlockcontentssScheduledForDeletion = $ccBlockcontentssToDelete; + + foreach ($ccBlockcontentssToDelete as $ccBlockcontentsRemoved) { + $ccBlockcontentsRemoved->setCcFiles(null); + } + + $this->collCcBlockcontentss = null; + foreach ($ccBlockcontentss as $ccBlockcontents) { + $this->addCcBlockcontents($ccBlockcontents); + } + + $this->collCcBlockcontentss = $ccBlockcontentss; + $this->collCcBlockcontentssPartial = false; + + return $this; + } + + /** + * Returns the number of related CcBlockcontents objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcBlockcontents objects. + * @throws PropelException + */ + public function countCcBlockcontentss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcBlockcontentssPartial && !$this->isNew(); + if (null === $this->collCcBlockcontentss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcBlockcontentss) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcBlockcontentss()); + } + $query = CcBlockcontentsQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcFiles($this) + ->count($con); + } + + return count($this->collCcBlockcontentss); + } + + /** + * Method called to associate a CcBlockcontents object to this object + * through the CcBlockcontents foreign key attribute. + * + * @param CcBlockcontents $l CcBlockcontents + * @return CcFiles The current object (for fluent API support) + */ + public function addCcBlockcontents(CcBlockcontents $l) + { + if ($this->collCcBlockcontentss === null) { + $this->initCcBlockcontentss(); + $this->collCcBlockcontentssPartial = true; + } + + if (!in_array($l, $this->collCcBlockcontentss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcBlockcontents($l); + + if ($this->ccBlockcontentssScheduledForDeletion and $this->ccBlockcontentssScheduledForDeletion->contains($l)) { + $this->ccBlockcontentssScheduledForDeletion->remove($this->ccBlockcontentssScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcBlockcontents $ccBlockcontents The ccBlockcontents object to add. + */ + protected function doAddCcBlockcontents($ccBlockcontents) + { + $this->collCcBlockcontentss[]= $ccBlockcontents; + $ccBlockcontents->setCcFiles($this); + } + + /** + * @param CcBlockcontents $ccBlockcontents The ccBlockcontents object to remove. + * @return CcFiles The current object (for fluent API support) + */ + public function removeCcBlockcontents($ccBlockcontents) + { + if ($this->getCcBlockcontentss()->contains($ccBlockcontents)) { + $this->collCcBlockcontentss->remove($this->collCcBlockcontentss->search($ccBlockcontents)); + if (null === $this->ccBlockcontentssScheduledForDeletion) { + $this->ccBlockcontentssScheduledForDeletion = clone $this->collCcBlockcontentss; + $this->ccBlockcontentssScheduledForDeletion->clear(); + } + $this->ccBlockcontentssScheduledForDeletion[]= $ccBlockcontents; + $ccBlockcontents->setCcFiles(null); + } + + return $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 CcBlockcontentss 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 PropelObjectCollection|CcBlockcontents[] List of CcBlockcontents objects + */ + public function getCcBlockcontentssJoinCcBlock($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcBlockcontentsQuery::create(null, $criteria); + $query->joinWith('CcBlock', $join_behavior); + + return $this->getCcBlockcontentss($query, $con); + } + + /** + * Clears out the collCcSchedules 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 CcFiles The current object (for fluent API support) + * @see addCcSchedules() + */ + public function clearCcSchedules() + { + $this->collCcSchedules = null; // important to set this to null since that means it is uninitialized + $this->collCcSchedulesPartial = null; + + return $this; + } + + /** + * reset is the collCcSchedules collection loaded partially + * + * @return void + */ + public function resetPartialCcSchedules($v = true) + { + $this->collCcSchedulesPartial = $v; + } + + /** + * Initializes the collCcSchedules collection. + * + * By default this just sets the collCcSchedules collection to an empty array (like clearcollCcSchedules()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcSchedules($overrideExisting = true) + { + if (null !== $this->collCcSchedules && !$overrideExisting) { + return; + } + $this->collCcSchedules = new PropelObjectCollection(); + $this->collCcSchedules->setModel('CcSchedule'); + } + + /** + * Gets an array of CcSchedule 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 PropelObjectCollection|CcSchedule[] List of CcSchedule objects + * @throws PropelException + */ + public function getCcSchedules($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcSchedulesPartial && !$this->isNew(); + if (null === $this->collCcSchedules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcSchedules) { + // return empty collection + $this->initCcSchedules(); + } else { + $collCcSchedules = CcScheduleQuery::create(null, $criteria) + ->filterByCcFiles($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcSchedulesPartial && count($collCcSchedules)) { + $this->initCcSchedules(false); + + foreach ($collCcSchedules as $obj) { + if (false == $this->collCcSchedules->contains($obj)) { + $this->collCcSchedules->append($obj); + } + } + + $this->collCcSchedulesPartial = true; + } + + $collCcSchedules->getInternalIterator()->rewind(); + + return $collCcSchedules; + } + + if ($partial && $this->collCcSchedules) { + foreach ($this->collCcSchedules as $obj) { + if ($obj->isNew()) { + $collCcSchedules[] = $obj; + } + } + } + + $this->collCcSchedules = $collCcSchedules; + $this->collCcSchedulesPartial = false; + } + } + + return $this->collCcSchedules; + } + + /** + * Sets a collection of CcSchedule objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccSchedules A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcFiles The current object (for fluent API support) + */ + public function setCcSchedules(PropelCollection $ccSchedules, PropelPDO $con = null) + { + $ccSchedulesToDelete = $this->getCcSchedules(new Criteria(), $con)->diff($ccSchedules); + + + $this->ccSchedulesScheduledForDeletion = $ccSchedulesToDelete; + + foreach ($ccSchedulesToDelete as $ccScheduleRemoved) { + $ccScheduleRemoved->setCcFiles(null); + } + + $this->collCcSchedules = null; + foreach ($ccSchedules as $ccSchedule) { + $this->addCcSchedule($ccSchedule); + } + + $this->collCcSchedules = $ccSchedules; + $this->collCcSchedulesPartial = false; + + return $this; + } + + /** + * Returns the number of related CcSchedule objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcSchedule objects. + * @throws PropelException + */ + public function countCcSchedules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcSchedulesPartial && !$this->isNew(); + if (null === $this->collCcSchedules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcSchedules) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcSchedules()); + } + $query = CcScheduleQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcFiles($this) + ->count($con); + } + + return count($this->collCcSchedules); + } + + /** + * Method called to associate a CcSchedule object to this object + * through the CcSchedule foreign key attribute. + * + * @param CcSchedule $l CcSchedule + * @return CcFiles The current object (for fluent API support) + */ + public function addCcSchedule(CcSchedule $l) + { + if ($this->collCcSchedules === null) { + $this->initCcSchedules(); + $this->collCcSchedulesPartial = true; + } + + if (!in_array($l, $this->collCcSchedules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcSchedule($l); + + if ($this->ccSchedulesScheduledForDeletion and $this->ccSchedulesScheduledForDeletion->contains($l)) { + $this->ccSchedulesScheduledForDeletion->remove($this->ccSchedulesScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcSchedule $ccSchedule The ccSchedule object to add. + */ + protected function doAddCcSchedule($ccSchedule) + { + $this->collCcSchedules[]= $ccSchedule; + $ccSchedule->setCcFiles($this); + } + + /** + * @param CcSchedule $ccSchedule The ccSchedule object to remove. + * @return CcFiles The current object (for fluent API support) + */ + public function removeCcSchedule($ccSchedule) + { + if ($this->getCcSchedules()->contains($ccSchedule)) { + $this->collCcSchedules->remove($this->collCcSchedules->search($ccSchedule)); + if (null === $this->ccSchedulesScheduledForDeletion) { + $this->ccSchedulesScheduledForDeletion = clone $this->collCcSchedules; + $this->ccSchedulesScheduledForDeletion->clear(); + } + $this->ccSchedulesScheduledForDeletion[]= $ccSchedule; + $ccSchedule->setCcFiles(null); + } + + return $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 CcSchedules 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 PropelObjectCollection|CcSchedule[] List of CcSchedule objects + */ + public function getCcSchedulesJoinCcShowInstances($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcScheduleQuery::create(null, $criteria); + $query->joinWith('CcShowInstances', $join_behavior); + + return $this->getCcSchedules($query, $con); + } + + + /** + * 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 CcSchedules 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 PropelObjectCollection|CcSchedule[] List of CcSchedule objects + */ + public function getCcSchedulesJoinCcWebstream($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcScheduleQuery::create(null, $criteria); + $query->joinWith('CcWebstream', $join_behavior); + + return $this->getCcSchedules($query, $con); + } + + /** + * Clears out the collCcPlayoutHistorys 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 CcFiles The current object (for fluent API support) + * @see addCcPlayoutHistorys() + */ + public function clearCcPlayoutHistorys() + { + $this->collCcPlayoutHistorys = null; // important to set this to null since that means it is uninitialized + $this->collCcPlayoutHistorysPartial = null; + + return $this; + } + + /** + * reset is the collCcPlayoutHistorys collection loaded partially + * + * @return void + */ + public function resetPartialCcPlayoutHistorys($v = true) + { + $this->collCcPlayoutHistorysPartial = $v; + } + + /** + * Initializes the collCcPlayoutHistorys collection. + * + * By default this just sets the collCcPlayoutHistorys collection to an empty array (like clearcollCcPlayoutHistorys()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcPlayoutHistorys($overrideExisting = true) + { + if (null !== $this->collCcPlayoutHistorys && !$overrideExisting) { + return; + } + $this->collCcPlayoutHistorys = new PropelObjectCollection(); + $this->collCcPlayoutHistorys->setModel('CcPlayoutHistory'); + } + + /** + * Gets an array of CcPlayoutHistory 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 PropelObjectCollection|CcPlayoutHistory[] List of CcPlayoutHistory objects + * @throws PropelException + */ + public function getCcPlayoutHistorys($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcPlayoutHistorysPartial && !$this->isNew(); + if (null === $this->collCcPlayoutHistorys || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPlayoutHistorys) { + // return empty collection + $this->initCcPlayoutHistorys(); + } else { + $collCcPlayoutHistorys = CcPlayoutHistoryQuery::create(null, $criteria) + ->filterByCcFiles($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcPlayoutHistorysPartial && count($collCcPlayoutHistorys)) { + $this->initCcPlayoutHistorys(false); + + foreach ($collCcPlayoutHistorys as $obj) { + if (false == $this->collCcPlayoutHistorys->contains($obj)) { + $this->collCcPlayoutHistorys->append($obj); + } + } + + $this->collCcPlayoutHistorysPartial = true; + } + + $collCcPlayoutHistorys->getInternalIterator()->rewind(); + + return $collCcPlayoutHistorys; + } + + if ($partial && $this->collCcPlayoutHistorys) { + foreach ($this->collCcPlayoutHistorys as $obj) { + if ($obj->isNew()) { + $collCcPlayoutHistorys[] = $obj; + } + } + } + + $this->collCcPlayoutHistorys = $collCcPlayoutHistorys; + $this->collCcPlayoutHistorysPartial = false; + } + } + + return $this->collCcPlayoutHistorys; + } + + /** + * Sets a collection of CcPlayoutHistory objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccPlayoutHistorys A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcFiles The current object (for fluent API support) + */ + public function setCcPlayoutHistorys(PropelCollection $ccPlayoutHistorys, PropelPDO $con = null) + { + $ccPlayoutHistorysToDelete = $this->getCcPlayoutHistorys(new Criteria(), $con)->diff($ccPlayoutHistorys); + + + $this->ccPlayoutHistorysScheduledForDeletion = $ccPlayoutHistorysToDelete; + + foreach ($ccPlayoutHistorysToDelete as $ccPlayoutHistoryRemoved) { + $ccPlayoutHistoryRemoved->setCcFiles(null); + } + + $this->collCcPlayoutHistorys = null; + foreach ($ccPlayoutHistorys as $ccPlayoutHistory) { + $this->addCcPlayoutHistory($ccPlayoutHistory); + } + + $this->collCcPlayoutHistorys = $ccPlayoutHistorys; + $this->collCcPlayoutHistorysPartial = false; + + return $this; + } + + /** + * Returns the number of related CcPlayoutHistory objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcPlayoutHistory objects. + * @throws PropelException + */ + public function countCcPlayoutHistorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcPlayoutHistorysPartial && !$this->isNew(); + if (null === $this->collCcPlayoutHistorys || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPlayoutHistorys) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcPlayoutHistorys()); + } + $query = CcPlayoutHistoryQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcFiles($this) + ->count($con); + } + + return count($this->collCcPlayoutHistorys); + } + + /** + * Method called to associate a CcPlayoutHistory object to this object + * through the CcPlayoutHistory foreign key attribute. + * + * @param CcPlayoutHistory $l CcPlayoutHistory + * @return CcFiles The current object (for fluent API support) + */ + public function addCcPlayoutHistory(CcPlayoutHistory $l) + { + if ($this->collCcPlayoutHistorys === null) { + $this->initCcPlayoutHistorys(); + $this->collCcPlayoutHistorysPartial = true; + } + + if (!in_array($l, $this->collCcPlayoutHistorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcPlayoutHistory($l); + + if ($this->ccPlayoutHistorysScheduledForDeletion and $this->ccPlayoutHistorysScheduledForDeletion->contains($l)) { + $this->ccPlayoutHistorysScheduledForDeletion->remove($this->ccPlayoutHistorysScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcPlayoutHistory $ccPlayoutHistory The ccPlayoutHistory object to add. + */ + protected function doAddCcPlayoutHistory($ccPlayoutHistory) + { + $this->collCcPlayoutHistorys[]= $ccPlayoutHistory; + $ccPlayoutHistory->setCcFiles($this); + } + + /** + * @param CcPlayoutHistory $ccPlayoutHistory The ccPlayoutHistory object to remove. + * @return CcFiles The current object (for fluent API support) + */ + public function removeCcPlayoutHistory($ccPlayoutHistory) + { + if ($this->getCcPlayoutHistorys()->contains($ccPlayoutHistory)) { + $this->collCcPlayoutHistorys->remove($this->collCcPlayoutHistorys->search($ccPlayoutHistory)); + if (null === $this->ccPlayoutHistorysScheduledForDeletion) { + $this->ccPlayoutHistorysScheduledForDeletion = clone $this->collCcPlayoutHistorys; + $this->ccPlayoutHistorysScheduledForDeletion->clear(); + } + $this->ccPlayoutHistorysScheduledForDeletion[]= $ccPlayoutHistory; + $ccPlayoutHistory->setCcFiles(null); + } + + return $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 CcPlayoutHistorys 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 PropelObjectCollection|CcPlayoutHistory[] List of CcPlayoutHistory objects + */ + public function getCcPlayoutHistorysJoinCcShowInstances($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcPlayoutHistoryQuery::create(null, $criteria); + $query->joinWith('CcShowInstances', $join_behavior); + + return $this->getCcPlayoutHistorys($query, $con); + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->name = null; + $this->mime = null; + $this->ftype = null; + $this->directory = null; + $this->filepath = null; + $this->state = null; + $this->currentlyaccessing = null; + $this->editedby = null; + $this->mtime = null; + $this->utime = null; + $this->lptime = 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->file_exists = null; + $this->soundcloud_id = null; + $this->soundcloud_error_code = null; + $this->soundcloud_error_msg = null; + $this->soundcloud_link_to_file = null; + $this->soundcloud_upload_time = null; + $this->replay_gain = null; + $this->owner_id = null; + $this->cuein = null; + $this->cueout = null; + $this->silan_check = null; + $this->hidden = null; + $this->is_scheduled = null; + $this->is_playlist = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->collCcShowInstancess) { + foreach ($this->collCcShowInstancess as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcPlaylistcontentss) { + foreach ($this->collCcPlaylistcontentss as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcBlockcontentss) { + foreach ($this->collCcBlockcontentss as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcSchedules) { + foreach ($this->collCcSchedules as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcPlayoutHistorys) { + foreach ($this->collCcPlayoutHistorys as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->aFkOwner instanceof Persistent) { + $this->aFkOwner->clearAllReferences($deep); + } + if ($this->aCcSubjsRelatedByDbEditedby instanceof Persistent) { + $this->aCcSubjsRelatedByDbEditedby->clearAllReferences($deep); + } + if ($this->aCcMusicDirs instanceof Persistent) { + $this->aCcMusicDirs->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + if ($this->collCcShowInstancess instanceof PropelCollection) { + $this->collCcShowInstancess->clearIterator(); + } + $this->collCcShowInstancess = null; + if ($this->collCcPlaylistcontentss instanceof PropelCollection) { + $this->collCcPlaylistcontentss->clearIterator(); + } + $this->collCcPlaylistcontentss = null; + if ($this->collCcBlockcontentss instanceof PropelCollection) { + $this->collCcBlockcontentss->clearIterator(); + } + $this->collCcBlockcontentss = null; + if ($this->collCcSchedules instanceof PropelCollection) { + $this->collCcSchedules->clearIterator(); + } + $this->collCcSchedules = null; + if ($this->collCcPlayoutHistorys instanceof PropelCollection) { + $this->collCcPlayoutHistorys->clearIterator(); + } + $this->collCcPlayoutHistorys = null; + $this->aFkOwner = null; + $this->aCcSubjsRelatedByDbEditedby = null; + $this->aCcMusicDirs = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcFilesPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFilesPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcFilesPeer.php index dbfbeaf06..70d59e758 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcFilesPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcFilesPeer.php @@ -1,2001 +1,2056 @@ array ('DbId', 'DbName', 'DbMime', 'DbFtype', 'DbDirectory', 'DbFilepath', 'DbState', 'DbCurrentlyaccessing', 'DbEditedby', 'DbMtime', 'DbUtime', 'DbLPtime', 'DbMd5', 'DbTrackTitle', 'DbArtistName', 'DbBitRate', 'DbSampleRate', 'DbFormat', 'DbLength', 'DbAlbumTitle', 'DbGenre', 'DbComments', 'DbYear', 'DbTrackNumber', 'DbChannels', 'DbUrl', 'DbBpm', 'DbRating', 'DbEncodedBy', 'DbDiscNumber', 'DbMood', 'DbLabel', 'DbComposer', 'DbEncoder', 'DbChecksum', 'DbLyrics', 'DbOrchestra', 'DbConductor', 'DbLyricist', 'DbOriginalLyricist', 'DbRadioStationName', 'DbInfoUrl', 'DbArtistUrl', 'DbAudioSourceUrl', 'DbRadioStationUrl', 'DbBuyThisUrl', 'DbIsrcNumber', 'DbCatalogNumber', 'DbOriginalArtist', 'DbCopyright', 'DbReportDatetime', 'DbReportLocation', 'DbReportOrganization', 'DbSubject', 'DbContributor', 'DbLanguage', 'DbFileExists', 'DbSoundcloudId', 'DbSoundcloudErrorCode', 'DbSoundcloudErrorMsg', 'DbSoundcloudLinkToFile', 'DbSoundCloundUploadTime', 'DbReplayGain', 'DbOwnerId', 'DbCuein', 'DbCueout', 'DbSilanCheck', 'DbHidden', 'DbIsScheduled', 'DbIsPlaylist', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbMime', 'dbFtype', 'dbDirectory', 'dbFilepath', 'dbState', 'dbCurrentlyaccessing', 'dbEditedby', 'dbMtime', 'dbUtime', 'dbLPtime', 'dbMd5', 'dbTrackTitle', 'dbArtistName', 'dbBitRate', 'dbSampleRate', 'dbFormat', 'dbLength', 'dbAlbumTitle', 'dbGenre', 'dbComments', 'dbYear', 'dbTrackNumber', 'dbChannels', 'dbUrl', 'dbBpm', 'dbRating', 'dbEncodedBy', 'dbDiscNumber', 'dbMood', 'dbLabel', 'dbComposer', 'dbEncoder', 'dbChecksum', 'dbLyrics', 'dbOrchestra', 'dbConductor', 'dbLyricist', 'dbOriginalLyricist', 'dbRadioStationName', 'dbInfoUrl', 'dbArtistUrl', 'dbAudioSourceUrl', 'dbRadioStationUrl', 'dbBuyThisUrl', 'dbIsrcNumber', 'dbCatalogNumber', 'dbOriginalArtist', 'dbCopyright', 'dbReportDatetime', 'dbReportLocation', 'dbReportOrganization', 'dbSubject', 'dbContributor', 'dbLanguage', 'dbFileExists', 'dbSoundcloudId', 'dbSoundcloudErrorCode', 'dbSoundcloudErrorMsg', 'dbSoundcloudLinkToFile', 'dbSoundCloundUploadTime', 'dbReplayGain', 'dbOwnerId', 'dbCuein', 'dbCueout', 'dbSilanCheck', 'dbHidden', 'dbIsScheduled', 'dbIsPlaylist', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::MIME, self::FTYPE, self::DIRECTORY, self::FILEPATH, self::STATE, self::CURRENTLYACCESSING, self::EDITEDBY, self::MTIME, self::UTIME, self::LPTIME, 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, self::FILE_EXISTS, self::SOUNDCLOUD_ID, self::SOUNDCLOUD_ERROR_CODE, self::SOUNDCLOUD_ERROR_MSG, self::SOUNDCLOUD_LINK_TO_FILE, self::SOUNDCLOUD_UPLOAD_TIME, self::REPLAY_GAIN, self::OWNER_ID, self::CUEIN, self::CUEOUT, self::SILAN_CHECK, self::HIDDEN, self::IS_SCHEDULED, self::IS_PLAYLIST, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'MIME', 'FTYPE', 'DIRECTORY', 'FILEPATH', 'STATE', 'CURRENTLYACCESSING', 'EDITEDBY', 'MTIME', 'UTIME', 'LPTIME', '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', 'FILE_EXISTS', 'SOUNDCLOUD_ID', 'SOUNDCLOUD_ERROR_CODE', 'SOUNDCLOUD_ERROR_MSG', 'SOUNDCLOUD_LINK_TO_FILE', 'SOUNDCLOUD_UPLOAD_TIME', 'REPLAY_GAIN', 'OWNER_ID', 'CUEIN', 'CUEOUT', 'SILAN_CHECK', 'HIDDEN', 'IS_SCHEDULED', 'IS_PLAYLIST', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'mime', 'ftype', 'directory', 'filepath', 'state', 'currentlyaccessing', 'editedby', 'mtime', 'utime', 'lptime', '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', 'file_exists', 'soundcloud_id', 'soundcloud_error_code', 'soundcloud_error_msg', 'soundcloud_link_to_file', 'soundcloud_upload_time', 'replay_gain', 'owner_id', 'cuein', 'cueout', 'silan_check', 'hidden', 'is_scheduled', 'is_playlist', ), - 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, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, ) - ); - - /** - * 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, 'DbMime' => 2, 'DbFtype' => 3, 'DbDirectory' => 4, 'DbFilepath' => 5, 'DbState' => 6, 'DbCurrentlyaccessing' => 7, 'DbEditedby' => 8, 'DbMtime' => 9, 'DbUtime' => 10, 'DbLPtime' => 11, 'DbMd5' => 12, 'DbTrackTitle' => 13, 'DbArtistName' => 14, 'DbBitRate' => 15, 'DbSampleRate' => 16, 'DbFormat' => 17, 'DbLength' => 18, 'DbAlbumTitle' => 19, 'DbGenre' => 20, 'DbComments' => 21, 'DbYear' => 22, 'DbTrackNumber' => 23, 'DbChannels' => 24, 'DbUrl' => 25, 'DbBpm' => 26, 'DbRating' => 27, 'DbEncodedBy' => 28, 'DbDiscNumber' => 29, 'DbMood' => 30, 'DbLabel' => 31, 'DbComposer' => 32, 'DbEncoder' => 33, 'DbChecksum' => 34, 'DbLyrics' => 35, 'DbOrchestra' => 36, 'DbConductor' => 37, 'DbLyricist' => 38, 'DbOriginalLyricist' => 39, 'DbRadioStationName' => 40, 'DbInfoUrl' => 41, 'DbArtistUrl' => 42, 'DbAudioSourceUrl' => 43, 'DbRadioStationUrl' => 44, 'DbBuyThisUrl' => 45, 'DbIsrcNumber' => 46, 'DbCatalogNumber' => 47, 'DbOriginalArtist' => 48, 'DbCopyright' => 49, 'DbReportDatetime' => 50, 'DbReportLocation' => 51, 'DbReportOrganization' => 52, 'DbSubject' => 53, 'DbContributor' => 54, 'DbLanguage' => 55, 'DbFileExists' => 56, 'DbSoundcloudId' => 57, 'DbSoundcloudErrorCode' => 58, 'DbSoundcloudErrorMsg' => 59, 'DbSoundcloudLinkToFile' => 60, 'DbSoundCloundUploadTime' => 61, 'DbReplayGain' => 62, 'DbOwnerId' => 63, 'DbCuein' => 64, 'DbCueout' => 65, 'DbSilanCheck' => 66, 'DbHidden' => 67, 'DbIsScheduled' => 68, 'DbIsPlaylist' => 69, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbMime' => 2, 'dbFtype' => 3, 'dbDirectory' => 4, 'dbFilepath' => 5, 'dbState' => 6, 'dbCurrentlyaccessing' => 7, 'dbEditedby' => 8, 'dbMtime' => 9, 'dbUtime' => 10, 'dbLPtime' => 11, 'dbMd5' => 12, 'dbTrackTitle' => 13, 'dbArtistName' => 14, 'dbBitRate' => 15, 'dbSampleRate' => 16, 'dbFormat' => 17, 'dbLength' => 18, 'dbAlbumTitle' => 19, 'dbGenre' => 20, 'dbComments' => 21, 'dbYear' => 22, 'dbTrackNumber' => 23, 'dbChannels' => 24, 'dbUrl' => 25, 'dbBpm' => 26, 'dbRating' => 27, 'dbEncodedBy' => 28, 'dbDiscNumber' => 29, 'dbMood' => 30, 'dbLabel' => 31, 'dbComposer' => 32, 'dbEncoder' => 33, 'dbChecksum' => 34, 'dbLyrics' => 35, 'dbOrchestra' => 36, 'dbConductor' => 37, 'dbLyricist' => 38, 'dbOriginalLyricist' => 39, 'dbRadioStationName' => 40, 'dbInfoUrl' => 41, 'dbArtistUrl' => 42, 'dbAudioSourceUrl' => 43, 'dbRadioStationUrl' => 44, 'dbBuyThisUrl' => 45, 'dbIsrcNumber' => 46, 'dbCatalogNumber' => 47, 'dbOriginalArtist' => 48, 'dbCopyright' => 49, 'dbReportDatetime' => 50, 'dbReportLocation' => 51, 'dbReportOrganization' => 52, 'dbSubject' => 53, 'dbContributor' => 54, 'dbLanguage' => 55, 'dbFileExists' => 56, 'dbSoundcloudId' => 57, 'dbSoundcloudErrorCode' => 58, 'dbSoundcloudErrorMsg' => 59, 'dbSoundcloudLinkToFile' => 60, 'dbSoundCloundUploadTime' => 61, 'dbReplayGain' => 62, 'dbOwnerId' => 63, 'dbCuein' => 64, 'dbCueout' => 65, 'dbSilanCheck' => 66, 'dbHidden' => 67, 'dbIsScheduled' => 68, 'dbIsPlaylist' => 69, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::MIME => 2, self::FTYPE => 3, self::DIRECTORY => 4, self::FILEPATH => 5, self::STATE => 6, self::CURRENTLYACCESSING => 7, self::EDITEDBY => 8, self::MTIME => 9, self::UTIME => 10, self::LPTIME => 11, self::MD5 => 12, self::TRACK_TITLE => 13, self::ARTIST_NAME => 14, self::BIT_RATE => 15, self::SAMPLE_RATE => 16, self::FORMAT => 17, self::LENGTH => 18, self::ALBUM_TITLE => 19, self::GENRE => 20, self::COMMENTS => 21, self::YEAR => 22, self::TRACK_NUMBER => 23, self::CHANNELS => 24, self::URL => 25, self::BPM => 26, self::RATING => 27, self::ENCODED_BY => 28, self::DISC_NUMBER => 29, self::MOOD => 30, self::LABEL => 31, self::COMPOSER => 32, self::ENCODER => 33, self::CHECKSUM => 34, self::LYRICS => 35, self::ORCHESTRA => 36, self::CONDUCTOR => 37, self::LYRICIST => 38, self::ORIGINAL_LYRICIST => 39, self::RADIO_STATION_NAME => 40, self::INFO_URL => 41, self::ARTIST_URL => 42, self::AUDIO_SOURCE_URL => 43, self::RADIO_STATION_URL => 44, self::BUY_THIS_URL => 45, self::ISRC_NUMBER => 46, self::CATALOG_NUMBER => 47, self::ORIGINAL_ARTIST => 48, self::COPYRIGHT => 49, self::REPORT_DATETIME => 50, self::REPORT_LOCATION => 51, self::REPORT_ORGANIZATION => 52, self::SUBJECT => 53, self::CONTRIBUTOR => 54, self::LANGUAGE => 55, self::FILE_EXISTS => 56, self::SOUNDCLOUD_ID => 57, self::SOUNDCLOUD_ERROR_CODE => 58, self::SOUNDCLOUD_ERROR_MSG => 59, self::SOUNDCLOUD_LINK_TO_FILE => 60, self::SOUNDCLOUD_UPLOAD_TIME => 61, self::REPLAY_GAIN => 62, self::OWNER_ID => 63, self::CUEIN => 64, self::CUEOUT => 65, self::SILAN_CHECK => 66, self::HIDDEN => 67, self::IS_SCHEDULED => 68, self::IS_PLAYLIST => 69, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'MIME' => 2, 'FTYPE' => 3, 'DIRECTORY' => 4, 'FILEPATH' => 5, 'STATE' => 6, 'CURRENTLYACCESSING' => 7, 'EDITEDBY' => 8, 'MTIME' => 9, 'UTIME' => 10, 'LPTIME' => 11, 'MD5' => 12, 'TRACK_TITLE' => 13, 'ARTIST_NAME' => 14, 'BIT_RATE' => 15, 'SAMPLE_RATE' => 16, 'FORMAT' => 17, 'LENGTH' => 18, 'ALBUM_TITLE' => 19, 'GENRE' => 20, 'COMMENTS' => 21, 'YEAR' => 22, 'TRACK_NUMBER' => 23, 'CHANNELS' => 24, 'URL' => 25, 'BPM' => 26, 'RATING' => 27, 'ENCODED_BY' => 28, 'DISC_NUMBER' => 29, 'MOOD' => 30, 'LABEL' => 31, 'COMPOSER' => 32, 'ENCODER' => 33, 'CHECKSUM' => 34, 'LYRICS' => 35, 'ORCHESTRA' => 36, 'CONDUCTOR' => 37, 'LYRICIST' => 38, 'ORIGINAL_LYRICIST' => 39, 'RADIO_STATION_NAME' => 40, 'INFO_URL' => 41, 'ARTIST_URL' => 42, 'AUDIO_SOURCE_URL' => 43, 'RADIO_STATION_URL' => 44, 'BUY_THIS_URL' => 45, 'ISRC_NUMBER' => 46, 'CATALOG_NUMBER' => 47, 'ORIGINAL_ARTIST' => 48, 'COPYRIGHT' => 49, 'REPORT_DATETIME' => 50, 'REPORT_LOCATION' => 51, 'REPORT_ORGANIZATION' => 52, 'SUBJECT' => 53, 'CONTRIBUTOR' => 54, 'LANGUAGE' => 55, 'FILE_EXISTS' => 56, 'SOUNDCLOUD_ID' => 57, 'SOUNDCLOUD_ERROR_CODE' => 58, 'SOUNDCLOUD_ERROR_MSG' => 59, 'SOUNDCLOUD_LINK_TO_FILE' => 60, 'SOUNDCLOUD_UPLOAD_TIME' => 61, 'REPLAY_GAIN' => 62, 'OWNER_ID' => 63, 'CUEIN' => 64, 'CUEOUT' => 65, 'SILAN_CHECK' => 66, 'HIDDEN' => 67, 'IS_SCHEDULED' => 68, 'IS_PLAYLIST' => 69, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'mime' => 2, 'ftype' => 3, 'directory' => 4, 'filepath' => 5, 'state' => 6, 'currentlyaccessing' => 7, 'editedby' => 8, 'mtime' => 9, 'utime' => 10, 'lptime' => 11, 'md5' => 12, 'track_title' => 13, 'artist_name' => 14, 'bit_rate' => 15, 'sample_rate' => 16, 'format' => 17, 'length' => 18, 'album_title' => 19, 'genre' => 20, 'comments' => 21, 'year' => 22, 'track_number' => 23, 'channels' => 24, 'url' => 25, 'bpm' => 26, 'rating' => 27, 'encoded_by' => 28, 'disc_number' => 29, 'mood' => 30, 'label' => 31, 'composer' => 32, 'encoder' => 33, 'checksum' => 34, 'lyrics' => 35, 'orchestra' => 36, 'conductor' => 37, 'lyricist' => 38, 'original_lyricist' => 39, 'radio_station_name' => 40, 'info_url' => 41, 'artist_url' => 42, 'audio_source_url' => 43, 'radio_station_url' => 44, 'buy_this_url' => 45, 'isrc_number' => 46, 'catalog_number' => 47, 'original_artist' => 48, 'copyright' => 49, 'report_datetime' => 50, 'report_location' => 51, 'report_organization' => 52, 'subject' => 53, 'contributor' => 54, 'language' => 55, 'file_exists' => 56, 'soundcloud_id' => 57, 'soundcloud_error_code' => 58, 'soundcloud_error_msg' => 59, 'soundcloud_link_to_file' => 60, 'soundcloud_upload_time' => 61, 'replay_gain' => 62, 'owner_id' => 63, 'cuein' => 64, 'cueout' => 65, 'silan_check' => 66, 'hidden' => 67, 'is_scheduled' => 68, 'is_playlist' => 69, ), - 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, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, ) - ); - - /** - * 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::NAME); - $criteria->addSelectColumn(CcFilesPeer::MIME); - $criteria->addSelectColumn(CcFilesPeer::FTYPE); - $criteria->addSelectColumn(CcFilesPeer::DIRECTORY); - $criteria->addSelectColumn(CcFilesPeer::FILEPATH); - $criteria->addSelectColumn(CcFilesPeer::STATE); - $criteria->addSelectColumn(CcFilesPeer::CURRENTLYACCESSING); - $criteria->addSelectColumn(CcFilesPeer::EDITEDBY); - $criteria->addSelectColumn(CcFilesPeer::MTIME); - $criteria->addSelectColumn(CcFilesPeer::UTIME); - $criteria->addSelectColumn(CcFilesPeer::LPTIME); - $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); - $criteria->addSelectColumn(CcFilesPeer::FILE_EXISTS); - $criteria->addSelectColumn(CcFilesPeer::SOUNDCLOUD_ID); - $criteria->addSelectColumn(CcFilesPeer::SOUNDCLOUD_ERROR_CODE); - $criteria->addSelectColumn(CcFilesPeer::SOUNDCLOUD_ERROR_MSG); - $criteria->addSelectColumn(CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE); - $criteria->addSelectColumn(CcFilesPeer::SOUNDCLOUD_UPLOAD_TIME); - $criteria->addSelectColumn(CcFilesPeer::REPLAY_GAIN); - $criteria->addSelectColumn(CcFilesPeer::OWNER_ID); - $criteria->addSelectColumn(CcFilesPeer::CUEIN); - $criteria->addSelectColumn(CcFilesPeer::CUEOUT); - $criteria->addSelectColumn(CcFilesPeer::SILAN_CHECK); - $criteria->addSelectColumn(CcFilesPeer::HIDDEN); - $criteria->addSelectColumn(CcFilesPeer::IS_SCHEDULED); - $criteria->addSelectColumn(CcFilesPeer::IS_PLAYLIST); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.NAME'); - $criteria->addSelectColumn($alias . '.MIME'); - $criteria->addSelectColumn($alias . '.FTYPE'); - $criteria->addSelectColumn($alias . '.DIRECTORY'); - $criteria->addSelectColumn($alias . '.FILEPATH'); - $criteria->addSelectColumn($alias . '.STATE'); - $criteria->addSelectColumn($alias . '.CURRENTLYACCESSING'); - $criteria->addSelectColumn($alias . '.EDITEDBY'); - $criteria->addSelectColumn($alias . '.MTIME'); - $criteria->addSelectColumn($alias . '.UTIME'); - $criteria->addSelectColumn($alias . '.LPTIME'); - $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'); - $criteria->addSelectColumn($alias . '.FILE_EXISTS'); - $criteria->addSelectColumn($alias . '.SOUNDCLOUD_ID'); - $criteria->addSelectColumn($alias . '.SOUNDCLOUD_ERROR_CODE'); - $criteria->addSelectColumn($alias . '.SOUNDCLOUD_ERROR_MSG'); - $criteria->addSelectColumn($alias . '.SOUNDCLOUD_LINK_TO_FILE'); - $criteria->addSelectColumn($alias . '.SOUNDCLOUD_UPLOAD_TIME'); - $criteria->addSelectColumn($alias . '.REPLAY_GAIN'); - $criteria->addSelectColumn($alias . '.OWNER_ID'); - $criteria->addSelectColumn($alias . '.CUEIN'); - $criteria->addSelectColumn($alias . '.CUEOUT'); - $criteria->addSelectColumn($alias . '.SILAN_CHECK'); - $criteria->addSelectColumn($alias . '.HIDDEN'); - $criteria->addSelectColumn($alias . '.IS_SCHEDULED'); - $criteria->addSelectColumn($alias . '.IS_PLAYLIST'); - } - } - - /** - * 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 CcShowInstancesPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcShowInstancesPeer::clearInstancePool(); - // Invalidate objects in CcPlaylistcontentsPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcPlaylistcontentsPeer::clearInstancePool(); - // Invalidate objects in CcBlockcontentsPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcBlockcontentsPeer::clearInstancePool(); - // Invalidate objects in CcSchedulePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcSchedulePeer::clearInstancePool(); - // Invalidate objects in CcPlayoutHistoryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcPlayoutHistoryPeer::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 FkOwner 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 doCountJoinFkOwner(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::OWNER_ID, 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; - } - - - /** - * Returns the number of rows matching criteria, joining the related CcSubjsRelatedByDbEditedby 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 doCountJoinCcSubjsRelatedByDbEditedby(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; - } - - - /** - * Returns the number of rows matching criteria, joining the related CcMusicDirs 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 doCountJoinCcMusicDirs(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::DIRECTORY, CcMusicDirsPeer::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 doSelectJoinFkOwner(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::OWNER_ID, 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->addCcFilesRelatedByDbOwnerId($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * 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 doSelectJoinCcSubjsRelatedByDbEditedby(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->addCcFilesRelatedByDbEditedby($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcFiles objects pre-filled with their CcMusicDirs 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 doSelectJoinCcMusicDirs(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); - CcMusicDirsPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcFilesPeer::DIRECTORY, CcMusicDirsPeer::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 = CcMusicDirsPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcMusicDirsPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcMusicDirsPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcMusicDirsPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcFiles) to $obj2 (CcMusicDirs) - $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::OWNER_ID, CcSubjsPeer::ID, $join_behavior); - - $criteria->addJoin(CcFilesPeer::EDITEDBY, CcSubjsPeer::ID, $join_behavior); - - $criteria->addJoin(CcFilesPeer::DIRECTORY, CcMusicDirsPeer::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); - - CcSubjsPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + (CcSubjsPeer::NUM_COLUMNS - CcSubjsPeer::NUM_LAZY_LOAD_COLUMNS); - - CcMusicDirsPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + (CcMusicDirsPeer::NUM_COLUMNS - CcMusicDirsPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcFilesPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); - - $criteria->addJoin(CcFilesPeer::EDITEDBY, CcSubjsPeer::ID, $join_behavior); - - $criteria->addJoin(CcFilesPeer::DIRECTORY, CcMusicDirsPeer::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->addCcFilesRelatedByDbOwnerId($obj1); - } // if joined row not null - - // Add objects for joined CcSubjs rows - - $key3 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CcSubjsPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CcSubjsPeer::getOMClass(false); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CcSubjsPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (CcFiles) to the collection in $obj3 (CcSubjs) - $obj3->addCcFilesRelatedByDbEditedby($obj1); - } // if joined row not null - - // Add objects for joined CcMusicDirs rows - - $key4 = CcMusicDirsPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = CcMusicDirsPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = CcMusicDirsPeer::getOMClass(false); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - CcMusicDirsPeer::addInstanceToPool($obj4, $key4); - } // if obj4 loaded - - // Add the $obj1 (CcFiles) to the collection in $obj4 (CcMusicDirs) - $obj4->addCcFiles($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related FkOwner 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 doCountJoinAllExceptFkOwner(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 should not affect 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::DIRECTORY, CcMusicDirsPeer::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 CcSubjsRelatedByDbEditedby 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 doCountJoinAllExceptCcSubjsRelatedByDbEditedby(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 should not affect 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::DIRECTORY, CcMusicDirsPeer::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 CcMusicDirs 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 doCountJoinAllExceptCcMusicDirs(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 should not affect 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::OWNER_ID, CcSubjsPeer::ID, $join_behavior); - - $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 except FkOwner. - * - * @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 doSelectJoinAllExceptFkOwner(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); - } - - CcFilesPeer::addSelectColumns($criteria); - $startcol2 = (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); - - CcMusicDirsPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcMusicDirsPeer::NUM_COLUMNS - CcMusicDirsPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcFilesPeer::DIRECTORY, CcMusicDirsPeer::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 CcMusicDirs rows - - $key2 = CcMusicDirsPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcMusicDirsPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcMusicDirsPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcMusicDirsPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (CcFiles) to the collection in $obj2 (CcMusicDirs) - $obj2->addCcFiles($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcFiles objects pre-filled with all related objects except CcSubjsRelatedByDbEditedby. - * - * @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 doSelectJoinAllExceptCcSubjsRelatedByDbEditedby(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); - } - - CcFilesPeer::addSelectColumns($criteria); - $startcol2 = (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); - - CcMusicDirsPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcMusicDirsPeer::NUM_COLUMNS - CcMusicDirsPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcFilesPeer::DIRECTORY, CcMusicDirsPeer::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 CcMusicDirs rows - - $key2 = CcMusicDirsPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcMusicDirsPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcMusicDirsPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcMusicDirsPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (CcFiles) to the collection in $obj2 (CcMusicDirs) - $obj2->addCcFiles($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcFiles objects pre-filled with all related objects except CcMusicDirs. - * - * @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 doSelectJoinAllExceptCcMusicDirs(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); - } - - 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); - - CcSubjsPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + (CcSubjsPeer::NUM_COLUMNS - CcSubjsPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcFilesPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); - - $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 already loaded - - // Add the $obj1 (CcFiles) to the collection in $obj2 (CcSubjs) - $obj2->addCcFilesRelatedByDbOwnerId($obj1); - - } // if joined row is not null - - // Add objects for joined CcSubjs rows - - $key3 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CcSubjsPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CcSubjsPeer::getOMClass(false); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CcSubjsPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (CcFiles) to the collection in $obj3 (CcSubjs) - $obj3->addCcFilesRelatedByDbEditedby($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(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; - } + /** the column name for the soundcloud_error_msg field */ + const SOUNDCLOUD_ERROR_MSG = 'cc_files.soundcloud_error_msg'; + + /** the column name for the soundcloud_link_to_file field */ + const SOUNDCLOUD_LINK_TO_FILE = 'cc_files.soundcloud_link_to_file'; + + /** the column name for the soundcloud_upload_time field */ + const SOUNDCLOUD_UPLOAD_TIME = 'cc_files.soundcloud_upload_time'; + + /** the column name for the replay_gain field */ + const REPLAY_GAIN = 'cc_files.replay_gain'; + + /** the column name for the owner_id field */ + const OWNER_ID = 'cc_files.owner_id'; + + /** the column name for the cuein field */ + const CUEIN = 'cc_files.cuein'; + + /** the column name for the cueout field */ + const CUEOUT = 'cc_files.cueout'; + + /** the column name for the silan_check field */ + const SILAN_CHECK = 'cc_files.silan_check'; + + /** the column name for the hidden field */ + const HIDDEN = 'cc_files.hidden'; + + /** the column name for the is_scheduled field */ + const IS_SCHEDULED = 'cc_files.is_scheduled'; + + /** the column name for the is_playlist field */ + const IS_PLAYLIST = 'cc_files.is_playlist'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcFiles objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcFiles[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcFilesPeer::$fieldNames[CcFilesPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbMime', 'DbFtype', 'DbDirectory', 'DbFilepath', 'DbState', 'DbCurrentlyaccessing', 'DbEditedby', 'DbMtime', 'DbUtime', 'DbLPtime', 'DbMd5', 'DbTrackTitle', 'DbArtistName', 'DbBitRate', 'DbSampleRate', 'DbFormat', 'DbLength', 'DbAlbumTitle', 'DbGenre', 'DbComments', 'DbYear', 'DbTrackNumber', 'DbChannels', 'DbUrl', 'DbBpm', 'DbRating', 'DbEncodedBy', 'DbDiscNumber', 'DbMood', 'DbLabel', 'DbComposer', 'DbEncoder', 'DbChecksum', 'DbLyrics', 'DbOrchestra', 'DbConductor', 'DbLyricist', 'DbOriginalLyricist', 'DbRadioStationName', 'DbInfoUrl', 'DbArtistUrl', 'DbAudioSourceUrl', 'DbRadioStationUrl', 'DbBuyThisUrl', 'DbIsrcNumber', 'DbCatalogNumber', 'DbOriginalArtist', 'DbCopyright', 'DbReportDatetime', 'DbReportLocation', 'DbReportOrganization', 'DbSubject', 'DbContributor', 'DbLanguage', 'DbFileExists', 'DbSoundcloudId', 'DbSoundcloudErrorCode', 'DbSoundcloudErrorMsg', 'DbSoundcloudLinkToFile', 'DbSoundCloundUploadTime', 'DbReplayGain', 'DbOwnerId', 'DbCuein', 'DbCueout', 'DbSilanCheck', 'DbHidden', 'DbIsScheduled', 'DbIsPlaylist', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbMime', 'dbFtype', 'dbDirectory', 'dbFilepath', 'dbState', 'dbCurrentlyaccessing', 'dbEditedby', 'dbMtime', 'dbUtime', 'dbLPtime', 'dbMd5', 'dbTrackTitle', 'dbArtistName', 'dbBitRate', 'dbSampleRate', 'dbFormat', 'dbLength', 'dbAlbumTitle', 'dbGenre', 'dbComments', 'dbYear', 'dbTrackNumber', 'dbChannels', 'dbUrl', 'dbBpm', 'dbRating', 'dbEncodedBy', 'dbDiscNumber', 'dbMood', 'dbLabel', 'dbComposer', 'dbEncoder', 'dbChecksum', 'dbLyrics', 'dbOrchestra', 'dbConductor', 'dbLyricist', 'dbOriginalLyricist', 'dbRadioStationName', 'dbInfoUrl', 'dbArtistUrl', 'dbAudioSourceUrl', 'dbRadioStationUrl', 'dbBuyThisUrl', 'dbIsrcNumber', 'dbCatalogNumber', 'dbOriginalArtist', 'dbCopyright', 'dbReportDatetime', 'dbReportLocation', 'dbReportOrganization', 'dbSubject', 'dbContributor', 'dbLanguage', 'dbFileExists', 'dbSoundcloudId', 'dbSoundcloudErrorCode', 'dbSoundcloudErrorMsg', 'dbSoundcloudLinkToFile', 'dbSoundCloundUploadTime', 'dbReplayGain', 'dbOwnerId', 'dbCuein', 'dbCueout', 'dbSilanCheck', 'dbHidden', 'dbIsScheduled', 'dbIsPlaylist', ), + BasePeer::TYPE_COLNAME => array (CcFilesPeer::ID, CcFilesPeer::NAME, CcFilesPeer::MIME, CcFilesPeer::FTYPE, CcFilesPeer::DIRECTORY, CcFilesPeer::FILEPATH, CcFilesPeer::STATE, CcFilesPeer::CURRENTLYACCESSING, CcFilesPeer::EDITEDBY, CcFilesPeer::MTIME, CcFilesPeer::UTIME, CcFilesPeer::LPTIME, CcFilesPeer::MD5, CcFilesPeer::TRACK_TITLE, CcFilesPeer::ARTIST_NAME, CcFilesPeer::BIT_RATE, CcFilesPeer::SAMPLE_RATE, CcFilesPeer::FORMAT, CcFilesPeer::LENGTH, CcFilesPeer::ALBUM_TITLE, CcFilesPeer::GENRE, CcFilesPeer::COMMENTS, CcFilesPeer::YEAR, CcFilesPeer::TRACK_NUMBER, CcFilesPeer::CHANNELS, CcFilesPeer::URL, CcFilesPeer::BPM, CcFilesPeer::RATING, CcFilesPeer::ENCODED_BY, CcFilesPeer::DISC_NUMBER, CcFilesPeer::MOOD, CcFilesPeer::LABEL, CcFilesPeer::COMPOSER, CcFilesPeer::ENCODER, CcFilesPeer::CHECKSUM, CcFilesPeer::LYRICS, CcFilesPeer::ORCHESTRA, CcFilesPeer::CONDUCTOR, CcFilesPeer::LYRICIST, CcFilesPeer::ORIGINAL_LYRICIST, CcFilesPeer::RADIO_STATION_NAME, CcFilesPeer::INFO_URL, CcFilesPeer::ARTIST_URL, CcFilesPeer::AUDIO_SOURCE_URL, CcFilesPeer::RADIO_STATION_URL, CcFilesPeer::BUY_THIS_URL, CcFilesPeer::ISRC_NUMBER, CcFilesPeer::CATALOG_NUMBER, CcFilesPeer::ORIGINAL_ARTIST, CcFilesPeer::COPYRIGHT, CcFilesPeer::REPORT_DATETIME, CcFilesPeer::REPORT_LOCATION, CcFilesPeer::REPORT_ORGANIZATION, CcFilesPeer::SUBJECT, CcFilesPeer::CONTRIBUTOR, CcFilesPeer::LANGUAGE, CcFilesPeer::FILE_EXISTS, CcFilesPeer::SOUNDCLOUD_ID, CcFilesPeer::SOUNDCLOUD_ERROR_CODE, CcFilesPeer::SOUNDCLOUD_ERROR_MSG, CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE, CcFilesPeer::SOUNDCLOUD_UPLOAD_TIME, CcFilesPeer::REPLAY_GAIN, CcFilesPeer::OWNER_ID, CcFilesPeer::CUEIN, CcFilesPeer::CUEOUT, CcFilesPeer::SILAN_CHECK, CcFilesPeer::HIDDEN, CcFilesPeer::IS_SCHEDULED, CcFilesPeer::IS_PLAYLIST, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'MIME', 'FTYPE', 'DIRECTORY', 'FILEPATH', 'STATE', 'CURRENTLYACCESSING', 'EDITEDBY', 'MTIME', 'UTIME', 'LPTIME', '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', 'FILE_EXISTS', 'SOUNDCLOUD_ID', 'SOUNDCLOUD_ERROR_CODE', 'SOUNDCLOUD_ERROR_MSG', 'SOUNDCLOUD_LINK_TO_FILE', 'SOUNDCLOUD_UPLOAD_TIME', 'REPLAY_GAIN', 'OWNER_ID', 'CUEIN', 'CUEOUT', 'SILAN_CHECK', 'HIDDEN', 'IS_SCHEDULED', 'IS_PLAYLIST', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'mime', 'ftype', 'directory', 'filepath', 'state', 'currentlyaccessing', 'editedby', 'mtime', 'utime', 'lptime', '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', 'file_exists', 'soundcloud_id', 'soundcloud_error_code', 'soundcloud_error_msg', 'soundcloud_link_to_file', 'soundcloud_upload_time', 'replay_gain', 'owner_id', 'cuein', 'cueout', 'silan_check', 'hidden', 'is_scheduled', 'is_playlist', ), + 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, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcFilesPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbMime' => 2, 'DbFtype' => 3, 'DbDirectory' => 4, 'DbFilepath' => 5, 'DbState' => 6, 'DbCurrentlyaccessing' => 7, 'DbEditedby' => 8, 'DbMtime' => 9, 'DbUtime' => 10, 'DbLPtime' => 11, 'DbMd5' => 12, 'DbTrackTitle' => 13, 'DbArtistName' => 14, 'DbBitRate' => 15, 'DbSampleRate' => 16, 'DbFormat' => 17, 'DbLength' => 18, 'DbAlbumTitle' => 19, 'DbGenre' => 20, 'DbComments' => 21, 'DbYear' => 22, 'DbTrackNumber' => 23, 'DbChannels' => 24, 'DbUrl' => 25, 'DbBpm' => 26, 'DbRating' => 27, 'DbEncodedBy' => 28, 'DbDiscNumber' => 29, 'DbMood' => 30, 'DbLabel' => 31, 'DbComposer' => 32, 'DbEncoder' => 33, 'DbChecksum' => 34, 'DbLyrics' => 35, 'DbOrchestra' => 36, 'DbConductor' => 37, 'DbLyricist' => 38, 'DbOriginalLyricist' => 39, 'DbRadioStationName' => 40, 'DbInfoUrl' => 41, 'DbArtistUrl' => 42, 'DbAudioSourceUrl' => 43, 'DbRadioStationUrl' => 44, 'DbBuyThisUrl' => 45, 'DbIsrcNumber' => 46, 'DbCatalogNumber' => 47, 'DbOriginalArtist' => 48, 'DbCopyright' => 49, 'DbReportDatetime' => 50, 'DbReportLocation' => 51, 'DbReportOrganization' => 52, 'DbSubject' => 53, 'DbContributor' => 54, 'DbLanguage' => 55, 'DbFileExists' => 56, 'DbSoundcloudId' => 57, 'DbSoundcloudErrorCode' => 58, 'DbSoundcloudErrorMsg' => 59, 'DbSoundcloudLinkToFile' => 60, 'DbSoundCloundUploadTime' => 61, 'DbReplayGain' => 62, 'DbOwnerId' => 63, 'DbCuein' => 64, 'DbCueout' => 65, 'DbSilanCheck' => 66, 'DbHidden' => 67, 'DbIsScheduled' => 68, 'DbIsPlaylist' => 69, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbMime' => 2, 'dbFtype' => 3, 'dbDirectory' => 4, 'dbFilepath' => 5, 'dbState' => 6, 'dbCurrentlyaccessing' => 7, 'dbEditedby' => 8, 'dbMtime' => 9, 'dbUtime' => 10, 'dbLPtime' => 11, 'dbMd5' => 12, 'dbTrackTitle' => 13, 'dbArtistName' => 14, 'dbBitRate' => 15, 'dbSampleRate' => 16, 'dbFormat' => 17, 'dbLength' => 18, 'dbAlbumTitle' => 19, 'dbGenre' => 20, 'dbComments' => 21, 'dbYear' => 22, 'dbTrackNumber' => 23, 'dbChannels' => 24, 'dbUrl' => 25, 'dbBpm' => 26, 'dbRating' => 27, 'dbEncodedBy' => 28, 'dbDiscNumber' => 29, 'dbMood' => 30, 'dbLabel' => 31, 'dbComposer' => 32, 'dbEncoder' => 33, 'dbChecksum' => 34, 'dbLyrics' => 35, 'dbOrchestra' => 36, 'dbConductor' => 37, 'dbLyricist' => 38, 'dbOriginalLyricist' => 39, 'dbRadioStationName' => 40, 'dbInfoUrl' => 41, 'dbArtistUrl' => 42, 'dbAudioSourceUrl' => 43, 'dbRadioStationUrl' => 44, 'dbBuyThisUrl' => 45, 'dbIsrcNumber' => 46, 'dbCatalogNumber' => 47, 'dbOriginalArtist' => 48, 'dbCopyright' => 49, 'dbReportDatetime' => 50, 'dbReportLocation' => 51, 'dbReportOrganization' => 52, 'dbSubject' => 53, 'dbContributor' => 54, 'dbLanguage' => 55, 'dbFileExists' => 56, 'dbSoundcloudId' => 57, 'dbSoundcloudErrorCode' => 58, 'dbSoundcloudErrorMsg' => 59, 'dbSoundcloudLinkToFile' => 60, 'dbSoundCloundUploadTime' => 61, 'dbReplayGain' => 62, 'dbOwnerId' => 63, 'dbCuein' => 64, 'dbCueout' => 65, 'dbSilanCheck' => 66, 'dbHidden' => 67, 'dbIsScheduled' => 68, 'dbIsPlaylist' => 69, ), + BasePeer::TYPE_COLNAME => array (CcFilesPeer::ID => 0, CcFilesPeer::NAME => 1, CcFilesPeer::MIME => 2, CcFilesPeer::FTYPE => 3, CcFilesPeer::DIRECTORY => 4, CcFilesPeer::FILEPATH => 5, CcFilesPeer::STATE => 6, CcFilesPeer::CURRENTLYACCESSING => 7, CcFilesPeer::EDITEDBY => 8, CcFilesPeer::MTIME => 9, CcFilesPeer::UTIME => 10, CcFilesPeer::LPTIME => 11, CcFilesPeer::MD5 => 12, CcFilesPeer::TRACK_TITLE => 13, CcFilesPeer::ARTIST_NAME => 14, CcFilesPeer::BIT_RATE => 15, CcFilesPeer::SAMPLE_RATE => 16, CcFilesPeer::FORMAT => 17, CcFilesPeer::LENGTH => 18, CcFilesPeer::ALBUM_TITLE => 19, CcFilesPeer::GENRE => 20, CcFilesPeer::COMMENTS => 21, CcFilesPeer::YEAR => 22, CcFilesPeer::TRACK_NUMBER => 23, CcFilesPeer::CHANNELS => 24, CcFilesPeer::URL => 25, CcFilesPeer::BPM => 26, CcFilesPeer::RATING => 27, CcFilesPeer::ENCODED_BY => 28, CcFilesPeer::DISC_NUMBER => 29, CcFilesPeer::MOOD => 30, CcFilesPeer::LABEL => 31, CcFilesPeer::COMPOSER => 32, CcFilesPeer::ENCODER => 33, CcFilesPeer::CHECKSUM => 34, CcFilesPeer::LYRICS => 35, CcFilesPeer::ORCHESTRA => 36, CcFilesPeer::CONDUCTOR => 37, CcFilesPeer::LYRICIST => 38, CcFilesPeer::ORIGINAL_LYRICIST => 39, CcFilesPeer::RADIO_STATION_NAME => 40, CcFilesPeer::INFO_URL => 41, CcFilesPeer::ARTIST_URL => 42, CcFilesPeer::AUDIO_SOURCE_URL => 43, CcFilesPeer::RADIO_STATION_URL => 44, CcFilesPeer::BUY_THIS_URL => 45, CcFilesPeer::ISRC_NUMBER => 46, CcFilesPeer::CATALOG_NUMBER => 47, CcFilesPeer::ORIGINAL_ARTIST => 48, CcFilesPeer::COPYRIGHT => 49, CcFilesPeer::REPORT_DATETIME => 50, CcFilesPeer::REPORT_LOCATION => 51, CcFilesPeer::REPORT_ORGANIZATION => 52, CcFilesPeer::SUBJECT => 53, CcFilesPeer::CONTRIBUTOR => 54, CcFilesPeer::LANGUAGE => 55, CcFilesPeer::FILE_EXISTS => 56, CcFilesPeer::SOUNDCLOUD_ID => 57, CcFilesPeer::SOUNDCLOUD_ERROR_CODE => 58, CcFilesPeer::SOUNDCLOUD_ERROR_MSG => 59, CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE => 60, CcFilesPeer::SOUNDCLOUD_UPLOAD_TIME => 61, CcFilesPeer::REPLAY_GAIN => 62, CcFilesPeer::OWNER_ID => 63, CcFilesPeer::CUEIN => 64, CcFilesPeer::CUEOUT => 65, CcFilesPeer::SILAN_CHECK => 66, CcFilesPeer::HIDDEN => 67, CcFilesPeer::IS_SCHEDULED => 68, CcFilesPeer::IS_PLAYLIST => 69, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'MIME' => 2, 'FTYPE' => 3, 'DIRECTORY' => 4, 'FILEPATH' => 5, 'STATE' => 6, 'CURRENTLYACCESSING' => 7, 'EDITEDBY' => 8, 'MTIME' => 9, 'UTIME' => 10, 'LPTIME' => 11, 'MD5' => 12, 'TRACK_TITLE' => 13, 'ARTIST_NAME' => 14, 'BIT_RATE' => 15, 'SAMPLE_RATE' => 16, 'FORMAT' => 17, 'LENGTH' => 18, 'ALBUM_TITLE' => 19, 'GENRE' => 20, 'COMMENTS' => 21, 'YEAR' => 22, 'TRACK_NUMBER' => 23, 'CHANNELS' => 24, 'URL' => 25, 'BPM' => 26, 'RATING' => 27, 'ENCODED_BY' => 28, 'DISC_NUMBER' => 29, 'MOOD' => 30, 'LABEL' => 31, 'COMPOSER' => 32, 'ENCODER' => 33, 'CHECKSUM' => 34, 'LYRICS' => 35, 'ORCHESTRA' => 36, 'CONDUCTOR' => 37, 'LYRICIST' => 38, 'ORIGINAL_LYRICIST' => 39, 'RADIO_STATION_NAME' => 40, 'INFO_URL' => 41, 'ARTIST_URL' => 42, 'AUDIO_SOURCE_URL' => 43, 'RADIO_STATION_URL' => 44, 'BUY_THIS_URL' => 45, 'ISRC_NUMBER' => 46, 'CATALOG_NUMBER' => 47, 'ORIGINAL_ARTIST' => 48, 'COPYRIGHT' => 49, 'REPORT_DATETIME' => 50, 'REPORT_LOCATION' => 51, 'REPORT_ORGANIZATION' => 52, 'SUBJECT' => 53, 'CONTRIBUTOR' => 54, 'LANGUAGE' => 55, 'FILE_EXISTS' => 56, 'SOUNDCLOUD_ID' => 57, 'SOUNDCLOUD_ERROR_CODE' => 58, 'SOUNDCLOUD_ERROR_MSG' => 59, 'SOUNDCLOUD_LINK_TO_FILE' => 60, 'SOUNDCLOUD_UPLOAD_TIME' => 61, 'REPLAY_GAIN' => 62, 'OWNER_ID' => 63, 'CUEIN' => 64, 'CUEOUT' => 65, 'SILAN_CHECK' => 66, 'HIDDEN' => 67, 'IS_SCHEDULED' => 68, 'IS_PLAYLIST' => 69, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'mime' => 2, 'ftype' => 3, 'directory' => 4, 'filepath' => 5, 'state' => 6, 'currentlyaccessing' => 7, 'editedby' => 8, 'mtime' => 9, 'utime' => 10, 'lptime' => 11, 'md5' => 12, 'track_title' => 13, 'artist_name' => 14, 'bit_rate' => 15, 'sample_rate' => 16, 'format' => 17, 'length' => 18, 'album_title' => 19, 'genre' => 20, 'comments' => 21, 'year' => 22, 'track_number' => 23, 'channels' => 24, 'url' => 25, 'bpm' => 26, 'rating' => 27, 'encoded_by' => 28, 'disc_number' => 29, 'mood' => 30, 'label' => 31, 'composer' => 32, 'encoder' => 33, 'checksum' => 34, 'lyrics' => 35, 'orchestra' => 36, 'conductor' => 37, 'lyricist' => 38, 'original_lyricist' => 39, 'radio_station_name' => 40, 'info_url' => 41, 'artist_url' => 42, 'audio_source_url' => 43, 'radio_station_url' => 44, 'buy_this_url' => 45, 'isrc_number' => 46, 'catalog_number' => 47, 'original_artist' => 48, 'copyright' => 49, 'report_datetime' => 50, 'report_location' => 51, 'report_organization' => 52, 'subject' => 53, 'contributor' => 54, 'language' => 55, 'file_exists' => 56, 'soundcloud_id' => 57, 'soundcloud_error_code' => 58, 'soundcloud_error_msg' => 59, 'soundcloud_link_to_file' => 60, 'soundcloud_upload_time' => 61, 'replay_gain' => 62, 'owner_id' => 63, 'cuein' => 64, 'cueout' => 65, 'silan_check' => 66, 'hidden' => 67, 'is_scheduled' => 68, 'is_playlist' => 69, ), + 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, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcFilesPeer::getFieldNames($toType); + $key = isset(CcFilesPeer::$fieldKeys[$fromType][$name]) ? CcFilesPeer::$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(CcFilesPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcFilesPeer::$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 CcFilesPeer::$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::NAME); + $criteria->addSelectColumn(CcFilesPeer::MIME); + $criteria->addSelectColumn(CcFilesPeer::FTYPE); + $criteria->addSelectColumn(CcFilesPeer::DIRECTORY); + $criteria->addSelectColumn(CcFilesPeer::FILEPATH); + $criteria->addSelectColumn(CcFilesPeer::STATE); + $criteria->addSelectColumn(CcFilesPeer::CURRENTLYACCESSING); + $criteria->addSelectColumn(CcFilesPeer::EDITEDBY); + $criteria->addSelectColumn(CcFilesPeer::MTIME); + $criteria->addSelectColumn(CcFilesPeer::UTIME); + $criteria->addSelectColumn(CcFilesPeer::LPTIME); + $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); + $criteria->addSelectColumn(CcFilesPeer::FILE_EXISTS); + $criteria->addSelectColumn(CcFilesPeer::SOUNDCLOUD_ID); + $criteria->addSelectColumn(CcFilesPeer::SOUNDCLOUD_ERROR_CODE); + $criteria->addSelectColumn(CcFilesPeer::SOUNDCLOUD_ERROR_MSG); + $criteria->addSelectColumn(CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE); + $criteria->addSelectColumn(CcFilesPeer::SOUNDCLOUD_UPLOAD_TIME); + $criteria->addSelectColumn(CcFilesPeer::REPLAY_GAIN); + $criteria->addSelectColumn(CcFilesPeer::OWNER_ID); + $criteria->addSelectColumn(CcFilesPeer::CUEIN); + $criteria->addSelectColumn(CcFilesPeer::CUEOUT); + $criteria->addSelectColumn(CcFilesPeer::SILAN_CHECK); + $criteria->addSelectColumn(CcFilesPeer::HIDDEN); + $criteria->addSelectColumn(CcFilesPeer::IS_SCHEDULED); + $criteria->addSelectColumn(CcFilesPeer::IS_PLAYLIST); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.name'); + $criteria->addSelectColumn($alias . '.mime'); + $criteria->addSelectColumn($alias . '.ftype'); + $criteria->addSelectColumn($alias . '.directory'); + $criteria->addSelectColumn($alias . '.filepath'); + $criteria->addSelectColumn($alias . '.state'); + $criteria->addSelectColumn($alias . '.currentlyaccessing'); + $criteria->addSelectColumn($alias . '.editedby'); + $criteria->addSelectColumn($alias . '.mtime'); + $criteria->addSelectColumn($alias . '.utime'); + $criteria->addSelectColumn($alias . '.lptime'); + $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'); + $criteria->addSelectColumn($alias . '.file_exists'); + $criteria->addSelectColumn($alias . '.soundcloud_id'); + $criteria->addSelectColumn($alias . '.soundcloud_error_code'); + $criteria->addSelectColumn($alias . '.soundcloud_error_msg'); + $criteria->addSelectColumn($alias . '.soundcloud_link_to_file'); + $criteria->addSelectColumn($alias . '.soundcloud_upload_time'); + $criteria->addSelectColumn($alias . '.replay_gain'); + $criteria->addSelectColumn($alias . '.owner_id'); + $criteria->addSelectColumn($alias . '.cuein'); + $criteria->addSelectColumn($alias . '.cueout'); + $criteria->addSelectColumn($alias . '.silan_check'); + $criteria->addSelectColumn($alias . '.hidden'); + $criteria->addSelectColumn($alias . '.is_scheduled'); + $criteria->addSelectColumn($alias . '.is_playlist'); + } + } + + /** + * 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(CcFilesPeer::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; + } + /** + * Selects 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; + } + /** + * Selects several row from the DB. + * + * @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 directly (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(CcFilesPeer::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 $obj 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($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcFilesPeer::$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. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + 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(CcFilesPeer::$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(CcFilesPeer::$instances[$key])) { + return CcFilesPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcFilesPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcFilesPeer::$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 CcShowInstancesPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcShowInstancesPeer::clearInstancePool(); + // Invalidate objects in CcPlaylistcontentsPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcPlaylistcontentsPeer::clearInstancePool(); + // Invalidate objects in CcBlockcontentsPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcBlockcontentsPeer::clearInstancePool(); + // Invalidate objects in CcSchedulePeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcSchedulePeer::clearInstancePool(); + // Invalidate objects in CcPlayoutHistoryPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcPlayoutHistoryPeer::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(); + // 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_HYDRATE_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 FkOwner 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 doCountJoinFkOwner(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(CcFilesPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcFilesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcFilesPeer::OWNER_ID, 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; + } + + + /** + * Returns the number of rows matching criteria, joining the related CcSubjsRelatedByDbEditedby 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 doCountJoinCcSubjsRelatedByDbEditedby(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(CcFilesPeer::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; + } + + + /** + * Returns the number of rows matching criteria, joining the related CcMusicDirs 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 doCountJoinCcMusicDirs(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(CcFilesPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcFilesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcFilesPeer::DIRECTORY, CcMusicDirsPeer::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 doSelectJoinFkOwner(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(CcFilesPeer::DATABASE_NAME); + } + + CcFilesPeer::addSelectColumns($criteria); + $startcol = CcFilesPeer::NUM_HYDRATE_COLUMNS; + CcSubjsPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcFilesPeer::OWNER_ID, 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(); + + $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(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcFiles) to $obj2 (CcSubjs) + $obj2->addCcFilesRelatedByDbOwnerId($obj1); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * 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 doSelectJoinCcSubjsRelatedByDbEditedby(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(CcFilesPeer::DATABASE_NAME); + } + + CcFilesPeer::addSelectColumns($criteria); + $startcol = CcFilesPeer::NUM_HYDRATE_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(); + + $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(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcFiles) to $obj2 (CcSubjs) + $obj2->addCcFilesRelatedByDbEditedby($obj1); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcFiles objects pre-filled with their CcMusicDirs 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 doSelectJoinCcMusicDirs(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(CcFilesPeer::DATABASE_NAME); + } + + CcFilesPeer::addSelectColumns($criteria); + $startcol = CcFilesPeer::NUM_HYDRATE_COLUMNS; + CcMusicDirsPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcFilesPeer::DIRECTORY, CcMusicDirsPeer::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(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcFilesPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcMusicDirsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcMusicDirsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcMusicDirsPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcMusicDirsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcFiles) to $obj2 (CcMusicDirs) + $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(CcFilesPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcFilesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcFilesPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + $criteria->addJoin(CcFilesPeer::EDITEDBY, CcSubjsPeer::ID, $join_behavior); + + $criteria->addJoin(CcFilesPeer::DIRECTORY, CcMusicDirsPeer::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(CcFilesPeer::DATABASE_NAME); + } + + CcFilesPeer::addSelectColumns($criteria); + $startcol2 = CcFilesPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + CcMusicDirsPeer::addSelectColumns($criteria); + $startcol5 = $startcol4 + CcMusicDirsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcFilesPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + $criteria->addJoin(CcFilesPeer::EDITEDBY, CcSubjsPeer::ID, $join_behavior); + + $criteria->addJoin(CcFilesPeer::DIRECTORY, CcMusicDirsPeer::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(); + + $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(); + + $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->addCcFilesRelatedByDbOwnerId($obj1); + } // if joined row not null + + // Add objects for joined CcSubjs rows + + $key3 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcSubjsPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcSubjsPeer::addInstanceToPool($obj3, $key3); + } // if obj3 loaded + + // Add the $obj1 (CcFiles) to the collection in $obj3 (CcSubjs) + $obj3->addCcFilesRelatedByDbEditedby($obj1); + } // if joined row not null + + // Add objects for joined CcMusicDirs rows + + $key4 = CcMusicDirsPeer::getPrimaryKeyHashFromRow($row, $startcol4); + if ($key4 !== null) { + $obj4 = CcMusicDirsPeer::getInstanceFromPool($key4); + if (!$obj4) { + + $cls = CcMusicDirsPeer::getOMClass(); + + $obj4 = new $cls(); + $obj4->hydrate($row, $startcol4); + CcMusicDirsPeer::addInstanceToPool($obj4, $key4); + } // if obj4 loaded + + // Add the $obj1 (CcFiles) to the collection in $obj4 (CcMusicDirs) + $obj4->addCcFiles($obj1); + } // if joined row not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining the related FkOwner 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 doCountJoinAllExceptFkOwner(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 should not affect count + + // Set the correct dbName + $criteria->setDbName(CcFilesPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcFilesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcFilesPeer::DIRECTORY, CcMusicDirsPeer::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 CcSubjsRelatedByDbEditedby 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 doCountJoinAllExceptCcSubjsRelatedByDbEditedby(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 should not affect count + + // Set the correct dbName + $criteria->setDbName(CcFilesPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcFilesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcFilesPeer::DIRECTORY, CcMusicDirsPeer::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 CcMusicDirs 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 doCountJoinAllExceptCcMusicDirs(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 should not affect count + + // Set the correct dbName + $criteria->setDbName(CcFilesPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcFilesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcFilesPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + $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 except FkOwner. + * + * @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 doSelectJoinAllExceptFkOwner(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(CcFilesPeer::DATABASE_NAME); + } + + CcFilesPeer::addSelectColumns($criteria); + $startcol2 = CcFilesPeer::NUM_HYDRATE_COLUMNS; + + CcMusicDirsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcMusicDirsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcFilesPeer::DIRECTORY, CcMusicDirsPeer::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(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcFilesPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcMusicDirs rows + + $key2 = CcMusicDirsPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcMusicDirsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcMusicDirsPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcMusicDirsPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcFiles) to the collection in $obj2 (CcMusicDirs) + $obj2->addCcFiles($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcFiles objects pre-filled with all related objects except CcSubjsRelatedByDbEditedby. + * + * @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 doSelectJoinAllExceptCcSubjsRelatedByDbEditedby(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(CcFilesPeer::DATABASE_NAME); + } + + CcFilesPeer::addSelectColumns($criteria); + $startcol2 = CcFilesPeer::NUM_HYDRATE_COLUMNS; + + CcMusicDirsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcMusicDirsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcFilesPeer::DIRECTORY, CcMusicDirsPeer::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(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcFilesPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcMusicDirs rows + + $key2 = CcMusicDirsPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcMusicDirsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcMusicDirsPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcMusicDirsPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcFiles) to the collection in $obj2 (CcMusicDirs) + $obj2->addCcFiles($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcFiles objects pre-filled with all related objects except CcMusicDirs. + * + * @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 doSelectJoinAllExceptCcMusicDirs(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(CcFilesPeer::DATABASE_NAME); + } + + CcFilesPeer::addSelectColumns($criteria); + $startcol2 = CcFilesPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcFilesPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + $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(); + + $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(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcFiles) to the collection in $obj2 (CcSubjs) + $obj2->addCcFilesRelatedByDbOwnerId($obj1); + + } // if joined row is not null + + // Add objects for joined CcSubjs rows + + $key3 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcSubjsPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcSubjsPeer::addInstanceToPool($obj3, $key3); + } // if $obj3 already loaded + + // Add the $obj1 (CcFiles) to the collection in $obj3 (CcSubjs) + $obj3->addCcFilesRelatedByDbEditedby($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(CcFilesPeer::DATABASE_NAME)->getTable(CcFilesPeer::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 \Airtime\map\CcFilesTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcFilesPeer::OM_CLASS; + } + + /** + * Performs 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(CcFilesPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs 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(CcFilesPeer::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(CcFilesPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_files table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $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 (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs 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(CcFilesPeer::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(CcFilesPeer::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 (Exception $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($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->hasColumn($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 + * @return CcFiles[] + * @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 diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php index 50a21a332..5e5b0980d 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php @@ -1,2622 +1,3413 @@ 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 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 CcFilesQuery 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(CcFilesPeer::NAME, $dbName, $comparison); - } - - /** - * Filter the query on the mime column - * - * @param string $dbMime 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 filterByDbMime($dbMime = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbMime)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbMime)) { - $dbMime = str_replace('*', '%', $dbMime); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::MIME, $dbMime, $comparison); - } - - /** - * Filter the query on the ftype column - * - * @param string $dbFtype 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 filterByDbFtype($dbFtype = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbFtype)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbFtype)) { - $dbFtype = str_replace('*', '%', $dbFtype); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::FTYPE, $dbFtype, $comparison); - } - - /** - * Filter the query on the directory column - * - * @param int|array $dbDirectory 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 filterByDbDirectory($dbDirectory = null, $comparison = null) - { - if (is_array($dbDirectory)) { - $useMinMax = false; - if (isset($dbDirectory['min'])) { - $this->addUsingAlias(CcFilesPeer::DIRECTORY, $dbDirectory['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbDirectory['max'])) { - $this->addUsingAlias(CcFilesPeer::DIRECTORY, $dbDirectory['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFilesPeer::DIRECTORY, $dbDirectory, $comparison); - } - - /** - * Filter the query on the filepath column - * - * @param string $dbFilepath 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 filterByDbFilepath($dbFilepath = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbFilepath)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbFilepath)) { - $dbFilepath = str_replace('*', '%', $dbFilepath); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::FILEPATH, $dbFilepath, $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 CcFilesQuery 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(CcFilesPeer::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 CcFilesQuery 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(CcFilesPeer::CURRENTLYACCESSING, $dbCurrentlyaccessing['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbCurrentlyaccessing['max'])) { - $this->addUsingAlias(CcFilesPeer::CURRENTLYACCESSING, $dbCurrentlyaccessing['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFilesPeer::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 CcFilesQuery 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(CcFilesPeer::EDITEDBY, $dbEditedby['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbEditedby['max'])) { - $this->addUsingAlias(CcFilesPeer::EDITEDBY, $dbEditedby['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFilesPeer::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 CcFilesQuery 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(CcFilesPeer::MTIME, $dbMtime['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbMtime['max'])) { - $this->addUsingAlias(CcFilesPeer::MTIME, $dbMtime['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFilesPeer::MTIME, $dbMtime, $comparison); - } - - /** - * Filter the query on the utime column - * - * @param string|array $dbUtime 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 filterByDbUtime($dbUtime = null, $comparison = null) - { - if (is_array($dbUtime)) { - $useMinMax = false; - if (isset($dbUtime['min'])) { - $this->addUsingAlias(CcFilesPeer::UTIME, $dbUtime['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbUtime['max'])) { - $this->addUsingAlias(CcFilesPeer::UTIME, $dbUtime['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFilesPeer::UTIME, $dbUtime, $comparison); - } - - /** - * Filter the query on the lptime column - * - * @param string|array $dbLPtime 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 filterByDbLPtime($dbLPtime = null, $comparison = null) - { - if (is_array($dbLPtime)) { - $useMinMax = false; - if (isset($dbLPtime['min'])) { - $this->addUsingAlias(CcFilesPeer::LPTIME, $dbLPtime['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbLPtime['max'])) { - $this->addUsingAlias(CcFilesPeer::LPTIME, $dbLPtime['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFilesPeer::LPTIME, $dbLPtime, $comparison); - } - - /** - * Filter the query on the md5 column - * - * @param string $dbMd5 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 filterByDbMd5($dbMd5 = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbMd5)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbMd5)) { - $dbMd5 = str_replace('*', '%', $dbMd5); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::MD5, $dbMd5, $comparison); - } - - /** - * Filter the query on the track_title column - * - * @param string $dbTrackTitle 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 filterByDbTrackTitle($dbTrackTitle = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbTrackTitle)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbTrackTitle)) { - $dbTrackTitle = str_replace('*', '%', $dbTrackTitle); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::TRACK_TITLE, $dbTrackTitle, $comparison); - } - - /** - * Filter the query on the artist_name column - * - * @param string $dbArtistName 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 filterByDbArtistName($dbArtistName = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbArtistName)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbArtistName)) { - $dbArtistName = str_replace('*', '%', $dbArtistName); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::ARTIST_NAME, $dbArtistName, $comparison); - } - - /** - * Filter the query on the bit_rate column - * - * @param int|array $dbBitRate The value to use as filter. - * Accepts an associative array('min' => $minValue, 'max' => $maxValue) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcFilesQuery The current query, for fluid interface - */ - public function filterByDbBitRate($dbBitRate = null, $comparison = null) - { - if (is_array($dbBitRate)) { - $useMinMax = false; - if (isset($dbBitRate['min'])) { - $this->addUsingAlias(CcFilesPeer::BIT_RATE, $dbBitRate['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbBitRate['max'])) { - $this->addUsingAlias(CcFilesPeer::BIT_RATE, $dbBitRate['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFilesPeer::BIT_RATE, $dbBitRate, $comparison); - } - - /** - * Filter the query on the sample_rate column - * - * @param int|array $dbSampleRate The value to use as filter. - * Accepts an associative array('min' => $minValue, 'max' => $maxValue) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcFilesQuery The current query, for fluid interface - */ - public function filterByDbSampleRate($dbSampleRate = null, $comparison = null) - { - if (is_array($dbSampleRate)) { - $useMinMax = false; - if (isset($dbSampleRate['min'])) { - $this->addUsingAlias(CcFilesPeer::SAMPLE_RATE, $dbSampleRate['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbSampleRate['max'])) { - $this->addUsingAlias(CcFilesPeer::SAMPLE_RATE, $dbSampleRate['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFilesPeer::SAMPLE_RATE, $dbSampleRate, $comparison); - } - - /** - * Filter the query on the format column - * - * @param string $dbFormat 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 filterByDbFormat($dbFormat = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbFormat)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbFormat)) { - $dbFormat = str_replace('*', '%', $dbFormat); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::FORMAT, $dbFormat, $comparison); - } - - /** - * Filter the query on the length column - * - * @param string $dbLength 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 filterByDbLength($dbLength = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbLength)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbLength)) { - $dbLength = str_replace('*', '%', $dbLength); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::LENGTH, $dbLength, $comparison); - } - - /** - * Filter the query on the album_title column - * - * @param string $dbAlbumTitle 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 filterByDbAlbumTitle($dbAlbumTitle = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbAlbumTitle)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbAlbumTitle)) { - $dbAlbumTitle = str_replace('*', '%', $dbAlbumTitle); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::ALBUM_TITLE, $dbAlbumTitle, $comparison); - } - - /** - * Filter the query on the genre column - * - * @param string $dbGenre 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 filterByDbGenre($dbGenre = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbGenre)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbGenre)) { - $dbGenre = str_replace('*', '%', $dbGenre); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::GENRE, $dbGenre, $comparison); - } - - /** - * Filter the query on the comments column - * - * @param string $dbComments 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 filterByDbComments($dbComments = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbComments)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbComments)) { - $dbComments = str_replace('*', '%', $dbComments); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::COMMENTS, $dbComments, $comparison); - } - - /** - * Filter the query on the year column - * - * @param string $dbYear 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 filterByDbYear($dbYear = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbYear)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbYear)) { - $dbYear = str_replace('*', '%', $dbYear); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::YEAR, $dbYear, $comparison); - } - - /** - * Filter the query on the track_number column - * - * @param int|array $dbTrackNumber 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 filterByDbTrackNumber($dbTrackNumber = null, $comparison = null) - { - if (is_array($dbTrackNumber)) { - $useMinMax = false; - if (isset($dbTrackNumber['min'])) { - $this->addUsingAlias(CcFilesPeer::TRACK_NUMBER, $dbTrackNumber['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbTrackNumber['max'])) { - $this->addUsingAlias(CcFilesPeer::TRACK_NUMBER, $dbTrackNumber['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFilesPeer::TRACK_NUMBER, $dbTrackNumber, $comparison); - } - - /** - * Filter the query on the channels column - * - * @param int|array $dbChannels 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 filterByDbChannels($dbChannels = null, $comparison = null) - { - if (is_array($dbChannels)) { - $useMinMax = false; - if (isset($dbChannels['min'])) { - $this->addUsingAlias(CcFilesPeer::CHANNELS, $dbChannels['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbChannels['max'])) { - $this->addUsingAlias(CcFilesPeer::CHANNELS, $dbChannels['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFilesPeer::CHANNELS, $dbChannels, $comparison); - } - - /** - * Filter the query on the url column - * - * @param string $dbUrl 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 filterByDbUrl($dbUrl = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbUrl)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbUrl)) { - $dbUrl = str_replace('*', '%', $dbUrl); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::URL, $dbUrl, $comparison); - } - - /** - * Filter the query on the bpm column - * - * @param int|array $dbBpm The value to use as filter. - * Accepts an associative array('min' => $minValue, 'max' => $maxValue) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcFilesQuery The current query, for fluid interface - */ - public function filterByDbBpm($dbBpm = null, $comparison = null) - { - if (is_array($dbBpm)) { - $useMinMax = false; - if (isset($dbBpm['min'])) { - $this->addUsingAlias(CcFilesPeer::BPM, $dbBpm['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbBpm['max'])) { - $this->addUsingAlias(CcFilesPeer::BPM, $dbBpm['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFilesPeer::BPM, $dbBpm, $comparison); - } - - /** - * Filter the query on the rating column - * - * @param string $dbRating 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 filterByDbRating($dbRating = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbRating)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbRating)) { - $dbRating = str_replace('*', '%', $dbRating); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::RATING, $dbRating, $comparison); - } - - /** - * Filter the query on the encoded_by column - * - * @param string $dbEncodedBy 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 filterByDbEncodedBy($dbEncodedBy = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbEncodedBy)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbEncodedBy)) { - $dbEncodedBy = str_replace('*', '%', $dbEncodedBy); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::ENCODED_BY, $dbEncodedBy, $comparison); - } - - /** - * Filter the query on the disc_number column - * - * @param string $dbDiscNumber 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 filterByDbDiscNumber($dbDiscNumber = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbDiscNumber)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbDiscNumber)) { - $dbDiscNumber = str_replace('*', '%', $dbDiscNumber); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::DISC_NUMBER, $dbDiscNumber, $comparison); - } - - /** - * Filter the query on the mood column - * - * @param string $dbMood 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 filterByDbMood($dbMood = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbMood)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbMood)) { - $dbMood = str_replace('*', '%', $dbMood); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::MOOD, $dbMood, $comparison); - } - - /** - * Filter the query on the label column - * - * @param string $dbLabel 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 filterByDbLabel($dbLabel = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbLabel)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbLabel)) { - $dbLabel = str_replace('*', '%', $dbLabel); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::LABEL, $dbLabel, $comparison); - } - - /** - * Filter the query on the composer column - * - * @param string $dbComposer 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 filterByDbComposer($dbComposer = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbComposer)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbComposer)) { - $dbComposer = str_replace('*', '%', $dbComposer); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::COMPOSER, $dbComposer, $comparison); - } - - /** - * Filter the query on the encoder column - * - * @param string $dbEncoder 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 filterByDbEncoder($dbEncoder = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbEncoder)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbEncoder)) { - $dbEncoder = str_replace('*', '%', $dbEncoder); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::ENCODER, $dbEncoder, $comparison); - } - - /** - * Filter the query on the checksum column - * - * @param string $dbChecksum 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 filterByDbChecksum($dbChecksum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbChecksum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbChecksum)) { - $dbChecksum = str_replace('*', '%', $dbChecksum); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::CHECKSUM, $dbChecksum, $comparison); - } - - /** - * Filter the query on the lyrics column - * - * @param string $dbLyrics 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 filterByDbLyrics($dbLyrics = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbLyrics)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbLyrics)) { - $dbLyrics = str_replace('*', '%', $dbLyrics); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::LYRICS, $dbLyrics, $comparison); - } - - /** - * Filter the query on the orchestra column - * - * @param string $dbOrchestra 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 filterByDbOrchestra($dbOrchestra = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbOrchestra)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbOrchestra)) { - $dbOrchestra = str_replace('*', '%', $dbOrchestra); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::ORCHESTRA, $dbOrchestra, $comparison); - } - - /** - * Filter the query on the conductor column - * - * @param string $dbConductor 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 filterByDbConductor($dbConductor = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbConductor)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbConductor)) { - $dbConductor = str_replace('*', '%', $dbConductor); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::CONDUCTOR, $dbConductor, $comparison); - } - - /** - * Filter the query on the lyricist column - * - * @param string $dbLyricist 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 filterByDbLyricist($dbLyricist = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbLyricist)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbLyricist)) { - $dbLyricist = str_replace('*', '%', $dbLyricist); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::LYRICIST, $dbLyricist, $comparison); - } - - /** - * Filter the query on the original_lyricist column - * - * @param string $dbOriginalLyricist 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 filterByDbOriginalLyricist($dbOriginalLyricist = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbOriginalLyricist)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbOriginalLyricist)) { - $dbOriginalLyricist = str_replace('*', '%', $dbOriginalLyricist); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::ORIGINAL_LYRICIST, $dbOriginalLyricist, $comparison); - } - - /** - * Filter the query on the radio_station_name column - * - * @param string $dbRadioStationName 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 filterByDbRadioStationName($dbRadioStationName = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbRadioStationName)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbRadioStationName)) { - $dbRadioStationName = str_replace('*', '%', $dbRadioStationName); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::RADIO_STATION_NAME, $dbRadioStationName, $comparison); - } - - /** - * Filter the query on the info_url column - * - * @param string $dbInfoUrl 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 filterByDbInfoUrl($dbInfoUrl = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbInfoUrl)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbInfoUrl)) { - $dbInfoUrl = str_replace('*', '%', $dbInfoUrl); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::INFO_URL, $dbInfoUrl, $comparison); - } - - /** - * Filter the query on the artist_url column - * - * @param string $dbArtistUrl 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 filterByDbArtistUrl($dbArtistUrl = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbArtistUrl)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbArtistUrl)) { - $dbArtistUrl = str_replace('*', '%', $dbArtistUrl); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::ARTIST_URL, $dbArtistUrl, $comparison); - } - - /** - * Filter the query on the audio_source_url column - * - * @param string $dbAudioSourceUrl 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 filterByDbAudioSourceUrl($dbAudioSourceUrl = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbAudioSourceUrl)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbAudioSourceUrl)) { - $dbAudioSourceUrl = str_replace('*', '%', $dbAudioSourceUrl); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::AUDIO_SOURCE_URL, $dbAudioSourceUrl, $comparison); - } - - /** - * Filter the query on the radio_station_url column - * - * @param string $dbRadioStationUrl 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 filterByDbRadioStationUrl($dbRadioStationUrl = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbRadioStationUrl)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbRadioStationUrl)) { - $dbRadioStationUrl = str_replace('*', '%', $dbRadioStationUrl); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::RADIO_STATION_URL, $dbRadioStationUrl, $comparison); - } - - /** - * Filter the query on the buy_this_url column - * - * @param string $dbBuyThisUrl 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 filterByDbBuyThisUrl($dbBuyThisUrl = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbBuyThisUrl)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbBuyThisUrl)) { - $dbBuyThisUrl = str_replace('*', '%', $dbBuyThisUrl); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::BUY_THIS_URL, $dbBuyThisUrl, $comparison); - } - - /** - * Filter the query on the isrc_number column - * - * @param string $dbIsrcNumber 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 filterByDbIsrcNumber($dbIsrcNumber = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbIsrcNumber)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbIsrcNumber)) { - $dbIsrcNumber = str_replace('*', '%', $dbIsrcNumber); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::ISRC_NUMBER, $dbIsrcNumber, $comparison); - } - - /** - * Filter the query on the catalog_number column - * - * @param string $dbCatalogNumber 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 filterByDbCatalogNumber($dbCatalogNumber = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbCatalogNumber)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbCatalogNumber)) { - $dbCatalogNumber = str_replace('*', '%', $dbCatalogNumber); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::CATALOG_NUMBER, $dbCatalogNumber, $comparison); - } - - /** - * Filter the query on the original_artist column - * - * @param string $dbOriginalArtist 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 filterByDbOriginalArtist($dbOriginalArtist = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbOriginalArtist)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbOriginalArtist)) { - $dbOriginalArtist = str_replace('*', '%', $dbOriginalArtist); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::ORIGINAL_ARTIST, $dbOriginalArtist, $comparison); - } - - /** - * Filter the query on the copyright column - * - * @param string $dbCopyright 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 filterByDbCopyright($dbCopyright = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbCopyright)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbCopyright)) { - $dbCopyright = str_replace('*', '%', $dbCopyright); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::COPYRIGHT, $dbCopyright, $comparison); - } - - /** - * Filter the query on the report_datetime column - * - * @param string $dbReportDatetime 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 filterByDbReportDatetime($dbReportDatetime = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbReportDatetime)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbReportDatetime)) { - $dbReportDatetime = str_replace('*', '%', $dbReportDatetime); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::REPORT_DATETIME, $dbReportDatetime, $comparison); - } - - /** - * Filter the query on the report_location column - * - * @param string $dbReportLocation 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 filterByDbReportLocation($dbReportLocation = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbReportLocation)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbReportLocation)) { - $dbReportLocation = str_replace('*', '%', $dbReportLocation); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::REPORT_LOCATION, $dbReportLocation, $comparison); - } - - /** - * Filter the query on the report_organization column - * - * @param string $dbReportOrganization 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 filterByDbReportOrganization($dbReportOrganization = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbReportOrganization)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbReportOrganization)) { - $dbReportOrganization = str_replace('*', '%', $dbReportOrganization); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::REPORT_ORGANIZATION, $dbReportOrganization, $comparison); - } - - /** - * Filter the query on the subject column - * - * @param string $dbSubject 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 filterByDbSubject($dbSubject = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbSubject)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbSubject)) { - $dbSubject = str_replace('*', '%', $dbSubject); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::SUBJECT, $dbSubject, $comparison); - } - - /** - * Filter the query on the contributor column - * - * @param string $dbContributor 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 filterByDbContributor($dbContributor = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbContributor)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbContributor)) { - $dbContributor = str_replace('*', '%', $dbContributor); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::CONTRIBUTOR, $dbContributor, $comparison); - } - - /** - * Filter the query on the language column - * - * @param string $dbLanguage 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 filterByDbLanguage($dbLanguage = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbLanguage)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbLanguage)) { - $dbLanguage = str_replace('*', '%', $dbLanguage); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::LANGUAGE, $dbLanguage, $comparison); - } - - /** - * Filter the query on the file_exists column - * - * @param boolean|string $dbFileExists The value to use as filter. - * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcFilesQuery The current query, for fluid interface - */ - public function filterByDbFileExists($dbFileExists = null, $comparison = null) - { - if (is_string($dbFileExists)) { - $file_exists = in_array(strtolower($dbFileExists), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; - } - return $this->addUsingAlias(CcFilesPeer::FILE_EXISTS, $dbFileExists, $comparison); - } - - /** - * Filter the query on the soundcloud_id column - * - * @param int|array $dbSoundcloudId 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 filterByDbSoundcloudId($dbSoundcloudId = null, $comparison = null) - { - if (is_array($dbSoundcloudId)) { - $useMinMax = false; - if (isset($dbSoundcloudId['min'])) { - $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ID, $dbSoundcloudId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbSoundcloudId['max'])) { - $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ID, $dbSoundcloudId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ID, $dbSoundcloudId, $comparison); - } - - /** - * Filter the query on the soundcloud_error_code column - * - * @param int|array $dbSoundcloudErrorCode 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 filterByDbSoundcloudErrorCode($dbSoundcloudErrorCode = null, $comparison = null) - { - if (is_array($dbSoundcloudErrorCode)) { - $useMinMax = false; - if (isset($dbSoundcloudErrorCode['min'])) { - $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ERROR_CODE, $dbSoundcloudErrorCode['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbSoundcloudErrorCode['max'])) { - $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ERROR_CODE, $dbSoundcloudErrorCode['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ERROR_CODE, $dbSoundcloudErrorCode, $comparison); - } - - /** - * Filter the query on the soundcloud_error_msg column - * - * @param string $dbSoundcloudErrorMsg 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 filterByDbSoundcloudErrorMsg($dbSoundcloudErrorMsg = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbSoundcloudErrorMsg)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbSoundcloudErrorMsg)) { - $dbSoundcloudErrorMsg = str_replace('*', '%', $dbSoundcloudErrorMsg); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ERROR_MSG, $dbSoundcloudErrorMsg, $comparison); - } - - /** - * Filter the query on the soundcloud_link_to_file column - * - * @param string $dbSoundcloudLinkToFile 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 filterByDbSoundcloudLinkToFile($dbSoundcloudLinkToFile = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbSoundcloudLinkToFile)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbSoundcloudLinkToFile)) { - $dbSoundcloudLinkToFile = str_replace('*', '%', $dbSoundcloudLinkToFile); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE, $dbSoundcloudLinkToFile, $comparison); - } - - /** - * Filter the query on the soundcloud_upload_time column - * - * @param string|array $dbSoundCloundUploadTime 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 filterByDbSoundCloundUploadTime($dbSoundCloundUploadTime = null, $comparison = null) - { - if (is_array($dbSoundCloundUploadTime)) { - $useMinMax = false; - if (isset($dbSoundCloundUploadTime['min'])) { - $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_UPLOAD_TIME, $dbSoundCloundUploadTime['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbSoundCloundUploadTime['max'])) { - $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_UPLOAD_TIME, $dbSoundCloundUploadTime['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_UPLOAD_TIME, $dbSoundCloundUploadTime, $comparison); - } - - /** - * Filter the query on the replay_gain column - * - * @param string|array $dbReplayGain 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 filterByDbReplayGain($dbReplayGain = null, $comparison = null) - { - if (is_array($dbReplayGain)) { - $useMinMax = false; - if (isset($dbReplayGain['min'])) { - $this->addUsingAlias(CcFilesPeer::REPLAY_GAIN, $dbReplayGain['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbReplayGain['max'])) { - $this->addUsingAlias(CcFilesPeer::REPLAY_GAIN, $dbReplayGain['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFilesPeer::REPLAY_GAIN, $dbReplayGain, $comparison); - } - - /** - * Filter the query on the owner_id column - * - * @param int|array $dbOwnerId 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 filterByDbOwnerId($dbOwnerId = null, $comparison = null) - { - if (is_array($dbOwnerId)) { - $useMinMax = false; - if (isset($dbOwnerId['min'])) { - $this->addUsingAlias(CcFilesPeer::OWNER_ID, $dbOwnerId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbOwnerId['max'])) { - $this->addUsingAlias(CcFilesPeer::OWNER_ID, $dbOwnerId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcFilesPeer::OWNER_ID, $dbOwnerId, $comparison); - } - - /** - * Filter the query on the cuein column - * - * @param string $dbCuein 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 filterByDbCuein($dbCuein = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbCuein)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbCuein)) { - $dbCuein = str_replace('*', '%', $dbCuein); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::CUEIN, $dbCuein, $comparison); - } - - /** - * Filter the query on the cueout column - * - * @param string $dbCueout 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 filterByDbCueout($dbCueout = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbCueout)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbCueout)) { - $dbCueout = str_replace('*', '%', $dbCueout); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcFilesPeer::CUEOUT, $dbCueout, $comparison); - } - - /** - * Filter the query on the silan_check column - * - * @param boolean|string $dbSilanCheck The value to use as filter. - * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcFilesQuery The current query, for fluid interface - */ - public function filterByDbSilanCheck($dbSilanCheck = null, $comparison = null) - { - if (is_string($dbSilanCheck)) { - $silan_check = in_array(strtolower($dbSilanCheck), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; - } - return $this->addUsingAlias(CcFilesPeer::SILAN_CHECK, $dbSilanCheck, $comparison); - } - - /** - * Filter the query on the hidden column - * - * @param boolean|string $dbHidden The value to use as filter. - * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcFilesQuery The current query, for fluid interface - */ - public function filterByDbHidden($dbHidden = null, $comparison = null) - { - if (is_string($dbHidden)) { - $hidden = in_array(strtolower($dbHidden), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; - } - return $this->addUsingAlias(CcFilesPeer::HIDDEN, $dbHidden, $comparison); - } - - /** - * Filter the query on the is_scheduled column - * - * @param boolean|string $dbIsScheduled The value to use as filter. - * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcFilesQuery The current query, for fluid interface - */ - public function filterByDbIsScheduled($dbIsScheduled = null, $comparison = null) - { - if (is_string($dbIsScheduled)) { - $is_scheduled = in_array(strtolower($dbIsScheduled), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; - } - return $this->addUsingAlias(CcFilesPeer::IS_SCHEDULED, $dbIsScheduled, $comparison); - } - - /** - * Filter the query on the is_playlist column - * - * @param boolean|string $dbIsPlaylist The value to use as filter. - * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcFilesQuery The current query, for fluid interface - */ - public function filterByDbIsPlaylist($dbIsPlaylist = null, $comparison = null) - { - if (is_string($dbIsPlaylist)) { - $is_playlist = in_array(strtolower($dbIsPlaylist), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; - } - return $this->addUsingAlias(CcFilesPeer::IS_PLAYLIST, $dbIsPlaylist, $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 filterByFkOwner($ccSubjs, $comparison = null) - { - return $this - ->addUsingAlias(CcFilesPeer::OWNER_ID, $ccSubjs->getDbId(), $comparison); - } - - /** - * Adds a JOIN clause to the query using the FkOwner 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 joinFkOwner($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FkOwner'); - - // 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, 'FkOwner'); - } - - return $this; - } - - /** - * Use the FkOwner 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 useFkOwnerQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinFkOwner($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FkOwner', 'CcSubjsQuery'); - } - - /** - * 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 filterByCcSubjsRelatedByDbEditedby($ccSubjs, $comparison = null) - { - return $this - ->addUsingAlias(CcFilesPeer::EDITEDBY, $ccSubjs->getDbId(), $comparison); - } - - /** - * Adds a JOIN clause to the query using the CcSubjsRelatedByDbEditedby 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 joinCcSubjsRelatedByDbEditedby($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcSubjsRelatedByDbEditedby'); - - // 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, 'CcSubjsRelatedByDbEditedby'); - } - - return $this; - } - - /** - * Use the CcSubjsRelatedByDbEditedby 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 useCcSubjsRelatedByDbEditedbyQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcSubjsRelatedByDbEditedby($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcSubjsRelatedByDbEditedby', 'CcSubjsQuery'); - } - - /** - * Filter the query by a related CcMusicDirs object - * - * @param CcMusicDirs $ccMusicDirs 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 filterByCcMusicDirs($ccMusicDirs, $comparison = null) - { - return $this - ->addUsingAlias(CcFilesPeer::DIRECTORY, $ccMusicDirs->getId(), $comparison); - } - - /** - * Adds a JOIN clause to the query using the CcMusicDirs 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 joinCcMusicDirs($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcMusicDirs'); - - // 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, 'CcMusicDirs'); - } - - return $this; - } - - /** - * Use the CcMusicDirs relation CcMusicDirs 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 CcMusicDirsQuery A secondary query class using the current class as primary query - */ - public function useCcMusicDirsQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcMusicDirs($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcMusicDirs', 'CcMusicDirsQuery'); - } - - /** - * Filter the query by a related CcShowInstances object - * - * @param CcShowInstances $ccShowInstances 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 filterByCcShowInstances($ccShowInstances, $comparison = null) - { - return $this - ->addUsingAlias(CcFilesPeer::ID, $ccShowInstances->getDbRecordedFile(), $comparison); - } - - /** - * Adds a JOIN clause to the query using the CcShowInstances 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 joinCcShowInstances($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcShowInstances'); - - // 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, 'CcShowInstances'); - } - - return $this; - } - - /** - * Use the CcShowInstances relation CcShowInstances 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 CcShowInstancesQuery A secondary query class using the current class as primary query - */ - public function useCcShowInstancesQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcShowInstances($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcShowInstances', 'CcShowInstancesQuery'); - } - - /** - * 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'); - } - - /** - * Filter the query by a related CcBlockcontents object - * - * @param CcBlockcontents $ccBlockcontents 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 filterByCcBlockcontents($ccBlockcontents, $comparison = null) - { - return $this - ->addUsingAlias(CcFilesPeer::ID, $ccBlockcontents->getDbFileId(), $comparison); - } - - /** - * Adds a JOIN clause to the query using the CcBlockcontents 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 joinCcBlockcontents($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcBlockcontents'); - - // 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, 'CcBlockcontents'); - } - - return $this; - } - - /** - * Use the CcBlockcontents relation CcBlockcontents 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 CcBlockcontentsQuery A secondary query class using the current class as primary query - */ - public function useCcBlockcontentsQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcBlockcontents($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcBlockcontents', 'CcBlockcontentsQuery'); - } - - /** - * Filter the query by a related CcSchedule object - * - * @param CcSchedule $ccSchedule 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 filterByCcSchedule($ccSchedule, $comparison = null) - { - return $this - ->addUsingAlias(CcFilesPeer::ID, $ccSchedule->getDbFileId(), $comparison); - } - - /** - * Adds a JOIN clause to the query using the CcSchedule 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 joinCcSchedule($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcSchedule'); - - // 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, 'CcSchedule'); - } - - return $this; - } - - /** - * Use the CcSchedule relation CcSchedule 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 CcScheduleQuery A secondary query class using the current class as primary query - */ - public function useCcScheduleQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcSchedule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcSchedule', 'CcScheduleQuery'); - } - - /** - * Filter the query by a related CcPlayoutHistory object - * - * @param CcPlayoutHistory $ccPlayoutHistory 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 filterByCcPlayoutHistory($ccPlayoutHistory, $comparison = null) - { - return $this - ->addUsingAlias(CcFilesPeer::ID, $ccPlayoutHistory->getDbFileId(), $comparison); - } - - /** - * Adds a JOIN clause to the query using the CcPlayoutHistory 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 joinCcPlayoutHistory($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcPlayoutHistory'); - - // 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, 'CcPlayoutHistory'); - } - - return $this; - } - - /** - * Use the CcPlayoutHistory relation CcPlayoutHistory 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 CcPlayoutHistoryQuery A secondary query class using the current class as primary query - */ - public function useCcPlayoutHistoryQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcPlayoutHistory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcPlayoutHistory', 'CcPlayoutHistoryQuery'); - } - - /** - * 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 + /** + * Initializes internal state of BaseCcFilesQuery object. + * + * @param string $dbName The dabase name + * @param string $modelName The phpName of a model, e.g. 'Book' + * @param string $modelAlias The alias for the model in this query, e.g. 'b' + */ + public function __construct($dbName = null, $modelName = null, $modelAlias = null) + { + if (null === $dbName) { + $dbName = 'airtime'; + } + if (null === $modelName) { + $modelName = 'Airtime\\CcFiles'; + } + parent::__construct($dbName, $modelName, $modelAlias); + } + + /** + * Returns a new CcFilesQuery object. + * + * @param string $modelAlias The alias of a model in the query + * @param CcFilesQuery|Criteria $criteria Optional Criteria to build the query from + * + * @return CcFilesQuery + */ + public static function create($modelAlias = null, $criteria = null) + { + if ($criteria instanceof CcFilesQuery) { + return $criteria; + } + $query = new CcFilesQuery(null, null, $modelAlias); + + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcFiles|CcFiles[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcFilesPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcFilesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcFiles A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcFiles A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "name", "mime", "ftype", "directory", "filepath", "state", "currentlyaccessing", "editedby", "mtime", "utime", "lptime", "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", "file_exists", "soundcloud_id", "soundcloud_error_code", "soundcloud_error_msg", "soundcloud_link_to_file", "soundcloud_upload_time", "replay_gain", "owner_id", "cuein", "cueout", "silan_check", "hidden", "is_scheduled", "is_playlist" FROM "cc_files" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcFiles(); + $obj->hydrate($row); + CcFilesPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcFiles|CcFiles[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($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|CcFiles[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($stmt); + } + + /** + * 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 + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @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)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcFilesPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcFilesPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcFilesPeer::ID, $dbId, $comparison); + } + + /** + * Filter the query on the name column + * + * Example usage: + * + * $query->filterByDbName('fooValue'); // WHERE name = 'fooValue' + * $query->filterByDbName('%fooValue%'); // WHERE name LIKE '%fooValue%' + * + * + * @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 CcFilesQuery 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(CcFilesPeer::NAME, $dbName, $comparison); + } + + /** + * Filter the query on the mime column + * + * Example usage: + * + * $query->filterByDbMime('fooValue'); // WHERE mime = 'fooValue' + * $query->filterByDbMime('%fooValue%'); // WHERE mime LIKE '%fooValue%' + * + * + * @param string $dbMime 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 filterByDbMime($dbMime = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbMime)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbMime)) { + $dbMime = str_replace('*', '%', $dbMime); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::MIME, $dbMime, $comparison); + } + + /** + * Filter the query on the ftype column + * + * Example usage: + * + * $query->filterByDbFtype('fooValue'); // WHERE ftype = 'fooValue' + * $query->filterByDbFtype('%fooValue%'); // WHERE ftype LIKE '%fooValue%' + * + * + * @param string $dbFtype 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 filterByDbFtype($dbFtype = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbFtype)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbFtype)) { + $dbFtype = str_replace('*', '%', $dbFtype); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::FTYPE, $dbFtype, $comparison); + } + + /** + * Filter the query on the directory column + * + * Example usage: + * + * $query->filterByDbDirectory(1234); // WHERE directory = 1234 + * $query->filterByDbDirectory(array(12, 34)); // WHERE directory IN (12, 34) + * $query->filterByDbDirectory(array('min' => 12)); // WHERE directory >= 12 + * $query->filterByDbDirectory(array('max' => 12)); // WHERE directory <= 12 + * + * + * @see filterByCcMusicDirs() + * + * @param mixed $dbDirectory The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbDirectory($dbDirectory = null, $comparison = null) + { + if (is_array($dbDirectory)) { + $useMinMax = false; + if (isset($dbDirectory['min'])) { + $this->addUsingAlias(CcFilesPeer::DIRECTORY, $dbDirectory['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbDirectory['max'])) { + $this->addUsingAlias(CcFilesPeer::DIRECTORY, $dbDirectory['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcFilesPeer::DIRECTORY, $dbDirectory, $comparison); + } + + /** + * Filter the query on the filepath column + * + * Example usage: + * + * $query->filterByDbFilepath('fooValue'); // WHERE filepath = 'fooValue' + * $query->filterByDbFilepath('%fooValue%'); // WHERE filepath LIKE '%fooValue%' + * + * + * @param string $dbFilepath 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 filterByDbFilepath($dbFilepath = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbFilepath)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbFilepath)) { + $dbFilepath = str_replace('*', '%', $dbFilepath); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::FILEPATH, $dbFilepath, $comparison); + } + + /** + * Filter the query on the state column + * + * Example usage: + * + * $query->filterByDbState('fooValue'); // WHERE state = 'fooValue' + * $query->filterByDbState('%fooValue%'); // WHERE state LIKE '%fooValue%' + * + * + * @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 CcFilesQuery 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(CcFilesPeer::STATE, $dbState, $comparison); + } + + /** + * Filter the query on the currentlyaccessing column + * + * Example usage: + * + * $query->filterByDbCurrentlyaccessing(1234); // WHERE currentlyaccessing = 1234 + * $query->filterByDbCurrentlyaccessing(array(12, 34)); // WHERE currentlyaccessing IN (12, 34) + * $query->filterByDbCurrentlyaccessing(array('min' => 12)); // WHERE currentlyaccessing >= 12 + * $query->filterByDbCurrentlyaccessing(array('max' => 12)); // WHERE currentlyaccessing <= 12 + * + * + * @param mixed $dbCurrentlyaccessing The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery 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(CcFilesPeer::CURRENTLYACCESSING, $dbCurrentlyaccessing['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbCurrentlyaccessing['max'])) { + $this->addUsingAlias(CcFilesPeer::CURRENTLYACCESSING, $dbCurrentlyaccessing['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcFilesPeer::CURRENTLYACCESSING, $dbCurrentlyaccessing, $comparison); + } + + /** + * Filter the query on the editedby column + * + * Example usage: + * + * $query->filterByDbEditedby(1234); // WHERE editedby = 1234 + * $query->filterByDbEditedby(array(12, 34)); // WHERE editedby IN (12, 34) + * $query->filterByDbEditedby(array('min' => 12)); // WHERE editedby >= 12 + * $query->filterByDbEditedby(array('max' => 12)); // WHERE editedby <= 12 + * + * + * @see filterByCcSubjsRelatedByDbEditedby() + * + * @param mixed $dbEditedby The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery 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(CcFilesPeer::EDITEDBY, $dbEditedby['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbEditedby['max'])) { + $this->addUsingAlias(CcFilesPeer::EDITEDBY, $dbEditedby['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcFilesPeer::EDITEDBY, $dbEditedby, $comparison); + } + + /** + * Filter the query on the mtime column + * + * Example usage: + * + * $query->filterByDbMtime('2011-03-14'); // WHERE mtime = '2011-03-14' + * $query->filterByDbMtime('now'); // WHERE mtime = '2011-03-14' + * $query->filterByDbMtime(array('max' => 'yesterday')); // WHERE mtime < '2011-03-13' + * + * + * @param mixed $dbMtime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery 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(CcFilesPeer::MTIME, $dbMtime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbMtime['max'])) { + $this->addUsingAlias(CcFilesPeer::MTIME, $dbMtime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcFilesPeer::MTIME, $dbMtime, $comparison); + } + + /** + * Filter the query on the utime column + * + * Example usage: + * + * $query->filterByDbUtime('2011-03-14'); // WHERE utime = '2011-03-14' + * $query->filterByDbUtime('now'); // WHERE utime = '2011-03-14' + * $query->filterByDbUtime(array('max' => 'yesterday')); // WHERE utime < '2011-03-13' + * + * + * @param mixed $dbUtime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbUtime($dbUtime = null, $comparison = null) + { + if (is_array($dbUtime)) { + $useMinMax = false; + if (isset($dbUtime['min'])) { + $this->addUsingAlias(CcFilesPeer::UTIME, $dbUtime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbUtime['max'])) { + $this->addUsingAlias(CcFilesPeer::UTIME, $dbUtime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcFilesPeer::UTIME, $dbUtime, $comparison); + } + + /** + * Filter the query on the lptime column + * + * Example usage: + * + * $query->filterByDbLPtime('2011-03-14'); // WHERE lptime = '2011-03-14' + * $query->filterByDbLPtime('now'); // WHERE lptime = '2011-03-14' + * $query->filterByDbLPtime(array('max' => 'yesterday')); // WHERE lptime < '2011-03-13' + * + * + * @param mixed $dbLPtime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbLPtime($dbLPtime = null, $comparison = null) + { + if (is_array($dbLPtime)) { + $useMinMax = false; + if (isset($dbLPtime['min'])) { + $this->addUsingAlias(CcFilesPeer::LPTIME, $dbLPtime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbLPtime['max'])) { + $this->addUsingAlias(CcFilesPeer::LPTIME, $dbLPtime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcFilesPeer::LPTIME, $dbLPtime, $comparison); + } + + /** + * Filter the query on the md5 column + * + * Example usage: + * + * $query->filterByDbMd5('fooValue'); // WHERE md5 = 'fooValue' + * $query->filterByDbMd5('%fooValue%'); // WHERE md5 LIKE '%fooValue%' + * + * + * @param string $dbMd5 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 filterByDbMd5($dbMd5 = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbMd5)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbMd5)) { + $dbMd5 = str_replace('*', '%', $dbMd5); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::MD5, $dbMd5, $comparison); + } + + /** + * Filter the query on the track_title column + * + * Example usage: + * + * $query->filterByDbTrackTitle('fooValue'); // WHERE track_title = 'fooValue' + * $query->filterByDbTrackTitle('%fooValue%'); // WHERE track_title LIKE '%fooValue%' + * + * + * @param string $dbTrackTitle 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 filterByDbTrackTitle($dbTrackTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbTrackTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbTrackTitle)) { + $dbTrackTitle = str_replace('*', '%', $dbTrackTitle); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::TRACK_TITLE, $dbTrackTitle, $comparison); + } + + /** + * Filter the query on the artist_name column + * + * Example usage: + * + * $query->filterByDbArtistName('fooValue'); // WHERE artist_name = 'fooValue' + * $query->filterByDbArtistName('%fooValue%'); // WHERE artist_name LIKE '%fooValue%' + * + * + * @param string $dbArtistName 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 filterByDbArtistName($dbArtistName = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbArtistName)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbArtistName)) { + $dbArtistName = str_replace('*', '%', $dbArtistName); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::ARTIST_NAME, $dbArtistName, $comparison); + } + + /** + * Filter the query on the bit_rate column + * + * Example usage: + * + * $query->filterByDbBitRate(1234); // WHERE bit_rate = 1234 + * $query->filterByDbBitRate(array(12, 34)); // WHERE bit_rate IN (12, 34) + * $query->filterByDbBitRate(array('min' => 12)); // WHERE bit_rate >= 12 + * $query->filterByDbBitRate(array('max' => 12)); // WHERE bit_rate <= 12 + * + * + * @param mixed $dbBitRate The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbBitRate($dbBitRate = null, $comparison = null) + { + if (is_array($dbBitRate)) { + $useMinMax = false; + if (isset($dbBitRate['min'])) { + $this->addUsingAlias(CcFilesPeer::BIT_RATE, $dbBitRate['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbBitRate['max'])) { + $this->addUsingAlias(CcFilesPeer::BIT_RATE, $dbBitRate['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcFilesPeer::BIT_RATE, $dbBitRate, $comparison); + } + + /** + * Filter the query on the sample_rate column + * + * Example usage: + * + * $query->filterByDbSampleRate(1234); // WHERE sample_rate = 1234 + * $query->filterByDbSampleRate(array(12, 34)); // WHERE sample_rate IN (12, 34) + * $query->filterByDbSampleRate(array('min' => 12)); // WHERE sample_rate >= 12 + * $query->filterByDbSampleRate(array('max' => 12)); // WHERE sample_rate <= 12 + * + * + * @param mixed $dbSampleRate The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbSampleRate($dbSampleRate = null, $comparison = null) + { + if (is_array($dbSampleRate)) { + $useMinMax = false; + if (isset($dbSampleRate['min'])) { + $this->addUsingAlias(CcFilesPeer::SAMPLE_RATE, $dbSampleRate['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbSampleRate['max'])) { + $this->addUsingAlias(CcFilesPeer::SAMPLE_RATE, $dbSampleRate['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcFilesPeer::SAMPLE_RATE, $dbSampleRate, $comparison); + } + + /** + * Filter the query on the format column + * + * Example usage: + * + * $query->filterByDbFormat('fooValue'); // WHERE format = 'fooValue' + * $query->filterByDbFormat('%fooValue%'); // WHERE format LIKE '%fooValue%' + * + * + * @param string $dbFormat 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 filterByDbFormat($dbFormat = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbFormat)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbFormat)) { + $dbFormat = str_replace('*', '%', $dbFormat); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::FORMAT, $dbFormat, $comparison); + } + + /** + * Filter the query on the length column + * + * Example usage: + * + * $query->filterByDbLength('fooValue'); // WHERE length = 'fooValue' + * $query->filterByDbLength('%fooValue%'); // WHERE length LIKE '%fooValue%' + * + * + * @param string $dbLength 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 filterByDbLength($dbLength = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLength)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLength)) { + $dbLength = str_replace('*', '%', $dbLength); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::LENGTH, $dbLength, $comparison); + } + + /** + * Filter the query on the album_title column + * + * Example usage: + * + * $query->filterByDbAlbumTitle('fooValue'); // WHERE album_title = 'fooValue' + * $query->filterByDbAlbumTitle('%fooValue%'); // WHERE album_title LIKE '%fooValue%' + * + * + * @param string $dbAlbumTitle 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 filterByDbAlbumTitle($dbAlbumTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbAlbumTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbAlbumTitle)) { + $dbAlbumTitle = str_replace('*', '%', $dbAlbumTitle); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::ALBUM_TITLE, $dbAlbumTitle, $comparison); + } + + /** + * Filter the query on the genre column + * + * Example usage: + * + * $query->filterByDbGenre('fooValue'); // WHERE genre = 'fooValue' + * $query->filterByDbGenre('%fooValue%'); // WHERE genre LIKE '%fooValue%' + * + * + * @param string $dbGenre 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 filterByDbGenre($dbGenre = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbGenre)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbGenre)) { + $dbGenre = str_replace('*', '%', $dbGenre); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::GENRE, $dbGenre, $comparison); + } + + /** + * Filter the query on the comments column + * + * Example usage: + * + * $query->filterByDbComments('fooValue'); // WHERE comments = 'fooValue' + * $query->filterByDbComments('%fooValue%'); // WHERE comments LIKE '%fooValue%' + * + * + * @param string $dbComments 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 filterByDbComments($dbComments = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbComments)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbComments)) { + $dbComments = str_replace('*', '%', $dbComments); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::COMMENTS, $dbComments, $comparison); + } + + /** + * Filter the query on the year column + * + * Example usage: + * + * $query->filterByDbYear('fooValue'); // WHERE year = 'fooValue' + * $query->filterByDbYear('%fooValue%'); // WHERE year LIKE '%fooValue%' + * + * + * @param string $dbYear 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 filterByDbYear($dbYear = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbYear)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbYear)) { + $dbYear = str_replace('*', '%', $dbYear); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::YEAR, $dbYear, $comparison); + } + + /** + * Filter the query on the track_number column + * + * Example usage: + * + * $query->filterByDbTrackNumber(1234); // WHERE track_number = 1234 + * $query->filterByDbTrackNumber(array(12, 34)); // WHERE track_number IN (12, 34) + * $query->filterByDbTrackNumber(array('min' => 12)); // WHERE track_number >= 12 + * $query->filterByDbTrackNumber(array('max' => 12)); // WHERE track_number <= 12 + * + * + * @param mixed $dbTrackNumber The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbTrackNumber($dbTrackNumber = null, $comparison = null) + { + if (is_array($dbTrackNumber)) { + $useMinMax = false; + if (isset($dbTrackNumber['min'])) { + $this->addUsingAlias(CcFilesPeer::TRACK_NUMBER, $dbTrackNumber['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbTrackNumber['max'])) { + $this->addUsingAlias(CcFilesPeer::TRACK_NUMBER, $dbTrackNumber['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcFilesPeer::TRACK_NUMBER, $dbTrackNumber, $comparison); + } + + /** + * Filter the query on the channels column + * + * Example usage: + * + * $query->filterByDbChannels(1234); // WHERE channels = 1234 + * $query->filterByDbChannels(array(12, 34)); // WHERE channels IN (12, 34) + * $query->filterByDbChannels(array('min' => 12)); // WHERE channels >= 12 + * $query->filterByDbChannels(array('max' => 12)); // WHERE channels <= 12 + * + * + * @param mixed $dbChannels The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbChannels($dbChannels = null, $comparison = null) + { + if (is_array($dbChannels)) { + $useMinMax = false; + if (isset($dbChannels['min'])) { + $this->addUsingAlias(CcFilesPeer::CHANNELS, $dbChannels['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbChannels['max'])) { + $this->addUsingAlias(CcFilesPeer::CHANNELS, $dbChannels['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcFilesPeer::CHANNELS, $dbChannels, $comparison); + } + + /** + * Filter the query on the url column + * + * Example usage: + * + * $query->filterByDbUrl('fooValue'); // WHERE url = 'fooValue' + * $query->filterByDbUrl('%fooValue%'); // WHERE url LIKE '%fooValue%' + * + * + * @param string $dbUrl 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 filterByDbUrl($dbUrl = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbUrl)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbUrl)) { + $dbUrl = str_replace('*', '%', $dbUrl); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::URL, $dbUrl, $comparison); + } + + /** + * Filter the query on the bpm column + * + * Example usage: + * + * $query->filterByDbBpm(1234); // WHERE bpm = 1234 + * $query->filterByDbBpm(array(12, 34)); // WHERE bpm IN (12, 34) + * $query->filterByDbBpm(array('min' => 12)); // WHERE bpm >= 12 + * $query->filterByDbBpm(array('max' => 12)); // WHERE bpm <= 12 + * + * + * @param mixed $dbBpm The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbBpm($dbBpm = null, $comparison = null) + { + if (is_array($dbBpm)) { + $useMinMax = false; + if (isset($dbBpm['min'])) { + $this->addUsingAlias(CcFilesPeer::BPM, $dbBpm['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbBpm['max'])) { + $this->addUsingAlias(CcFilesPeer::BPM, $dbBpm['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcFilesPeer::BPM, $dbBpm, $comparison); + } + + /** + * Filter the query on the rating column + * + * Example usage: + * + * $query->filterByDbRating('fooValue'); // WHERE rating = 'fooValue' + * $query->filterByDbRating('%fooValue%'); // WHERE rating LIKE '%fooValue%' + * + * + * @param string $dbRating 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 filterByDbRating($dbRating = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbRating)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbRating)) { + $dbRating = str_replace('*', '%', $dbRating); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::RATING, $dbRating, $comparison); + } + + /** + * Filter the query on the encoded_by column + * + * Example usage: + * + * $query->filterByDbEncodedBy('fooValue'); // WHERE encoded_by = 'fooValue' + * $query->filterByDbEncodedBy('%fooValue%'); // WHERE encoded_by LIKE '%fooValue%' + * + * + * @param string $dbEncodedBy 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 filterByDbEncodedBy($dbEncodedBy = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbEncodedBy)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbEncodedBy)) { + $dbEncodedBy = str_replace('*', '%', $dbEncodedBy); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::ENCODED_BY, $dbEncodedBy, $comparison); + } + + /** + * Filter the query on the disc_number column + * + * Example usage: + * + * $query->filterByDbDiscNumber('fooValue'); // WHERE disc_number = 'fooValue' + * $query->filterByDbDiscNumber('%fooValue%'); // WHERE disc_number LIKE '%fooValue%' + * + * + * @param string $dbDiscNumber 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 filterByDbDiscNumber($dbDiscNumber = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbDiscNumber)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbDiscNumber)) { + $dbDiscNumber = str_replace('*', '%', $dbDiscNumber); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::DISC_NUMBER, $dbDiscNumber, $comparison); + } + + /** + * Filter the query on the mood column + * + * Example usage: + * + * $query->filterByDbMood('fooValue'); // WHERE mood = 'fooValue' + * $query->filterByDbMood('%fooValue%'); // WHERE mood LIKE '%fooValue%' + * + * + * @param string $dbMood 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 filterByDbMood($dbMood = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbMood)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbMood)) { + $dbMood = str_replace('*', '%', $dbMood); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::MOOD, $dbMood, $comparison); + } + + /** + * Filter the query on the label column + * + * Example usage: + * + * $query->filterByDbLabel('fooValue'); // WHERE label = 'fooValue' + * $query->filterByDbLabel('%fooValue%'); // WHERE label LIKE '%fooValue%' + * + * + * @param string $dbLabel 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 filterByDbLabel($dbLabel = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLabel)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLabel)) { + $dbLabel = str_replace('*', '%', $dbLabel); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::LABEL, $dbLabel, $comparison); + } + + /** + * Filter the query on the composer column + * + * Example usage: + * + * $query->filterByDbComposer('fooValue'); // WHERE composer = 'fooValue' + * $query->filterByDbComposer('%fooValue%'); // WHERE composer LIKE '%fooValue%' + * + * + * @param string $dbComposer 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 filterByDbComposer($dbComposer = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbComposer)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbComposer)) { + $dbComposer = str_replace('*', '%', $dbComposer); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::COMPOSER, $dbComposer, $comparison); + } + + /** + * Filter the query on the encoder column + * + * Example usage: + * + * $query->filterByDbEncoder('fooValue'); // WHERE encoder = 'fooValue' + * $query->filterByDbEncoder('%fooValue%'); // WHERE encoder LIKE '%fooValue%' + * + * + * @param string $dbEncoder 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 filterByDbEncoder($dbEncoder = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbEncoder)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbEncoder)) { + $dbEncoder = str_replace('*', '%', $dbEncoder); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::ENCODER, $dbEncoder, $comparison); + } + + /** + * Filter the query on the checksum column + * + * Example usage: + * + * $query->filterByDbChecksum('fooValue'); // WHERE checksum = 'fooValue' + * $query->filterByDbChecksum('%fooValue%'); // WHERE checksum LIKE '%fooValue%' + * + * + * @param string $dbChecksum 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 filterByDbChecksum($dbChecksum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbChecksum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbChecksum)) { + $dbChecksum = str_replace('*', '%', $dbChecksum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::CHECKSUM, $dbChecksum, $comparison); + } + + /** + * Filter the query on the lyrics column + * + * Example usage: + * + * $query->filterByDbLyrics('fooValue'); // WHERE lyrics = 'fooValue' + * $query->filterByDbLyrics('%fooValue%'); // WHERE lyrics LIKE '%fooValue%' + * + * + * @param string $dbLyrics 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 filterByDbLyrics($dbLyrics = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLyrics)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLyrics)) { + $dbLyrics = str_replace('*', '%', $dbLyrics); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::LYRICS, $dbLyrics, $comparison); + } + + /** + * Filter the query on the orchestra column + * + * Example usage: + * + * $query->filterByDbOrchestra('fooValue'); // WHERE orchestra = 'fooValue' + * $query->filterByDbOrchestra('%fooValue%'); // WHERE orchestra LIKE '%fooValue%' + * + * + * @param string $dbOrchestra 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 filterByDbOrchestra($dbOrchestra = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbOrchestra)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbOrchestra)) { + $dbOrchestra = str_replace('*', '%', $dbOrchestra); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::ORCHESTRA, $dbOrchestra, $comparison); + } + + /** + * Filter the query on the conductor column + * + * Example usage: + * + * $query->filterByDbConductor('fooValue'); // WHERE conductor = 'fooValue' + * $query->filterByDbConductor('%fooValue%'); // WHERE conductor LIKE '%fooValue%' + * + * + * @param string $dbConductor 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 filterByDbConductor($dbConductor = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbConductor)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbConductor)) { + $dbConductor = str_replace('*', '%', $dbConductor); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::CONDUCTOR, $dbConductor, $comparison); + } + + /** + * Filter the query on the lyricist column + * + * Example usage: + * + * $query->filterByDbLyricist('fooValue'); // WHERE lyricist = 'fooValue' + * $query->filterByDbLyricist('%fooValue%'); // WHERE lyricist LIKE '%fooValue%' + * + * + * @param string $dbLyricist 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 filterByDbLyricist($dbLyricist = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLyricist)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLyricist)) { + $dbLyricist = str_replace('*', '%', $dbLyricist); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::LYRICIST, $dbLyricist, $comparison); + } + + /** + * Filter the query on the original_lyricist column + * + * Example usage: + * + * $query->filterByDbOriginalLyricist('fooValue'); // WHERE original_lyricist = 'fooValue' + * $query->filterByDbOriginalLyricist('%fooValue%'); // WHERE original_lyricist LIKE '%fooValue%' + * + * + * @param string $dbOriginalLyricist 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 filterByDbOriginalLyricist($dbOriginalLyricist = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbOriginalLyricist)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbOriginalLyricist)) { + $dbOriginalLyricist = str_replace('*', '%', $dbOriginalLyricist); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::ORIGINAL_LYRICIST, $dbOriginalLyricist, $comparison); + } + + /** + * Filter the query on the radio_station_name column + * + * Example usage: + * + * $query->filterByDbRadioStationName('fooValue'); // WHERE radio_station_name = 'fooValue' + * $query->filterByDbRadioStationName('%fooValue%'); // WHERE radio_station_name LIKE '%fooValue%' + * + * + * @param string $dbRadioStationName 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 filterByDbRadioStationName($dbRadioStationName = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbRadioStationName)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbRadioStationName)) { + $dbRadioStationName = str_replace('*', '%', $dbRadioStationName); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::RADIO_STATION_NAME, $dbRadioStationName, $comparison); + } + + /** + * Filter the query on the info_url column + * + * Example usage: + * + * $query->filterByDbInfoUrl('fooValue'); // WHERE info_url = 'fooValue' + * $query->filterByDbInfoUrl('%fooValue%'); // WHERE info_url LIKE '%fooValue%' + * + * + * @param string $dbInfoUrl 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 filterByDbInfoUrl($dbInfoUrl = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbInfoUrl)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbInfoUrl)) { + $dbInfoUrl = str_replace('*', '%', $dbInfoUrl); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::INFO_URL, $dbInfoUrl, $comparison); + } + + /** + * Filter the query on the artist_url column + * + * Example usage: + * + * $query->filterByDbArtistUrl('fooValue'); // WHERE artist_url = 'fooValue' + * $query->filterByDbArtistUrl('%fooValue%'); // WHERE artist_url LIKE '%fooValue%' + * + * + * @param string $dbArtistUrl 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 filterByDbArtistUrl($dbArtistUrl = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbArtistUrl)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbArtistUrl)) { + $dbArtistUrl = str_replace('*', '%', $dbArtistUrl); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::ARTIST_URL, $dbArtistUrl, $comparison); + } + + /** + * Filter the query on the audio_source_url column + * + * Example usage: + * + * $query->filterByDbAudioSourceUrl('fooValue'); // WHERE audio_source_url = 'fooValue' + * $query->filterByDbAudioSourceUrl('%fooValue%'); // WHERE audio_source_url LIKE '%fooValue%' + * + * + * @param string $dbAudioSourceUrl 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 filterByDbAudioSourceUrl($dbAudioSourceUrl = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbAudioSourceUrl)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbAudioSourceUrl)) { + $dbAudioSourceUrl = str_replace('*', '%', $dbAudioSourceUrl); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::AUDIO_SOURCE_URL, $dbAudioSourceUrl, $comparison); + } + + /** + * Filter the query on the radio_station_url column + * + * Example usage: + * + * $query->filterByDbRadioStationUrl('fooValue'); // WHERE radio_station_url = 'fooValue' + * $query->filterByDbRadioStationUrl('%fooValue%'); // WHERE radio_station_url LIKE '%fooValue%' + * + * + * @param string $dbRadioStationUrl 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 filterByDbRadioStationUrl($dbRadioStationUrl = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbRadioStationUrl)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbRadioStationUrl)) { + $dbRadioStationUrl = str_replace('*', '%', $dbRadioStationUrl); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::RADIO_STATION_URL, $dbRadioStationUrl, $comparison); + } + + /** + * Filter the query on the buy_this_url column + * + * Example usage: + * + * $query->filterByDbBuyThisUrl('fooValue'); // WHERE buy_this_url = 'fooValue' + * $query->filterByDbBuyThisUrl('%fooValue%'); // WHERE buy_this_url LIKE '%fooValue%' + * + * + * @param string $dbBuyThisUrl 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 filterByDbBuyThisUrl($dbBuyThisUrl = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbBuyThisUrl)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbBuyThisUrl)) { + $dbBuyThisUrl = str_replace('*', '%', $dbBuyThisUrl); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::BUY_THIS_URL, $dbBuyThisUrl, $comparison); + } + + /** + * Filter the query on the isrc_number column + * + * Example usage: + * + * $query->filterByDbIsrcNumber('fooValue'); // WHERE isrc_number = 'fooValue' + * $query->filterByDbIsrcNumber('%fooValue%'); // WHERE isrc_number LIKE '%fooValue%' + * + * + * @param string $dbIsrcNumber 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 filterByDbIsrcNumber($dbIsrcNumber = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbIsrcNumber)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbIsrcNumber)) { + $dbIsrcNumber = str_replace('*', '%', $dbIsrcNumber); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::ISRC_NUMBER, $dbIsrcNumber, $comparison); + } + + /** + * Filter the query on the catalog_number column + * + * Example usage: + * + * $query->filterByDbCatalogNumber('fooValue'); // WHERE catalog_number = 'fooValue' + * $query->filterByDbCatalogNumber('%fooValue%'); // WHERE catalog_number LIKE '%fooValue%' + * + * + * @param string $dbCatalogNumber 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 filterByDbCatalogNumber($dbCatalogNumber = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbCatalogNumber)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbCatalogNumber)) { + $dbCatalogNumber = str_replace('*', '%', $dbCatalogNumber); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::CATALOG_NUMBER, $dbCatalogNumber, $comparison); + } + + /** + * Filter the query on the original_artist column + * + * Example usage: + * + * $query->filterByDbOriginalArtist('fooValue'); // WHERE original_artist = 'fooValue' + * $query->filterByDbOriginalArtist('%fooValue%'); // WHERE original_artist LIKE '%fooValue%' + * + * + * @param string $dbOriginalArtist 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 filterByDbOriginalArtist($dbOriginalArtist = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbOriginalArtist)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbOriginalArtist)) { + $dbOriginalArtist = str_replace('*', '%', $dbOriginalArtist); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::ORIGINAL_ARTIST, $dbOriginalArtist, $comparison); + } + + /** + * Filter the query on the copyright column + * + * Example usage: + * + * $query->filterByDbCopyright('fooValue'); // WHERE copyright = 'fooValue' + * $query->filterByDbCopyright('%fooValue%'); // WHERE copyright LIKE '%fooValue%' + * + * + * @param string $dbCopyright 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 filterByDbCopyright($dbCopyright = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbCopyright)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbCopyright)) { + $dbCopyright = str_replace('*', '%', $dbCopyright); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::COPYRIGHT, $dbCopyright, $comparison); + } + + /** + * Filter the query on the report_datetime column + * + * Example usage: + * + * $query->filterByDbReportDatetime('fooValue'); // WHERE report_datetime = 'fooValue' + * $query->filterByDbReportDatetime('%fooValue%'); // WHERE report_datetime LIKE '%fooValue%' + * + * + * @param string $dbReportDatetime 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 filterByDbReportDatetime($dbReportDatetime = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbReportDatetime)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbReportDatetime)) { + $dbReportDatetime = str_replace('*', '%', $dbReportDatetime); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::REPORT_DATETIME, $dbReportDatetime, $comparison); + } + + /** + * Filter the query on the report_location column + * + * Example usage: + * + * $query->filterByDbReportLocation('fooValue'); // WHERE report_location = 'fooValue' + * $query->filterByDbReportLocation('%fooValue%'); // WHERE report_location LIKE '%fooValue%' + * + * + * @param string $dbReportLocation 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 filterByDbReportLocation($dbReportLocation = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbReportLocation)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbReportLocation)) { + $dbReportLocation = str_replace('*', '%', $dbReportLocation); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::REPORT_LOCATION, $dbReportLocation, $comparison); + } + + /** + * Filter the query on the report_organization column + * + * Example usage: + * + * $query->filterByDbReportOrganization('fooValue'); // WHERE report_organization = 'fooValue' + * $query->filterByDbReportOrganization('%fooValue%'); // WHERE report_organization LIKE '%fooValue%' + * + * + * @param string $dbReportOrganization 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 filterByDbReportOrganization($dbReportOrganization = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbReportOrganization)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbReportOrganization)) { + $dbReportOrganization = str_replace('*', '%', $dbReportOrganization); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::REPORT_ORGANIZATION, $dbReportOrganization, $comparison); + } + + /** + * Filter the query on the subject column + * + * Example usage: + * + * $query->filterByDbSubject('fooValue'); // WHERE subject = 'fooValue' + * $query->filterByDbSubject('%fooValue%'); // WHERE subject LIKE '%fooValue%' + * + * + * @param string $dbSubject 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 filterByDbSubject($dbSubject = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbSubject)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbSubject)) { + $dbSubject = str_replace('*', '%', $dbSubject); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::SUBJECT, $dbSubject, $comparison); + } + + /** + * Filter the query on the contributor column + * + * Example usage: + * + * $query->filterByDbContributor('fooValue'); // WHERE contributor = 'fooValue' + * $query->filterByDbContributor('%fooValue%'); // WHERE contributor LIKE '%fooValue%' + * + * + * @param string $dbContributor 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 filterByDbContributor($dbContributor = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbContributor)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbContributor)) { + $dbContributor = str_replace('*', '%', $dbContributor); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::CONTRIBUTOR, $dbContributor, $comparison); + } + + /** + * Filter the query on the language column + * + * Example usage: + * + * $query->filterByDbLanguage('fooValue'); // WHERE language = 'fooValue' + * $query->filterByDbLanguage('%fooValue%'); // WHERE language LIKE '%fooValue%' + * + * + * @param string $dbLanguage 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 filterByDbLanguage($dbLanguage = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLanguage)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLanguage)) { + $dbLanguage = str_replace('*', '%', $dbLanguage); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::LANGUAGE, $dbLanguage, $comparison); + } + + /** + * Filter the query on the file_exists column + * + * Example usage: + * + * $query->filterByDbFileExists(true); // WHERE file_exists = true + * $query->filterByDbFileExists('yes'); // WHERE file_exists = true + * + * + * @param boolean|string $dbFileExists The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbFileExists($dbFileExists = null, $comparison = null) + { + if (is_string($dbFileExists)) { + $dbFileExists = in_array(strtolower($dbFileExists), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CcFilesPeer::FILE_EXISTS, $dbFileExists, $comparison); + } + + /** + * Filter the query on the soundcloud_id column + * + * Example usage: + * + * $query->filterByDbSoundcloudId(1234); // WHERE soundcloud_id = 1234 + * $query->filterByDbSoundcloudId(array(12, 34)); // WHERE soundcloud_id IN (12, 34) + * $query->filterByDbSoundcloudId(array('min' => 12)); // WHERE soundcloud_id >= 12 + * $query->filterByDbSoundcloudId(array('max' => 12)); // WHERE soundcloud_id <= 12 + * + * + * @param mixed $dbSoundcloudId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbSoundcloudId($dbSoundcloudId = null, $comparison = null) + { + if (is_array($dbSoundcloudId)) { + $useMinMax = false; + if (isset($dbSoundcloudId['min'])) { + $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ID, $dbSoundcloudId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbSoundcloudId['max'])) { + $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ID, $dbSoundcloudId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ID, $dbSoundcloudId, $comparison); + } + + /** + * Filter the query on the soundcloud_error_code column + * + * Example usage: + * + * $query->filterByDbSoundcloudErrorCode(1234); // WHERE soundcloud_error_code = 1234 + * $query->filterByDbSoundcloudErrorCode(array(12, 34)); // WHERE soundcloud_error_code IN (12, 34) + * $query->filterByDbSoundcloudErrorCode(array('min' => 12)); // WHERE soundcloud_error_code >= 12 + * $query->filterByDbSoundcloudErrorCode(array('max' => 12)); // WHERE soundcloud_error_code <= 12 + * + * + * @param mixed $dbSoundcloudErrorCode The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbSoundcloudErrorCode($dbSoundcloudErrorCode = null, $comparison = null) + { + if (is_array($dbSoundcloudErrorCode)) { + $useMinMax = false; + if (isset($dbSoundcloudErrorCode['min'])) { + $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ERROR_CODE, $dbSoundcloudErrorCode['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbSoundcloudErrorCode['max'])) { + $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ERROR_CODE, $dbSoundcloudErrorCode['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ERROR_CODE, $dbSoundcloudErrorCode, $comparison); + } + + /** + * Filter the query on the soundcloud_error_msg column + * + * Example usage: + * + * $query->filterByDbSoundcloudErrorMsg('fooValue'); // WHERE soundcloud_error_msg = 'fooValue' + * $query->filterByDbSoundcloudErrorMsg('%fooValue%'); // WHERE soundcloud_error_msg LIKE '%fooValue%' + * + * + * @param string $dbSoundcloudErrorMsg 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 filterByDbSoundcloudErrorMsg($dbSoundcloudErrorMsg = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbSoundcloudErrorMsg)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbSoundcloudErrorMsg)) { + $dbSoundcloudErrorMsg = str_replace('*', '%', $dbSoundcloudErrorMsg); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_ERROR_MSG, $dbSoundcloudErrorMsg, $comparison); + } + + /** + * Filter the query on the soundcloud_link_to_file column + * + * Example usage: + * + * $query->filterByDbSoundcloudLinkToFile('fooValue'); // WHERE soundcloud_link_to_file = 'fooValue' + * $query->filterByDbSoundcloudLinkToFile('%fooValue%'); // WHERE soundcloud_link_to_file LIKE '%fooValue%' + * + * + * @param string $dbSoundcloudLinkToFile 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 filterByDbSoundcloudLinkToFile($dbSoundcloudLinkToFile = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbSoundcloudLinkToFile)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbSoundcloudLinkToFile)) { + $dbSoundcloudLinkToFile = str_replace('*', '%', $dbSoundcloudLinkToFile); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_LINK_TO_FILE, $dbSoundcloudLinkToFile, $comparison); + } + + /** + * Filter the query on the soundcloud_upload_time column + * + * Example usage: + * + * $query->filterByDbSoundCloundUploadTime('2011-03-14'); // WHERE soundcloud_upload_time = '2011-03-14' + * $query->filterByDbSoundCloundUploadTime('now'); // WHERE soundcloud_upload_time = '2011-03-14' + * $query->filterByDbSoundCloundUploadTime(array('max' => 'yesterday')); // WHERE soundcloud_upload_time < '2011-03-13' + * + * + * @param mixed $dbSoundCloundUploadTime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbSoundCloundUploadTime($dbSoundCloundUploadTime = null, $comparison = null) + { + if (is_array($dbSoundCloundUploadTime)) { + $useMinMax = false; + if (isset($dbSoundCloundUploadTime['min'])) { + $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_UPLOAD_TIME, $dbSoundCloundUploadTime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbSoundCloundUploadTime['max'])) { + $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_UPLOAD_TIME, $dbSoundCloundUploadTime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcFilesPeer::SOUNDCLOUD_UPLOAD_TIME, $dbSoundCloundUploadTime, $comparison); + } + + /** + * Filter the query on the replay_gain column + * + * Example usage: + * + * $query->filterByDbReplayGain(1234); // WHERE replay_gain = 1234 + * $query->filterByDbReplayGain(array(12, 34)); // WHERE replay_gain IN (12, 34) + * $query->filterByDbReplayGain(array('min' => 12)); // WHERE replay_gain >= 12 + * $query->filterByDbReplayGain(array('max' => 12)); // WHERE replay_gain <= 12 + * + * + * @param mixed $dbReplayGain The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbReplayGain($dbReplayGain = null, $comparison = null) + { + if (is_array($dbReplayGain)) { + $useMinMax = false; + if (isset($dbReplayGain['min'])) { + $this->addUsingAlias(CcFilesPeer::REPLAY_GAIN, $dbReplayGain['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbReplayGain['max'])) { + $this->addUsingAlias(CcFilesPeer::REPLAY_GAIN, $dbReplayGain['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcFilesPeer::REPLAY_GAIN, $dbReplayGain, $comparison); + } + + /** + * Filter the query on the owner_id column + * + * Example usage: + * + * $query->filterByDbOwnerId(1234); // WHERE owner_id = 1234 + * $query->filterByDbOwnerId(array(12, 34)); // WHERE owner_id IN (12, 34) + * $query->filterByDbOwnerId(array('min' => 12)); // WHERE owner_id >= 12 + * $query->filterByDbOwnerId(array('max' => 12)); // WHERE owner_id <= 12 + * + * + * @see filterByFkOwner() + * + * @param mixed $dbOwnerId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbOwnerId($dbOwnerId = null, $comparison = null) + { + if (is_array($dbOwnerId)) { + $useMinMax = false; + if (isset($dbOwnerId['min'])) { + $this->addUsingAlias(CcFilesPeer::OWNER_ID, $dbOwnerId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbOwnerId['max'])) { + $this->addUsingAlias(CcFilesPeer::OWNER_ID, $dbOwnerId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcFilesPeer::OWNER_ID, $dbOwnerId, $comparison); + } + + /** + * Filter the query on the cuein column + * + * Example usage: + * + * $query->filterByDbCuein('fooValue'); // WHERE cuein = 'fooValue' + * $query->filterByDbCuein('%fooValue%'); // WHERE cuein LIKE '%fooValue%' + * + * + * @param string $dbCuein 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 filterByDbCuein($dbCuein = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbCuein)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbCuein)) { + $dbCuein = str_replace('*', '%', $dbCuein); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::CUEIN, $dbCuein, $comparison); + } + + /** + * Filter the query on the cueout column + * + * Example usage: + * + * $query->filterByDbCueout('fooValue'); // WHERE cueout = 'fooValue' + * $query->filterByDbCueout('%fooValue%'); // WHERE cueout LIKE '%fooValue%' + * + * + * @param string $dbCueout 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 filterByDbCueout($dbCueout = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbCueout)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbCueout)) { + $dbCueout = str_replace('*', '%', $dbCueout); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcFilesPeer::CUEOUT, $dbCueout, $comparison); + } + + /** + * Filter the query on the silan_check column + * + * Example usage: + * + * $query->filterByDbSilanCheck(true); // WHERE silan_check = true + * $query->filterByDbSilanCheck('yes'); // WHERE silan_check = true + * + * + * @param boolean|string $dbSilanCheck The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbSilanCheck($dbSilanCheck = null, $comparison = null) + { + if (is_string($dbSilanCheck)) { + $dbSilanCheck = in_array(strtolower($dbSilanCheck), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CcFilesPeer::SILAN_CHECK, $dbSilanCheck, $comparison); + } + + /** + * Filter the query on the hidden column + * + * Example usage: + * + * $query->filterByDbHidden(true); // WHERE hidden = true + * $query->filterByDbHidden('yes'); // WHERE hidden = true + * + * + * @param boolean|string $dbHidden The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbHidden($dbHidden = null, $comparison = null) + { + if (is_string($dbHidden)) { + $dbHidden = in_array(strtolower($dbHidden), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CcFilesPeer::HIDDEN, $dbHidden, $comparison); + } + + /** + * Filter the query on the is_scheduled column + * + * Example usage: + * + * $query->filterByDbIsScheduled(true); // WHERE is_scheduled = true + * $query->filterByDbIsScheduled('yes'); // WHERE is_scheduled = true + * + * + * @param boolean|string $dbIsScheduled The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbIsScheduled($dbIsScheduled = null, $comparison = null) + { + if (is_string($dbIsScheduled)) { + $dbIsScheduled = in_array(strtolower($dbIsScheduled), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CcFilesPeer::IS_SCHEDULED, $dbIsScheduled, $comparison); + } + + /** + * Filter the query on the is_playlist column + * + * Example usage: + * + * $query->filterByDbIsPlaylist(true); // WHERE is_playlist = true + * $query->filterByDbIsPlaylist('yes'); // WHERE is_playlist = true + * + * + * @param boolean|string $dbIsPlaylist The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcFilesQuery The current query, for fluid interface + */ + public function filterByDbIsPlaylist($dbIsPlaylist = null, $comparison = null) + { + if (is_string($dbIsPlaylist)) { + $dbIsPlaylist = in_array(strtolower($dbIsPlaylist), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CcFilesPeer::IS_PLAYLIST, $dbIsPlaylist, $comparison); + } + + /** + * Filter the query by a related CcSubjs object + * + * @param CcSubjs|PropelObjectCollection $ccSubjs The related object(s) 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByFkOwner($ccSubjs, $comparison = null) + { + if ($ccSubjs instanceof CcSubjs) { + return $this + ->addUsingAlias(CcFilesPeer::OWNER_ID, $ccSubjs->getDbId(), $comparison); + } elseif ($ccSubjs instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcFilesPeer::OWNER_ID, $ccSubjs->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByFkOwner() only accepts arguments of type CcSubjs or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the FkOwner 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 joinFkOwner($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('FkOwner'); + + // 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, 'FkOwner'); + } + + return $this; + } + + /** + * Use the FkOwner 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 \Airtime\CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useFkOwnerQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinFkOwner($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'FkOwner', '\Airtime\CcSubjsQuery'); + } + + /** + * Filter the query by a related CcSubjs object + * + * @param CcSubjs|PropelObjectCollection $ccSubjs The related object(s) 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcSubjsRelatedByDbEditedby($ccSubjs, $comparison = null) + { + if ($ccSubjs instanceof CcSubjs) { + return $this + ->addUsingAlias(CcFilesPeer::EDITEDBY, $ccSubjs->getDbId(), $comparison); + } elseif ($ccSubjs instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcFilesPeer::EDITEDBY, $ccSubjs->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcSubjsRelatedByDbEditedby() only accepts arguments of type CcSubjs or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcSubjsRelatedByDbEditedby 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 joinCcSubjsRelatedByDbEditedby($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcSubjsRelatedByDbEditedby'); + + // 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, 'CcSubjsRelatedByDbEditedby'); + } + + return $this; + } + + /** + * Use the CcSubjsRelatedByDbEditedby 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 \Airtime\CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsRelatedByDbEditedbyQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSubjsRelatedByDbEditedby($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjsRelatedByDbEditedby', '\Airtime\CcSubjsQuery'); + } + + /** + * Filter the query by a related CcMusicDirs object + * + * @param CcMusicDirs|PropelObjectCollection $ccMusicDirs The related object(s) 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcMusicDirs($ccMusicDirs, $comparison = null) + { + if ($ccMusicDirs instanceof CcMusicDirs) { + return $this + ->addUsingAlias(CcFilesPeer::DIRECTORY, $ccMusicDirs->getId(), $comparison); + } elseif ($ccMusicDirs instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcFilesPeer::DIRECTORY, $ccMusicDirs->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByCcMusicDirs() only accepts arguments of type CcMusicDirs or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcMusicDirs 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 joinCcMusicDirs($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcMusicDirs'); + + // 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, 'CcMusicDirs'); + } + + return $this; + } + + /** + * Use the CcMusicDirs relation CcMusicDirs 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 \Airtime\CcMusicDirsQuery A secondary query class using the current class as primary query + */ + public function useCcMusicDirsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcMusicDirs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcMusicDirs', '\Airtime\CcMusicDirsQuery'); + } + + /** + * Filter the query by a related CcShowInstances object + * + * @param CcShowInstances|PropelObjectCollection $ccShowInstances 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcShowInstances($ccShowInstances, $comparison = null) + { + if ($ccShowInstances instanceof CcShowInstances) { + return $this + ->addUsingAlias(CcFilesPeer::ID, $ccShowInstances->getDbRecordedFile(), $comparison); + } elseif ($ccShowInstances instanceof PropelObjectCollection) { + return $this + ->useCcShowInstancesQuery() + ->filterByPrimaryKeys($ccShowInstances->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcShowInstances() only accepts arguments of type CcShowInstances or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcShowInstances 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 joinCcShowInstances($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShowInstances'); + + // 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, 'CcShowInstances'); + } + + return $this; + } + + /** + * Use the CcShowInstances relation CcShowInstances 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 \Airtime\CcShowInstancesQuery A secondary query class using the current class as primary query + */ + public function useCcShowInstancesQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcShowInstances($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShowInstances', '\Airtime\CcShowInstancesQuery'); + } + + /** + * Filter the query by a related CcPlaylistcontents object + * + * @param CcPlaylistcontents|PropelObjectCollection $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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcPlaylistcontents($ccPlaylistcontents, $comparison = null) + { + if ($ccPlaylistcontents instanceof CcPlaylistcontents) { + return $this + ->addUsingAlias(CcFilesPeer::ID, $ccPlaylistcontents->getDbFileId(), $comparison); + } elseif ($ccPlaylistcontents instanceof PropelObjectCollection) { + return $this + ->useCcPlaylistcontentsQuery() + ->filterByPrimaryKeys($ccPlaylistcontents->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcPlaylistcontents() only accepts arguments of type CcPlaylistcontents or PropelCollection'); + } + } + + /** + * 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 = null, $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 \Airtime\CcPlaylistcontentsQuery A secondary query class using the current class as primary query + */ + public function useCcPlaylistcontentsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcPlaylistcontents($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPlaylistcontents', '\Airtime\CcPlaylistcontentsQuery'); + } + + /** + * Filter the query by a related CcBlockcontents object + * + * @param CcBlockcontents|PropelObjectCollection $ccBlockcontents 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcBlockcontents($ccBlockcontents, $comparison = null) + { + if ($ccBlockcontents instanceof CcBlockcontents) { + return $this + ->addUsingAlias(CcFilesPeer::ID, $ccBlockcontents->getDbFileId(), $comparison); + } elseif ($ccBlockcontents instanceof PropelObjectCollection) { + return $this + ->useCcBlockcontentsQuery() + ->filterByPrimaryKeys($ccBlockcontents->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcBlockcontents() only accepts arguments of type CcBlockcontents or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcBlockcontents 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 joinCcBlockcontents($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcBlockcontents'); + + // 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, 'CcBlockcontents'); + } + + return $this; + } + + /** + * Use the CcBlockcontents relation CcBlockcontents 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 \Airtime\CcBlockcontentsQuery A secondary query class using the current class as primary query + */ + public function useCcBlockcontentsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcBlockcontents($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcBlockcontents', '\Airtime\CcBlockcontentsQuery'); + } + + /** + * Filter the query by a related CcSchedule object + * + * @param CcSchedule|PropelObjectCollection $ccSchedule 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcSchedule($ccSchedule, $comparison = null) + { + if ($ccSchedule instanceof CcSchedule) { + return $this + ->addUsingAlias(CcFilesPeer::ID, $ccSchedule->getDbFileId(), $comparison); + } elseif ($ccSchedule instanceof PropelObjectCollection) { + return $this + ->useCcScheduleQuery() + ->filterByPrimaryKeys($ccSchedule->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcSchedule() only accepts arguments of type CcSchedule or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcSchedule 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 joinCcSchedule($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcSchedule'); + + // 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, 'CcSchedule'); + } + + return $this; + } + + /** + * Use the CcSchedule relation CcSchedule 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 \Airtime\CcScheduleQuery A secondary query class using the current class as primary query + */ + public function useCcScheduleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSchedule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSchedule', '\Airtime\CcScheduleQuery'); + } + + /** + * Filter the query by a related CcPlayoutHistory object + * + * @param CcPlayoutHistory|PropelObjectCollection $ccPlayoutHistory 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcPlayoutHistory($ccPlayoutHistory, $comparison = null) + { + if ($ccPlayoutHistory instanceof CcPlayoutHistory) { + return $this + ->addUsingAlias(CcFilesPeer::ID, $ccPlayoutHistory->getDbFileId(), $comparison); + } elseif ($ccPlayoutHistory instanceof PropelObjectCollection) { + return $this + ->useCcPlayoutHistoryQuery() + ->filterByPrimaryKeys($ccPlayoutHistory->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcPlayoutHistory() only accepts arguments of type CcPlayoutHistory or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcPlayoutHistory 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 joinCcPlayoutHistory($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcPlayoutHistory'); + + // 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, 'CcPlayoutHistory'); + } + + return $this; + } + + /** + * Use the CcPlayoutHistory relation CcPlayoutHistory 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 \Airtime\PlayoutHistory\CcPlayoutHistoryQuery A secondary query class using the current class as primary query + */ + public function useCcPlayoutHistoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcPlayoutHistory($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPlayoutHistory', '\Airtime\PlayoutHistory\CcPlayoutHistoryQuery'); + } + + /** + * 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; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcListenerCount.php b/airtime_mvc/application/models/airtime/om/BaseCcListenerCount.php index 42c435123..c52ecca00 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcListenerCount.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcListenerCount.php @@ -1,984 +1,1154 @@ id; - } - - /** - * Get the [timestamp_id] column value. - * - * @return int - */ - public function getDbTimestampId() - { - return $this->timestamp_id; - } - - /** - * Get the [mount_name_id] column value. - * - * @return int - */ - public function getDbMountNameId() - { - return $this->mount_name_id; - } - - /** - * Get the [listener_count] column value. - * - * @return int - */ - public function getDbListenerCount() - { - return $this->listener_count; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcListenerCount 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[] = CcListenerCountPeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [timestamp_id] column. - * - * @param int $v new value - * @return CcListenerCount The current object (for fluent API support) - */ - public function setDbTimestampId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->timestamp_id !== $v) { - $this->timestamp_id = $v; - $this->modifiedColumns[] = CcListenerCountPeer::TIMESTAMP_ID; - } - - if ($this->aCcTimestamp !== null && $this->aCcTimestamp->getDbId() !== $v) { - $this->aCcTimestamp = null; - } - - return $this; - } // setDbTimestampId() - - /** - * Set the value of [mount_name_id] column. - * - * @param int $v new value - * @return CcListenerCount The current object (for fluent API support) - */ - public function setDbMountNameId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->mount_name_id !== $v) { - $this->mount_name_id = $v; - $this->modifiedColumns[] = CcListenerCountPeer::MOUNT_NAME_ID; - } - - if ($this->aCcMountName !== null && $this->aCcMountName->getDbId() !== $v) { - $this->aCcMountName = null; - } - - return $this; - } // setDbMountNameId() - - /** - * Set the value of [listener_count] column. - * - * @param int $v new value - * @return CcListenerCount The current object (for fluent API support) - */ - public function setDbListenerCount($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->listener_count !== $v) { - $this->listener_count = $v; - $this->modifiedColumns[] = CcListenerCountPeer::LISTENER_COUNT; - } - - return $this; - } // setDbListenerCount() - - /** - * 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->timestamp_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->mount_name_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->listener_count = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 4; // 4 = CcListenerCountPeer::NUM_COLUMNS - CcListenerCountPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcListenerCount 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->aCcTimestamp !== null && $this->timestamp_id !== $this->aCcTimestamp->getDbId()) { - $this->aCcTimestamp = null; - } - if ($this->aCcMountName !== null && $this->mount_name_id !== $this->aCcMountName->getDbId()) { - $this->aCcMountName = 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(CcListenerCountPeer::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 = CcListenerCountPeer::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->aCcTimestamp = null; - $this->aCcMountName = 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(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcListenerCountQuery::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(CcListenerCountPeer::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); - CcListenerCountPeer::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->aCcTimestamp !== null) { - if ($this->aCcTimestamp->isModified() || $this->aCcTimestamp->isNew()) { - $affectedRows += $this->aCcTimestamp->save($con); - } - $this->setCcTimestamp($this->aCcTimestamp); - } - - if ($this->aCcMountName !== null) { - if ($this->aCcMountName->isModified() || $this->aCcMountName->isNew()) { - $affectedRows += $this->aCcMountName->save($con); - } - $this->setCcMountName($this->aCcMountName); - } - - if ($this->isNew() ) { - $this->modifiedColumns[] = CcListenerCountPeer::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(CcListenerCountPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcListenerCountPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows += 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows += CcListenerCountPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcTimestamp !== null) { - if (!$this->aCcTimestamp->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcTimestamp->getValidationFailures()); - } - } - - if ($this->aCcMountName !== null) { - if (!$this->aCcMountName->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcMountName->getValidationFailures()); - } - } - - - if (($retval = CcListenerCountPeer::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 = CcListenerCountPeer::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->getDbTimestampId(); - break; - case 2: - return $this->getDbMountNameId(); - break; - case 3: - return $this->getDbListenerCount(); - 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 = CcListenerCountPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbTimestampId(), - $keys[2] => $this->getDbMountNameId(), - $keys[3] => $this->getDbListenerCount(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCcTimestamp) { - $result['CcTimestamp'] = $this->aCcTimestamp->toArray($keyType, $includeLazyLoadColumns, true); - } - if (null !== $this->aCcMountName) { - $result['CcMountName'] = $this->aCcMountName->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 = CcListenerCountPeer::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->setDbTimestampId($value); - break; - case 2: - $this->setDbMountNameId($value); - break; - case 3: - $this->setDbListenerCount($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 = CcListenerCountPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbTimestampId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbMountNameId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbListenerCount($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(CcListenerCountPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcListenerCountPeer::ID)) $criteria->add(CcListenerCountPeer::ID, $this->id); - if ($this->isColumnModified(CcListenerCountPeer::TIMESTAMP_ID)) $criteria->add(CcListenerCountPeer::TIMESTAMP_ID, $this->timestamp_id); - if ($this->isColumnModified(CcListenerCountPeer::MOUNT_NAME_ID)) $criteria->add(CcListenerCountPeer::MOUNT_NAME_ID, $this->mount_name_id); - if ($this->isColumnModified(CcListenerCountPeer::LISTENER_COUNT)) $criteria->add(CcListenerCountPeer::LISTENER_COUNT, $this->listener_count); - - 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(CcListenerCountPeer::DATABASE_NAME); - $criteria->add(CcListenerCountPeer::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 CcListenerCount (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->setDbTimestampId($this->timestamp_id); - $copyObj->setDbMountNameId($this->mount_name_id); - $copyObj->setDbListenerCount($this->listener_count); - - $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 CcListenerCount 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 CcListenerCountPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcListenerCountPeer(); - } - return self::$peer; - } - - /** - * Declares an association between this object and a CcTimestamp object. - * - * @param CcTimestamp $v - * @return CcListenerCount The current object (for fluent API support) - * @throws PropelException - */ - public function setCcTimestamp(CcTimestamp $v = null) - { - if ($v === null) { - $this->setDbTimestampId(NULL); - } else { - $this->setDbTimestampId($v->getDbId()); - } - - $this->aCcTimestamp = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcTimestamp object, it will not be re-added. - if ($v !== null) { - $v->addCcListenerCount($this); - } - - return $this; - } - - - /** - * Get the associated CcTimestamp object - * - * @param PropelPDO Optional Connection object. - * @return CcTimestamp The associated CcTimestamp object. - * @throws PropelException - */ - public function getCcTimestamp(PropelPDO $con = null) - { - if ($this->aCcTimestamp === null && ($this->timestamp_id !== null)) { - $this->aCcTimestamp = CcTimestampQuery::create()->findPk($this->timestamp_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->aCcTimestamp->addCcListenerCounts($this); - */ - } - return $this->aCcTimestamp; - } - - /** - * Declares an association between this object and a CcMountName object. - * - * @param CcMountName $v - * @return CcListenerCount The current object (for fluent API support) - * @throws PropelException - */ - public function setCcMountName(CcMountName $v = null) - { - if ($v === null) { - $this->setDbMountNameId(NULL); - } else { - $this->setDbMountNameId($v->getDbId()); - } - - $this->aCcMountName = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcMountName object, it will not be re-added. - if ($v !== null) { - $v->addCcListenerCount($this); - } - - return $this; - } - - - /** - * Get the associated CcMountName object - * - * @param PropelPDO Optional Connection object. - * @return CcMountName The associated CcMountName object. - * @throws PropelException - */ - public function getCcMountName(PropelPDO $con = null) - { - if ($this->aCcMountName === null && ($this->mount_name_id !== null)) { - $this->aCcMountName = CcMountNameQuery::create()->findPk($this->mount_name_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->aCcMountName->addCcListenerCounts($this); - */ - } - return $this->aCcMountName; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->timestamp_id = null; - $this->mount_name_id = null; - $this->listener_count = 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->aCcTimestamp = null; - $this->aCcMountName = 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); - } - -} // BaseCcListenerCount + /** + * Peer class name + */ + const PEER = 'Airtime\\CcListenerCountPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcListenerCountPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the timestamp_id field. + * @var int + */ + protected $timestamp_id; + + /** + * The value for the mount_name_id field. + * @var int + */ + protected $mount_name_id; + + /** + * The value for the listener_count field. + * @var int + */ + protected $listener_count; + + /** + * @var CcTimestamp + */ + protected $aCcTimestamp; + + /** + * @var CcMountName + */ + protected $aCcMountName; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * Get the [id] column value. + * + * @return int + */ + public function getDbId() + { + + return $this->id; + } + + /** + * Get the [timestamp_id] column value. + * + * @return int + */ + public function getDbTimestampId() + { + + return $this->timestamp_id; + } + + /** + * Get the [mount_name_id] column value. + * + * @return int + */ + public function getDbMountNameId() + { + + return $this->mount_name_id; + } + + /** + * Get the [listener_count] column value. + * + * @return int + */ + public function getDbListenerCount() + { + + return $this->listener_count; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcListenerCount The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcListenerCountPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [timestamp_id] column. + * + * @param int $v new value + * @return CcListenerCount The current object (for fluent API support) + */ + public function setDbTimestampId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->timestamp_id !== $v) { + $this->timestamp_id = $v; + $this->modifiedColumns[] = CcListenerCountPeer::TIMESTAMP_ID; + } + + if ($this->aCcTimestamp !== null && $this->aCcTimestamp->getDbId() !== $v) { + $this->aCcTimestamp = null; + } + + + return $this; + } // setDbTimestampId() + + /** + * Set the value of [mount_name_id] column. + * + * @param int $v new value + * @return CcListenerCount The current object (for fluent API support) + */ + public function setDbMountNameId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->mount_name_id !== $v) { + $this->mount_name_id = $v; + $this->modifiedColumns[] = CcListenerCountPeer::MOUNT_NAME_ID; + } + + if ($this->aCcMountName !== null && $this->aCcMountName->getDbId() !== $v) { + $this->aCcMountName = null; + } + + + return $this; + } // setDbMountNameId() + + /** + * Set the value of [listener_count] column. + * + * @param int $v new value + * @return CcListenerCount The current object (for fluent API support) + */ + public function setDbListenerCount($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->listener_count !== $v) { + $this->listener_count = $v; + $this->modifiedColumns[] = CcListenerCountPeer::LISTENER_COUNT; + } + + + return $this; + } // setDbListenerCount() + + /** + * 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 resultset 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->timestamp_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->mount_name_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; + $this->listener_count = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 4; // 4 = CcListenerCountPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcListenerCount 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->aCcTimestamp !== null && $this->timestamp_id !== $this->aCcTimestamp->getDbId()) { + $this->aCcTimestamp = null; + } + if ($this->aCcMountName !== null && $this->mount_name_id !== $this->aCcMountName->getDbId()) { + $this->aCcMountName = 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(CcListenerCountPeer::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 = CcListenerCountPeer::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->aCcTimestamp = null; + $this->aCcMountName = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcListenerCountQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcListenerCountPeer::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); + CcListenerCountPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcTimestamp !== null) { + if ($this->aCcTimestamp->isModified() || $this->aCcTimestamp->isNew()) { + $affectedRows += $this->aCcTimestamp->save($con); + } + $this->setCcTimestamp($this->aCcTimestamp); + } + + if ($this->aCcMountName !== null) { + if ($this->aCcMountName->isModified() || $this->aCcMountName->isNew()) { + $affectedRows += $this->aCcMountName->save($con); + } + $this->setCcMountName($this->aCcMountName); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcListenerCountPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcListenerCountPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_listener_count_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcListenerCountPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcListenerCountPeer::TIMESTAMP_ID)) { + $modifiedColumns[':p' . $index++] = '"timestamp_id"'; + } + if ($this->isColumnModified(CcListenerCountPeer::MOUNT_NAME_ID)) { + $modifiedColumns[':p' . $index++] = '"mount_name_id"'; + } + if ($this->isColumnModified(CcListenerCountPeer::LISTENER_COUNT)) { + $modifiedColumns[':p' . $index++] = '"listener_count"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_listener_count" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"timestamp_id"': + $stmt->bindValue($identifier, $this->timestamp_id, PDO::PARAM_INT); + break; + case '"mount_name_id"': + $stmt->bindValue($identifier, $this->mount_name_id, PDO::PARAM_INT); + break; + case '"listener_count"': + $stmt->bindValue($identifier, $this->listener_count, PDO::PARAM_INT); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcTimestamp !== null) { + if (!$this->aCcTimestamp->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcTimestamp->getValidationFailures()); + } + } + + if ($this->aCcMountName !== null) { + if (!$this->aCcMountName->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcMountName->getValidationFailures()); + } + } + + + if (($retval = CcListenerCountPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcListenerCountPeer::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->getDbTimestampId(); + break; + case 2: + return $this->getDbMountNameId(); + break; + case 3: + return $this->getDbListenerCount(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcListenerCount'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcListenerCount'][$this->getPrimaryKey()] = true; + $keys = CcListenerCountPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbTimestampId(), + $keys[2] => $this->getDbMountNameId(), + $keys[3] => $this->getDbListenerCount(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcTimestamp) { + $result['CcTimestamp'] = $this->aCcTimestamp->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aCcMountName) { + $result['CcMountName'] = $this->aCcMountName->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcListenerCountPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbTimestampId($value); + break; + case 2: + $this->setDbMountNameId($value); + break; + case 3: + $this->setDbListenerCount($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcListenerCountPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbTimestampId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbMountNameId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbListenerCount($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(CcListenerCountPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcListenerCountPeer::ID)) $criteria->add(CcListenerCountPeer::ID, $this->id); + if ($this->isColumnModified(CcListenerCountPeer::TIMESTAMP_ID)) $criteria->add(CcListenerCountPeer::TIMESTAMP_ID, $this->timestamp_id); + if ($this->isColumnModified(CcListenerCountPeer::MOUNT_NAME_ID)) $criteria->add(CcListenerCountPeer::MOUNT_NAME_ID, $this->mount_name_id); + if ($this->isColumnModified(CcListenerCountPeer::LISTENER_COUNT)) $criteria->add(CcListenerCountPeer::LISTENER_COUNT, $this->listener_count); + + 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(CcListenerCountPeer::DATABASE_NAME); + $criteria->add(CcListenerCountPeer::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 CcListenerCount (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbTimestampId($this->getDbTimestampId()); + $copyObj->setDbMountNameId($this->getDbMountNameId()); + $copyObj->setDbListenerCount($this->getDbListenerCount()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcListenerCount 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 CcListenerCountPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcListenerCountPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a CcTimestamp object. + * + * @param CcTimestamp $v + * @return CcListenerCount The current object (for fluent API support) + * @throws PropelException + */ + public function setCcTimestamp(CcTimestamp $v = null) + { + if ($v === null) { + $this->setDbTimestampId(NULL); + } else { + $this->setDbTimestampId($v->getDbId()); + } + + $this->aCcTimestamp = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcTimestamp object, it will not be re-added. + if ($v !== null) { + $v->addCcListenerCount($this); + } + + + return $this; + } + + + /** + * Get the associated CcTimestamp object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcTimestamp The associated CcTimestamp object. + * @throws PropelException + */ + public function getCcTimestamp(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcTimestamp === null && ($this->timestamp_id !== null) && $doQuery) { + $this->aCcTimestamp = CcTimestampQuery::create()->findPk($this->timestamp_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->aCcTimestamp->addCcListenerCounts($this); + */ + } + + return $this->aCcTimestamp; + } + + /** + * Declares an association between this object and a CcMountName object. + * + * @param CcMountName $v + * @return CcListenerCount The current object (for fluent API support) + * @throws PropelException + */ + public function setCcMountName(CcMountName $v = null) + { + if ($v === null) { + $this->setDbMountNameId(NULL); + } else { + $this->setDbMountNameId($v->getDbId()); + } + + $this->aCcMountName = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcMountName object, it will not be re-added. + if ($v !== null) { + $v->addCcListenerCount($this); + } + + + return $this; + } + + + /** + * Get the associated CcMountName object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcMountName The associated CcMountName object. + * @throws PropelException + */ + public function getCcMountName(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcMountName === null && ($this->mount_name_id !== null) && $doQuery) { + $this->aCcMountName = CcMountNameQuery::create()->findPk($this->mount_name_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->aCcMountName->addCcListenerCounts($this); + */ + } + + return $this->aCcMountName; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->timestamp_id = null; + $this->mount_name_id = null; + $this->listener_count = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCcTimestamp instanceof Persistent) { + $this->aCcTimestamp->clearAllReferences($deep); + } + if ($this->aCcMountName instanceof Persistent) { + $this->aCcMountName->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + $this->aCcTimestamp = null; + $this->aCcMountName = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcListenerCountPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcListenerCountPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcListenerCountPeer.php index dad3a53b9..12a3b88ad 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcListenerCountPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcListenerCountPeer.php @@ -1,1366 +1,1412 @@ array ('DbId', 'DbTimestampId', 'DbMountNameId', 'DbListenerCount', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbTimestampId', 'dbMountNameId', 'dbListenerCount', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::TIMESTAMP_ID, self::MOUNT_NAME_ID, self::LISTENER_COUNT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TIMESTAMP_ID', 'MOUNT_NAME_ID', 'LISTENER_COUNT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'timestamp_id', 'mount_name_id', 'listener_count', ), - 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 ('DbId' => 0, 'DbTimestampId' => 1, 'DbMountNameId' => 2, 'DbListenerCount' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbTimestampId' => 1, 'dbMountNameId' => 2, 'dbListenerCount' => 3, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::TIMESTAMP_ID => 1, self::MOUNT_NAME_ID => 2, self::LISTENER_COUNT => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TIMESTAMP_ID' => 1, 'MOUNT_NAME_ID' => 2, 'LISTENER_COUNT' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'timestamp_id' => 1, 'mount_name_id' => 2, 'listener_count' => 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. CcListenerCountPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcListenerCountPeer::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(CcListenerCountPeer::ID); - $criteria->addSelectColumn(CcListenerCountPeer::TIMESTAMP_ID); - $criteria->addSelectColumn(CcListenerCountPeer::MOUNT_NAME_ID); - $criteria->addSelectColumn(CcListenerCountPeer::LISTENER_COUNT); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.TIMESTAMP_ID'); - $criteria->addSelectColumn($alias . '.MOUNT_NAME_ID'); - $criteria->addSelectColumn($alias . '.LISTENER_COUNT'); - } - } - - /** - * 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(CcListenerCountPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcListenerCountPeer::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(CcListenerCountPeer::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 CcListenerCount - * @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 = CcListenerCountPeer::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 CcListenerCountPeer::populateObjects(CcListenerCountPeer::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(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcListenerCountPeer::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 CcListenerCount $value A CcListenerCount object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcListenerCount $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 CcListenerCount object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcListenerCount) { - $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 CcListenerCount 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 CcListenerCount 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_listener_count - * 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 = CcListenerCountPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcListenerCountPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcListenerCountPeer::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; - CcListenerCountPeer::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 (CcListenerCount object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcListenerCountPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcListenerCountPeer::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 + CcListenerCountPeer::NUM_COLUMNS; - } else { - $cls = CcListenerCountPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcListenerCountPeer::addInstanceToPool($obj, $key); - } - return array($obj, $col); - } - - /** - * Returns the number of rows matching criteria, joining the related CcTimestamp 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 doCountJoinCcTimestamp(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(CcListenerCountPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcListenerCountPeer::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(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcListenerCountPeer::TIMESTAMP_ID, CcTimestampPeer::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 CcMountName 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 doCountJoinCcMountName(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(CcListenerCountPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcListenerCountPeer::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(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcListenerCountPeer::MOUNT_NAME_ID, CcMountNamePeer::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 CcListenerCount objects pre-filled with their CcTimestamp 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 CcListenerCount objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCcTimestamp(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); - } - - CcListenerCountPeer::addSelectColumns($criteria); - $startcol = (CcListenerCountPeer::NUM_COLUMNS - CcListenerCountPeer::NUM_LAZY_LOAD_COLUMNS); - CcTimestampPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcListenerCountPeer::TIMESTAMP_ID, CcTimestampPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcListenerCountPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcListenerCountPeer::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 = CcListenerCountPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcListenerCountPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CcTimestampPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcTimestampPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcTimestampPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcTimestampPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcListenerCount) to $obj2 (CcTimestamp) - $obj2->addCcListenerCount($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcListenerCount objects pre-filled with their CcMountName 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 CcListenerCount objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCcMountName(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); - } - - CcListenerCountPeer::addSelectColumns($criteria); - $startcol = (CcListenerCountPeer::NUM_COLUMNS - CcListenerCountPeer::NUM_LAZY_LOAD_COLUMNS); - CcMountNamePeer::addSelectColumns($criteria); - - $criteria->addJoin(CcListenerCountPeer::MOUNT_NAME_ID, CcMountNamePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcListenerCountPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcListenerCountPeer::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 = CcListenerCountPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcListenerCountPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CcMountNamePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcMountNamePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcMountNamePeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcMountNamePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcListenerCount) to $obj2 (CcMountName) - $obj2->addCcListenerCount($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(CcListenerCountPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcListenerCountPeer::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(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcListenerCountPeer::TIMESTAMP_ID, CcTimestampPeer::ID, $join_behavior); - - $criteria->addJoin(CcListenerCountPeer::MOUNT_NAME_ID, CcMountNamePeer::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 CcListenerCount 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 CcListenerCount 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); - } - - CcListenerCountPeer::addSelectColumns($criteria); - $startcol2 = (CcListenerCountPeer::NUM_COLUMNS - CcListenerCountPeer::NUM_LAZY_LOAD_COLUMNS); - - CcTimestampPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcTimestampPeer::NUM_COLUMNS - CcTimestampPeer::NUM_LAZY_LOAD_COLUMNS); - - CcMountNamePeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + (CcMountNamePeer::NUM_COLUMNS - CcMountNamePeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcListenerCountPeer::TIMESTAMP_ID, CcTimestampPeer::ID, $join_behavior); - - $criteria->addJoin(CcListenerCountPeer::MOUNT_NAME_ID, CcMountNamePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcListenerCountPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcListenerCountPeer::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 = CcListenerCountPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcListenerCountPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcTimestamp rows - - $key2 = CcTimestampPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcTimestampPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcTimestampPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcTimestampPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (CcListenerCount) to the collection in $obj2 (CcTimestamp) - $obj2->addCcListenerCount($obj1); - } // if joined row not null - - // Add objects for joined CcMountName rows - - $key3 = CcMountNamePeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CcMountNamePeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CcMountNamePeer::getOMClass(false); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CcMountNamePeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (CcListenerCount) to the collection in $obj3 (CcMountName) - $obj3->addCcListenerCount($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related CcTimestamp 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 doCountJoinAllExceptCcTimestamp(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(CcListenerCountPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcListenerCountPeer::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(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcListenerCountPeer::MOUNT_NAME_ID, CcMountNamePeer::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 CcMountName 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 doCountJoinAllExceptCcMountName(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(CcListenerCountPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcListenerCountPeer::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(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcListenerCountPeer::TIMESTAMP_ID, CcTimestampPeer::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 CcListenerCount objects pre-filled with all related objects except CcTimestamp. - * - * @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 CcListenerCount objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCcTimestamp(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); - } - - CcListenerCountPeer::addSelectColumns($criteria); - $startcol2 = (CcListenerCountPeer::NUM_COLUMNS - CcListenerCountPeer::NUM_LAZY_LOAD_COLUMNS); - - CcMountNamePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcMountNamePeer::NUM_COLUMNS - CcMountNamePeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcListenerCountPeer::MOUNT_NAME_ID, CcMountNamePeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcListenerCountPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcListenerCountPeer::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 = CcListenerCountPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcListenerCountPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcMountName rows - - $key2 = CcMountNamePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcMountNamePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcMountNamePeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcMountNamePeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (CcListenerCount) to the collection in $obj2 (CcMountName) - $obj2->addCcListenerCount($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcListenerCount objects pre-filled with all related objects except CcMountName. - * - * @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 CcListenerCount objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCcMountName(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); - } - - CcListenerCountPeer::addSelectColumns($criteria); - $startcol2 = (CcListenerCountPeer::NUM_COLUMNS - CcListenerCountPeer::NUM_LAZY_LOAD_COLUMNS); - - CcTimestampPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcTimestampPeer::NUM_COLUMNS - CcTimestampPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcListenerCountPeer::TIMESTAMP_ID, CcTimestampPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcListenerCountPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcListenerCountPeer::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 = CcListenerCountPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcListenerCountPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcTimestamp rows - - $key2 = CcTimestampPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcTimestampPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcTimestampPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcTimestampPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (CcListenerCount) to the collection in $obj2 (CcTimestamp) - $obj2->addCcListenerCount($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(BaseCcListenerCountPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcListenerCountPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcListenerCountTableMap()); - } - } - - /** - * 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 ? CcListenerCountPeer::CLASS_DEFAULT : CcListenerCountPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcListenerCount or Criteria object. - * - * @param mixed $values Criteria or CcListenerCount 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(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcListenerCount object - } - - if ($criteria->containsKey(CcListenerCountPeer::ID) && $criteria->keyContainsValue(CcListenerCountPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcListenerCountPeer::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 CcListenerCount or Criteria object. - * - * @param mixed $values Criteria or CcListenerCount 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(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcListenerCountPeer::ID); - $value = $criteria->remove(CcListenerCountPeer::ID); - if ($value) { - $selectCriteria->add(CcListenerCountPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcListenerCountPeer::TABLE_NAME); - } - - } else { // $values is CcListenerCount 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_listener_count 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(CcListenerCountPeer::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(CcListenerCountPeer::TABLE_NAME, $con, CcListenerCountPeer::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). - CcListenerCountPeer::clearInstancePool(); - CcListenerCountPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcListenerCount or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcListenerCount 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(CcListenerCountPeer::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. - CcListenerCountPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcListenerCount) { // it's a model object - // invalidate the cache for this single object - CcListenerCountPeer::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(CcListenerCountPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcListenerCountPeer::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); - CcListenerCountPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcListenerCount 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 CcListenerCount $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(CcListenerCount $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcListenerCountPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcListenerCountPeer::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(CcListenerCountPeer::DATABASE_NAME, CcListenerCountPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcListenerCount - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcListenerCountPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcListenerCountPeer::DATABASE_NAME); - $criteria->add(CcListenerCountPeer::ID, $pk); - - $v = CcListenerCountPeer::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(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcListenerCountPeer::DATABASE_NAME); - $criteria->add(CcListenerCountPeer::ID, $pks, Criteria::IN); - $objs = CcListenerCountPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcListenerCountPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_listener_count'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcListenerCount'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcListenerCountTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 4; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 4; + + /** the column name for the id field */ + const ID = 'cc_listener_count.id'; + + /** the column name for the timestamp_id field */ + const TIMESTAMP_ID = 'cc_listener_count.timestamp_id'; + + /** the column name for the mount_name_id field */ + const MOUNT_NAME_ID = 'cc_listener_count.mount_name_id'; + + /** the column name for the listener_count field */ + const LISTENER_COUNT = 'cc_listener_count.listener_count'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcListenerCount objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcListenerCount[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcListenerCountPeer::$fieldNames[CcListenerCountPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbTimestampId', 'DbMountNameId', 'DbListenerCount', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbTimestampId', 'dbMountNameId', 'dbListenerCount', ), + BasePeer::TYPE_COLNAME => array (CcListenerCountPeer::ID, CcListenerCountPeer::TIMESTAMP_ID, CcListenerCountPeer::MOUNT_NAME_ID, CcListenerCountPeer::LISTENER_COUNT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TIMESTAMP_ID', 'MOUNT_NAME_ID', 'LISTENER_COUNT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'timestamp_id', 'mount_name_id', 'listener_count', ), + 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. CcListenerCountPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbTimestampId' => 1, 'DbMountNameId' => 2, 'DbListenerCount' => 3, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbTimestampId' => 1, 'dbMountNameId' => 2, 'dbListenerCount' => 3, ), + BasePeer::TYPE_COLNAME => array (CcListenerCountPeer::ID => 0, CcListenerCountPeer::TIMESTAMP_ID => 1, CcListenerCountPeer::MOUNT_NAME_ID => 2, CcListenerCountPeer::LISTENER_COUNT => 3, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TIMESTAMP_ID' => 1, 'MOUNT_NAME_ID' => 2, 'LISTENER_COUNT' => 3, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'timestamp_id' => 1, 'mount_name_id' => 2, 'listener_count' => 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcListenerCountPeer::getFieldNames($toType); + $key = isset(CcListenerCountPeer::$fieldKeys[$fromType][$name]) ? CcListenerCountPeer::$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(CcListenerCountPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcListenerCountPeer::$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 CcListenerCountPeer::$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. CcListenerCountPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcListenerCountPeer::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(CcListenerCountPeer::ID); + $criteria->addSelectColumn(CcListenerCountPeer::TIMESTAMP_ID); + $criteria->addSelectColumn(CcListenerCountPeer::MOUNT_NAME_ID); + $criteria->addSelectColumn(CcListenerCountPeer::LISTENER_COUNT); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.timestamp_id'); + $criteria->addSelectColumn($alias . '.mount_name_id'); + $criteria->addSelectColumn($alias . '.listener_count'); + } + } + + /** + * 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(CcListenerCountPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcListenerCountPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcListenerCountPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcListenerCountPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcListenerCount + * @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 = CcListenerCountPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcListenerCountPeer::populateObjects(CcListenerCountPeer::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 directly (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(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcListenerCountPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcListenerCountPeer::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 CcListenerCount $obj A CcListenerCount object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcListenerCountPeer::$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 CcListenerCount object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcListenerCount) { + $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 CcListenerCount object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcListenerCountPeer::$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 CcListenerCount 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(CcListenerCountPeer::$instances[$key])) { + return CcListenerCountPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcListenerCountPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcListenerCountPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_listener_count + * 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 = CcListenerCountPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcListenerCountPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcListenerCountPeer::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; + CcListenerCountPeer::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 (CcListenerCount object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcListenerCountPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcListenerCountPeer::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 + CcListenerCountPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcListenerCountPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcListenerCountPeer::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + + /** + * Returns the number of rows matching criteria, joining the related CcTimestamp 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 doCountJoinCcTimestamp(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(CcListenerCountPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcListenerCountPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcListenerCountPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcListenerCountPeer::TIMESTAMP_ID, CcTimestampPeer::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 CcMountName 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 doCountJoinCcMountName(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(CcListenerCountPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcListenerCountPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcListenerCountPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcListenerCountPeer::MOUNT_NAME_ID, CcMountNamePeer::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 CcListenerCount objects pre-filled with their CcTimestamp 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 CcListenerCount objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcTimestamp(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(CcListenerCountPeer::DATABASE_NAME); + } + + CcListenerCountPeer::addSelectColumns($criteria); + $startcol = CcListenerCountPeer::NUM_HYDRATE_COLUMNS; + CcTimestampPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcListenerCountPeer::TIMESTAMP_ID, CcTimestampPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcListenerCountPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcListenerCountPeer::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 = CcListenerCountPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcListenerCountPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcTimestampPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcTimestampPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcTimestampPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcTimestampPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcListenerCount) to $obj2 (CcTimestamp) + $obj2->addCcListenerCount($obj1); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcListenerCount objects pre-filled with their CcMountName 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 CcListenerCount objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcMountName(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(CcListenerCountPeer::DATABASE_NAME); + } + + CcListenerCountPeer::addSelectColumns($criteria); + $startcol = CcListenerCountPeer::NUM_HYDRATE_COLUMNS; + CcMountNamePeer::addSelectColumns($criteria); + + $criteria->addJoin(CcListenerCountPeer::MOUNT_NAME_ID, CcMountNamePeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcListenerCountPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcListenerCountPeer::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 = CcListenerCountPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcListenerCountPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcMountNamePeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcMountNamePeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcMountNamePeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcMountNamePeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcListenerCount) to $obj2 (CcMountName) + $obj2->addCcListenerCount($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(CcListenerCountPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcListenerCountPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcListenerCountPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcListenerCountPeer::TIMESTAMP_ID, CcTimestampPeer::ID, $join_behavior); + + $criteria->addJoin(CcListenerCountPeer::MOUNT_NAME_ID, CcMountNamePeer::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 CcListenerCount 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 CcListenerCount 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(CcListenerCountPeer::DATABASE_NAME); + } + + CcListenerCountPeer::addSelectColumns($criteria); + $startcol2 = CcListenerCountPeer::NUM_HYDRATE_COLUMNS; + + CcTimestampPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcTimestampPeer::NUM_HYDRATE_COLUMNS; + + CcMountNamePeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcMountNamePeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcListenerCountPeer::TIMESTAMP_ID, CcTimestampPeer::ID, $join_behavior); + + $criteria->addJoin(CcListenerCountPeer::MOUNT_NAME_ID, CcMountNamePeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcListenerCountPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcListenerCountPeer::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 = CcListenerCountPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcListenerCountPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcTimestamp rows + + $key2 = CcTimestampPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcTimestampPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcTimestampPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcTimestampPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcListenerCount) to the collection in $obj2 (CcTimestamp) + $obj2->addCcListenerCount($obj1); + } // if joined row not null + + // Add objects for joined CcMountName rows + + $key3 = CcMountNamePeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcMountNamePeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcMountNamePeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcMountNamePeer::addInstanceToPool($obj3, $key3); + } // if obj3 loaded + + // Add the $obj1 (CcListenerCount) to the collection in $obj3 (CcMountName) + $obj3->addCcListenerCount($obj1); + } // if joined row not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining the related CcTimestamp 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 doCountJoinAllExceptCcTimestamp(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(CcListenerCountPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcListenerCountPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(CcListenerCountPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcListenerCountPeer::MOUNT_NAME_ID, CcMountNamePeer::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 CcMountName 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 doCountJoinAllExceptCcMountName(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(CcListenerCountPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcListenerCountPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(CcListenerCountPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcListenerCountPeer::TIMESTAMP_ID, CcTimestampPeer::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 CcListenerCount objects pre-filled with all related objects except CcTimestamp. + * + * @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 CcListenerCount objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcTimestamp(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(CcListenerCountPeer::DATABASE_NAME); + } + + CcListenerCountPeer::addSelectColumns($criteria); + $startcol2 = CcListenerCountPeer::NUM_HYDRATE_COLUMNS; + + CcMountNamePeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcMountNamePeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcListenerCountPeer::MOUNT_NAME_ID, CcMountNamePeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcListenerCountPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcListenerCountPeer::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 = CcListenerCountPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcListenerCountPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcMountName rows + + $key2 = CcMountNamePeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcMountNamePeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcMountNamePeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcMountNamePeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcListenerCount) to the collection in $obj2 (CcMountName) + $obj2->addCcListenerCount($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcListenerCount objects pre-filled with all related objects except CcMountName. + * + * @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 CcListenerCount objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcMountName(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(CcListenerCountPeer::DATABASE_NAME); + } + + CcListenerCountPeer::addSelectColumns($criteria); + $startcol2 = CcListenerCountPeer::NUM_HYDRATE_COLUMNS; + + CcTimestampPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcTimestampPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcListenerCountPeer::TIMESTAMP_ID, CcTimestampPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcListenerCountPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcListenerCountPeer::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 = CcListenerCountPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcListenerCountPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcTimestamp rows + + $key2 = CcTimestampPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcTimestampPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcTimestampPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcTimestampPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcListenerCount) to the collection in $obj2 (CcTimestamp) + $obj2->addCcListenerCount($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(CcListenerCountPeer::DATABASE_NAME)->getTable(CcListenerCountPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcListenerCountPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcListenerCountPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcListenerCountTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcListenerCountPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcListenerCount or Criteria object. + * + * @param mixed $values Criteria or CcListenerCount 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(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcListenerCount object + } + + if ($criteria->containsKey(CcListenerCountPeer::ID) && $criteria->keyContainsValue(CcListenerCountPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcListenerCountPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcListenerCountPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcListenerCount or Criteria object. + * + * @param mixed $values Criteria or CcListenerCount 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(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcListenerCountPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcListenerCountPeer::ID); + $value = $criteria->remove(CcListenerCountPeer::ID); + if ($value) { + $selectCriteria->add(CcListenerCountPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcListenerCountPeer::TABLE_NAME); + } + + } else { // $values is CcListenerCount object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcListenerCountPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_listener_count table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcListenerCountPeer::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(CcListenerCountPeer::TABLE_NAME, $con, CcListenerCountPeer::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). + CcListenerCountPeer::clearInstancePool(); + CcListenerCountPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcListenerCount or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcListenerCount 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(CcListenerCountPeer::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. + CcListenerCountPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcListenerCount) { // it's a model object + // invalidate the cache for this single object + CcListenerCountPeer::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(CcListenerCountPeer::DATABASE_NAME); + $criteria->add(CcListenerCountPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcListenerCountPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcListenerCountPeer::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); + CcListenerCountPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcListenerCount 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 CcListenerCount $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcListenerCountPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcListenerCountPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcListenerCountPeer::DATABASE_NAME, CcListenerCountPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcListenerCount + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcListenerCountPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcListenerCountPeer::DATABASE_NAME); + $criteria->add(CcListenerCountPeer::ID, $pk); + + $v = CcListenerCountPeer::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 + * @return CcListenerCount[] + * @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(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcListenerCountPeer::DATABASE_NAME); + $criteria->add(CcListenerCountPeer::ID, $pks, Criteria::IN); + $objs = CcListenerCountPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcListenerCountPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcListenerCountQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcListenerCountQuery.php index 30c702e6e..4429f81c7 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcListenerCountQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcListenerCountQuery.php @@ -1,406 +1,595 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcListenerCount|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcListenerCountPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcListenerCount|CcListenerCount[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcListenerCountPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcListenerCountQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcListenerCountPeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcListenerCount A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcListenerCountQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcListenerCountPeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcListenerCount A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "timestamp_id", "mount_name_id", "listener_count" FROM "cc_listener_count" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcListenerCount(); + $obj->hydrate($row); + CcListenerCountPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcListenerCountQuery 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(CcListenerCountPeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * Filter the query on the timestamp_id column - * - * @param int|array $dbTimestampId 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 CcListenerCountQuery The current query, for fluid interface - */ - public function filterByDbTimestampId($dbTimestampId = null, $comparison = null) - { - if (is_array($dbTimestampId)) { - $useMinMax = false; - if (isset($dbTimestampId['min'])) { - $this->addUsingAlias(CcListenerCountPeer::TIMESTAMP_ID, $dbTimestampId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbTimestampId['max'])) { - $this->addUsingAlias(CcListenerCountPeer::TIMESTAMP_ID, $dbTimestampId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcListenerCountPeer::TIMESTAMP_ID, $dbTimestampId, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcListenerCount|CcListenerCount[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Filter the query on the mount_name_id column - * - * @param int|array $dbMountNameId 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 CcListenerCountQuery The current query, for fluid interface - */ - public function filterByDbMountNameId($dbMountNameId = null, $comparison = null) - { - if (is_array($dbMountNameId)) { - $useMinMax = false; - if (isset($dbMountNameId['min'])) { - $this->addUsingAlias(CcListenerCountPeer::MOUNT_NAME_ID, $dbMountNameId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbMountNameId['max'])) { - $this->addUsingAlias(CcListenerCountPeer::MOUNT_NAME_ID, $dbMountNameId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcListenerCountPeer::MOUNT_NAME_ID, $dbMountNameId, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query on the listener_count column - * - * @param int|array $dbListenerCount 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 CcListenerCountQuery The current query, for fluid interface - */ - public function filterByDbListenerCount($dbListenerCount = null, $comparison = null) - { - if (is_array($dbListenerCount)) { - $useMinMax = false; - if (isset($dbListenerCount['min'])) { - $this->addUsingAlias(CcListenerCountPeer::LISTENER_COUNT, $dbListenerCount['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbListenerCount['max'])) { - $this->addUsingAlias(CcListenerCountPeer::LISTENER_COUNT, $dbListenerCount['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcListenerCountPeer::LISTENER_COUNT, $dbListenerCount, $comparison); - } + /** + * 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|CcListenerCount[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query by a related CcTimestamp object - * - * @param CcTimestamp $ccTimestamp the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcListenerCountQuery The current query, for fluid interface - */ - public function filterByCcTimestamp($ccTimestamp, $comparison = null) - { - return $this - ->addUsingAlias(CcListenerCountPeer::TIMESTAMP_ID, $ccTimestamp->getDbId(), $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Adds a JOIN clause to the query using the CcTimestamp relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcListenerCountQuery The current query, for fluid interface - */ - public function joinCcTimestamp($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcTimestamp'); - - // 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, 'CcTimestamp'); - } - - return $this; - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcListenerCountQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { - /** - * Use the CcTimestamp relation CcTimestamp 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 CcTimestampQuery A secondary query class using the current class as primary query - */ - public function useCcTimestampQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcTimestamp($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcTimestamp', 'CcTimestampQuery'); - } + return $this->addUsingAlias(CcListenerCountPeer::ID, $key, Criteria::EQUAL); + } - /** - * Filter the query by a related CcMountName object - * - * @param CcMountName $ccMountName the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcListenerCountQuery The current query, for fluid interface - */ - public function filterByCcMountName($ccMountName, $comparison = null) - { - return $this - ->addUsingAlias(CcListenerCountPeer::MOUNT_NAME_ID, $ccMountName->getDbId(), $comparison); - } + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return CcListenerCountQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { - /** - * Adds a JOIN clause to the query using the CcMountName relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcListenerCountQuery The current query, for fluid interface - */ - public function joinCcMountName($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcMountName'); - - // 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, 'CcMountName'); - } - - return $this; - } + return $this->addUsingAlias(CcListenerCountPeer::ID, $keys, Criteria::IN); + } - /** - * Use the CcMountName relation CcMountName 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 CcMountNameQuery A secondary query class using the current class as primary query - */ - public function useCcMountNameQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcMountName($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcMountName', 'CcMountNameQuery'); - } + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcListenerCountQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcListenerCountPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcListenerCountPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Exclude object from result - * - * @param CcListenerCount $ccListenerCount Object to remove from the list of results - * - * @return CcListenerCountQuery The current query, for fluid interface - */ - public function prune($ccListenerCount = null) - { - if ($ccListenerCount) { - $this->addUsingAlias(CcListenerCountPeer::ID, $ccListenerCount->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + return $this->addUsingAlias(CcListenerCountPeer::ID, $dbId, $comparison); + } -} // BaseCcListenerCountQuery + /** + * Filter the query on the timestamp_id column + * + * Example usage: + * + * $query->filterByDbTimestampId(1234); // WHERE timestamp_id = 1234 + * $query->filterByDbTimestampId(array(12, 34)); // WHERE timestamp_id IN (12, 34) + * $query->filterByDbTimestampId(array('min' => 12)); // WHERE timestamp_id >= 12 + * $query->filterByDbTimestampId(array('max' => 12)); // WHERE timestamp_id <= 12 + * + * + * @see filterByCcTimestamp() + * + * @param mixed $dbTimestampId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcListenerCountQuery The current query, for fluid interface + */ + public function filterByDbTimestampId($dbTimestampId = null, $comparison = null) + { + if (is_array($dbTimestampId)) { + $useMinMax = false; + if (isset($dbTimestampId['min'])) { + $this->addUsingAlias(CcListenerCountPeer::TIMESTAMP_ID, $dbTimestampId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbTimestampId['max'])) { + $this->addUsingAlias(CcListenerCountPeer::TIMESTAMP_ID, $dbTimestampId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcListenerCountPeer::TIMESTAMP_ID, $dbTimestampId, $comparison); + } + + /** + * Filter the query on the mount_name_id column + * + * Example usage: + * + * $query->filterByDbMountNameId(1234); // WHERE mount_name_id = 1234 + * $query->filterByDbMountNameId(array(12, 34)); // WHERE mount_name_id IN (12, 34) + * $query->filterByDbMountNameId(array('min' => 12)); // WHERE mount_name_id >= 12 + * $query->filterByDbMountNameId(array('max' => 12)); // WHERE mount_name_id <= 12 + * + * + * @see filterByCcMountName() + * + * @param mixed $dbMountNameId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcListenerCountQuery The current query, for fluid interface + */ + public function filterByDbMountNameId($dbMountNameId = null, $comparison = null) + { + if (is_array($dbMountNameId)) { + $useMinMax = false; + if (isset($dbMountNameId['min'])) { + $this->addUsingAlias(CcListenerCountPeer::MOUNT_NAME_ID, $dbMountNameId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbMountNameId['max'])) { + $this->addUsingAlias(CcListenerCountPeer::MOUNT_NAME_ID, $dbMountNameId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcListenerCountPeer::MOUNT_NAME_ID, $dbMountNameId, $comparison); + } + + /** + * Filter the query on the listener_count column + * + * Example usage: + * + * $query->filterByDbListenerCount(1234); // WHERE listener_count = 1234 + * $query->filterByDbListenerCount(array(12, 34)); // WHERE listener_count IN (12, 34) + * $query->filterByDbListenerCount(array('min' => 12)); // WHERE listener_count >= 12 + * $query->filterByDbListenerCount(array('max' => 12)); // WHERE listener_count <= 12 + * + * + * @param mixed $dbListenerCount The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcListenerCountQuery The current query, for fluid interface + */ + public function filterByDbListenerCount($dbListenerCount = null, $comparison = null) + { + if (is_array($dbListenerCount)) { + $useMinMax = false; + if (isset($dbListenerCount['min'])) { + $this->addUsingAlias(CcListenerCountPeer::LISTENER_COUNT, $dbListenerCount['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbListenerCount['max'])) { + $this->addUsingAlias(CcListenerCountPeer::LISTENER_COUNT, $dbListenerCount['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcListenerCountPeer::LISTENER_COUNT, $dbListenerCount, $comparison); + } + + /** + * Filter the query by a related CcTimestamp object + * + * @param CcTimestamp|PropelObjectCollection $ccTimestamp The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcListenerCountQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcTimestamp($ccTimestamp, $comparison = null) + { + if ($ccTimestamp instanceof CcTimestamp) { + return $this + ->addUsingAlias(CcListenerCountPeer::TIMESTAMP_ID, $ccTimestamp->getDbId(), $comparison); + } elseif ($ccTimestamp instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcListenerCountPeer::TIMESTAMP_ID, $ccTimestamp->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcTimestamp() only accepts arguments of type CcTimestamp or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcTimestamp relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcListenerCountQuery The current query, for fluid interface + */ + public function joinCcTimestamp($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcTimestamp'); + + // 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, 'CcTimestamp'); + } + + return $this; + } + + /** + * Use the CcTimestamp relation CcTimestamp 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 \Airtime\CcTimestampQuery A secondary query class using the current class as primary query + */ + public function useCcTimestampQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcTimestamp($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcTimestamp', '\Airtime\CcTimestampQuery'); + } + + /** + * Filter the query by a related CcMountName object + * + * @param CcMountName|PropelObjectCollection $ccMountName The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcListenerCountQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcMountName($ccMountName, $comparison = null) + { + if ($ccMountName instanceof CcMountName) { + return $this + ->addUsingAlias(CcListenerCountPeer::MOUNT_NAME_ID, $ccMountName->getDbId(), $comparison); + } elseif ($ccMountName instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcListenerCountPeer::MOUNT_NAME_ID, $ccMountName->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcMountName() only accepts arguments of type CcMountName or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcMountName relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcListenerCountQuery The current query, for fluid interface + */ + public function joinCcMountName($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcMountName'); + + // 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, 'CcMountName'); + } + + return $this; + } + + /** + * Use the CcMountName relation CcMountName 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 \Airtime\CcMountNameQuery A secondary query class using the current class as primary query + */ + public function useCcMountNameQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcMountName($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcMountName', '\Airtime\CcMountNameQuery'); + } + + /** + * Exclude object from result + * + * @param CcListenerCount $ccListenerCount Object to remove from the list of results + * + * @return CcListenerCountQuery The current query, for fluid interface + */ + public function prune($ccListenerCount = null) + { + if ($ccListenerCount) { + $this->addUsingAlias(CcListenerCountPeer::ID, $ccListenerCount->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcLiveLog.php b/airtime_mvc/application/models/airtime/om/BaseCcLiveLog.php index 583630ee6..9bfb4f6e8 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcLiveLog.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcLiveLog.php @@ -1,916 +1,1008 @@ id; - } - - /** - * Get the [state] column value. - * - * @return string - */ - public function getDbState() - { - return $this->state; - } - - /** - * 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 = 'Y-m-d H:i:s') - { - 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 = 'Y-m-d H:i:s') - { - 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); - } - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcLiveLog 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[] = CcLiveLogPeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [state] column. - * - * @param string $v new value - * @return CcLiveLog The current object (for fluent API support) - */ - public function setDbState($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->state !== $v) { - $this->state = $v; - $this->modifiedColumns[] = CcLiveLogPeer::STATE; - } - - return $this; - } // setDbState() - - /** - * 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 CcLiveLog 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('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_time = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); - $this->modifiedColumns[] = CcLiveLogPeer::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 CcLiveLog 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('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->end_time = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); - $this->modifiedColumns[] = CcLiveLogPeer::END_TIME; - } - } // if either are not null - - return $this; - } // setDbEndTime() - - /** - * 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->state = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->start_time = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->end_time = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 4; // 4 = CcLiveLogPeer::NUM_COLUMNS - CcLiveLogPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcLiveLog 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(CcLiveLogPeer::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 = CcLiveLogPeer::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(CcLiveLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcLiveLogQuery::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(CcLiveLogPeer::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); - CcLiveLogPeer::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[] = CcLiveLogPeer::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(CcLiveLogPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcLiveLogPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows = 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows = CcLiveLogPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CcLiveLogPeer::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 = CcLiveLogPeer::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->getDbState(); - break; - case 2: - return $this->getDbStartTime(); - break; - case 3: - return $this->getDbEndTime(); - 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 = CcLiveLogPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbState(), - $keys[2] => $this->getDbStartTime(), - $keys[3] => $this->getDbEndTime(), - ); - 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 = CcLiveLogPeer::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->setDbState($value); - break; - case 2: - $this->setDbStartTime($value); - break; - case 3: - $this->setDbEndTime($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 = CcLiveLogPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbState($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbStartTime($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbEndTime($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(CcLiveLogPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcLiveLogPeer::ID)) $criteria->add(CcLiveLogPeer::ID, $this->id); - if ($this->isColumnModified(CcLiveLogPeer::STATE)) $criteria->add(CcLiveLogPeer::STATE, $this->state); - if ($this->isColumnModified(CcLiveLogPeer::START_TIME)) $criteria->add(CcLiveLogPeer::START_TIME, $this->start_time); - if ($this->isColumnModified(CcLiveLogPeer::END_TIME)) $criteria->add(CcLiveLogPeer::END_TIME, $this->end_time); - - 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(CcLiveLogPeer::DATABASE_NAME); - $criteria->add(CcLiveLogPeer::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 CcLiveLog (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->setDbState($this->state); - $copyObj->setDbStartTime($this->start_time); - $copyObj->setDbEndTime($this->end_time); - - $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 CcLiveLog 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 CcLiveLogPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcLiveLogPeer(); - } - return self::$peer; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->state = null; - $this->start_time = null; - $this->end_time = 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); - } - -} // BaseCcLiveLog + /** + * Peer class name + */ + const PEER = 'Airtime\\CcLiveLogPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcLiveLogPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the state field. + * @var string + */ + protected $state; + + /** + * The value for the start_time field. + * @var string + */ + protected $start_time; + + /** + * The value for the end_time field. + * @var string + */ + protected $end_time; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * Get the [id] column value. + * + * @return int + */ + public function getDbId() + { + + return $this->id; + } + + /** + * Get the [state] column value. + * + * @return string + */ + public function getDbState() + { + + return $this->state; + } + + /** + * 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 = 'Y-m-d H:i:s') + { + 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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + 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 = 'Y-m-d H:i:s') + { + 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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcLiveLog The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcLiveLogPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [state] column. + * + * @param string $v new value + * @return CcLiveLog The current object (for fluent API support) + */ + public function setDbState($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->state !== $v) { + $this->state = $v; + $this->modifiedColumns[] = CcLiveLogPeer::STATE; + } + + + return $this; + } // setDbState() + + /** + * 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 strings are treated as null. + * @return CcLiveLog The current object (for fluent API support) + */ + public function setDbStartTime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->start_time !== null || $dt !== null) { + $currentDateAsString = ($this->start_time !== null && $tmpDt = new DateTime($this->start_time)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->start_time = $newDateAsString; + $this->modifiedColumns[] = CcLiveLogPeer::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 strings are treated as null. + * @return CcLiveLog The current object (for fluent API support) + */ + public function setDbEndTime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->end_time !== null || $dt !== null) { + $currentDateAsString = ($this->end_time !== null && $tmpDt = new DateTime($this->end_time)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->end_time = $newDateAsString; + $this->modifiedColumns[] = CcLiveLogPeer::END_TIME; + } + } // if either are not null + + + return $this; + } // setDbEndTime() + + /** + * 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 resultset 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->state = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->start_time = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->end_time = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 4; // 4 = CcLiveLogPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcLiveLog 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(CcLiveLogPeer::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 = CcLiveLogPeer::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 + * @throws Exception + * @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(CcLiveLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcLiveLogQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcLiveLogPeer::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); + CcLiveLogPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcLiveLogPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcLiveLogPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_live_log_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcLiveLogPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcLiveLogPeer::STATE)) { + $modifiedColumns[':p' . $index++] = '"state"'; + } + if ($this->isColumnModified(CcLiveLogPeer::START_TIME)) { + $modifiedColumns[':p' . $index++] = '"start_time"'; + } + if ($this->isColumnModified(CcLiveLogPeer::END_TIME)) { + $modifiedColumns[':p' . $index++] = '"end_time"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_live_log" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"state"': + $stmt->bindValue($identifier, $this->state, PDO::PARAM_STR); + break; + case '"start_time"': + $stmt->bindValue($identifier, $this->start_time, PDO::PARAM_STR); + break; + case '"end_time"': + $stmt->bindValue($identifier, $this->end_time, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcLiveLogPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcLiveLogPeer::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->getDbState(); + break; + case 2: + return $this->getDbStartTime(); + break; + case 3: + return $this->getDbEndTime(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) + { + if (isset($alreadyDumpedObjects['CcLiveLog'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcLiveLog'][$this->getPrimaryKey()] = true; + $keys = CcLiveLogPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbState(), + $keys[2] => $this->getDbStartTime(), + $keys[3] => $this->getDbEndTime(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcLiveLogPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbState($value); + break; + case 2: + $this->setDbStartTime($value); + break; + case 3: + $this->setDbEndTime($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcLiveLogPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbState($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbStartTime($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbEndTime($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(CcLiveLogPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcLiveLogPeer::ID)) $criteria->add(CcLiveLogPeer::ID, $this->id); + if ($this->isColumnModified(CcLiveLogPeer::STATE)) $criteria->add(CcLiveLogPeer::STATE, $this->state); + if ($this->isColumnModified(CcLiveLogPeer::START_TIME)) $criteria->add(CcLiveLogPeer::START_TIME, $this->start_time); + if ($this->isColumnModified(CcLiveLogPeer::END_TIME)) $criteria->add(CcLiveLogPeer::END_TIME, $this->end_time); + + 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(CcLiveLogPeer::DATABASE_NAME); + $criteria->add(CcLiveLogPeer::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 CcLiveLog (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbState($this->getDbState()); + $copyObj->setDbStartTime($this->getDbStartTime()); + $copyObj->setDbEndTime($this->getDbEndTime()); + if ($makeNew) { + $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 CcLiveLog 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 CcLiveLogPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcLiveLogPeer(); + } + + return self::$peer; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->state = null; + $this->start_time = null; + $this->end_time = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcLiveLogPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcLiveLogPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcLiveLogPeer.php index 0a8cb69c5..f9a4f7f6b 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcLiveLogPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcLiveLogPeer.php @@ -1,745 +1,779 @@ array ('DbId', 'DbState', 'DbStartTime', 'DbEndTime', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbState', 'dbStartTime', 'dbEndTime', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::STATE, self::START_TIME, self::END_TIME, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STATE', 'START_TIME', 'END_TIME', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'state', 'start_time', 'end_time', ), - 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 ('DbId' => 0, 'DbState' => 1, 'DbStartTime' => 2, 'DbEndTime' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbState' => 1, 'dbStartTime' => 2, 'dbEndTime' => 3, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STATE => 1, self::START_TIME => 2, self::END_TIME => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STATE' => 1, 'START_TIME' => 2, 'END_TIME' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'state' => 1, 'start_time' => 2, 'end_time' => 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. CcLiveLogPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcLiveLogPeer::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(CcLiveLogPeer::ID); - $criteria->addSelectColumn(CcLiveLogPeer::STATE); - $criteria->addSelectColumn(CcLiveLogPeer::START_TIME); - $criteria->addSelectColumn(CcLiveLogPeer::END_TIME); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.STATE'); - $criteria->addSelectColumn($alias . '.START_TIME'); - $criteria->addSelectColumn($alias . '.END_TIME'); - } - } - - /** - * 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(CcLiveLogPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcLiveLogPeer::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(CcLiveLogPeer::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 CcLiveLog - * @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 = CcLiveLogPeer::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 CcLiveLogPeer::populateObjects(CcLiveLogPeer::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(CcLiveLogPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcLiveLogPeer::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 CcLiveLog $value A CcLiveLog object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcLiveLog $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 CcLiveLog object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcLiveLog) { - $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 CcLiveLog 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 CcLiveLog 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_live_log - * 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 = CcLiveLogPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcLiveLogPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcLiveLogPeer::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; - CcLiveLogPeer::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 (CcLiveLog object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcLiveLogPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcLiveLogPeer::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 + CcLiveLogPeer::NUM_COLUMNS; - } else { - $cls = CcLiveLogPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcLiveLogPeer::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(BaseCcLiveLogPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcLiveLogPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcLiveLogTableMap()); - } - } - - /** - * 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 ? CcLiveLogPeer::CLASS_DEFAULT : CcLiveLogPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcLiveLog or Criteria object. - * - * @param mixed $values Criteria or CcLiveLog 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(CcLiveLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcLiveLog object - } - - if ($criteria->containsKey(CcLiveLogPeer::ID) && $criteria->keyContainsValue(CcLiveLogPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcLiveLogPeer::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 CcLiveLog or Criteria object. - * - * @param mixed $values Criteria or CcLiveLog 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(CcLiveLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcLiveLogPeer::ID); - $value = $criteria->remove(CcLiveLogPeer::ID); - if ($value) { - $selectCriteria->add(CcLiveLogPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcLiveLogPeer::TABLE_NAME); - } - - } else { // $values is CcLiveLog 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_live_log 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(CcLiveLogPeer::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(CcLiveLogPeer::TABLE_NAME, $con, CcLiveLogPeer::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). - CcLiveLogPeer::clearInstancePool(); - CcLiveLogPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcLiveLog or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcLiveLog 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(CcLiveLogPeer::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. - CcLiveLogPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcLiveLog) { // it's a model object - // invalidate the cache for this single object - CcLiveLogPeer::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(CcLiveLogPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcLiveLogPeer::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); - CcLiveLogPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcLiveLog 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 CcLiveLog $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(CcLiveLog $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcLiveLogPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcLiveLogPeer::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(CcLiveLogPeer::DATABASE_NAME, CcLiveLogPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcLiveLog - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcLiveLogPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcLiveLogPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcLiveLogPeer::DATABASE_NAME); - $criteria->add(CcLiveLogPeer::ID, $pk); - - $v = CcLiveLogPeer::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(CcLiveLogPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcLiveLogPeer::DATABASE_NAME); - $criteria->add(CcLiveLogPeer::ID, $pks, Criteria::IN); - $objs = CcLiveLogPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcLiveLogPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_live_log'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcLiveLog'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcLiveLogTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 4; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 4; + + /** the column name for the id field */ + const ID = 'cc_live_log.id'; + + /** the column name for the state field */ + const STATE = 'cc_live_log.state'; + + /** the column name for the start_time field */ + const START_TIME = 'cc_live_log.start_time'; + + /** the column name for the end_time field */ + const END_TIME = 'cc_live_log.end_time'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcLiveLog objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcLiveLog[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcLiveLogPeer::$fieldNames[CcLiveLogPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbState', 'DbStartTime', 'DbEndTime', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbState', 'dbStartTime', 'dbEndTime', ), + BasePeer::TYPE_COLNAME => array (CcLiveLogPeer::ID, CcLiveLogPeer::STATE, CcLiveLogPeer::START_TIME, CcLiveLogPeer::END_TIME, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STATE', 'START_TIME', 'END_TIME', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'state', 'start_time', 'end_time', ), + 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. CcLiveLogPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbState' => 1, 'DbStartTime' => 2, 'DbEndTime' => 3, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbState' => 1, 'dbStartTime' => 2, 'dbEndTime' => 3, ), + BasePeer::TYPE_COLNAME => array (CcLiveLogPeer::ID => 0, CcLiveLogPeer::STATE => 1, CcLiveLogPeer::START_TIME => 2, CcLiveLogPeer::END_TIME => 3, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STATE' => 1, 'START_TIME' => 2, 'END_TIME' => 3, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'state' => 1, 'start_time' => 2, 'end_time' => 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcLiveLogPeer::getFieldNames($toType); + $key = isset(CcLiveLogPeer::$fieldKeys[$fromType][$name]) ? CcLiveLogPeer::$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(CcLiveLogPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcLiveLogPeer::$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 CcLiveLogPeer::$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. CcLiveLogPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcLiveLogPeer::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(CcLiveLogPeer::ID); + $criteria->addSelectColumn(CcLiveLogPeer::STATE); + $criteria->addSelectColumn(CcLiveLogPeer::START_TIME); + $criteria->addSelectColumn(CcLiveLogPeer::END_TIME); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.state'); + $criteria->addSelectColumn($alias . '.start_time'); + $criteria->addSelectColumn($alias . '.end_time'); + } + } + + /** + * 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(CcLiveLogPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcLiveLogPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcLiveLogPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcLiveLogPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcLiveLog + * @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 = CcLiveLogPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcLiveLogPeer::populateObjects(CcLiveLogPeer::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 directly (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(CcLiveLogPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcLiveLogPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcLiveLogPeer::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 CcLiveLog $obj A CcLiveLog object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcLiveLogPeer::$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 CcLiveLog object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcLiveLog) { + $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 CcLiveLog object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcLiveLogPeer::$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 CcLiveLog 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(CcLiveLogPeer::$instances[$key])) { + return CcLiveLogPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcLiveLogPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcLiveLogPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_live_log + * 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 = CcLiveLogPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcLiveLogPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcLiveLogPeer::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; + CcLiveLogPeer::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 (CcLiveLog object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcLiveLogPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcLiveLogPeer::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 + CcLiveLogPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcLiveLogPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcLiveLogPeer::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(CcLiveLogPeer::DATABASE_NAME)->getTable(CcLiveLogPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcLiveLogPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcLiveLogPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcLiveLogTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcLiveLogPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcLiveLog or Criteria object. + * + * @param mixed $values Criteria or CcLiveLog 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(CcLiveLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcLiveLog object + } + + if ($criteria->containsKey(CcLiveLogPeer::ID) && $criteria->keyContainsValue(CcLiveLogPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcLiveLogPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcLiveLogPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcLiveLog or Criteria object. + * + * @param mixed $values Criteria or CcLiveLog 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(CcLiveLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcLiveLogPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcLiveLogPeer::ID); + $value = $criteria->remove(CcLiveLogPeer::ID); + if ($value) { + $selectCriteria->add(CcLiveLogPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcLiveLogPeer::TABLE_NAME); + } + + } else { // $values is CcLiveLog object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcLiveLogPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_live_log table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcLiveLogPeer::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(CcLiveLogPeer::TABLE_NAME, $con, CcLiveLogPeer::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). + CcLiveLogPeer::clearInstancePool(); + CcLiveLogPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcLiveLog or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcLiveLog 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(CcLiveLogPeer::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. + CcLiveLogPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcLiveLog) { // it's a model object + // invalidate the cache for this single object + CcLiveLogPeer::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(CcLiveLogPeer::DATABASE_NAME); + $criteria->add(CcLiveLogPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcLiveLogPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcLiveLogPeer::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); + CcLiveLogPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcLiveLog 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 CcLiveLog $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcLiveLogPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcLiveLogPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcLiveLogPeer::DATABASE_NAME, CcLiveLogPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcLiveLog + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcLiveLogPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcLiveLogPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcLiveLogPeer::DATABASE_NAME); + $criteria->add(CcLiveLogPeer::ID, $pk); + + $v = CcLiveLogPeer::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 + * @return CcLiveLog[] + * @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(CcLiveLogPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcLiveLogPeer::DATABASE_NAME); + $criteria->add(CcLiveLogPeer::ID, $pks, Criteria::IN); + $objs = CcLiveLogPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcLiveLogPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcLiveLogQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcLiveLogQuery.php index 723d568de..fdfb3c459 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcLiveLogQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcLiveLogQuery.php @@ -1,261 +1,416 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcLiveLog|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcLiveLogPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcLiveLog|CcLiveLog[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcLiveLogPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcLiveLogPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcLiveLogQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcLiveLogPeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcLiveLog A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcLiveLogQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcLiveLogPeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcLiveLog A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "state", "start_time", "end_time" FROM "cc_live_log" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcLiveLog(); + $obj->hydrate($row); + CcLiveLogPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcLiveLogQuery 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(CcLiveLogPeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * 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 CcLiveLogQuery 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(CcLiveLogPeer::STATE, $dbState, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcLiveLog|CcLiveLog[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * 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 CcLiveLogQuery 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(CcLiveLogPeer::START_TIME, $dbStartTime['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbStartTime['max'])) { - $this->addUsingAlias(CcLiveLogPeer::START_TIME, $dbStartTime['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcLiveLogPeer::START_TIME, $dbStartTime, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * 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 CcLiveLogQuery 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(CcLiveLogPeer::END_TIME, $dbEndTime['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbEndTime['max'])) { - $this->addUsingAlias(CcLiveLogPeer::END_TIME, $dbEndTime['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcLiveLogPeer::END_TIME, $dbEndTime, $comparison); - } + /** + * 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|CcLiveLog[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Exclude object from result - * - * @param CcLiveLog $ccLiveLog Object to remove from the list of results - * - * @return CcLiveLogQuery The current query, for fluid interface - */ - public function prune($ccLiveLog = null) - { - if ($ccLiveLog) { - $this->addUsingAlias(CcLiveLogPeer::ID, $ccLiveLog->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } -} // BaseCcLiveLogQuery + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcLiveLogQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(CcLiveLogPeer::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 CcLiveLogQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(CcLiveLogPeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcLiveLogQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcLiveLogPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcLiveLogPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcLiveLogPeer::ID, $dbId, $comparison); + } + + /** + * Filter the query on the state column + * + * Example usage: + * + * $query->filterByDbState('fooValue'); // WHERE state = 'fooValue' + * $query->filterByDbState('%fooValue%'); // WHERE state LIKE '%fooValue%' + * + * + * @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 CcLiveLogQuery 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(CcLiveLogPeer::STATE, $dbState, $comparison); + } + + /** + * Filter the query on the start_time column + * + * Example usage: + * + * $query->filterByDbStartTime('2011-03-14'); // WHERE start_time = '2011-03-14' + * $query->filterByDbStartTime('now'); // WHERE start_time = '2011-03-14' + * $query->filterByDbStartTime(array('max' => 'yesterday')); // WHERE start_time < '2011-03-13' + * + * + * @param mixed $dbStartTime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcLiveLogQuery 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(CcLiveLogPeer::START_TIME, $dbStartTime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbStartTime['max'])) { + $this->addUsingAlias(CcLiveLogPeer::START_TIME, $dbStartTime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcLiveLogPeer::START_TIME, $dbStartTime, $comparison); + } + + /** + * Filter the query on the end_time column + * + * Example usage: + * + * $query->filterByDbEndTime('2011-03-14'); // WHERE end_time = '2011-03-14' + * $query->filterByDbEndTime('now'); // WHERE end_time = '2011-03-14' + * $query->filterByDbEndTime(array('max' => 'yesterday')); // WHERE end_time < '2011-03-13' + * + * + * @param mixed $dbEndTime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcLiveLogQuery 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(CcLiveLogPeer::END_TIME, $dbEndTime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbEndTime['max'])) { + $this->addUsingAlias(CcLiveLogPeer::END_TIME, $dbEndTime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcLiveLogPeer::END_TIME, $dbEndTime, $comparison); + } + + /** + * Exclude object from result + * + * @param CcLiveLog $ccLiveLog Object to remove from the list of results + * + * @return CcLiveLogQuery The current query, for fluid interface + */ + public function prune($ccLiveLog = null) + { + if ($ccLiveLog) { + $this->addUsingAlias(CcLiveLogPeer::ID, $ccLiveLog->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcLocale.php b/airtime_mvc/application/models/airtime/om/BaseCcLocale.php index fdd4d43d8..bc1d0f027 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcLocale.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcLocale.php @@ -1,764 +1,898 @@ id; - } - - /** - * Get the [locale_code] column value. - * - * @return string - */ - public function getDbLocaleCode() - { - return $this->locale_code; - } - - /** - * Get the [locale_lang] column value. - * - * @return string - */ - public function getDbLocaleLang() - { - return $this->locale_lang; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcLocale 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[] = CcLocalePeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [locale_code] column. - * - * @param string $v new value - * @return CcLocale The current object (for fluent API support) - */ - public function setDbLocaleCode($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->locale_code !== $v) { - $this->locale_code = $v; - $this->modifiedColumns[] = CcLocalePeer::LOCALE_CODE; - } - - return $this; - } // setDbLocaleCode() - - /** - * Set the value of [locale_lang] column. - * - * @param string $v new value - * @return CcLocale The current object (for fluent API support) - */ - public function setDbLocaleLang($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->locale_lang !== $v) { - $this->locale_lang = $v; - $this->modifiedColumns[] = CcLocalePeer::LOCALE_LANG; - } - - return $this; - } // setDbLocaleLang() - - /** - * 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->locale_code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->locale_lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 3; // 3 = CcLocalePeer::NUM_COLUMNS - CcLocalePeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcLocale 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(CcLocalePeer::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 = CcLocalePeer::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(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcLocaleQuery::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(CcLocalePeer::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); - CcLocalePeer::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[] = CcLocalePeer::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(CcLocalePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcLocalePeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows = 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows = CcLocalePeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CcLocalePeer::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 = CcLocalePeer::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->getDbLocaleCode(); - break; - case 2: - return $this->getDbLocaleLang(); - 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 = CcLocalePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbLocaleCode(), - $keys[2] => $this->getDbLocaleLang(), - ); - 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 = CcLocalePeer::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->setDbLocaleCode($value); - break; - case 2: - $this->setDbLocaleLang($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 = CcLocalePeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbLocaleCode($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbLocaleLang($arr[$keys[2]]); - } - - /** - * 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(CcLocalePeer::DATABASE_NAME); - - if ($this->isColumnModified(CcLocalePeer::ID)) $criteria->add(CcLocalePeer::ID, $this->id); - if ($this->isColumnModified(CcLocalePeer::LOCALE_CODE)) $criteria->add(CcLocalePeer::LOCALE_CODE, $this->locale_code); - if ($this->isColumnModified(CcLocalePeer::LOCALE_LANG)) $criteria->add(CcLocalePeer::LOCALE_LANG, $this->locale_lang); - - 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(CcLocalePeer::DATABASE_NAME); - $criteria->add(CcLocalePeer::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 CcLocale (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->setDbLocaleCode($this->locale_code); - $copyObj->setDbLocaleLang($this->locale_lang); - - $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 CcLocale 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 CcLocalePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcLocalePeer(); - } - return self::$peer; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale_code = null; - $this->locale_lang = 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); - } - -} // BaseCcLocale + /** + * Peer class name + */ + const PEER = 'Airtime\\CcLocalePeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcLocalePeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the locale_code field. + * @var string + */ + protected $locale_code; + + /** + * The value for the locale_lang field. + * @var string + */ + protected $locale_lang; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * Get the [id] column value. + * + * @return int + */ + public function getDbId() + { + + return $this->id; + } + + /** + * Get the [locale_code] column value. + * + * @return string + */ + public function getDbLocaleCode() + { + + return $this->locale_code; + } + + /** + * Get the [locale_lang] column value. + * + * @return string + */ + public function getDbLocaleLang() + { + + return $this->locale_lang; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcLocale The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcLocalePeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [locale_code] column. + * + * @param string $v new value + * @return CcLocale The current object (for fluent API support) + */ + public function setDbLocaleCode($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->locale_code !== $v) { + $this->locale_code = $v; + $this->modifiedColumns[] = CcLocalePeer::LOCALE_CODE; + } + + + return $this; + } // setDbLocaleCode() + + /** + * Set the value of [locale_lang] column. + * + * @param string $v new value + * @return CcLocale The current object (for fluent API support) + */ + public function setDbLocaleLang($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->locale_lang !== $v) { + $this->locale_lang = $v; + $this->modifiedColumns[] = CcLocalePeer::LOCALE_LANG; + } + + + return $this; + } // setDbLocaleLang() + + /** + * 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 resultset 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->locale_code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->locale_lang = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 3; // 3 = CcLocalePeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcLocale 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(CcLocalePeer::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 = CcLocalePeer::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 + * @throws Exception + * @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(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcLocaleQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcLocalePeer::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); + CcLocalePeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcLocalePeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcLocalePeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_locale_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcLocalePeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcLocalePeer::LOCALE_CODE)) { + $modifiedColumns[':p' . $index++] = '"locale_code"'; + } + if ($this->isColumnModified(CcLocalePeer::LOCALE_LANG)) { + $modifiedColumns[':p' . $index++] = '"locale_lang"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_locale" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"locale_code"': + $stmt->bindValue($identifier, $this->locale_code, PDO::PARAM_STR); + break; + case '"locale_lang"': + $stmt->bindValue($identifier, $this->locale_lang, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcLocalePeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcLocalePeer::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->getDbLocaleCode(); + break; + case 2: + return $this->getDbLocaleLang(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) + { + if (isset($alreadyDumpedObjects['CcLocale'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcLocale'][$this->getPrimaryKey()] = true; + $keys = CcLocalePeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbLocaleCode(), + $keys[2] => $this->getDbLocaleLang(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcLocalePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbLocaleCode($value); + break; + case 2: + $this->setDbLocaleLang($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcLocalePeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbLocaleCode($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbLocaleLang($arr[$keys[2]]); + } + + /** + * 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(CcLocalePeer::DATABASE_NAME); + + if ($this->isColumnModified(CcLocalePeer::ID)) $criteria->add(CcLocalePeer::ID, $this->id); + if ($this->isColumnModified(CcLocalePeer::LOCALE_CODE)) $criteria->add(CcLocalePeer::LOCALE_CODE, $this->locale_code); + if ($this->isColumnModified(CcLocalePeer::LOCALE_LANG)) $criteria->add(CcLocalePeer::LOCALE_LANG, $this->locale_lang); + + 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(CcLocalePeer::DATABASE_NAME); + $criteria->add(CcLocalePeer::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 CcLocale (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbLocaleCode($this->getDbLocaleCode()); + $copyObj->setDbLocaleLang($this->getDbLocaleLang()); + if ($makeNew) { + $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 CcLocale 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 CcLocalePeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcLocalePeer(); + } + + return self::$peer; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->locale_code = null; + $this->locale_lang = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcLocalePeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcLocalePeer.php b/airtime_mvc/application/models/airtime/om/BaseCcLocalePeer.php index eebb6a002..2cfecfe92 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcLocalePeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcLocalePeer.php @@ -1,740 +1,774 @@ array ('DbId', 'DbLocaleCode', 'DbLocaleLang', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbLocaleCode', 'dbLocaleLang', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::LOCALE_CODE, self::LOCALE_LANG, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE_CODE', 'LOCALE_LANG', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale_code', 'locale_lang', ), - BasePeer::TYPE_NUM => array (0, 1, 2, ) - ); - - /** - * 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, 'DbLocaleCode' => 1, 'DbLocaleLang' => 2, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbLocaleCode' => 1, 'dbLocaleLang' => 2, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::LOCALE_CODE => 1, self::LOCALE_LANG => 2, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE_CODE' => 1, 'LOCALE_LANG' => 2, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale_code' => 1, 'locale_lang' => 2, ), - BasePeer::TYPE_NUM => array (0, 1, 2, ) - ); - - /** - * 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. CcLocalePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcLocalePeer::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(CcLocalePeer::ID); - $criteria->addSelectColumn(CcLocalePeer::LOCALE_CODE); - $criteria->addSelectColumn(CcLocalePeer::LOCALE_LANG); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE_CODE'); - $criteria->addSelectColumn($alias . '.LOCALE_LANG'); - } - } - - /** - * 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(CcLocalePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcLocalePeer::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(CcLocalePeer::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 CcLocale - * @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 = CcLocalePeer::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 CcLocalePeer::populateObjects(CcLocalePeer::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(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcLocalePeer::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 CcLocale $value A CcLocale object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcLocale $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 CcLocale object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcLocale) { - $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 CcLocale 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 CcLocale 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_locale - * 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 = CcLocalePeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcLocalePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcLocalePeer::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; - CcLocalePeer::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 (CcLocale object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcLocalePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcLocalePeer::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 + CcLocalePeer::NUM_COLUMNS; - } else { - $cls = CcLocalePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcLocalePeer::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(BaseCcLocalePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcLocalePeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcLocaleTableMap()); - } - } - - /** - * 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 ? CcLocalePeer::CLASS_DEFAULT : CcLocalePeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcLocale or Criteria object. - * - * @param mixed $values Criteria or CcLocale 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(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcLocale object - } - - if ($criteria->containsKey(CcLocalePeer::ID) && $criteria->keyContainsValue(CcLocalePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcLocalePeer::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 CcLocale or Criteria object. - * - * @param mixed $values Criteria or CcLocale 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(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcLocalePeer::ID); - $value = $criteria->remove(CcLocalePeer::ID); - if ($value) { - $selectCriteria->add(CcLocalePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcLocalePeer::TABLE_NAME); - } - - } else { // $values is CcLocale 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_locale 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(CcLocalePeer::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(CcLocalePeer::TABLE_NAME, $con, CcLocalePeer::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). - CcLocalePeer::clearInstancePool(); - CcLocalePeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcLocale or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcLocale 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(CcLocalePeer::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. - CcLocalePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcLocale) { // it's a model object - // invalidate the cache for this single object - CcLocalePeer::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(CcLocalePeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcLocalePeer::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); - CcLocalePeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcLocale 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 CcLocale $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(CcLocale $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcLocalePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcLocalePeer::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(CcLocalePeer::DATABASE_NAME, CcLocalePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcLocale - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcLocalePeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcLocalePeer::DATABASE_NAME); - $criteria->add(CcLocalePeer::ID, $pk); - - $v = CcLocalePeer::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(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcLocalePeer::DATABASE_NAME); - $criteria->add(CcLocalePeer::ID, $pks, Criteria::IN); - $objs = CcLocalePeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcLocalePeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_locale'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcLocale'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcLocaleTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 3; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 3; + + /** the column name for the id field */ + const ID = 'cc_locale.id'; + + /** the column name for the locale_code field */ + const LOCALE_CODE = 'cc_locale.locale_code'; + + /** the column name for the locale_lang field */ + const LOCALE_LANG = 'cc_locale.locale_lang'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcLocale objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcLocale[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcLocalePeer::$fieldNames[CcLocalePeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbLocaleCode', 'DbLocaleLang', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbLocaleCode', 'dbLocaleLang', ), + BasePeer::TYPE_COLNAME => array (CcLocalePeer::ID, CcLocalePeer::LOCALE_CODE, CcLocalePeer::LOCALE_LANG, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE_CODE', 'LOCALE_LANG', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'locale_code', 'locale_lang', ), + BasePeer::TYPE_NUM => array (0, 1, 2, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcLocalePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbLocaleCode' => 1, 'DbLocaleLang' => 2, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbLocaleCode' => 1, 'dbLocaleLang' => 2, ), + BasePeer::TYPE_COLNAME => array (CcLocalePeer::ID => 0, CcLocalePeer::LOCALE_CODE => 1, CcLocalePeer::LOCALE_LANG => 2, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE_CODE' => 1, 'LOCALE_LANG' => 2, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale_code' => 1, 'locale_lang' => 2, ), + BasePeer::TYPE_NUM => array (0, 1, 2, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcLocalePeer::getFieldNames($toType); + $key = isset(CcLocalePeer::$fieldKeys[$fromType][$name]) ? CcLocalePeer::$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(CcLocalePeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcLocalePeer::$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 CcLocalePeer::$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. CcLocalePeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcLocalePeer::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(CcLocalePeer::ID); + $criteria->addSelectColumn(CcLocalePeer::LOCALE_CODE); + $criteria->addSelectColumn(CcLocalePeer::LOCALE_LANG); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.locale_code'); + $criteria->addSelectColumn($alias . '.locale_lang'); + } + } + + /** + * 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(CcLocalePeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcLocalePeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcLocalePeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcLocalePeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcLocale + * @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 = CcLocalePeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcLocalePeer::populateObjects(CcLocalePeer::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 directly (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(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcLocalePeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcLocalePeer::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 CcLocale $obj A CcLocale object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcLocalePeer::$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 CcLocale object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcLocale) { + $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 CcLocale object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcLocalePeer::$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 CcLocale 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(CcLocalePeer::$instances[$key])) { + return CcLocalePeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcLocalePeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcLocalePeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_locale + * 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 = CcLocalePeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcLocalePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcLocalePeer::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; + CcLocalePeer::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 (CcLocale object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcLocalePeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcLocalePeer::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 + CcLocalePeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcLocalePeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcLocalePeer::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(CcLocalePeer::DATABASE_NAME)->getTable(CcLocalePeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcLocalePeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcLocalePeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcLocaleTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcLocalePeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcLocale or Criteria object. + * + * @param mixed $values Criteria or CcLocale 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(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcLocale object + } + + if ($criteria->containsKey(CcLocalePeer::ID) && $criteria->keyContainsValue(CcLocalePeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcLocalePeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcLocalePeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcLocale or Criteria object. + * + * @param mixed $values Criteria or CcLocale 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(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcLocalePeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcLocalePeer::ID); + $value = $criteria->remove(CcLocalePeer::ID); + if ($value) { + $selectCriteria->add(CcLocalePeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcLocalePeer::TABLE_NAME); + } + + } else { // $values is CcLocale object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcLocalePeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_locale table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcLocalePeer::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(CcLocalePeer::TABLE_NAME, $con, CcLocalePeer::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). + CcLocalePeer::clearInstancePool(); + CcLocalePeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcLocale or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcLocale 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(CcLocalePeer::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. + CcLocalePeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcLocale) { // it's a model object + // invalidate the cache for this single object + CcLocalePeer::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(CcLocalePeer::DATABASE_NAME); + $criteria->add(CcLocalePeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcLocalePeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcLocalePeer::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); + CcLocalePeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcLocale 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 CcLocale $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcLocalePeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcLocalePeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcLocalePeer::DATABASE_NAME, CcLocalePeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcLocale + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcLocalePeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcLocalePeer::DATABASE_NAME); + $criteria->add(CcLocalePeer::ID, $pk); + + $v = CcLocalePeer::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 + * @return CcLocale[] + * @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(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcLocalePeer::DATABASE_NAME); + $criteria->add(CcLocalePeer::ID, $pks, Criteria::IN); + $objs = CcLocalePeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcLocalePeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcLocaleQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcLocaleQuery.php index e12a5971b..6c3b0d185 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcLocaleQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcLocaleQuery.php @@ -1,217 +1,355 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcLocale|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcLocalePeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcLocale|CcLocale[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcLocalePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcLocalePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcLocaleQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcLocalePeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcLocale A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcLocaleQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcLocalePeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcLocale A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "locale_code", "locale_lang" FROM "cc_locale" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcLocale(); + $obj->hydrate($row); + CcLocalePeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcLocaleQuery 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(CcLocalePeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * Filter the query on the locale_code column - * - * @param string $dbLocaleCode 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 CcLocaleQuery The current query, for fluid interface - */ - public function filterByDbLocaleCode($dbLocaleCode = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbLocaleCode)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbLocaleCode)) { - $dbLocaleCode = str_replace('*', '%', $dbLocaleCode); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcLocalePeer::LOCALE_CODE, $dbLocaleCode, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcLocale|CcLocale[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Filter the query on the locale_lang column - * - * @param string $dbLocaleLang 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 CcLocaleQuery The current query, for fluid interface - */ - public function filterByDbLocaleLang($dbLocaleLang = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbLocaleLang)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbLocaleLang)) { - $dbLocaleLang = str_replace('*', '%', $dbLocaleLang); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcLocalePeer::LOCALE_LANG, $dbLocaleLang, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Exclude object from result - * - * @param CcLocale $ccLocale Object to remove from the list of results - * - * @return CcLocaleQuery The current query, for fluid interface - */ - public function prune($ccLocale = null) - { - if ($ccLocale) { - $this->addUsingAlias(CcLocalePeer::ID, $ccLocale->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + /** + * 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|CcLocale[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); -} // BaseCcLocaleQuery + return $criteria->getFormatter()->init($criteria)->format($stmt); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcLocaleQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(CcLocalePeer::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 CcLocaleQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(CcLocalePeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcLocaleQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcLocalePeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcLocalePeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcLocalePeer::ID, $dbId, $comparison); + } + + /** + * Filter the query on the locale_code column + * + * Example usage: + * + * $query->filterByDbLocaleCode('fooValue'); // WHERE locale_code = 'fooValue' + * $query->filterByDbLocaleCode('%fooValue%'); // WHERE locale_code LIKE '%fooValue%' + * + * + * @param string $dbLocaleCode 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 CcLocaleQuery The current query, for fluid interface + */ + public function filterByDbLocaleCode($dbLocaleCode = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLocaleCode)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLocaleCode)) { + $dbLocaleCode = str_replace('*', '%', $dbLocaleCode); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcLocalePeer::LOCALE_CODE, $dbLocaleCode, $comparison); + } + + /** + * Filter the query on the locale_lang column + * + * Example usage: + * + * $query->filterByDbLocaleLang('fooValue'); // WHERE locale_lang = 'fooValue' + * $query->filterByDbLocaleLang('%fooValue%'); // WHERE locale_lang LIKE '%fooValue%' + * + * + * @param string $dbLocaleLang 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 CcLocaleQuery The current query, for fluid interface + */ + public function filterByDbLocaleLang($dbLocaleLang = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLocaleLang)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLocaleLang)) { + $dbLocaleLang = str_replace('*', '%', $dbLocaleLang); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcLocalePeer::LOCALE_LANG, $dbLocaleLang, $comparison); + } + + /** + * Exclude object from result + * + * @param CcLocale $ccLocale Object to remove from the list of results + * + * @return CcLocaleQuery The current query, for fluid interface + */ + public function prune($ccLocale = null) + { + if ($ccLocale) { + $this->addUsingAlias(CcLocalePeer::ID, $ccLocale->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcLoginAttempts.php b/airtime_mvc/application/models/airtime/om/BaseCcLoginAttempts.php index b529e12d5..afe912872 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcLoginAttempts.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcLoginAttempts.php @@ -1,735 +1,855 @@ attempts = 0; - } - - /** - * Initializes internal state of BaseCcLoginAttempts object. - * @see applyDefaults() - */ - public function __construct() - { - parent::__construct(); - $this->applyDefaultValues(); - } - - /** - * Get the [ip] column value. - * - * @return string - */ - public function getDbIP() - { - return $this->ip; - } - - /** - * Get the [attempts] column value. - * - * @return int - */ - public function getDbAttempts() - { - return $this->attempts; - } - - /** - * Set the value of [ip] column. - * - * @param string $v new value - * @return CcLoginAttempts The current object (for fluent API support) - */ - public function setDbIP($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->ip !== $v) { - $this->ip = $v; - $this->modifiedColumns[] = CcLoginAttemptsPeer::IP; - } - - return $this; - } // setDbIP() - - /** - * Set the value of [attempts] column. - * - * @param int $v new value - * @return CcLoginAttempts The current object (for fluent API support) - */ - public function setDbAttempts($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->attempts !== $v || $this->isNew()) { - $this->attempts = $v; - $this->modifiedColumns[] = CcLoginAttemptsPeer::ATTEMPTS; - } - - return $this; - } // setDbAttempts() - - /** - * 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->attempts !== 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->ip = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null; - $this->attempts = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 2; // 2 = CcLoginAttemptsPeer::NUM_COLUMNS - CcLoginAttemptsPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcLoginAttempts 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(CcLoginAttemptsPeer::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 = CcLoginAttemptsPeer::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(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcLoginAttemptsQuery::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(CcLoginAttemptsPeer::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); - CcLoginAttemptsPeer::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 = CcLoginAttemptsPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CcLoginAttemptsPeer::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 = CcLoginAttemptsPeer::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->getDbIP(); - break; - case 1: - return $this->getDbAttempts(); - 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 = CcLoginAttemptsPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbIP(), - $keys[1] => $this->getDbAttempts(), - ); - 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 = CcLoginAttemptsPeer::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->setDbIP($value); - break; - case 1: - $this->setDbAttempts($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 = CcLoginAttemptsPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbIP($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbAttempts($arr[$keys[1]]); - } - - /** - * 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(CcLoginAttemptsPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcLoginAttemptsPeer::IP)) $criteria->add(CcLoginAttemptsPeer::IP, $this->ip); - if ($this->isColumnModified(CcLoginAttemptsPeer::ATTEMPTS)) $criteria->add(CcLoginAttemptsPeer::ATTEMPTS, $this->attempts); - - 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(CcLoginAttemptsPeer::DATABASE_NAME); - $criteria->add(CcLoginAttemptsPeer::IP, $this->ip); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return string - */ - public function getPrimaryKey() - { - return $this->getDbIP(); - } - - /** - * Generic method to set the primary key (ip column). - * - * @param string $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setDbIP($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - return null === $this->getDbIP(); - } - - /** - * 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 CcLoginAttempts (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->setDbIP($this->ip); - $copyObj->setDbAttempts($this->attempts); - - $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 CcLoginAttempts 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 CcLoginAttemptsPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcLoginAttemptsPeer(); - } - return self::$peer; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->ip = null; - $this->attempts = 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); - } - -} // BaseCcLoginAttempts + /** + * Peer class name + */ + const PEER = 'Airtime\\CcLoginAttemptsPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcLoginAttemptsPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the ip field. + * @var string + */ + protected $ip; + + /** + * The value for the attempts field. + * Note: this column has a database default value of: 0 + * @var int + */ + protected $attempts; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->attempts = 0; + } + + /** + * Initializes internal state of BaseCcLoginAttempts object. + * @see applyDefaults() + */ + public function __construct() + { + parent::__construct(); + $this->applyDefaultValues(); + } + + /** + * Get the [ip] column value. + * + * @return string + */ + public function getDbIP() + { + + return $this->ip; + } + + /** + * Get the [attempts] column value. + * + * @return int + */ + public function getDbAttempts() + { + + return $this->attempts; + } + + /** + * Set the value of [ip] column. + * + * @param string $v new value + * @return CcLoginAttempts The current object (for fluent API support) + */ + public function setDbIP($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->ip !== $v) { + $this->ip = $v; + $this->modifiedColumns[] = CcLoginAttemptsPeer::IP; + } + + + return $this; + } // setDbIP() + + /** + * Set the value of [attempts] column. + * + * @param int $v new value + * @return CcLoginAttempts The current object (for fluent API support) + */ + public function setDbAttempts($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->attempts !== $v) { + $this->attempts = $v; + $this->modifiedColumns[] = CcLoginAttemptsPeer::ATTEMPTS; + } + + + return $this; + } // setDbAttempts() + + /** + * 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->attempts !== 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 resultset 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->ip = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null; + $this->attempts = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 2; // 2 = CcLoginAttemptsPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcLoginAttempts 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(CcLoginAttemptsPeer::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 = CcLoginAttemptsPeer::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 + * @throws Exception + * @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(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcLoginAttemptsQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcLoginAttemptsPeer::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); + CcLoginAttemptsPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcLoginAttemptsPeer::IP)) { + $modifiedColumns[':p' . $index++] = '"ip"'; + } + if ($this->isColumnModified(CcLoginAttemptsPeer::ATTEMPTS)) { + $modifiedColumns[':p' . $index++] = '"attempts"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_login_attempts" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"ip"': + $stmt->bindValue($identifier, $this->ip, PDO::PARAM_STR); + break; + case '"attempts"': + $stmt->bindValue($identifier, $this->attempts, PDO::PARAM_INT); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcLoginAttemptsPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcLoginAttemptsPeer::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->getDbIP(); + break; + case 1: + return $this->getDbAttempts(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) + { + if (isset($alreadyDumpedObjects['CcLoginAttempts'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcLoginAttempts'][$this->getPrimaryKey()] = true; + $keys = CcLoginAttemptsPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbIP(), + $keys[1] => $this->getDbAttempts(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcLoginAttemptsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbIP($value); + break; + case 1: + $this->setDbAttempts($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcLoginAttemptsPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbIP($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbAttempts($arr[$keys[1]]); + } + + /** + * 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(CcLoginAttemptsPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcLoginAttemptsPeer::IP)) $criteria->add(CcLoginAttemptsPeer::IP, $this->ip); + if ($this->isColumnModified(CcLoginAttemptsPeer::ATTEMPTS)) $criteria->add(CcLoginAttemptsPeer::ATTEMPTS, $this->attempts); + + 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(CcLoginAttemptsPeer::DATABASE_NAME); + $criteria->add(CcLoginAttemptsPeer::IP, $this->ip); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getDbIP(); + } + + /** + * Generic method to set the primary key (ip column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setDbIP($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getDbIP(); + } + + /** + * 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 CcLoginAttempts (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbAttempts($this->getDbAttempts()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setDbIP(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 CcLoginAttempts 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 CcLoginAttemptsPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcLoginAttemptsPeer(); + } + + return self::$peer; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->ip = null; + $this->attempts = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcLoginAttemptsPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcLoginAttemptsPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcLoginAttemptsPeer.php index 27b4cd90c..5995de8e4 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcLoginAttemptsPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcLoginAttemptsPeer.php @@ -1,731 +1,765 @@ array ('DbIP', 'DbAttempts', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbIP', 'dbAttempts', ), - BasePeer::TYPE_COLNAME => array (self::IP, self::ATTEMPTS, ), - BasePeer::TYPE_RAW_COLNAME => array ('IP', 'ATTEMPTS', ), - BasePeer::TYPE_FIELDNAME => array ('ip', 'attempts', ), - BasePeer::TYPE_NUM => array (0, 1, ) - ); - - /** - * 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 ('DbIP' => 0, 'DbAttempts' => 1, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbIP' => 0, 'dbAttempts' => 1, ), - BasePeer::TYPE_COLNAME => array (self::IP => 0, self::ATTEMPTS => 1, ), - BasePeer::TYPE_RAW_COLNAME => array ('IP' => 0, 'ATTEMPTS' => 1, ), - BasePeer::TYPE_FIELDNAME => array ('ip' => 0, 'attempts' => 1, ), - BasePeer::TYPE_NUM => array (0, 1, ) - ); - - /** - * 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. CcLoginAttemptsPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcLoginAttemptsPeer::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(CcLoginAttemptsPeer::IP); - $criteria->addSelectColumn(CcLoginAttemptsPeer::ATTEMPTS); - } else { - $criteria->addSelectColumn($alias . '.IP'); - $criteria->addSelectColumn($alias . '.ATTEMPTS'); - } - } - - /** - * 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(CcLoginAttemptsPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcLoginAttemptsPeer::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(CcLoginAttemptsPeer::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 CcLoginAttempts - * @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 = CcLoginAttemptsPeer::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 CcLoginAttemptsPeer::populateObjects(CcLoginAttemptsPeer::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(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcLoginAttemptsPeer::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 CcLoginAttempts $value A CcLoginAttempts object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcLoginAttempts $obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getDbIP(); - } // 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 CcLoginAttempts object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcLoginAttempts) { - $key = (string) $value->getDbIP(); - } 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 CcLoginAttempts 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 CcLoginAttempts 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_login_attempts - * 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 = CcLoginAttemptsPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcLoginAttemptsPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcLoginAttemptsPeer::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; - CcLoginAttemptsPeer::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 (CcLoginAttempts object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcLoginAttemptsPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcLoginAttemptsPeer::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 + CcLoginAttemptsPeer::NUM_COLUMNS; - } else { - $cls = CcLoginAttemptsPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcLoginAttemptsPeer::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(BaseCcLoginAttemptsPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcLoginAttemptsPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcLoginAttemptsTableMap()); - } - } - - /** - * 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 ? CcLoginAttemptsPeer::CLASS_DEFAULT : CcLoginAttemptsPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcLoginAttempts or Criteria object. - * - * @param mixed $values Criteria or CcLoginAttempts 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(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcLoginAttempts 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 CcLoginAttempts or Criteria object. - * - * @param mixed $values Criteria or CcLoginAttempts 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(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcLoginAttemptsPeer::IP); - $value = $criteria->remove(CcLoginAttemptsPeer::IP); - if ($value) { - $selectCriteria->add(CcLoginAttemptsPeer::IP, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcLoginAttemptsPeer::TABLE_NAME); - } - - } else { // $values is CcLoginAttempts 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_login_attempts 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(CcLoginAttemptsPeer::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(CcLoginAttemptsPeer::TABLE_NAME, $con, CcLoginAttemptsPeer::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). - CcLoginAttemptsPeer::clearInstancePool(); - CcLoginAttemptsPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcLoginAttempts or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcLoginAttempts 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(CcLoginAttemptsPeer::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. - CcLoginAttemptsPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcLoginAttempts) { // it's a model object - // invalidate the cache for this single object - CcLoginAttemptsPeer::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(CcLoginAttemptsPeer::IP, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcLoginAttemptsPeer::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); - CcLoginAttemptsPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcLoginAttempts 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 CcLoginAttempts $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(CcLoginAttempts $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcLoginAttemptsPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcLoginAttemptsPeer::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(CcLoginAttemptsPeer::DATABASE_NAME, CcLoginAttemptsPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param string $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcLoginAttempts - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcLoginAttemptsPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcLoginAttemptsPeer::DATABASE_NAME); - $criteria->add(CcLoginAttemptsPeer::IP, $pk); - - $v = CcLoginAttemptsPeer::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(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcLoginAttemptsPeer::DATABASE_NAME); - $criteria->add(CcLoginAttemptsPeer::IP, $pks, Criteria::IN); - $objs = CcLoginAttemptsPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcLoginAttemptsPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_login_attempts'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcLoginAttempts'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcLoginAttemptsTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 2; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 2; + + /** the column name for the ip field */ + const IP = 'cc_login_attempts.ip'; + + /** the column name for the attempts field */ + const ATTEMPTS = 'cc_login_attempts.attempts'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcLoginAttempts objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcLoginAttempts[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcLoginAttemptsPeer::$fieldNames[CcLoginAttemptsPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbIP', 'DbAttempts', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbIP', 'dbAttempts', ), + BasePeer::TYPE_COLNAME => array (CcLoginAttemptsPeer::IP, CcLoginAttemptsPeer::ATTEMPTS, ), + BasePeer::TYPE_RAW_COLNAME => array ('IP', 'ATTEMPTS', ), + BasePeer::TYPE_FIELDNAME => array ('ip', 'attempts', ), + BasePeer::TYPE_NUM => array (0, 1, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcLoginAttemptsPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbIP' => 0, 'DbAttempts' => 1, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbIP' => 0, 'dbAttempts' => 1, ), + BasePeer::TYPE_COLNAME => array (CcLoginAttemptsPeer::IP => 0, CcLoginAttemptsPeer::ATTEMPTS => 1, ), + BasePeer::TYPE_RAW_COLNAME => array ('IP' => 0, 'ATTEMPTS' => 1, ), + BasePeer::TYPE_FIELDNAME => array ('ip' => 0, 'attempts' => 1, ), + BasePeer::TYPE_NUM => array (0, 1, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcLoginAttemptsPeer::getFieldNames($toType); + $key = isset(CcLoginAttemptsPeer::$fieldKeys[$fromType][$name]) ? CcLoginAttemptsPeer::$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(CcLoginAttemptsPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcLoginAttemptsPeer::$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 CcLoginAttemptsPeer::$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. CcLoginAttemptsPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcLoginAttemptsPeer::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(CcLoginAttemptsPeer::IP); + $criteria->addSelectColumn(CcLoginAttemptsPeer::ATTEMPTS); + } else { + $criteria->addSelectColumn($alias . '.ip'); + $criteria->addSelectColumn($alias . '.attempts'); + } + } + + /** + * 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(CcLoginAttemptsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcLoginAttemptsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcLoginAttemptsPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcLoginAttemptsPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcLoginAttempts + * @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 = CcLoginAttemptsPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcLoginAttemptsPeer::populateObjects(CcLoginAttemptsPeer::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 directly (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(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcLoginAttemptsPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcLoginAttemptsPeer::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 CcLoginAttempts $obj A CcLoginAttempts object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbIP(); + } // if key === null + CcLoginAttemptsPeer::$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 CcLoginAttempts object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcLoginAttempts) { + $key = (string) $value->getDbIP(); + } 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 CcLoginAttempts object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcLoginAttemptsPeer::$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 CcLoginAttempts 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(CcLoginAttemptsPeer::$instances[$key])) { + return CcLoginAttemptsPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcLoginAttemptsPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcLoginAttemptsPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_login_attempts + * 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 = CcLoginAttemptsPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcLoginAttemptsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcLoginAttemptsPeer::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; + CcLoginAttemptsPeer::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 (CcLoginAttempts object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcLoginAttemptsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcLoginAttemptsPeer::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 + CcLoginAttemptsPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcLoginAttemptsPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcLoginAttemptsPeer::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(CcLoginAttemptsPeer::DATABASE_NAME)->getTable(CcLoginAttemptsPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcLoginAttemptsPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcLoginAttemptsPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcLoginAttemptsTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcLoginAttemptsPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcLoginAttempts or Criteria object. + * + * @param mixed $values Criteria or CcLoginAttempts 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(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcLoginAttempts object + } + + + // Set the correct dbName + $criteria->setDbName(CcLoginAttemptsPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcLoginAttempts or Criteria object. + * + * @param mixed $values Criteria or CcLoginAttempts 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(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcLoginAttemptsPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcLoginAttemptsPeer::IP); + $value = $criteria->remove(CcLoginAttemptsPeer::IP); + if ($value) { + $selectCriteria->add(CcLoginAttemptsPeer::IP, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcLoginAttemptsPeer::TABLE_NAME); + } + + } else { // $values is CcLoginAttempts object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcLoginAttemptsPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_login_attempts table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcLoginAttemptsPeer::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(CcLoginAttemptsPeer::TABLE_NAME, $con, CcLoginAttemptsPeer::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). + CcLoginAttemptsPeer::clearInstancePool(); + CcLoginAttemptsPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcLoginAttempts or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcLoginAttempts 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(CcLoginAttemptsPeer::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. + CcLoginAttemptsPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcLoginAttempts) { // it's a model object + // invalidate the cache for this single object + CcLoginAttemptsPeer::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(CcLoginAttemptsPeer::DATABASE_NAME); + $criteria->add(CcLoginAttemptsPeer::IP, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcLoginAttemptsPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcLoginAttemptsPeer::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); + CcLoginAttemptsPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcLoginAttempts 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 CcLoginAttempts $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcLoginAttemptsPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcLoginAttemptsPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcLoginAttemptsPeer::DATABASE_NAME, CcLoginAttemptsPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param string $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcLoginAttempts + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcLoginAttemptsPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcLoginAttemptsPeer::DATABASE_NAME); + $criteria->add(CcLoginAttemptsPeer::IP, $pk); + + $v = CcLoginAttemptsPeer::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 + * @return CcLoginAttempts[] + * @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(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcLoginAttemptsPeer::DATABASE_NAME); + $criteria->add(CcLoginAttemptsPeer::IP, $pks, Criteria::IN); + $objs = CcLoginAttemptsPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcLoginAttemptsPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcLoginAttemptsQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcLoginAttemptsQuery.php index 930f32eda..0db31ead1 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcLoginAttemptsQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcLoginAttemptsQuery.php @@ -1,205 +1,322 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcLoginAttempts|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcLoginAttemptsPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcLoginAttempts|CcLoginAttempts[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcLoginAttemptsPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcLoginAttemptsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcLoginAttemptsQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcLoginAttemptsPeer::IP, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcLoginAttempts A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbIP($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcLoginAttemptsQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcLoginAttemptsPeer::IP, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcLoginAttempts A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "ip", "attempts" FROM "cc_login_attempts" WHERE "ip" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcLoginAttempts(); + $obj->hydrate($row); + CcLoginAttemptsPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * Filter the query on the ip column - * - * @param string $dbIP 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 CcLoginAttemptsQuery The current query, for fluid interface - */ - public function filterByDbIP($dbIP = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbIP)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbIP)) { - $dbIP = str_replace('*', '%', $dbIP); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcLoginAttemptsPeer::IP, $dbIP, $comparison); - } + return $obj; + } - /** - * Filter the query on the attempts column - * - * @param int|array $dbAttempts 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 CcLoginAttemptsQuery The current query, for fluid interface - */ - public function filterByDbAttempts($dbAttempts = null, $comparison = null) - { - if (is_array($dbAttempts)) { - $useMinMax = false; - if (isset($dbAttempts['min'])) { - $this->addUsingAlias(CcLoginAttemptsPeer::ATTEMPTS, $dbAttempts['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbAttempts['max'])) { - $this->addUsingAlias(CcLoginAttemptsPeer::ATTEMPTS, $dbAttempts['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcLoginAttemptsPeer::ATTEMPTS, $dbAttempts, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcLoginAttempts|CcLoginAttempts[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Exclude object from result - * - * @param CcLoginAttempts $ccLoginAttempts Object to remove from the list of results - * - * @return CcLoginAttemptsQuery The current query, for fluid interface - */ - public function prune($ccLoginAttempts = null) - { - if ($ccLoginAttempts) { - $this->addUsingAlias(CcLoginAttemptsPeer::IP, $ccLoginAttempts->getDbIP(), Criteria::NOT_EQUAL); - } - - return $this; - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } -} // BaseCcLoginAttemptsQuery + /** + * 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|CcLoginAttempts[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($stmt); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcLoginAttemptsQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(CcLoginAttemptsPeer::IP, $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 CcLoginAttemptsQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(CcLoginAttemptsPeer::IP, $keys, Criteria::IN); + } + + /** + * Filter the query on the ip column + * + * Example usage: + * + * $query->filterByDbIP('fooValue'); // WHERE ip = 'fooValue' + * $query->filterByDbIP('%fooValue%'); // WHERE ip LIKE '%fooValue%' + * + * + * @param string $dbIP 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 CcLoginAttemptsQuery The current query, for fluid interface + */ + public function filterByDbIP($dbIP = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbIP)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbIP)) { + $dbIP = str_replace('*', '%', $dbIP); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcLoginAttemptsPeer::IP, $dbIP, $comparison); + } + + /** + * Filter the query on the attempts column + * + * Example usage: + * + * $query->filterByDbAttempts(1234); // WHERE attempts = 1234 + * $query->filterByDbAttempts(array(12, 34)); // WHERE attempts IN (12, 34) + * $query->filterByDbAttempts(array('min' => 12)); // WHERE attempts >= 12 + * $query->filterByDbAttempts(array('max' => 12)); // WHERE attempts <= 12 + * + * + * @param mixed $dbAttempts The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcLoginAttemptsQuery The current query, for fluid interface + */ + public function filterByDbAttempts($dbAttempts = null, $comparison = null) + { + if (is_array($dbAttempts)) { + $useMinMax = false; + if (isset($dbAttempts['min'])) { + $this->addUsingAlias(CcLoginAttemptsPeer::ATTEMPTS, $dbAttempts['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbAttempts['max'])) { + $this->addUsingAlias(CcLoginAttemptsPeer::ATTEMPTS, $dbAttempts['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcLoginAttemptsPeer::ATTEMPTS, $dbAttempts, $comparison); + } + + /** + * Exclude object from result + * + * @param CcLoginAttempts $ccLoginAttempts Object to remove from the list of results + * + * @return CcLoginAttemptsQuery The current query, for fluid interface + */ + public function prune($ccLoginAttempts = null) + { + if ($ccLoginAttempts) { + $this->addUsingAlias(CcLoginAttemptsPeer::IP, $ccLoginAttempts->getDbIP(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcMountName.php b/airtime_mvc/application/models/airtime/om/BaseCcMountName.php index b476f05a8..b03b84b5e 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcMountName.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcMountName.php @@ -1,893 +1,1184 @@ id; - } - - /** - * Get the [mount_name] column value. - * - * @return string - */ - public function getDbMountName() - { - return $this->mount_name; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcMountName 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[] = CcMountNamePeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [mount_name] column. - * - * @param string $v new value - * @return CcMountName The current object (for fluent API support) - */ - public function setDbMountName($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->mount_name !== $v) { - $this->mount_name = $v; - $this->modifiedColumns[] = CcMountNamePeer::MOUNT_NAME; - } - - return $this; - } // setDbMountName() - - /** - * 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->mount_name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 2; // 2 = CcMountNamePeer::NUM_COLUMNS - CcMountNamePeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcMountName 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(CcMountNamePeer::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 = CcMountNamePeer::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->collCcListenerCounts = 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(CcMountNamePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcMountNameQuery::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(CcMountNamePeer::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); - CcMountNamePeer::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[] = CcMountNamePeer::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(CcMountNamePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcMountNamePeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows = 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows = CcMountNamePeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - if ($this->collCcListenerCounts !== null) { - foreach ($this->collCcListenerCounts 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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CcMountNamePeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collCcListenerCounts !== null) { - foreach ($this->collCcListenerCounts 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 = CcMountNamePeer::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->getDbMountName(); - 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 = CcMountNamePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbMountName(), - ); - 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 = CcMountNamePeer::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->setDbMountName($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 = CcMountNamePeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbMountName($arr[$keys[1]]); - } - - /** - * 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(CcMountNamePeer::DATABASE_NAME); - - if ($this->isColumnModified(CcMountNamePeer::ID)) $criteria->add(CcMountNamePeer::ID, $this->id); - if ($this->isColumnModified(CcMountNamePeer::MOUNT_NAME)) $criteria->add(CcMountNamePeer::MOUNT_NAME, $this->mount_name); - - 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(CcMountNamePeer::DATABASE_NAME); - $criteria->add(CcMountNamePeer::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 CcMountName (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->setDbMountName($this->mount_name); - - 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->getCcListenerCounts() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcListenerCount($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 CcMountName 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 CcMountNamePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcMountNamePeer(); - } - return self::$peer; - } - - /** - * Clears out the collCcListenerCounts 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 addCcListenerCounts() - */ - public function clearCcListenerCounts() - { - $this->collCcListenerCounts = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcListenerCounts collection. - * - * By default this just sets the collCcListenerCounts collection to an empty array (like clearcollCcListenerCounts()); - * 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 initCcListenerCounts() - { - $this->collCcListenerCounts = new PropelObjectCollection(); - $this->collCcListenerCounts->setModel('CcListenerCount'); - } - - /** - * Gets an array of CcListenerCount 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 CcMountName 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 CcListenerCount[] List of CcListenerCount objects - * @throws PropelException - */ - public function getCcListenerCounts($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcListenerCounts || null !== $criteria) { - if ($this->isNew() && null === $this->collCcListenerCounts) { - // return empty collection - $this->initCcListenerCounts(); - } else { - $collCcListenerCounts = CcListenerCountQuery::create(null, $criteria) - ->filterByCcMountName($this) - ->find($con); - if (null !== $criteria) { - return $collCcListenerCounts; - } - $this->collCcListenerCounts = $collCcListenerCounts; - } - } - return $this->collCcListenerCounts; - } - - /** - * Returns the number of related CcListenerCount objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcListenerCount objects. - * @throws PropelException - */ - public function countCcListenerCounts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcListenerCounts || null !== $criteria) { - if ($this->isNew() && null === $this->collCcListenerCounts) { - return 0; - } else { - $query = CcListenerCountQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcMountName($this) - ->count($con); - } - } else { - return count($this->collCcListenerCounts); - } - } - - /** - * Method called to associate a CcListenerCount object to this object - * through the CcListenerCount foreign key attribute. - * - * @param CcListenerCount $l CcListenerCount - * @return void - * @throws PropelException - */ - public function addCcListenerCount(CcListenerCount $l) - { - if ($this->collCcListenerCounts === null) { - $this->initCcListenerCounts(); - } - if (!$this->collCcListenerCounts->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcListenerCounts[]= $l; - $l->setCcMountName($this); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcMountName is new, it will return - * an empty collection; or if this CcMountName has previously - * been saved, it will retrieve related CcListenerCounts 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 CcMountName. - * - * @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 CcListenerCount[] List of CcListenerCount objects - */ - public function getCcListenerCountsJoinCcTimestamp($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcListenerCountQuery::create(null, $criteria); - $query->joinWith('CcTimestamp', $join_behavior); - - return $this->getCcListenerCounts($query, $con); - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->mount_name = 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 ($this->collCcListenerCounts) { - foreach ((array) $this->collCcListenerCounts as $o) { - $o->clearAllReferences($deep); - } - } - } // if ($deep) - - $this->collCcListenerCounts = 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); - } - -} // BaseCcMountName + /** + * Peer class name + */ + const PEER = 'Airtime\\CcMountNamePeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcMountNamePeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the mount_name field. + * @var string + */ + protected $mount_name; + + /** + * @var PropelObjectCollection|CcListenerCount[] Collection to store aggregation of CcListenerCount objects. + */ + protected $collCcListenerCounts; + protected $collCcListenerCountsPartial; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccListenerCountsScheduledForDeletion = null; + + /** + * Get the [id] column value. + * + * @return int + */ + public function getDbId() + { + + return $this->id; + } + + /** + * Get the [mount_name] column value. + * + * @return string + */ + public function getDbMountName() + { + + return $this->mount_name; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcMountName The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcMountNamePeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [mount_name] column. + * + * @param string $v new value + * @return CcMountName The current object (for fluent API support) + */ + public function setDbMountName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->mount_name !== $v) { + $this->mount_name = $v; + $this->modifiedColumns[] = CcMountNamePeer::MOUNT_NAME; + } + + + return $this; + } // setDbMountName() + + /** + * 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 resultset 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->mount_name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 2; // 2 = CcMountNamePeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcMountName 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(CcMountNamePeer::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 = CcMountNamePeer::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->collCcListenerCounts = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(CcMountNamePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcMountNameQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcMountNamePeer::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); + CcMountNamePeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->ccListenerCountsScheduledForDeletion !== null) { + if (!$this->ccListenerCountsScheduledForDeletion->isEmpty()) { + CcListenerCountQuery::create() + ->filterByPrimaryKeys($this->ccListenerCountsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccListenerCountsScheduledForDeletion = null; + } + } + + if ($this->collCcListenerCounts !== null) { + foreach ($this->collCcListenerCounts as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcMountNamePeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcMountNamePeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_mount_name_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcMountNamePeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcMountNamePeer::MOUNT_NAME)) { + $modifiedColumns[':p' . $index++] = '"mount_name"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_mount_name" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"mount_name"': + $stmt->bindValue($identifier, $this->mount_name, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcMountNamePeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collCcListenerCounts !== null) { + foreach ($this->collCcListenerCounts 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcMountNamePeer::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->getDbMountName(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcMountName'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcMountName'][$this->getPrimaryKey()] = true; + $keys = CcMountNamePeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbMountName(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->collCcListenerCounts) { + $result['CcListenerCounts'] = $this->collCcListenerCounts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcMountNamePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbMountName($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcMountNamePeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbMountName($arr[$keys[1]]); + } + + /** + * 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(CcMountNamePeer::DATABASE_NAME); + + if ($this->isColumnModified(CcMountNamePeer::ID)) $criteria->add(CcMountNamePeer::ID, $this->id); + if ($this->isColumnModified(CcMountNamePeer::MOUNT_NAME)) $criteria->add(CcMountNamePeer::MOUNT_NAME, $this->mount_name); + + 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(CcMountNamePeer::DATABASE_NAME); + $criteria->add(CcMountNamePeer::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 CcMountName (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbMountName($this->getDbMountName()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + foreach ($this->getCcListenerCounts() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcListenerCount($relObj->copy($deepCopy)); + } + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcMountName 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 CcMountNamePeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcMountNamePeer(); + } + + return self::$peer; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('CcListenerCount' == $relationName) { + $this->initCcListenerCounts(); + } + } + + /** + * Clears out the collCcListenerCounts 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 CcMountName The current object (for fluent API support) + * @see addCcListenerCounts() + */ + public function clearCcListenerCounts() + { + $this->collCcListenerCounts = null; // important to set this to null since that means it is uninitialized + $this->collCcListenerCountsPartial = null; + + return $this; + } + + /** + * reset is the collCcListenerCounts collection loaded partially + * + * @return void + */ + public function resetPartialCcListenerCounts($v = true) + { + $this->collCcListenerCountsPartial = $v; + } + + /** + * Initializes the collCcListenerCounts collection. + * + * By default this just sets the collCcListenerCounts collection to an empty array (like clearcollCcListenerCounts()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcListenerCounts($overrideExisting = true) + { + if (null !== $this->collCcListenerCounts && !$overrideExisting) { + return; + } + $this->collCcListenerCounts = new PropelObjectCollection(); + $this->collCcListenerCounts->setModel('CcListenerCount'); + } + + /** + * Gets an array of CcListenerCount 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 CcMountName 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 PropelObjectCollection|CcListenerCount[] List of CcListenerCount objects + * @throws PropelException + */ + public function getCcListenerCounts($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcListenerCountsPartial && !$this->isNew(); + if (null === $this->collCcListenerCounts || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcListenerCounts) { + // return empty collection + $this->initCcListenerCounts(); + } else { + $collCcListenerCounts = CcListenerCountQuery::create(null, $criteria) + ->filterByCcMountName($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcListenerCountsPartial && count($collCcListenerCounts)) { + $this->initCcListenerCounts(false); + + foreach ($collCcListenerCounts as $obj) { + if (false == $this->collCcListenerCounts->contains($obj)) { + $this->collCcListenerCounts->append($obj); + } + } + + $this->collCcListenerCountsPartial = true; + } + + $collCcListenerCounts->getInternalIterator()->rewind(); + + return $collCcListenerCounts; + } + + if ($partial && $this->collCcListenerCounts) { + foreach ($this->collCcListenerCounts as $obj) { + if ($obj->isNew()) { + $collCcListenerCounts[] = $obj; + } + } + } + + $this->collCcListenerCounts = $collCcListenerCounts; + $this->collCcListenerCountsPartial = false; + } + } + + return $this->collCcListenerCounts; + } + + /** + * Sets a collection of CcListenerCount objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccListenerCounts A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcMountName The current object (for fluent API support) + */ + public function setCcListenerCounts(PropelCollection $ccListenerCounts, PropelPDO $con = null) + { + $ccListenerCountsToDelete = $this->getCcListenerCounts(new Criteria(), $con)->diff($ccListenerCounts); + + + $this->ccListenerCountsScheduledForDeletion = $ccListenerCountsToDelete; + + foreach ($ccListenerCountsToDelete as $ccListenerCountRemoved) { + $ccListenerCountRemoved->setCcMountName(null); + } + + $this->collCcListenerCounts = null; + foreach ($ccListenerCounts as $ccListenerCount) { + $this->addCcListenerCount($ccListenerCount); + } + + $this->collCcListenerCounts = $ccListenerCounts; + $this->collCcListenerCountsPartial = false; + + return $this; + } + + /** + * Returns the number of related CcListenerCount objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcListenerCount objects. + * @throws PropelException + */ + public function countCcListenerCounts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcListenerCountsPartial && !$this->isNew(); + if (null === $this->collCcListenerCounts || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcListenerCounts) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcListenerCounts()); + } + $query = CcListenerCountQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcMountName($this) + ->count($con); + } + + return count($this->collCcListenerCounts); + } + + /** + * Method called to associate a CcListenerCount object to this object + * through the CcListenerCount foreign key attribute. + * + * @param CcListenerCount $l CcListenerCount + * @return CcMountName The current object (for fluent API support) + */ + public function addCcListenerCount(CcListenerCount $l) + { + if ($this->collCcListenerCounts === null) { + $this->initCcListenerCounts(); + $this->collCcListenerCountsPartial = true; + } + + if (!in_array($l, $this->collCcListenerCounts->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcListenerCount($l); + + if ($this->ccListenerCountsScheduledForDeletion and $this->ccListenerCountsScheduledForDeletion->contains($l)) { + $this->ccListenerCountsScheduledForDeletion->remove($this->ccListenerCountsScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcListenerCount $ccListenerCount The ccListenerCount object to add. + */ + protected function doAddCcListenerCount($ccListenerCount) + { + $this->collCcListenerCounts[]= $ccListenerCount; + $ccListenerCount->setCcMountName($this); + } + + /** + * @param CcListenerCount $ccListenerCount The ccListenerCount object to remove. + * @return CcMountName The current object (for fluent API support) + */ + public function removeCcListenerCount($ccListenerCount) + { + if ($this->getCcListenerCounts()->contains($ccListenerCount)) { + $this->collCcListenerCounts->remove($this->collCcListenerCounts->search($ccListenerCount)); + if (null === $this->ccListenerCountsScheduledForDeletion) { + $this->ccListenerCountsScheduledForDeletion = clone $this->collCcListenerCounts; + $this->ccListenerCountsScheduledForDeletion->clear(); + } + $this->ccListenerCountsScheduledForDeletion[]= clone $ccListenerCount; + $ccListenerCount->setCcMountName(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcMountName is new, it will return + * an empty collection; or if this CcMountName has previously + * been saved, it will retrieve related CcListenerCounts 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 CcMountName. + * + * @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 PropelObjectCollection|CcListenerCount[] List of CcListenerCount objects + */ + public function getCcListenerCountsJoinCcTimestamp($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcListenerCountQuery::create(null, $criteria); + $query->joinWith('CcTimestamp', $join_behavior); + + return $this->getCcListenerCounts($query, $con); + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->mount_name = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->collCcListenerCounts) { + foreach ($this->collCcListenerCounts as $o) { + $o->clearAllReferences($deep); + } + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + if ($this->collCcListenerCounts instanceof PropelCollection) { + $this->collCcListenerCounts->clearIterator(); + } + $this->collCcListenerCounts = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcMountNamePeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcMountNamePeer.php b/airtime_mvc/application/models/airtime/om/BaseCcMountNamePeer.php index af2e416b1..c473ad304 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcMountNamePeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcMountNamePeer.php @@ -1,738 +1,773 @@ array ('DbId', 'DbMountName', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbMountName', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::MOUNT_NAME, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'MOUNT_NAME', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'mount_name', ), - BasePeer::TYPE_NUM => array (0, 1, ) - ); - - /** - * 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, 'DbMountName' => 1, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbMountName' => 1, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::MOUNT_NAME => 1, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'MOUNT_NAME' => 1, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'mount_name' => 1, ), - BasePeer::TYPE_NUM => array (0, 1, ) - ); - - /** - * 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. CcMountNamePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcMountNamePeer::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(CcMountNamePeer::ID); - $criteria->addSelectColumn(CcMountNamePeer::MOUNT_NAME); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.MOUNT_NAME'); - } - } - - /** - * 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(CcMountNamePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcMountNamePeer::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(CcMountNamePeer::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 CcMountName - * @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 = CcMountNamePeer::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 CcMountNamePeer::populateObjects(CcMountNamePeer::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(CcMountNamePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcMountNamePeer::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 CcMountName $value A CcMountName object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcMountName $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 CcMountName object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcMountName) { - $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 CcMountName 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 CcMountName 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_mount_name - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in CcListenerCountPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcListenerCountPeer::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 = CcMountNamePeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcMountNamePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcMountNamePeer::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; - CcMountNamePeer::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 (CcMountName object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcMountNamePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcMountNamePeer::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 + CcMountNamePeer::NUM_COLUMNS; - } else { - $cls = CcMountNamePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcMountNamePeer::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(BaseCcMountNamePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcMountNamePeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcMountNameTableMap()); - } - } - - /** - * 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 ? CcMountNamePeer::CLASS_DEFAULT : CcMountNamePeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcMountName or Criteria object. - * - * @param mixed $values Criteria or CcMountName 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(CcMountNamePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcMountName object - } - - if ($criteria->containsKey(CcMountNamePeer::ID) && $criteria->keyContainsValue(CcMountNamePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcMountNamePeer::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 CcMountName or Criteria object. - * - * @param mixed $values Criteria or CcMountName 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(CcMountNamePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcMountNamePeer::ID); - $value = $criteria->remove(CcMountNamePeer::ID); - if ($value) { - $selectCriteria->add(CcMountNamePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcMountNamePeer::TABLE_NAME); - } - - } else { // $values is CcMountName 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_mount_name 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(CcMountNamePeer::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(CcMountNamePeer::TABLE_NAME, $con, CcMountNamePeer::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). - CcMountNamePeer::clearInstancePool(); - CcMountNamePeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcMountName or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcMountName 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(CcMountNamePeer::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. - CcMountNamePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcMountName) { // it's a model object - // invalidate the cache for this single object - CcMountNamePeer::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(CcMountNamePeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcMountNamePeer::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); - CcMountNamePeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcMountName 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 CcMountName $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(CcMountName $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcMountNamePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcMountNamePeer::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(CcMountNamePeer::DATABASE_NAME, CcMountNamePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcMountName - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcMountNamePeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcMountNamePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcMountNamePeer::DATABASE_NAME); - $criteria->add(CcMountNamePeer::ID, $pk); - - $v = CcMountNamePeer::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(CcMountNamePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcMountNamePeer::DATABASE_NAME); - $criteria->add(CcMountNamePeer::ID, $pks, Criteria::IN); - $objs = CcMountNamePeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcMountNamePeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_mount_name'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcMountName'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcMountNameTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 2; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 2; + + /** the column name for the id field */ + const ID = 'cc_mount_name.id'; + + /** the column name for the mount_name field */ + const MOUNT_NAME = 'cc_mount_name.mount_name'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcMountName objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcMountName[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcMountNamePeer::$fieldNames[CcMountNamePeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbMountName', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbMountName', ), + BasePeer::TYPE_COLNAME => array (CcMountNamePeer::ID, CcMountNamePeer::MOUNT_NAME, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'MOUNT_NAME', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'mount_name', ), + BasePeer::TYPE_NUM => array (0, 1, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcMountNamePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbMountName' => 1, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbMountName' => 1, ), + BasePeer::TYPE_COLNAME => array (CcMountNamePeer::ID => 0, CcMountNamePeer::MOUNT_NAME => 1, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'MOUNT_NAME' => 1, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'mount_name' => 1, ), + BasePeer::TYPE_NUM => array (0, 1, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcMountNamePeer::getFieldNames($toType); + $key = isset(CcMountNamePeer::$fieldKeys[$fromType][$name]) ? CcMountNamePeer::$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(CcMountNamePeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcMountNamePeer::$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 CcMountNamePeer::$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. CcMountNamePeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcMountNamePeer::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(CcMountNamePeer::ID); + $criteria->addSelectColumn(CcMountNamePeer::MOUNT_NAME); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.mount_name'); + } + } + + /** + * 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(CcMountNamePeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcMountNamePeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcMountNamePeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcMountNamePeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcMountName + * @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 = CcMountNamePeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcMountNamePeer::populateObjects(CcMountNamePeer::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 directly (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(CcMountNamePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcMountNamePeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcMountNamePeer::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 CcMountName $obj A CcMountName object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcMountNamePeer::$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 CcMountName object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcMountName) { + $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 CcMountName object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcMountNamePeer::$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 CcMountName 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(CcMountNamePeer::$instances[$key])) { + return CcMountNamePeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcMountNamePeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcMountNamePeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_mount_name + * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in CcListenerCountPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcListenerCountPeer::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 = CcMountNamePeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcMountNamePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcMountNamePeer::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; + CcMountNamePeer::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 (CcMountName object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcMountNamePeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcMountNamePeer::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 + CcMountNamePeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcMountNamePeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcMountNamePeer::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(CcMountNamePeer::DATABASE_NAME)->getTable(CcMountNamePeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcMountNamePeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcMountNamePeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcMountNameTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcMountNamePeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcMountName or Criteria object. + * + * @param mixed $values Criteria or CcMountName 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(CcMountNamePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcMountName object + } + + if ($criteria->containsKey(CcMountNamePeer::ID) && $criteria->keyContainsValue(CcMountNamePeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcMountNamePeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcMountNamePeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcMountName or Criteria object. + * + * @param mixed $values Criteria or CcMountName 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(CcMountNamePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcMountNamePeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcMountNamePeer::ID); + $value = $criteria->remove(CcMountNamePeer::ID); + if ($value) { + $selectCriteria->add(CcMountNamePeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcMountNamePeer::TABLE_NAME); + } + + } else { // $values is CcMountName object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcMountNamePeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_mount_name table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcMountNamePeer::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(CcMountNamePeer::TABLE_NAME, $con, CcMountNamePeer::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). + CcMountNamePeer::clearInstancePool(); + CcMountNamePeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcMountName or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcMountName 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(CcMountNamePeer::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. + CcMountNamePeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcMountName) { // it's a model object + // invalidate the cache for this single object + CcMountNamePeer::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(CcMountNamePeer::DATABASE_NAME); + $criteria->add(CcMountNamePeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcMountNamePeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcMountNamePeer::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); + CcMountNamePeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcMountName 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 CcMountName $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcMountNamePeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcMountNamePeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcMountNamePeer::DATABASE_NAME, CcMountNamePeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcMountName + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcMountNamePeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcMountNamePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcMountNamePeer::DATABASE_NAME); + $criteria->add(CcMountNamePeer::ID, $pk); + + $v = CcMountNamePeer::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 + * @return CcMountName[] + * @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(CcMountNamePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcMountNamePeer::DATABASE_NAME); + $criteria->add(CcMountNamePeer::ID, $pks, Criteria::IN); + $objs = CcMountNamePeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcMountNamePeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcMountNameQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcMountNameQuery.php index 52af75f38..b0a445a4e 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcMountNameQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcMountNameQuery.php @@ -1,259 +1,403 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcMountName|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcMountNamePeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcMountName|CcMountName[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcMountNamePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcMountNamePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcMountNameQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcMountNamePeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcMountName A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcMountNameQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcMountNamePeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcMountName A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "mount_name" FROM "cc_mount_name" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcMountName(); + $obj->hydrate($row); + CcMountNamePeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcMountNameQuery 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(CcMountNamePeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * Filter the query on the mount_name column - * - * @param string $dbMountName 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 CcMountNameQuery The current query, for fluid interface - */ - public function filterByDbMountName($dbMountName = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbMountName)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbMountName)) { - $dbMountName = str_replace('*', '%', $dbMountName); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcMountNamePeer::MOUNT_NAME, $dbMountName, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcMountName|CcMountName[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Filter the query by a related CcListenerCount object - * - * @param CcListenerCount $ccListenerCount the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcMountNameQuery The current query, for fluid interface - */ - public function filterByCcListenerCount($ccListenerCount, $comparison = null) - { - return $this - ->addUsingAlias(CcMountNamePeer::ID, $ccListenerCount->getDbMountNameId(), $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Adds a JOIN clause to the query using the CcListenerCount relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcMountNameQuery The current query, for fluid interface - */ - public function joinCcListenerCount($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcListenerCount'); - - // 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, 'CcListenerCount'); - } - - return $this; - } + /** + * 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|CcMountName[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Use the CcListenerCount relation CcListenerCount 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 CcListenerCountQuery A secondary query class using the current class as primary query - */ - public function useCcListenerCountQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcListenerCount($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcListenerCount', 'CcListenerCountQuery'); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Exclude object from result - * - * @param CcMountName $ccMountName Object to remove from the list of results - * - * @return CcMountNameQuery The current query, for fluid interface - */ - public function prune($ccMountName = null) - { - if ($ccMountName) { - $this->addUsingAlias(CcMountNamePeer::ID, $ccMountName->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcMountNameQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { -} // BaseCcMountNameQuery + return $this->addUsingAlias(CcMountNamePeer::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 CcMountNameQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(CcMountNamePeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcMountNameQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcMountNamePeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcMountNamePeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcMountNamePeer::ID, $dbId, $comparison); + } + + /** + * Filter the query on the mount_name column + * + * Example usage: + * + * $query->filterByDbMountName('fooValue'); // WHERE mount_name = 'fooValue' + * $query->filterByDbMountName('%fooValue%'); // WHERE mount_name LIKE '%fooValue%' + * + * + * @param string $dbMountName 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 CcMountNameQuery The current query, for fluid interface + */ + public function filterByDbMountName($dbMountName = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbMountName)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbMountName)) { + $dbMountName = str_replace('*', '%', $dbMountName); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcMountNamePeer::MOUNT_NAME, $dbMountName, $comparison); + } + + /** + * Filter the query by a related CcListenerCount object + * + * @param CcListenerCount|PropelObjectCollection $ccListenerCount the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcMountNameQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcListenerCount($ccListenerCount, $comparison = null) + { + if ($ccListenerCount instanceof CcListenerCount) { + return $this + ->addUsingAlias(CcMountNamePeer::ID, $ccListenerCount->getDbMountNameId(), $comparison); + } elseif ($ccListenerCount instanceof PropelObjectCollection) { + return $this + ->useCcListenerCountQuery() + ->filterByPrimaryKeys($ccListenerCount->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcListenerCount() only accepts arguments of type CcListenerCount or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcListenerCount relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcMountNameQuery The current query, for fluid interface + */ + public function joinCcListenerCount($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcListenerCount'); + + // 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, 'CcListenerCount'); + } + + return $this; + } + + /** + * Use the CcListenerCount relation CcListenerCount 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 \Airtime\CcListenerCountQuery A secondary query class using the current class as primary query + */ + public function useCcListenerCountQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcListenerCount($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcListenerCount', '\Airtime\CcListenerCountQuery'); + } + + /** + * Exclude object from result + * + * @param CcMountName $ccMountName Object to remove from the list of results + * + * @return CcMountNameQuery The current query, for fluid interface + */ + public function prune($ccMountName = null) + { + if ($ccMountName) { + $this->addUsingAlias(CcMountNamePeer::ID, $ccMountName->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcMusicDirs.php b/airtime_mvc/application/models/airtime/om/BaseCcMusicDirs.php index f58915945..55f10be32 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcMusicDirs.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcMusicDirs.php @@ -1,1095 +1,1765 @@ exists = true; - $this->watched = true; - } - - /** - * Initializes internal state of BaseCcMusicDirs 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 [directory] column value. - * - * @return string - */ - public function getDirectory() - { - return $this->directory; - } - - /** - * Get the [type] column value. - * - * @return string - */ - public function getType() - { - return $this->type; - } - - /** - * Get the [exists] column value. - * - * @return boolean - */ - public function getExists() - { - return $this->exists; - } - - /** - * Get the [watched] column value. - * - * @return boolean - */ - public function getWatched() - { - return $this->watched; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcMusicDirs 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[] = CcMusicDirsPeer::ID; - } - - return $this; - } // setId() - - /** - * Set the value of [directory] column. - * - * @param string $v new value - * @return CcMusicDirs The current object (for fluent API support) - */ - public function setDirectory($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->directory !== $v) { - $this->directory = $v; - $this->modifiedColumns[] = CcMusicDirsPeer::DIRECTORY; - } - - return $this; - } // setDirectory() - - /** - * Set the value of [type] column. - * - * @param string $v new value - * @return CcMusicDirs 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[] = CcMusicDirsPeer::TYPE; - } - - return $this; - } // setType() - - /** - * Set the value of [exists] column. - * - * @param boolean $v new value - * @return CcMusicDirs The current object (for fluent API support) - */ - public function setExists($v) - { - if ($v !== null) { - $v = (boolean) $v; - } - - if ($this->exists !== $v || $this->isNew()) { - $this->exists = $v; - $this->modifiedColumns[] = CcMusicDirsPeer::EXISTS; - } - - return $this; - } // setExists() - - /** - * Set the value of [watched] column. - * - * @param boolean $v new value - * @return CcMusicDirs The current object (for fluent API support) - */ - public function setWatched($v) - { - if ($v !== null) { - $v = (boolean) $v; - } - - if ($this->watched !== $v || $this->isNew()) { - $this->watched = $v; - $this->modifiedColumns[] = CcMusicDirsPeer::WATCHED; - } - - return $this; - } // setWatched() - - /** - * 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->exists !== true) { - return false; - } - - if ($this->watched !== true) { - 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->directory = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->type = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->exists = ($row[$startcol + 3] !== null) ? (boolean) $row[$startcol + 3] : null; - $this->watched = ($row[$startcol + 4] !== null) ? (boolean) $row[$startcol + 4] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 5; // 5 = CcMusicDirsPeer::NUM_COLUMNS - CcMusicDirsPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcMusicDirs 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(CcMusicDirsPeer::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 = CcMusicDirsPeer::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->collCcFiless = 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(CcMusicDirsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcMusicDirsQuery::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(CcMusicDirsPeer::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); - CcMusicDirsPeer::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[] = CcMusicDirsPeer::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(CcMusicDirsPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcMusicDirsPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows = 1; - $this->setId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows = CcMusicDirsPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - if ($this->collCcFiless !== null) { - foreach ($this->collCcFiless 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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CcMusicDirsPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collCcFiless !== null) { - foreach ($this->collCcFiless 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 = CcMusicDirsPeer::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->getDirectory(); - break; - case 2: - return $this->getType(); - break; - case 3: - return $this->getExists(); - break; - case 4: - return $this->getWatched(); - 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 = CcMusicDirsPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getDirectory(), - $keys[2] => $this->getType(), - $keys[3] => $this->getExists(), - $keys[4] => $this->getWatched(), - ); - 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 = CcMusicDirsPeer::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->setDirectory($value); - break; - case 2: - $this->setType($value); - break; - case 3: - $this->setExists($value); - break; - case 4: - $this->setWatched($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 = CcMusicDirsPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDirectory($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setType($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setExists($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setWatched($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(CcMusicDirsPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcMusicDirsPeer::ID)) $criteria->add(CcMusicDirsPeer::ID, $this->id); - if ($this->isColumnModified(CcMusicDirsPeer::DIRECTORY)) $criteria->add(CcMusicDirsPeer::DIRECTORY, $this->directory); - if ($this->isColumnModified(CcMusicDirsPeer::TYPE)) $criteria->add(CcMusicDirsPeer::TYPE, $this->type); - if ($this->isColumnModified(CcMusicDirsPeer::EXISTS)) $criteria->add(CcMusicDirsPeer::EXISTS, $this->exists); - if ($this->isColumnModified(CcMusicDirsPeer::WATCHED)) $criteria->add(CcMusicDirsPeer::WATCHED, $this->watched); - - 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(CcMusicDirsPeer::DATABASE_NAME); - $criteria->add(CcMusicDirsPeer::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 CcMusicDirs (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->setDirectory($this->directory); - $copyObj->setType($this->type); - $copyObj->setExists($this->exists); - $copyObj->setWatched($this->watched); - - 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->getCcFiless() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcFiles($relObj->copy($deepCopy)); - } - } - - } // if ($deepCopy) - - - $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 CcMusicDirs 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 CcMusicDirsPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcMusicDirsPeer(); - } - return self::$peer; - } - - /** - * 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 CcMusicDirs 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) - ->filterByCcMusicDirs($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 - ->filterByCcMusicDirs($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->setCcMusicDirs($this); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcMusicDirs is new, it will return - * an empty collection; or if this CcMusicDirs has previously - * been saved, it will retrieve related CcFiless 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 CcMusicDirs. - * - * @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 CcFiles[] List of CcFiles objects - */ - public function getCcFilessJoinFkOwner($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcFilesQuery::create(null, $criteria); - $query->joinWith('FkOwner', $join_behavior); - - return $this->getCcFiless($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcMusicDirs is new, it will return - * an empty collection; or if this CcMusicDirs has previously - * been saved, it will retrieve related CcFiless 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 CcMusicDirs. - * - * @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 CcFiles[] List of CcFiles objects - */ - public function getCcFilessJoinCcSubjsRelatedByDbEditedby($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcFilesQuery::create(null, $criteria); - $query->joinWith('CcSubjsRelatedByDbEditedby', $join_behavior); - - return $this->getCcFiless($query, $con); - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->directory = null; - $this->type = null; - $this->exists = null; - $this->watched = 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->collCcFiless) { - foreach ((array) $this->collCcFiless as $o) { - $o->clearAllReferences($deep); - } - } - } // if ($deep) - - $this->collCcFiless = 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); - } - -} // BaseCcMusicDirs + /** + * Peer class name + */ + const PEER = 'Airtime\\CcMusicDirsPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcMusicDirsPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the directory field. + * @var string + */ + protected $directory; + + /** + * The value for the type field. + * @var string + */ + protected $type; + + /** + * The value for the exists field. + * Note: this column has a database default value of: true + * @var boolean + */ + protected $exists; + + /** + * The value for the watched field. + * Note: this column has a database default value of: true + * @var boolean + */ + protected $watched; + + /** + * @var PropelObjectCollection|CcFiles[] Collection to store aggregation of CcFiles objects. + */ + protected $collCcFiless; + protected $collCcFilessPartial; + + /** + * @var PropelObjectCollection|AudioFile[] Collection to store aggregation of AudioFile objects. + */ + protected $collAudioFiles; + protected $collAudioFilesPartial; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccFilessScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $audioFilesScheduledForDeletion = null; + + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->exists = true; + $this->watched = true; + } + + /** + * Initializes internal state of BaseCcMusicDirs 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 [directory] column value. + * + * @return string + */ + public function getDirectory() + { + + return $this->directory; + } + + /** + * Get the [type] column value. + * + * @return string + */ + public function getType() + { + + return $this->type; + } + + /** + * Get the [exists] column value. + * + * @return boolean + */ + public function getExists() + { + + return $this->exists; + } + + /** + * Get the [watched] column value. + * + * @return boolean + */ + public function getWatched() + { + + return $this->watched; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcMusicDirs The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcMusicDirsPeer::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [directory] column. + * + * @param string $v new value + * @return CcMusicDirs The current object (for fluent API support) + */ + public function setDirectory($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->directory !== $v) { + $this->directory = $v; + $this->modifiedColumns[] = CcMusicDirsPeer::DIRECTORY; + } + + + return $this; + } // setDirectory() + + /** + * Set the value of [type] column. + * + * @param string $v new value + * @return CcMusicDirs The current object (for fluent API support) + */ + public function setType($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->type !== $v) { + $this->type = $v; + $this->modifiedColumns[] = CcMusicDirsPeer::TYPE; + } + + + return $this; + } // setType() + + /** + * Sets the value of the [exists] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return CcMusicDirs The current object (for fluent API support) + */ + public function setExists($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->exists !== $v) { + $this->exists = $v; + $this->modifiedColumns[] = CcMusicDirsPeer::EXISTS; + } + + + return $this; + } // setExists() + + /** + * Sets the value of the [watched] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return CcMusicDirs The current object (for fluent API support) + */ + public function setWatched($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->watched !== $v) { + $this->watched = $v; + $this->modifiedColumns[] = CcMusicDirsPeer::WATCHED; + } + + + return $this; + } // setWatched() + + /** + * 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->exists !== true) { + return false; + } + + if ($this->watched !== true) { + 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 resultset 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->directory = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->type = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->exists = ($row[$startcol + 3] !== null) ? (boolean) $row[$startcol + 3] : null; + $this->watched = ($row[$startcol + 4] !== null) ? (boolean) $row[$startcol + 4] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 5; // 5 = CcMusicDirsPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcMusicDirs 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(CcMusicDirsPeer::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 = CcMusicDirsPeer::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->collCcFiless = null; + + $this->collAudioFiles = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(CcMusicDirsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcMusicDirsQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcMusicDirsPeer::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); + CcMusicDirsPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->ccFilessScheduledForDeletion !== null) { + if (!$this->ccFilessScheduledForDeletion->isEmpty()) { + foreach ($this->ccFilessScheduledForDeletion as $ccFiles) { + // need to save related object because we set the relation to null + $ccFiles->save($con); + } + $this->ccFilessScheduledForDeletion = null; + } + } + + if ($this->collCcFiless !== null) { + foreach ($this->collCcFiless as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->audioFilesScheduledForDeletion !== null) { + if (!$this->audioFilesScheduledForDeletion->isEmpty()) { + foreach ($this->audioFilesScheduledForDeletion as $audioFile) { + // need to save related object because we set the relation to null + $audioFile->save($con); + } + $this->audioFilesScheduledForDeletion = null; + } + } + + if ($this->collAudioFiles !== null) { + foreach ($this->collAudioFiles as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcMusicDirsPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcMusicDirsPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_music_dirs_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcMusicDirsPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcMusicDirsPeer::DIRECTORY)) { + $modifiedColumns[':p' . $index++] = '"directory"'; + } + if ($this->isColumnModified(CcMusicDirsPeer::TYPE)) { + $modifiedColumns[':p' . $index++] = '"type"'; + } + if ($this->isColumnModified(CcMusicDirsPeer::EXISTS)) { + $modifiedColumns[':p' . $index++] = '"exists"'; + } + if ($this->isColumnModified(CcMusicDirsPeer::WATCHED)) { + $modifiedColumns[':p' . $index++] = '"watched"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_music_dirs" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"directory"': + $stmt->bindValue($identifier, $this->directory, PDO::PARAM_STR); + break; + case '"type"': + $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR); + break; + case '"exists"': + $stmt->bindValue($identifier, $this->exists, PDO::PARAM_BOOL); + break; + case '"watched"': + $stmt->bindValue($identifier, $this->watched, PDO::PARAM_BOOL); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcMusicDirsPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collCcFiless !== null) { + foreach ($this->collCcFiless as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collAudioFiles !== null) { + foreach ($this->collAudioFiles 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcMusicDirsPeer::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->getDirectory(); + break; + case 2: + return $this->getType(); + break; + case 3: + return $this->getExists(); + break; + case 4: + return $this->getWatched(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcMusicDirs'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcMusicDirs'][$this->getPrimaryKey()] = true; + $keys = CcMusicDirsPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getDirectory(), + $keys[2] => $this->getType(), + $keys[3] => $this->getExists(), + $keys[4] => $this->getWatched(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->collCcFiless) { + $result['CcFiless'] = $this->collCcFiless->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collAudioFiles) { + $result['AudioFiles'] = $this->collAudioFiles->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcMusicDirsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDirectory($value); + break; + case 2: + $this->setType($value); + break; + case 3: + $this->setExists($value); + break; + case 4: + $this->setWatched($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcMusicDirsPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDirectory($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setType($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setExists($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setWatched($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(CcMusicDirsPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcMusicDirsPeer::ID)) $criteria->add(CcMusicDirsPeer::ID, $this->id); + if ($this->isColumnModified(CcMusicDirsPeer::DIRECTORY)) $criteria->add(CcMusicDirsPeer::DIRECTORY, $this->directory); + if ($this->isColumnModified(CcMusicDirsPeer::TYPE)) $criteria->add(CcMusicDirsPeer::TYPE, $this->type); + if ($this->isColumnModified(CcMusicDirsPeer::EXISTS)) $criteria->add(CcMusicDirsPeer::EXISTS, $this->exists); + if ($this->isColumnModified(CcMusicDirsPeer::WATCHED)) $criteria->add(CcMusicDirsPeer::WATCHED, $this->watched); + + 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(CcMusicDirsPeer::DATABASE_NAME); + $criteria->add(CcMusicDirsPeer::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 CcMusicDirs (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDirectory($this->getDirectory()); + $copyObj->setType($this->getType()); + $copyObj->setExists($this->getExists()); + $copyObj->setWatched($this->getWatched()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + 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->getAudioFiles() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addAudioFile($relObj->copy($deepCopy)); + } + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcMusicDirs 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 CcMusicDirsPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcMusicDirsPeer(); + } + + return self::$peer; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('CcFiles' == $relationName) { + $this->initCcFiless(); + } + if ('AudioFile' == $relationName) { + $this->initAudioFiles(); + } + } + + /** + * 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 CcMusicDirs The current object (for fluent API support) + * @see addCcFiless() + */ + public function clearCcFiless() + { + $this->collCcFiless = null; // important to set this to null since that means it is uninitialized + $this->collCcFilessPartial = null; + + return $this; + } + + /** + * reset is the collCcFiless collection loaded partially + * + * @return void + */ + public function resetPartialCcFiless($v = true) + { + $this->collCcFilessPartial = $v; + } + + /** + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcFiless($overrideExisting = true) + { + if (null !== $this->collCcFiless && !$overrideExisting) { + return; + } + $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 CcMusicDirs 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 PropelObjectCollection|CcFiles[] List of CcFiles objects + * @throws PropelException + */ + public function getCcFiless($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcFilessPartial && !$this->isNew(); + if (null === $this->collCcFiless || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcFiless) { + // return empty collection + $this->initCcFiless(); + } else { + $collCcFiless = CcFilesQuery::create(null, $criteria) + ->filterByCcMusicDirs($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcFilessPartial && count($collCcFiless)) { + $this->initCcFiless(false); + + foreach ($collCcFiless as $obj) { + if (false == $this->collCcFiless->contains($obj)) { + $this->collCcFiless->append($obj); + } + } + + $this->collCcFilessPartial = true; + } + + $collCcFiless->getInternalIterator()->rewind(); + + return $collCcFiless; + } + + if ($partial && $this->collCcFiless) { + foreach ($this->collCcFiless as $obj) { + if ($obj->isNew()) { + $collCcFiless[] = $obj; + } + } + } + + $this->collCcFiless = $collCcFiless; + $this->collCcFilessPartial = false; + } + } + + return $this->collCcFiless; + } + + /** + * Sets a collection of CcFiles objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccFiless A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcMusicDirs The current object (for fluent API support) + */ + public function setCcFiless(PropelCollection $ccFiless, PropelPDO $con = null) + { + $ccFilessToDelete = $this->getCcFiless(new Criteria(), $con)->diff($ccFiless); + + + $this->ccFilessScheduledForDeletion = $ccFilessToDelete; + + foreach ($ccFilessToDelete as $ccFilesRemoved) { + $ccFilesRemoved->setCcMusicDirs(null); + } + + $this->collCcFiless = null; + foreach ($ccFiless as $ccFiles) { + $this->addCcFiles($ccFiles); + } + + $this->collCcFiless = $ccFiless; + $this->collCcFilessPartial = false; + + return $this; + } + + /** + * 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) + { + $partial = $this->collCcFilessPartial && !$this->isNew(); + if (null === $this->collCcFiless || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcFiless) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcFiless()); + } + $query = CcFilesQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcMusicDirs($this) + ->count($con); + } + + 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 CcMusicDirs The current object (for fluent API support) + */ + public function addCcFiles(CcFiles $l) + { + if ($this->collCcFiless === null) { + $this->initCcFiless(); + $this->collCcFilessPartial = true; + } + + if (!in_array($l, $this->collCcFiless->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcFiles($l); + + if ($this->ccFilessScheduledForDeletion and $this->ccFilessScheduledForDeletion->contains($l)) { + $this->ccFilessScheduledForDeletion->remove($this->ccFilessScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcFiles $ccFiles The ccFiles object to add. + */ + protected function doAddCcFiles($ccFiles) + { + $this->collCcFiless[]= $ccFiles; + $ccFiles->setCcMusicDirs($this); + } + + /** + * @param CcFiles $ccFiles The ccFiles object to remove. + * @return CcMusicDirs The current object (for fluent API support) + */ + public function removeCcFiles($ccFiles) + { + if ($this->getCcFiless()->contains($ccFiles)) { + $this->collCcFiless->remove($this->collCcFiless->search($ccFiles)); + if (null === $this->ccFilessScheduledForDeletion) { + $this->ccFilessScheduledForDeletion = clone $this->collCcFiless; + $this->ccFilessScheduledForDeletion->clear(); + } + $this->ccFilessScheduledForDeletion[]= $ccFiles; + $ccFiles->setCcMusicDirs(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcMusicDirs is new, it will return + * an empty collection; or if this CcMusicDirs has previously + * been saved, it will retrieve related CcFiless 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 CcMusicDirs. + * + * @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 PropelObjectCollection|CcFiles[] List of CcFiles objects + */ + public function getCcFilessJoinFkOwner($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcFilesQuery::create(null, $criteria); + $query->joinWith('FkOwner', $join_behavior); + + return $this->getCcFiless($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcMusicDirs is new, it will return + * an empty collection; or if this CcMusicDirs has previously + * been saved, it will retrieve related CcFiless 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 CcMusicDirs. + * + * @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 PropelObjectCollection|CcFiles[] List of CcFiles objects + */ + public function getCcFilessJoinCcSubjsRelatedByDbEditedby($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcFilesQuery::create(null, $criteria); + $query->joinWith('CcSubjsRelatedByDbEditedby', $join_behavior); + + return $this->getCcFiless($query, $con); + } + + /** + * Clears out the collAudioFiles 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 CcMusicDirs The current object (for fluent API support) + * @see addAudioFiles() + */ + public function clearAudioFiles() + { + $this->collAudioFiles = null; // important to set this to null since that means it is uninitialized + $this->collAudioFilesPartial = null; + + return $this; + } + + /** + * reset is the collAudioFiles collection loaded partially + * + * @return void + */ + public function resetPartialAudioFiles($v = true) + { + $this->collAudioFilesPartial = $v; + } + + /** + * Initializes the collAudioFiles collection. + * + * By default this just sets the collAudioFiles collection to an empty array (like clearcollAudioFiles()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initAudioFiles($overrideExisting = true) + { + if (null !== $this->collAudioFiles && !$overrideExisting) { + return; + } + $this->collAudioFiles = new PropelObjectCollection(); + $this->collAudioFiles->setModel('AudioFile'); + } + + /** + * Gets an array of AudioFile 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 CcMusicDirs 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 PropelObjectCollection|AudioFile[] List of AudioFile objects + * @throws PropelException + */ + public function getAudioFiles($criteria = null, PropelPDO $con = null) + { + $partial = $this->collAudioFilesPartial && !$this->isNew(); + if (null === $this->collAudioFiles || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAudioFiles) { + // return empty collection + $this->initAudioFiles(); + } else { + $collAudioFiles = AudioFileQuery::create(null, $criteria) + ->filterByCcMusicDirs($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collAudioFilesPartial && count($collAudioFiles)) { + $this->initAudioFiles(false); + + foreach ($collAudioFiles as $obj) { + if (false == $this->collAudioFiles->contains($obj)) { + $this->collAudioFiles->append($obj); + } + } + + $this->collAudioFilesPartial = true; + } + + $collAudioFiles->getInternalIterator()->rewind(); + + return $collAudioFiles; + } + + if ($partial && $this->collAudioFiles) { + foreach ($this->collAudioFiles as $obj) { + if ($obj->isNew()) { + $collAudioFiles[] = $obj; + } + } + } + + $this->collAudioFiles = $collAudioFiles; + $this->collAudioFilesPartial = false; + } + } + + return $this->collAudioFiles; + } + + /** + * Sets a collection of AudioFile objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $audioFiles A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcMusicDirs The current object (for fluent API support) + */ + public function setAudioFiles(PropelCollection $audioFiles, PropelPDO $con = null) + { + $audioFilesToDelete = $this->getAudioFiles(new Criteria(), $con)->diff($audioFiles); + + + $this->audioFilesScheduledForDeletion = $audioFilesToDelete; + + foreach ($audioFilesToDelete as $audioFileRemoved) { + $audioFileRemoved->setCcMusicDirs(null); + } + + $this->collAudioFiles = null; + foreach ($audioFiles as $audioFile) { + $this->addAudioFile($audioFile); + } + + $this->collAudioFiles = $audioFiles; + $this->collAudioFilesPartial = false; + + return $this; + } + + /** + * Returns the number of related AudioFile objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related AudioFile objects. + * @throws PropelException + */ + public function countAudioFiles(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collAudioFilesPartial && !$this->isNew(); + if (null === $this->collAudioFiles || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAudioFiles) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getAudioFiles()); + } + $query = AudioFileQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcMusicDirs($this) + ->count($con); + } + + return count($this->collAudioFiles); + } + + /** + * Method called to associate a AudioFile object to this object + * through the AudioFile foreign key attribute. + * + * @param AudioFile $l AudioFile + * @return CcMusicDirs The current object (for fluent API support) + */ + public function addAudioFile(AudioFile $l) + { + if ($this->collAudioFiles === null) { + $this->initAudioFiles(); + $this->collAudioFilesPartial = true; + } + + if (!in_array($l, $this->collAudioFiles->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddAudioFile($l); + + if ($this->audioFilesScheduledForDeletion and $this->audioFilesScheduledForDeletion->contains($l)) { + $this->audioFilesScheduledForDeletion->remove($this->audioFilesScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param AudioFile $audioFile The audioFile object to add. + */ + protected function doAddAudioFile($audioFile) + { + $this->collAudioFiles[]= $audioFile; + $audioFile->setCcMusicDirs($this); + } + + /** + * @param AudioFile $audioFile The audioFile object to remove. + * @return CcMusicDirs The current object (for fluent API support) + */ + public function removeAudioFile($audioFile) + { + if ($this->getAudioFiles()->contains($audioFile)) { + $this->collAudioFiles->remove($this->collAudioFiles->search($audioFile)); + if (null === $this->audioFilesScheduledForDeletion) { + $this->audioFilesScheduledForDeletion = clone $this->collAudioFiles; + $this->audioFilesScheduledForDeletion->clear(); + } + $this->audioFilesScheduledForDeletion[]= $audioFile; + $audioFile->setCcMusicDirs(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcMusicDirs is new, it will return + * an empty collection; or if this CcMusicDirs has previously + * been saved, it will retrieve related AudioFiles 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 CcMusicDirs. + * + * @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 PropelObjectCollection|AudioFile[] List of AudioFile objects + */ + public function getAudioFilesJoinMediaItem($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = AudioFileQuery::create(null, $criteria); + $query->joinWith('MediaItem', $join_behavior); + + return $this->getAudioFiles($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcMusicDirs is new, it will return + * an empty collection; or if this CcMusicDirs has previously + * been saved, it will retrieve related AudioFiles 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 CcMusicDirs. + * + * @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 PropelObjectCollection|AudioFile[] List of AudioFile objects + */ + public function getAudioFilesJoinCcSubjs($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = AudioFileQuery::create(null, $criteria); + $query->joinWith('CcSubjs', $join_behavior); + + return $this->getAudioFiles($query, $con); + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->directory = null; + $this->type = null; + $this->exists = null; + $this->watched = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->collCcFiless) { + foreach ($this->collCcFiless as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collAudioFiles) { + foreach ($this->collAudioFiles as $o) { + $o->clearAllReferences($deep); + } + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + if ($this->collCcFiless instanceof PropelCollection) { + $this->collCcFiless->clearIterator(); + } + $this->collCcFiless = null; + if ($this->collAudioFiles instanceof PropelCollection) { + $this->collAudioFiles->clearIterator(); + } + $this->collAudioFiles = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcMusicDirsPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcMusicDirsPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcMusicDirsPeer.php index 22f30f960..2fa8bd779 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcMusicDirsPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcMusicDirsPeer.php @@ -1,750 +1,784 @@ array ('Id', 'Directory', 'Type', 'Exists', 'Watched', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'directory', 'type', 'exists', 'watched', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::DIRECTORY, self::TYPE, self::EXISTS, self::WATCHED, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'DIRECTORY', 'TYPE', 'EXISTS', 'WATCHED', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'directory', 'type', 'exists', 'watched', ), - 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, 'Directory' => 1, 'Type' => 2, 'Exists' => 3, 'Watched' => 4, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'directory' => 1, 'type' => 2, 'exists' => 3, 'watched' => 4, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::DIRECTORY => 1, self::TYPE => 2, self::EXISTS => 3, self::WATCHED => 4, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'DIRECTORY' => 1, 'TYPE' => 2, 'EXISTS' => 3, 'WATCHED' => 4, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'directory' => 1, 'type' => 2, 'exists' => 3, 'watched' => 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. CcMusicDirsPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcMusicDirsPeer::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(CcMusicDirsPeer::ID); - $criteria->addSelectColumn(CcMusicDirsPeer::DIRECTORY); - $criteria->addSelectColumn(CcMusicDirsPeer::TYPE); - $criteria->addSelectColumn(CcMusicDirsPeer::EXISTS); - $criteria->addSelectColumn(CcMusicDirsPeer::WATCHED); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.DIRECTORY'); - $criteria->addSelectColumn($alias . '.TYPE'); - $criteria->addSelectColumn($alias . '.EXISTS'); - $criteria->addSelectColumn($alias . '.WATCHED'); - } - } - - /** - * 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(CcMusicDirsPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcMusicDirsPeer::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(CcMusicDirsPeer::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 CcMusicDirs - * @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 = CcMusicDirsPeer::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 CcMusicDirsPeer::populateObjects(CcMusicDirsPeer::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(CcMusicDirsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcMusicDirsPeer::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 CcMusicDirs $value A CcMusicDirs object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcMusicDirs $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 CcMusicDirs object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcMusicDirs) { - $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 CcMusicDirs 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 CcMusicDirs 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_music_dirs - * 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 = CcMusicDirsPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcMusicDirsPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcMusicDirsPeer::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; - CcMusicDirsPeer::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 (CcMusicDirs object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcMusicDirsPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcMusicDirsPeer::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 + CcMusicDirsPeer::NUM_COLUMNS; - } else { - $cls = CcMusicDirsPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcMusicDirsPeer::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(BaseCcMusicDirsPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcMusicDirsPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcMusicDirsTableMap()); - } - } - - /** - * 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 ? CcMusicDirsPeer::CLASS_DEFAULT : CcMusicDirsPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcMusicDirs or Criteria object. - * - * @param mixed $values Criteria or CcMusicDirs 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(CcMusicDirsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcMusicDirs object - } - - if ($criteria->containsKey(CcMusicDirsPeer::ID) && $criteria->keyContainsValue(CcMusicDirsPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcMusicDirsPeer::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 CcMusicDirs or Criteria object. - * - * @param mixed $values Criteria or CcMusicDirs 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(CcMusicDirsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcMusicDirsPeer::ID); - $value = $criteria->remove(CcMusicDirsPeer::ID); - if ($value) { - $selectCriteria->add(CcMusicDirsPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcMusicDirsPeer::TABLE_NAME); - } - - } else { // $values is CcMusicDirs 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_music_dirs 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(CcMusicDirsPeer::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(CcMusicDirsPeer::TABLE_NAME, $con, CcMusicDirsPeer::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). - CcMusicDirsPeer::clearInstancePool(); - CcMusicDirsPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcMusicDirs or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcMusicDirs 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(CcMusicDirsPeer::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. - CcMusicDirsPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcMusicDirs) { // it's a model object - // invalidate the cache for this single object - CcMusicDirsPeer::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(CcMusicDirsPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcMusicDirsPeer::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); - CcMusicDirsPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcMusicDirs 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 CcMusicDirs $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(CcMusicDirs $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcMusicDirsPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcMusicDirsPeer::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(CcMusicDirsPeer::DATABASE_NAME, CcMusicDirsPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcMusicDirs - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcMusicDirsPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcMusicDirsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcMusicDirsPeer::DATABASE_NAME); - $criteria->add(CcMusicDirsPeer::ID, $pk); - - $v = CcMusicDirsPeer::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(CcMusicDirsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcMusicDirsPeer::DATABASE_NAME); - $criteria->add(CcMusicDirsPeer::ID, $pks, Criteria::IN); - $objs = CcMusicDirsPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcMusicDirsPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_music_dirs'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcMusicDirs'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcMusicDirsTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 5; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 5; + + /** the column name for the id field */ + const ID = 'cc_music_dirs.id'; + + /** the column name for the directory field */ + const DIRECTORY = 'cc_music_dirs.directory'; + + /** the column name for the type field */ + const TYPE = 'cc_music_dirs.type'; + + /** the column name for the exists field */ + const EXISTS = 'cc_music_dirs.exists'; + + /** the column name for the watched field */ + const WATCHED = 'cc_music_dirs.watched'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcMusicDirs objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcMusicDirs[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcMusicDirsPeer::$fieldNames[CcMusicDirsPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('Id', 'Directory', 'Type', 'Exists', 'Watched', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'directory', 'type', 'exists', 'watched', ), + BasePeer::TYPE_COLNAME => array (CcMusicDirsPeer::ID, CcMusicDirsPeer::DIRECTORY, CcMusicDirsPeer::TYPE, CcMusicDirsPeer::EXISTS, CcMusicDirsPeer::WATCHED, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'DIRECTORY', 'TYPE', 'EXISTS', 'WATCHED', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'directory', 'type', 'exists', 'watched', ), + 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. CcMusicDirsPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Directory' => 1, 'Type' => 2, 'Exists' => 3, 'Watched' => 4, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'directory' => 1, 'type' => 2, 'exists' => 3, 'watched' => 4, ), + BasePeer::TYPE_COLNAME => array (CcMusicDirsPeer::ID => 0, CcMusicDirsPeer::DIRECTORY => 1, CcMusicDirsPeer::TYPE => 2, CcMusicDirsPeer::EXISTS => 3, CcMusicDirsPeer::WATCHED => 4, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'DIRECTORY' => 1, 'TYPE' => 2, 'EXISTS' => 3, 'WATCHED' => 4, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'directory' => 1, 'type' => 2, 'exists' => 3, 'watched' => 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcMusicDirsPeer::getFieldNames($toType); + $key = isset(CcMusicDirsPeer::$fieldKeys[$fromType][$name]) ? CcMusicDirsPeer::$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(CcMusicDirsPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcMusicDirsPeer::$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 CcMusicDirsPeer::$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. CcMusicDirsPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcMusicDirsPeer::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(CcMusicDirsPeer::ID); + $criteria->addSelectColumn(CcMusicDirsPeer::DIRECTORY); + $criteria->addSelectColumn(CcMusicDirsPeer::TYPE); + $criteria->addSelectColumn(CcMusicDirsPeer::EXISTS); + $criteria->addSelectColumn(CcMusicDirsPeer::WATCHED); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.directory'); + $criteria->addSelectColumn($alias . '.type'); + $criteria->addSelectColumn($alias . '.exists'); + $criteria->addSelectColumn($alias . '.watched'); + } + } + + /** + * 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(CcMusicDirsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcMusicDirsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcMusicDirsPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcMusicDirsPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcMusicDirs + * @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 = CcMusicDirsPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcMusicDirsPeer::populateObjects(CcMusicDirsPeer::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 directly (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(CcMusicDirsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcMusicDirsPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcMusicDirsPeer::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 CcMusicDirs $obj A CcMusicDirs object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getId(); + } // if key === null + CcMusicDirsPeer::$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 CcMusicDirs object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcMusicDirs) { + $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 CcMusicDirs object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcMusicDirsPeer::$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 CcMusicDirs 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(CcMusicDirsPeer::$instances[$key])) { + return CcMusicDirsPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcMusicDirsPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcMusicDirsPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_music_dirs + * 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 = CcMusicDirsPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcMusicDirsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcMusicDirsPeer::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; + CcMusicDirsPeer::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 (CcMusicDirs object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcMusicDirsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcMusicDirsPeer::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 + CcMusicDirsPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcMusicDirsPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcMusicDirsPeer::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(CcMusicDirsPeer::DATABASE_NAME)->getTable(CcMusicDirsPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcMusicDirsPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcMusicDirsPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcMusicDirsTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcMusicDirsPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcMusicDirs or Criteria object. + * + * @param mixed $values Criteria or CcMusicDirs 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(CcMusicDirsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcMusicDirs object + } + + if ($criteria->containsKey(CcMusicDirsPeer::ID) && $criteria->keyContainsValue(CcMusicDirsPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcMusicDirsPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcMusicDirsPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcMusicDirs or Criteria object. + * + * @param mixed $values Criteria or CcMusicDirs 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(CcMusicDirsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcMusicDirsPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcMusicDirsPeer::ID); + $value = $criteria->remove(CcMusicDirsPeer::ID); + if ($value) { + $selectCriteria->add(CcMusicDirsPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcMusicDirsPeer::TABLE_NAME); + } + + } else { // $values is CcMusicDirs object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcMusicDirsPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_music_dirs table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcMusicDirsPeer::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(CcMusicDirsPeer::TABLE_NAME, $con, CcMusicDirsPeer::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). + CcMusicDirsPeer::clearInstancePool(); + CcMusicDirsPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcMusicDirs or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcMusicDirs 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(CcMusicDirsPeer::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. + CcMusicDirsPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcMusicDirs) { // it's a model object + // invalidate the cache for this single object + CcMusicDirsPeer::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(CcMusicDirsPeer::DATABASE_NAME); + $criteria->add(CcMusicDirsPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcMusicDirsPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcMusicDirsPeer::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); + CcMusicDirsPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcMusicDirs 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 CcMusicDirs $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcMusicDirsPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcMusicDirsPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcMusicDirsPeer::DATABASE_NAME, CcMusicDirsPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcMusicDirs + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcMusicDirsPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcMusicDirsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcMusicDirsPeer::DATABASE_NAME); + $criteria->add(CcMusicDirsPeer::ID, $pk); + + $v = CcMusicDirsPeer::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 + * @return CcMusicDirs[] + * @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(CcMusicDirsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcMusicDirsPeer::DATABASE_NAME); + $criteria->add(CcMusicDirsPeer::ID, $pks, Criteria::IN); + $objs = CcMusicDirsPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcMusicDirsPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcMusicDirsQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcMusicDirsQuery.php index 31bbec3d4..7fd2315ce 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcMusicDirsQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcMusicDirsQuery.php @@ -1,327 +1,577 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcMusicDirs|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcMusicDirsPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcMusicDirs|CcMusicDirs[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcMusicDirsPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcMusicDirsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcMusicDirsQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcMusicDirsPeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcMusicDirs A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcMusicDirsQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcMusicDirsPeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcMusicDirs A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "directory", "type", "exists", "watched" FROM "cc_music_dirs" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcMusicDirs(); + $obj->hydrate($row); + CcMusicDirsPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcMusicDirsQuery 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(CcMusicDirsPeer::ID, $id, $comparison); - } + return $obj; + } - /** - * Filter the query on the directory column - * - * @param string $directory 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 CcMusicDirsQuery The current query, for fluid interface - */ - public function filterByDirectory($directory = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($directory)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $directory)) { - $directory = str_replace('*', '%', $directory); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcMusicDirsPeer::DIRECTORY, $directory, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcMusicDirs|CcMusicDirs[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * 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 CcMusicDirsQuery 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(CcMusicDirsPeer::TYPE, $type, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query on the exists column - * - * @param boolean|string $exists The value to use as filter. - * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcMusicDirsQuery The current query, for fluid interface - */ - public function filterByExists($exists = null, $comparison = null) - { - if (is_string($exists)) { - $exists = in_array(strtolower($exists), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; - } - return $this->addUsingAlias(CcMusicDirsPeer::EXISTS, $exists, $comparison); - } + /** + * 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|CcMusicDirs[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query on the watched column - * - * @param boolean|string $watched The value to use as filter. - * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcMusicDirsQuery The current query, for fluid interface - */ - public function filterByWatched($watched = null, $comparison = null) - { - if (is_string($watched)) { - $watched = in_array(strtolower($watched), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; - } - return $this->addUsingAlias(CcMusicDirsPeer::WATCHED, $watched, $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * 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 CcMusicDirsQuery The current query, for fluid interface - */ - public function filterByCcFiles($ccFiles, $comparison = null) - { - return $this - ->addUsingAlias(CcMusicDirsPeer::ID, $ccFiles->getDbDirectory(), $comparison); - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcMusicDirsQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { - /** - * 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 CcMusicDirsQuery 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; - } + return $this->addUsingAlias(CcMusicDirsPeer::ID, $key, Criteria::EQUAL); + } - /** - * 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 list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return CcMusicDirsQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { - /** - * Exclude object from result - * - * @param CcMusicDirs $ccMusicDirs Object to remove from the list of results - * - * @return CcMusicDirsQuery The current query, for fluid interface - */ - public function prune($ccMusicDirs = null) - { - if ($ccMusicDirs) { - $this->addUsingAlias(CcMusicDirsPeer::ID, $ccMusicDirs->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } + return $this->addUsingAlias(CcMusicDirsPeer::ID, $keys, Criteria::IN); + } -} // BaseCcMusicDirsQuery + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcMusicDirsQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CcMusicDirsPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CcMusicDirsPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcMusicDirsPeer::ID, $id, $comparison); + } + + /** + * Filter the query on the directory column + * + * Example usage: + * + * $query->filterByDirectory('fooValue'); // WHERE directory = 'fooValue' + * $query->filterByDirectory('%fooValue%'); // WHERE directory LIKE '%fooValue%' + * + * + * @param string $directory 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 CcMusicDirsQuery The current query, for fluid interface + */ + public function filterByDirectory($directory = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($directory)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $directory)) { + $directory = str_replace('*', '%', $directory); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcMusicDirsPeer::DIRECTORY, $directory, $comparison); + } + + /** + * Filter the query on the type column + * + * Example usage: + * + * $query->filterByType('fooValue'); // WHERE type = 'fooValue' + * $query->filterByType('%fooValue%'); // WHERE type LIKE '%fooValue%' + * + * + * @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 CcMusicDirsQuery 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(CcMusicDirsPeer::TYPE, $type, $comparison); + } + + /** + * Filter the query on the exists column + * + * Example usage: + * + * $query->filterByExists(true); // WHERE exists = true + * $query->filterByExists('yes'); // WHERE exists = true + * + * + * @param boolean|string $exists The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcMusicDirsQuery The current query, for fluid interface + */ + public function filterByExists($exists = null, $comparison = null) + { + if (is_string($exists)) { + $exists = in_array(strtolower($exists), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CcMusicDirsPeer::EXISTS, $exists, $comparison); + } + + /** + * Filter the query on the watched column + * + * Example usage: + * + * $query->filterByWatched(true); // WHERE watched = true + * $query->filterByWatched('yes'); // WHERE watched = true + * + * + * @param boolean|string $watched The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcMusicDirsQuery The current query, for fluid interface + */ + public function filterByWatched($watched = null, $comparison = null) + { + if (is_string($watched)) { + $watched = in_array(strtolower($watched), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CcMusicDirsPeer::WATCHED, $watched, $comparison); + } + + /** + * Filter the query by a related CcFiles object + * + * @param CcFiles|PropelObjectCollection $ccFiles the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcMusicDirsQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcFiles($ccFiles, $comparison = null) + { + if ($ccFiles instanceof CcFiles) { + return $this + ->addUsingAlias(CcMusicDirsPeer::ID, $ccFiles->getDbDirectory(), $comparison); + } elseif ($ccFiles instanceof PropelObjectCollection) { + return $this + ->useCcFilesQuery() + ->filterByPrimaryKeys($ccFiles->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcFiles() only accepts arguments of type CcFiles or PropelCollection'); + } + } + + /** + * 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 CcMusicDirsQuery The current query, for fluid interface + */ + public function joinCcFiles($relationAlias = null, $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 \Airtime\CcFilesQuery A secondary query class using the current class as primary query + */ + public function useCcFilesQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcFiles($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcFiles', '\Airtime\CcFilesQuery'); + } + + /** + * Filter the query by a related AudioFile object + * + * @param AudioFile|PropelObjectCollection $audioFile the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcMusicDirsQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByAudioFile($audioFile, $comparison = null) + { + if ($audioFile instanceof AudioFile) { + return $this + ->addUsingAlias(CcMusicDirsPeer::ID, $audioFile->getDirectory(), $comparison); + } elseif ($audioFile instanceof PropelObjectCollection) { + return $this + ->useAudioFileQuery() + ->filterByPrimaryKeys($audioFile->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByAudioFile() only accepts arguments of type AudioFile or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the AudioFile relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcMusicDirsQuery The current query, for fluid interface + */ + public function joinAudioFile($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('AudioFile'); + + // 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, 'AudioFile'); + } + + return $this; + } + + /** + * Use the AudioFile relation AudioFile 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 \Airtime\MediaItem\AudioFileQuery A secondary query class using the current class as primary query + */ + public function useAudioFileQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinAudioFile($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'AudioFile', '\Airtime\MediaItem\AudioFileQuery'); + } + + /** + * Exclude object from result + * + * @param CcMusicDirs $ccMusicDirs Object to remove from the list of results + * + * @return CcMusicDirsQuery The current query, for fluid interface + */ + public function prune($ccMusicDirs = null) + { + if ($ccMusicDirs) { + $this->addUsingAlias(CcMusicDirsPeer::ID, $ccMusicDirs->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPerms.php b/airtime_mvc/application/models/airtime/om/BaseCcPerms.php deleted file mode 100644 index a86413fc1..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcPerms.php +++ /dev/null @@ -1,945 +0,0 @@ -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->getDbId() !== $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->getDbId()) { - $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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->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->getDbId()); - } - - $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/airtime_mvc/application/models/airtime/om/BaseCcPermsPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcPermsPeer.php deleted file mode 100644 index 4bd4c07ea..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcPermsPeer.php +++ /dev/null @@ -1,984 +0,0 @@ - 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/airtime_mvc/application/models/airtime/om/BaseCcPermsQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcPermsQuery.php deleted file mode 100644 index 5866aa488..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcPermsQuery.php +++ /dev/null @@ -1,355 +0,0 @@ -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->getDbId(), $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/airtime_mvc/application/models/airtime/om/BaseCcPlaylist.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylist.php index 73b081708..10e5be19b 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylist.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylist.php @@ -1,1416 +1,1709 @@ name = ''; - $this->length = '00:00:00'; - } - - /** - * 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 [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 [optionally formatted] temporal [utime] 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 getDbUtime($format = 'Y-m-d H:i:s') - { - if ($this->utime === null) { - return null; - } - - - - try { - $dt = new DateTime($this->utime); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->utime, 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_id] column value. - * - * @return int - */ - public function getDbCreatorId() - { - return $this->creator_id; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDbDescription() - { - return $this->description; - } - - /** - * Get the [length] column value. - * - * @return string - */ - public function getDbLength() - { - return $this->length; - } - - /** - * 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() - - /** - * 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() - - /** - * Sets the value of [utime] 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 setDbUtime($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->utime !== null || $dt !== null ) { - // (nested ifs are a little easier to read in this case) - - $currNorm = ($this->utime !== null && $tmpDt = new DateTime($this->utime)) ? $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->utime = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); - $this->modifiedColumns[] = CcPlaylistPeer::UTIME; - } - } // if either are not null - - return $this; - } // setDbUtime() - - /** - * Set the value of [creator_id] column. - * - * @param int $v new value - * @return CcPlaylist The current object (for fluent API support) - */ - public function setDbCreatorId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->creator_id !== $v) { - $this->creator_id = $v; - $this->modifiedColumns[] = CcPlaylistPeer::CREATOR_ID; - } - - if ($this->aCcSubjs !== null && $this->aCcSubjs->getDbId() !== $v) { - $this->aCcSubjs = null; - } - - return $this; - } // setDbCreatorId() - - /** - * 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() - - /** - * Set the value of [length] column. - * - * @param string $v new value - * @return CcPlaylist The current object (for fluent API support) - */ - public function setDbLength($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->length !== $v || $this->isNew()) { - $this->length = $v; - $this->modifiedColumns[] = CcPlaylistPeer::LENGTH; - } - - return $this; - } // setDbLength() - - /** - * 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->length !== '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->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->mtime = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->utime = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->creator_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->description = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->length = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 7; // 7 = 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->creator_id !== $this->aCcSubjs->getDbId()) { - $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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->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->getDbMtime(); - break; - case 3: - return $this->getDbUtime(); - break; - case 4: - return $this->getDbCreatorId(); - break; - case 5: - return $this->getDbDescription(); - break; - case 6: - return $this->getDbLength(); - 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->getDbMtime(), - $keys[3] => $this->getDbUtime(), - $keys[4] => $this->getDbCreatorId(), - $keys[5] => $this->getDbDescription(), - $keys[6] => $this->getDbLength(), - ); - 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->setDbMtime($value); - break; - case 3: - $this->setDbUtime($value); - break; - case 4: - $this->setDbCreatorId($value); - break; - case 5: - $this->setDbDescription($value); - break; - case 6: - $this->setDbLength($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->setDbMtime($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbUtime($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbCreatorId($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbDescription($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDbLength($arr[$keys[6]]); - } - - /** - * 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::MTIME)) $criteria->add(CcPlaylistPeer::MTIME, $this->mtime); - if ($this->isColumnModified(CcPlaylistPeer::UTIME)) $criteria->add(CcPlaylistPeer::UTIME, $this->utime); - if ($this->isColumnModified(CcPlaylistPeer::CREATOR_ID)) $criteria->add(CcPlaylistPeer::CREATOR_ID, $this->creator_id); - if ($this->isColumnModified(CcPlaylistPeer::DESCRIPTION)) $criteria->add(CcPlaylistPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(CcPlaylistPeer::LENGTH)) $criteria->add(CcPlaylistPeer::LENGTH, $this->length); - - 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->setDbMtime($this->mtime); - $copyObj->setDbUtime($this->utime); - $copyObj->setDbCreatorId($this->creator_id); - $copyObj->setDbDescription($this->description); - $copyObj->setDbLength($this->length); - - 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->setDbCreatorId(NULL); - } else { - $this->setDbCreatorId($v->getDbId()); - } - - $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->creator_id !== null)) { - $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->creator_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->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); - } - - - /** - * 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 getCcPlaylistcontentssJoinCcBlock($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcPlaylistcontentsQuery::create(null, $criteria); - $query->joinWith('CcBlock', $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->mtime = null; - $this->utime = null; - $this->creator_id = null; - $this->description = null; - $this->length = 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; - } - - // aggregate_column behavior - - /** - * Computes the value of the aggregate column length - * - * @param PropelPDO $con A connection object - * - * @return mixed The scalar result from the aggregate query - */ - public function computeDbLength(PropelPDO $con) - { - $stmt = $con->prepare('SELECT SUM(cliplength) FROM "cc_playlistcontents" WHERE cc_playlistcontents.PLAYLIST_ID = :p1'); - $stmt->bindValue(':p1', $this->getDbId()); - $stmt->execute(); - return $stmt->fetchColumn(); - } - - /** - * Updates the aggregate column length - * - * @param PropelPDO $con A connection object - */ - public function updateDbLength(PropelPDO $con) - { - $this->setDbLength($this->computeDbLength($con)); - $this->save($con); - } - - /** - * 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 + /** + * Peer class name + */ + const PEER = 'Airtime\\CcPlaylistPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcPlaylistPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the name field. + * Note: this column has a database default value of: '' + * @var string + */ + protected $name; + + /** + * The value for the mtime field. + * @var string + */ + protected $mtime; + + /** + * The value for the utime field. + * @var string + */ + protected $utime; + + /** + * The value for the creator_id field. + * @var int + */ + protected $creator_id; + + /** + * The value for the description field. + * @var string + */ + protected $description; + + /** + * The value for the length field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $length; + + /** + * @var CcSubjs + */ + protected $aCcSubjs; + + /** + * @var PropelObjectCollection|CcPlaylistcontents[] Collection to store aggregation of CcPlaylistcontents objects. + */ + protected $collCcPlaylistcontentss; + protected $collCcPlaylistcontentssPartial; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccPlaylistcontentssScheduledForDeletion = null; + + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->name = ''; + $this->length = '00:00:00'; + } + + /** + * 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 [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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [optionally formatted] temporal [utime] 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 getDbUtime($format = 'Y-m-d H:i:s') + { + if ($this->utime === null) { + return null; + } + + + try { + $dt = new DateTime($this->utime); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->utime, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [creator_id] column value. + * + * @return int + */ + public function getDbCreatorId() + { + + return $this->creator_id; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDbDescription() + { + + return $this->description; + } + + /** + * Get the [length] column value. + * + * @return string + */ + public function getDbLength() + { + + return $this->length; + } + + /** + * 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 && is_numeric($v)) { + $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 && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = CcPlaylistPeer::NAME; + } + + + return $this; + } // setDbName() + + /** + * 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 strings are treated as null. + * @return CcPlaylist The current object (for fluent API support) + */ + public function setDbMtime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->mtime !== null || $dt !== null) { + $currentDateAsString = ($this->mtime !== null && $tmpDt = new DateTime($this->mtime)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->mtime = $newDateAsString; + $this->modifiedColumns[] = CcPlaylistPeer::MTIME; + } + } // if either are not null + + + return $this; + } // setDbMtime() + + /** + * Sets the value of [utime] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return CcPlaylist The current object (for fluent API support) + */ + public function setDbUtime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->utime !== null || $dt !== null) { + $currentDateAsString = ($this->utime !== null && $tmpDt = new DateTime($this->utime)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->utime = $newDateAsString; + $this->modifiedColumns[] = CcPlaylistPeer::UTIME; + } + } // if either are not null + + + return $this; + } // setDbUtime() + + /** + * Set the value of [creator_id] column. + * + * @param int $v new value + * @return CcPlaylist The current object (for fluent API support) + */ + public function setDbCreatorId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->creator_id !== $v) { + $this->creator_id = $v; + $this->modifiedColumns[] = CcPlaylistPeer::CREATOR_ID; + } + + if ($this->aCcSubjs !== null && $this->aCcSubjs->getDbId() !== $v) { + $this->aCcSubjs = null; + } + + + return $this; + } // setDbCreatorId() + + /** + * 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 && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = CcPlaylistPeer::DESCRIPTION; + } + + + return $this; + } // setDbDescription() + + /** + * Set the value of [length] column. + * + * @param string $v new value + * @return CcPlaylist The current object (for fluent API support) + */ + public function setDbLength($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->length !== $v) { + $this->length = $v; + $this->modifiedColumns[] = CcPlaylistPeer::LENGTH; + } + + + return $this; + } // setDbLength() + + /** + * 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->length !== '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 resultset 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->mtime = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->utime = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->creator_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; + $this->description = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->length = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 7; // 7 = CcPlaylistPeer::NUM_HYDRATE_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->creator_id !== $this->aCcSubjs->getDbId()) { + $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 + * @throws Exception + * @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 { + $deleteQuery = CcPlaylistQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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); + // aggregate_column behavior + if (null !== $this->collCcPlaylistcontentss) { + $this->setDbLength($this->computeDbLength($con)); + if ($this->isModified()) { + $this->save($con); + } + } + + CcPlaylistPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding 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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->ccPlaylistcontentssScheduledForDeletion !== null) { + if (!$this->ccPlaylistcontentssScheduledForDeletion->isEmpty()) { + CcPlaylistcontentsQuery::create() + ->filterByPrimaryKeys($this->ccPlaylistcontentssScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccPlaylistcontentssScheduledForDeletion = null; + } + } + + if ($this->collCcPlaylistcontentss !== null) { + foreach ($this->collCcPlaylistcontentss as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcPlaylistPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcPlaylistPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_playlist_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcPlaylistPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcPlaylistPeer::NAME)) { + $modifiedColumns[':p' . $index++] = '"name"'; + } + if ($this->isColumnModified(CcPlaylistPeer::MTIME)) { + $modifiedColumns[':p' . $index++] = '"mtime"'; + } + if ($this->isColumnModified(CcPlaylistPeer::UTIME)) { + $modifiedColumns[':p' . $index++] = '"utime"'; + } + if ($this->isColumnModified(CcPlaylistPeer::CREATOR_ID)) { + $modifiedColumns[':p' . $index++] = '"creator_id"'; + } + if ($this->isColumnModified(CcPlaylistPeer::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = '"description"'; + } + if ($this->isColumnModified(CcPlaylistPeer::LENGTH)) { + $modifiedColumns[':p' . $index++] = '"length"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_playlist" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"name"': + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); + break; + case '"mtime"': + $stmt->bindValue($identifier, $this->mtime, PDO::PARAM_STR); + break; + case '"utime"': + $stmt->bindValue($identifier, $this->utime, PDO::PARAM_STR); + break; + case '"creator_id"': + $stmt->bindValue($identifier, $this->creator_id, PDO::PARAM_INT); + break; + case '"description"': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case '"length"': + $stmt->bindValue($identifier, $this->length, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @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->getDbMtime(); + break; + case 3: + return $this->getDbUtime(); + break; + case 4: + return $this->getDbCreatorId(); + break; + case 5: + return $this->getDbDescription(); + break; + case 6: + return $this->getDbLength(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcPlaylist'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcPlaylist'][$this->getPrimaryKey()] = true; + $keys = CcPlaylistPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbName(), + $keys[2] => $this->getDbMtime(), + $keys[3] => $this->getDbUtime(), + $keys[4] => $this->getDbCreatorId(), + $keys[5] => $this->getDbDescription(), + $keys[6] => $this->getDbLength(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcSubjs) { + $result['CcSubjs'] = $this->aCcSubjs->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collCcPlaylistcontentss) { + $result['CcPlaylistcontentss'] = $this->collCcPlaylistcontentss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcPlaylistPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbMtime($value); + break; + case 3: + $this->setDbUtime($value); + break; + case 4: + $this->setDbCreatorId($value); + break; + case 5: + $this->setDbDescription($value); + break; + case 6: + $this->setDbLength($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 BasePeer::TYPE_PHPNAME + * + * @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->setDbMtime($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbUtime($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbCreatorId($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbDescription($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbLength($arr[$keys[6]]); + } + + /** + * 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::MTIME)) $criteria->add(CcPlaylistPeer::MTIME, $this->mtime); + if ($this->isColumnModified(CcPlaylistPeer::UTIME)) $criteria->add(CcPlaylistPeer::UTIME, $this->utime); + if ($this->isColumnModified(CcPlaylistPeer::CREATOR_ID)) $criteria->add(CcPlaylistPeer::CREATOR_ID, $this->creator_id); + if ($this->isColumnModified(CcPlaylistPeer::DESCRIPTION)) $criteria->add(CcPlaylistPeer::DESCRIPTION, $this->description); + if ($this->isColumnModified(CcPlaylistPeer::LENGTH)) $criteria->add(CcPlaylistPeer::LENGTH, $this->length); + + 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. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbName($this->getDbName()); + $copyObj->setDbMtime($this->getDbMtime()); + $copyObj->setDbUtime($this->getDbUtime()); + $copyObj->setDbCreatorId($this->getDbCreatorId()); + $copyObj->setDbDescription($this->getDbDescription()); + $copyObj->setDbLength($this->getDbLength()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + 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)); + } + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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->setDbCreatorId(NULL); + } else { + $this->setDbCreatorId($v->getDbId()); + } + + $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 $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getCcSubjs(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcSubjs === null && ($this->creator_id !== null) && $doQuery) { + $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->creator_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->aCcSubjs->addCcPlaylists($this); + */ + } + + return $this->aCcSubjs; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('CcPlaylistcontents' == $relationName) { + $this->initCcPlaylistcontentss(); + } + } + + /** + * 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 CcPlaylist The current object (for fluent API support) + * @see addCcPlaylistcontentss() + */ + public function clearCcPlaylistcontentss() + { + $this->collCcPlaylistcontentss = null; // important to set this to null since that means it is uninitialized + $this->collCcPlaylistcontentssPartial = null; + + return $this; + } + + /** + * reset is the collCcPlaylistcontentss collection loaded partially + * + * @return void + */ + public function resetPartialCcPlaylistcontentss($v = true) + { + $this->collCcPlaylistcontentssPartial = $v; + } + + /** + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcPlaylistcontentss($overrideExisting = true) + { + if (null !== $this->collCcPlaylistcontentss && !$overrideExisting) { + return; + } + $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 PropelObjectCollection|CcPlaylistcontents[] List of CcPlaylistcontents objects + * @throws PropelException + */ + public function getCcPlaylistcontentss($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcPlaylistcontentssPartial && !$this->isNew(); + if (null === $this->collCcPlaylistcontentss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPlaylistcontentss) { + // return empty collection + $this->initCcPlaylistcontentss(); + } else { + $collCcPlaylistcontentss = CcPlaylistcontentsQuery::create(null, $criteria) + ->filterByCcPlaylist($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcPlaylistcontentssPartial && count($collCcPlaylistcontentss)) { + $this->initCcPlaylistcontentss(false); + + foreach ($collCcPlaylistcontentss as $obj) { + if (false == $this->collCcPlaylistcontentss->contains($obj)) { + $this->collCcPlaylistcontentss->append($obj); + } + } + + $this->collCcPlaylistcontentssPartial = true; + } + + $collCcPlaylistcontentss->getInternalIterator()->rewind(); + + return $collCcPlaylistcontentss; + } + + if ($partial && $this->collCcPlaylistcontentss) { + foreach ($this->collCcPlaylistcontentss as $obj) { + if ($obj->isNew()) { + $collCcPlaylistcontentss[] = $obj; + } + } + } + + $this->collCcPlaylistcontentss = $collCcPlaylistcontentss; + $this->collCcPlaylistcontentssPartial = false; + } + } + + return $this->collCcPlaylistcontentss; + } + + /** + * Sets a collection of CcPlaylistcontents objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccPlaylistcontentss A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcPlaylist The current object (for fluent API support) + */ + public function setCcPlaylistcontentss(PropelCollection $ccPlaylistcontentss, PropelPDO $con = null) + { + $ccPlaylistcontentssToDelete = $this->getCcPlaylistcontentss(new Criteria(), $con)->diff($ccPlaylistcontentss); + + + $this->ccPlaylistcontentssScheduledForDeletion = $ccPlaylistcontentssToDelete; + + foreach ($ccPlaylistcontentssToDelete as $ccPlaylistcontentsRemoved) { + $ccPlaylistcontentsRemoved->setCcPlaylist(null); + } + + $this->collCcPlaylistcontentss = null; + foreach ($ccPlaylistcontentss as $ccPlaylistcontents) { + $this->addCcPlaylistcontents($ccPlaylistcontents); + } + + $this->collCcPlaylistcontentss = $ccPlaylistcontentss; + $this->collCcPlaylistcontentssPartial = false; + + return $this; + } + + /** + * 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) + { + $partial = $this->collCcPlaylistcontentssPartial && !$this->isNew(); + if (null === $this->collCcPlaylistcontentss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPlaylistcontentss) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcPlaylistcontentss()); + } + $query = CcPlaylistcontentsQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcPlaylist($this) + ->count($con); + } + + 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 CcPlaylist The current object (for fluent API support) + */ + public function addCcPlaylistcontents(CcPlaylistcontents $l) + { + if ($this->collCcPlaylistcontentss === null) { + $this->initCcPlaylistcontentss(); + $this->collCcPlaylistcontentssPartial = true; + } + + if (!in_array($l, $this->collCcPlaylistcontentss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcPlaylistcontents($l); + + if ($this->ccPlaylistcontentssScheduledForDeletion and $this->ccPlaylistcontentssScheduledForDeletion->contains($l)) { + $this->ccPlaylistcontentssScheduledForDeletion->remove($this->ccPlaylistcontentssScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcPlaylistcontents $ccPlaylistcontents The ccPlaylistcontents object to add. + */ + protected function doAddCcPlaylistcontents($ccPlaylistcontents) + { + $this->collCcPlaylistcontentss[]= $ccPlaylistcontents; + $ccPlaylistcontents->setCcPlaylist($this); + } + + /** + * @param CcPlaylistcontents $ccPlaylistcontents The ccPlaylistcontents object to remove. + * @return CcPlaylist The current object (for fluent API support) + */ + public function removeCcPlaylistcontents($ccPlaylistcontents) + { + if ($this->getCcPlaylistcontentss()->contains($ccPlaylistcontents)) { + $this->collCcPlaylistcontentss->remove($this->collCcPlaylistcontentss->search($ccPlaylistcontents)); + if (null === $this->ccPlaylistcontentssScheduledForDeletion) { + $this->ccPlaylistcontentssScheduledForDeletion = clone $this->collCcPlaylistcontentss; + $this->ccPlaylistcontentssScheduledForDeletion->clear(); + } + $this->ccPlaylistcontentssScheduledForDeletion[]= $ccPlaylistcontents; + $ccPlaylistcontents->setCcPlaylist(null); + } + + return $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 PropelObjectCollection|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); + } + + + /** + * 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 PropelObjectCollection|CcPlaylistcontents[] List of CcPlaylistcontents objects + */ + public function getCcPlaylistcontentssJoinCcBlock($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcPlaylistcontentsQuery::create(null, $criteria); + $query->joinWith('CcBlock', $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->mtime = null; + $this->utime = null; + $this->creator_id = null; + $this->description = null; + $this->length = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->collCcPlaylistcontentss) { + foreach ($this->collCcPlaylistcontentss as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->aCcSubjs instanceof Persistent) { + $this->aCcSubjs->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + if ($this->collCcPlaylistcontentss instanceof PropelCollection) { + $this->collCcPlaylistcontentss->clearIterator(); + } + $this->collCcPlaylistcontentss = null; + $this->aCcSubjs = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcPlaylistPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + + // aggregate_column behavior + + /** + * Computes the value of the aggregate column length * + * @param PropelPDO $con A connection object + * + * @return mixed The scalar result from the aggregate query + */ + public function computeDbLength(PropelPDO $con) + { + $stmt = $con->prepare('SELECT SUM(cliplength) FROM "cc_playlistcontents" WHERE cc_playlistcontents.playlist_id = :p1'); + $stmt->bindValue(':p1', $this->getDbId()); + $stmt->execute(); + + return $stmt->fetchColumn(); + } + + /** + * Updates the aggregate column length * + * @param PropelPDO $con A connection object + */ + public function updateDbLength(PropelPDO $con) + { + $this->setDbLength($this->computeDbLength($con)); + $this->save($con); + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistPeer.php index da3593e02..bfc43f097 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistPeer.php @@ -1,997 +1,1037 @@ array ('DbId', 'DbName', 'DbMtime', 'DbUtime', 'DbCreatorId', 'DbDescription', 'DbLength', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbMtime', 'dbUtime', 'dbCreatorId', 'dbDescription', 'dbLength', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::MTIME, self::UTIME, self::CREATOR_ID, self::DESCRIPTION, self::LENGTH, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'MTIME', 'UTIME', 'CREATOR_ID', 'DESCRIPTION', 'LENGTH', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'mtime', 'utime', 'creator_id', 'description', 'length', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * 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, 'DbMtime' => 2, 'DbUtime' => 3, 'DbCreatorId' => 4, 'DbDescription' => 5, 'DbLength' => 6, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbMtime' => 2, 'dbUtime' => 3, 'dbCreatorId' => 4, 'dbDescription' => 5, 'dbLength' => 6, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::MTIME => 2, self::UTIME => 3, self::CREATOR_ID => 4, self::DESCRIPTION => 5, self::LENGTH => 6, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'MTIME' => 2, 'UTIME' => 3, 'CREATOR_ID' => 4, 'DESCRIPTION' => 5, 'LENGTH' => 6, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'mtime' => 2, 'utime' => 3, 'creator_id' => 4, 'description' => 5, 'length' => 6, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * 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::MTIME); - $criteria->addSelectColumn(CcPlaylistPeer::UTIME); - $criteria->addSelectColumn(CcPlaylistPeer::CREATOR_ID); - $criteria->addSelectColumn(CcPlaylistPeer::DESCRIPTION); - $criteria->addSelectColumn(CcPlaylistPeer::LENGTH); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.NAME'); - $criteria->addSelectColumn($alias . '.MTIME'); - $criteria->addSelectColumn($alias . '.UTIME'); - $criteria->addSelectColumn($alias . '.CREATOR_ID'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.LENGTH'); - } - } - - /** - * 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::CREATOR_ID, 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::CREATOR_ID, 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::CREATOR_ID, 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::CREATOR_ID, 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; - } +abstract class BaseCcPlaylistPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_playlist'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcPlaylist'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcPlaylistTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 7; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 7; + + /** the column name for the id field */ + const ID = 'cc_playlist.id'; + + /** the column name for the name field */ + const NAME = 'cc_playlist.name'; + + /** the column name for the mtime field */ + const MTIME = 'cc_playlist.mtime'; + + /** the column name for the utime field */ + const UTIME = 'cc_playlist.utime'; + + /** the column name for the creator_id field */ + const CREATOR_ID = 'cc_playlist.creator_id'; + + /** the column name for the description field */ + const DESCRIPTION = 'cc_playlist.description'; + + /** the column name for the length field */ + const LENGTH = 'cc_playlist.length'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcPlaylist objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcPlaylist[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcPlaylistPeer::$fieldNames[CcPlaylistPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbMtime', 'DbUtime', 'DbCreatorId', 'DbDescription', 'DbLength', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbMtime', 'dbUtime', 'dbCreatorId', 'dbDescription', 'dbLength', ), + BasePeer::TYPE_COLNAME => array (CcPlaylistPeer::ID, CcPlaylistPeer::NAME, CcPlaylistPeer::MTIME, CcPlaylistPeer::UTIME, CcPlaylistPeer::CREATOR_ID, CcPlaylistPeer::DESCRIPTION, CcPlaylistPeer::LENGTH, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'MTIME', 'UTIME', 'CREATOR_ID', 'DESCRIPTION', 'LENGTH', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'mtime', 'utime', 'creator_id', 'description', 'length', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcPlaylistPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbMtime' => 2, 'DbUtime' => 3, 'DbCreatorId' => 4, 'DbDescription' => 5, 'DbLength' => 6, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbMtime' => 2, 'dbUtime' => 3, 'dbCreatorId' => 4, 'dbDescription' => 5, 'dbLength' => 6, ), + BasePeer::TYPE_COLNAME => array (CcPlaylistPeer::ID => 0, CcPlaylistPeer::NAME => 1, CcPlaylistPeer::MTIME => 2, CcPlaylistPeer::UTIME => 3, CcPlaylistPeer::CREATOR_ID => 4, CcPlaylistPeer::DESCRIPTION => 5, CcPlaylistPeer::LENGTH => 6, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'MTIME' => 2, 'UTIME' => 3, 'CREATOR_ID' => 4, 'DESCRIPTION' => 5, 'LENGTH' => 6, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'mtime' => 2, 'utime' => 3, 'creator_id' => 4, 'description' => 5, 'length' => 6, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcPlaylistPeer::getFieldNames($toType); + $key = isset(CcPlaylistPeer::$fieldKeys[$fromType][$name]) ? CcPlaylistPeer::$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(CcPlaylistPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcPlaylistPeer::$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 CcPlaylistPeer::$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::MTIME); + $criteria->addSelectColumn(CcPlaylistPeer::UTIME); + $criteria->addSelectColumn(CcPlaylistPeer::CREATOR_ID); + $criteria->addSelectColumn(CcPlaylistPeer::DESCRIPTION); + $criteria->addSelectColumn(CcPlaylistPeer::LENGTH); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.name'); + $criteria->addSelectColumn($alias . '.mtime'); + $criteria->addSelectColumn($alias . '.utime'); + $criteria->addSelectColumn($alias . '.creator_id'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.length'); + } + } + + /** + * 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(CcPlaylistPeer::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; + } + /** + * Selects 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; + } + /** + * Selects several row from the DB. + * + * @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 directly (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(CcPlaylistPeer::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 $obj 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($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcPlaylistPeer::$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. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + 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(CcPlaylistPeer::$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(CcPlaylistPeer::$instances[$key])) { + return CcPlaylistPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcPlaylistPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcPlaylistPeer::$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(); + // 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_HYDRATE_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(CcPlaylistPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlaylistPeer::CREATOR_ID, 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(CcPlaylistPeer::DATABASE_NAME); + } + + CcPlaylistPeer::addSelectColumns($criteria); + $startcol = CcPlaylistPeer::NUM_HYDRATE_COLUMNS; + CcSubjsPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcPlaylistPeer::CREATOR_ID, 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(); + + $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(); + + $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(CcPlaylistPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlaylistPeer::CREATOR_ID, 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(CcPlaylistPeer::DATABASE_NAME); + } + + CcPlaylistPeer::addSelectColumns($criteria); + $startcol2 = CcPlaylistPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcPlaylistPeer::CREATOR_ID, 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(); + + $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(); + + $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(CcPlaylistPeer::DATABASE_NAME)->getTable(CcPlaylistPeer::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 \Airtime\map\CcPlaylistTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcPlaylistPeer::OM_CLASS; + } + + /** + * Performs 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(CcPlaylistPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs 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(CcPlaylistPeer::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(CcPlaylistPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_playlist table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $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 (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs 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(CcPlaylistPeer::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(CcPlaylistPeer::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 (Exception $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($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->hasColumn($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 + * @return CcPlaylist[] + * @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 diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistQuery.php index 66b50e1c2..51208c982 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistQuery.php @@ -1,484 +1,692 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcPlaylist|CcPlaylist[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcPlaylistPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $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); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlaylist A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * 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); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlaylist A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "name", "mtime", "utime", "creator_id", "description", "length" FROM "cc_playlist" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcPlaylist(); + $obj->hydrate($row); + CcPlaylistPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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); - } + return $obj; + } - /** - * 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); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlaylist|CcPlaylist[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * 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); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query on the utime column - * - * @param string|array $dbUtime 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 filterByDbUtime($dbUtime = null, $comparison = null) - { - if (is_array($dbUtime)) { - $useMinMax = false; - if (isset($dbUtime['min'])) { - $this->addUsingAlias(CcPlaylistPeer::UTIME, $dbUtime['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbUtime['max'])) { - $this->addUsingAlias(CcPlaylistPeer::UTIME, $dbUtime['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcPlaylistPeer::UTIME, $dbUtime, $comparison); - } + /** + * 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|CcPlaylist[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query on the creator_id column - * - * @param int|array $dbCreatorId 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 filterByDbCreatorId($dbCreatorId = null, $comparison = null) - { - if (is_array($dbCreatorId)) { - $useMinMax = false; - if (isset($dbCreatorId['min'])) { - $this->addUsingAlias(CcPlaylistPeer::CREATOR_ID, $dbCreatorId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbCreatorId['max'])) { - $this->addUsingAlias(CcPlaylistPeer::CREATOR_ID, $dbCreatorId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcPlaylistPeer::CREATOR_ID, $dbCreatorId, $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * 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 primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcPlaylistQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { - /** - * Filter the query on the length column - * - * @param string $dbLength 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 filterByDbLength($dbLength = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbLength)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbLength)) { - $dbLength = str_replace('*', '%', $dbLength); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcPlaylistPeer::LENGTH, $dbLength, $comparison); - } + return $this->addUsingAlias(CcPlaylistPeer::ID, $key, Criteria::EQUAL); + } - /** - * 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::CREATOR_ID, $ccSubjs->getDbId(), $comparison); - } + /** + * 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) + { - /** - * 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; - } + return $this->addUsingAlias(CcPlaylistPeer::ID, $keys, Criteria::IN); + } - /** - * 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 on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @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)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcPlaylistPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcPlaylistPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * 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); - } + return $this->addUsingAlias(CcPlaylistPeer::ID, $dbId, $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; - } + /** + * Filter the query on the name column + * + * Example usage: + * + * $query->filterByDbName('fooValue'); // WHERE name = 'fooValue' + * $query->filterByDbName('%fooValue%'); // WHERE name LIKE '%fooValue%' + * + * + * @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; + } + } - /** - * 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'); - } + return $this->addUsingAlias(CcPlaylistPeer::NAME, $dbName, $comparison); + } - /** - * 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; - } + /** + * Filter the query on the mtime column + * + * Example usage: + * + * $query->filterByDbMtime('2011-03-14'); // WHERE mtime = '2011-03-14' + * $query->filterByDbMtime('now'); // WHERE mtime = '2011-03-14' + * $query->filterByDbMtime(array('max' => 'yesterday')); // WHERE mtime < '2011-03-13' + * + * + * @param mixed $dbMtime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @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; + } + } -} // BaseCcPlaylistQuery + return $this->addUsingAlias(CcPlaylistPeer::MTIME, $dbMtime, $comparison); + } + + /** + * Filter the query on the utime column + * + * Example usage: + * + * $query->filterByDbUtime('2011-03-14'); // WHERE utime = '2011-03-14' + * $query->filterByDbUtime('now'); // WHERE utime = '2011-03-14' + * $query->filterByDbUtime(array('max' => 'yesterday')); // WHERE utime < '2011-03-13' + * + * + * @param mixed $dbUtime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlaylistQuery The current query, for fluid interface + */ + public function filterByDbUtime($dbUtime = null, $comparison = null) + { + if (is_array($dbUtime)) { + $useMinMax = false; + if (isset($dbUtime['min'])) { + $this->addUsingAlias(CcPlaylistPeer::UTIME, $dbUtime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbUtime['max'])) { + $this->addUsingAlias(CcPlaylistPeer::UTIME, $dbUtime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcPlaylistPeer::UTIME, $dbUtime, $comparison); + } + + /** + * Filter the query on the creator_id column + * + * Example usage: + * + * $query->filterByDbCreatorId(1234); // WHERE creator_id = 1234 + * $query->filterByDbCreatorId(array(12, 34)); // WHERE creator_id IN (12, 34) + * $query->filterByDbCreatorId(array('min' => 12)); // WHERE creator_id >= 12 + * $query->filterByDbCreatorId(array('max' => 12)); // WHERE creator_id <= 12 + * + * + * @see filterByCcSubjs() + * + * @param mixed $dbCreatorId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlaylistQuery The current query, for fluid interface + */ + public function filterByDbCreatorId($dbCreatorId = null, $comparison = null) + { + if (is_array($dbCreatorId)) { + $useMinMax = false; + if (isset($dbCreatorId['min'])) { + $this->addUsingAlias(CcPlaylistPeer::CREATOR_ID, $dbCreatorId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbCreatorId['max'])) { + $this->addUsingAlias(CcPlaylistPeer::CREATOR_ID, $dbCreatorId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcPlaylistPeer::CREATOR_ID, $dbCreatorId, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDbDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDbDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @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 on the length column + * + * Example usage: + * + * $query->filterByDbLength('fooValue'); // WHERE length = 'fooValue' + * $query->filterByDbLength('%fooValue%'); // WHERE length LIKE '%fooValue%' + * + * + * @param string $dbLength 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 filterByDbLength($dbLength = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLength)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLength)) { + $dbLength = str_replace('*', '%', $dbLength); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcPlaylistPeer::LENGTH, $dbLength, $comparison); + } + + /** + * Filter the query by a related CcSubjs object + * + * @param CcSubjs|PropelObjectCollection $ccSubjs The related object(s) 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcSubjs($ccSubjs, $comparison = null) + { + if ($ccSubjs instanceof CcSubjs) { + return $this + ->addUsingAlias(CcPlaylistPeer::CREATOR_ID, $ccSubjs->getDbId(), $comparison); + } elseif ($ccSubjs instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcPlaylistPeer::CREATOR_ID, $ccSubjs->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcSubjs() only accepts arguments of type CcSubjs or PropelCollection'); + } + } + + /** + * 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 = null, $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 \Airtime\CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSubjs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', '\Airtime\CcSubjsQuery'); + } + + /** + * Filter the query by a related CcPlaylistcontents object + * + * @param CcPlaylistcontents|PropelObjectCollection $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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcPlaylistcontents($ccPlaylistcontents, $comparison = null) + { + if ($ccPlaylistcontents instanceof CcPlaylistcontents) { + return $this + ->addUsingAlias(CcPlaylistPeer::ID, $ccPlaylistcontents->getDbPlaylistId(), $comparison); + } elseif ($ccPlaylistcontents instanceof PropelObjectCollection) { + return $this + ->useCcPlaylistcontentsQuery() + ->filterByPrimaryKeys($ccPlaylistcontents->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcPlaylistcontents() only accepts arguments of type CcPlaylistcontents or PropelCollection'); + } + } + + /** + * 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 = null, $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 \Airtime\CcPlaylistcontentsQuery A secondary query class using the current class as primary query + */ + public function useCcPlaylistcontentsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcPlaylistcontents($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPlaylistcontents', '\Airtime\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; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontents.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontents.php index cf6e53a98..ba2a15d10 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontents.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontents.php @@ -1,1691 +1,1895 @@ type = 0; - $this->trackoffset = 0; - $this->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 [block_id] column value. - * - * @return int - */ - public function getDbBlockId() - { - return $this->block_id; - } - - /** - * Get the [stream_id] column value. - * - * @return int - */ - public function getDbStreamId() - { - return $this->stream_id; - } - - /** - * Get the [type] column value. - * - * @return int - */ - public function getDbType() - { - return $this->type; - } - - /** - * Get the [position] column value. - * - * @return int - */ - public function getDbPosition() - { - return $this->position; - } - - /** - * Get the [trackoffset] column value. - * - * @return double - */ - public function getDbTrackOffset() - { - return $this->trackoffset; - } - - /** - * Get the [cliplength] column value. - * - * @return string - */ - public function getDbCliplength() - { - return $this->cliplength; - } - - /** - * Get the [cuein] column value. - * - * @return string - */ - public function getDbCuein() - { - return $this->cuein; - } - - /** - * Get the [cueout] column value. - * - * @return string - */ - public function getDbCueout() - { - return $this->cueout; - } - - /** - * 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 [block_id] column. - * - * @param int $v new value - * @return CcPlaylistcontents The current object (for fluent API support) - */ - public function setDbBlockId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->block_id !== $v) { - $this->block_id = $v; - $this->modifiedColumns[] = CcPlaylistcontentsPeer::BLOCK_ID; - } - - if ($this->aCcBlock !== null && $this->aCcBlock->getDbId() !== $v) { - $this->aCcBlock = null; - } - - return $this; - } // setDbBlockId() - - /** - * Set the value of [stream_id] column. - * - * @param int $v new value - * @return CcPlaylistcontents The current object (for fluent API support) - */ - public function setDbStreamId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->stream_id !== $v) { - $this->stream_id = $v; - $this->modifiedColumns[] = CcPlaylistcontentsPeer::STREAM_ID; - } - - return $this; - } // setDbStreamId() - - /** - * Set the value of [type] column. - * - * @param int $v new value - * @return CcPlaylistcontents The current object (for fluent API support) - */ - public function setDbType($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->type !== $v || $this->isNew()) { - $this->type = $v; - $this->modifiedColumns[] = CcPlaylistcontentsPeer::TYPE; - } - - return $this; - } // setDbType() - - /** - * 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() - - /** - * Set the value of [trackoffset] column. - * - * @param double $v new value - * @return CcPlaylistcontents The current object (for fluent API support) - */ - public function setDbTrackOffset($v) - { - if ($v !== null) { - $v = (double) $v; - } - - if ($this->trackoffset !== $v || $this->isNew()) { - $this->trackoffset = $v; - $this->modifiedColumns[] = CcPlaylistcontentsPeer::TRACKOFFSET; - } - - return $this; - } // setDbTrackOffset() - - /** - * Set the value of [cliplength] column. - * - * @param string $v new value - * @return CcPlaylistcontents The current object (for fluent API support) - */ - public function setDbCliplength($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->cliplength !== $v || $this->isNew()) { - $this->cliplength = $v; - $this->modifiedColumns[] = CcPlaylistcontentsPeer::CLIPLENGTH; - } - - return $this; - } // setDbCliplength() - - /** - * Set the value of [cuein] column. - * - * @param string $v new value - * @return CcPlaylistcontents The current object (for fluent API support) - */ - public function setDbCuein($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->cuein !== $v || $this->isNew()) { - $this->cuein = $v; - $this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEIN; - } - - return $this; - } // setDbCuein() - - /** - * Set the value of [cueout] column. - * - * @param string $v new value - * @return CcPlaylistcontents The current object (for fluent API support) - */ - public function setDbCueout($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->cueout !== $v || $this->isNew()) { - $this->cueout = $v; - $this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEOUT; - } - - 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->type !== 0) { - return false; - } - - if ($this->trackoffset !== 0) { - return false; - } - - 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->block_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->stream_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->type = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; - $this->position = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; - $this->trackoffset = ($row[$startcol + 7] !== null) ? (double) $row[$startcol + 7] : null; - $this->cliplength = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; - $this->cuein = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; - $this->cueout = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; - $this->fadein = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null; - $this->fadeout = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 13; // 13 = 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; - } - if ($this->aCcBlock !== null && $this->block_id !== $this->aCcBlock->getDbId()) { - $this->aCcBlock = 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->aCcBlock = 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); - // aggregate_column_relation behavior - $this->updateRelatedCcPlaylist($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->aCcBlock !== null) { - if ($this->aCcBlock->isModified() || $this->aCcBlock->isNew()) { - $affectedRows += $this->aCcBlock->save($con); - } - $this->setCcBlock($this->aCcBlock); - } - - 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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcFiles !== null) { - if (!$this->aCcFiles->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcFiles->getValidationFailures()); - } - } - - if ($this->aCcBlock !== null) { - if (!$this->aCcBlock->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcBlock->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->getDbBlockId(); - break; - case 4: - return $this->getDbStreamId(); - break; - case 5: - return $this->getDbType(); - break; - case 6: - return $this->getDbPosition(); - break; - case 7: - return $this->getDbTrackOffset(); - break; - case 8: - return $this->getDbCliplength(); - break; - case 9: - return $this->getDbCuein(); - break; - case 10: - return $this->getDbCueout(); - break; - case 11: - return $this->getDbFadein(); - break; - case 12: - 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->getDbBlockId(), - $keys[4] => $this->getDbStreamId(), - $keys[5] => $this->getDbType(), - $keys[6] => $this->getDbPosition(), - $keys[7] => $this->getDbTrackOffset(), - $keys[8] => $this->getDbCliplength(), - $keys[9] => $this->getDbCuein(), - $keys[10] => $this->getDbCueout(), - $keys[11] => $this->getDbFadein(), - $keys[12] => $this->getDbFadeout(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCcFiles) { - $result['CcFiles'] = $this->aCcFiles->toArray($keyType, $includeLazyLoadColumns, true); - } - if (null !== $this->aCcBlock) { - $result['CcBlock'] = $this->aCcBlock->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->setDbBlockId($value); - break; - case 4: - $this->setDbStreamId($value); - break; - case 5: - $this->setDbType($value); - break; - case 6: - $this->setDbPosition($value); - break; - case 7: - $this->setDbTrackOffset($value); - break; - case 8: - $this->setDbCliplength($value); - break; - case 9: - $this->setDbCuein($value); - break; - case 10: - $this->setDbCueout($value); - break; - case 11: - $this->setDbFadein($value); - break; - case 12: - $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->setDbBlockId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbStreamId($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbType($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDbPosition($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setDbTrackOffset($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setDbCliplength($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setDbCuein($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setDbCueout($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setDbFadein($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setDbFadeout($arr[$keys[12]]); - } - - /** - * 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::BLOCK_ID)) $criteria->add(CcPlaylistcontentsPeer::BLOCK_ID, $this->block_id); - if ($this->isColumnModified(CcPlaylistcontentsPeer::STREAM_ID)) $criteria->add(CcPlaylistcontentsPeer::STREAM_ID, $this->stream_id); - if ($this->isColumnModified(CcPlaylistcontentsPeer::TYPE)) $criteria->add(CcPlaylistcontentsPeer::TYPE, $this->type); - if ($this->isColumnModified(CcPlaylistcontentsPeer::POSITION)) $criteria->add(CcPlaylistcontentsPeer::POSITION, $this->position); - if ($this->isColumnModified(CcPlaylistcontentsPeer::TRACKOFFSET)) $criteria->add(CcPlaylistcontentsPeer::TRACKOFFSET, $this->trackoffset); - 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->setDbBlockId($this->block_id); - $copyObj->setDbStreamId($this->stream_id); - $copyObj->setDbType($this->type); - $copyObj->setDbPosition($this->position); - $copyObj->setDbTrackOffset($this->trackoffset); - $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 CcBlock object. - * - * @param CcBlock $v - * @return CcPlaylistcontents The current object (for fluent API support) - * @throws PropelException - */ - public function setCcBlock(CcBlock $v = null) - { - if ($v === null) { - $this->setDbBlockId(NULL); - } else { - $this->setDbBlockId($v->getDbId()); - } - - $this->aCcBlock = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcBlock object, it will not be re-added. - if ($v !== null) { - $v->addCcPlaylistcontents($this); - } - - return $this; - } - - - /** - * Get the associated CcBlock object - * - * @param PropelPDO Optional Connection object. - * @return CcBlock The associated CcBlock object. - * @throws PropelException - */ - public function getCcBlock(PropelPDO $con = null) - { - if ($this->aCcBlock === null && ($this->block_id !== null)) { - $this->aCcBlock = CcBlockQuery::create()->findPk($this->block_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->aCcBlock->addCcPlaylistcontentss($this); - */ - } - return $this->aCcBlock; - } - - /** - * 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) - { - // aggregate_column_relation behavior - if (null !== $this->aCcPlaylist && $v !== $this->aCcPlaylist) { - $this->oldCcPlaylist = $this->aCcPlaylist; - } - 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->block_id = null; - $this->stream_id = null; - $this->type = null; - $this->position = null; - $this->trackoffset = 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->aCcBlock = null; - $this->aCcPlaylist = null; - } - - // aggregate_column_relation behavior - - /** - * Update the aggregate column in the related CcPlaylist object - * - * @param PropelPDO $con A connection object - */ - protected function updateRelatedCcPlaylist(PropelPDO $con) - { - if ($ccPlaylist = $this->getCcPlaylist()) { - $ccPlaylist->updateDbLength($con); - } - if ($this->oldCcPlaylist) { - $this->oldCcPlaylist->updateDbLength($con); - $this->oldCcPlaylist = 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 + /** + * Peer class name + */ + const PEER = 'Airtime\\CcPlaylistcontentsPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcPlaylistcontentsPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the playlist_id field. + * @var int + */ + protected $playlist_id; + + /** + * The value for the file_id field. + * @var int + */ + protected $file_id; + + /** + * The value for the block_id field. + * @var int + */ + protected $block_id; + + /** + * The value for the stream_id field. + * @var int + */ + protected $stream_id; + + /** + * The value for the type field. + * Note: this column has a database default value of: 0 + * @var int + */ + protected $type; + + /** + * The value for the position field. + * @var int + */ + protected $position; + + /** + * The value for the trackoffset field. + * Note: this column has a database default value of: 0 + * @var double + */ + protected $trackoffset; + + /** + * The value for the cliplength field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $cliplength; + + /** + * The value for the cuein field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $cuein; + + /** + * The value for the cueout field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $cueout; + + /** + * The value for the fadein field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $fadein; + + /** + * The value for the fadeout field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $fadeout; + + /** + * @var CcFiles + */ + protected $aCcFiles; + + /** + * @var CcBlock + */ + protected $aCcBlock; + + /** + * @var CcPlaylist + */ + protected $aCcPlaylist; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + // aggregate_column_relation behavior + protected $oldCcPlaylist; + + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->type = 0; + $this->trackoffset = 0; + $this->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 [block_id] column value. + * + * @return int + */ + public function getDbBlockId() + { + + return $this->block_id; + } + + /** + * Get the [stream_id] column value. + * + * @return int + */ + public function getDbStreamId() + { + + return $this->stream_id; + } + + /** + * Get the [type] column value. + * + * @return int + */ + public function getDbType() + { + + return $this->type; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getDbPosition() + { + + return $this->position; + } + + /** + * Get the [trackoffset] column value. + * + * @return double + */ + public function getDbTrackOffset() + { + + return $this->trackoffset; + } + + /** + * Get the [cliplength] column value. + * + * @return string + */ + public function getDbCliplength() + { + + return $this->cliplength; + } + + /** + * Get the [cuein] column value. + * + * @return string + */ + public function getDbCuein() + { + + return $this->cuein; + } + + /** + * Get the [cueout] column value. + * + * @return string + */ + public function getDbCueout() + { + + return $this->cueout; + } + + /** + * 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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + 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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + 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 && is_numeric($v)) { + $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 && is_numeric($v)) { + $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 && is_numeric($v)) { + $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 [block_id] column. + * + * @param int $v new value + * @return CcPlaylistcontents The current object (for fluent API support) + */ + public function setDbBlockId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->block_id !== $v) { + $this->block_id = $v; + $this->modifiedColumns[] = CcPlaylistcontentsPeer::BLOCK_ID; + } + + if ($this->aCcBlock !== null && $this->aCcBlock->getDbId() !== $v) { + $this->aCcBlock = null; + } + + + return $this; + } // setDbBlockId() + + /** + * Set the value of [stream_id] column. + * + * @param int $v new value + * @return CcPlaylistcontents The current object (for fluent API support) + */ + public function setDbStreamId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->stream_id !== $v) { + $this->stream_id = $v; + $this->modifiedColumns[] = CcPlaylistcontentsPeer::STREAM_ID; + } + + + return $this; + } // setDbStreamId() + + /** + * Set the value of [type] column. + * + * @param int $v new value + * @return CcPlaylistcontents The current object (for fluent API support) + */ + public function setDbType($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->type !== $v) { + $this->type = $v; + $this->modifiedColumns[] = CcPlaylistcontentsPeer::TYPE; + } + + + return $this; + } // setDbType() + + /** + * 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 && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = CcPlaylistcontentsPeer::POSITION; + } + + + return $this; + } // setDbPosition() + + /** + * Set the value of [trackoffset] column. + * + * @param double $v new value + * @return CcPlaylistcontents The current object (for fluent API support) + */ + public function setDbTrackOffset($v) + { + if ($v !== null && is_numeric($v)) { + $v = (double) $v; + } + + if ($this->trackoffset !== $v) { + $this->trackoffset = $v; + $this->modifiedColumns[] = CcPlaylistcontentsPeer::TRACKOFFSET; + } + + + return $this; + } // setDbTrackOffset() + + /** + * Set the value of [cliplength] column. + * + * @param string $v new value + * @return CcPlaylistcontents The current object (for fluent API support) + */ + public function setDbCliplength($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->cliplength !== $v) { + $this->cliplength = $v; + $this->modifiedColumns[] = CcPlaylistcontentsPeer::CLIPLENGTH; + } + + + return $this; + } // setDbCliplength() + + /** + * Set the value of [cuein] column. + * + * @param string $v new value + * @return CcPlaylistcontents The current object (for fluent API support) + */ + public function setDbCuein($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->cuein !== $v) { + $this->cuein = $v; + $this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEIN; + } + + + return $this; + } // setDbCuein() + + /** + * Set the value of [cueout] column. + * + * @param string $v new value + * @return CcPlaylistcontents The current object (for fluent API support) + */ + public function setDbCueout($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->cueout !== $v) { + $this->cueout = $v; + $this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEOUT; + } + + + 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 strings are treated as null. + * @return CcPlaylistcontents The current object (for fluent API support) + */ + public function setDbFadein($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->fadein !== null || $dt !== null) { + $currentDateAsString = ($this->fadein !== null && $tmpDt = new DateTime($this->fadein)) ? $tmpDt->format('H:i:s') : null; + $newDateAsString = $dt ? $dt->format('H:i:s') : null; + if ( ($currentDateAsString !== $newDateAsString) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) { + $this->fadein = $newDateAsString; + $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 strings are treated as null. + * @return CcPlaylistcontents The current object (for fluent API support) + */ + public function setDbFadeout($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->fadeout !== null || $dt !== null) { + $currentDateAsString = ($this->fadeout !== null && $tmpDt = new DateTime($this->fadeout)) ? $tmpDt->format('H:i:s') : null; + $newDateAsString = $dt ? $dt->format('H:i:s') : null; + if ( ($currentDateAsString !== $newDateAsString) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) { + $this->fadeout = $newDateAsString; + $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->type !== 0) { + return false; + } + + if ($this->trackoffset !== 0) { + return false; + } + + 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 resultset 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->block_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; + $this->stream_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; + $this->type = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; + $this->position = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; + $this->trackoffset = ($row[$startcol + 7] !== null) ? (double) $row[$startcol + 7] : null; + $this->cliplength = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->cuein = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->cueout = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; + $this->fadein = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null; + $this->fadeout = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 13; // 13 = CcPlaylistcontentsPeer::NUM_HYDRATE_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; + } + if ($this->aCcBlock !== null && $this->block_id !== $this->aCcBlock->getDbId()) { + $this->aCcBlock = 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->aCcBlock = null; + $this->aCcPlaylist = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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 { + $deleteQuery = CcPlaylistcontentsQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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); + // aggregate_column_relation behavior + $this->updateRelatedCcPlaylist($con); + CcPlaylistcontentsPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding 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->aCcBlock !== null) { + if ($this->aCcBlock->isModified() || $this->aCcBlock->isNew()) { + $affectedRows += $this->aCcBlock->save($con); + } + $this->setCcBlock($this->aCcBlock); + } + + if ($this->aCcPlaylist !== null) { + if ($this->aCcPlaylist->isModified() || $this->aCcPlaylist->isNew()) { + $affectedRows += $this->aCcPlaylist->save($con); + } + $this->setCcPlaylist($this->aCcPlaylist); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcPlaylistcontentsPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcPlaylistcontentsPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_playlistcontents_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcPlaylistcontentsPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcPlaylistcontentsPeer::PLAYLIST_ID)) { + $modifiedColumns[':p' . $index++] = '"playlist_id"'; + } + if ($this->isColumnModified(CcPlaylistcontentsPeer::FILE_ID)) { + $modifiedColumns[':p' . $index++] = '"file_id"'; + } + if ($this->isColumnModified(CcPlaylistcontentsPeer::BLOCK_ID)) { + $modifiedColumns[':p' . $index++] = '"block_id"'; + } + if ($this->isColumnModified(CcPlaylistcontentsPeer::STREAM_ID)) { + $modifiedColumns[':p' . $index++] = '"stream_id"'; + } + if ($this->isColumnModified(CcPlaylistcontentsPeer::TYPE)) { + $modifiedColumns[':p' . $index++] = '"type"'; + } + if ($this->isColumnModified(CcPlaylistcontentsPeer::POSITION)) { + $modifiedColumns[':p' . $index++] = '"position"'; + } + if ($this->isColumnModified(CcPlaylistcontentsPeer::TRACKOFFSET)) { + $modifiedColumns[':p' . $index++] = '"trackoffset"'; + } + if ($this->isColumnModified(CcPlaylistcontentsPeer::CLIPLENGTH)) { + $modifiedColumns[':p' . $index++] = '"cliplength"'; + } + if ($this->isColumnModified(CcPlaylistcontentsPeer::CUEIN)) { + $modifiedColumns[':p' . $index++] = '"cuein"'; + } + if ($this->isColumnModified(CcPlaylistcontentsPeer::CUEOUT)) { + $modifiedColumns[':p' . $index++] = '"cueout"'; + } + if ($this->isColumnModified(CcPlaylistcontentsPeer::FADEIN)) { + $modifiedColumns[':p' . $index++] = '"fadein"'; + } + if ($this->isColumnModified(CcPlaylistcontentsPeer::FADEOUT)) { + $modifiedColumns[':p' . $index++] = '"fadeout"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_playlistcontents" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"playlist_id"': + $stmt->bindValue($identifier, $this->playlist_id, PDO::PARAM_INT); + break; + case '"file_id"': + $stmt->bindValue($identifier, $this->file_id, PDO::PARAM_INT); + break; + case '"block_id"': + $stmt->bindValue($identifier, $this->block_id, PDO::PARAM_INT); + break; + case '"stream_id"': + $stmt->bindValue($identifier, $this->stream_id, PDO::PARAM_INT); + break; + case '"type"': + $stmt->bindValue($identifier, $this->type, PDO::PARAM_INT); + break; + case '"position"': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case '"trackoffset"': + $stmt->bindValue($identifier, $this->trackoffset, PDO::PARAM_STR); + break; + case '"cliplength"': + $stmt->bindValue($identifier, $this->cliplength, PDO::PARAM_STR); + break; + case '"cuein"': + $stmt->bindValue($identifier, $this->cuein, PDO::PARAM_STR); + break; + case '"cueout"': + $stmt->bindValue($identifier, $this->cueout, PDO::PARAM_STR); + break; + case '"fadein"': + $stmt->bindValue($identifier, $this->fadein, PDO::PARAM_STR); + break; + case '"fadeout"': + $stmt->bindValue($identifier, $this->fadeout, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding 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->aCcBlock !== null) { + if (!$this->aCcBlock->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcBlock->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. + * Defaults to BasePeer::TYPE_PHPNAME + * @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->getDbBlockId(); + break; + case 4: + return $this->getDbStreamId(); + break; + case 5: + return $this->getDbType(); + break; + case 6: + return $this->getDbPosition(); + break; + case 7: + return $this->getDbTrackOffset(); + break; + case 8: + return $this->getDbCliplength(); + break; + case 9: + return $this->getDbCuein(); + break; + case 10: + return $this->getDbCueout(); + break; + case 11: + return $this->getDbFadein(); + break; + case 12: + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcPlaylistcontents'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcPlaylistcontents'][$this->getPrimaryKey()] = true; + $keys = CcPlaylistcontentsPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbPlaylistId(), + $keys[2] => $this->getDbFileId(), + $keys[3] => $this->getDbBlockId(), + $keys[4] => $this->getDbStreamId(), + $keys[5] => $this->getDbType(), + $keys[6] => $this->getDbPosition(), + $keys[7] => $this->getDbTrackOffset(), + $keys[8] => $this->getDbCliplength(), + $keys[9] => $this->getDbCuein(), + $keys[10] => $this->getDbCueout(), + $keys[11] => $this->getDbFadein(), + $keys[12] => $this->getDbFadeout(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcFiles) { + $result['CcFiles'] = $this->aCcFiles->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aCcBlock) { + $result['CcBlock'] = $this->aCcBlock->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aCcPlaylist) { + $result['CcPlaylist'] = $this->aCcPlaylist->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcPlaylistcontentsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbBlockId($value); + break; + case 4: + $this->setDbStreamId($value); + break; + case 5: + $this->setDbType($value); + break; + case 6: + $this->setDbPosition($value); + break; + case 7: + $this->setDbTrackOffset($value); + break; + case 8: + $this->setDbCliplength($value); + break; + case 9: + $this->setDbCuein($value); + break; + case 10: + $this->setDbCueout($value); + break; + case 11: + $this->setDbFadein($value); + break; + case 12: + $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 BasePeer::TYPE_PHPNAME + * + * @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->setDbBlockId($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbStreamId($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbType($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbPosition($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbTrackOffset($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setDbCliplength($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDbCuein($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setDbCueout($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setDbFadein($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setDbFadeout($arr[$keys[12]]); + } + + /** + * 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::BLOCK_ID)) $criteria->add(CcPlaylistcontentsPeer::BLOCK_ID, $this->block_id); + if ($this->isColumnModified(CcPlaylistcontentsPeer::STREAM_ID)) $criteria->add(CcPlaylistcontentsPeer::STREAM_ID, $this->stream_id); + if ($this->isColumnModified(CcPlaylistcontentsPeer::TYPE)) $criteria->add(CcPlaylistcontentsPeer::TYPE, $this->type); + if ($this->isColumnModified(CcPlaylistcontentsPeer::POSITION)) $criteria->add(CcPlaylistcontentsPeer::POSITION, $this->position); + if ($this->isColumnModified(CcPlaylistcontentsPeer::TRACKOFFSET)) $criteria->add(CcPlaylistcontentsPeer::TRACKOFFSET, $this->trackoffset); + 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. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbPlaylistId($this->getDbPlaylistId()); + $copyObj->setDbFileId($this->getDbFileId()); + $copyObj->setDbBlockId($this->getDbBlockId()); + $copyObj->setDbStreamId($this->getDbStreamId()); + $copyObj->setDbType($this->getDbType()); + $copyObj->setDbPosition($this->getDbPosition()); + $copyObj->setDbTrackOffset($this->getDbTrackOffset()); + $copyObj->setDbCliplength($this->getDbCliplength()); + $copyObj->setDbCuein($this->getDbCuein()); + $copyObj->setDbCueout($this->getDbCueout()); + $copyObj->setDbFadein($this->getDbFadein()); + $copyObj->setDbFadeout($this->getDbFadeout()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcFiles The associated CcFiles object. + * @throws PropelException + */ + public function getCcFiles(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcFiles === null && ($this->file_id !== null) && $doQuery) { + $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 CcBlock object. + * + * @param CcBlock $v + * @return CcPlaylistcontents The current object (for fluent API support) + * @throws PropelException + */ + public function setCcBlock(CcBlock $v = null) + { + if ($v === null) { + $this->setDbBlockId(NULL); + } else { + $this->setDbBlockId($v->getDbId()); + } + + $this->aCcBlock = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcBlock object, it will not be re-added. + if ($v !== null) { + $v->addCcPlaylistcontents($this); + } + + + return $this; + } + + + /** + * Get the associated CcBlock object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcBlock The associated CcBlock object. + * @throws PropelException + */ + public function getCcBlock(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcBlock === null && ($this->block_id !== null) && $doQuery) { + $this->aCcBlock = CcBlockQuery::create()->findPk($this->block_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->aCcBlock->addCcPlaylistcontentss($this); + */ + } + + return $this->aCcBlock; + } + + /** + * 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) + { + // aggregate_column_relation behavior + if (null !== $this->aCcPlaylist && $v !== $this->aCcPlaylist) { + $this->oldCcPlaylist = $this->aCcPlaylist; + } + 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 $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcPlaylist The associated CcPlaylist object. + * @throws PropelException + */ + public function getCcPlaylist(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcPlaylist === null && ($this->playlist_id !== null) && $doQuery) { + $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->block_id = null; + $this->stream_id = null; + $this->type = null; + $this->position = null; + $this->trackoffset = null; + $this->cliplength = null; + $this->cuein = null; + $this->cueout = null; + $this->fadein = null; + $this->fadeout = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCcFiles instanceof Persistent) { + $this->aCcFiles->clearAllReferences($deep); + } + if ($this->aCcBlock instanceof Persistent) { + $this->aCcBlock->clearAllReferences($deep); + } + if ($this->aCcPlaylist instanceof Persistent) { + $this->aCcPlaylist->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + $this->aCcFiles = null; + $this->aCcBlock = null; + $this->aCcPlaylist = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcPlaylistcontentsPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + + // aggregate_column_relation behavior + + /** + * Update the aggregate column in the related CcPlaylist object + * + * @param PropelPDO $con A connection object + */ + protected function updateRelatedCcPlaylist(PropelPDO $con) + { + if ($ccPlaylist = $this->getCcPlaylist()) { + if (!$ccPlaylist->isAlreadyInSave()) { + $ccPlaylist->updateDbLength($con); + } + } + if ($this->oldCcPlaylist) { + $this->oldCcPlaylist->updateDbLength($con); + $this->oldCcPlaylist = null; + } + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontentsPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontentsPeer.php index 0e23f44c3..3842e4074 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontentsPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontentsPeer.php @@ -1,1753 +1,1804 @@ array ('DbId', 'DbPlaylistId', 'DbFileId', 'DbBlockId', 'DbStreamId', 'DbType', 'DbPosition', 'DbTrackOffset', 'DbCliplength', 'DbCuein', 'DbCueout', 'DbFadein', 'DbFadeout', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbPlaylistId', 'dbFileId', 'dbBlockId', 'dbStreamId', 'dbType', 'dbPosition', 'dbTrackOffset', 'dbCliplength', 'dbCuein', 'dbCueout', 'dbFadein', 'dbFadeout', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::PLAYLIST_ID, self::FILE_ID, self::BLOCK_ID, self::STREAM_ID, self::TYPE, self::POSITION, self::TRACKOFFSET, self::CLIPLENGTH, self::CUEIN, self::CUEOUT, self::FADEIN, self::FADEOUT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PLAYLIST_ID', 'FILE_ID', 'BLOCK_ID', 'STREAM_ID', 'TYPE', 'POSITION', 'TRACKOFFSET', 'CLIPLENGTH', 'CUEIN', 'CUEOUT', 'FADEIN', 'FADEOUT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'playlist_id', 'file_id', 'block_id', 'stream_id', 'type', 'position', 'trackoffset', 'cliplength', 'cuein', 'cueout', 'fadein', 'fadeout', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) - ); - - /** - * 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, 'DbBlockId' => 3, 'DbStreamId' => 4, 'DbType' => 5, 'DbPosition' => 6, 'DbTrackOffset' => 7, 'DbCliplength' => 8, 'DbCuein' => 9, 'DbCueout' => 10, 'DbFadein' => 11, 'DbFadeout' => 12, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbPlaylistId' => 1, 'dbFileId' => 2, 'dbBlockId' => 3, 'dbStreamId' => 4, 'dbType' => 5, 'dbPosition' => 6, 'dbTrackOffset' => 7, 'dbCliplength' => 8, 'dbCuein' => 9, 'dbCueout' => 10, 'dbFadein' => 11, 'dbFadeout' => 12, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::PLAYLIST_ID => 1, self::FILE_ID => 2, self::BLOCK_ID => 3, self::STREAM_ID => 4, self::TYPE => 5, self::POSITION => 6, self::TRACKOFFSET => 7, self::CLIPLENGTH => 8, self::CUEIN => 9, self::CUEOUT => 10, self::FADEIN => 11, self::FADEOUT => 12, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PLAYLIST_ID' => 1, 'FILE_ID' => 2, 'BLOCK_ID' => 3, 'STREAM_ID' => 4, 'TYPE' => 5, 'POSITION' => 6, 'TRACKOFFSET' => 7, 'CLIPLENGTH' => 8, 'CUEIN' => 9, 'CUEOUT' => 10, 'FADEIN' => 11, 'FADEOUT' => 12, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'playlist_id' => 1, 'file_id' => 2, 'block_id' => 3, 'stream_id' => 4, 'type' => 5, 'position' => 6, 'trackoffset' => 7, 'cliplength' => 8, 'cuein' => 9, 'cueout' => 10, 'fadein' => 11, 'fadeout' => 12, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) - ); - - /** - * 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::BLOCK_ID); - $criteria->addSelectColumn(CcPlaylistcontentsPeer::STREAM_ID); - $criteria->addSelectColumn(CcPlaylistcontentsPeer::TYPE); - $criteria->addSelectColumn(CcPlaylistcontentsPeer::POSITION); - $criteria->addSelectColumn(CcPlaylistcontentsPeer::TRACKOFFSET); - $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 . '.BLOCK_ID'); - $criteria->addSelectColumn($alias . '.STREAM_ID'); - $criteria->addSelectColumn($alias . '.TYPE'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.TRACKOFFSET'); - $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 CcBlock 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 doCountJoinCcBlock(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::BLOCK_ID, CcBlockPeer::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 CcBlock 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 doSelectJoinCcBlock(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); - CcBlockPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcPlaylistcontentsPeer::BLOCK_ID, CcBlockPeer::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 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcBlockPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcBlockPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcBlockPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcPlaylistcontents) to $obj2 (CcBlock) - $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::BLOCK_ID, CcBlockPeer::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); - - CcBlockPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + (CcBlockPeer::NUM_COLUMNS - CcBlockPeer::NUM_LAZY_LOAD_COLUMNS); - - CcPlaylistPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + (CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcPlaylistcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $criteria->addJoin(CcPlaylistcontentsPeer::BLOCK_ID, CcBlockPeer::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 CcBlock rows - - $key3 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CcBlockPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CcBlockPeer::getOMClass(false); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CcBlockPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (CcPlaylistcontents) to the collection in $obj3 (CcBlock) - $obj3->addCcPlaylistcontents($obj1); - } // if joined row not null - - // Add objects for joined CcPlaylist rows - - $key4 = CcPlaylistPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = CcPlaylistPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = CcPlaylistPeer::getOMClass(false); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - CcPlaylistPeer::addInstanceToPool($obj4, $key4); - } // if obj4 loaded - - // Add the $obj1 (CcPlaylistcontents) to the collection in $obj4 (CcPlaylist) - $obj4->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::BLOCK_ID, CcBlockPeer::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; - } - - - /** - * Returns the number of rows matching criteria, joining the related CcBlock 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 doCountJoinAllExceptCcBlock(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); - - $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); - - $criteria->addJoin(CcPlaylistcontentsPeer::BLOCK_ID, CcBlockPeer::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); - - CcBlockPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcBlockPeer::NUM_COLUMNS - CcBlockPeer::NUM_LAZY_LOAD_COLUMNS); - - CcPlaylistPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + (CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcPlaylistcontentsPeer::BLOCK_ID, CcBlockPeer::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 CcBlock rows - - $key2 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcBlockPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcBlockPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcBlockPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (CcPlaylistcontents) to the collection in $obj2 (CcBlock) - $obj2->addCcPlaylistcontents($obj1); - - } // if joined row is 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 already loaded - - // Add the $obj1 (CcPlaylistcontents) to the collection in $obj3 (CcPlaylist) - $obj3->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 CcBlock. - * - * @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 doSelectJoinAllExceptCcBlock(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); - - 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); +abstract class BaseCcPlaylistcontentsPeer +{ + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; - $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 - - // 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 already loaded - - // Add the $obj1 (CcPlaylistcontents) to the collection in $obj3 (CcPlaylist) - $obj3->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); - - CcBlockPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + (CcBlockPeer::NUM_COLUMNS - CcBlockPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcPlaylistcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $criteria->addJoin(CcPlaylistcontentsPeer::BLOCK_ID, CcBlockPeer::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 - - // Add objects for joined CcBlock rows - - $key3 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CcBlockPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CcBlockPeer::getOMClass(false); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CcBlockPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (CcPlaylistcontents) to the collection in $obj3 (CcBlock) - $obj3->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; - } + /** the table name for this class */ + const TABLE_NAME = 'cc_playlistcontents'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcPlaylistcontents'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcPlaylistcontentsTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 13; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 13; + + /** the column name for the id field */ + const ID = 'cc_playlistcontents.id'; + + /** the column name for the playlist_id field */ + const PLAYLIST_ID = 'cc_playlistcontents.playlist_id'; + + /** the column name for the file_id field */ + const FILE_ID = 'cc_playlistcontents.file_id'; + + /** the column name for the block_id field */ + const BLOCK_ID = 'cc_playlistcontents.block_id'; + + /** the column name for the stream_id field */ + const STREAM_ID = 'cc_playlistcontents.stream_id'; + + /** the column name for the type field */ + const TYPE = 'cc_playlistcontents.type'; + + /** the column name for the position field */ + const POSITION = 'cc_playlistcontents.position'; + + /** the column name for the trackoffset field */ + const TRACKOFFSET = 'cc_playlistcontents.trackoffset'; + + /** the column name for the cliplength field */ + const CLIPLENGTH = 'cc_playlistcontents.cliplength'; + + /** the column name for the cuein field */ + const CUEIN = 'cc_playlistcontents.cuein'; + + /** the column name for the cueout field */ + const CUEOUT = 'cc_playlistcontents.cueout'; + + /** the column name for the fadein field */ + const FADEIN = 'cc_playlistcontents.fadein'; + + /** the column name for the fadeout field */ + const FADEOUT = 'cc_playlistcontents.fadeout'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcPlaylistcontents objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcPlaylistcontents[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcPlaylistcontentsPeer::$fieldNames[CcPlaylistcontentsPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbPlaylistId', 'DbFileId', 'DbBlockId', 'DbStreamId', 'DbType', 'DbPosition', 'DbTrackOffset', 'DbCliplength', 'DbCuein', 'DbCueout', 'DbFadein', 'DbFadeout', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbPlaylistId', 'dbFileId', 'dbBlockId', 'dbStreamId', 'dbType', 'dbPosition', 'dbTrackOffset', 'dbCliplength', 'dbCuein', 'dbCueout', 'dbFadein', 'dbFadeout', ), + BasePeer::TYPE_COLNAME => array (CcPlaylistcontentsPeer::ID, CcPlaylistcontentsPeer::PLAYLIST_ID, CcPlaylistcontentsPeer::FILE_ID, CcPlaylistcontentsPeer::BLOCK_ID, CcPlaylistcontentsPeer::STREAM_ID, CcPlaylistcontentsPeer::TYPE, CcPlaylistcontentsPeer::POSITION, CcPlaylistcontentsPeer::TRACKOFFSET, CcPlaylistcontentsPeer::CLIPLENGTH, CcPlaylistcontentsPeer::CUEIN, CcPlaylistcontentsPeer::CUEOUT, CcPlaylistcontentsPeer::FADEIN, CcPlaylistcontentsPeer::FADEOUT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PLAYLIST_ID', 'FILE_ID', 'BLOCK_ID', 'STREAM_ID', 'TYPE', 'POSITION', 'TRACKOFFSET', 'CLIPLENGTH', 'CUEIN', 'CUEOUT', 'FADEIN', 'FADEOUT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'playlist_id', 'file_id', 'block_id', 'stream_id', 'type', 'position', 'trackoffset', 'cliplength', 'cuein', 'cueout', 'fadein', 'fadeout', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcPlaylistcontentsPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbPlaylistId' => 1, 'DbFileId' => 2, 'DbBlockId' => 3, 'DbStreamId' => 4, 'DbType' => 5, 'DbPosition' => 6, 'DbTrackOffset' => 7, 'DbCliplength' => 8, 'DbCuein' => 9, 'DbCueout' => 10, 'DbFadein' => 11, 'DbFadeout' => 12, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbPlaylistId' => 1, 'dbFileId' => 2, 'dbBlockId' => 3, 'dbStreamId' => 4, 'dbType' => 5, 'dbPosition' => 6, 'dbTrackOffset' => 7, 'dbCliplength' => 8, 'dbCuein' => 9, 'dbCueout' => 10, 'dbFadein' => 11, 'dbFadeout' => 12, ), + BasePeer::TYPE_COLNAME => array (CcPlaylistcontentsPeer::ID => 0, CcPlaylistcontentsPeer::PLAYLIST_ID => 1, CcPlaylistcontentsPeer::FILE_ID => 2, CcPlaylistcontentsPeer::BLOCK_ID => 3, CcPlaylistcontentsPeer::STREAM_ID => 4, CcPlaylistcontentsPeer::TYPE => 5, CcPlaylistcontentsPeer::POSITION => 6, CcPlaylistcontentsPeer::TRACKOFFSET => 7, CcPlaylistcontentsPeer::CLIPLENGTH => 8, CcPlaylistcontentsPeer::CUEIN => 9, CcPlaylistcontentsPeer::CUEOUT => 10, CcPlaylistcontentsPeer::FADEIN => 11, CcPlaylistcontentsPeer::FADEOUT => 12, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PLAYLIST_ID' => 1, 'FILE_ID' => 2, 'BLOCK_ID' => 3, 'STREAM_ID' => 4, 'TYPE' => 5, 'POSITION' => 6, 'TRACKOFFSET' => 7, 'CLIPLENGTH' => 8, 'CUEIN' => 9, 'CUEOUT' => 10, 'FADEIN' => 11, 'FADEOUT' => 12, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'playlist_id' => 1, 'file_id' => 2, 'block_id' => 3, 'stream_id' => 4, 'type' => 5, 'position' => 6, 'trackoffset' => 7, 'cliplength' => 8, 'cuein' => 9, 'cueout' => 10, 'fadein' => 11, 'fadeout' => 12, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcPlaylistcontentsPeer::getFieldNames($toType); + $key = isset(CcPlaylistcontentsPeer::$fieldKeys[$fromType][$name]) ? CcPlaylistcontentsPeer::$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(CcPlaylistcontentsPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcPlaylistcontentsPeer::$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 CcPlaylistcontentsPeer::$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::BLOCK_ID); + $criteria->addSelectColumn(CcPlaylistcontentsPeer::STREAM_ID); + $criteria->addSelectColumn(CcPlaylistcontentsPeer::TYPE); + $criteria->addSelectColumn(CcPlaylistcontentsPeer::POSITION); + $criteria->addSelectColumn(CcPlaylistcontentsPeer::TRACKOFFSET); + $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 . '.block_id'); + $criteria->addSelectColumn($alias . '.stream_id'); + $criteria->addSelectColumn($alias . '.type'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.trackoffset'); + $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(CcPlaylistcontentsPeer::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; + } + /** + * Selects 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; + } + /** + * Selects several row from the DB. + * + * @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 directly (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(CcPlaylistcontentsPeer::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 $obj 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($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcPlaylistcontentsPeer::$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. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + 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(CcPlaylistcontentsPeer::$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(CcPlaylistcontentsPeer::$instances[$key])) { + return CcPlaylistcontentsPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcPlaylistcontentsPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcPlaylistcontentsPeer::$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(); + // 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_HYDRATE_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(CcPlaylistcontentsPeer::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 CcBlock 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 doCountJoinCcBlock(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(CcPlaylistcontentsPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcPlaylistcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlaylistcontentsPeer::BLOCK_ID, CcBlockPeer::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(CcPlaylistcontentsPeer::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(CcPlaylistcontentsPeer::DATABASE_NAME); + } + + CcPlaylistcontentsPeer::addSelectColumns($criteria); + $startcol = CcPlaylistcontentsPeer::NUM_HYDRATE_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(); + + $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(); + + $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 CcBlock 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 doSelectJoinCcBlock(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(CcPlaylistcontentsPeer::DATABASE_NAME); + } + + CcPlaylistcontentsPeer::addSelectColumns($criteria); + $startcol = CcPlaylistcontentsPeer::NUM_HYDRATE_COLUMNS; + CcBlockPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcPlaylistcontentsPeer::BLOCK_ID, CcBlockPeer::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(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlaylistcontentsPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcBlockPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcBlockPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcBlockPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcPlaylistcontents) to $obj2 (CcBlock) + $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(CcPlaylistcontentsPeer::DATABASE_NAME); + } + + CcPlaylistcontentsPeer::addSelectColumns($criteria); + $startcol = CcPlaylistcontentsPeer::NUM_HYDRATE_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(); + + $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(); + + $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(CcPlaylistcontentsPeer::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::BLOCK_ID, CcBlockPeer::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(CcPlaylistcontentsPeer::DATABASE_NAME); + } + + CcPlaylistcontentsPeer::addSelectColumns($criteria); + $startcol2 = CcPlaylistcontentsPeer::NUM_HYDRATE_COLUMNS; + + CcFilesPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcFilesPeer::NUM_HYDRATE_COLUMNS; + + CcBlockPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcBlockPeer::NUM_HYDRATE_COLUMNS; + + CcPlaylistPeer::addSelectColumns($criteria); + $startcol5 = $startcol4 + CcPlaylistPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcPlaylistcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $criteria->addJoin(CcPlaylistcontentsPeer::BLOCK_ID, CcBlockPeer::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(); + + $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(); + + $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 CcBlock rows + + $key3 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcBlockPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcBlockPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcBlockPeer::addInstanceToPool($obj3, $key3); + } // if obj3 loaded + + // Add the $obj1 (CcPlaylistcontents) to the collection in $obj3 (CcBlock) + $obj3->addCcPlaylistcontents($obj1); + } // if joined row not null + + // Add objects for joined CcPlaylist rows + + $key4 = CcPlaylistPeer::getPrimaryKeyHashFromRow($row, $startcol4); + if ($key4 !== null) { + $obj4 = CcPlaylistPeer::getInstanceFromPool($key4); + if (!$obj4) { + + $cls = CcPlaylistPeer::getOMClass(); + + $obj4 = new $cls(); + $obj4->hydrate($row, $startcol4); + CcPlaylistPeer::addInstanceToPool($obj4, $key4); + } // if obj4 loaded + + // Add the $obj1 (CcPlaylistcontents) to the collection in $obj4 (CcPlaylist) + $obj4->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(CcPlaylistcontentsPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcPlaylistcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlaylistcontentsPeer::BLOCK_ID, CcBlockPeer::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; + } + + + /** + * Returns the number of rows matching criteria, joining the related CcBlock 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 doCountJoinAllExceptCcBlock(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(CcPlaylistcontentsPeer::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; + } + + + /** + * 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(CcPlaylistcontentsPeer::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::BLOCK_ID, CcBlockPeer::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(CcPlaylistcontentsPeer::DATABASE_NAME); + } + + CcPlaylistcontentsPeer::addSelectColumns($criteria); + $startcol2 = CcPlaylistcontentsPeer::NUM_HYDRATE_COLUMNS; + + CcBlockPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcBlockPeer::NUM_HYDRATE_COLUMNS; + + CcPlaylistPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcPlaylistPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcPlaylistcontentsPeer::BLOCK_ID, CcBlockPeer::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(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlaylistcontentsPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcBlock rows + + $key2 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcBlockPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcBlockPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcBlockPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcPlaylistcontents) to the collection in $obj2 (CcBlock) + $obj2->addCcPlaylistcontents($obj1); + + } // if joined row is 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(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcPlaylistPeer::addInstanceToPool($obj3, $key3); + } // if $obj3 already loaded + + // Add the $obj1 (CcPlaylistcontents) to the collection in $obj3 (CcPlaylist) + $obj3->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 CcBlock. + * + * @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 doSelectJoinAllExceptCcBlock(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(CcPlaylistcontentsPeer::DATABASE_NAME); + } + + CcPlaylistcontentsPeer::addSelectColumns($criteria); + $startcol2 = CcPlaylistcontentsPeer::NUM_HYDRATE_COLUMNS; + + CcFilesPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcFilesPeer::NUM_HYDRATE_COLUMNS; + + CcPlaylistPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcPlaylistPeer::NUM_HYDRATE_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(); + + $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(); + + $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 + + // Add objects for joined CcPlaylist rows + + $key3 = CcPlaylistPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcPlaylistPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcPlaylistPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcPlaylistPeer::addInstanceToPool($obj3, $key3); + } // if $obj3 already loaded + + // Add the $obj1 (CcPlaylistcontents) to the collection in $obj3 (CcPlaylist) + $obj3->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(CcPlaylistcontentsPeer::DATABASE_NAME); + } + + CcPlaylistcontentsPeer::addSelectColumns($criteria); + $startcol2 = CcPlaylistcontentsPeer::NUM_HYDRATE_COLUMNS; + + CcFilesPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcFilesPeer::NUM_HYDRATE_COLUMNS; + + CcBlockPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcBlockPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcPlaylistcontentsPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $criteria->addJoin(CcPlaylistcontentsPeer::BLOCK_ID, CcBlockPeer::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(); + + $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(); + + $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 + + // Add objects for joined CcBlock rows + + $key3 = CcBlockPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcBlockPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcBlockPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcBlockPeer::addInstanceToPool($obj3, $key3); + } // if $obj3 already loaded + + // Add the $obj1 (CcPlaylistcontents) to the collection in $obj3 (CcBlock) + $obj3->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(CcPlaylistcontentsPeer::DATABASE_NAME)->getTable(CcPlaylistcontentsPeer::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 \Airtime\map\CcPlaylistcontentsTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcPlaylistcontentsPeer::OM_CLASS; + } + + /** + * Performs 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(CcPlaylistcontentsPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs 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(CcPlaylistcontentsPeer::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(CcPlaylistcontentsPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_playlistcontents table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $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 (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs 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(CcPlaylistcontentsPeer::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(CcPlaylistcontentsPeer::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 (Exception $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($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->hasColumn($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 + * @return CcPlaylistcontents[] + * @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 diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontentsQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontentsQuery.php index ef3d3877a..cb20ff795 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontentsQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistcontentsQuery.php @@ -1,848 +1,1142 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcPlaylistcontents|CcPlaylistcontents[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcPlaylistcontentsPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcPlaylistcontentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $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); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlaylistcontents A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * 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); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlaylistcontents A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "playlist_id", "file_id", "block_id", "stream_id", "type", "position", "trackoffset", "cliplength", "cuein", "cueout", "fadein", "fadeout" FROM "cc_playlistcontents" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcPlaylistcontents(); + $obj->hydrate($row); + CcPlaylistcontentsPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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); - } + return $obj; + } - /** - * 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); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlaylistcontents|CcPlaylistcontents[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * 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); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query on the block_id column - * - * @param int|array $dbBlockId 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 filterByDbBlockId($dbBlockId = null, $comparison = null) - { - if (is_array($dbBlockId)) { - $useMinMax = false; - if (isset($dbBlockId['min'])) { - $this->addUsingAlias(CcPlaylistcontentsPeer::BLOCK_ID, $dbBlockId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbBlockId['max'])) { - $this->addUsingAlias(CcPlaylistcontentsPeer::BLOCK_ID, $dbBlockId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcPlaylistcontentsPeer::BLOCK_ID, $dbBlockId, $comparison); - } + /** + * 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|CcPlaylistcontents[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query on the stream_id column - * - * @param int|array $dbStreamId 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 filterByDbStreamId($dbStreamId = null, $comparison = null) - { - if (is_array($dbStreamId)) { - $useMinMax = false; - if (isset($dbStreamId['min'])) { - $this->addUsingAlias(CcPlaylistcontentsPeer::STREAM_ID, $dbStreamId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbStreamId['max'])) { - $this->addUsingAlias(CcPlaylistcontentsPeer::STREAM_ID, $dbStreamId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcPlaylistcontentsPeer::STREAM_ID, $dbStreamId, $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Filter the query on the type column - * - * @param int|array $dbType 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 filterByDbType($dbType = null, $comparison = null) - { - if (is_array($dbType)) { - $useMinMax = false; - if (isset($dbType['min'])) { - $this->addUsingAlias(CcPlaylistcontentsPeer::TYPE, $dbType['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbType['max'])) { - $this->addUsingAlias(CcPlaylistcontentsPeer::TYPE, $dbType['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcPlaylistcontentsPeer::TYPE, $dbType, $comparison); - } + /** + * 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) + { - /** - * 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); - } + return $this->addUsingAlias(CcPlaylistcontentsPeer::ID, $key, Criteria::EQUAL); + } - /** - * Filter the query on the trackoffset column - * - * @param double|array $dbTrackOffset 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 filterByDbTrackOffset($dbTrackOffset = null, $comparison = null) - { - if (is_array($dbTrackOffset)) { - $useMinMax = false; - if (isset($dbTrackOffset['min'])) { - $this->addUsingAlias(CcPlaylistcontentsPeer::TRACKOFFSET, $dbTrackOffset['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbTrackOffset['max'])) { - $this->addUsingAlias(CcPlaylistcontentsPeer::TRACKOFFSET, $dbTrackOffset['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcPlaylistcontentsPeer::TRACKOFFSET, $dbTrackOffset, $comparison); - } + /** + * 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) + { - /** - * Filter the query on the cliplength column - * - * @param string $dbCliplength 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 CcPlaylistcontentsQuery The current query, for fluid interface - */ - public function filterByDbCliplength($dbCliplength = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbCliplength)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbCliplength)) { - $dbCliplength = str_replace('*', '%', $dbCliplength); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcPlaylistcontentsPeer::CLIPLENGTH, $dbCliplength, $comparison); - } + return $this->addUsingAlias(CcPlaylistcontentsPeer::ID, $keys, Criteria::IN); + } - /** - * Filter the query on the cuein column - * - * @param string $dbCuein 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 CcPlaylistcontentsQuery The current query, for fluid interface - */ - public function filterByDbCuein($dbCuein = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbCuein)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbCuein)) { - $dbCuein = str_replace('*', '%', $dbCuein); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcPlaylistcontentsPeer::CUEIN, $dbCuein, $comparison); - } + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @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)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Filter the query on the cueout column - * - * @param string $dbCueout 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 CcPlaylistcontentsQuery The current query, for fluid interface - */ - public function filterByDbCueout($dbCueout = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbCueout)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbCueout)) { - $dbCueout = str_replace('*', '%', $dbCueout); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcPlaylistcontentsPeer::CUEOUT, $dbCueout, $comparison); - } + return $this->addUsingAlias(CcPlaylistcontentsPeer::ID, $dbId, $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 playlist_id column + * + * Example usage: + * + * $query->filterByDbPlaylistId(1234); // WHERE playlist_id = 1234 + * $query->filterByDbPlaylistId(array(12, 34)); // WHERE playlist_id IN (12, 34) + * $query->filterByDbPlaylistId(array('min' => 12)); // WHERE playlist_id >= 12 + * $query->filterByDbPlaylistId(array('max' => 12)); // WHERE playlist_id <= 12 + * + * + * @see filterByCcPlaylist() + * + * @param mixed $dbPlaylistId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @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; + } + } - /** - * 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); - } + return $this->addUsingAlias(CcPlaylistcontentsPeer::PLAYLIST_ID, $dbPlaylistId, $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); - } + /** + * Filter the query on the file_id column + * + * Example usage: + * + * $query->filterByDbFileId(1234); // WHERE file_id = 1234 + * $query->filterByDbFileId(array(12, 34)); // WHERE file_id IN (12, 34) + * $query->filterByDbFileId(array('min' => 12)); // WHERE file_id >= 12 + * $query->filterByDbFileId(array('max' => 12)); // WHERE file_id <= 12 + * + * + * @see filterByCcFiles() + * + * @param mixed $dbFileId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @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; + } + } - /** - * 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; - } + return $this->addUsingAlias(CcPlaylistcontentsPeer::FILE_ID, $dbFileId, $comparison); + } - /** - * 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 on the block_id column + * + * Example usage: + * + * $query->filterByDbBlockId(1234); // WHERE block_id = 1234 + * $query->filterByDbBlockId(array(12, 34)); // WHERE block_id IN (12, 34) + * $query->filterByDbBlockId(array('min' => 12)); // WHERE block_id >= 12 + * $query->filterByDbBlockId(array('max' => 12)); // WHERE block_id <= 12 + * + * + * @see filterByCcBlock() + * + * @param mixed $dbBlockId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByDbBlockId($dbBlockId = null, $comparison = null) + { + if (is_array($dbBlockId)) { + $useMinMax = false; + if (isset($dbBlockId['min'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::BLOCK_ID, $dbBlockId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbBlockId['max'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::BLOCK_ID, $dbBlockId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Filter the query by a related CcBlock object - * - * @param CcBlock $ccBlock 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 filterByCcBlock($ccBlock, $comparison = null) - { - return $this - ->addUsingAlias(CcPlaylistcontentsPeer::BLOCK_ID, $ccBlock->getDbId(), $comparison); - } + return $this->addUsingAlias(CcPlaylistcontentsPeer::BLOCK_ID, $dbBlockId, $comparison); + } - /** - * Adds a JOIN clause to the query using the CcBlock 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 joinCcBlock($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcBlock'); - - // 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, 'CcBlock'); - } - - return $this; - } + /** + * Filter the query on the stream_id column + * + * Example usage: + * + * $query->filterByDbStreamId(1234); // WHERE stream_id = 1234 + * $query->filterByDbStreamId(array(12, 34)); // WHERE stream_id IN (12, 34) + * $query->filterByDbStreamId(array('min' => 12)); // WHERE stream_id >= 12 + * $query->filterByDbStreamId(array('max' => 12)); // WHERE stream_id <= 12 + * + * + * @param mixed $dbStreamId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByDbStreamId($dbStreamId = null, $comparison = null) + { + if (is_array($dbStreamId)) { + $useMinMax = false; + if (isset($dbStreamId['min'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::STREAM_ID, $dbStreamId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbStreamId['max'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::STREAM_ID, $dbStreamId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Use the CcBlock relation CcBlock 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 CcBlockQuery A secondary query class using the current class as primary query - */ - public function useCcBlockQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcBlock($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcBlock', 'CcBlockQuery'); - } + return $this->addUsingAlias(CcPlaylistcontentsPeer::STREAM_ID, $dbStreamId, $comparison); + } - /** - * Filter the query by a related CcPlaylist object - * - * @param CcPlaylist $ccPlaylist the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcPlaylistcontentsQuery The current query, for fluid interface - */ - public function filterByCcPlaylist($ccPlaylist, $comparison = null) - { - return $this - ->addUsingAlias(CcPlaylistcontentsPeer::PLAYLIST_ID, $ccPlaylist->getDbId(), $comparison); - } + /** + * Filter the query on the type column + * + * Example usage: + * + * $query->filterByDbType(1234); // WHERE type = 1234 + * $query->filterByDbType(array(12, 34)); // WHERE type IN (12, 34) + * $query->filterByDbType(array('min' => 12)); // WHERE type >= 12 + * $query->filterByDbType(array('max' => 12)); // WHERE type <= 12 + * + * + * @param mixed $dbType The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByDbType($dbType = null, $comparison = null) + { + if (is_array($dbType)) { + $useMinMax = false; + if (isset($dbType['min'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::TYPE, $dbType['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbType['max'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::TYPE, $dbType['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * 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; - } + return $this->addUsingAlias(CcPlaylistcontentsPeer::TYPE, $dbType, $comparison); + } - /** - * 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 on the position column + * + * Example usage: + * + * $query->filterByDbPosition(1234); // WHERE position = 1234 + * $query->filterByDbPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByDbPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByDbPosition(array('max' => 12)); // WHERE position <= 12 + * + * + * @param mixed $dbPosition The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @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; + } + } - /** - * 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; - } + return $this->addUsingAlias(CcPlaylistcontentsPeer::POSITION, $dbPosition, $comparison); + } - /** - * Code to execute before every DELETE statement - * - * @param PropelPDO $con The connection object used by the query - */ - protected function basePreDelete(PropelPDO $con) - { - // aggregate_column_relation behavior - $this->findRelatedCcPlaylists($con); - - return $this->preDelete($con); - } + /** + * Filter the query on the trackoffset column + * + * Example usage: + * + * $query->filterByDbTrackOffset(1234); // WHERE trackoffset = 1234 + * $query->filterByDbTrackOffset(array(12, 34)); // WHERE trackoffset IN (12, 34) + * $query->filterByDbTrackOffset(array('min' => 12)); // WHERE trackoffset >= 12 + * $query->filterByDbTrackOffset(array('max' => 12)); // WHERE trackoffset <= 12 + * + * + * @param mixed $dbTrackOffset The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByDbTrackOffset($dbTrackOffset = null, $comparison = null) + { + if (is_array($dbTrackOffset)) { + $useMinMax = false; + if (isset($dbTrackOffset['min'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::TRACKOFFSET, $dbTrackOffset['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbTrackOffset['max'])) { + $this->addUsingAlias(CcPlaylistcontentsPeer::TRACKOFFSET, $dbTrackOffset['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Code to execute after every DELETE statement - * - * @param int $affectedRows the number of deleted rows - * @param PropelPDO $con The connection object used by the query - */ - protected function basePostDelete($affectedRows, PropelPDO $con) - { - // aggregate_column_relation behavior - $this->updateRelatedCcPlaylists($con); - - return $this->postDelete($affectedRows, $con); - } + return $this->addUsingAlias(CcPlaylistcontentsPeer::TRACKOFFSET, $dbTrackOffset, $comparison); + } - /** - * Code to execute before every UPDATE statement - * - * @param array $values The associatiove array of columns and values for the update - * @param PropelPDO $con The connection object used by the query - * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), ortherwise it is a series of save() calls on all the found objects - */ - protected function basePreUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false) - { - // aggregate_column_relation behavior - $this->findRelatedCcPlaylists($con); - - return $this->preUpdate($values, $con, $forceIndividualSaves); - } + /** + * Filter the query on the cliplength column + * + * Example usage: + * + * $query->filterByDbCliplength('fooValue'); // WHERE cliplength = 'fooValue' + * $query->filterByDbCliplength('%fooValue%'); // WHERE cliplength LIKE '%fooValue%' + * + * + * @param string $dbCliplength 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 CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByDbCliplength($dbCliplength = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbCliplength)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbCliplength)) { + $dbCliplength = str_replace('*', '%', $dbCliplength); + $comparison = Criteria::LIKE; + } + } - /** - * Code to execute after every UPDATE statement - * - * @param int $affectedRows the number of udated rows - * @param PropelPDO $con The connection object used by the query - */ - protected function basePostUpdate($affectedRows, PropelPDO $con) - { - // aggregate_column_relation behavior - $this->updateRelatedCcPlaylists($con); - - return $this->postUpdate($affectedRows, $con); - } + return $this->addUsingAlias(CcPlaylistcontentsPeer::CLIPLENGTH, $dbCliplength, $comparison); + } - // aggregate_column_relation behavior - - /** - * Finds the related CcPlaylist objects and keep them for later - * - * @param PropelPDO $con A connection object - */ - protected function findRelatedCcPlaylists($con) - { - $criteria = clone $this; - if ($this->useAliasInSQL) { - $alias = $this->getModelAlias(); - $criteria->removeAlias($alias); - } else { - $alias = ''; - } - $this->ccPlaylists = CcPlaylistQuery::create() - ->joinCcPlaylistcontents($alias) - ->mergeWith($criteria) - ->find($con); - } - - protected function updateRelatedCcPlaylists($con) - { - foreach ($this->ccPlaylists as $ccPlaylist) { - $ccPlaylist->updateDbLength($con); - } - $this->ccPlaylists = array(); - } + /** + * Filter the query on the cuein column + * + * Example usage: + * + * $query->filterByDbCuein('fooValue'); // WHERE cuein = 'fooValue' + * $query->filterByDbCuein('%fooValue%'); // WHERE cuein LIKE '%fooValue%' + * + * + * @param string $dbCuein 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 CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByDbCuein($dbCuein = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbCuein)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbCuein)) { + $dbCuein = str_replace('*', '%', $dbCuein); + $comparison = Criteria::LIKE; + } + } -} // BaseCcPlaylistcontentsQuery + return $this->addUsingAlias(CcPlaylistcontentsPeer::CUEIN, $dbCuein, $comparison); + } + + /** + * Filter the query on the cueout column + * + * Example usage: + * + * $query->filterByDbCueout('fooValue'); // WHERE cueout = 'fooValue' + * $query->filterByDbCueout('%fooValue%'); // WHERE cueout LIKE '%fooValue%' + * + * + * @param string $dbCueout 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 CcPlaylistcontentsQuery The current query, for fluid interface + */ + public function filterByDbCueout($dbCueout = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbCueout)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbCueout)) { + $dbCueout = str_replace('*', '%', $dbCueout); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcPlaylistcontentsPeer::CUEOUT, $dbCueout, $comparison); + } + + /** + * Filter the query on the fadein column + * + * Example usage: + * + * $query->filterByDbFadein('2011-03-14'); // WHERE fadein = '2011-03-14' + * $query->filterByDbFadein('now'); // WHERE fadein = '2011-03-14' + * $query->filterByDbFadein(array('max' => 'yesterday')); // WHERE fadein < '2011-03-13' + * + * + * @param mixed $dbFadein The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @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 + * + * Example usage: + * + * $query->filterByDbFadeout('2011-03-14'); // WHERE fadeout = '2011-03-14' + * $query->filterByDbFadeout('now'); // WHERE fadeout = '2011-03-14' + * $query->filterByDbFadeout(array('max' => 'yesterday')); // WHERE fadeout < '2011-03-13' + * + * + * @param mixed $dbFadeout The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @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|PropelObjectCollection $ccFiles The related object(s) 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcFiles($ccFiles, $comparison = null) + { + if ($ccFiles instanceof CcFiles) { + return $this + ->addUsingAlias(CcPlaylistcontentsPeer::FILE_ID, $ccFiles->getDbId(), $comparison); + } elseif ($ccFiles instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcPlaylistcontentsPeer::FILE_ID, $ccFiles->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcFiles() only accepts arguments of type CcFiles or PropelCollection'); + } + } + + /** + * 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 = null, $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 \Airtime\CcFilesQuery A secondary query class using the current class as primary query + */ + public function useCcFilesQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcFiles($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcFiles', '\Airtime\CcFilesQuery'); + } + + /** + * Filter the query by a related CcBlock object + * + * @param CcBlock|PropelObjectCollection $ccBlock The related object(s) 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcBlock($ccBlock, $comparison = null) + { + if ($ccBlock instanceof CcBlock) { + return $this + ->addUsingAlias(CcPlaylistcontentsPeer::BLOCK_ID, $ccBlock->getDbId(), $comparison); + } elseif ($ccBlock instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcPlaylistcontentsPeer::BLOCK_ID, $ccBlock->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcBlock() only accepts arguments of type CcBlock or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcBlock 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 joinCcBlock($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcBlock'); + + // 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, 'CcBlock'); + } + + return $this; + } + + /** + * Use the CcBlock relation CcBlock 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 \Airtime\CcBlockQuery A secondary query class using the current class as primary query + */ + public function useCcBlockQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcBlock($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcBlock', '\Airtime\CcBlockQuery'); + } + + /** + * Filter the query by a related CcPlaylist object + * + * @param CcPlaylist|PropelObjectCollection $ccPlaylist The related object(s) 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcPlaylist($ccPlaylist, $comparison = null) + { + if ($ccPlaylist instanceof CcPlaylist) { + return $this + ->addUsingAlias(CcPlaylistcontentsPeer::PLAYLIST_ID, $ccPlaylist->getDbId(), $comparison); + } elseif ($ccPlaylist instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcPlaylistcontentsPeer::PLAYLIST_ID, $ccPlaylist->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcPlaylist() only accepts arguments of type CcPlaylist or PropelCollection'); + } + } + + /** + * 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 = null, $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 \Airtime\CcPlaylistQuery A secondary query class using the current class as primary query + */ + public function useCcPlaylistQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcPlaylist($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPlaylist', '\Airtime\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; + } + + /** + * Code to execute before every DELETE statement + * + * @param PropelPDO $con The connection object used by the query + */ + protected function basePreDelete(PropelPDO $con) + { + // aggregate_column_relation behavior + $this->findRelatedCcPlaylists($con); + + return $this->preDelete($con); + } + + /** + * Code to execute after every DELETE statement + * + * @param int $affectedRows the number of deleted rows + * @param PropelPDO $con The connection object used by the query + */ + protected function basePostDelete($affectedRows, PropelPDO $con) + { + // aggregate_column_relation behavior + $this->updateRelatedCcPlaylists($con); + + return $this->postDelete($affectedRows, $con); + } + + /** + * Code to execute before every UPDATE statement + * + * @param array $values The associative array of columns and values for the update + * @param PropelPDO $con The connection object used by the query + * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), otherwise it is a series of save() calls on all the found objects + */ + protected function basePreUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false) + { + // aggregate_column_relation behavior + $this->findRelatedCcPlaylists($con); + + return $this->preUpdate($values, $con, $forceIndividualSaves); + } + + /** + * Code to execute after every UPDATE statement + * + * @param int $affectedRows the number of updated rows + * @param PropelPDO $con The connection object used by the query + */ + protected function basePostUpdate($affectedRows, PropelPDO $con) + { + // aggregate_column_relation behavior + $this->updateRelatedCcPlaylists($con); + + return $this->postUpdate($affectedRows, $con); + } + + // aggregate_column_relation behavior + + /** + * Finds the related CcPlaylist objects and keep them for later + * + * @param PropelPDO $con A connection object + */ + protected function findRelatedCcPlaylists($con) + { + $criteria = clone $this; + if ($this->useAliasInSQL) { + $alias = $this->getModelAlias(); + $criteria->removeAlias($alias); + } else { + $alias = ''; + } + $this->ccPlaylists = CcPlaylistQuery::create() + ->joinCcPlaylistcontents($alias) + ->mergeWith($criteria) + ->find($con); + } + + protected function updateRelatedCcPlaylists($con) + { + foreach ($this->ccPlaylists as $ccPlaylist) { + $ccPlaylist->updateDbLength($con); + } + $this->ccPlaylists = array(); + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistory.php b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistory.php index 2e55a484f..51010f1d1 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistory.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistory.php @@ -1,1288 +1,1566 @@ id; - } - - /** - * Get the [file_id] column value. - * - * @return int - */ - public function getDbFileId() - { - return $this->file_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 getDbStarts($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 getDbEnds($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 [instance_id] column value. - * - * @return int - */ - public function getDbInstanceId() - { - return $this->instance_id; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcPlayoutHistory 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[] = CcPlayoutHistoryPeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [file_id] column. - * - * @param int $v new value - * @return CcPlayoutHistory 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[] = CcPlayoutHistoryPeer::FILE_ID; - } - - if ($this->aCcFiles !== null && $this->aCcFiles->getDbId() !== $v) { - $this->aCcFiles = null; - } - - return $this; - } // setDbFileId() - - /** - * 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 CcPlayoutHistory The current object (for fluent API support) - */ - public function setDbStarts($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[] = CcPlayoutHistoryPeer::STARTS; - } - } // if either are not null - - return $this; - } // setDbStarts() - - /** - * 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 CcPlayoutHistory The current object (for fluent API support) - */ - public function setDbEnds($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[] = CcPlayoutHistoryPeer::ENDS; - } - } // if either are not null - - return $this; - } // setDbEnds() - - /** - * Set the value of [instance_id] column. - * - * @param int $v new value - * @return CcPlayoutHistory The current object (for fluent API support) - */ - public function setDbInstanceId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->instance_id !== $v) { - $this->instance_id = $v; - $this->modifiedColumns[] = CcPlayoutHistoryPeer::INSTANCE_ID; - } - - if ($this->aCcShowInstances !== null && $this->aCcShowInstances->getDbId() !== $v) { - $this->aCcShowInstances = null; - } - - return $this; - } // setDbInstanceId() - - /** - * 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->file_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->instance_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 5; // 5 = CcPlayoutHistoryPeer::NUM_COLUMNS - CcPlayoutHistoryPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcPlayoutHistory 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->aCcFiles !== null && $this->file_id !== $this->aCcFiles->getDbId()) { - $this->aCcFiles = null; - } - if ($this->aCcShowInstances !== null && $this->instance_id !== $this->aCcShowInstances->getDbId()) { - $this->aCcShowInstances = 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(CcPlayoutHistoryPeer::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 = CcPlayoutHistoryPeer::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->aCcShowInstances = null; - $this->collCcPlayoutHistoryMetaDatas = 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(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcPlayoutHistoryQuery::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(CcPlayoutHistoryPeer::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); - CcPlayoutHistoryPeer::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->aCcShowInstances !== null) { - if ($this->aCcShowInstances->isModified() || $this->aCcShowInstances->isNew()) { - $affectedRows += $this->aCcShowInstances->save($con); - } - $this->setCcShowInstances($this->aCcShowInstances); - } - - if ($this->isNew() ) { - $this->modifiedColumns[] = CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlayoutHistoryPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows += 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows += CcPlayoutHistoryPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - if ($this->collCcPlayoutHistoryMetaDatas !== null) { - foreach ($this->collCcPlayoutHistoryMetaDatas 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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcFiles !== null) { - if (!$this->aCcFiles->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcFiles->getValidationFailures()); - } - } - - if ($this->aCcShowInstances !== null) { - if (!$this->aCcShowInstances->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcShowInstances->getValidationFailures()); - } - } - - - if (($retval = CcPlayoutHistoryPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collCcPlayoutHistoryMetaDatas !== null) { - foreach ($this->collCcPlayoutHistoryMetaDatas 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 = CcPlayoutHistoryPeer::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->getDbFileId(); - break; - case 2: - return $this->getDbStarts(); - break; - case 3: - return $this->getDbEnds(); - break; - case 4: - return $this->getDbInstanceId(); - 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 = CcPlayoutHistoryPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbFileId(), - $keys[2] => $this->getDbStarts(), - $keys[3] => $this->getDbEnds(), - $keys[4] => $this->getDbInstanceId(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCcFiles) { - $result['CcFiles'] = $this->aCcFiles->toArray($keyType, $includeLazyLoadColumns, true); - } - if (null !== $this->aCcShowInstances) { - $result['CcShowInstances'] = $this->aCcShowInstances->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 = CcPlayoutHistoryPeer::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->setDbFileId($value); - break; - case 2: - $this->setDbStarts($value); - break; - case 3: - $this->setDbEnds($value); - break; - case 4: - $this->setDbInstanceId($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 = CcPlayoutHistoryPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbFileId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbStarts($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbEnds($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbInstanceId($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(CcPlayoutHistoryPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcPlayoutHistoryPeer::ID)) $criteria->add(CcPlayoutHistoryPeer::ID, $this->id); - if ($this->isColumnModified(CcPlayoutHistoryPeer::FILE_ID)) $criteria->add(CcPlayoutHistoryPeer::FILE_ID, $this->file_id); - if ($this->isColumnModified(CcPlayoutHistoryPeer::STARTS)) $criteria->add(CcPlayoutHistoryPeer::STARTS, $this->starts); - if ($this->isColumnModified(CcPlayoutHistoryPeer::ENDS)) $criteria->add(CcPlayoutHistoryPeer::ENDS, $this->ends); - if ($this->isColumnModified(CcPlayoutHistoryPeer::INSTANCE_ID)) $criteria->add(CcPlayoutHistoryPeer::INSTANCE_ID, $this->instance_id); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(CcPlayoutHistoryPeer::DATABASE_NAME); - $criteria->add(CcPlayoutHistoryPeer::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 CcPlayoutHistory (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->setDbFileId($this->file_id); - $copyObj->setDbStarts($this->starts); - $copyObj->setDbEnds($this->ends); - $copyObj->setDbInstanceId($this->instance_id); - - 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->getCcPlayoutHistoryMetaDatas() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcPlayoutHistoryMetaData($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 CcPlayoutHistory 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 CcPlayoutHistoryPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcPlayoutHistoryPeer(); - } - return self::$peer; - } - - /** - * Declares an association between this object and a CcFiles object. - * - * @param CcFiles $v - * @return CcPlayoutHistory 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->addCcPlayoutHistory($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->addCcPlayoutHistorys($this); - */ - } - return $this->aCcFiles; - } - - /** - * Declares an association between this object and a CcShowInstances object. - * - * @param CcShowInstances $v - * @return CcPlayoutHistory The current object (for fluent API support) - * @throws PropelException - */ - public function setCcShowInstances(CcShowInstances $v = null) - { - if ($v === null) { - $this->setDbInstanceId(NULL); - } else { - $this->setDbInstanceId($v->getDbId()); - } - - $this->aCcShowInstances = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcShowInstances object, it will not be re-added. - if ($v !== null) { - $v->addCcPlayoutHistory($this); - } - - return $this; - } - - - /** - * Get the associated CcShowInstances object - * - * @param PropelPDO Optional Connection object. - * @return CcShowInstances The associated CcShowInstances object. - * @throws PropelException - */ - public function getCcShowInstances(PropelPDO $con = null) - { - if ($this->aCcShowInstances === null && ($this->instance_id !== null)) { - $this->aCcShowInstances = CcShowInstancesQuery::create()->findPk($this->instance_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->aCcShowInstances->addCcPlayoutHistorys($this); - */ - } - return $this->aCcShowInstances; - } - - /** - * Clears out the collCcPlayoutHistoryMetaDatas 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 addCcPlayoutHistoryMetaDatas() - */ - public function clearCcPlayoutHistoryMetaDatas() - { - $this->collCcPlayoutHistoryMetaDatas = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcPlayoutHistoryMetaDatas collection. - * - * By default this just sets the collCcPlayoutHistoryMetaDatas collection to an empty array (like clearcollCcPlayoutHistoryMetaDatas()); - * 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 initCcPlayoutHistoryMetaDatas() - { - $this->collCcPlayoutHistoryMetaDatas = new PropelObjectCollection(); - $this->collCcPlayoutHistoryMetaDatas->setModel('CcPlayoutHistoryMetaData'); - } - - /** - * Gets an array of CcPlayoutHistoryMetaData 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 CcPlayoutHistory 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 CcPlayoutHistoryMetaData[] List of CcPlayoutHistoryMetaData objects - * @throws PropelException - */ - public function getCcPlayoutHistoryMetaDatas($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcPlayoutHistoryMetaDatas || null !== $criteria) { - if ($this->isNew() && null === $this->collCcPlayoutHistoryMetaDatas) { - // return empty collection - $this->initCcPlayoutHistoryMetaDatas(); - } else { - $collCcPlayoutHistoryMetaDatas = CcPlayoutHistoryMetaDataQuery::create(null, $criteria) - ->filterByCcPlayoutHistory($this) - ->find($con); - if (null !== $criteria) { - return $collCcPlayoutHistoryMetaDatas; - } - $this->collCcPlayoutHistoryMetaDatas = $collCcPlayoutHistoryMetaDatas; - } - } - return $this->collCcPlayoutHistoryMetaDatas; - } - - /** - * Returns the number of related CcPlayoutHistoryMetaData objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcPlayoutHistoryMetaData objects. - * @throws PropelException - */ - public function countCcPlayoutHistoryMetaDatas(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcPlayoutHistoryMetaDatas || null !== $criteria) { - if ($this->isNew() && null === $this->collCcPlayoutHistoryMetaDatas) { - return 0; - } else { - $query = CcPlayoutHistoryMetaDataQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcPlayoutHistory($this) - ->count($con); - } - } else { - return count($this->collCcPlayoutHistoryMetaDatas); - } - } - - /** - * Method called to associate a CcPlayoutHistoryMetaData object to this object - * through the CcPlayoutHistoryMetaData foreign key attribute. - * - * @param CcPlayoutHistoryMetaData $l CcPlayoutHistoryMetaData - * @return void - * @throws PropelException - */ - public function addCcPlayoutHistoryMetaData(CcPlayoutHistoryMetaData $l) - { - if ($this->collCcPlayoutHistoryMetaDatas === null) { - $this->initCcPlayoutHistoryMetaDatas(); - } - if (!$this->collCcPlayoutHistoryMetaDatas->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcPlayoutHistoryMetaDatas[]= $l; - $l->setCcPlayoutHistory($this); - } - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->file_id = null; - $this->starts = null; - $this->ends = null; - $this->instance_id = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all collections of referencing foreign keys. - * - * This method is a user-space workaround for PHP's inability to garbage collect objects - * with circular references. This is currently necessary when using Propel in certain - * daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all associated objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep) { - if ($this->collCcPlayoutHistoryMetaDatas) { - foreach ((array) $this->collCcPlayoutHistoryMetaDatas as $o) { - $o->clearAllReferences($deep); - } - } - } // if ($deep) - - $this->collCcPlayoutHistoryMetaDatas = null; - $this->aCcFiles = null; - $this->aCcShowInstances = 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); - } - -} // BaseCcPlayoutHistory + /** + * Peer class name + */ + const PEER = 'Airtime\\PlayoutHistory\\CcPlayoutHistoryPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcPlayoutHistoryPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the file_id field. + * @var int + */ + protected $file_id; + + /** + * The value for the starts field. + * @var string + */ + protected $starts; + + /** + * The value for the ends field. + * @var string + */ + protected $ends; + + /** + * The value for the instance_id field. + * @var int + */ + protected $instance_id; + + /** + * @var CcFiles + */ + protected $aCcFiles; + + /** + * @var CcShowInstances + */ + protected $aCcShowInstances; + + /** + * @var PropelObjectCollection|CcPlayoutHistoryMetaData[] Collection to store aggregation of CcPlayoutHistoryMetaData objects. + */ + protected $collCcPlayoutHistoryMetaDatas; + protected $collCcPlayoutHistoryMetaDatasPartial; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccPlayoutHistoryMetaDatasScheduledForDeletion = null; + + /** + * Get the [id] column value. + * + * @return int + */ + public function getDbId() + { + + return $this->id; + } + + /** + * Get the [file_id] column value. + * + * @return int + */ + public function getDbFileId() + { + + return $this->file_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 getDbStarts($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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + 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 getDbEnds($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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [instance_id] column value. + * + * @return int + */ + public function getDbInstanceId() + { + + return $this->instance_id; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcPlayoutHistory The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcPlayoutHistoryPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [file_id] column. + * + * @param int $v new value + * @return CcPlayoutHistory The current object (for fluent API support) + */ + public function setDbFileId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->file_id !== $v) { + $this->file_id = $v; + $this->modifiedColumns[] = CcPlayoutHistoryPeer::FILE_ID; + } + + if ($this->aCcFiles !== null && $this->aCcFiles->getDbId() !== $v) { + $this->aCcFiles = null; + } + + + return $this; + } // setDbFileId() + + /** + * 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 strings are treated as null. + * @return CcPlayoutHistory The current object (for fluent API support) + */ + public function setDbStarts($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->starts !== null || $dt !== null) { + $currentDateAsString = ($this->starts !== null && $tmpDt = new DateTime($this->starts)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->starts = $newDateAsString; + $this->modifiedColumns[] = CcPlayoutHistoryPeer::STARTS; + } + } // if either are not null + + + return $this; + } // setDbStarts() + + /** + * 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 strings are treated as null. + * @return CcPlayoutHistory The current object (for fluent API support) + */ + public function setDbEnds($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->ends !== null || $dt !== null) { + $currentDateAsString = ($this->ends !== null && $tmpDt = new DateTime($this->ends)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->ends = $newDateAsString; + $this->modifiedColumns[] = CcPlayoutHistoryPeer::ENDS; + } + } // if either are not null + + + return $this; + } // setDbEnds() + + /** + * Set the value of [instance_id] column. + * + * @param int $v new value + * @return CcPlayoutHistory The current object (for fluent API support) + */ + public function setDbInstanceId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->instance_id !== $v) { + $this->instance_id = $v; + $this->modifiedColumns[] = CcPlayoutHistoryPeer::INSTANCE_ID; + } + + if ($this->aCcShowInstances !== null && $this->aCcShowInstances->getDbId() !== $v) { + $this->aCcShowInstances = null; + } + + + return $this; + } // setDbInstanceId() + + /** + * 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 resultset 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->file_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->instance_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 5; // 5 = CcPlayoutHistoryPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcPlayoutHistory 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->aCcFiles !== null && $this->file_id !== $this->aCcFiles->getDbId()) { + $this->aCcFiles = null; + } + if ($this->aCcShowInstances !== null && $this->instance_id !== $this->aCcShowInstances->getDbId()) { + $this->aCcShowInstances = 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(CcPlayoutHistoryPeer::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 = CcPlayoutHistoryPeer::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->aCcShowInstances = null; + $this->collCcPlayoutHistoryMetaDatas = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcPlayoutHistoryQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcPlayoutHistoryPeer::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); + CcPlayoutHistoryPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding 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->aCcShowInstances !== null) { + if ($this->aCcShowInstances->isModified() || $this->aCcShowInstances->isNew()) { + $affectedRows += $this->aCcShowInstances->save($con); + } + $this->setCcShowInstances($this->aCcShowInstances); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->ccPlayoutHistoryMetaDatasScheduledForDeletion !== null) { + if (!$this->ccPlayoutHistoryMetaDatasScheduledForDeletion->isEmpty()) { + CcPlayoutHistoryMetaDataQuery::create() + ->filterByPrimaryKeys($this->ccPlayoutHistoryMetaDatasScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccPlayoutHistoryMetaDatasScheduledForDeletion = null; + } + } + + if ($this->collCcPlayoutHistoryMetaDatas !== null) { + foreach ($this->collCcPlayoutHistoryMetaDatas as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcPlayoutHistoryPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcPlayoutHistoryPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_playout_history_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcPlayoutHistoryPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcPlayoutHistoryPeer::FILE_ID)) { + $modifiedColumns[':p' . $index++] = '"file_id"'; + } + if ($this->isColumnModified(CcPlayoutHistoryPeer::STARTS)) { + $modifiedColumns[':p' . $index++] = '"starts"'; + } + if ($this->isColumnModified(CcPlayoutHistoryPeer::ENDS)) { + $modifiedColumns[':p' . $index++] = '"ends"'; + } + if ($this->isColumnModified(CcPlayoutHistoryPeer::INSTANCE_ID)) { + $modifiedColumns[':p' . $index++] = '"instance_id"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_playout_history" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"file_id"': + $stmt->bindValue($identifier, $this->file_id, PDO::PARAM_INT); + break; + case '"starts"': + $stmt->bindValue($identifier, $this->starts, PDO::PARAM_STR); + break; + case '"ends"': + $stmt->bindValue($identifier, $this->ends, PDO::PARAM_STR); + break; + case '"instance_id"': + $stmt->bindValue($identifier, $this->instance_id, PDO::PARAM_INT); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding 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->aCcShowInstances !== null) { + if (!$this->aCcShowInstances->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcShowInstances->getValidationFailures()); + } + } + + + if (($retval = CcPlayoutHistoryPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collCcPlayoutHistoryMetaDatas !== null) { + foreach ($this->collCcPlayoutHistoryMetaDatas 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcPlayoutHistoryPeer::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->getDbFileId(); + break; + case 2: + return $this->getDbStarts(); + break; + case 3: + return $this->getDbEnds(); + break; + case 4: + return $this->getDbInstanceId(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcPlayoutHistory'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcPlayoutHistory'][$this->getPrimaryKey()] = true; + $keys = CcPlayoutHistoryPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbFileId(), + $keys[2] => $this->getDbStarts(), + $keys[3] => $this->getDbEnds(), + $keys[4] => $this->getDbInstanceId(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcFiles) { + $result['CcFiles'] = $this->aCcFiles->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aCcShowInstances) { + $result['CcShowInstances'] = $this->aCcShowInstances->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collCcPlayoutHistoryMetaDatas) { + $result['CcPlayoutHistoryMetaDatas'] = $this->collCcPlayoutHistoryMetaDatas->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcPlayoutHistoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbFileId($value); + break; + case 2: + $this->setDbStarts($value); + break; + case 3: + $this->setDbEnds($value); + break; + case 4: + $this->setDbInstanceId($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcPlayoutHistoryPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbFileId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbStarts($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbEnds($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbInstanceId($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(CcPlayoutHistoryPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcPlayoutHistoryPeer::ID)) $criteria->add(CcPlayoutHistoryPeer::ID, $this->id); + if ($this->isColumnModified(CcPlayoutHistoryPeer::FILE_ID)) $criteria->add(CcPlayoutHistoryPeer::FILE_ID, $this->file_id); + if ($this->isColumnModified(CcPlayoutHistoryPeer::STARTS)) $criteria->add(CcPlayoutHistoryPeer::STARTS, $this->starts); + if ($this->isColumnModified(CcPlayoutHistoryPeer::ENDS)) $criteria->add(CcPlayoutHistoryPeer::ENDS, $this->ends); + if ($this->isColumnModified(CcPlayoutHistoryPeer::INSTANCE_ID)) $criteria->add(CcPlayoutHistoryPeer::INSTANCE_ID, $this->instance_id); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(CcPlayoutHistoryPeer::DATABASE_NAME); + $criteria->add(CcPlayoutHistoryPeer::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 CcPlayoutHistory (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbFileId($this->getDbFileId()); + $copyObj->setDbStarts($this->getDbStarts()); + $copyObj->setDbEnds($this->getDbEnds()); + $copyObj->setDbInstanceId($this->getDbInstanceId()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + foreach ($this->getCcPlayoutHistoryMetaDatas() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcPlayoutHistoryMetaData($relObj->copy($deepCopy)); + } + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcPlayoutHistory 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 CcPlayoutHistoryPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcPlayoutHistoryPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a CcFiles object. + * + * @param CcFiles $v + * @return CcPlayoutHistory 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->addCcPlayoutHistory($this); + } + + + return $this; + } + + + /** + * Get the associated CcFiles object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcFiles The associated CcFiles object. + * @throws PropelException + */ + public function getCcFiles(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcFiles === null && ($this->file_id !== null) && $doQuery) { + $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->addCcPlayoutHistorys($this); + */ + } + + return $this->aCcFiles; + } + + /** + * Declares an association between this object and a CcShowInstances object. + * + * @param CcShowInstances $v + * @return CcPlayoutHistory The current object (for fluent API support) + * @throws PropelException + */ + public function setCcShowInstances(CcShowInstances $v = null) + { + if ($v === null) { + $this->setDbInstanceId(NULL); + } else { + $this->setDbInstanceId($v->getDbId()); + } + + $this->aCcShowInstances = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcShowInstances object, it will not be re-added. + if ($v !== null) { + $v->addCcPlayoutHistory($this); + } + + + return $this; + } + + + /** + * Get the associated CcShowInstances object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcShowInstances The associated CcShowInstances object. + * @throws PropelException + */ + public function getCcShowInstances(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcShowInstances === null && ($this->instance_id !== null) && $doQuery) { + $this->aCcShowInstances = CcShowInstancesQuery::create()->findPk($this->instance_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->aCcShowInstances->addCcPlayoutHistorys($this); + */ + } + + return $this->aCcShowInstances; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('CcPlayoutHistoryMetaData' == $relationName) { + $this->initCcPlayoutHistoryMetaDatas(); + } + } + + /** + * Clears out the collCcPlayoutHistoryMetaDatas 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 CcPlayoutHistory The current object (for fluent API support) + * @see addCcPlayoutHistoryMetaDatas() + */ + public function clearCcPlayoutHistoryMetaDatas() + { + $this->collCcPlayoutHistoryMetaDatas = null; // important to set this to null since that means it is uninitialized + $this->collCcPlayoutHistoryMetaDatasPartial = null; + + return $this; + } + + /** + * reset is the collCcPlayoutHistoryMetaDatas collection loaded partially + * + * @return void + */ + public function resetPartialCcPlayoutHistoryMetaDatas($v = true) + { + $this->collCcPlayoutHistoryMetaDatasPartial = $v; + } + + /** + * Initializes the collCcPlayoutHistoryMetaDatas collection. + * + * By default this just sets the collCcPlayoutHistoryMetaDatas collection to an empty array (like clearcollCcPlayoutHistoryMetaDatas()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcPlayoutHistoryMetaDatas($overrideExisting = true) + { + if (null !== $this->collCcPlayoutHistoryMetaDatas && !$overrideExisting) { + return; + } + $this->collCcPlayoutHistoryMetaDatas = new PropelObjectCollection(); + $this->collCcPlayoutHistoryMetaDatas->setModel('CcPlayoutHistoryMetaData'); + } + + /** + * Gets an array of CcPlayoutHistoryMetaData 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 CcPlayoutHistory 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 PropelObjectCollection|CcPlayoutHistoryMetaData[] List of CcPlayoutHistoryMetaData objects + * @throws PropelException + */ + public function getCcPlayoutHistoryMetaDatas($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcPlayoutHistoryMetaDatasPartial && !$this->isNew(); + if (null === $this->collCcPlayoutHistoryMetaDatas || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPlayoutHistoryMetaDatas) { + // return empty collection + $this->initCcPlayoutHistoryMetaDatas(); + } else { + $collCcPlayoutHistoryMetaDatas = CcPlayoutHistoryMetaDataQuery::create(null, $criteria) + ->filterByCcPlayoutHistory($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcPlayoutHistoryMetaDatasPartial && count($collCcPlayoutHistoryMetaDatas)) { + $this->initCcPlayoutHistoryMetaDatas(false); + + foreach ($collCcPlayoutHistoryMetaDatas as $obj) { + if (false == $this->collCcPlayoutHistoryMetaDatas->contains($obj)) { + $this->collCcPlayoutHistoryMetaDatas->append($obj); + } + } + + $this->collCcPlayoutHistoryMetaDatasPartial = true; + } + + $collCcPlayoutHistoryMetaDatas->getInternalIterator()->rewind(); + + return $collCcPlayoutHistoryMetaDatas; + } + + if ($partial && $this->collCcPlayoutHistoryMetaDatas) { + foreach ($this->collCcPlayoutHistoryMetaDatas as $obj) { + if ($obj->isNew()) { + $collCcPlayoutHistoryMetaDatas[] = $obj; + } + } + } + + $this->collCcPlayoutHistoryMetaDatas = $collCcPlayoutHistoryMetaDatas; + $this->collCcPlayoutHistoryMetaDatasPartial = false; + } + } + + return $this->collCcPlayoutHistoryMetaDatas; + } + + /** + * Sets a collection of CcPlayoutHistoryMetaData objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccPlayoutHistoryMetaDatas A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcPlayoutHistory The current object (for fluent API support) + */ + public function setCcPlayoutHistoryMetaDatas(PropelCollection $ccPlayoutHistoryMetaDatas, PropelPDO $con = null) + { + $ccPlayoutHistoryMetaDatasToDelete = $this->getCcPlayoutHistoryMetaDatas(new Criteria(), $con)->diff($ccPlayoutHistoryMetaDatas); + + + $this->ccPlayoutHistoryMetaDatasScheduledForDeletion = $ccPlayoutHistoryMetaDatasToDelete; + + foreach ($ccPlayoutHistoryMetaDatasToDelete as $ccPlayoutHistoryMetaDataRemoved) { + $ccPlayoutHistoryMetaDataRemoved->setCcPlayoutHistory(null); + } + + $this->collCcPlayoutHistoryMetaDatas = null; + foreach ($ccPlayoutHistoryMetaDatas as $ccPlayoutHistoryMetaData) { + $this->addCcPlayoutHistoryMetaData($ccPlayoutHistoryMetaData); + } + + $this->collCcPlayoutHistoryMetaDatas = $ccPlayoutHistoryMetaDatas; + $this->collCcPlayoutHistoryMetaDatasPartial = false; + + return $this; + } + + /** + * Returns the number of related CcPlayoutHistoryMetaData objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcPlayoutHistoryMetaData objects. + * @throws PropelException + */ + public function countCcPlayoutHistoryMetaDatas(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcPlayoutHistoryMetaDatasPartial && !$this->isNew(); + if (null === $this->collCcPlayoutHistoryMetaDatas || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPlayoutHistoryMetaDatas) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcPlayoutHistoryMetaDatas()); + } + $query = CcPlayoutHistoryMetaDataQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcPlayoutHistory($this) + ->count($con); + } + + return count($this->collCcPlayoutHistoryMetaDatas); + } + + /** + * Method called to associate a CcPlayoutHistoryMetaData object to this object + * through the CcPlayoutHistoryMetaData foreign key attribute. + * + * @param CcPlayoutHistoryMetaData $l CcPlayoutHistoryMetaData + * @return CcPlayoutHistory The current object (for fluent API support) + */ + public function addCcPlayoutHistoryMetaData(CcPlayoutHistoryMetaData $l) + { + if ($this->collCcPlayoutHistoryMetaDatas === null) { + $this->initCcPlayoutHistoryMetaDatas(); + $this->collCcPlayoutHistoryMetaDatasPartial = true; + } + + if (!in_array($l, $this->collCcPlayoutHistoryMetaDatas->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcPlayoutHistoryMetaData($l); + + if ($this->ccPlayoutHistoryMetaDatasScheduledForDeletion and $this->ccPlayoutHistoryMetaDatasScheduledForDeletion->contains($l)) { + $this->ccPlayoutHistoryMetaDatasScheduledForDeletion->remove($this->ccPlayoutHistoryMetaDatasScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcPlayoutHistoryMetaData $ccPlayoutHistoryMetaData The ccPlayoutHistoryMetaData object to add. + */ + protected function doAddCcPlayoutHistoryMetaData($ccPlayoutHistoryMetaData) + { + $this->collCcPlayoutHistoryMetaDatas[]= $ccPlayoutHistoryMetaData; + $ccPlayoutHistoryMetaData->setCcPlayoutHistory($this); + } + + /** + * @param CcPlayoutHistoryMetaData $ccPlayoutHistoryMetaData The ccPlayoutHistoryMetaData object to remove. + * @return CcPlayoutHistory The current object (for fluent API support) + */ + public function removeCcPlayoutHistoryMetaData($ccPlayoutHistoryMetaData) + { + if ($this->getCcPlayoutHistoryMetaDatas()->contains($ccPlayoutHistoryMetaData)) { + $this->collCcPlayoutHistoryMetaDatas->remove($this->collCcPlayoutHistoryMetaDatas->search($ccPlayoutHistoryMetaData)); + if (null === $this->ccPlayoutHistoryMetaDatasScheduledForDeletion) { + $this->ccPlayoutHistoryMetaDatasScheduledForDeletion = clone $this->collCcPlayoutHistoryMetaDatas; + $this->ccPlayoutHistoryMetaDatasScheduledForDeletion->clear(); + } + $this->ccPlayoutHistoryMetaDatasScheduledForDeletion[]= clone $ccPlayoutHistoryMetaData; + $ccPlayoutHistoryMetaData->setCcPlayoutHistory(null); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->file_id = null; + $this->starts = null; + $this->ends = null; + $this->instance_id = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->collCcPlayoutHistoryMetaDatas) { + foreach ($this->collCcPlayoutHistoryMetaDatas as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->aCcFiles instanceof Persistent) { + $this->aCcFiles->clearAllReferences($deep); + } + if ($this->aCcShowInstances instanceof Persistent) { + $this->aCcShowInstances->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + if ($this->collCcPlayoutHistoryMetaDatas instanceof PropelCollection) { + $this->collCcPlayoutHistoryMetaDatas->clearIterator(); + } + $this->collCcPlayoutHistoryMetaDatas = null; + $this->aCcFiles = null; + $this->aCcShowInstances = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcPlayoutHistoryPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryMetaData.php b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryMetaData.php index a0cbb9539..ae886ca23 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryMetaData.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryMetaData.php @@ -1,905 +1,1067 @@ id; - } - - /** - * Get the [history_id] column value. - * - * @return int - */ - public function getDbHistoryId() - { - return $this->history_id; - } - - /** - * Get the [key] column value. - * - * @return string - */ - public function getDbKey() - { - return $this->key; - } - - /** - * Get the [value] column value. - * - * @return string - */ - public function getDbValue() - { - return $this->value; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcPlayoutHistoryMetaData 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[] = CcPlayoutHistoryMetaDataPeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [history_id] column. - * - * @param int $v new value - * @return CcPlayoutHistoryMetaData The current object (for fluent API support) - */ - public function setDbHistoryId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->history_id !== $v) { - $this->history_id = $v; - $this->modifiedColumns[] = CcPlayoutHistoryMetaDataPeer::HISTORY_ID; - } - - if ($this->aCcPlayoutHistory !== null && $this->aCcPlayoutHistory->getDbId() !== $v) { - $this->aCcPlayoutHistory = null; - } - - return $this; - } // setDbHistoryId() - - /** - * Set the value of [key] column. - * - * @param string $v new value - * @return CcPlayoutHistoryMetaData The current object (for fluent API support) - */ - public function setDbKey($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->key !== $v) { - $this->key = $v; - $this->modifiedColumns[] = CcPlayoutHistoryMetaDataPeer::KEY; - } - - return $this; - } // setDbKey() - - /** - * Set the value of [value] column. - * - * @param string $v new value - * @return CcPlayoutHistoryMetaData The current object (for fluent API support) - */ - public function setDbValue($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->value !== $v) { - $this->value = $v; - $this->modifiedColumns[] = CcPlayoutHistoryMetaDataPeer::VALUE; - } - - return $this; - } // setDbValue() - - /** - * 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->history_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->key = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->value = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 4; // 4 = CcPlayoutHistoryMetaDataPeer::NUM_COLUMNS - CcPlayoutHistoryMetaDataPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcPlayoutHistoryMetaData 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->aCcPlayoutHistory !== null && $this->history_id !== $this->aCcPlayoutHistory->getDbId()) { - $this->aCcPlayoutHistory = 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(CcPlayoutHistoryMetaDataPeer::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 = CcPlayoutHistoryMetaDataPeer::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->aCcPlayoutHistory = 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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcPlayoutHistoryMetaDataQuery::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(CcPlayoutHistoryMetaDataPeer::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); - CcPlayoutHistoryMetaDataPeer::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->aCcPlayoutHistory !== null) { - if ($this->aCcPlayoutHistory->isModified() || $this->aCcPlayoutHistory->isNew()) { - $affectedRows += $this->aCcPlayoutHistory->save($con); - } - $this->setCcPlayoutHistory($this->aCcPlayoutHistory); - } - - if ($this->isNew() ) { - $this->modifiedColumns[] = CcPlayoutHistoryMetaDataPeer::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(CcPlayoutHistoryMetaDataPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlayoutHistoryMetaDataPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows += 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows += CcPlayoutHistoryMetaDataPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcPlayoutHistory !== null) { - if (!$this->aCcPlayoutHistory->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcPlayoutHistory->getValidationFailures()); - } - } - - - if (($retval = CcPlayoutHistoryMetaDataPeer::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 = CcPlayoutHistoryMetaDataPeer::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->getDbHistoryId(); - break; - case 2: - return $this->getDbKey(); - break; - case 3: - return $this->getDbValue(); - 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 = CcPlayoutHistoryMetaDataPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbHistoryId(), - $keys[2] => $this->getDbKey(), - $keys[3] => $this->getDbValue(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCcPlayoutHistory) { - $result['CcPlayoutHistory'] = $this->aCcPlayoutHistory->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 = CcPlayoutHistoryMetaDataPeer::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->setDbHistoryId($value); - break; - case 2: - $this->setDbKey($value); - break; - case 3: - $this->setDbValue($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 = CcPlayoutHistoryMetaDataPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbHistoryId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbKey($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbValue($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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcPlayoutHistoryMetaDataPeer::ID)) $criteria->add(CcPlayoutHistoryMetaDataPeer::ID, $this->id); - if ($this->isColumnModified(CcPlayoutHistoryMetaDataPeer::HISTORY_ID)) $criteria->add(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, $this->history_id); - if ($this->isColumnModified(CcPlayoutHistoryMetaDataPeer::KEY)) $criteria->add(CcPlayoutHistoryMetaDataPeer::KEY, $this->key); - if ($this->isColumnModified(CcPlayoutHistoryMetaDataPeer::VALUE)) $criteria->add(CcPlayoutHistoryMetaDataPeer::VALUE, $this->value); - - 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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); - $criteria->add(CcPlayoutHistoryMetaDataPeer::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 CcPlayoutHistoryMetaData (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->setDbHistoryId($this->history_id); - $copyObj->setDbKey($this->key); - $copyObj->setDbValue($this->value); - - $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 CcPlayoutHistoryMetaData 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 CcPlayoutHistoryMetaDataPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcPlayoutHistoryMetaDataPeer(); - } - return self::$peer; - } - - /** - * Declares an association between this object and a CcPlayoutHistory object. - * - * @param CcPlayoutHistory $v - * @return CcPlayoutHistoryMetaData The current object (for fluent API support) - * @throws PropelException - */ - public function setCcPlayoutHistory(CcPlayoutHistory $v = null) - { - if ($v === null) { - $this->setDbHistoryId(NULL); - } else { - $this->setDbHistoryId($v->getDbId()); - } - - $this->aCcPlayoutHistory = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcPlayoutHistory object, it will not be re-added. - if ($v !== null) { - $v->addCcPlayoutHistoryMetaData($this); - } - - return $this; - } - - - /** - * Get the associated CcPlayoutHistory object - * - * @param PropelPDO Optional Connection object. - * @return CcPlayoutHistory The associated CcPlayoutHistory object. - * @throws PropelException - */ - public function getCcPlayoutHistory(PropelPDO $con = null) - { - if ($this->aCcPlayoutHistory === null && ($this->history_id !== null)) { - $this->aCcPlayoutHistory = CcPlayoutHistoryQuery::create()->findPk($this->history_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->aCcPlayoutHistory->addCcPlayoutHistoryMetaDatas($this); - */ - } - return $this->aCcPlayoutHistory; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->history_id = null; - $this->key = null; - $this->value = 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->aCcPlayoutHistory = 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); - } - -} // BaseCcPlayoutHistoryMetaData + /** + * Peer class name + */ + const PEER = 'Airtime\\PlayoutHistory\\CcPlayoutHistoryMetaDataPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcPlayoutHistoryMetaDataPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the history_id field. + * @var int + */ + protected $history_id; + + /** + * The value for the key field. + * @var string + */ + protected $key; + + /** + * The value for the value field. + * @var string + */ + protected $value; + + /** + * @var CcPlayoutHistory + */ + protected $aCcPlayoutHistory; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * Get the [id] column value. + * + * @return int + */ + public function getDbId() + { + + return $this->id; + } + + /** + * Get the [history_id] column value. + * + * @return int + */ + public function getDbHistoryId() + { + + return $this->history_id; + } + + /** + * Get the [key] column value. + * + * @return string + */ + public function getDbKey() + { + + return $this->key; + } + + /** + * Get the [value] column value. + * + * @return string + */ + public function getDbValue() + { + + return $this->value; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcPlayoutHistoryMetaData The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcPlayoutHistoryMetaDataPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [history_id] column. + * + * @param int $v new value + * @return CcPlayoutHistoryMetaData The current object (for fluent API support) + */ + public function setDbHistoryId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->history_id !== $v) { + $this->history_id = $v; + $this->modifiedColumns[] = CcPlayoutHistoryMetaDataPeer::HISTORY_ID; + } + + if ($this->aCcPlayoutHistory !== null && $this->aCcPlayoutHistory->getDbId() !== $v) { + $this->aCcPlayoutHistory = null; + } + + + return $this; + } // setDbHistoryId() + + /** + * Set the value of [key] column. + * + * @param string $v new value + * @return CcPlayoutHistoryMetaData The current object (for fluent API support) + */ + public function setDbKey($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->key !== $v) { + $this->key = $v; + $this->modifiedColumns[] = CcPlayoutHistoryMetaDataPeer::KEY; + } + + + return $this; + } // setDbKey() + + /** + * Set the value of [value] column. + * + * @param string $v new value + * @return CcPlayoutHistoryMetaData The current object (for fluent API support) + */ + public function setDbValue($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->value !== $v) { + $this->value = $v; + $this->modifiedColumns[] = CcPlayoutHistoryMetaDataPeer::VALUE; + } + + + return $this; + } // setDbValue() + + /** + * 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 resultset 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->history_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->key = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->value = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 4; // 4 = CcPlayoutHistoryMetaDataPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcPlayoutHistoryMetaData 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->aCcPlayoutHistory !== null && $this->history_id !== $this->aCcPlayoutHistory->getDbId()) { + $this->aCcPlayoutHistory = 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(CcPlayoutHistoryMetaDataPeer::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 = CcPlayoutHistoryMetaDataPeer::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->aCcPlayoutHistory = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcPlayoutHistoryMetaDataQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcPlayoutHistoryMetaDataPeer::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); + CcPlayoutHistoryMetaDataPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcPlayoutHistory !== null) { + if ($this->aCcPlayoutHistory->isModified() || $this->aCcPlayoutHistory->isNew()) { + $affectedRows += $this->aCcPlayoutHistory->save($con); + } + $this->setCcPlayoutHistory($this->aCcPlayoutHistory); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcPlayoutHistoryMetaDataPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcPlayoutHistoryMetaDataPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_playout_history_metadata_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcPlayoutHistoryMetaDataPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcPlayoutHistoryMetaDataPeer::HISTORY_ID)) { + $modifiedColumns[':p' . $index++] = '"history_id"'; + } + if ($this->isColumnModified(CcPlayoutHistoryMetaDataPeer::KEY)) { + $modifiedColumns[':p' . $index++] = '"key"'; + } + if ($this->isColumnModified(CcPlayoutHistoryMetaDataPeer::VALUE)) { + $modifiedColumns[':p' . $index++] = '"value"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_playout_history_metadata" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"history_id"': + $stmt->bindValue($identifier, $this->history_id, PDO::PARAM_INT); + break; + case '"key"': + $stmt->bindValue($identifier, $this->key, PDO::PARAM_STR); + break; + case '"value"': + $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcPlayoutHistory !== null) { + if (!$this->aCcPlayoutHistory->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcPlayoutHistory->getValidationFailures()); + } + } + + + if (($retval = CcPlayoutHistoryMetaDataPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcPlayoutHistoryMetaDataPeer::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->getDbHistoryId(); + break; + case 2: + return $this->getDbKey(); + break; + case 3: + return $this->getDbValue(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcPlayoutHistoryMetaData'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcPlayoutHistoryMetaData'][$this->getPrimaryKey()] = true; + $keys = CcPlayoutHistoryMetaDataPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbHistoryId(), + $keys[2] => $this->getDbKey(), + $keys[3] => $this->getDbValue(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcPlayoutHistory) { + $result['CcPlayoutHistory'] = $this->aCcPlayoutHistory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcPlayoutHistoryMetaDataPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbHistoryId($value); + break; + case 2: + $this->setDbKey($value); + break; + case 3: + $this->setDbValue($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcPlayoutHistoryMetaDataPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbHistoryId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbKey($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbValue($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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcPlayoutHistoryMetaDataPeer::ID)) $criteria->add(CcPlayoutHistoryMetaDataPeer::ID, $this->id); + if ($this->isColumnModified(CcPlayoutHistoryMetaDataPeer::HISTORY_ID)) $criteria->add(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, $this->history_id); + if ($this->isColumnModified(CcPlayoutHistoryMetaDataPeer::KEY)) $criteria->add(CcPlayoutHistoryMetaDataPeer::KEY, $this->key); + if ($this->isColumnModified(CcPlayoutHistoryMetaDataPeer::VALUE)) $criteria->add(CcPlayoutHistoryMetaDataPeer::VALUE, $this->value); + + 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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); + $criteria->add(CcPlayoutHistoryMetaDataPeer::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 CcPlayoutHistoryMetaData (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbHistoryId($this->getDbHistoryId()); + $copyObj->setDbKey($this->getDbKey()); + $copyObj->setDbValue($this->getDbValue()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcPlayoutHistoryMetaData 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 CcPlayoutHistoryMetaDataPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcPlayoutHistoryMetaDataPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a CcPlayoutHistory object. + * + * @param CcPlayoutHistory $v + * @return CcPlayoutHistoryMetaData The current object (for fluent API support) + * @throws PropelException + */ + public function setCcPlayoutHistory(CcPlayoutHistory $v = null) + { + if ($v === null) { + $this->setDbHistoryId(NULL); + } else { + $this->setDbHistoryId($v->getDbId()); + } + + $this->aCcPlayoutHistory = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcPlayoutHistory object, it will not be re-added. + if ($v !== null) { + $v->addCcPlayoutHistoryMetaData($this); + } + + + return $this; + } + + + /** + * Get the associated CcPlayoutHistory object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcPlayoutHistory The associated CcPlayoutHistory object. + * @throws PropelException + */ + public function getCcPlayoutHistory(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcPlayoutHistory === null && ($this->history_id !== null) && $doQuery) { + $this->aCcPlayoutHistory = CcPlayoutHistoryQuery::create()->findPk($this->history_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->aCcPlayoutHistory->addCcPlayoutHistoryMetaDatas($this); + */ + } + + return $this->aCcPlayoutHistory; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->history_id = null; + $this->key = null; + $this->value = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCcPlayoutHistory instanceof Persistent) { + $this->aCcPlayoutHistory->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + $this->aCcPlayoutHistory = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcPlayoutHistoryMetaDataPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryMetaDataPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryMetaDataPeer.php index 0b980ec4e..8c12fa9c6 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryMetaDataPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryMetaDataPeer.php @@ -1,979 +1,1018 @@ array ('DbId', 'DbHistoryId', 'DbKey', 'DbValue', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbHistoryId', 'dbKey', 'dbValue', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::HISTORY_ID, self::KEY, self::VALUE, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'HISTORY_ID', 'KEY', 'VALUE', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'history_id', 'key', 'value', ), - 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 ('DbId' => 0, 'DbHistoryId' => 1, 'DbKey' => 2, 'DbValue' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbHistoryId' => 1, 'dbKey' => 2, 'dbValue' => 3, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::HISTORY_ID => 1, self::KEY => 2, self::VALUE => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'HISTORY_ID' => 1, 'KEY' => 2, 'VALUE' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'history_id' => 1, 'key' => 2, 'value' => 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. CcPlayoutHistoryMetaDataPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcPlayoutHistoryMetaDataPeer::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(CcPlayoutHistoryMetaDataPeer::ID); - $criteria->addSelectColumn(CcPlayoutHistoryMetaDataPeer::HISTORY_ID); - $criteria->addSelectColumn(CcPlayoutHistoryMetaDataPeer::KEY); - $criteria->addSelectColumn(CcPlayoutHistoryMetaDataPeer::VALUE); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.HISTORY_ID'); - $criteria->addSelectColumn($alias . '.KEY'); - $criteria->addSelectColumn($alias . '.VALUE'); - } - } - - /** - * 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(CcPlayoutHistoryMetaDataPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcPlayoutHistoryMetaDataPeer::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(CcPlayoutHistoryMetaDataPeer::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 CcPlayoutHistoryMetaData - * @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 = CcPlayoutHistoryMetaDataPeer::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 CcPlayoutHistoryMetaDataPeer::populateObjects(CcPlayoutHistoryMetaDataPeer::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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcPlayoutHistoryMetaDataPeer::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 CcPlayoutHistoryMetaData $value A CcPlayoutHistoryMetaData object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcPlayoutHistoryMetaData $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 CcPlayoutHistoryMetaData object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcPlayoutHistoryMetaData) { - $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 CcPlayoutHistoryMetaData 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 CcPlayoutHistoryMetaData 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_playout_history_metadata - * 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 = CcPlayoutHistoryMetaDataPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcPlayoutHistoryMetaDataPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcPlayoutHistoryMetaDataPeer::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; - CcPlayoutHistoryMetaDataPeer::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 (CcPlayoutHistoryMetaData object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcPlayoutHistoryMetaDataPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcPlayoutHistoryMetaDataPeer::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 + CcPlayoutHistoryMetaDataPeer::NUM_COLUMNS; - } else { - $cls = CcPlayoutHistoryMetaDataPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcPlayoutHistoryMetaDataPeer::addInstanceToPool($obj, $key); - } - return array($obj, $col); - } - - /** - * Returns the number of rows matching criteria, joining the related CcPlayoutHistory 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 doCountJoinCcPlayoutHistory(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(CcPlayoutHistoryMetaDataPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcPlayoutHistoryMetaDataPeer::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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, CcPlayoutHistoryPeer::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 CcPlayoutHistoryMetaData objects pre-filled with their CcPlayoutHistory 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 CcPlayoutHistoryMetaData objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCcPlayoutHistory(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); - } - - CcPlayoutHistoryMetaDataPeer::addSelectColumns($criteria); - $startcol = (CcPlayoutHistoryMetaDataPeer::NUM_COLUMNS - CcPlayoutHistoryMetaDataPeer::NUM_LAZY_LOAD_COLUMNS); - CcPlayoutHistoryPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, CcPlayoutHistoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcPlayoutHistoryMetaDataPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcPlayoutHistoryMetaDataPeer::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 = CcPlayoutHistoryMetaDataPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcPlayoutHistoryMetaDataPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcPlayoutHistoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcPlayoutHistoryPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcPlayoutHistoryPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcPlayoutHistoryMetaData) to $obj2 (CcPlayoutHistory) - $obj2->addCcPlayoutHistoryMetaData($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(CcPlayoutHistoryMetaDataPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcPlayoutHistoryMetaDataPeer::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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, CcPlayoutHistoryPeer::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 CcPlayoutHistoryMetaData 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 CcPlayoutHistoryMetaData 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); - } - - CcPlayoutHistoryMetaDataPeer::addSelectColumns($criteria); - $startcol2 = (CcPlayoutHistoryMetaDataPeer::NUM_COLUMNS - CcPlayoutHistoryMetaDataPeer::NUM_LAZY_LOAD_COLUMNS); - - CcPlayoutHistoryPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcPlayoutHistoryPeer::NUM_COLUMNS - CcPlayoutHistoryPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, CcPlayoutHistoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcPlayoutHistoryMetaDataPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcPlayoutHistoryMetaDataPeer::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 = CcPlayoutHistoryMetaDataPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcPlayoutHistoryMetaDataPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcPlayoutHistory rows - - $key2 = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcPlayoutHistoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcPlayoutHistoryPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcPlayoutHistoryPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (CcPlayoutHistoryMetaData) to the collection in $obj2 (CcPlayoutHistory) - $obj2->addCcPlayoutHistoryMetaData($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(BaseCcPlayoutHistoryMetaDataPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcPlayoutHistoryMetaDataPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcPlayoutHistoryMetaDataTableMap()); - } - } - - /** - * 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 ? CcPlayoutHistoryMetaDataPeer::CLASS_DEFAULT : CcPlayoutHistoryMetaDataPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcPlayoutHistoryMetaData or Criteria object. - * - * @param mixed $values Criteria or CcPlayoutHistoryMetaData 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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcPlayoutHistoryMetaData object - } - - if ($criteria->containsKey(CcPlayoutHistoryMetaDataPeer::ID) && $criteria->keyContainsValue(CcPlayoutHistoryMetaDataPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlayoutHistoryMetaDataPeer::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 CcPlayoutHistoryMetaData or Criteria object. - * - * @param mixed $values Criteria or CcPlayoutHistoryMetaData 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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcPlayoutHistoryMetaDataPeer::ID); - $value = $criteria->remove(CcPlayoutHistoryMetaDataPeer::ID); - if ($value) { - $selectCriteria->add(CcPlayoutHistoryMetaDataPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcPlayoutHistoryMetaDataPeer::TABLE_NAME); - } - - } else { // $values is CcPlayoutHistoryMetaData 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_playout_history_metadata 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(CcPlayoutHistoryMetaDataPeer::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(CcPlayoutHistoryMetaDataPeer::TABLE_NAME, $con, CcPlayoutHistoryMetaDataPeer::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). - CcPlayoutHistoryMetaDataPeer::clearInstancePool(); - CcPlayoutHistoryMetaDataPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcPlayoutHistoryMetaData or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcPlayoutHistoryMetaData 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(CcPlayoutHistoryMetaDataPeer::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. - CcPlayoutHistoryMetaDataPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcPlayoutHistoryMetaData) { // it's a model object - // invalidate the cache for this single object - CcPlayoutHistoryMetaDataPeer::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(CcPlayoutHistoryMetaDataPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcPlayoutHistoryMetaDataPeer::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); - CcPlayoutHistoryMetaDataPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcPlayoutHistoryMetaData 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 CcPlayoutHistoryMetaData $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(CcPlayoutHistoryMetaData $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcPlayoutHistoryMetaDataPeer::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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, CcPlayoutHistoryMetaDataPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcPlayoutHistoryMetaData - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcPlayoutHistoryMetaDataPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); - $criteria->add(CcPlayoutHistoryMetaDataPeer::ID, $pk); - - $v = CcPlayoutHistoryMetaDataPeer::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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); - $criteria->add(CcPlayoutHistoryMetaDataPeer::ID, $pks, Criteria::IN); - $objs = CcPlayoutHistoryMetaDataPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcPlayoutHistoryMetaDataPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_playout_history_metadata'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\PlayoutHistory\\CcPlayoutHistoryMetaData'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\PlayoutHistory\\map\\CcPlayoutHistoryMetaDataTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 4; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 4; + + /** the column name for the id field */ + const ID = 'cc_playout_history_metadata.id'; + + /** the column name for the history_id field */ + const HISTORY_ID = 'cc_playout_history_metadata.history_id'; + + /** the column name for the key field */ + const KEY = 'cc_playout_history_metadata.key'; + + /** the column name for the value field */ + const VALUE = 'cc_playout_history_metadata.value'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcPlayoutHistoryMetaData objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcPlayoutHistoryMetaData[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcPlayoutHistoryMetaDataPeer::$fieldNames[CcPlayoutHistoryMetaDataPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbHistoryId', 'DbKey', 'DbValue', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbHistoryId', 'dbKey', 'dbValue', ), + BasePeer::TYPE_COLNAME => array (CcPlayoutHistoryMetaDataPeer::ID, CcPlayoutHistoryMetaDataPeer::HISTORY_ID, CcPlayoutHistoryMetaDataPeer::KEY, CcPlayoutHistoryMetaDataPeer::VALUE, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'HISTORY_ID', 'KEY', 'VALUE', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'history_id', 'key', 'value', ), + 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. CcPlayoutHistoryMetaDataPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbHistoryId' => 1, 'DbKey' => 2, 'DbValue' => 3, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbHistoryId' => 1, 'dbKey' => 2, 'dbValue' => 3, ), + BasePeer::TYPE_COLNAME => array (CcPlayoutHistoryMetaDataPeer::ID => 0, CcPlayoutHistoryMetaDataPeer::HISTORY_ID => 1, CcPlayoutHistoryMetaDataPeer::KEY => 2, CcPlayoutHistoryMetaDataPeer::VALUE => 3, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'HISTORY_ID' => 1, 'KEY' => 2, 'VALUE' => 3, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'history_id' => 1, 'key' => 2, 'value' => 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcPlayoutHistoryMetaDataPeer::getFieldNames($toType); + $key = isset(CcPlayoutHistoryMetaDataPeer::$fieldKeys[$fromType][$name]) ? CcPlayoutHistoryMetaDataPeer::$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(CcPlayoutHistoryMetaDataPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcPlayoutHistoryMetaDataPeer::$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 CcPlayoutHistoryMetaDataPeer::$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. CcPlayoutHistoryMetaDataPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcPlayoutHistoryMetaDataPeer::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(CcPlayoutHistoryMetaDataPeer::ID); + $criteria->addSelectColumn(CcPlayoutHistoryMetaDataPeer::HISTORY_ID); + $criteria->addSelectColumn(CcPlayoutHistoryMetaDataPeer::KEY); + $criteria->addSelectColumn(CcPlayoutHistoryMetaDataPeer::VALUE); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.history_id'); + $criteria->addSelectColumn($alias . '.key'); + $criteria->addSelectColumn($alias . '.value'); + } + } + + /** + * 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(CcPlayoutHistoryMetaDataPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlayoutHistoryMetaDataPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryMetaDataPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcPlayoutHistoryMetaData + * @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 = CcPlayoutHistoryMetaDataPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcPlayoutHistoryMetaDataPeer::populateObjects(CcPlayoutHistoryMetaDataPeer::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 directly (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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcPlayoutHistoryMetaDataPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryMetaDataPeer::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 CcPlayoutHistoryMetaData $obj A CcPlayoutHistoryMetaData object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcPlayoutHistoryMetaDataPeer::$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 CcPlayoutHistoryMetaData object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcPlayoutHistoryMetaData) { + $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 CcPlayoutHistoryMetaData object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcPlayoutHistoryMetaDataPeer::$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 CcPlayoutHistoryMetaData 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(CcPlayoutHistoryMetaDataPeer::$instances[$key])) { + return CcPlayoutHistoryMetaDataPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcPlayoutHistoryMetaDataPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcPlayoutHistoryMetaDataPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_playout_history_metadata + * 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 = CcPlayoutHistoryMetaDataPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcPlayoutHistoryMetaDataPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcPlayoutHistoryMetaDataPeer::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; + CcPlayoutHistoryMetaDataPeer::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 (CcPlayoutHistoryMetaData object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcPlayoutHistoryMetaDataPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcPlayoutHistoryMetaDataPeer::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 + CcPlayoutHistoryMetaDataPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcPlayoutHistoryMetaDataPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcPlayoutHistoryMetaDataPeer::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + + /** + * Returns the number of rows matching criteria, joining the related CcPlayoutHistory 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 doCountJoinCcPlayoutHistory(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(CcPlayoutHistoryMetaDataPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlayoutHistoryMetaDataPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, CcPlayoutHistoryPeer::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 CcPlayoutHistoryMetaData objects pre-filled with their CcPlayoutHistory 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 CcPlayoutHistoryMetaData objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcPlayoutHistory(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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); + } + + CcPlayoutHistoryMetaDataPeer::addSelectColumns($criteria); + $startcol = CcPlayoutHistoryMetaDataPeer::NUM_HYDRATE_COLUMNS; + CcPlayoutHistoryPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, CcPlayoutHistoryPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPlayoutHistoryMetaDataPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPlayoutHistoryMetaDataPeer::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 = CcPlayoutHistoryMetaDataPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlayoutHistoryMetaDataPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcPlayoutHistoryPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcPlayoutHistoryPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcPlayoutHistoryPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcPlayoutHistoryMetaData) to $obj2 (CcPlayoutHistory) + $obj2->addCcPlayoutHistoryMetaData($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(CcPlayoutHistoryMetaDataPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlayoutHistoryMetaDataPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, CcPlayoutHistoryPeer::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 CcPlayoutHistoryMetaData 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 CcPlayoutHistoryMetaData 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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); + } + + CcPlayoutHistoryMetaDataPeer::addSelectColumns($criteria); + $startcol2 = CcPlayoutHistoryMetaDataPeer::NUM_HYDRATE_COLUMNS; + + CcPlayoutHistoryPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcPlayoutHistoryPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, CcPlayoutHistoryPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPlayoutHistoryMetaDataPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPlayoutHistoryMetaDataPeer::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 = CcPlayoutHistoryMetaDataPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlayoutHistoryMetaDataPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcPlayoutHistory rows + + $key2 = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcPlayoutHistoryPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcPlayoutHistoryPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcPlayoutHistoryPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcPlayoutHistoryMetaData) to the collection in $obj2 (CcPlayoutHistory) + $obj2->addCcPlayoutHistoryMetaData($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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME)->getTable(CcPlayoutHistoryMetaDataPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcPlayoutHistoryMetaDataPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcPlayoutHistoryMetaDataPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\PlayoutHistory\map\CcPlayoutHistoryMetaDataTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcPlayoutHistoryMetaDataPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcPlayoutHistoryMetaData or Criteria object. + * + * @param mixed $values Criteria or CcPlayoutHistoryMetaData 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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcPlayoutHistoryMetaData object + } + + if ($criteria->containsKey(CcPlayoutHistoryMetaDataPeer::ID) && $criteria->keyContainsValue(CcPlayoutHistoryMetaDataPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlayoutHistoryMetaDataPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryMetaDataPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcPlayoutHistoryMetaData or Criteria object. + * + * @param mixed $values Criteria or CcPlayoutHistoryMetaData 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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcPlayoutHistoryMetaDataPeer::ID); + $value = $criteria->remove(CcPlayoutHistoryMetaDataPeer::ID); + if ($value) { + $selectCriteria->add(CcPlayoutHistoryMetaDataPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcPlayoutHistoryMetaDataPeer::TABLE_NAME); + } + + } else { // $values is CcPlayoutHistoryMetaData object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_playout_history_metadata table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryMetaDataPeer::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(CcPlayoutHistoryMetaDataPeer::TABLE_NAME, $con, CcPlayoutHistoryMetaDataPeer::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). + CcPlayoutHistoryMetaDataPeer::clearInstancePool(); + CcPlayoutHistoryMetaDataPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcPlayoutHistoryMetaData or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcPlayoutHistoryMetaData 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(CcPlayoutHistoryMetaDataPeer::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. + CcPlayoutHistoryMetaDataPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcPlayoutHistoryMetaData) { // it's a model object + // invalidate the cache for this single object + CcPlayoutHistoryMetaDataPeer::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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); + $criteria->add(CcPlayoutHistoryMetaDataPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcPlayoutHistoryMetaDataPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryMetaDataPeer::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); + CcPlayoutHistoryMetaDataPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcPlayoutHistoryMetaData 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 CcPlayoutHistoryMetaData $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcPlayoutHistoryMetaDataPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, CcPlayoutHistoryMetaDataPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcPlayoutHistoryMetaData + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcPlayoutHistoryMetaDataPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); + $criteria->add(CcPlayoutHistoryMetaDataPeer::ID, $pk); + + $v = CcPlayoutHistoryMetaDataPeer::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 + * @return CcPlayoutHistoryMetaData[] + * @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(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME); + $criteria->add(CcPlayoutHistoryMetaDataPeer::ID, $pks, Criteria::IN); + $objs = CcPlayoutHistoryMetaDataPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcPlayoutHistoryMetaDataPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryMetaDataQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryMetaDataQuery.php index 7a27c61af..cad90d3d8 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryMetaDataQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryMetaDataQuery.php @@ -1,320 +1,486 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcPlayoutHistoryMetaData|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcPlayoutHistoryMetaDataPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcPlayoutHistoryMetaData|CcPlayoutHistoryMetaData[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcPlayoutHistoryMetaDataPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryMetaDataPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcPlayoutHistoryMetaDataQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlayoutHistoryMetaData A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcPlayoutHistoryMetaDataQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlayoutHistoryMetaData A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "history_id", "key", "value" FROM "cc_playout_history_metadata" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcPlayoutHistoryMetaData(); + $obj->hydrate($row); + CcPlayoutHistoryMetaDataPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcPlayoutHistoryMetaDataQuery 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(CcPlayoutHistoryMetaDataPeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * Filter the query on the history_id column - * - * @param int|array $dbHistoryId 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 CcPlayoutHistoryMetaDataQuery The current query, for fluid interface - */ - public function filterByDbHistoryId($dbHistoryId = null, $comparison = null) - { - if (is_array($dbHistoryId)) { - $useMinMax = false; - if (isset($dbHistoryId['min'])) { - $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, $dbHistoryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbHistoryId['max'])) { - $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, $dbHistoryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, $dbHistoryId, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlayoutHistoryMetaData|CcPlayoutHistoryMetaData[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Filter the query on the key column - * - * @param string $dbKey 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 CcPlayoutHistoryMetaDataQuery The current query, for fluid interface - */ - public function filterByDbKey($dbKey = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbKey)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbKey)) { - $dbKey = str_replace('*', '%', $dbKey); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::KEY, $dbKey, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query on the value column - * - * @param string $dbValue The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcPlayoutHistoryMetaDataQuery The current query, for fluid interface - */ - public function filterByDbValue($dbValue = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbValue)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbValue)) { - $dbValue = str_replace('*', '%', $dbValue); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::VALUE, $dbValue, $comparison); - } + /** + * 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|CcPlayoutHistoryMetaData[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query by a related CcPlayoutHistory object - * - * @param CcPlayoutHistory $ccPlayoutHistory the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcPlayoutHistoryMetaDataQuery The current query, for fluid interface - */ - public function filterByCcPlayoutHistory($ccPlayoutHistory, $comparison = null) - { - return $this - ->addUsingAlias(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, $ccPlayoutHistory->getDbId(), $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Adds a JOIN clause to the query using the CcPlayoutHistory relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcPlayoutHistoryMetaDataQuery The current query, for fluid interface - */ - public function joinCcPlayoutHistory($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcPlayoutHistory'); - - // 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, 'CcPlayoutHistory'); - } - - return $this; - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcPlayoutHistoryMetaDataQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { - /** - * Use the CcPlayoutHistory relation CcPlayoutHistory 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 CcPlayoutHistoryQuery A secondary query class using the current class as primary query - */ - public function useCcPlayoutHistoryQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcPlayoutHistory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcPlayoutHistory', 'CcPlayoutHistoryQuery'); - } + return $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::ID, $key, Criteria::EQUAL); + } - /** - * Exclude object from result - * - * @param CcPlayoutHistoryMetaData $ccPlayoutHistoryMetaData Object to remove from the list of results - * - * @return CcPlayoutHistoryMetaDataQuery The current query, for fluid interface - */ - public function prune($ccPlayoutHistoryMetaData = null) - { - if ($ccPlayoutHistoryMetaData) { - $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::ID, $ccPlayoutHistoryMetaData->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return CcPlayoutHistoryMetaDataQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { -} // BaseCcPlayoutHistoryMetaDataQuery + return $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryMetaDataQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::ID, $dbId, $comparison); + } + + /** + * Filter the query on the history_id column + * + * Example usage: + * + * $query->filterByDbHistoryId(1234); // WHERE history_id = 1234 + * $query->filterByDbHistoryId(array(12, 34)); // WHERE history_id IN (12, 34) + * $query->filterByDbHistoryId(array('min' => 12)); // WHERE history_id >= 12 + * $query->filterByDbHistoryId(array('max' => 12)); // WHERE history_id <= 12 + * + * + * @see filterByCcPlayoutHistory() + * + * @param mixed $dbHistoryId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryMetaDataQuery The current query, for fluid interface + */ + public function filterByDbHistoryId($dbHistoryId = null, $comparison = null) + { + if (is_array($dbHistoryId)) { + $useMinMax = false; + if (isset($dbHistoryId['min'])) { + $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, $dbHistoryId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbHistoryId['max'])) { + $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, $dbHistoryId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, $dbHistoryId, $comparison); + } + + /** + * Filter the query on the key column + * + * Example usage: + * + * $query->filterByDbKey('fooValue'); // WHERE key = 'fooValue' + * $query->filterByDbKey('%fooValue%'); // WHERE key LIKE '%fooValue%' + * + * + * @param string $dbKey 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 CcPlayoutHistoryMetaDataQuery The current query, for fluid interface + */ + public function filterByDbKey($dbKey = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbKey)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbKey)) { + $dbKey = str_replace('*', '%', $dbKey); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::KEY, $dbKey, $comparison); + } + + /** + * Filter the query on the value column + * + * Example usage: + * + * $query->filterByDbValue('fooValue'); // WHERE value = 'fooValue' + * $query->filterByDbValue('%fooValue%'); // WHERE value LIKE '%fooValue%' + * + * + * @param string $dbValue The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryMetaDataQuery The current query, for fluid interface + */ + public function filterByDbValue($dbValue = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbValue)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbValue)) { + $dbValue = str_replace('*', '%', $dbValue); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::VALUE, $dbValue, $comparison); + } + + /** + * Filter the query by a related CcPlayoutHistory object + * + * @param CcPlayoutHistory|PropelObjectCollection $ccPlayoutHistory The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryMetaDataQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcPlayoutHistory($ccPlayoutHistory, $comparison = null) + { + if ($ccPlayoutHistory instanceof CcPlayoutHistory) { + return $this + ->addUsingAlias(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, $ccPlayoutHistory->getDbId(), $comparison); + } elseif ($ccPlayoutHistory instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcPlayoutHistoryMetaDataPeer::HISTORY_ID, $ccPlayoutHistory->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcPlayoutHistory() only accepts arguments of type CcPlayoutHistory or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcPlayoutHistory relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcPlayoutHistoryMetaDataQuery The current query, for fluid interface + */ + public function joinCcPlayoutHistory($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcPlayoutHistory'); + + // 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, 'CcPlayoutHistory'); + } + + return $this; + } + + /** + * Use the CcPlayoutHistory relation CcPlayoutHistory 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 \Airtime\PlayoutHistory\CcPlayoutHistoryQuery A secondary query class using the current class as primary query + */ + public function useCcPlayoutHistoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcPlayoutHistory($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPlayoutHistory', '\Airtime\PlayoutHistory\CcPlayoutHistoryQuery'); + } + + /** + * Exclude object from result + * + * @param CcPlayoutHistoryMetaData $ccPlayoutHistoryMetaData Object to remove from the list of results + * + * @return CcPlayoutHistoryMetaDataQuery The current query, for fluid interface + */ + public function prune($ccPlayoutHistoryMetaData = null) + { + if ($ccPlayoutHistoryMetaData) { + $this->addUsingAlias(CcPlayoutHistoryMetaDataPeer::ID, $ccPlayoutHistoryMetaData->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryPeer.php index 01b944a65..b4827e466 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryPeer.php @@ -1,1374 +1,1421 @@ array ('DbId', 'DbFileId', 'DbStarts', 'DbEnds', 'DbInstanceId', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbFileId', 'dbStarts', 'dbEnds', 'dbInstanceId', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::FILE_ID, self::STARTS, self::ENDS, self::INSTANCE_ID, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FILE_ID', 'STARTS', 'ENDS', 'INSTANCE_ID', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'file_id', 'starts', 'ends', 'instance_id', ), - 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 ('DbId' => 0, 'DbFileId' => 1, 'DbStarts' => 2, 'DbEnds' => 3, 'DbInstanceId' => 4, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbFileId' => 1, 'dbStarts' => 2, 'dbEnds' => 3, 'dbInstanceId' => 4, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::FILE_ID => 1, self::STARTS => 2, self::ENDS => 3, self::INSTANCE_ID => 4, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FILE_ID' => 1, 'STARTS' => 2, 'ENDS' => 3, 'INSTANCE_ID' => 4, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'file_id' => 1, 'starts' => 2, 'ends' => 3, 'instance_id' => 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. CcPlayoutHistoryPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::ID); - $criteria->addSelectColumn(CcPlayoutHistoryPeer::FILE_ID); - $criteria->addSelectColumn(CcPlayoutHistoryPeer::STARTS); - $criteria->addSelectColumn(CcPlayoutHistoryPeer::ENDS); - $criteria->addSelectColumn(CcPlayoutHistoryPeer::INSTANCE_ID); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.FILE_ID'); - $criteria->addSelectColumn($alias . '.STARTS'); - $criteria->addSelectColumn($alias . '.ENDS'); - $criteria->addSelectColumn($alias . '.INSTANCE_ID'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CcPlayoutHistoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::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 CcPlayoutHistory - * @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 = CcPlayoutHistoryPeer::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 CcPlayoutHistoryPeer::populateObjects(CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcPlayoutHistoryPeer::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 CcPlayoutHistory $value A CcPlayoutHistory object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcPlayoutHistory $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 CcPlayoutHistory object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcPlayoutHistory) { - $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 CcPlayoutHistory 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 CcPlayoutHistory 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_playout_history - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in CcPlayoutHistoryMetaDataPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcPlayoutHistoryMetaDataPeer::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 = CcPlayoutHistoryPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcPlayoutHistoryPeer::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; - CcPlayoutHistoryPeer::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 (CcPlayoutHistory object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcPlayoutHistoryPeer::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 + CcPlayoutHistoryPeer::NUM_COLUMNS; - } else { - $cls = CcPlayoutHistoryPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcPlayoutHistoryPeer::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 CcShowInstances 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 doCountJoinCcShowInstances(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(CcPlayoutHistoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcPlayoutHistoryPeer::INSTANCE_ID, CcShowInstancesPeer::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 CcPlayoutHistory 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 CcPlayoutHistory 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); - } - - CcPlayoutHistoryPeer::addSelectColumns($criteria); - $startcol = (CcPlayoutHistoryPeer::NUM_COLUMNS - CcPlayoutHistoryPeer::NUM_LAZY_LOAD_COLUMNS); - CcFilesPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcPlayoutHistoryPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcPlayoutHistoryPeer::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 = CcPlayoutHistoryPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcPlayoutHistoryPeer::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 (CcPlayoutHistory) to $obj2 (CcFiles) - $obj2->addCcPlayoutHistory($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcPlayoutHistory objects pre-filled with their CcShowInstances 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 CcPlayoutHistory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCcShowInstances(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); - } - - CcPlayoutHistoryPeer::addSelectColumns($criteria); - $startcol = (CcPlayoutHistoryPeer::NUM_COLUMNS - CcPlayoutHistoryPeer::NUM_LAZY_LOAD_COLUMNS); - CcShowInstancesPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcPlayoutHistoryPeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcPlayoutHistoryPeer::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 = CcPlayoutHistoryPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcPlayoutHistoryPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcShowInstancesPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowInstancesPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcShowInstancesPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcPlayoutHistory) to $obj2 (CcShowInstances) - $obj2->addCcPlayoutHistory($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(CcPlayoutHistoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcPlayoutHistoryPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $criteria->addJoin(CcPlayoutHistoryPeer::INSTANCE_ID, CcShowInstancesPeer::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 CcPlayoutHistory 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 CcPlayoutHistory 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); - } - - CcPlayoutHistoryPeer::addSelectColumns($criteria); - $startcol2 = (CcPlayoutHistoryPeer::NUM_COLUMNS - CcPlayoutHistoryPeer::NUM_LAZY_LOAD_COLUMNS); - - CcFilesPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); - - CcShowInstancesPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcPlayoutHistoryPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $criteria->addJoin(CcPlayoutHistoryPeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcPlayoutHistoryPeer::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 = CcPlayoutHistoryPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcPlayoutHistoryPeer::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 (CcPlayoutHistory) to the collection in $obj2 (CcFiles) - $obj2->addCcPlayoutHistory($obj1); - } // if joined row not null - - // Add objects for joined CcShowInstances rows - - $key3 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CcShowInstancesPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CcShowInstancesPeer::getOMClass(false); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CcShowInstancesPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (CcPlayoutHistory) to the collection in $obj3 (CcShowInstances) - $obj3->addCcPlayoutHistory($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(CcPlayoutHistoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcPlayoutHistoryPeer::INSTANCE_ID, CcShowInstancesPeer::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 CcShowInstances 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 doCountJoinAllExceptCcShowInstances(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(CcPlayoutHistoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcPlayoutHistoryPeer::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 CcPlayoutHistory 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 CcPlayoutHistory 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); - } - - CcPlayoutHistoryPeer::addSelectColumns($criteria); - $startcol2 = (CcPlayoutHistoryPeer::NUM_COLUMNS - CcPlayoutHistoryPeer::NUM_LAZY_LOAD_COLUMNS); - - CcShowInstancesPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcPlayoutHistoryPeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcPlayoutHistoryPeer::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 = CcPlayoutHistoryPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcPlayoutHistoryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcShowInstances rows - - $key2 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcShowInstancesPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowInstancesPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcShowInstancesPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (CcPlayoutHistory) to the collection in $obj2 (CcShowInstances) - $obj2->addCcPlayoutHistory($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcPlayoutHistory objects pre-filled with all related objects except CcShowInstances. - * - * @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 CcPlayoutHistory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCcShowInstances(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); - } - - CcPlayoutHistoryPeer::addSelectColumns($criteria); - $startcol2 = (CcPlayoutHistoryPeer::NUM_COLUMNS - CcPlayoutHistoryPeer::NUM_LAZY_LOAD_COLUMNS); - - CcFilesPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcPlayoutHistoryPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcPlayoutHistoryPeer::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 = CcPlayoutHistoryPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcPlayoutHistoryPeer::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 (CcPlayoutHistory) to the collection in $obj2 (CcFiles) - $obj2->addCcPlayoutHistory($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(BaseCcPlayoutHistoryPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcPlayoutHistoryPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcPlayoutHistoryTableMap()); - } - } - - /** - * 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 ? CcPlayoutHistoryPeer::CLASS_DEFAULT : CcPlayoutHistoryPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcPlayoutHistory or Criteria object. - * - * @param mixed $values Criteria or CcPlayoutHistory 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(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcPlayoutHistory object - } - - if ($criteria->containsKey(CcPlayoutHistoryPeer::ID) && $criteria->keyContainsValue(CcPlayoutHistoryPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlayoutHistoryPeer::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 CcPlayoutHistory or Criteria object. - * - * @param mixed $values Criteria or CcPlayoutHistory 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(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcPlayoutHistoryPeer::ID); - $value = $criteria->remove(CcPlayoutHistoryPeer::ID); - if ($value) { - $selectCriteria->add(CcPlayoutHistoryPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcPlayoutHistoryPeer::TABLE_NAME); - } - - } else { // $values is CcPlayoutHistory 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_playout_history 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(CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::TABLE_NAME, $con, CcPlayoutHistoryPeer::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). - CcPlayoutHistoryPeer::clearInstancePool(); - CcPlayoutHistoryPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcPlayoutHistory or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcPlayoutHistory 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(CcPlayoutHistoryPeer::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. - CcPlayoutHistoryPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcPlayoutHistory) { // it's a model object - // invalidate the cache for this single object - CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcPlayoutHistoryPeer::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); - CcPlayoutHistoryPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcPlayoutHistory 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 CcPlayoutHistory $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(CcPlayoutHistory $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcPlayoutHistoryPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::DATABASE_NAME, CcPlayoutHistoryPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcPlayoutHistory - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcPlayoutHistoryPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcPlayoutHistoryPeer::DATABASE_NAME); - $criteria->add(CcPlayoutHistoryPeer::ID, $pk); - - $v = CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcPlayoutHistoryPeer::DATABASE_NAME); - $criteria->add(CcPlayoutHistoryPeer::ID, $pks, Criteria::IN); - $objs = CcPlayoutHistoryPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcPlayoutHistoryPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_playout_history'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\PlayoutHistory\\CcPlayoutHistory'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\PlayoutHistory\\map\\CcPlayoutHistoryTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 5; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 5; + + /** the column name for the id field */ + const ID = 'cc_playout_history.id'; + + /** the column name for the file_id field */ + const FILE_ID = 'cc_playout_history.file_id'; + + /** the column name for the starts field */ + const STARTS = 'cc_playout_history.starts'; + + /** the column name for the ends field */ + const ENDS = 'cc_playout_history.ends'; + + /** the column name for the instance_id field */ + const INSTANCE_ID = 'cc_playout_history.instance_id'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcPlayoutHistory objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcPlayoutHistory[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcPlayoutHistoryPeer::$fieldNames[CcPlayoutHistoryPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbFileId', 'DbStarts', 'DbEnds', 'DbInstanceId', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbFileId', 'dbStarts', 'dbEnds', 'dbInstanceId', ), + BasePeer::TYPE_COLNAME => array (CcPlayoutHistoryPeer::ID, CcPlayoutHistoryPeer::FILE_ID, CcPlayoutHistoryPeer::STARTS, CcPlayoutHistoryPeer::ENDS, CcPlayoutHistoryPeer::INSTANCE_ID, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FILE_ID', 'STARTS', 'ENDS', 'INSTANCE_ID', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'file_id', 'starts', 'ends', 'instance_id', ), + 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. CcPlayoutHistoryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbFileId' => 1, 'DbStarts' => 2, 'DbEnds' => 3, 'DbInstanceId' => 4, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbFileId' => 1, 'dbStarts' => 2, 'dbEnds' => 3, 'dbInstanceId' => 4, ), + BasePeer::TYPE_COLNAME => array (CcPlayoutHistoryPeer::ID => 0, CcPlayoutHistoryPeer::FILE_ID => 1, CcPlayoutHistoryPeer::STARTS => 2, CcPlayoutHistoryPeer::ENDS => 3, CcPlayoutHistoryPeer::INSTANCE_ID => 4, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FILE_ID' => 1, 'STARTS' => 2, 'ENDS' => 3, 'INSTANCE_ID' => 4, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'file_id' => 1, 'starts' => 2, 'ends' => 3, 'instance_id' => 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcPlayoutHistoryPeer::getFieldNames($toType); + $key = isset(CcPlayoutHistoryPeer::$fieldKeys[$fromType][$name]) ? CcPlayoutHistoryPeer::$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(CcPlayoutHistoryPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcPlayoutHistoryPeer::$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 CcPlayoutHistoryPeer::$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. CcPlayoutHistoryPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::ID); + $criteria->addSelectColumn(CcPlayoutHistoryPeer::FILE_ID); + $criteria->addSelectColumn(CcPlayoutHistoryPeer::STARTS); + $criteria->addSelectColumn(CcPlayoutHistoryPeer::ENDS); + $criteria->addSelectColumn(CcPlayoutHistoryPeer::INSTANCE_ID); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.file_id'); + $criteria->addSelectColumn($alias . '.starts'); + $criteria->addSelectColumn($alias . '.ends'); + $criteria->addSelectColumn($alias . '.instance_id'); + } + } + + /** + * Returns the number of rows matching criteria. + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. + * @param PropelPDO $con + * @return int Number of matching rows. + */ + public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) + { + // we may modify criteria, so copy it first + $criteria = clone $criteria; + + // We need to set the primary table name, since in the case that there are no WHERE columns + // it will be impossible for the BasePeer::createSelectSql() method to determine which + // tables go into the FROM clause. + $criteria->setPrimaryTableName(CcPlayoutHistoryPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlayoutHistoryPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcPlayoutHistoryPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcPlayoutHistory + * @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 = CcPlayoutHistoryPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcPlayoutHistoryPeer::populateObjects(CcPlayoutHistoryPeer::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 directly (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(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcPlayoutHistoryPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryPeer::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 CcPlayoutHistory $obj A CcPlayoutHistory object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcPlayoutHistoryPeer::$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 CcPlayoutHistory object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcPlayoutHistory) { + $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 CcPlayoutHistory object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcPlayoutHistoryPeer::$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 CcPlayoutHistory 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(CcPlayoutHistoryPeer::$instances[$key])) { + return CcPlayoutHistoryPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcPlayoutHistoryPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcPlayoutHistoryPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_playout_history + * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in CcPlayoutHistoryMetaDataPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcPlayoutHistoryMetaDataPeer::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 = CcPlayoutHistoryPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcPlayoutHistoryPeer::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; + CcPlayoutHistoryPeer::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 (CcPlayoutHistory object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcPlayoutHistoryPeer::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 + CcPlayoutHistoryPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcPlayoutHistoryPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlayoutHistoryPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlayoutHistoryPeer::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 CcShowInstances 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 doCountJoinCcShowInstances(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(CcPlayoutHistoryPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlayoutHistoryPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlayoutHistoryPeer::INSTANCE_ID, CcShowInstancesPeer::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 CcPlayoutHistory 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 CcPlayoutHistory 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(CcPlayoutHistoryPeer::DATABASE_NAME); + } + + CcPlayoutHistoryPeer::addSelectColumns($criteria); + $startcol = CcPlayoutHistoryPeer::NUM_HYDRATE_COLUMNS; + CcFilesPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcPlayoutHistoryPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPlayoutHistoryPeer::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 = CcPlayoutHistoryPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlayoutHistoryPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcFilesPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcFilesPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcFilesPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcPlayoutHistory) to $obj2 (CcFiles) + $obj2->addCcPlayoutHistory($obj1); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcPlayoutHistory objects pre-filled with their CcShowInstances 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 CcPlayoutHistory objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcShowInstances(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(CcPlayoutHistoryPeer::DATABASE_NAME); + } + + CcPlayoutHistoryPeer::addSelectColumns($criteria); + $startcol = CcPlayoutHistoryPeer::NUM_HYDRATE_COLUMNS; + CcShowInstancesPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcPlayoutHistoryPeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPlayoutHistoryPeer::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 = CcPlayoutHistoryPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlayoutHistoryPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcShowInstancesPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowInstancesPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcShowInstancesPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcPlayoutHistory) to $obj2 (CcShowInstances) + $obj2->addCcPlayoutHistory($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(CcPlayoutHistoryPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlayoutHistoryPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlayoutHistoryPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $criteria->addJoin(CcPlayoutHistoryPeer::INSTANCE_ID, CcShowInstancesPeer::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 CcPlayoutHistory 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 CcPlayoutHistory 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(CcPlayoutHistoryPeer::DATABASE_NAME); + } + + CcPlayoutHistoryPeer::addSelectColumns($criteria); + $startcol2 = CcPlayoutHistoryPeer::NUM_HYDRATE_COLUMNS; + + CcFilesPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcFilesPeer::NUM_HYDRATE_COLUMNS; + + CcShowInstancesPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcShowInstancesPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcPlayoutHistoryPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $criteria->addJoin(CcPlayoutHistoryPeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPlayoutHistoryPeer::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 = CcPlayoutHistoryPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlayoutHistoryPeer::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(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcFilesPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcPlayoutHistory) to the collection in $obj2 (CcFiles) + $obj2->addCcPlayoutHistory($obj1); + } // if joined row not null + + // Add objects for joined CcShowInstances rows + + $key3 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcShowInstancesPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcShowInstancesPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcShowInstancesPeer::addInstanceToPool($obj3, $key3); + } // if obj3 loaded + + // Add the $obj1 (CcPlayoutHistory) to the collection in $obj3 (CcShowInstances) + $obj3->addCcPlayoutHistory($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(CcPlayoutHistoryPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlayoutHistoryPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlayoutHistoryPeer::INSTANCE_ID, CcShowInstancesPeer::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 CcShowInstances 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 doCountJoinAllExceptCcShowInstances(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(CcPlayoutHistoryPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlayoutHistoryPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlayoutHistoryPeer::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 CcPlayoutHistory 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 CcPlayoutHistory 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(CcPlayoutHistoryPeer::DATABASE_NAME); + } + + CcPlayoutHistoryPeer::addSelectColumns($criteria); + $startcol2 = CcPlayoutHistoryPeer::NUM_HYDRATE_COLUMNS; + + CcShowInstancesPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcShowInstancesPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcPlayoutHistoryPeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPlayoutHistoryPeer::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 = CcPlayoutHistoryPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlayoutHistoryPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcShowInstances rows + + $key2 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcShowInstancesPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowInstancesPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcShowInstancesPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcPlayoutHistory) to the collection in $obj2 (CcShowInstances) + $obj2->addCcPlayoutHistory($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcPlayoutHistory objects pre-filled with all related objects except CcShowInstances. + * + * @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 CcPlayoutHistory objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcShowInstances(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(CcPlayoutHistoryPeer::DATABASE_NAME); + } + + CcPlayoutHistoryPeer::addSelectColumns($criteria); + $startcol2 = CcPlayoutHistoryPeer::NUM_HYDRATE_COLUMNS; + + CcFilesPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcFilesPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcPlayoutHistoryPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPlayoutHistoryPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPlayoutHistoryPeer::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 = CcPlayoutHistoryPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlayoutHistoryPeer::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(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcFilesPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcPlayoutHistory) to the collection in $obj2 (CcFiles) + $obj2->addCcPlayoutHistory($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(CcPlayoutHistoryPeer::DATABASE_NAME)->getTable(CcPlayoutHistoryPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcPlayoutHistoryPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcPlayoutHistoryPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\PlayoutHistory\map\CcPlayoutHistoryTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcPlayoutHistoryPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcPlayoutHistory or Criteria object. + * + * @param mixed $values Criteria or CcPlayoutHistory 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(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcPlayoutHistory object + } + + if ($criteria->containsKey(CcPlayoutHistoryPeer::ID) && $criteria->keyContainsValue(CcPlayoutHistoryPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlayoutHistoryPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcPlayoutHistory or Criteria object. + * + * @param mixed $values Criteria or CcPlayoutHistory 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(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcPlayoutHistoryPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcPlayoutHistoryPeer::ID); + $value = $criteria->remove(CcPlayoutHistoryPeer::ID); + if ($value) { + $selectCriteria->add(CcPlayoutHistoryPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcPlayoutHistoryPeer::TABLE_NAME); + } + + } else { // $values is CcPlayoutHistory object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcPlayoutHistoryPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_playout_history table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::TABLE_NAME, $con, CcPlayoutHistoryPeer::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). + CcPlayoutHistoryPeer::clearInstancePool(); + CcPlayoutHistoryPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcPlayoutHistory or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcPlayoutHistory 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(CcPlayoutHistoryPeer::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. + CcPlayoutHistoryPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcPlayoutHistory) { // it's a model object + // invalidate the cache for this single object + CcPlayoutHistoryPeer::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(CcPlayoutHistoryPeer::DATABASE_NAME); + $criteria->add(CcPlayoutHistoryPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcPlayoutHistoryPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryPeer::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); + CcPlayoutHistoryPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcPlayoutHistory 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 CcPlayoutHistory $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcPlayoutHistoryPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcPlayoutHistoryPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcPlayoutHistoryPeer::DATABASE_NAME, CcPlayoutHistoryPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcPlayoutHistory + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcPlayoutHistoryPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcPlayoutHistoryPeer::DATABASE_NAME); + $criteria->add(CcPlayoutHistoryPeer::ID, $pk); + + $v = CcPlayoutHistoryPeer::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 + * @return CcPlayoutHistory[] + * @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(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcPlayoutHistoryPeer::DATABASE_NAME); + $criteria->add(CcPlayoutHistoryPeer::ID, $pks, Criteria::IN); + $objs = CcPlayoutHistoryPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcPlayoutHistoryPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryQuery.php index b772a0d7a..f2d2ff1b6 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryQuery.php @@ -1,509 +1,722 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcPlayoutHistory|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcPlayoutHistoryPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcPlayoutHistory|CcPlayoutHistory[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcPlayoutHistoryPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcPlayoutHistoryQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcPlayoutHistoryPeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlayoutHistory A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcPlayoutHistoryQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcPlayoutHistoryPeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlayoutHistory A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "file_id", "starts", "ends", "instance_id" FROM "cc_playout_history" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcPlayoutHistory(); + $obj->hydrate($row); + CcPlayoutHistoryPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcPlayoutHistoryQuery 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(CcPlayoutHistoryPeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * 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 CcPlayoutHistoryQuery 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(CcPlayoutHistoryPeer::FILE_ID, $dbFileId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbFileId['max'])) { - $this->addUsingAlias(CcPlayoutHistoryPeer::FILE_ID, $dbFileId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcPlayoutHistoryPeer::FILE_ID, $dbFileId, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlayoutHistory|CcPlayoutHistory[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Filter the query on the starts column - * - * @param string|array $dbStarts 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 CcPlayoutHistoryQuery The current query, for fluid interface - */ - public function filterByDbStarts($dbStarts = null, $comparison = null) - { - if (is_array($dbStarts)) { - $useMinMax = false; - if (isset($dbStarts['min'])) { - $this->addUsingAlias(CcPlayoutHistoryPeer::STARTS, $dbStarts['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbStarts['max'])) { - $this->addUsingAlias(CcPlayoutHistoryPeer::STARTS, $dbStarts['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcPlayoutHistoryPeer::STARTS, $dbStarts, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query on the ends column - * - * @param string|array $dbEnds 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 CcPlayoutHistoryQuery The current query, for fluid interface - */ - public function filterByDbEnds($dbEnds = null, $comparison = null) - { - if (is_array($dbEnds)) { - $useMinMax = false; - if (isset($dbEnds['min'])) { - $this->addUsingAlias(CcPlayoutHistoryPeer::ENDS, $dbEnds['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbEnds['max'])) { - $this->addUsingAlias(CcPlayoutHistoryPeer::ENDS, $dbEnds['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcPlayoutHistoryPeer::ENDS, $dbEnds, $comparison); - } + /** + * 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|CcPlayoutHistory[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query on the instance_id column - * - * @param int|array $dbInstanceId 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 CcPlayoutHistoryQuery The current query, for fluid interface - */ - public function filterByDbInstanceId($dbInstanceId = null, $comparison = null) - { - if (is_array($dbInstanceId)) { - $useMinMax = false; - if (isset($dbInstanceId['min'])) { - $this->addUsingAlias(CcPlayoutHistoryPeer::INSTANCE_ID, $dbInstanceId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbInstanceId['max'])) { - $this->addUsingAlias(CcPlayoutHistoryPeer::INSTANCE_ID, $dbInstanceId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcPlayoutHistoryPeer::INSTANCE_ID, $dbInstanceId, $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * 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 CcPlayoutHistoryQuery The current query, for fluid interface - */ - public function filterByCcFiles($ccFiles, $comparison = null) - { - return $this - ->addUsingAlias(CcPlayoutHistoryPeer::FILE_ID, $ccFiles->getDbId(), $comparison); - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcPlayoutHistoryQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { - /** - * 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 CcPlayoutHistoryQuery 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; - } + return $this->addUsingAlias(CcPlayoutHistoryPeer::ID, $key, Criteria::EQUAL); + } - /** - * 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 list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return CcPlayoutHistoryQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { - /** - * Filter the query by a related CcShowInstances object - * - * @param CcShowInstances $ccShowInstances the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcPlayoutHistoryQuery The current query, for fluid interface - */ - public function filterByCcShowInstances($ccShowInstances, $comparison = null) - { - return $this - ->addUsingAlias(CcPlayoutHistoryPeer::INSTANCE_ID, $ccShowInstances->getDbId(), $comparison); - } + return $this->addUsingAlias(CcPlayoutHistoryPeer::ID, $keys, Criteria::IN); + } - /** - * Adds a JOIN clause to the query using the CcShowInstances relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcPlayoutHistoryQuery The current query, for fluid interface - */ - public function joinCcShowInstances($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcShowInstances'); - - // 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, 'CcShowInstances'); - } - - return $this; - } + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcPlayoutHistoryPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcPlayoutHistoryPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Use the CcShowInstances relation CcShowInstances 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 CcShowInstancesQuery A secondary query class using the current class as primary query - */ - public function useCcShowInstancesQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcShowInstances($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcShowInstances', 'CcShowInstancesQuery'); - } + return $this->addUsingAlias(CcPlayoutHistoryPeer::ID, $dbId, $comparison); + } - /** - * Filter the query by a related CcPlayoutHistoryMetaData object - * - * @param CcPlayoutHistoryMetaData $ccPlayoutHistoryMetaData the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcPlayoutHistoryQuery The current query, for fluid interface - */ - public function filterByCcPlayoutHistoryMetaData($ccPlayoutHistoryMetaData, $comparison = null) - { - return $this - ->addUsingAlias(CcPlayoutHistoryPeer::ID, $ccPlayoutHistoryMetaData->getDbHistoryId(), $comparison); - } + /** + * Filter the query on the file_id column + * + * Example usage: + * + * $query->filterByDbFileId(1234); // WHERE file_id = 1234 + * $query->filterByDbFileId(array(12, 34)); // WHERE file_id IN (12, 34) + * $query->filterByDbFileId(array('min' => 12)); // WHERE file_id >= 12 + * $query->filterByDbFileId(array('max' => 12)); // WHERE file_id <= 12 + * + * + * @see filterByCcFiles() + * + * @param mixed $dbFileId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryQuery 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(CcPlayoutHistoryPeer::FILE_ID, $dbFileId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbFileId['max'])) { + $this->addUsingAlias(CcPlayoutHistoryPeer::FILE_ID, $dbFileId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Adds a JOIN clause to the query using the CcPlayoutHistoryMetaData relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcPlayoutHistoryQuery The current query, for fluid interface - */ - public function joinCcPlayoutHistoryMetaData($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcPlayoutHistoryMetaData'); - - // 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, 'CcPlayoutHistoryMetaData'); - } - - return $this; - } + return $this->addUsingAlias(CcPlayoutHistoryPeer::FILE_ID, $dbFileId, $comparison); + } - /** - * Use the CcPlayoutHistoryMetaData relation CcPlayoutHistoryMetaData 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 CcPlayoutHistoryMetaDataQuery A secondary query class using the current class as primary query - */ - public function useCcPlayoutHistoryMetaDataQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcPlayoutHistoryMetaData($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcPlayoutHistoryMetaData', 'CcPlayoutHistoryMetaDataQuery'); - } + /** + * Filter the query on the starts column + * + * Example usage: + * + * $query->filterByDbStarts('2011-03-14'); // WHERE starts = '2011-03-14' + * $query->filterByDbStarts('now'); // WHERE starts = '2011-03-14' + * $query->filterByDbStarts(array('max' => 'yesterday')); // WHERE starts < '2011-03-13' + * + * + * @param mixed $dbStarts The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryQuery The current query, for fluid interface + */ + public function filterByDbStarts($dbStarts = null, $comparison = null) + { + if (is_array($dbStarts)) { + $useMinMax = false; + if (isset($dbStarts['min'])) { + $this->addUsingAlias(CcPlayoutHistoryPeer::STARTS, $dbStarts['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbStarts['max'])) { + $this->addUsingAlias(CcPlayoutHistoryPeer::STARTS, $dbStarts['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Exclude object from result - * - * @param CcPlayoutHistory $ccPlayoutHistory Object to remove from the list of results - * - * @return CcPlayoutHistoryQuery The current query, for fluid interface - */ - public function prune($ccPlayoutHistory = null) - { - if ($ccPlayoutHistory) { - $this->addUsingAlias(CcPlayoutHistoryPeer::ID, $ccPlayoutHistory->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + return $this->addUsingAlias(CcPlayoutHistoryPeer::STARTS, $dbStarts, $comparison); + } -} // BaseCcPlayoutHistoryQuery + /** + * Filter the query on the ends column + * + * Example usage: + * + * $query->filterByDbEnds('2011-03-14'); // WHERE ends = '2011-03-14' + * $query->filterByDbEnds('now'); // WHERE ends = '2011-03-14' + * $query->filterByDbEnds(array('max' => 'yesterday')); // WHERE ends < '2011-03-13' + * + * + * @param mixed $dbEnds The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryQuery The current query, for fluid interface + */ + public function filterByDbEnds($dbEnds = null, $comparison = null) + { + if (is_array($dbEnds)) { + $useMinMax = false; + if (isset($dbEnds['min'])) { + $this->addUsingAlias(CcPlayoutHistoryPeer::ENDS, $dbEnds['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbEnds['max'])) { + $this->addUsingAlias(CcPlayoutHistoryPeer::ENDS, $dbEnds['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcPlayoutHistoryPeer::ENDS, $dbEnds, $comparison); + } + + /** + * Filter the query on the instance_id column + * + * Example usage: + * + * $query->filterByDbInstanceId(1234); // WHERE instance_id = 1234 + * $query->filterByDbInstanceId(array(12, 34)); // WHERE instance_id IN (12, 34) + * $query->filterByDbInstanceId(array('min' => 12)); // WHERE instance_id >= 12 + * $query->filterByDbInstanceId(array('max' => 12)); // WHERE instance_id <= 12 + * + * + * @see filterByCcShowInstances() + * + * @param mixed $dbInstanceId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryQuery The current query, for fluid interface + */ + public function filterByDbInstanceId($dbInstanceId = null, $comparison = null) + { + if (is_array($dbInstanceId)) { + $useMinMax = false; + if (isset($dbInstanceId['min'])) { + $this->addUsingAlias(CcPlayoutHistoryPeer::INSTANCE_ID, $dbInstanceId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbInstanceId['max'])) { + $this->addUsingAlias(CcPlayoutHistoryPeer::INSTANCE_ID, $dbInstanceId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcPlayoutHistoryPeer::INSTANCE_ID, $dbInstanceId, $comparison); + } + + /** + * Filter the query by a related CcFiles object + * + * @param CcFiles|PropelObjectCollection $ccFiles The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcFiles($ccFiles, $comparison = null) + { + if ($ccFiles instanceof CcFiles) { + return $this + ->addUsingAlias(CcPlayoutHistoryPeer::FILE_ID, $ccFiles->getDbId(), $comparison); + } elseif ($ccFiles instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcPlayoutHistoryPeer::FILE_ID, $ccFiles->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcFiles() only accepts arguments of type CcFiles or PropelCollection'); + } + } + + /** + * 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 CcPlayoutHistoryQuery The current query, for fluid interface + */ + public function joinCcFiles($relationAlias = null, $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 \Airtime\CcFilesQuery A secondary query class using the current class as primary query + */ + public function useCcFilesQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcFiles($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcFiles', '\Airtime\CcFilesQuery'); + } + + /** + * Filter the query by a related CcShowInstances object + * + * @param CcShowInstances|PropelObjectCollection $ccShowInstances The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcShowInstances($ccShowInstances, $comparison = null) + { + if ($ccShowInstances instanceof CcShowInstances) { + return $this + ->addUsingAlias(CcPlayoutHistoryPeer::INSTANCE_ID, $ccShowInstances->getDbId(), $comparison); + } elseif ($ccShowInstances instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcPlayoutHistoryPeer::INSTANCE_ID, $ccShowInstances->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcShowInstances() only accepts arguments of type CcShowInstances or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcShowInstances relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcPlayoutHistoryQuery The current query, for fluid interface + */ + public function joinCcShowInstances($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShowInstances'); + + // 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, 'CcShowInstances'); + } + + return $this; + } + + /** + * Use the CcShowInstances relation CcShowInstances 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 \Airtime\CcShowInstancesQuery A secondary query class using the current class as primary query + */ + public function useCcShowInstancesQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcShowInstances($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShowInstances', '\Airtime\CcShowInstancesQuery'); + } + + /** + * Filter the query by a related CcPlayoutHistoryMetaData object + * + * @param CcPlayoutHistoryMetaData|PropelObjectCollection $ccPlayoutHistoryMetaData the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcPlayoutHistoryMetaData($ccPlayoutHistoryMetaData, $comparison = null) + { + if ($ccPlayoutHistoryMetaData instanceof CcPlayoutHistoryMetaData) { + return $this + ->addUsingAlias(CcPlayoutHistoryPeer::ID, $ccPlayoutHistoryMetaData->getDbHistoryId(), $comparison); + } elseif ($ccPlayoutHistoryMetaData instanceof PropelObjectCollection) { + return $this + ->useCcPlayoutHistoryMetaDataQuery() + ->filterByPrimaryKeys($ccPlayoutHistoryMetaData->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcPlayoutHistoryMetaData() only accepts arguments of type CcPlayoutHistoryMetaData or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcPlayoutHistoryMetaData relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcPlayoutHistoryQuery The current query, for fluid interface + */ + public function joinCcPlayoutHistoryMetaData($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcPlayoutHistoryMetaData'); + + // 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, 'CcPlayoutHistoryMetaData'); + } + + return $this; + } + + /** + * Use the CcPlayoutHistoryMetaData relation CcPlayoutHistoryMetaData 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 \Airtime\PlayoutHistory\CcPlayoutHistoryMetaDataQuery A secondary query class using the current class as primary query + */ + public function useCcPlayoutHistoryMetaDataQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcPlayoutHistoryMetaData($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPlayoutHistoryMetaData', '\Airtime\PlayoutHistory\CcPlayoutHistoryMetaDataQuery'); + } + + /** + * Exclude object from result + * + * @param CcPlayoutHistory $ccPlayoutHistory Object to remove from the list of results + * + * @return CcPlayoutHistoryQuery The current query, for fluid interface + */ + public function prune($ccPlayoutHistory = null) + { + if ($ccPlayoutHistory) { + $this->addUsingAlias(CcPlayoutHistoryPeer::ID, $ccPlayoutHistory->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplate.php b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplate.php index 222227af6..ae4396987 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplate.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplate.php @@ -1,916 +1,1215 @@ id; - } - - /** - * Get the [name] column value. - * - * @return string - */ - public function getDbName() - { - return $this->name; - } - - /** - * Get the [type] column value. - * - * @return string - */ - public function getDbType() - { - return $this->type; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcPlayoutHistoryTemplate 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[] = CcPlayoutHistoryTemplatePeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [name] column. - * - * @param string $v new value - * @return CcPlayoutHistoryTemplate The current object (for fluent API support) - */ - public function setDbName($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->name !== $v) { - $this->name = $v; - $this->modifiedColumns[] = CcPlayoutHistoryTemplatePeer::NAME; - } - - return $this; - } // setDbName() - - /** - * Set the value of [type] column. - * - * @param string $v new value - * @return CcPlayoutHistoryTemplate The current object (for fluent API support) - */ - public function setDbType($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->type !== $v) { - $this->type = $v; - $this->modifiedColumns[] = CcPlayoutHistoryTemplatePeer::TYPE; - } - - return $this; - } // setDbType() - - /** - * 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->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->type = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 3; // 3 = CcPlayoutHistoryTemplatePeer::NUM_COLUMNS - CcPlayoutHistoryTemplatePeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcPlayoutHistoryTemplate 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(CcPlayoutHistoryTemplatePeer::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 = CcPlayoutHistoryTemplatePeer::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->collCcPlayoutHistoryTemplateFields = 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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcPlayoutHistoryTemplateQuery::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(CcPlayoutHistoryTemplatePeer::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); - CcPlayoutHistoryTemplatePeer::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[] = CcPlayoutHistoryTemplatePeer::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(CcPlayoutHistoryTemplatePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlayoutHistoryTemplatePeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows = 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows = CcPlayoutHistoryTemplatePeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - if ($this->collCcPlayoutHistoryTemplateFields !== null) { - foreach ($this->collCcPlayoutHistoryTemplateFields 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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CcPlayoutHistoryTemplatePeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collCcPlayoutHistoryTemplateFields !== null) { - foreach ($this->collCcPlayoutHistoryTemplateFields 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 = CcPlayoutHistoryTemplatePeer::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->getDbType(); - 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 = CcPlayoutHistoryTemplatePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbName(), - $keys[2] => $this->getDbType(), - ); - 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 = CcPlayoutHistoryTemplatePeer::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->setDbType($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 = CcPlayoutHistoryTemplatePeer::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->setDbType($arr[$keys[2]]); - } - - /** - * 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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME); - - if ($this->isColumnModified(CcPlayoutHistoryTemplatePeer::ID)) $criteria->add(CcPlayoutHistoryTemplatePeer::ID, $this->id); - if ($this->isColumnModified(CcPlayoutHistoryTemplatePeer::NAME)) $criteria->add(CcPlayoutHistoryTemplatePeer::NAME, $this->name); - if ($this->isColumnModified(CcPlayoutHistoryTemplatePeer::TYPE)) $criteria->add(CcPlayoutHistoryTemplatePeer::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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME); - $criteria->add(CcPlayoutHistoryTemplatePeer::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 CcPlayoutHistoryTemplate (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->setDbType($this->type); - - 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->getCcPlayoutHistoryTemplateFields() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcPlayoutHistoryTemplateField($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 CcPlayoutHistoryTemplate 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 CcPlayoutHistoryTemplatePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcPlayoutHistoryTemplatePeer(); - } - return self::$peer; - } - - /** - * Clears out the collCcPlayoutHistoryTemplateFields 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 addCcPlayoutHistoryTemplateFields() - */ - public function clearCcPlayoutHistoryTemplateFields() - { - $this->collCcPlayoutHistoryTemplateFields = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcPlayoutHistoryTemplateFields collection. - * - * By default this just sets the collCcPlayoutHistoryTemplateFields collection to an empty array (like clearcollCcPlayoutHistoryTemplateFields()); - * 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 initCcPlayoutHistoryTemplateFields() - { - $this->collCcPlayoutHistoryTemplateFields = new PropelObjectCollection(); - $this->collCcPlayoutHistoryTemplateFields->setModel('CcPlayoutHistoryTemplateField'); - } - - /** - * Gets an array of CcPlayoutHistoryTemplateField 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 CcPlayoutHistoryTemplate 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 CcPlayoutHistoryTemplateField[] List of CcPlayoutHistoryTemplateField objects - * @throws PropelException - */ - public function getCcPlayoutHistoryTemplateFields($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcPlayoutHistoryTemplateFields || null !== $criteria) { - if ($this->isNew() && null === $this->collCcPlayoutHistoryTemplateFields) { - // return empty collection - $this->initCcPlayoutHistoryTemplateFields(); - } else { - $collCcPlayoutHistoryTemplateFields = CcPlayoutHistoryTemplateFieldQuery::create(null, $criteria) - ->filterByCcPlayoutHistoryTemplate($this) - ->find($con); - if (null !== $criteria) { - return $collCcPlayoutHistoryTemplateFields; - } - $this->collCcPlayoutHistoryTemplateFields = $collCcPlayoutHistoryTemplateFields; - } - } - return $this->collCcPlayoutHistoryTemplateFields; - } - - /** - * Returns the number of related CcPlayoutHistoryTemplateField objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcPlayoutHistoryTemplateField objects. - * @throws PropelException - */ - public function countCcPlayoutHistoryTemplateFields(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcPlayoutHistoryTemplateFields || null !== $criteria) { - if ($this->isNew() && null === $this->collCcPlayoutHistoryTemplateFields) { - return 0; - } else { - $query = CcPlayoutHistoryTemplateFieldQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcPlayoutHistoryTemplate($this) - ->count($con); - } - } else { - return count($this->collCcPlayoutHistoryTemplateFields); - } - } - - /** - * Method called to associate a CcPlayoutHistoryTemplateField object to this object - * through the CcPlayoutHistoryTemplateField foreign key attribute. - * - * @param CcPlayoutHistoryTemplateField $l CcPlayoutHistoryTemplateField - * @return void - * @throws PropelException - */ - public function addCcPlayoutHistoryTemplateField(CcPlayoutHistoryTemplateField $l) - { - if ($this->collCcPlayoutHistoryTemplateFields === null) { - $this->initCcPlayoutHistoryTemplateFields(); - } - if (!$this->collCcPlayoutHistoryTemplateFields->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcPlayoutHistoryTemplateFields[]= $l; - $l->setCcPlayoutHistoryTemplate($this); - } - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->name = 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 ($this->collCcPlayoutHistoryTemplateFields) { - foreach ((array) $this->collCcPlayoutHistoryTemplateFields as $o) { - $o->clearAllReferences($deep); - } - } - } // if ($deep) - - $this->collCcPlayoutHistoryTemplateFields = 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); - } - -} // BaseCcPlayoutHistoryTemplate + /** + * Peer class name + */ + const PEER = 'Airtime\\PlayoutHistory\\CcPlayoutHistoryTemplatePeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcPlayoutHistoryTemplatePeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the name field. + * @var string + */ + protected $name; + + /** + * The value for the type field. + * @var string + */ + protected $type; + + /** + * @var PropelObjectCollection|CcPlayoutHistoryTemplateField[] Collection to store aggregation of CcPlayoutHistoryTemplateField objects. + */ + protected $collCcPlayoutHistoryTemplateFields; + protected $collCcPlayoutHistoryTemplateFieldsPartial; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccPlayoutHistoryTemplateFieldsScheduledForDeletion = null; + + /** + * 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 [type] column value. + * + * @return string + */ + public function getDbType() + { + + return $this->type; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcPlayoutHistoryTemplate The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcPlayoutHistoryTemplatePeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return CcPlayoutHistoryTemplate The current object (for fluent API support) + */ + public function setDbName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = CcPlayoutHistoryTemplatePeer::NAME; + } + + + return $this; + } // setDbName() + + /** + * Set the value of [type] column. + * + * @param string $v new value + * @return CcPlayoutHistoryTemplate The current object (for fluent API support) + */ + public function setDbType($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->type !== $v) { + $this->type = $v; + $this->modifiedColumns[] = CcPlayoutHistoryTemplatePeer::TYPE; + } + + + return $this; + } // setDbType() + + /** + * 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 resultset 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->type = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 3; // 3 = CcPlayoutHistoryTemplatePeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcPlayoutHistoryTemplate 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(CcPlayoutHistoryTemplatePeer::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 = CcPlayoutHistoryTemplatePeer::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->collCcPlayoutHistoryTemplateFields = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcPlayoutHistoryTemplateQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcPlayoutHistoryTemplatePeer::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); + CcPlayoutHistoryTemplatePeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->ccPlayoutHistoryTemplateFieldsScheduledForDeletion !== null) { + if (!$this->ccPlayoutHistoryTemplateFieldsScheduledForDeletion->isEmpty()) { + CcPlayoutHistoryTemplateFieldQuery::create() + ->filterByPrimaryKeys($this->ccPlayoutHistoryTemplateFieldsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccPlayoutHistoryTemplateFieldsScheduledForDeletion = null; + } + } + + if ($this->collCcPlayoutHistoryTemplateFields !== null) { + foreach ($this->collCcPlayoutHistoryTemplateFields as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcPlayoutHistoryTemplatePeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcPlayoutHistoryTemplatePeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_playout_history_template_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcPlayoutHistoryTemplatePeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcPlayoutHistoryTemplatePeer::NAME)) { + $modifiedColumns[':p' . $index++] = '"name"'; + } + if ($this->isColumnModified(CcPlayoutHistoryTemplatePeer::TYPE)) { + $modifiedColumns[':p' . $index++] = '"type"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_playout_history_template" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"name"': + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); + break; + case '"type"': + $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcPlayoutHistoryTemplatePeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collCcPlayoutHistoryTemplateFields !== null) { + foreach ($this->collCcPlayoutHistoryTemplateFields 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcPlayoutHistoryTemplatePeer::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->getDbType(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcPlayoutHistoryTemplate'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcPlayoutHistoryTemplate'][$this->getPrimaryKey()] = true; + $keys = CcPlayoutHistoryTemplatePeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbName(), + $keys[2] => $this->getDbType(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->collCcPlayoutHistoryTemplateFields) { + $result['CcPlayoutHistoryTemplateFields'] = $this->collCcPlayoutHistoryTemplateFields->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcPlayoutHistoryTemplatePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbType($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcPlayoutHistoryTemplatePeer::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->setDbType($arr[$keys[2]]); + } + + /** + * 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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME); + + if ($this->isColumnModified(CcPlayoutHistoryTemplatePeer::ID)) $criteria->add(CcPlayoutHistoryTemplatePeer::ID, $this->id); + if ($this->isColumnModified(CcPlayoutHistoryTemplatePeer::NAME)) $criteria->add(CcPlayoutHistoryTemplatePeer::NAME, $this->name); + if ($this->isColumnModified(CcPlayoutHistoryTemplatePeer::TYPE)) $criteria->add(CcPlayoutHistoryTemplatePeer::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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME); + $criteria->add(CcPlayoutHistoryTemplatePeer::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 CcPlayoutHistoryTemplate (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbName($this->getDbName()); + $copyObj->setDbType($this->getDbType()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + foreach ($this->getCcPlayoutHistoryTemplateFields() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcPlayoutHistoryTemplateField($relObj->copy($deepCopy)); + } + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcPlayoutHistoryTemplate 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 CcPlayoutHistoryTemplatePeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcPlayoutHistoryTemplatePeer(); + } + + return self::$peer; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('CcPlayoutHistoryTemplateField' == $relationName) { + $this->initCcPlayoutHistoryTemplateFields(); + } + } + + /** + * Clears out the collCcPlayoutHistoryTemplateFields 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 CcPlayoutHistoryTemplate The current object (for fluent API support) + * @see addCcPlayoutHistoryTemplateFields() + */ + public function clearCcPlayoutHistoryTemplateFields() + { + $this->collCcPlayoutHistoryTemplateFields = null; // important to set this to null since that means it is uninitialized + $this->collCcPlayoutHistoryTemplateFieldsPartial = null; + + return $this; + } + + /** + * reset is the collCcPlayoutHistoryTemplateFields collection loaded partially + * + * @return void + */ + public function resetPartialCcPlayoutHistoryTemplateFields($v = true) + { + $this->collCcPlayoutHistoryTemplateFieldsPartial = $v; + } + + /** + * Initializes the collCcPlayoutHistoryTemplateFields collection. + * + * By default this just sets the collCcPlayoutHistoryTemplateFields collection to an empty array (like clearcollCcPlayoutHistoryTemplateFields()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcPlayoutHistoryTemplateFields($overrideExisting = true) + { + if (null !== $this->collCcPlayoutHistoryTemplateFields && !$overrideExisting) { + return; + } + $this->collCcPlayoutHistoryTemplateFields = new PropelObjectCollection(); + $this->collCcPlayoutHistoryTemplateFields->setModel('CcPlayoutHistoryTemplateField'); + } + + /** + * Gets an array of CcPlayoutHistoryTemplateField 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 CcPlayoutHistoryTemplate 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 PropelObjectCollection|CcPlayoutHistoryTemplateField[] List of CcPlayoutHistoryTemplateField objects + * @throws PropelException + */ + public function getCcPlayoutHistoryTemplateFields($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcPlayoutHistoryTemplateFieldsPartial && !$this->isNew(); + if (null === $this->collCcPlayoutHistoryTemplateFields || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPlayoutHistoryTemplateFields) { + // return empty collection + $this->initCcPlayoutHistoryTemplateFields(); + } else { + $collCcPlayoutHistoryTemplateFields = CcPlayoutHistoryTemplateFieldQuery::create(null, $criteria) + ->filterByCcPlayoutHistoryTemplate($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcPlayoutHistoryTemplateFieldsPartial && count($collCcPlayoutHistoryTemplateFields)) { + $this->initCcPlayoutHistoryTemplateFields(false); + + foreach ($collCcPlayoutHistoryTemplateFields as $obj) { + if (false == $this->collCcPlayoutHistoryTemplateFields->contains($obj)) { + $this->collCcPlayoutHistoryTemplateFields->append($obj); + } + } + + $this->collCcPlayoutHistoryTemplateFieldsPartial = true; + } + + $collCcPlayoutHistoryTemplateFields->getInternalIterator()->rewind(); + + return $collCcPlayoutHistoryTemplateFields; + } + + if ($partial && $this->collCcPlayoutHistoryTemplateFields) { + foreach ($this->collCcPlayoutHistoryTemplateFields as $obj) { + if ($obj->isNew()) { + $collCcPlayoutHistoryTemplateFields[] = $obj; + } + } + } + + $this->collCcPlayoutHistoryTemplateFields = $collCcPlayoutHistoryTemplateFields; + $this->collCcPlayoutHistoryTemplateFieldsPartial = false; + } + } + + return $this->collCcPlayoutHistoryTemplateFields; + } + + /** + * Sets a collection of CcPlayoutHistoryTemplateField objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccPlayoutHistoryTemplateFields A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcPlayoutHistoryTemplate The current object (for fluent API support) + */ + public function setCcPlayoutHistoryTemplateFields(PropelCollection $ccPlayoutHistoryTemplateFields, PropelPDO $con = null) + { + $ccPlayoutHistoryTemplateFieldsToDelete = $this->getCcPlayoutHistoryTemplateFields(new Criteria(), $con)->diff($ccPlayoutHistoryTemplateFields); + + + $this->ccPlayoutHistoryTemplateFieldsScheduledForDeletion = $ccPlayoutHistoryTemplateFieldsToDelete; + + foreach ($ccPlayoutHistoryTemplateFieldsToDelete as $ccPlayoutHistoryTemplateFieldRemoved) { + $ccPlayoutHistoryTemplateFieldRemoved->setCcPlayoutHistoryTemplate(null); + } + + $this->collCcPlayoutHistoryTemplateFields = null; + foreach ($ccPlayoutHistoryTemplateFields as $ccPlayoutHistoryTemplateField) { + $this->addCcPlayoutHistoryTemplateField($ccPlayoutHistoryTemplateField); + } + + $this->collCcPlayoutHistoryTemplateFields = $ccPlayoutHistoryTemplateFields; + $this->collCcPlayoutHistoryTemplateFieldsPartial = false; + + return $this; + } + + /** + * Returns the number of related CcPlayoutHistoryTemplateField objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcPlayoutHistoryTemplateField objects. + * @throws PropelException + */ + public function countCcPlayoutHistoryTemplateFields(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcPlayoutHistoryTemplateFieldsPartial && !$this->isNew(); + if (null === $this->collCcPlayoutHistoryTemplateFields || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPlayoutHistoryTemplateFields) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcPlayoutHistoryTemplateFields()); + } + $query = CcPlayoutHistoryTemplateFieldQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcPlayoutHistoryTemplate($this) + ->count($con); + } + + return count($this->collCcPlayoutHistoryTemplateFields); + } + + /** + * Method called to associate a CcPlayoutHistoryTemplateField object to this object + * through the CcPlayoutHistoryTemplateField foreign key attribute. + * + * @param CcPlayoutHistoryTemplateField $l CcPlayoutHistoryTemplateField + * @return CcPlayoutHistoryTemplate The current object (for fluent API support) + */ + public function addCcPlayoutHistoryTemplateField(CcPlayoutHistoryTemplateField $l) + { + if ($this->collCcPlayoutHistoryTemplateFields === null) { + $this->initCcPlayoutHistoryTemplateFields(); + $this->collCcPlayoutHistoryTemplateFieldsPartial = true; + } + + if (!in_array($l, $this->collCcPlayoutHistoryTemplateFields->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcPlayoutHistoryTemplateField($l); + + if ($this->ccPlayoutHistoryTemplateFieldsScheduledForDeletion and $this->ccPlayoutHistoryTemplateFieldsScheduledForDeletion->contains($l)) { + $this->ccPlayoutHistoryTemplateFieldsScheduledForDeletion->remove($this->ccPlayoutHistoryTemplateFieldsScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcPlayoutHistoryTemplateField $ccPlayoutHistoryTemplateField The ccPlayoutHistoryTemplateField object to add. + */ + protected function doAddCcPlayoutHistoryTemplateField($ccPlayoutHistoryTemplateField) + { + $this->collCcPlayoutHistoryTemplateFields[]= $ccPlayoutHistoryTemplateField; + $ccPlayoutHistoryTemplateField->setCcPlayoutHistoryTemplate($this); + } + + /** + * @param CcPlayoutHistoryTemplateField $ccPlayoutHistoryTemplateField The ccPlayoutHistoryTemplateField object to remove. + * @return CcPlayoutHistoryTemplate The current object (for fluent API support) + */ + public function removeCcPlayoutHistoryTemplateField($ccPlayoutHistoryTemplateField) + { + if ($this->getCcPlayoutHistoryTemplateFields()->contains($ccPlayoutHistoryTemplateField)) { + $this->collCcPlayoutHistoryTemplateFields->remove($this->collCcPlayoutHistoryTemplateFields->search($ccPlayoutHistoryTemplateField)); + if (null === $this->ccPlayoutHistoryTemplateFieldsScheduledForDeletion) { + $this->ccPlayoutHistoryTemplateFieldsScheduledForDeletion = clone $this->collCcPlayoutHistoryTemplateFields; + $this->ccPlayoutHistoryTemplateFieldsScheduledForDeletion->clear(); + } + $this->ccPlayoutHistoryTemplateFieldsScheduledForDeletion[]= clone $ccPlayoutHistoryTemplateField; + $ccPlayoutHistoryTemplateField->setCcPlayoutHistoryTemplate(null); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->name = null; + $this->type = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->collCcPlayoutHistoryTemplateFields) { + foreach ($this->collCcPlayoutHistoryTemplateFields as $o) { + $o->clearAllReferences($deep); + } + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + if ($this->collCcPlayoutHistoryTemplateFields instanceof PropelCollection) { + $this->collCcPlayoutHistoryTemplateFields->clearIterator(); + } + $this->collCcPlayoutHistoryTemplateFields = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcPlayoutHistoryTemplatePeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateField.php b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateField.php index 3476aa459..667421828 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateField.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateField.php @@ -1,1076 +1,1270 @@ is_file_md = false; - } - - /** - * Initializes internal state of BaseCcPlayoutHistoryTemplateField 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 [template_id] column value. - * - * @return int - */ - public function getDbTemplateId() - { - return $this->template_id; - } - - /** - * Get the [name] column value. - * - * @return string - */ - public function getDbName() - { - return $this->name; - } - - /** - * Get the [label] column value. - * - * @return string - */ - public function getDbLabel() - { - return $this->label; - } - - /** - * Get the [type] column value. - * - * @return string - */ - public function getDbType() - { - return $this->type; - } - - /** - * Get the [is_file_md] column value. - * - * @return boolean - */ - public function getDbIsFileMD() - { - return $this->is_file_md; - } - - /** - * Get the [position] column value. - * - * @return int - */ - public function getDbPosition() - { - return $this->position; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcPlayoutHistoryTemplateField 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[] = CcPlayoutHistoryTemplateFieldPeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [template_id] column. - * - * @param int $v new value - * @return CcPlayoutHistoryTemplateField The current object (for fluent API support) - */ - public function setDbTemplateId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->template_id !== $v) { - $this->template_id = $v; - $this->modifiedColumns[] = CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID; - } - - if ($this->aCcPlayoutHistoryTemplate !== null && $this->aCcPlayoutHistoryTemplate->getDbId() !== $v) { - $this->aCcPlayoutHistoryTemplate = null; - } - - return $this; - } // setDbTemplateId() - - /** - * Set the value of [name] column. - * - * @param string $v new value - * @return CcPlayoutHistoryTemplateField The current object (for fluent API support) - */ - public function setDbName($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->name !== $v) { - $this->name = $v; - $this->modifiedColumns[] = CcPlayoutHistoryTemplateFieldPeer::NAME; - } - - return $this; - } // setDbName() - - /** - * Set the value of [label] column. - * - * @param string $v new value - * @return CcPlayoutHistoryTemplateField The current object (for fluent API support) - */ - public function setDbLabel($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->label !== $v) { - $this->label = $v; - $this->modifiedColumns[] = CcPlayoutHistoryTemplateFieldPeer::LABEL; - } - - return $this; - } // setDbLabel() - - /** - * Set the value of [type] column. - * - * @param string $v new value - * @return CcPlayoutHistoryTemplateField The current object (for fluent API support) - */ - public function setDbType($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->type !== $v) { - $this->type = $v; - $this->modifiedColumns[] = CcPlayoutHistoryTemplateFieldPeer::TYPE; - } - - return $this; - } // setDbType() - - /** - * Set the value of [is_file_md] column. - * - * @param boolean $v new value - * @return CcPlayoutHistoryTemplateField The current object (for fluent API support) - */ - public function setDbIsFileMD($v) - { - if ($v !== null) { - $v = (boolean) $v; - } - - if ($this->is_file_md !== $v || $this->isNew()) { - $this->is_file_md = $v; - $this->modifiedColumns[] = CcPlayoutHistoryTemplateFieldPeer::IS_FILE_MD; - } - - return $this; - } // setDbIsFileMD() - - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return CcPlayoutHistoryTemplateField 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[] = CcPlayoutHistoryTemplateFieldPeer::POSITION; - } - - return $this; - } // setDbPosition() - - /** - * 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->is_file_md !== false) { - 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->template_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->name = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->label = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->type = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->is_file_md = ($row[$startcol + 5] !== null) ? (boolean) $row[$startcol + 5] : null; - $this->position = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 7; // 7 = CcPlayoutHistoryTemplateFieldPeer::NUM_COLUMNS - CcPlayoutHistoryTemplateFieldPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcPlayoutHistoryTemplateField 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->aCcPlayoutHistoryTemplate !== null && $this->template_id !== $this->aCcPlayoutHistoryTemplate->getDbId()) { - $this->aCcPlayoutHistoryTemplate = 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(CcPlayoutHistoryTemplateFieldPeer::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 = CcPlayoutHistoryTemplateFieldPeer::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->aCcPlayoutHistoryTemplate = 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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcPlayoutHistoryTemplateFieldQuery::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(CcPlayoutHistoryTemplateFieldPeer::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); - CcPlayoutHistoryTemplateFieldPeer::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->aCcPlayoutHistoryTemplate !== null) { - if ($this->aCcPlayoutHistoryTemplate->isModified() || $this->aCcPlayoutHistoryTemplate->isNew()) { - $affectedRows += $this->aCcPlayoutHistoryTemplate->save($con); - } - $this->setCcPlayoutHistoryTemplate($this->aCcPlayoutHistoryTemplate); - } - - if ($this->isNew() ) { - $this->modifiedColumns[] = CcPlayoutHistoryTemplateFieldPeer::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(CcPlayoutHistoryTemplateFieldPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlayoutHistoryTemplateFieldPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows += 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows += CcPlayoutHistoryTemplateFieldPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcPlayoutHistoryTemplate !== null) { - if (!$this->aCcPlayoutHistoryTemplate->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcPlayoutHistoryTemplate->getValidationFailures()); - } - } - - - if (($retval = CcPlayoutHistoryTemplateFieldPeer::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 = CcPlayoutHistoryTemplateFieldPeer::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->getDbTemplateId(); - break; - case 2: - return $this->getDbName(); - break; - case 3: - return $this->getDbLabel(); - break; - case 4: - return $this->getDbType(); - break; - case 5: - return $this->getDbIsFileMD(); - break; - case 6: - return $this->getDbPosition(); - 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 = CcPlayoutHistoryTemplateFieldPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbTemplateId(), - $keys[2] => $this->getDbName(), - $keys[3] => $this->getDbLabel(), - $keys[4] => $this->getDbType(), - $keys[5] => $this->getDbIsFileMD(), - $keys[6] => $this->getDbPosition(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCcPlayoutHistoryTemplate) { - $result['CcPlayoutHistoryTemplate'] = $this->aCcPlayoutHistoryTemplate->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 = CcPlayoutHistoryTemplateFieldPeer::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->setDbTemplateId($value); - break; - case 2: - $this->setDbName($value); - break; - case 3: - $this->setDbLabel($value); - break; - case 4: - $this->setDbType($value); - break; - case 5: - $this->setDbIsFileMD($value); - break; - case 6: - $this->setDbPosition($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 = CcPlayoutHistoryTemplateFieldPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbTemplateId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbName($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbLabel($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbType($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbIsFileMD($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDbPosition($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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::ID)) $criteria->add(CcPlayoutHistoryTemplateFieldPeer::ID, $this->id); - if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID)) $criteria->add(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, $this->template_id); - if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::NAME)) $criteria->add(CcPlayoutHistoryTemplateFieldPeer::NAME, $this->name); - if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::LABEL)) $criteria->add(CcPlayoutHistoryTemplateFieldPeer::LABEL, $this->label); - if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::TYPE)) $criteria->add(CcPlayoutHistoryTemplateFieldPeer::TYPE, $this->type); - if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::IS_FILE_MD)) $criteria->add(CcPlayoutHistoryTemplateFieldPeer::IS_FILE_MD, $this->is_file_md); - if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::POSITION)) $criteria->add(CcPlayoutHistoryTemplateFieldPeer::POSITION, $this->position); - - 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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); - $criteria->add(CcPlayoutHistoryTemplateFieldPeer::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 CcPlayoutHistoryTemplateField (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->setDbTemplateId($this->template_id); - $copyObj->setDbName($this->name); - $copyObj->setDbLabel($this->label); - $copyObj->setDbType($this->type); - $copyObj->setDbIsFileMD($this->is_file_md); - $copyObj->setDbPosition($this->position); - - $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 CcPlayoutHistoryTemplateField 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 CcPlayoutHistoryTemplateFieldPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcPlayoutHistoryTemplateFieldPeer(); - } - return self::$peer; - } - - /** - * Declares an association between this object and a CcPlayoutHistoryTemplate object. - * - * @param CcPlayoutHistoryTemplate $v - * @return CcPlayoutHistoryTemplateField The current object (for fluent API support) - * @throws PropelException - */ - public function setCcPlayoutHistoryTemplate(CcPlayoutHistoryTemplate $v = null) - { - if ($v === null) { - $this->setDbTemplateId(NULL); - } else { - $this->setDbTemplateId($v->getDbId()); - } - - $this->aCcPlayoutHistoryTemplate = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcPlayoutHistoryTemplate object, it will not be re-added. - if ($v !== null) { - $v->addCcPlayoutHistoryTemplateField($this); - } - - return $this; - } - - - /** - * Get the associated CcPlayoutHistoryTemplate object - * - * @param PropelPDO Optional Connection object. - * @return CcPlayoutHistoryTemplate The associated CcPlayoutHistoryTemplate object. - * @throws PropelException - */ - public function getCcPlayoutHistoryTemplate(PropelPDO $con = null) - { - if ($this->aCcPlayoutHistoryTemplate === null && ($this->template_id !== null)) { - $this->aCcPlayoutHistoryTemplate = CcPlayoutHistoryTemplateQuery::create()->findPk($this->template_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->aCcPlayoutHistoryTemplate->addCcPlayoutHistoryTemplateFields($this); - */ - } - return $this->aCcPlayoutHistoryTemplate; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->template_id = null; - $this->name = null; - $this->label = null; - $this->type = null; - $this->is_file_md = null; - $this->position = 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->aCcPlayoutHistoryTemplate = 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); - } - -} // BaseCcPlayoutHistoryTemplateField + /** + * Peer class name + */ + const PEER = 'Airtime\\PlayoutHistory\\CcPlayoutHistoryTemplateFieldPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcPlayoutHistoryTemplateFieldPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the template_id field. + * @var int + */ + protected $template_id; + + /** + * The value for the name field. + * @var string + */ + protected $name; + + /** + * The value for the label field. + * @var string + */ + protected $label; + + /** + * The value for the type field. + * @var string + */ + protected $type; + + /** + * The value for the is_file_md field. + * Note: this column has a database default value of: false + * @var boolean + */ + protected $is_file_md; + + /** + * The value for the position field. + * @var int + */ + protected $position; + + /** + * @var CcPlayoutHistoryTemplate + */ + protected $aCcPlayoutHistoryTemplate; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->is_file_md = false; + } + + /** + * Initializes internal state of BaseCcPlayoutHistoryTemplateField 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 [template_id] column value. + * + * @return int + */ + public function getDbTemplateId() + { + + return $this->template_id; + } + + /** + * Get the [name] column value. + * + * @return string + */ + public function getDbName() + { + + return $this->name; + } + + /** + * Get the [label] column value. + * + * @return string + */ + public function getDbLabel() + { + + return $this->label; + } + + /** + * Get the [type] column value. + * + * @return string + */ + public function getDbType() + { + + return $this->type; + } + + /** + * Get the [is_file_md] column value. + * + * @return boolean + */ + public function getDbIsFileMD() + { + + return $this->is_file_md; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getDbPosition() + { + + return $this->position; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcPlayoutHistoryTemplateField The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcPlayoutHistoryTemplateFieldPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [template_id] column. + * + * @param int $v new value + * @return CcPlayoutHistoryTemplateField The current object (for fluent API support) + */ + public function setDbTemplateId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->template_id !== $v) { + $this->template_id = $v; + $this->modifiedColumns[] = CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID; + } + + if ($this->aCcPlayoutHistoryTemplate !== null && $this->aCcPlayoutHistoryTemplate->getDbId() !== $v) { + $this->aCcPlayoutHistoryTemplate = null; + } + + + return $this; + } // setDbTemplateId() + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return CcPlayoutHistoryTemplateField The current object (for fluent API support) + */ + public function setDbName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = CcPlayoutHistoryTemplateFieldPeer::NAME; + } + + + return $this; + } // setDbName() + + /** + * Set the value of [label] column. + * + * @param string $v new value + * @return CcPlayoutHistoryTemplateField The current object (for fluent API support) + */ + public function setDbLabel($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->label !== $v) { + $this->label = $v; + $this->modifiedColumns[] = CcPlayoutHistoryTemplateFieldPeer::LABEL; + } + + + return $this; + } // setDbLabel() + + /** + * Set the value of [type] column. + * + * @param string $v new value + * @return CcPlayoutHistoryTemplateField The current object (for fluent API support) + */ + public function setDbType($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->type !== $v) { + $this->type = $v; + $this->modifiedColumns[] = CcPlayoutHistoryTemplateFieldPeer::TYPE; + } + + + return $this; + } // setDbType() + + /** + * Sets the value of the [is_file_md] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return CcPlayoutHistoryTemplateField The current object (for fluent API support) + */ + public function setDbIsFileMD($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_file_md !== $v) { + $this->is_file_md = $v; + $this->modifiedColumns[] = CcPlayoutHistoryTemplateFieldPeer::IS_FILE_MD; + } + + + return $this; + } // setDbIsFileMD() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return CcPlayoutHistoryTemplateField The current object (for fluent API support) + */ + public function setDbPosition($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = CcPlayoutHistoryTemplateFieldPeer::POSITION; + } + + + return $this; + } // setDbPosition() + + /** + * 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->is_file_md !== false) { + 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 resultset 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->template_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->name = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->label = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->type = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->is_file_md = ($row[$startcol + 5] !== null) ? (boolean) $row[$startcol + 5] : null; + $this->position = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 7; // 7 = CcPlayoutHistoryTemplateFieldPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcPlayoutHistoryTemplateField 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->aCcPlayoutHistoryTemplate !== null && $this->template_id !== $this->aCcPlayoutHistoryTemplate->getDbId()) { + $this->aCcPlayoutHistoryTemplate = 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(CcPlayoutHistoryTemplateFieldPeer::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 = CcPlayoutHistoryTemplateFieldPeer::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->aCcPlayoutHistoryTemplate = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcPlayoutHistoryTemplateFieldQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcPlayoutHistoryTemplateFieldPeer::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); + CcPlayoutHistoryTemplateFieldPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcPlayoutHistoryTemplate !== null) { + if ($this->aCcPlayoutHistoryTemplate->isModified() || $this->aCcPlayoutHistoryTemplate->isNew()) { + $affectedRows += $this->aCcPlayoutHistoryTemplate->save($con); + } + $this->setCcPlayoutHistoryTemplate($this->aCcPlayoutHistoryTemplate); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcPlayoutHistoryTemplateFieldPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcPlayoutHistoryTemplateFieldPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_playout_history_template_field_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID)) { + $modifiedColumns[':p' . $index++] = '"template_id"'; + } + if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::NAME)) { + $modifiedColumns[':p' . $index++] = '"name"'; + } + if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::LABEL)) { + $modifiedColumns[':p' . $index++] = '"label"'; + } + if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::TYPE)) { + $modifiedColumns[':p' . $index++] = '"type"'; + } + if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::IS_FILE_MD)) { + $modifiedColumns[':p' . $index++] = '"is_file_md"'; + } + if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::POSITION)) { + $modifiedColumns[':p' . $index++] = '"position"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_playout_history_template_field" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"template_id"': + $stmt->bindValue($identifier, $this->template_id, PDO::PARAM_INT); + break; + case '"name"': + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); + break; + case '"label"': + $stmt->bindValue($identifier, $this->label, PDO::PARAM_STR); + break; + case '"type"': + $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR); + break; + case '"is_file_md"': + $stmt->bindValue($identifier, $this->is_file_md, PDO::PARAM_BOOL); + break; + case '"position"': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcPlayoutHistoryTemplate !== null) { + if (!$this->aCcPlayoutHistoryTemplate->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcPlayoutHistoryTemplate->getValidationFailures()); + } + } + + + if (($retval = CcPlayoutHistoryTemplateFieldPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcPlayoutHistoryTemplateFieldPeer::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->getDbTemplateId(); + break; + case 2: + return $this->getDbName(); + break; + case 3: + return $this->getDbLabel(); + break; + case 4: + return $this->getDbType(); + break; + case 5: + return $this->getDbIsFileMD(); + break; + case 6: + return $this->getDbPosition(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcPlayoutHistoryTemplateField'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcPlayoutHistoryTemplateField'][$this->getPrimaryKey()] = true; + $keys = CcPlayoutHistoryTemplateFieldPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbTemplateId(), + $keys[2] => $this->getDbName(), + $keys[3] => $this->getDbLabel(), + $keys[4] => $this->getDbType(), + $keys[5] => $this->getDbIsFileMD(), + $keys[6] => $this->getDbPosition(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcPlayoutHistoryTemplate) { + $result['CcPlayoutHistoryTemplate'] = $this->aCcPlayoutHistoryTemplate->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcPlayoutHistoryTemplateFieldPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbTemplateId($value); + break; + case 2: + $this->setDbName($value); + break; + case 3: + $this->setDbLabel($value); + break; + case 4: + $this->setDbType($value); + break; + case 5: + $this->setDbIsFileMD($value); + break; + case 6: + $this->setDbPosition($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcPlayoutHistoryTemplateFieldPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbTemplateId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbName($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbLabel($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbType($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbIsFileMD($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbPosition($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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::ID)) $criteria->add(CcPlayoutHistoryTemplateFieldPeer::ID, $this->id); + if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID)) $criteria->add(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, $this->template_id); + if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::NAME)) $criteria->add(CcPlayoutHistoryTemplateFieldPeer::NAME, $this->name); + if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::LABEL)) $criteria->add(CcPlayoutHistoryTemplateFieldPeer::LABEL, $this->label); + if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::TYPE)) $criteria->add(CcPlayoutHistoryTemplateFieldPeer::TYPE, $this->type); + if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::IS_FILE_MD)) $criteria->add(CcPlayoutHistoryTemplateFieldPeer::IS_FILE_MD, $this->is_file_md); + if ($this->isColumnModified(CcPlayoutHistoryTemplateFieldPeer::POSITION)) $criteria->add(CcPlayoutHistoryTemplateFieldPeer::POSITION, $this->position); + + 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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); + $criteria->add(CcPlayoutHistoryTemplateFieldPeer::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 CcPlayoutHistoryTemplateField (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbTemplateId($this->getDbTemplateId()); + $copyObj->setDbName($this->getDbName()); + $copyObj->setDbLabel($this->getDbLabel()); + $copyObj->setDbType($this->getDbType()); + $copyObj->setDbIsFileMD($this->getDbIsFileMD()); + $copyObj->setDbPosition($this->getDbPosition()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcPlayoutHistoryTemplateField 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 CcPlayoutHistoryTemplateFieldPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcPlayoutHistoryTemplateFieldPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a CcPlayoutHistoryTemplate object. + * + * @param CcPlayoutHistoryTemplate $v + * @return CcPlayoutHistoryTemplateField The current object (for fluent API support) + * @throws PropelException + */ + public function setCcPlayoutHistoryTemplate(CcPlayoutHistoryTemplate $v = null) + { + if ($v === null) { + $this->setDbTemplateId(NULL); + } else { + $this->setDbTemplateId($v->getDbId()); + } + + $this->aCcPlayoutHistoryTemplate = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcPlayoutHistoryTemplate object, it will not be re-added. + if ($v !== null) { + $v->addCcPlayoutHistoryTemplateField($this); + } + + + return $this; + } + + + /** + * Get the associated CcPlayoutHistoryTemplate object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcPlayoutHistoryTemplate The associated CcPlayoutHistoryTemplate object. + * @throws PropelException + */ + public function getCcPlayoutHistoryTemplate(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcPlayoutHistoryTemplate === null && ($this->template_id !== null) && $doQuery) { + $this->aCcPlayoutHistoryTemplate = CcPlayoutHistoryTemplateQuery::create()->findPk($this->template_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->aCcPlayoutHistoryTemplate->addCcPlayoutHistoryTemplateFields($this); + */ + } + + return $this->aCcPlayoutHistoryTemplate; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->template_id = null; + $this->name = null; + $this->label = null; + $this->type = null; + $this->is_file_md = null; + $this->position = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCcPlayoutHistoryTemplate instanceof Persistent) { + $this->aCcPlayoutHistoryTemplate->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + $this->aCcPlayoutHistoryTemplate = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcPlayoutHistoryTemplateFieldPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateFieldPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateFieldPeer.php index 91586fa1d..783bb9388 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateFieldPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateFieldPeer.php @@ -1,994 +1,1033 @@ array ('DbId', 'DbTemplateId', 'DbName', 'DbLabel', 'DbType', 'DbIsFileMD', 'DbPosition', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbTemplateId', 'dbName', 'dbLabel', 'dbType', 'dbIsFileMD', 'dbPosition', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::TEMPLATE_ID, self::NAME, self::LABEL, self::TYPE, self::IS_FILE_MD, self::POSITION, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TEMPLATE_ID', 'NAME', 'LABEL', 'TYPE', 'IS_FILE_MD', 'POSITION', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'template_id', 'name', 'label', 'type', 'is_file_md', 'position', ), - 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 ('DbId' => 0, 'DbTemplateId' => 1, 'DbName' => 2, 'DbLabel' => 3, 'DbType' => 4, 'DbIsFileMD' => 5, 'DbPosition' => 6, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbTemplateId' => 1, 'dbName' => 2, 'dbLabel' => 3, 'dbType' => 4, 'dbIsFileMD' => 5, 'dbPosition' => 6, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::TEMPLATE_ID => 1, self::NAME => 2, self::LABEL => 3, self::TYPE => 4, self::IS_FILE_MD => 5, self::POSITION => 6, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TEMPLATE_ID' => 1, 'NAME' => 2, 'LABEL' => 3, 'TYPE' => 4, 'IS_FILE_MD' => 5, 'POSITION' => 6, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'template_id' => 1, 'name' => 2, 'label' => 3, 'type' => 4, 'is_file_md' => 5, 'position' => 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. CcPlayoutHistoryTemplateFieldPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcPlayoutHistoryTemplateFieldPeer::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(CcPlayoutHistoryTemplateFieldPeer::ID); - $criteria->addSelectColumn(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID); - $criteria->addSelectColumn(CcPlayoutHistoryTemplateFieldPeer::NAME); - $criteria->addSelectColumn(CcPlayoutHistoryTemplateFieldPeer::LABEL); - $criteria->addSelectColumn(CcPlayoutHistoryTemplateFieldPeer::TYPE); - $criteria->addSelectColumn(CcPlayoutHistoryTemplateFieldPeer::IS_FILE_MD); - $criteria->addSelectColumn(CcPlayoutHistoryTemplateFieldPeer::POSITION); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.TEMPLATE_ID'); - $criteria->addSelectColumn($alias . '.NAME'); - $criteria->addSelectColumn($alias . '.LABEL'); - $criteria->addSelectColumn($alias . '.TYPE'); - $criteria->addSelectColumn($alias . '.IS_FILE_MD'); - $criteria->addSelectColumn($alias . '.POSITION'); - } - } - - /** - * 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(CcPlayoutHistoryTemplateFieldPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcPlayoutHistoryTemplateFieldPeer::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(CcPlayoutHistoryTemplateFieldPeer::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 CcPlayoutHistoryTemplateField - * @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 = CcPlayoutHistoryTemplateFieldPeer::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 CcPlayoutHistoryTemplateFieldPeer::populateObjects(CcPlayoutHistoryTemplateFieldPeer::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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcPlayoutHistoryTemplateFieldPeer::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 CcPlayoutHistoryTemplateField $value A CcPlayoutHistoryTemplateField object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcPlayoutHistoryTemplateField $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 CcPlayoutHistoryTemplateField object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcPlayoutHistoryTemplateField) { - $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 CcPlayoutHistoryTemplateField 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 CcPlayoutHistoryTemplateField 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_playout_history_template_field - * 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 = CcPlayoutHistoryTemplateFieldPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcPlayoutHistoryTemplateFieldPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcPlayoutHistoryTemplateFieldPeer::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; - CcPlayoutHistoryTemplateFieldPeer::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 (CcPlayoutHistoryTemplateField object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcPlayoutHistoryTemplateFieldPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcPlayoutHistoryTemplateFieldPeer::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 + CcPlayoutHistoryTemplateFieldPeer::NUM_COLUMNS; - } else { - $cls = CcPlayoutHistoryTemplateFieldPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcPlayoutHistoryTemplateFieldPeer::addInstanceToPool($obj, $key); - } - return array($obj, $col); - } - - /** - * Returns the number of rows matching criteria, joining the related CcPlayoutHistoryTemplate 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 doCountJoinCcPlayoutHistoryTemplate(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(CcPlayoutHistoryTemplateFieldPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcPlayoutHistoryTemplateFieldPeer::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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, CcPlayoutHistoryTemplatePeer::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 CcPlayoutHistoryTemplateField objects pre-filled with their CcPlayoutHistoryTemplate 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 CcPlayoutHistoryTemplateField objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCcPlayoutHistoryTemplate(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); - } - - CcPlayoutHistoryTemplateFieldPeer::addSelectColumns($criteria); - $startcol = (CcPlayoutHistoryTemplateFieldPeer::NUM_COLUMNS - CcPlayoutHistoryTemplateFieldPeer::NUM_LAZY_LOAD_COLUMNS); - CcPlayoutHistoryTemplatePeer::addSelectColumns($criteria); - - $criteria->addJoin(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, CcPlayoutHistoryTemplatePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcPlayoutHistoryTemplateFieldPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcPlayoutHistoryTemplateFieldPeer::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 = CcPlayoutHistoryTemplateFieldPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcPlayoutHistoryTemplateFieldPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CcPlayoutHistoryTemplatePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcPlayoutHistoryTemplatePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcPlayoutHistoryTemplatePeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcPlayoutHistoryTemplatePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcPlayoutHistoryTemplateField) to $obj2 (CcPlayoutHistoryTemplate) - $obj2->addCcPlayoutHistoryTemplateField($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(CcPlayoutHistoryTemplateFieldPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcPlayoutHistoryTemplateFieldPeer::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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, CcPlayoutHistoryTemplatePeer::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 CcPlayoutHistoryTemplateField 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 CcPlayoutHistoryTemplateField 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); - } - - CcPlayoutHistoryTemplateFieldPeer::addSelectColumns($criteria); - $startcol2 = (CcPlayoutHistoryTemplateFieldPeer::NUM_COLUMNS - CcPlayoutHistoryTemplateFieldPeer::NUM_LAZY_LOAD_COLUMNS); - - CcPlayoutHistoryTemplatePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcPlayoutHistoryTemplatePeer::NUM_COLUMNS - CcPlayoutHistoryTemplatePeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, CcPlayoutHistoryTemplatePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcPlayoutHistoryTemplateFieldPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcPlayoutHistoryTemplateFieldPeer::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 = CcPlayoutHistoryTemplateFieldPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcPlayoutHistoryTemplateFieldPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcPlayoutHistoryTemplate rows - - $key2 = CcPlayoutHistoryTemplatePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcPlayoutHistoryTemplatePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcPlayoutHistoryTemplatePeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcPlayoutHistoryTemplatePeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (CcPlayoutHistoryTemplateField) to the collection in $obj2 (CcPlayoutHistoryTemplate) - $obj2->addCcPlayoutHistoryTemplateField($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(BaseCcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcPlayoutHistoryTemplateFieldPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcPlayoutHistoryTemplateFieldTableMap()); - } - } - - /** - * 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 ? CcPlayoutHistoryTemplateFieldPeer::CLASS_DEFAULT : CcPlayoutHistoryTemplateFieldPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcPlayoutHistoryTemplateField or Criteria object. - * - * @param mixed $values Criteria or CcPlayoutHistoryTemplateField 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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcPlayoutHistoryTemplateField object - } - - if ($criteria->containsKey(CcPlayoutHistoryTemplateFieldPeer::ID) && $criteria->keyContainsValue(CcPlayoutHistoryTemplateFieldPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlayoutHistoryTemplateFieldPeer::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 CcPlayoutHistoryTemplateField or Criteria object. - * - * @param mixed $values Criteria or CcPlayoutHistoryTemplateField 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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcPlayoutHistoryTemplateFieldPeer::ID); - $value = $criteria->remove(CcPlayoutHistoryTemplateFieldPeer::ID); - if ($value) { - $selectCriteria->add(CcPlayoutHistoryTemplateFieldPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcPlayoutHistoryTemplateFieldPeer::TABLE_NAME); - } - - } else { // $values is CcPlayoutHistoryTemplateField 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_playout_history_template_field 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(CcPlayoutHistoryTemplateFieldPeer::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(CcPlayoutHistoryTemplateFieldPeer::TABLE_NAME, $con, CcPlayoutHistoryTemplateFieldPeer::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). - CcPlayoutHistoryTemplateFieldPeer::clearInstancePool(); - CcPlayoutHistoryTemplateFieldPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcPlayoutHistoryTemplateField or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcPlayoutHistoryTemplateField 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(CcPlayoutHistoryTemplateFieldPeer::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. - CcPlayoutHistoryTemplateFieldPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcPlayoutHistoryTemplateField) { // it's a model object - // invalidate the cache for this single object - CcPlayoutHistoryTemplateFieldPeer::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(CcPlayoutHistoryTemplateFieldPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcPlayoutHistoryTemplateFieldPeer::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); - CcPlayoutHistoryTemplateFieldPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcPlayoutHistoryTemplateField 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 CcPlayoutHistoryTemplateField $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(CcPlayoutHistoryTemplateField $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcPlayoutHistoryTemplateFieldPeer::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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, CcPlayoutHistoryTemplateFieldPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcPlayoutHistoryTemplateField - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcPlayoutHistoryTemplateFieldPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); - $criteria->add(CcPlayoutHistoryTemplateFieldPeer::ID, $pk); - - $v = CcPlayoutHistoryTemplateFieldPeer::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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); - $criteria->add(CcPlayoutHistoryTemplateFieldPeer::ID, $pks, Criteria::IN); - $objs = CcPlayoutHistoryTemplateFieldPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcPlayoutHistoryTemplateFieldPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_playout_history_template_field'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\PlayoutHistory\\CcPlayoutHistoryTemplateField'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\PlayoutHistory\\map\\CcPlayoutHistoryTemplateFieldTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 7; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 7; + + /** the column name for the id field */ + const ID = 'cc_playout_history_template_field.id'; + + /** the column name for the template_id field */ + const TEMPLATE_ID = 'cc_playout_history_template_field.template_id'; + + /** the column name for the name field */ + const NAME = 'cc_playout_history_template_field.name'; + + /** the column name for the label field */ + const LABEL = 'cc_playout_history_template_field.label'; + + /** the column name for the type field */ + const TYPE = 'cc_playout_history_template_field.type'; + + /** the column name for the is_file_md field */ + const IS_FILE_MD = 'cc_playout_history_template_field.is_file_md'; + + /** the column name for the position field */ + const POSITION = 'cc_playout_history_template_field.position'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcPlayoutHistoryTemplateField objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcPlayoutHistoryTemplateField[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcPlayoutHistoryTemplateFieldPeer::$fieldNames[CcPlayoutHistoryTemplateFieldPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbTemplateId', 'DbName', 'DbLabel', 'DbType', 'DbIsFileMD', 'DbPosition', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbTemplateId', 'dbName', 'dbLabel', 'dbType', 'dbIsFileMD', 'dbPosition', ), + BasePeer::TYPE_COLNAME => array (CcPlayoutHistoryTemplateFieldPeer::ID, CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, CcPlayoutHistoryTemplateFieldPeer::NAME, CcPlayoutHistoryTemplateFieldPeer::LABEL, CcPlayoutHistoryTemplateFieldPeer::TYPE, CcPlayoutHistoryTemplateFieldPeer::IS_FILE_MD, CcPlayoutHistoryTemplateFieldPeer::POSITION, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TEMPLATE_ID', 'NAME', 'LABEL', 'TYPE', 'IS_FILE_MD', 'POSITION', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'template_id', 'name', 'label', 'type', 'is_file_md', 'position', ), + 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. CcPlayoutHistoryTemplateFieldPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbTemplateId' => 1, 'DbName' => 2, 'DbLabel' => 3, 'DbType' => 4, 'DbIsFileMD' => 5, 'DbPosition' => 6, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbTemplateId' => 1, 'dbName' => 2, 'dbLabel' => 3, 'dbType' => 4, 'dbIsFileMD' => 5, 'dbPosition' => 6, ), + BasePeer::TYPE_COLNAME => array (CcPlayoutHistoryTemplateFieldPeer::ID => 0, CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID => 1, CcPlayoutHistoryTemplateFieldPeer::NAME => 2, CcPlayoutHistoryTemplateFieldPeer::LABEL => 3, CcPlayoutHistoryTemplateFieldPeer::TYPE => 4, CcPlayoutHistoryTemplateFieldPeer::IS_FILE_MD => 5, CcPlayoutHistoryTemplateFieldPeer::POSITION => 6, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TEMPLATE_ID' => 1, 'NAME' => 2, 'LABEL' => 3, 'TYPE' => 4, 'IS_FILE_MD' => 5, 'POSITION' => 6, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'template_id' => 1, 'name' => 2, 'label' => 3, 'type' => 4, 'is_file_md' => 5, 'position' => 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcPlayoutHistoryTemplateFieldPeer::getFieldNames($toType); + $key = isset(CcPlayoutHistoryTemplateFieldPeer::$fieldKeys[$fromType][$name]) ? CcPlayoutHistoryTemplateFieldPeer::$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(CcPlayoutHistoryTemplateFieldPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcPlayoutHistoryTemplateFieldPeer::$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 CcPlayoutHistoryTemplateFieldPeer::$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. CcPlayoutHistoryTemplateFieldPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcPlayoutHistoryTemplateFieldPeer::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(CcPlayoutHistoryTemplateFieldPeer::ID); + $criteria->addSelectColumn(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID); + $criteria->addSelectColumn(CcPlayoutHistoryTemplateFieldPeer::NAME); + $criteria->addSelectColumn(CcPlayoutHistoryTemplateFieldPeer::LABEL); + $criteria->addSelectColumn(CcPlayoutHistoryTemplateFieldPeer::TYPE); + $criteria->addSelectColumn(CcPlayoutHistoryTemplateFieldPeer::IS_FILE_MD); + $criteria->addSelectColumn(CcPlayoutHistoryTemplateFieldPeer::POSITION); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.template_id'); + $criteria->addSelectColumn($alias . '.name'); + $criteria->addSelectColumn($alias . '.label'); + $criteria->addSelectColumn($alias . '.type'); + $criteria->addSelectColumn($alias . '.is_file_md'); + $criteria->addSelectColumn($alias . '.position'); + } + } + + /** + * 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(CcPlayoutHistoryTemplateFieldPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlayoutHistoryTemplateFieldPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryTemplateFieldPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcPlayoutHistoryTemplateField + * @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 = CcPlayoutHistoryTemplateFieldPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcPlayoutHistoryTemplateFieldPeer::populateObjects(CcPlayoutHistoryTemplateFieldPeer::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 directly (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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcPlayoutHistoryTemplateFieldPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryTemplateFieldPeer::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 CcPlayoutHistoryTemplateField $obj A CcPlayoutHistoryTemplateField object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcPlayoutHistoryTemplateFieldPeer::$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 CcPlayoutHistoryTemplateField object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcPlayoutHistoryTemplateField) { + $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 CcPlayoutHistoryTemplateField object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcPlayoutHistoryTemplateFieldPeer::$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 CcPlayoutHistoryTemplateField 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(CcPlayoutHistoryTemplateFieldPeer::$instances[$key])) { + return CcPlayoutHistoryTemplateFieldPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcPlayoutHistoryTemplateFieldPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcPlayoutHistoryTemplateFieldPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_playout_history_template_field + * 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 = CcPlayoutHistoryTemplateFieldPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcPlayoutHistoryTemplateFieldPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcPlayoutHistoryTemplateFieldPeer::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; + CcPlayoutHistoryTemplateFieldPeer::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 (CcPlayoutHistoryTemplateField object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcPlayoutHistoryTemplateFieldPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcPlayoutHistoryTemplateFieldPeer::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 + CcPlayoutHistoryTemplateFieldPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcPlayoutHistoryTemplateFieldPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcPlayoutHistoryTemplateFieldPeer::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + + /** + * Returns the number of rows matching criteria, joining the related CcPlayoutHistoryTemplate 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 doCountJoinCcPlayoutHistoryTemplate(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(CcPlayoutHistoryTemplateFieldPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlayoutHistoryTemplateFieldPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, CcPlayoutHistoryTemplatePeer::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 CcPlayoutHistoryTemplateField objects pre-filled with their CcPlayoutHistoryTemplate 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 CcPlayoutHistoryTemplateField objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcPlayoutHistoryTemplate(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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); + } + + CcPlayoutHistoryTemplateFieldPeer::addSelectColumns($criteria); + $startcol = CcPlayoutHistoryTemplateFieldPeer::NUM_HYDRATE_COLUMNS; + CcPlayoutHistoryTemplatePeer::addSelectColumns($criteria); + + $criteria->addJoin(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, CcPlayoutHistoryTemplatePeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPlayoutHistoryTemplateFieldPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPlayoutHistoryTemplateFieldPeer::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 = CcPlayoutHistoryTemplateFieldPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlayoutHistoryTemplateFieldPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcPlayoutHistoryTemplatePeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcPlayoutHistoryTemplatePeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcPlayoutHistoryTemplatePeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcPlayoutHistoryTemplatePeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcPlayoutHistoryTemplateField) to $obj2 (CcPlayoutHistoryTemplate) + $obj2->addCcPlayoutHistoryTemplateField($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(CcPlayoutHistoryTemplateFieldPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlayoutHistoryTemplateFieldPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, CcPlayoutHistoryTemplatePeer::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 CcPlayoutHistoryTemplateField 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 CcPlayoutHistoryTemplateField 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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); + } + + CcPlayoutHistoryTemplateFieldPeer::addSelectColumns($criteria); + $startcol2 = CcPlayoutHistoryTemplateFieldPeer::NUM_HYDRATE_COLUMNS; + + CcPlayoutHistoryTemplatePeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcPlayoutHistoryTemplatePeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, CcPlayoutHistoryTemplatePeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcPlayoutHistoryTemplateFieldPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcPlayoutHistoryTemplateFieldPeer::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 = CcPlayoutHistoryTemplateFieldPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcPlayoutHistoryTemplateFieldPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcPlayoutHistoryTemplate rows + + $key2 = CcPlayoutHistoryTemplatePeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcPlayoutHistoryTemplatePeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcPlayoutHistoryTemplatePeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcPlayoutHistoryTemplatePeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcPlayoutHistoryTemplateField) to the collection in $obj2 (CcPlayoutHistoryTemplate) + $obj2->addCcPlayoutHistoryTemplateField($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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME)->getTable(CcPlayoutHistoryTemplateFieldPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcPlayoutHistoryTemplateFieldPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\PlayoutHistory\map\CcPlayoutHistoryTemplateFieldTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcPlayoutHistoryTemplateFieldPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcPlayoutHistoryTemplateField or Criteria object. + * + * @param mixed $values Criteria or CcPlayoutHistoryTemplateField 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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcPlayoutHistoryTemplateField object + } + + if ($criteria->containsKey(CcPlayoutHistoryTemplateFieldPeer::ID) && $criteria->keyContainsValue(CcPlayoutHistoryTemplateFieldPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlayoutHistoryTemplateFieldPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryTemplateFieldPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcPlayoutHistoryTemplateField or Criteria object. + * + * @param mixed $values Criteria or CcPlayoutHistoryTemplateField 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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcPlayoutHistoryTemplateFieldPeer::ID); + $value = $criteria->remove(CcPlayoutHistoryTemplateFieldPeer::ID); + if ($value) { + $selectCriteria->add(CcPlayoutHistoryTemplateFieldPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcPlayoutHistoryTemplateFieldPeer::TABLE_NAME); + } + + } else { // $values is CcPlayoutHistoryTemplateField object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_playout_history_template_field table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryTemplateFieldPeer::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(CcPlayoutHistoryTemplateFieldPeer::TABLE_NAME, $con, CcPlayoutHistoryTemplateFieldPeer::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). + CcPlayoutHistoryTemplateFieldPeer::clearInstancePool(); + CcPlayoutHistoryTemplateFieldPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcPlayoutHistoryTemplateField or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcPlayoutHistoryTemplateField 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(CcPlayoutHistoryTemplateFieldPeer::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. + CcPlayoutHistoryTemplateFieldPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcPlayoutHistoryTemplateField) { // it's a model object + // invalidate the cache for this single object + CcPlayoutHistoryTemplateFieldPeer::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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); + $criteria->add(CcPlayoutHistoryTemplateFieldPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcPlayoutHistoryTemplateFieldPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryTemplateFieldPeer::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); + CcPlayoutHistoryTemplateFieldPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcPlayoutHistoryTemplateField 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 CcPlayoutHistoryTemplateField $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcPlayoutHistoryTemplateFieldPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, CcPlayoutHistoryTemplateFieldPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcPlayoutHistoryTemplateField + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcPlayoutHistoryTemplateFieldPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); + $criteria->add(CcPlayoutHistoryTemplateFieldPeer::ID, $pk); + + $v = CcPlayoutHistoryTemplateFieldPeer::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 + * @return CcPlayoutHistoryTemplateField[] + * @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(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME); + $criteria->add(CcPlayoutHistoryTemplateFieldPeer::ID, $pks, Criteria::IN); + $objs = CcPlayoutHistoryTemplateFieldPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcPlayoutHistoryTemplateFieldPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateFieldQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateFieldQuery.php index 2bccd58ca..f123e0847 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateFieldQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateFieldQuery.php @@ -1,402 +1,596 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcPlayoutHistoryTemplateField|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcPlayoutHistoryTemplateFieldPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcPlayoutHistoryTemplateField|CcPlayoutHistoryTemplateField[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcPlayoutHistoryTemplateFieldPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryTemplateFieldPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlayoutHistoryTemplateField A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlayoutHistoryTemplateField A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "template_id", "name", "label", "type", "is_file_md", "position" FROM "cc_playout_history_template_field" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcPlayoutHistoryTemplateField(); + $obj->hydrate($row); + CcPlayoutHistoryTemplateFieldPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcPlayoutHistoryTemplateFieldQuery 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(CcPlayoutHistoryTemplateFieldPeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * Filter the query on the template_id column - * - * @param int|array $dbTemplateId 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 CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface - */ - public function filterByDbTemplateId($dbTemplateId = null, $comparison = null) - { - if (is_array($dbTemplateId)) { - $useMinMax = false; - if (isset($dbTemplateId['min'])) { - $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, $dbTemplateId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbTemplateId['max'])) { - $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, $dbTemplateId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, $dbTemplateId, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlayoutHistoryTemplateField|CcPlayoutHistoryTemplateField[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * 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 CcPlayoutHistoryTemplateFieldQuery 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(CcPlayoutHistoryTemplateFieldPeer::NAME, $dbName, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query on the label column - * - * @param string $dbLabel 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 CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface - */ - public function filterByDbLabel($dbLabel = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbLabel)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbLabel)) { - $dbLabel = str_replace('*', '%', $dbLabel); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::LABEL, $dbLabel, $comparison); - } + /** + * 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|CcPlayoutHistoryTemplateField[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query on the type column - * - * @param string $dbType The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface - */ - public function filterByDbType($dbType = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbType)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbType)) { - $dbType = str_replace('*', '%', $dbType); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::TYPE, $dbType, $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Filter the query on the is_file_md column - * - * @param boolean|string $dbIsFileMD The value to use as filter. - * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface - */ - public function filterByDbIsFileMD($dbIsFileMD = null, $comparison = null) - { - if (is_string($dbIsFileMD)) { - $is_file_md = in_array(strtolower($dbIsFileMD), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; - } - return $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::IS_FILE_MD, $dbIsFileMD, $comparison); - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { - /** - * 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 CcPlayoutHistoryTemplateFieldQuery 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(CcPlayoutHistoryTemplateFieldPeer::POSITION, $dbPosition['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbPosition['max'])) { - $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::POSITION, $dbPosition['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::POSITION, $dbPosition, $comparison); - } + return $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::ID, $key, Criteria::EQUAL); + } - /** - * Filter the query by a related CcPlayoutHistoryTemplate object - * - * @param CcPlayoutHistoryTemplate $ccPlayoutHistoryTemplate the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface - */ - public function filterByCcPlayoutHistoryTemplate($ccPlayoutHistoryTemplate, $comparison = null) - { - return $this - ->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, $ccPlayoutHistoryTemplate->getDbId(), $comparison); - } + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { - /** - * Adds a JOIN clause to the query using the CcPlayoutHistoryTemplate relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface - */ - public function joinCcPlayoutHistoryTemplate($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcPlayoutHistoryTemplate'); - - // 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, 'CcPlayoutHistoryTemplate'); - } - - return $this; - } + return $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::ID, $keys, Criteria::IN); + } - /** - * Use the CcPlayoutHistoryTemplate relation CcPlayoutHistoryTemplate 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 CcPlayoutHistoryTemplateQuery A secondary query class using the current class as primary query - */ - public function useCcPlayoutHistoryTemplateQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcPlayoutHistoryTemplate($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcPlayoutHistoryTemplate', 'CcPlayoutHistoryTemplateQuery'); - } + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Exclude object from result - * - * @param CcPlayoutHistoryTemplateField $ccPlayoutHistoryTemplateField Object to remove from the list of results - * - * @return CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface - */ - public function prune($ccPlayoutHistoryTemplateField = null) - { - if ($ccPlayoutHistoryTemplateField) { - $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::ID, $ccPlayoutHistoryTemplateField->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + return $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::ID, $dbId, $comparison); + } -} // BaseCcPlayoutHistoryTemplateFieldQuery + /** + * Filter the query on the template_id column + * + * Example usage: + * + * $query->filterByDbTemplateId(1234); // WHERE template_id = 1234 + * $query->filterByDbTemplateId(array(12, 34)); // WHERE template_id IN (12, 34) + * $query->filterByDbTemplateId(array('min' => 12)); // WHERE template_id >= 12 + * $query->filterByDbTemplateId(array('max' => 12)); // WHERE template_id <= 12 + * + * + * @see filterByCcPlayoutHistoryTemplate() + * + * @param mixed $dbTemplateId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface + */ + public function filterByDbTemplateId($dbTemplateId = null, $comparison = null) + { + if (is_array($dbTemplateId)) { + $useMinMax = false; + if (isset($dbTemplateId['min'])) { + $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, $dbTemplateId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbTemplateId['max'])) { + $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, $dbTemplateId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, $dbTemplateId, $comparison); + } + + /** + * Filter the query on the name column + * + * Example usage: + * + * $query->filterByDbName('fooValue'); // WHERE name = 'fooValue' + * $query->filterByDbName('%fooValue%'); // WHERE name LIKE '%fooValue%' + * + * + * @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 CcPlayoutHistoryTemplateFieldQuery 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(CcPlayoutHistoryTemplateFieldPeer::NAME, $dbName, $comparison); + } + + /** + * Filter the query on the label column + * + * Example usage: + * + * $query->filterByDbLabel('fooValue'); // WHERE label = 'fooValue' + * $query->filterByDbLabel('%fooValue%'); // WHERE label LIKE '%fooValue%' + * + * + * @param string $dbLabel 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 CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface + */ + public function filterByDbLabel($dbLabel = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLabel)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLabel)) { + $dbLabel = str_replace('*', '%', $dbLabel); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::LABEL, $dbLabel, $comparison); + } + + /** + * Filter the query on the type column + * + * Example usage: + * + * $query->filterByDbType('fooValue'); // WHERE type = 'fooValue' + * $query->filterByDbType('%fooValue%'); // WHERE type LIKE '%fooValue%' + * + * + * @param string $dbType The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface + */ + public function filterByDbType($dbType = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbType)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbType)) { + $dbType = str_replace('*', '%', $dbType); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::TYPE, $dbType, $comparison); + } + + /** + * Filter the query on the is_file_md column + * + * Example usage: + * + * $query->filterByDbIsFileMD(true); // WHERE is_file_md = true + * $query->filterByDbIsFileMD('yes'); // WHERE is_file_md = true + * + * + * @param boolean|string $dbIsFileMD The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface + */ + public function filterByDbIsFileMD($dbIsFileMD = null, $comparison = null) + { + if (is_string($dbIsFileMD)) { + $dbIsFileMD = in_array(strtolower($dbIsFileMD), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::IS_FILE_MD, $dbIsFileMD, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByDbPosition(1234); // WHERE position = 1234 + * $query->filterByDbPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByDbPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByDbPosition(array('max' => 12)); // WHERE position <= 12 + * + * + * @param mixed $dbPosition The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryTemplateFieldQuery 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(CcPlayoutHistoryTemplateFieldPeer::POSITION, $dbPosition['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbPosition['max'])) { + $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::POSITION, $dbPosition['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::POSITION, $dbPosition, $comparison); + } + + /** + * Filter the query by a related CcPlayoutHistoryTemplate object + * + * @param CcPlayoutHistoryTemplate|PropelObjectCollection $ccPlayoutHistoryTemplate The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcPlayoutHistoryTemplate($ccPlayoutHistoryTemplate, $comparison = null) + { + if ($ccPlayoutHistoryTemplate instanceof CcPlayoutHistoryTemplate) { + return $this + ->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, $ccPlayoutHistoryTemplate->getDbId(), $comparison); + } elseif ($ccPlayoutHistoryTemplate instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::TEMPLATE_ID, $ccPlayoutHistoryTemplate->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcPlayoutHistoryTemplate() only accepts arguments of type CcPlayoutHistoryTemplate or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcPlayoutHistoryTemplate relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface + */ + public function joinCcPlayoutHistoryTemplate($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcPlayoutHistoryTemplate'); + + // 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, 'CcPlayoutHistoryTemplate'); + } + + return $this; + } + + /** + * Use the CcPlayoutHistoryTemplate relation CcPlayoutHistoryTemplate 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 \Airtime\PlayoutHistory\CcPlayoutHistoryTemplateQuery A secondary query class using the current class as primary query + */ + public function useCcPlayoutHistoryTemplateQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcPlayoutHistoryTemplate($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPlayoutHistoryTemplate', '\Airtime\PlayoutHistory\CcPlayoutHistoryTemplateQuery'); + } + + /** + * Exclude object from result + * + * @param CcPlayoutHistoryTemplateField $ccPlayoutHistoryTemplateField Object to remove from the list of results + * + * @return CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface + */ + public function prune($ccPlayoutHistoryTemplateField = null) + { + if ($ccPlayoutHistoryTemplateField) { + $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::ID, $ccPlayoutHistoryTemplateField->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplatePeer.php b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplatePeer.php index 9e1d216f1..b2bb4f9d7 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplatePeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplatePeer.php @@ -1,743 +1,778 @@ array ('DbId', 'DbName', 'DbType', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbType', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::TYPE, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'TYPE', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'type', ), - BasePeer::TYPE_NUM => array (0, 1, 2, ) - ); - - /** - * 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, 'DbType' => 2, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbType' => 2, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::TYPE => 2, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'TYPE' => 2, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'type' => 2, ), - BasePeer::TYPE_NUM => array (0, 1, 2, ) - ); - - /** - * 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. CcPlayoutHistoryTemplatePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcPlayoutHistoryTemplatePeer::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(CcPlayoutHistoryTemplatePeer::ID); - $criteria->addSelectColumn(CcPlayoutHistoryTemplatePeer::NAME); - $criteria->addSelectColumn(CcPlayoutHistoryTemplatePeer::TYPE); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.NAME'); - $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(CcPlayoutHistoryTemplatePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcPlayoutHistoryTemplatePeer::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(CcPlayoutHistoryTemplatePeer::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 CcPlayoutHistoryTemplate - * @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 = CcPlayoutHistoryTemplatePeer::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 CcPlayoutHistoryTemplatePeer::populateObjects(CcPlayoutHistoryTemplatePeer::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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcPlayoutHistoryTemplatePeer::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 CcPlayoutHistoryTemplate $value A CcPlayoutHistoryTemplate object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcPlayoutHistoryTemplate $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 CcPlayoutHistoryTemplate object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcPlayoutHistoryTemplate) { - $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 CcPlayoutHistoryTemplate 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 CcPlayoutHistoryTemplate 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_playout_history_template - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in CcPlayoutHistoryTemplateFieldPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcPlayoutHistoryTemplateFieldPeer::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 = CcPlayoutHistoryTemplatePeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcPlayoutHistoryTemplatePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcPlayoutHistoryTemplatePeer::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; - CcPlayoutHistoryTemplatePeer::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 (CcPlayoutHistoryTemplate object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcPlayoutHistoryTemplatePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcPlayoutHistoryTemplatePeer::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 + CcPlayoutHistoryTemplatePeer::NUM_COLUMNS; - } else { - $cls = CcPlayoutHistoryTemplatePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcPlayoutHistoryTemplatePeer::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(BaseCcPlayoutHistoryTemplatePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcPlayoutHistoryTemplatePeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcPlayoutHistoryTemplateTableMap()); - } - } - - /** - * 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 ? CcPlayoutHistoryTemplatePeer::CLASS_DEFAULT : CcPlayoutHistoryTemplatePeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcPlayoutHistoryTemplate or Criteria object. - * - * @param mixed $values Criteria or CcPlayoutHistoryTemplate 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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcPlayoutHistoryTemplate object - } - - if ($criteria->containsKey(CcPlayoutHistoryTemplatePeer::ID) && $criteria->keyContainsValue(CcPlayoutHistoryTemplatePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlayoutHistoryTemplatePeer::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 CcPlayoutHistoryTemplate or Criteria object. - * - * @param mixed $values Criteria or CcPlayoutHistoryTemplate 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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcPlayoutHistoryTemplatePeer::ID); - $value = $criteria->remove(CcPlayoutHistoryTemplatePeer::ID); - if ($value) { - $selectCriteria->add(CcPlayoutHistoryTemplatePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcPlayoutHistoryTemplatePeer::TABLE_NAME); - } - - } else { // $values is CcPlayoutHistoryTemplate 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_playout_history_template 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(CcPlayoutHistoryTemplatePeer::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(CcPlayoutHistoryTemplatePeer::TABLE_NAME, $con, CcPlayoutHistoryTemplatePeer::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). - CcPlayoutHistoryTemplatePeer::clearInstancePool(); - CcPlayoutHistoryTemplatePeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcPlayoutHistoryTemplate or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcPlayoutHistoryTemplate 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(CcPlayoutHistoryTemplatePeer::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. - CcPlayoutHistoryTemplatePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcPlayoutHistoryTemplate) { // it's a model object - // invalidate the cache for this single object - CcPlayoutHistoryTemplatePeer::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(CcPlayoutHistoryTemplatePeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcPlayoutHistoryTemplatePeer::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); - CcPlayoutHistoryTemplatePeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcPlayoutHistoryTemplate 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 CcPlayoutHistoryTemplate $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(CcPlayoutHistoryTemplate $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcPlayoutHistoryTemplatePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcPlayoutHistoryTemplatePeer::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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, CcPlayoutHistoryTemplatePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcPlayoutHistoryTemplate - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcPlayoutHistoryTemplatePeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcPlayoutHistoryTemplatePeer::DATABASE_NAME); - $criteria->add(CcPlayoutHistoryTemplatePeer::ID, $pk); - - $v = CcPlayoutHistoryTemplatePeer::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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcPlayoutHistoryTemplatePeer::DATABASE_NAME); - $criteria->add(CcPlayoutHistoryTemplatePeer::ID, $pks, Criteria::IN); - $objs = CcPlayoutHistoryTemplatePeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcPlayoutHistoryTemplatePeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_playout_history_template'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\PlayoutHistory\\CcPlayoutHistoryTemplate'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\PlayoutHistory\\map\\CcPlayoutHistoryTemplateTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 3; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 3; + + /** the column name for the id field */ + const ID = 'cc_playout_history_template.id'; + + /** the column name for the name field */ + const NAME = 'cc_playout_history_template.name'; + + /** the column name for the type field */ + const TYPE = 'cc_playout_history_template.type'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcPlayoutHistoryTemplate objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcPlayoutHistoryTemplate[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcPlayoutHistoryTemplatePeer::$fieldNames[CcPlayoutHistoryTemplatePeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbType', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbType', ), + BasePeer::TYPE_COLNAME => array (CcPlayoutHistoryTemplatePeer::ID, CcPlayoutHistoryTemplatePeer::NAME, CcPlayoutHistoryTemplatePeer::TYPE, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'TYPE', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'type', ), + BasePeer::TYPE_NUM => array (0, 1, 2, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcPlayoutHistoryTemplatePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbType' => 2, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbType' => 2, ), + BasePeer::TYPE_COLNAME => array (CcPlayoutHistoryTemplatePeer::ID => 0, CcPlayoutHistoryTemplatePeer::NAME => 1, CcPlayoutHistoryTemplatePeer::TYPE => 2, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'TYPE' => 2, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'type' => 2, ), + BasePeer::TYPE_NUM => array (0, 1, 2, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcPlayoutHistoryTemplatePeer::getFieldNames($toType); + $key = isset(CcPlayoutHistoryTemplatePeer::$fieldKeys[$fromType][$name]) ? CcPlayoutHistoryTemplatePeer::$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(CcPlayoutHistoryTemplatePeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcPlayoutHistoryTemplatePeer::$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 CcPlayoutHistoryTemplatePeer::$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. CcPlayoutHistoryTemplatePeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcPlayoutHistoryTemplatePeer::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(CcPlayoutHistoryTemplatePeer::ID); + $criteria->addSelectColumn(CcPlayoutHistoryTemplatePeer::NAME); + $criteria->addSelectColumn(CcPlayoutHistoryTemplatePeer::TYPE); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.name'); + $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(CcPlayoutHistoryTemplatePeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcPlayoutHistoryTemplatePeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcPlayoutHistoryTemplatePeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryTemplatePeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcPlayoutHistoryTemplate + * @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 = CcPlayoutHistoryTemplatePeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcPlayoutHistoryTemplatePeer::populateObjects(CcPlayoutHistoryTemplatePeer::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 directly (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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcPlayoutHistoryTemplatePeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryTemplatePeer::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 CcPlayoutHistoryTemplate $obj A CcPlayoutHistoryTemplate object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcPlayoutHistoryTemplatePeer::$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 CcPlayoutHistoryTemplate object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcPlayoutHistoryTemplate) { + $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 CcPlayoutHistoryTemplate object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcPlayoutHistoryTemplatePeer::$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 CcPlayoutHistoryTemplate 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(CcPlayoutHistoryTemplatePeer::$instances[$key])) { + return CcPlayoutHistoryTemplatePeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcPlayoutHistoryTemplatePeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcPlayoutHistoryTemplatePeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_playout_history_template + * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in CcPlayoutHistoryTemplateFieldPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcPlayoutHistoryTemplateFieldPeer::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 = CcPlayoutHistoryTemplatePeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcPlayoutHistoryTemplatePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcPlayoutHistoryTemplatePeer::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; + CcPlayoutHistoryTemplatePeer::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 (CcPlayoutHistoryTemplate object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcPlayoutHistoryTemplatePeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcPlayoutHistoryTemplatePeer::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 + CcPlayoutHistoryTemplatePeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcPlayoutHistoryTemplatePeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcPlayoutHistoryTemplatePeer::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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME)->getTable(CcPlayoutHistoryTemplatePeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcPlayoutHistoryTemplatePeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcPlayoutHistoryTemplatePeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\PlayoutHistory\map\CcPlayoutHistoryTemplateTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcPlayoutHistoryTemplatePeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcPlayoutHistoryTemplate or Criteria object. + * + * @param mixed $values Criteria or CcPlayoutHistoryTemplate 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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcPlayoutHistoryTemplate object + } + + if ($criteria->containsKey(CcPlayoutHistoryTemplatePeer::ID) && $criteria->keyContainsValue(CcPlayoutHistoryTemplatePeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcPlayoutHistoryTemplatePeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryTemplatePeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcPlayoutHistoryTemplate or Criteria object. + * + * @param mixed $values Criteria or CcPlayoutHistoryTemplate 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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcPlayoutHistoryTemplatePeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcPlayoutHistoryTemplatePeer::ID); + $value = $criteria->remove(CcPlayoutHistoryTemplatePeer::ID); + if ($value) { + $selectCriteria->add(CcPlayoutHistoryTemplatePeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcPlayoutHistoryTemplatePeer::TABLE_NAME); + } + + } else { // $values is CcPlayoutHistoryTemplate object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcPlayoutHistoryTemplatePeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_playout_history_template table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryTemplatePeer::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(CcPlayoutHistoryTemplatePeer::TABLE_NAME, $con, CcPlayoutHistoryTemplatePeer::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). + CcPlayoutHistoryTemplatePeer::clearInstancePool(); + CcPlayoutHistoryTemplatePeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcPlayoutHistoryTemplate or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcPlayoutHistoryTemplate 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(CcPlayoutHistoryTemplatePeer::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. + CcPlayoutHistoryTemplatePeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcPlayoutHistoryTemplate) { // it's a model object + // invalidate the cache for this single object + CcPlayoutHistoryTemplatePeer::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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME); + $criteria->add(CcPlayoutHistoryTemplatePeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcPlayoutHistoryTemplatePeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcPlayoutHistoryTemplatePeer::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); + CcPlayoutHistoryTemplatePeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcPlayoutHistoryTemplate 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 CcPlayoutHistoryTemplate $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcPlayoutHistoryTemplatePeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcPlayoutHistoryTemplatePeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, CcPlayoutHistoryTemplatePeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcPlayoutHistoryTemplate + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcPlayoutHistoryTemplatePeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcPlayoutHistoryTemplatePeer::DATABASE_NAME); + $criteria->add(CcPlayoutHistoryTemplatePeer::ID, $pk); + + $v = CcPlayoutHistoryTemplatePeer::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 + * @return CcPlayoutHistoryTemplate[] + * @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(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcPlayoutHistoryTemplatePeer::DATABASE_NAME); + $criteria->add(CcPlayoutHistoryTemplatePeer::ID, $pks, Criteria::IN); + $objs = CcPlayoutHistoryTemplatePeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcPlayoutHistoryTemplatePeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateQuery.php index ca2f84229..2057b0e62 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateQuery.php @@ -1,285 +1,436 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcPlayoutHistoryTemplate|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcPlayoutHistoryTemplatePeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcPlayoutHistoryTemplate|CcPlayoutHistoryTemplate[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcPlayoutHistoryTemplatePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcPlayoutHistoryTemplatePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcPlayoutHistoryTemplateQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcPlayoutHistoryTemplatePeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlayoutHistoryTemplate A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcPlayoutHistoryTemplateQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcPlayoutHistoryTemplatePeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlayoutHistoryTemplate A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "name", "type" FROM "cc_playout_history_template" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcPlayoutHistoryTemplate(); + $obj->hydrate($row); + CcPlayoutHistoryTemplatePeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcPlayoutHistoryTemplateQuery 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(CcPlayoutHistoryTemplatePeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * 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 CcPlayoutHistoryTemplateQuery 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(CcPlayoutHistoryTemplatePeer::NAME, $dbName, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPlayoutHistoryTemplate|CcPlayoutHistoryTemplate[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Filter the query on the type column - * - * @param string $dbType The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcPlayoutHistoryTemplateQuery The current query, for fluid interface - */ - public function filterByDbType($dbType = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbType)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbType)) { - $dbType = str_replace('*', '%', $dbType); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcPlayoutHistoryTemplatePeer::TYPE, $dbType, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query by a related CcPlayoutHistoryTemplateField object - * - * @param CcPlayoutHistoryTemplateField $ccPlayoutHistoryTemplateField the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcPlayoutHistoryTemplateQuery The current query, for fluid interface - */ - public function filterByCcPlayoutHistoryTemplateField($ccPlayoutHistoryTemplateField, $comparison = null) - { - return $this - ->addUsingAlias(CcPlayoutHistoryTemplatePeer::ID, $ccPlayoutHistoryTemplateField->getDbTemplateId(), $comparison); - } + /** + * 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|CcPlayoutHistoryTemplate[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Adds a JOIN clause to the query using the CcPlayoutHistoryTemplateField relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcPlayoutHistoryTemplateQuery The current query, for fluid interface - */ - public function joinCcPlayoutHistoryTemplateField($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcPlayoutHistoryTemplateField'); - - // 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, 'CcPlayoutHistoryTemplateField'); - } - - return $this; - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Use the CcPlayoutHistoryTemplateField relation CcPlayoutHistoryTemplateField 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 CcPlayoutHistoryTemplateFieldQuery A secondary query class using the current class as primary query - */ - public function useCcPlayoutHistoryTemplateFieldQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcPlayoutHistoryTemplateField($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcPlayoutHistoryTemplateField', 'CcPlayoutHistoryTemplateFieldQuery'); - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcPlayoutHistoryTemplateQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { - /** - * Exclude object from result - * - * @param CcPlayoutHistoryTemplate $ccPlayoutHistoryTemplate Object to remove from the list of results - * - * @return CcPlayoutHistoryTemplateQuery The current query, for fluid interface - */ - public function prune($ccPlayoutHistoryTemplate = null) - { - if ($ccPlayoutHistoryTemplate) { - $this->addUsingAlias(CcPlayoutHistoryTemplatePeer::ID, $ccPlayoutHistoryTemplate->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + return $this->addUsingAlias(CcPlayoutHistoryTemplatePeer::ID, $key, Criteria::EQUAL); + } -} // BaseCcPlayoutHistoryTemplateQuery + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return CcPlayoutHistoryTemplateQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(CcPlayoutHistoryTemplatePeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryTemplateQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcPlayoutHistoryTemplatePeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcPlayoutHistoryTemplatePeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcPlayoutHistoryTemplatePeer::ID, $dbId, $comparison); + } + + /** + * Filter the query on the name column + * + * Example usage: + * + * $query->filterByDbName('fooValue'); // WHERE name = 'fooValue' + * $query->filterByDbName('%fooValue%'); // WHERE name LIKE '%fooValue%' + * + * + * @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 CcPlayoutHistoryTemplateQuery 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(CcPlayoutHistoryTemplatePeer::NAME, $dbName, $comparison); + } + + /** + * Filter the query on the type column + * + * Example usage: + * + * $query->filterByDbType('fooValue'); // WHERE type = 'fooValue' + * $query->filterByDbType('%fooValue%'); // WHERE type LIKE '%fooValue%' + * + * + * @param string $dbType The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryTemplateQuery The current query, for fluid interface + */ + public function filterByDbType($dbType = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbType)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbType)) { + $dbType = str_replace('*', '%', $dbType); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcPlayoutHistoryTemplatePeer::TYPE, $dbType, $comparison); + } + + /** + * Filter the query by a related CcPlayoutHistoryTemplateField object + * + * @param CcPlayoutHistoryTemplateField|PropelObjectCollection $ccPlayoutHistoryTemplateField the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcPlayoutHistoryTemplateQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcPlayoutHistoryTemplateField($ccPlayoutHistoryTemplateField, $comparison = null) + { + if ($ccPlayoutHistoryTemplateField instanceof CcPlayoutHistoryTemplateField) { + return $this + ->addUsingAlias(CcPlayoutHistoryTemplatePeer::ID, $ccPlayoutHistoryTemplateField->getDbTemplateId(), $comparison); + } elseif ($ccPlayoutHistoryTemplateField instanceof PropelObjectCollection) { + return $this + ->useCcPlayoutHistoryTemplateFieldQuery() + ->filterByPrimaryKeys($ccPlayoutHistoryTemplateField->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcPlayoutHistoryTemplateField() only accepts arguments of type CcPlayoutHistoryTemplateField or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcPlayoutHistoryTemplateField relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcPlayoutHistoryTemplateQuery The current query, for fluid interface + */ + public function joinCcPlayoutHistoryTemplateField($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcPlayoutHistoryTemplateField'); + + // 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, 'CcPlayoutHistoryTemplateField'); + } + + return $this; + } + + /** + * Use the CcPlayoutHistoryTemplateField relation CcPlayoutHistoryTemplateField 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 \Airtime\PlayoutHistory\CcPlayoutHistoryTemplateFieldQuery A secondary query class using the current class as primary query + */ + public function useCcPlayoutHistoryTemplateFieldQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcPlayoutHistoryTemplateField($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPlayoutHistoryTemplateField', '\Airtime\PlayoutHistory\CcPlayoutHistoryTemplateFieldQuery'); + } + + /** + * Exclude object from result + * + * @param CcPlayoutHistoryTemplate $ccPlayoutHistoryTemplate Object to remove from the list of results + * + * @return CcPlayoutHistoryTemplateQuery The current query, for fluid interface + */ + public function prune($ccPlayoutHistoryTemplate = null) + { + if ($ccPlayoutHistoryTemplate) { + $this->addUsingAlias(CcPlayoutHistoryTemplatePeer::ID, $ccPlayoutHistoryTemplate->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPref.php b/airtime_mvc/application/models/airtime/om/BaseCcPref.php index b1d9a307e..bdff5cbfa 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPref.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPref.php @@ -1,905 +1,1067 @@ 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->getDbId() !== $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->getDbId()) { - $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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->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->getDbId()); - } - - $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 + /** + * Peer class name + */ + const PEER = 'Airtime\\CcPrefPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcPrefPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the subjid field. + * @var int + */ + protected $subjid; + + /** + * The value for the keystr field. + * @var string + */ + protected $keystr; + + /** + * The value for the valstr field. + * @var string + */ + protected $valstr; + + /** + * @var CcSubjs + */ + protected $aCcSubjs; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->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 && is_numeric($v)) { + $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 && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->subjid !== $v) { + $this->subjid = $v; + $this->modifiedColumns[] = CcPrefPeer::SUBJID; + } + + if ($this->aCcSubjs !== null && $this->aCcSubjs->getDbId() !== $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 && is_numeric($v)) { + $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 && is_numeric($v)) { + $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 resultset 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(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 4; // 4 = CcPrefPeer::NUM_HYDRATE_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->getDbId()) { + $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 + * @throws Exception + * @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 { + $deleteQuery = CcPrefQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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 (Exception $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 corresponding 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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcPrefPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcPrefPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_pref_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcPrefPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcPrefPeer::SUBJID)) { + $modifiedColumns[':p' . $index++] = '"subjid"'; + } + if ($this->isColumnModified(CcPrefPeer::KEYSTR)) { + $modifiedColumns[':p' . $index++] = '"keystr"'; + } + if ($this->isColumnModified(CcPrefPeer::VALSTR)) { + $modifiedColumns[':p' . $index++] = '"valstr"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_pref" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"subjid"': + $stmt->bindValue($identifier, $this->subjid, PDO::PARAM_INT); + break; + case '"keystr"': + $stmt->bindValue($identifier, $this->keystr, PDO::PARAM_STR); + break; + case '"valstr"': + $stmt->bindValue($identifier, $this->valstr, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcPref'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcPref'][$this->getPrimaryKey()] = true; + $keys = CcPrefPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getSubjid(), + $keys[2] => $this->getKeystr(), + $keys[3] => $this->getValstr(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcSubjs) { + $result['CcSubjs'] = $this->aCcSubjs->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcPrefPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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 BasePeer::TYPE_PHPNAME + * + * @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. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setSubjid($this->getSubjid()); + $copyObj->setKeystr($this->getKeystr()); + $copyObj->setValstr($this->getValstr()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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->getDbId()); + } + + $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 $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getCcSubjs(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcSubjs === null && ($this->subjid !== null) && $doQuery) { + $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->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCcSubjs instanceof Persistent) { + $this->aCcSubjs->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + $this->aCcSubjs = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcPrefPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPrefPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcPrefPeer.php index cb6345eac..d59bed07c 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPrefPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPrefPeer.php @@ -1,979 +1,1018 @@ 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; - } +abstract class BaseCcPrefPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_pref'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcPref'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcPrefTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 4; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 4; + + /** the column name for the id field */ + const ID = 'cc_pref.id'; + + /** the column name for the subjid field */ + const SUBJID = 'cc_pref.subjid'; + + /** the column name for the keystr field */ + const KEYSTR = 'cc_pref.keystr'; + + /** the column name for the valstr field */ + const VALSTR = 'cc_pref.valstr'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcPref objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcPref[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcPrefPeer::$fieldNames[CcPrefPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('Id', 'Subjid', 'Keystr', 'Valstr', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'subjid', 'keystr', 'valstr', ), + BasePeer::TYPE_COLNAME => array (CcPrefPeer::ID, CcPrefPeer::SUBJID, CcPrefPeer::KEYSTR, CcPrefPeer::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. CcPrefPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected 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 (CcPrefPeer::ID => 0, CcPrefPeer::SUBJID => 1, CcPrefPeer::KEYSTR => 2, CcPrefPeer::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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcPrefPeer::getFieldNames($toType); + $key = isset(CcPrefPeer::$fieldKeys[$fromType][$name]) ? CcPrefPeer::$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(CcPrefPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcPrefPeer::$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 CcPrefPeer::$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(CcPrefPeer::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; + } + /** + * Selects 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; + } + /** + * Selects several row from the DB. + * + * @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 directly (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(CcPrefPeer::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 $obj 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($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getId(); + } // if key === null + CcPrefPeer::$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. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + 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(CcPrefPeer::$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(CcPrefPeer::$instances[$key])) { + return CcPrefPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcPrefPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcPrefPeer::$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(); + // 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_HYDRATE_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(CcPrefPeer::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(CcPrefPeer::DATABASE_NAME); + } + + CcPrefPeer::addSelectColumns($criteria); + $startcol = CcPrefPeer::NUM_HYDRATE_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(); + + $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(); + + $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(CcPrefPeer::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(CcPrefPeer::DATABASE_NAME); + } + + CcPrefPeer::addSelectColumns($criteria); + $startcol2 = CcPrefPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcSubjsPeer::NUM_HYDRATE_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(); + + $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(); + + $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(CcPrefPeer::DATABASE_NAME)->getTable(CcPrefPeer::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 \Airtime\map\CcPrefTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcPrefPeer::OM_CLASS; + } + + /** + * Performs 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(CcPrefPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs 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(CcPrefPeer::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(CcPrefPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_pref table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $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 (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs 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(CcPrefPeer::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(CcPrefPeer::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 (Exception $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($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->hasColumn($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 + * @return CcPref[] + * @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 diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPrefQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcPrefQuery.php index 473bafc98..0f7ea2731 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcPrefQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcPrefQuery.php @@ -1,320 +1,486 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcPref|CcPref[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcPrefPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcPrefPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $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); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPref A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * 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); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPref A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "subjid", "keystr", "valstr" FROM "cc_pref" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcPref(); + $obj->hydrate($row); + CcPrefPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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); - } + return $obj; + } - /** - * 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); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcPref|CcPref[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * 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); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * 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); - } + /** + * 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|CcPref[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * 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->getDbId(), $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * 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; - } + /** + * 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) + { - /** - * 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'); - } + return $this->addUsingAlias(CcPrefPeer::ID, $key, Criteria::EQUAL); + } - /** - * 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; - } + /** + * 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) + { -} // BaseCcPrefQuery + return $this->addUsingAlias(CcPrefPeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @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)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CcPrefPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CcPrefPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcPrefPeer::ID, $id, $comparison); + } + + /** + * Filter the query on the subjid column + * + * Example usage: + * + * $query->filterBySubjid(1234); // WHERE subjid = 1234 + * $query->filterBySubjid(array(12, 34)); // WHERE subjid IN (12, 34) + * $query->filterBySubjid(array('min' => 12)); // WHERE subjid >= 12 + * $query->filterBySubjid(array('max' => 12)); // WHERE subjid <= 12 + * + * + * @see filterByCcSubjs() + * + * @param mixed $subjid The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @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 + * + * Example usage: + * + * $query->filterByKeystr('fooValue'); // WHERE keystr = 'fooValue' + * $query->filterByKeystr('%fooValue%'); // WHERE keystr LIKE '%fooValue%' + * + * + * @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 + * + * Example usage: + * + * $query->filterByValstr('fooValue'); // WHERE valstr = 'fooValue' + * $query->filterByValstr('%fooValue%'); // WHERE valstr LIKE '%fooValue%' + * + * + * @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|PropelObjectCollection $ccSubjs The related object(s) 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcSubjs($ccSubjs, $comparison = null) + { + if ($ccSubjs instanceof CcSubjs) { + return $this + ->addUsingAlias(CcPrefPeer::SUBJID, $ccSubjs->getDbId(), $comparison); + } elseif ($ccSubjs instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcPrefPeer::SUBJID, $ccSubjs->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcSubjs() only accepts arguments of type CcSubjs or PropelCollection'); + } + } + + /** + * 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 = null, $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 \Airtime\CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSubjs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', '\Airtime\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; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcSchedule.php b/airtime_mvc/application/models/airtime/om/BaseCcSchedule.php index ceb5008d8..713fe9247 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcSchedule.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcSchedule.php @@ -1,2016 +1,2340 @@ clip_length = '00:00:00'; - $this->fade_in = '00:00:00'; - $this->fade_out = '00:00:00'; - $this->media_item_played = false; - $this->playout_status = 1; - $this->broadcasted = 0; - $this->position = 0; - } - - /** - * Initializes internal state of BaseCcSchedule 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 [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 getDbStarts($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 getDbEnds($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 [file_id] column value. - * - * @return int - */ - public function getDbFileId() - { - return $this->file_id; - } - - /** - * Get the [stream_id] column value. - * - * @return int - */ - public function getDbStreamId() - { - return $this->stream_id; - } - - /** - * Get the [clip_length] column value. - * - * @return string - */ - public function getDbClipLength() - { - return $this->clip_length; - } - - /** - * 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 getDbFadeIn($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 getDbFadeOut($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 [cue_in] column value. - * - * @return string - */ - public function getDbCueIn() - { - return $this->cue_in; - } - - /** - * Get the [cue_out] column value. - * - * @return string - */ - public function getDbCueOut() - { - return $this->cue_out; - } - - /** - * Get the [media_item_played] column value. - * - * @return boolean - */ - public function getDbMediaItemPlayed() - { - return $this->media_item_played; - } - - /** - * Get the [instance_id] column value. - * - * @return int - */ - public function getDbInstanceId() - { - return $this->instance_id; - } - - /** - * Get the [playout_status] column value. - * - * @return int - */ - public function getDbPlayoutStatus() - { - return $this->playout_status; - } - - /** - * Get the [broadcasted] column value. - * - * @return int - */ - public function getDbBroadcasted() - { - return $this->broadcasted; - } - - /** - * Get the [position] column value. - * - * @return int - */ - public function getDbPosition() - { - return $this->position; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcSchedule 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[] = CcSchedulePeer::ID; - } - - return $this; - } // setDbId() - - /** - * 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 setDbStarts($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; - } // setDbStarts() - - /** - * 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 setDbEnds($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; - } // setDbEnds() - - /** - * Set the value of [file_id] column. - * - * @param int $v new value - * @return CcSchedule 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[] = CcSchedulePeer::FILE_ID; - } - - if ($this->aCcFiles !== null && $this->aCcFiles->getDbId() !== $v) { - $this->aCcFiles = null; - } - - return $this; - } // setDbFileId() - - /** - * Set the value of [stream_id] column. - * - * @param int $v new value - * @return CcSchedule The current object (for fluent API support) - */ - public function setDbStreamId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->stream_id !== $v) { - $this->stream_id = $v; - $this->modifiedColumns[] = CcSchedulePeer::STREAM_ID; - } - - if ($this->aCcWebstream !== null && $this->aCcWebstream->getDbId() !== $v) { - $this->aCcWebstream = null; - } - - return $this; - } // setDbStreamId() - - /** - * Set the value of [clip_length] column. - * - * @param string $v new value - * @return CcSchedule The current object (for fluent API support) - */ - public function setDbClipLength($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->clip_length !== $v || $this->isNew()) { - $this->clip_length = $v; - $this->modifiedColumns[] = CcSchedulePeer::CLIP_LENGTH; - } - - return $this; - } // setDbClipLength() - - /** - * 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 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->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; - } // setDbFadeIn() - - /** - * 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 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->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; - } // setDbFadeOut() - - /** - * Set the value of [cue_in] column. - * - * @param string $v new value - * @return CcSchedule The current object (for fluent API support) - */ - public function setDbCueIn($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->cue_in !== $v) { - $this->cue_in = $v; - $this->modifiedColumns[] = CcSchedulePeer::CUE_IN; - } - - return $this; - } // setDbCueIn() - - /** - * Set the value of [cue_out] column. - * - * @param string $v new value - * @return CcSchedule The current object (for fluent API support) - */ - public function setDbCueOut($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->cue_out !== $v) { - $this->cue_out = $v; - $this->modifiedColumns[] = CcSchedulePeer::CUE_OUT; - } - - return $this; - } // setDbCueOut() - - /** - * Set the value of [media_item_played] column. - * - * @param boolean $v new value - * @return CcSchedule The current object (for fluent API support) - */ - public function setDbMediaItemPlayed($v) - { - if ($v !== null) { - $v = (boolean) $v; - } - - if ($this->media_item_played !== $v || $this->isNew()) { - $this->media_item_played = $v; - $this->modifiedColumns[] = CcSchedulePeer::MEDIA_ITEM_PLAYED; - } - - return $this; - } // setDbMediaItemPlayed() - - /** - * Set the value of [instance_id] column. - * - * @param int $v new value - * @return CcSchedule The current object (for fluent API support) - */ - public function setDbInstanceId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->instance_id !== $v) { - $this->instance_id = $v; - $this->modifiedColumns[] = CcSchedulePeer::INSTANCE_ID; - } - - if ($this->aCcShowInstances !== null && $this->aCcShowInstances->getDbId() !== $v) { - $this->aCcShowInstances = null; - } - - return $this; - } // setDbInstanceId() - - /** - * Set the value of [playout_status] column. - * - * @param int $v new value - * @return CcSchedule The current object (for fluent API support) - */ - public function setDbPlayoutStatus($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->playout_status !== $v || $this->isNew()) { - $this->playout_status = $v; - $this->modifiedColumns[] = CcSchedulePeer::PLAYOUT_STATUS; - } - - return $this; - } // setDbPlayoutStatus() - - /** - * Set the value of [broadcasted] column. - * - * @param int $v new value - * @return CcSchedule The current object (for fluent API support) - */ - public function setDbBroadcasted($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->broadcasted !== $v || $this->isNew()) { - $this->broadcasted = $v; - $this->modifiedColumns[] = CcSchedulePeer::BROADCASTED; - } - - return $this; - } // setDbBroadcasted() - - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return CcSchedule The current object (for fluent API support) - */ - public function setDbPosition($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->position !== $v || $this->isNew()) { - $this->position = $v; - $this->modifiedColumns[] = CcSchedulePeer::POSITION; - } - - return $this; - } // setDbPosition() - - /** - * 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->media_item_played !== false) { - return false; - } - - if ($this->playout_status !== 1) { - return false; - } - - if ($this->broadcasted !== 0) { - return false; - } - - if ($this->position !== 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->starts = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->ends = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->file_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->stream_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->clip_length = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->fade_in = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->fade_out = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->cue_in = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; - $this->cue_out = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; - $this->media_item_played = ($row[$startcol + 10] !== null) ? (boolean) $row[$startcol + 10] : null; - $this->instance_id = ($row[$startcol + 11] !== null) ? (int) $row[$startcol + 11] : null; - $this->playout_status = ($row[$startcol + 12] !== null) ? (int) $row[$startcol + 12] : null; - $this->broadcasted = ($row[$startcol + 13] !== null) ? (int) $row[$startcol + 13] : null; - $this->position = ($row[$startcol + 14] !== null) ? (int) $row[$startcol + 14] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 15; // 15 = 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() - { - - if ($this->aCcFiles !== null && $this->file_id !== $this->aCcFiles->getDbId()) { - $this->aCcFiles = null; - } - if ($this->aCcWebstream !== null && $this->stream_id !== $this->aCcWebstream->getDbId()) { - $this->aCcWebstream = null; - } - if ($this->aCcShowInstances !== null && $this->instance_id !== $this->aCcShowInstances->getDbId()) { - $this->aCcShowInstances = 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(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? - - $this->aCcShowInstances = null; - $this->aCcFiles = null; - $this->aCcWebstream = null; - $this->collCcWebstreamMetadatas = 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(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; - - // 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->aCcShowInstances !== null) { - if ($this->aCcShowInstances->isModified() || $this->aCcShowInstances->isNew()) { - $affectedRows += $this->aCcShowInstances->save($con); - } - $this->setCcShowInstances($this->aCcShowInstances); - } - - if ($this->aCcFiles !== null) { - if ($this->aCcFiles->isModified() || $this->aCcFiles->isNew()) { - $affectedRows += $this->aCcFiles->save($con); - } - $this->setCcFiles($this->aCcFiles); - } - - if ($this->aCcWebstream !== null) { - if ($this->aCcWebstream->isModified() || $this->aCcWebstream->isNew()) { - $affectedRows += $this->aCcWebstream->save($con); - } - $this->setCcWebstream($this->aCcWebstream); - } - - if ($this->isNew() ) { - $this->modifiedColumns[] = CcSchedulePeer::ID; - } - - // If this object has been modified, then save it to the database. - if ($this->isModified()) { - if ($this->isNew()) { - $criteria = $this->buildCriteria(); - if ($criteria->keyContainsValue(CcSchedulePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSchedulePeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows += 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows += CcSchedulePeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - if ($this->collCcWebstreamMetadatas !== null) { - foreach ($this->collCcWebstreamMetadatas 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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcShowInstances !== null) { - if (!$this->aCcShowInstances->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcShowInstances->getValidationFailures()); - } - } - - if ($this->aCcFiles !== null) { - if (!$this->aCcFiles->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcFiles->getValidationFailures()); - } - } - - if ($this->aCcWebstream !== null) { - if (!$this->aCcWebstream->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcWebstream->getValidationFailures()); - } - } - - - if (($retval = CcSchedulePeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collCcWebstreamMetadatas !== null) { - foreach ($this->collCcWebstreamMetadatas 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 = 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->getDbId(); - break; - case 1: - return $this->getDbStarts(); - break; - case 2: - return $this->getDbEnds(); - break; - case 3: - return $this->getDbFileId(); - break; - case 4: - return $this->getDbStreamId(); - break; - case 5: - return $this->getDbClipLength(); - break; - case 6: - return $this->getDbFadeIn(); - break; - case 7: - return $this->getDbFadeOut(); - break; - case 8: - return $this->getDbCueIn(); - break; - case 9: - return $this->getDbCueOut(); - break; - case 10: - return $this->getDbMediaItemPlayed(); - break; - case 11: - return $this->getDbInstanceId(); - break; - case 12: - return $this->getDbPlayoutStatus(); - break; - case 13: - return $this->getDbBroadcasted(); - break; - case 14: - return $this->getDbPosition(); - 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 = CcSchedulePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbStarts(), - $keys[2] => $this->getDbEnds(), - $keys[3] => $this->getDbFileId(), - $keys[4] => $this->getDbStreamId(), - $keys[5] => $this->getDbClipLength(), - $keys[6] => $this->getDbFadeIn(), - $keys[7] => $this->getDbFadeOut(), - $keys[8] => $this->getDbCueIn(), - $keys[9] => $this->getDbCueOut(), - $keys[10] => $this->getDbMediaItemPlayed(), - $keys[11] => $this->getDbInstanceId(), - $keys[12] => $this->getDbPlayoutStatus(), - $keys[13] => $this->getDbBroadcasted(), - $keys[14] => $this->getDbPosition(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCcShowInstances) { - $result['CcShowInstances'] = $this->aCcShowInstances->toArray($keyType, $includeLazyLoadColumns, true); - } - if (null !== $this->aCcFiles) { - $result['CcFiles'] = $this->aCcFiles->toArray($keyType, $includeLazyLoadColumns, true); - } - if (null !== $this->aCcWebstream) { - $result['CcWebstream'] = $this->aCcWebstream->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 = 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->setDbId($value); - break; - case 1: - $this->setDbStarts($value); - break; - case 2: - $this->setDbEnds($value); - break; - case 3: - $this->setDbFileId($value); - break; - case 4: - $this->setDbStreamId($value); - break; - case 5: - $this->setDbClipLength($value); - break; - case 6: - $this->setDbFadeIn($value); - break; - case 7: - $this->setDbFadeOut($value); - break; - case 8: - $this->setDbCueIn($value); - break; - case 9: - $this->setDbCueOut($value); - break; - case 10: - $this->setDbMediaItemPlayed($value); - break; - case 11: - $this->setDbInstanceId($value); - break; - case 12: - $this->setDbPlayoutStatus($value); - break; - case 13: - $this->setDbBroadcasted($value); - break; - case 14: - $this->setDbPosition($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->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbStarts($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbEnds($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbFileId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbStreamId($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbClipLength($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDbFadeIn($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setDbFadeOut($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setDbCueIn($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setDbCueOut($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setDbMediaItemPlayed($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setDbInstanceId($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setDbPlayoutStatus($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setDbBroadcasted($arr[$keys[13]]); - if (array_key_exists($keys[14], $arr)) $this->setDbPosition($arr[$keys[14]]); - } - - /** - * 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::STARTS)) $criteria->add(CcSchedulePeer::STARTS, $this->starts); - if ($this->isColumnModified(CcSchedulePeer::ENDS)) $criteria->add(CcSchedulePeer::ENDS, $this->ends); - if ($this->isColumnModified(CcSchedulePeer::FILE_ID)) $criteria->add(CcSchedulePeer::FILE_ID, $this->file_id); - if ($this->isColumnModified(CcSchedulePeer::STREAM_ID)) $criteria->add(CcSchedulePeer::STREAM_ID, $this->stream_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); - if ($this->isColumnModified(CcSchedulePeer::MEDIA_ITEM_PLAYED)) $criteria->add(CcSchedulePeer::MEDIA_ITEM_PLAYED, $this->media_item_played); - if ($this->isColumnModified(CcSchedulePeer::INSTANCE_ID)) $criteria->add(CcSchedulePeer::INSTANCE_ID, $this->instance_id); - if ($this->isColumnModified(CcSchedulePeer::PLAYOUT_STATUS)) $criteria->add(CcSchedulePeer::PLAYOUT_STATUS, $this->playout_status); - if ($this->isColumnModified(CcSchedulePeer::BROADCASTED)) $criteria->add(CcSchedulePeer::BROADCASTED, $this->broadcasted); - if ($this->isColumnModified(CcSchedulePeer::POSITION)) $criteria->add(CcSchedulePeer::POSITION, $this->position); - - 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 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 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->setDbStarts($this->starts); - $copyObj->setDbEnds($this->ends); - $copyObj->setDbFileId($this->file_id); - $copyObj->setDbStreamId($this->stream_id); - $copyObj->setDbClipLength($this->clip_length); - $copyObj->setDbFadeIn($this->fade_in); - $copyObj->setDbFadeOut($this->fade_out); - $copyObj->setDbCueIn($this->cue_in); - $copyObj->setDbCueOut($this->cue_out); - $copyObj->setDbMediaItemPlayed($this->media_item_played); - $copyObj->setDbInstanceId($this->instance_id); - $copyObj->setDbPlayoutStatus($this->playout_status); - $copyObj->setDbBroadcasted($this->broadcasted); - $copyObj->setDbPosition($this->position); - - 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->getCcWebstreamMetadatas() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcWebstreamMetadata($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 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; - } - - /** - * Declares an association between this object and a CcShowInstances object. - * - * @param CcShowInstances $v - * @return CcSchedule The current object (for fluent API support) - * @throws PropelException - */ - public function setCcShowInstances(CcShowInstances $v = null) - { - if ($v === null) { - $this->setDbInstanceId(NULL); - } else { - $this->setDbInstanceId($v->getDbId()); - } - - $this->aCcShowInstances = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcShowInstances object, it will not be re-added. - if ($v !== null) { - $v->addCcSchedule($this); - } - - return $this; - } - - - /** - * Get the associated CcShowInstances object - * - * @param PropelPDO Optional Connection object. - * @return CcShowInstances The associated CcShowInstances object. - * @throws PropelException - */ - public function getCcShowInstances(PropelPDO $con = null) - { - if ($this->aCcShowInstances === null && ($this->instance_id !== null)) { - $this->aCcShowInstances = CcShowInstancesQuery::create()->findPk($this->instance_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->aCcShowInstances->addCcSchedules($this); - */ - } - return $this->aCcShowInstances; - } - - /** - * Declares an association between this object and a CcFiles object. - * - * @param CcFiles $v - * @return CcSchedule 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->addCcSchedule($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->addCcSchedules($this); - */ - } - return $this->aCcFiles; - } - - /** - * Declares an association between this object and a CcWebstream object. - * - * @param CcWebstream $v - * @return CcSchedule The current object (for fluent API support) - * @throws PropelException - */ - public function setCcWebstream(CcWebstream $v = null) - { - if ($v === null) { - $this->setDbStreamId(NULL); - } else { - $this->setDbStreamId($v->getDbId()); - } - - $this->aCcWebstream = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcWebstream object, it will not be re-added. - if ($v !== null) { - $v->addCcSchedule($this); - } - - return $this; - } - - - /** - * Get the associated CcWebstream object - * - * @param PropelPDO Optional Connection object. - * @return CcWebstream The associated CcWebstream object. - * @throws PropelException - */ - public function getCcWebstream(PropelPDO $con = null) - { - if ($this->aCcWebstream === null && ($this->stream_id !== null)) { - $this->aCcWebstream = CcWebstreamQuery::create()->findPk($this->stream_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->aCcWebstream->addCcSchedules($this); - */ - } - return $this->aCcWebstream; - } - - /** - * Clears out the collCcWebstreamMetadatas 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 addCcWebstreamMetadatas() - */ - public function clearCcWebstreamMetadatas() - { - $this->collCcWebstreamMetadatas = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcWebstreamMetadatas collection. - * - * By default this just sets the collCcWebstreamMetadatas collection to an empty array (like clearcollCcWebstreamMetadatas()); - * 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 initCcWebstreamMetadatas() - { - $this->collCcWebstreamMetadatas = new PropelObjectCollection(); - $this->collCcWebstreamMetadatas->setModel('CcWebstreamMetadata'); - } - - /** - * Gets an array of CcWebstreamMetadata 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 CcSchedule 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 CcWebstreamMetadata[] List of CcWebstreamMetadata objects - * @throws PropelException - */ - public function getCcWebstreamMetadatas($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcWebstreamMetadatas || null !== $criteria) { - if ($this->isNew() && null === $this->collCcWebstreamMetadatas) { - // return empty collection - $this->initCcWebstreamMetadatas(); - } else { - $collCcWebstreamMetadatas = CcWebstreamMetadataQuery::create(null, $criteria) - ->filterByCcSchedule($this) - ->find($con); - if (null !== $criteria) { - return $collCcWebstreamMetadatas; - } - $this->collCcWebstreamMetadatas = $collCcWebstreamMetadatas; - } - } - return $this->collCcWebstreamMetadatas; - } - - /** - * Returns the number of related CcWebstreamMetadata objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcWebstreamMetadata objects. - * @throws PropelException - */ - public function countCcWebstreamMetadatas(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcWebstreamMetadatas || null !== $criteria) { - if ($this->isNew() && null === $this->collCcWebstreamMetadatas) { - return 0; - } else { - $query = CcWebstreamMetadataQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcSchedule($this) - ->count($con); - } - } else { - return count($this->collCcWebstreamMetadatas); - } - } - - /** - * Method called to associate a CcWebstreamMetadata object to this object - * through the CcWebstreamMetadata foreign key attribute. - * - * @param CcWebstreamMetadata $l CcWebstreamMetadata - * @return void - * @throws PropelException - */ - public function addCcWebstreamMetadata(CcWebstreamMetadata $l) - { - if ($this->collCcWebstreamMetadatas === null) { - $this->initCcWebstreamMetadatas(); - } - if (!$this->collCcWebstreamMetadatas->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcWebstreamMetadatas[]= $l; - $l->setCcSchedule($this); - } - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->starts = null; - $this->ends = null; - $this->file_id = null; - $this->stream_id = null; - $this->clip_length = null; - $this->fade_in = null; - $this->fade_out = null; - $this->cue_in = null; - $this->cue_out = null; - $this->media_item_played = null; - $this->instance_id = null; - $this->playout_status = null; - $this->broadcasted = null; - $this->position = 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->collCcWebstreamMetadatas) { - foreach ((array) $this->collCcWebstreamMetadatas as $o) { - $o->clearAllReferences($deep); - } - } - } // if ($deep) - - $this->collCcWebstreamMetadatas = null; - $this->aCcShowInstances = null; - $this->aCcFiles = null; - $this->aCcWebstream = 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); - } - -} // BaseCcSchedule + /** + * Peer class name + */ + const PEER = 'Airtime\\CcSchedulePeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcSchedulePeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the starts field. + * @var string + */ + protected $starts; + + /** + * The value for the ends field. + * @var string + */ + protected $ends; + + /** + * The value for the file_id field. + * @var int + */ + protected $file_id; + + /** + * The value for the stream_id field. + * @var int + */ + protected $stream_id; + + /** + * The value for the clip_length field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $clip_length; + + /** + * The value for the fade_in field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $fade_in; + + /** + * The value for the fade_out field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $fade_out; + + /** + * The value for the cue_in field. + * @var string + */ + protected $cue_in; + + /** + * The value for the cue_out field. + * @var string + */ + protected $cue_out; + + /** + * The value for the media_item_played field. + * Note: this column has a database default value of: false + * @var boolean + */ + protected $media_item_played; + + /** + * The value for the instance_id field. + * @var int + */ + protected $instance_id; + + /** + * The value for the playout_status field. + * Note: this column has a database default value of: 1 + * @var int + */ + protected $playout_status; + + /** + * The value for the broadcasted field. + * Note: this column has a database default value of: 0 + * @var int + */ + protected $broadcasted; + + /** + * The value for the position field. + * Note: this column has a database default value of: 0 + * @var int + */ + protected $position; + + /** + * @var CcShowInstances + */ + protected $aCcShowInstances; + + /** + * @var CcFiles + */ + protected $aCcFiles; + + /** + * @var CcWebstream + */ + protected $aCcWebstream; + + /** + * @var PropelObjectCollection|CcWebstreamMetadata[] Collection to store aggregation of CcWebstreamMetadata objects. + */ + protected $collCcWebstreamMetadatas; + protected $collCcWebstreamMetadatasPartial; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccWebstreamMetadatasScheduledForDeletion = null; + + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->clip_length = '00:00:00'; + $this->fade_in = '00:00:00'; + $this->fade_out = '00:00:00'; + $this->media_item_played = false; + $this->playout_status = 1; + $this->broadcasted = 0; + $this->position = 0; + } + + /** + * Initializes internal state of BaseCcSchedule 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 [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 getDbStarts($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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + 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 getDbEnds($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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [file_id] column value. + * + * @return int + */ + public function getDbFileId() + { + + return $this->file_id; + } + + /** + * Get the [stream_id] column value. + * + * @return int + */ + public function getDbStreamId() + { + + return $this->stream_id; + } + + /** + * Get the [clip_length] column value. + * + * @return string + */ + public function getDbClipLength() + { + + return $this->clip_length; + } + + /** + * 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 getDbFadeIn($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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + 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 getDbFadeOut($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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [cue_in] column value. + * + * @return string + */ + public function getDbCueIn() + { + + return $this->cue_in; + } + + /** + * Get the [cue_out] column value. + * + * @return string + */ + public function getDbCueOut() + { + + return $this->cue_out; + } + + /** + * Get the [media_item_played] column value. + * + * @return boolean + */ + public function getDbMediaItemPlayed() + { + + return $this->media_item_played; + } + + /** + * Get the [instance_id] column value. + * + * @return int + */ + public function getDbInstanceId() + { + + return $this->instance_id; + } + + /** + * Get the [playout_status] column value. + * + * @return int + */ + public function getDbPlayoutStatus() + { + + return $this->playout_status; + } + + /** + * Get the [broadcasted] column value. + * + * @return int + */ + public function getDbBroadcasted() + { + + return $this->broadcasted; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getDbPosition() + { + + return $this->position; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcSchedule The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcSchedulePeer::ID; + } + + + return $this; + } // setDbId() + + /** + * 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 strings are treated as null. + * @return CcSchedule The current object (for fluent API support) + */ + public function setDbStarts($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->starts !== null || $dt !== null) { + $currentDateAsString = ($this->starts !== null && $tmpDt = new DateTime($this->starts)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->starts = $newDateAsString; + $this->modifiedColumns[] = CcSchedulePeer::STARTS; + } + } // if either are not null + + + return $this; + } // setDbStarts() + + /** + * 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 strings are treated as null. + * @return CcSchedule The current object (for fluent API support) + */ + public function setDbEnds($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->ends !== null || $dt !== null) { + $currentDateAsString = ($this->ends !== null && $tmpDt = new DateTime($this->ends)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->ends = $newDateAsString; + $this->modifiedColumns[] = CcSchedulePeer::ENDS; + } + } // if either are not null + + + return $this; + } // setDbEnds() + + /** + * Set the value of [file_id] column. + * + * @param int $v new value + * @return CcSchedule The current object (for fluent API support) + */ + public function setDbFileId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->file_id !== $v) { + $this->file_id = $v; + $this->modifiedColumns[] = CcSchedulePeer::FILE_ID; + } + + if ($this->aCcFiles !== null && $this->aCcFiles->getDbId() !== $v) { + $this->aCcFiles = null; + } + + + return $this; + } // setDbFileId() + + /** + * Set the value of [stream_id] column. + * + * @param int $v new value + * @return CcSchedule The current object (for fluent API support) + */ + public function setDbStreamId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->stream_id !== $v) { + $this->stream_id = $v; + $this->modifiedColumns[] = CcSchedulePeer::STREAM_ID; + } + + if ($this->aCcWebstream !== null && $this->aCcWebstream->getDbId() !== $v) { + $this->aCcWebstream = null; + } + + + return $this; + } // setDbStreamId() + + /** + * Set the value of [clip_length] column. + * + * @param string $v new value + * @return CcSchedule The current object (for fluent API support) + */ + public function setDbClipLength($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->clip_length !== $v) { + $this->clip_length = $v; + $this->modifiedColumns[] = CcSchedulePeer::CLIP_LENGTH; + } + + + return $this; + } // setDbClipLength() + + /** + * 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 strings are treated as null. + * @return CcSchedule The current object (for fluent API support) + */ + public function setDbFadeIn($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->fade_in !== null || $dt !== null) { + $currentDateAsString = ($this->fade_in !== null && $tmpDt = new DateTime($this->fade_in)) ? $tmpDt->format('H:i:s') : null; + $newDateAsString = $dt ? $dt->format('H:i:s') : null; + if ( ($currentDateAsString !== $newDateAsString) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) { + $this->fade_in = $newDateAsString; + $this->modifiedColumns[] = CcSchedulePeer::FADE_IN; + } + } // if either are not null + + + return $this; + } // setDbFadeIn() + + /** + * 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 strings are treated as null. + * @return CcSchedule The current object (for fluent API support) + */ + public function setDbFadeOut($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->fade_out !== null || $dt !== null) { + $currentDateAsString = ($this->fade_out !== null && $tmpDt = new DateTime($this->fade_out)) ? $tmpDt->format('H:i:s') : null; + $newDateAsString = $dt ? $dt->format('H:i:s') : null; + if ( ($currentDateAsString !== $newDateAsString) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) { + $this->fade_out = $newDateAsString; + $this->modifiedColumns[] = CcSchedulePeer::FADE_OUT; + } + } // if either are not null + + + return $this; + } // setDbFadeOut() + + /** + * Set the value of [cue_in] column. + * + * @param string $v new value + * @return CcSchedule The current object (for fluent API support) + */ + public function setDbCueIn($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->cue_in !== $v) { + $this->cue_in = $v; + $this->modifiedColumns[] = CcSchedulePeer::CUE_IN; + } + + + return $this; + } // setDbCueIn() + + /** + * Set the value of [cue_out] column. + * + * @param string $v new value + * @return CcSchedule The current object (for fluent API support) + */ + public function setDbCueOut($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->cue_out !== $v) { + $this->cue_out = $v; + $this->modifiedColumns[] = CcSchedulePeer::CUE_OUT; + } + + + return $this; + } // setDbCueOut() + + /** + * Sets the value of the [media_item_played] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return CcSchedule The current object (for fluent API support) + */ + public function setDbMediaItemPlayed($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->media_item_played !== $v) { + $this->media_item_played = $v; + $this->modifiedColumns[] = CcSchedulePeer::MEDIA_ITEM_PLAYED; + } + + + return $this; + } // setDbMediaItemPlayed() + + /** + * Set the value of [instance_id] column. + * + * @param int $v new value + * @return CcSchedule The current object (for fluent API support) + */ + public function setDbInstanceId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->instance_id !== $v) { + $this->instance_id = $v; + $this->modifiedColumns[] = CcSchedulePeer::INSTANCE_ID; + } + + if ($this->aCcShowInstances !== null && $this->aCcShowInstances->getDbId() !== $v) { + $this->aCcShowInstances = null; + } + + + return $this; + } // setDbInstanceId() + + /** + * Set the value of [playout_status] column. + * + * @param int $v new value + * @return CcSchedule The current object (for fluent API support) + */ + public function setDbPlayoutStatus($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->playout_status !== $v) { + $this->playout_status = $v; + $this->modifiedColumns[] = CcSchedulePeer::PLAYOUT_STATUS; + } + + + return $this; + } // setDbPlayoutStatus() + + /** + * Set the value of [broadcasted] column. + * + * @param int $v new value + * @return CcSchedule The current object (for fluent API support) + */ + public function setDbBroadcasted($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->broadcasted !== $v) { + $this->broadcasted = $v; + $this->modifiedColumns[] = CcSchedulePeer::BROADCASTED; + } + + + return $this; + } // setDbBroadcasted() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return CcSchedule The current object (for fluent API support) + */ + public function setDbPosition($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = CcSchedulePeer::POSITION; + } + + + return $this; + } // setDbPosition() + + /** + * 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->media_item_played !== false) { + return false; + } + + if ($this->playout_status !== 1) { + return false; + } + + if ($this->broadcasted !== 0) { + return false; + } + + if ($this->position !== 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 resultset 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->starts = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->ends = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->file_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; + $this->stream_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; + $this->clip_length = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->fade_in = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->fade_out = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; + $this->cue_in = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->cue_out = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->media_item_played = ($row[$startcol + 10] !== null) ? (boolean) $row[$startcol + 10] : null; + $this->instance_id = ($row[$startcol + 11] !== null) ? (int) $row[$startcol + 11] : null; + $this->playout_status = ($row[$startcol + 12] !== null) ? (int) $row[$startcol + 12] : null; + $this->broadcasted = ($row[$startcol + 13] !== null) ? (int) $row[$startcol + 13] : null; + $this->position = ($row[$startcol + 14] !== null) ? (int) $row[$startcol + 14] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 15; // 15 = CcSchedulePeer::NUM_HYDRATE_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() + { + + if ($this->aCcFiles !== null && $this->file_id !== $this->aCcFiles->getDbId()) { + $this->aCcFiles = null; + } + if ($this->aCcWebstream !== null && $this->stream_id !== $this->aCcWebstream->getDbId()) { + $this->aCcWebstream = null; + } + if ($this->aCcShowInstances !== null && $this->instance_id !== $this->aCcShowInstances->getDbId()) { + $this->aCcShowInstances = 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(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? + + $this->aCcShowInstances = null; + $this->aCcFiles = null; + $this->aCcWebstream = null; + $this->collCcWebstreamMetadatas = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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 { + $deleteQuery = CcScheduleQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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 (Exception $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcShowInstances !== null) { + if ($this->aCcShowInstances->isModified() || $this->aCcShowInstances->isNew()) { + $affectedRows += $this->aCcShowInstances->save($con); + } + $this->setCcShowInstances($this->aCcShowInstances); + } + + if ($this->aCcFiles !== null) { + if ($this->aCcFiles->isModified() || $this->aCcFiles->isNew()) { + $affectedRows += $this->aCcFiles->save($con); + } + $this->setCcFiles($this->aCcFiles); + } + + if ($this->aCcWebstream !== null) { + if ($this->aCcWebstream->isModified() || $this->aCcWebstream->isNew()) { + $affectedRows += $this->aCcWebstream->save($con); + } + $this->setCcWebstream($this->aCcWebstream); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->ccWebstreamMetadatasScheduledForDeletion !== null) { + if (!$this->ccWebstreamMetadatasScheduledForDeletion->isEmpty()) { + CcWebstreamMetadataQuery::create() + ->filterByPrimaryKeys($this->ccWebstreamMetadatasScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccWebstreamMetadatasScheduledForDeletion = null; + } + } + + if ($this->collCcWebstreamMetadatas !== null) { + foreach ($this->collCcWebstreamMetadatas as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcSchedulePeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcSchedulePeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_schedule_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcSchedulePeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcSchedulePeer::STARTS)) { + $modifiedColumns[':p' . $index++] = '"starts"'; + } + if ($this->isColumnModified(CcSchedulePeer::ENDS)) { + $modifiedColumns[':p' . $index++] = '"ends"'; + } + if ($this->isColumnModified(CcSchedulePeer::FILE_ID)) { + $modifiedColumns[':p' . $index++] = '"file_id"'; + } + if ($this->isColumnModified(CcSchedulePeer::STREAM_ID)) { + $modifiedColumns[':p' . $index++] = '"stream_id"'; + } + if ($this->isColumnModified(CcSchedulePeer::CLIP_LENGTH)) { + $modifiedColumns[':p' . $index++] = '"clip_length"'; + } + if ($this->isColumnModified(CcSchedulePeer::FADE_IN)) { + $modifiedColumns[':p' . $index++] = '"fade_in"'; + } + if ($this->isColumnModified(CcSchedulePeer::FADE_OUT)) { + $modifiedColumns[':p' . $index++] = '"fade_out"'; + } + if ($this->isColumnModified(CcSchedulePeer::CUE_IN)) { + $modifiedColumns[':p' . $index++] = '"cue_in"'; + } + if ($this->isColumnModified(CcSchedulePeer::CUE_OUT)) { + $modifiedColumns[':p' . $index++] = '"cue_out"'; + } + if ($this->isColumnModified(CcSchedulePeer::MEDIA_ITEM_PLAYED)) { + $modifiedColumns[':p' . $index++] = '"media_item_played"'; + } + if ($this->isColumnModified(CcSchedulePeer::INSTANCE_ID)) { + $modifiedColumns[':p' . $index++] = '"instance_id"'; + } + if ($this->isColumnModified(CcSchedulePeer::PLAYOUT_STATUS)) { + $modifiedColumns[':p' . $index++] = '"playout_status"'; + } + if ($this->isColumnModified(CcSchedulePeer::BROADCASTED)) { + $modifiedColumns[':p' . $index++] = '"broadcasted"'; + } + if ($this->isColumnModified(CcSchedulePeer::POSITION)) { + $modifiedColumns[':p' . $index++] = '"position"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_schedule" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"starts"': + $stmt->bindValue($identifier, $this->starts, PDO::PARAM_STR); + break; + case '"ends"': + $stmt->bindValue($identifier, $this->ends, PDO::PARAM_STR); + break; + case '"file_id"': + $stmt->bindValue($identifier, $this->file_id, PDO::PARAM_INT); + break; + case '"stream_id"': + $stmt->bindValue($identifier, $this->stream_id, PDO::PARAM_INT); + break; + case '"clip_length"': + $stmt->bindValue($identifier, $this->clip_length, PDO::PARAM_STR); + break; + case '"fade_in"': + $stmt->bindValue($identifier, $this->fade_in, PDO::PARAM_STR); + break; + case '"fade_out"': + $stmt->bindValue($identifier, $this->fade_out, PDO::PARAM_STR); + break; + case '"cue_in"': + $stmt->bindValue($identifier, $this->cue_in, PDO::PARAM_STR); + break; + case '"cue_out"': + $stmt->bindValue($identifier, $this->cue_out, PDO::PARAM_STR); + break; + case '"media_item_played"': + $stmt->bindValue($identifier, $this->media_item_played, PDO::PARAM_BOOL); + break; + case '"instance_id"': + $stmt->bindValue($identifier, $this->instance_id, PDO::PARAM_INT); + break; + case '"playout_status"': + $stmt->bindValue($identifier, $this->playout_status, PDO::PARAM_INT); + break; + case '"broadcasted"': + $stmt->bindValue($identifier, $this->broadcasted, PDO::PARAM_INT); + break; + case '"position"': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcShowInstances !== null) { + if (!$this->aCcShowInstances->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcShowInstances->getValidationFailures()); + } + } + + if ($this->aCcFiles !== null) { + if (!$this->aCcFiles->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcFiles->getValidationFailures()); + } + } + + if ($this->aCcWebstream !== null) { + if (!$this->aCcWebstream->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcWebstream->getValidationFailures()); + } + } + + + if (($retval = CcSchedulePeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collCcWebstreamMetadatas !== null) { + foreach ($this->collCcWebstreamMetadatas 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @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->getDbId(); + break; + case 1: + return $this->getDbStarts(); + break; + case 2: + return $this->getDbEnds(); + break; + case 3: + return $this->getDbFileId(); + break; + case 4: + return $this->getDbStreamId(); + break; + case 5: + return $this->getDbClipLength(); + break; + case 6: + return $this->getDbFadeIn(); + break; + case 7: + return $this->getDbFadeOut(); + break; + case 8: + return $this->getDbCueIn(); + break; + case 9: + return $this->getDbCueOut(); + break; + case 10: + return $this->getDbMediaItemPlayed(); + break; + case 11: + return $this->getDbInstanceId(); + break; + case 12: + return $this->getDbPlayoutStatus(); + break; + case 13: + return $this->getDbBroadcasted(); + break; + case 14: + return $this->getDbPosition(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcSchedule'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcSchedule'][$this->getPrimaryKey()] = true; + $keys = CcSchedulePeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbStarts(), + $keys[2] => $this->getDbEnds(), + $keys[3] => $this->getDbFileId(), + $keys[4] => $this->getDbStreamId(), + $keys[5] => $this->getDbClipLength(), + $keys[6] => $this->getDbFadeIn(), + $keys[7] => $this->getDbFadeOut(), + $keys[8] => $this->getDbCueIn(), + $keys[9] => $this->getDbCueOut(), + $keys[10] => $this->getDbMediaItemPlayed(), + $keys[11] => $this->getDbInstanceId(), + $keys[12] => $this->getDbPlayoutStatus(), + $keys[13] => $this->getDbBroadcasted(), + $keys[14] => $this->getDbPosition(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcShowInstances) { + $result['CcShowInstances'] = $this->aCcShowInstances->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aCcFiles) { + $result['CcFiles'] = $this->aCcFiles->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aCcWebstream) { + $result['CcWebstream'] = $this->aCcWebstream->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collCcWebstreamMetadatas) { + $result['CcWebstreamMetadatas'] = $this->collCcWebstreamMetadatas->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcSchedulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbStarts($value); + break; + case 2: + $this->setDbEnds($value); + break; + case 3: + $this->setDbFileId($value); + break; + case 4: + $this->setDbStreamId($value); + break; + case 5: + $this->setDbClipLength($value); + break; + case 6: + $this->setDbFadeIn($value); + break; + case 7: + $this->setDbFadeOut($value); + break; + case 8: + $this->setDbCueIn($value); + break; + case 9: + $this->setDbCueOut($value); + break; + case 10: + $this->setDbMediaItemPlayed($value); + break; + case 11: + $this->setDbInstanceId($value); + break; + case 12: + $this->setDbPlayoutStatus($value); + break; + case 13: + $this->setDbBroadcasted($value); + break; + case 14: + $this->setDbPosition($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 BasePeer::TYPE_PHPNAME + * + * @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->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbStarts($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbEnds($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbFileId($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbStreamId($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbClipLength($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbFadeIn($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbFadeOut($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setDbCueIn($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDbCueOut($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setDbMediaItemPlayed($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setDbInstanceId($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setDbPlayoutStatus($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setDbBroadcasted($arr[$keys[13]]); + if (array_key_exists($keys[14], $arr)) $this->setDbPosition($arr[$keys[14]]); + } + + /** + * 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::STARTS)) $criteria->add(CcSchedulePeer::STARTS, $this->starts); + if ($this->isColumnModified(CcSchedulePeer::ENDS)) $criteria->add(CcSchedulePeer::ENDS, $this->ends); + if ($this->isColumnModified(CcSchedulePeer::FILE_ID)) $criteria->add(CcSchedulePeer::FILE_ID, $this->file_id); + if ($this->isColumnModified(CcSchedulePeer::STREAM_ID)) $criteria->add(CcSchedulePeer::STREAM_ID, $this->stream_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); + if ($this->isColumnModified(CcSchedulePeer::MEDIA_ITEM_PLAYED)) $criteria->add(CcSchedulePeer::MEDIA_ITEM_PLAYED, $this->media_item_played); + if ($this->isColumnModified(CcSchedulePeer::INSTANCE_ID)) $criteria->add(CcSchedulePeer::INSTANCE_ID, $this->instance_id); + if ($this->isColumnModified(CcSchedulePeer::PLAYOUT_STATUS)) $criteria->add(CcSchedulePeer::PLAYOUT_STATUS, $this->playout_status); + if ($this->isColumnModified(CcSchedulePeer::BROADCASTED)) $criteria->add(CcSchedulePeer::BROADCASTED, $this->broadcasted); + if ($this->isColumnModified(CcSchedulePeer::POSITION)) $criteria->add(CcSchedulePeer::POSITION, $this->position); + + 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 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 CcSchedule (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbStarts($this->getDbStarts()); + $copyObj->setDbEnds($this->getDbEnds()); + $copyObj->setDbFileId($this->getDbFileId()); + $copyObj->setDbStreamId($this->getDbStreamId()); + $copyObj->setDbClipLength($this->getDbClipLength()); + $copyObj->setDbFadeIn($this->getDbFadeIn()); + $copyObj->setDbFadeOut($this->getDbFadeOut()); + $copyObj->setDbCueIn($this->getDbCueIn()); + $copyObj->setDbCueOut($this->getDbCueOut()); + $copyObj->setDbMediaItemPlayed($this->getDbMediaItemPlayed()); + $copyObj->setDbInstanceId($this->getDbInstanceId()); + $copyObj->setDbPlayoutStatus($this->getDbPlayoutStatus()); + $copyObj->setDbBroadcasted($this->getDbBroadcasted()); + $copyObj->setDbPosition($this->getDbPosition()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + foreach ($this->getCcWebstreamMetadatas() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcWebstreamMetadata($relObj->copy($deepCopy)); + } + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 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; + } + + /** + * Declares an association between this object and a CcShowInstances object. + * + * @param CcShowInstances $v + * @return CcSchedule The current object (for fluent API support) + * @throws PropelException + */ + public function setCcShowInstances(CcShowInstances $v = null) + { + if ($v === null) { + $this->setDbInstanceId(NULL); + } else { + $this->setDbInstanceId($v->getDbId()); + } + + $this->aCcShowInstances = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcShowInstances object, it will not be re-added. + if ($v !== null) { + $v->addCcSchedule($this); + } + + + return $this; + } + + + /** + * Get the associated CcShowInstances object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcShowInstances The associated CcShowInstances object. + * @throws PropelException + */ + public function getCcShowInstances(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcShowInstances === null && ($this->instance_id !== null) && $doQuery) { + $this->aCcShowInstances = CcShowInstancesQuery::create()->findPk($this->instance_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->aCcShowInstances->addCcSchedules($this); + */ + } + + return $this->aCcShowInstances; + } + + /** + * Declares an association between this object and a CcFiles object. + * + * @param CcFiles $v + * @return CcSchedule 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->addCcSchedule($this); + } + + + return $this; + } + + + /** + * Get the associated CcFiles object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcFiles The associated CcFiles object. + * @throws PropelException + */ + public function getCcFiles(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcFiles === null && ($this->file_id !== null) && $doQuery) { + $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->addCcSchedules($this); + */ + } + + return $this->aCcFiles; + } + + /** + * Declares an association between this object and a CcWebstream object. + * + * @param CcWebstream $v + * @return CcSchedule The current object (for fluent API support) + * @throws PropelException + */ + public function setCcWebstream(CcWebstream $v = null) + { + if ($v === null) { + $this->setDbStreamId(NULL); + } else { + $this->setDbStreamId($v->getDbId()); + } + + $this->aCcWebstream = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcWebstream object, it will not be re-added. + if ($v !== null) { + $v->addCcSchedule($this); + } + + + return $this; + } + + + /** + * Get the associated CcWebstream object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcWebstream The associated CcWebstream object. + * @throws PropelException + */ + public function getCcWebstream(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcWebstream === null && ($this->stream_id !== null) && $doQuery) { + $this->aCcWebstream = CcWebstreamQuery::create()->findPk($this->stream_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->aCcWebstream->addCcSchedules($this); + */ + } + + return $this->aCcWebstream; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('CcWebstreamMetadata' == $relationName) { + $this->initCcWebstreamMetadatas(); + } + } + + /** + * Clears out the collCcWebstreamMetadatas 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 CcSchedule The current object (for fluent API support) + * @see addCcWebstreamMetadatas() + */ + public function clearCcWebstreamMetadatas() + { + $this->collCcWebstreamMetadatas = null; // important to set this to null since that means it is uninitialized + $this->collCcWebstreamMetadatasPartial = null; + + return $this; + } + + /** + * reset is the collCcWebstreamMetadatas collection loaded partially + * + * @return void + */ + public function resetPartialCcWebstreamMetadatas($v = true) + { + $this->collCcWebstreamMetadatasPartial = $v; + } + + /** + * Initializes the collCcWebstreamMetadatas collection. + * + * By default this just sets the collCcWebstreamMetadatas collection to an empty array (like clearcollCcWebstreamMetadatas()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcWebstreamMetadatas($overrideExisting = true) + { + if (null !== $this->collCcWebstreamMetadatas && !$overrideExisting) { + return; + } + $this->collCcWebstreamMetadatas = new PropelObjectCollection(); + $this->collCcWebstreamMetadatas->setModel('CcWebstreamMetadata'); + } + + /** + * Gets an array of CcWebstreamMetadata 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 CcSchedule 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 PropelObjectCollection|CcWebstreamMetadata[] List of CcWebstreamMetadata objects + * @throws PropelException + */ + public function getCcWebstreamMetadatas($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcWebstreamMetadatasPartial && !$this->isNew(); + if (null === $this->collCcWebstreamMetadatas || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcWebstreamMetadatas) { + // return empty collection + $this->initCcWebstreamMetadatas(); + } else { + $collCcWebstreamMetadatas = CcWebstreamMetadataQuery::create(null, $criteria) + ->filterByCcSchedule($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcWebstreamMetadatasPartial && count($collCcWebstreamMetadatas)) { + $this->initCcWebstreamMetadatas(false); + + foreach ($collCcWebstreamMetadatas as $obj) { + if (false == $this->collCcWebstreamMetadatas->contains($obj)) { + $this->collCcWebstreamMetadatas->append($obj); + } + } + + $this->collCcWebstreamMetadatasPartial = true; + } + + $collCcWebstreamMetadatas->getInternalIterator()->rewind(); + + return $collCcWebstreamMetadatas; + } + + if ($partial && $this->collCcWebstreamMetadatas) { + foreach ($this->collCcWebstreamMetadatas as $obj) { + if ($obj->isNew()) { + $collCcWebstreamMetadatas[] = $obj; + } + } + } + + $this->collCcWebstreamMetadatas = $collCcWebstreamMetadatas; + $this->collCcWebstreamMetadatasPartial = false; + } + } + + return $this->collCcWebstreamMetadatas; + } + + /** + * Sets a collection of CcWebstreamMetadata objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccWebstreamMetadatas A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcSchedule The current object (for fluent API support) + */ + public function setCcWebstreamMetadatas(PropelCollection $ccWebstreamMetadatas, PropelPDO $con = null) + { + $ccWebstreamMetadatasToDelete = $this->getCcWebstreamMetadatas(new Criteria(), $con)->diff($ccWebstreamMetadatas); + + + $this->ccWebstreamMetadatasScheduledForDeletion = $ccWebstreamMetadatasToDelete; + + foreach ($ccWebstreamMetadatasToDelete as $ccWebstreamMetadataRemoved) { + $ccWebstreamMetadataRemoved->setCcSchedule(null); + } + + $this->collCcWebstreamMetadatas = null; + foreach ($ccWebstreamMetadatas as $ccWebstreamMetadata) { + $this->addCcWebstreamMetadata($ccWebstreamMetadata); + } + + $this->collCcWebstreamMetadatas = $ccWebstreamMetadatas; + $this->collCcWebstreamMetadatasPartial = false; + + return $this; + } + + /** + * Returns the number of related CcWebstreamMetadata objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcWebstreamMetadata objects. + * @throws PropelException + */ + public function countCcWebstreamMetadatas(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcWebstreamMetadatasPartial && !$this->isNew(); + if (null === $this->collCcWebstreamMetadatas || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcWebstreamMetadatas) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcWebstreamMetadatas()); + } + $query = CcWebstreamMetadataQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcSchedule($this) + ->count($con); + } + + return count($this->collCcWebstreamMetadatas); + } + + /** + * Method called to associate a CcWebstreamMetadata object to this object + * through the CcWebstreamMetadata foreign key attribute. + * + * @param CcWebstreamMetadata $l CcWebstreamMetadata + * @return CcSchedule The current object (for fluent API support) + */ + public function addCcWebstreamMetadata(CcWebstreamMetadata $l) + { + if ($this->collCcWebstreamMetadatas === null) { + $this->initCcWebstreamMetadatas(); + $this->collCcWebstreamMetadatasPartial = true; + } + + if (!in_array($l, $this->collCcWebstreamMetadatas->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcWebstreamMetadata($l); + + if ($this->ccWebstreamMetadatasScheduledForDeletion and $this->ccWebstreamMetadatasScheduledForDeletion->contains($l)) { + $this->ccWebstreamMetadatasScheduledForDeletion->remove($this->ccWebstreamMetadatasScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcWebstreamMetadata $ccWebstreamMetadata The ccWebstreamMetadata object to add. + */ + protected function doAddCcWebstreamMetadata($ccWebstreamMetadata) + { + $this->collCcWebstreamMetadatas[]= $ccWebstreamMetadata; + $ccWebstreamMetadata->setCcSchedule($this); + } + + /** + * @param CcWebstreamMetadata $ccWebstreamMetadata The ccWebstreamMetadata object to remove. + * @return CcSchedule The current object (for fluent API support) + */ + public function removeCcWebstreamMetadata($ccWebstreamMetadata) + { + if ($this->getCcWebstreamMetadatas()->contains($ccWebstreamMetadata)) { + $this->collCcWebstreamMetadatas->remove($this->collCcWebstreamMetadatas->search($ccWebstreamMetadata)); + if (null === $this->ccWebstreamMetadatasScheduledForDeletion) { + $this->ccWebstreamMetadatasScheduledForDeletion = clone $this->collCcWebstreamMetadatas; + $this->ccWebstreamMetadatasScheduledForDeletion->clear(); + } + $this->ccWebstreamMetadatasScheduledForDeletion[]= clone $ccWebstreamMetadata; + $ccWebstreamMetadata->setCcSchedule(null); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->starts = null; + $this->ends = null; + $this->file_id = null; + $this->stream_id = null; + $this->clip_length = null; + $this->fade_in = null; + $this->fade_out = null; + $this->cue_in = null; + $this->cue_out = null; + $this->media_item_played = null; + $this->instance_id = null; + $this->playout_status = null; + $this->broadcasted = null; + $this->position = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->collCcWebstreamMetadatas) { + foreach ($this->collCcWebstreamMetadatas as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->aCcShowInstances instanceof Persistent) { + $this->aCcShowInstances->clearAllReferences($deep); + } + if ($this->aCcFiles instanceof Persistent) { + $this->aCcFiles->clearAllReferences($deep); + } + if ($this->aCcWebstream instanceof Persistent) { + $this->aCcWebstream->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + if ($this->collCcWebstreamMetadatas instanceof PropelCollection) { + $this->collCcWebstreamMetadatas->clearIterator(); + } + $this->collCcWebstreamMetadatas = null; + $this->aCcShowInstances = null; + $this->aCcFiles = null; + $this->aCcWebstream = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcSchedulePeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcSchedulePeer.php b/airtime_mvc/application/models/airtime/om/BaseCcSchedulePeer.php index 164830444..350d70da2 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcSchedulePeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcSchedulePeer.php @@ -1,1766 +1,1818 @@ array ('DbId', 'DbStarts', 'DbEnds', 'DbFileId', 'DbStreamId', 'DbClipLength', 'DbFadeIn', 'DbFadeOut', 'DbCueIn', 'DbCueOut', 'DbMediaItemPlayed', 'DbInstanceId', 'DbPlayoutStatus', 'DbBroadcasted', 'DbPosition', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbFileId', 'dbStreamId', 'dbClipLength', 'dbFadeIn', 'dbFadeOut', 'dbCueIn', 'dbCueOut', 'dbMediaItemPlayed', 'dbInstanceId', 'dbPlayoutStatus', 'dbBroadcasted', 'dbPosition', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::FILE_ID, self::STREAM_ID, self::CLIP_LENGTH, self::FADE_IN, self::FADE_OUT, self::CUE_IN, self::CUE_OUT, self::MEDIA_ITEM_PLAYED, self::INSTANCE_ID, self::PLAYOUT_STATUS, self::BROADCASTED, self::POSITION, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'FILE_ID', 'STREAM_ID', 'CLIP_LENGTH', 'FADE_IN', 'FADE_OUT', 'CUE_IN', 'CUE_OUT', 'MEDIA_ITEM_PLAYED', 'INSTANCE_ID', 'PLAYOUT_STATUS', 'BROADCASTED', 'POSITION', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'file_id', 'stream_id', 'clip_length', 'fade_in', 'fade_out', 'cue_in', 'cue_out', 'media_item_played', 'instance_id', 'playout_status', 'broadcasted', 'position', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ) - ); - - /** - * 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, 'DbStarts' => 1, 'DbEnds' => 2, 'DbFileId' => 3, 'DbStreamId' => 4, 'DbClipLength' => 5, 'DbFadeIn' => 6, 'DbFadeOut' => 7, 'DbCueIn' => 8, 'DbCueOut' => 9, 'DbMediaItemPlayed' => 10, 'DbInstanceId' => 11, 'DbPlayoutStatus' => 12, 'DbBroadcasted' => 13, 'DbPosition' => 14, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbFileId' => 3, 'dbStreamId' => 4, 'dbClipLength' => 5, 'dbFadeIn' => 6, 'dbFadeOut' => 7, 'dbCueIn' => 8, 'dbCueOut' => 9, 'dbMediaItemPlayed' => 10, 'dbInstanceId' => 11, 'dbPlayoutStatus' => 12, 'dbBroadcasted' => 13, 'dbPosition' => 14, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::FILE_ID => 3, self::STREAM_ID => 4, self::CLIP_LENGTH => 5, self::FADE_IN => 6, self::FADE_OUT => 7, self::CUE_IN => 8, self::CUE_OUT => 9, self::MEDIA_ITEM_PLAYED => 10, self::INSTANCE_ID => 11, self::PLAYOUT_STATUS => 12, self::BROADCASTED => 13, self::POSITION => 14, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'FILE_ID' => 3, 'STREAM_ID' => 4, 'CLIP_LENGTH' => 5, 'FADE_IN' => 6, 'FADE_OUT' => 7, 'CUE_IN' => 8, 'CUE_OUT' => 9, 'MEDIA_ITEM_PLAYED' => 10, 'INSTANCE_ID' => 11, 'PLAYOUT_STATUS' => 12, 'BROADCASTED' => 13, 'POSITION' => 14, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'file_id' => 3, 'stream_id' => 4, 'clip_length' => 5, 'fade_in' => 6, 'fade_out' => 7, 'cue_in' => 8, 'cue_out' => 9, 'media_item_played' => 10, 'instance_id' => 11, 'playout_status' => 12, 'broadcasted' => 13, 'position' => 14, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ) - ); - - /** - * 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::STARTS); - $criteria->addSelectColumn(CcSchedulePeer::ENDS); - $criteria->addSelectColumn(CcSchedulePeer::FILE_ID); - $criteria->addSelectColumn(CcSchedulePeer::STREAM_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); - $criteria->addSelectColumn(CcSchedulePeer::MEDIA_ITEM_PLAYED); - $criteria->addSelectColumn(CcSchedulePeer::INSTANCE_ID); - $criteria->addSelectColumn(CcSchedulePeer::PLAYOUT_STATUS); - $criteria->addSelectColumn(CcSchedulePeer::BROADCASTED); - $criteria->addSelectColumn(CcSchedulePeer::POSITION); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.STARTS'); - $criteria->addSelectColumn($alias . '.ENDS'); - $criteria->addSelectColumn($alias . '.FILE_ID'); - $criteria->addSelectColumn($alias . '.STREAM_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'); - $criteria->addSelectColumn($alias . '.MEDIA_ITEM_PLAYED'); - $criteria->addSelectColumn($alias . '.INSTANCE_ID'); - $criteria->addSelectColumn($alias . '.PLAYOUT_STATUS'); - $criteria->addSelectColumn($alias . '.BROADCASTED'); - $criteria->addSelectColumn($alias . '.POSITION'); - } - } - - /** - * 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->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 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->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 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() - { - // Invalidate objects in CcWebstreamMetadataPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcWebstreamMetadataPeer::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 = 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 number of rows matching criteria, joining the related CcShowInstances 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 doCountJoinCcShowInstances(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(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 - - // Set the correct dbName - $criteria->setDbName(self::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::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 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(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 - - // Set the correct dbName - $criteria->setDbName(self::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcSchedulePeer::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 CcWebstream 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 doCountJoinCcWebstream(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(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 - - // Set the correct dbName - $criteria->setDbName(self::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcSchedulePeer::STREAM_ID, CcWebstreamPeer::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 CcSchedule objects pre-filled with their CcShowInstances 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 CcSchedule objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCcShowInstances(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); - } - - CcSchedulePeer::addSelectColumns($criteria); - $startcol = (CcSchedulePeer::NUM_COLUMNS - CcSchedulePeer::NUM_LAZY_LOAD_COLUMNS); - CcShowInstancesPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcSchedulePeer::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 = CcSchedulePeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcSchedulePeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcShowInstancesPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowInstancesPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcShowInstancesPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcSchedule) to $obj2 (CcShowInstances) - $obj2->addCcSchedule($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcSchedule 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 CcSchedule 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); - } - - CcSchedulePeer::addSelectColumns($criteria); - $startcol = (CcSchedulePeer::NUM_COLUMNS - CcSchedulePeer::NUM_LAZY_LOAD_COLUMNS); - CcFilesPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcSchedulePeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcSchedulePeer::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 = CcSchedulePeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcSchedulePeer::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 (CcSchedule) to $obj2 (CcFiles) - $obj2->addCcSchedule($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcSchedule objects pre-filled with their CcWebstream 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 CcSchedule objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCcWebstream(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); - } - - CcSchedulePeer::addSelectColumns($criteria); - $startcol = (CcSchedulePeer::NUM_COLUMNS - CcSchedulePeer::NUM_LAZY_LOAD_COLUMNS); - CcWebstreamPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcSchedulePeer::STREAM_ID, CcWebstreamPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcSchedulePeer::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 = CcSchedulePeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcSchedulePeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CcWebstreamPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcWebstreamPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcWebstreamPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcWebstreamPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcSchedule) to $obj2 (CcWebstream) - $obj2->addCcSchedule($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(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 - - // Set the correct dbName - $criteria->setDbName(self::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); - - $criteria->addJoin(CcSchedulePeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $criteria->addJoin(CcSchedulePeer::STREAM_ID, CcWebstreamPeer::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 CcSchedule 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 CcSchedule 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); - } - - CcSchedulePeer::addSelectColumns($criteria); - $startcol2 = (CcSchedulePeer::NUM_COLUMNS - CcSchedulePeer::NUM_LAZY_LOAD_COLUMNS); - - CcShowInstancesPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS); - - CcFilesPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); - - CcWebstreamPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + (CcWebstreamPeer::NUM_COLUMNS - CcWebstreamPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); - - $criteria->addJoin(CcSchedulePeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $criteria->addJoin(CcSchedulePeer::STREAM_ID, CcWebstreamPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcSchedulePeer::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 = CcSchedulePeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcSchedulePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcShowInstances rows - - $key2 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcShowInstancesPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowInstancesPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcShowInstancesPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (CcSchedule) to the collection in $obj2 (CcShowInstances) - $obj2->addCcSchedule($obj1); - } // if joined row not null - - // Add objects for joined CcFiles rows - - $key3 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CcFilesPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CcFilesPeer::getOMClass(false); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CcFilesPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (CcSchedule) to the collection in $obj3 (CcFiles) - $obj3->addCcSchedule($obj1); - } // if joined row not null - - // Add objects for joined CcWebstream rows - - $key4 = CcWebstreamPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = CcWebstreamPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = CcWebstreamPeer::getOMClass(false); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - CcWebstreamPeer::addInstanceToPool($obj4, $key4); - } // if obj4 loaded - - // Add the $obj1 (CcSchedule) to the collection in $obj4 (CcWebstream) - $obj4->addCcSchedule($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related CcShowInstances 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 doCountJoinAllExceptCcShowInstances(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(CcSchedulePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcSchedulePeer::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(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcSchedulePeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $criteria->addJoin(CcSchedulePeer::STREAM_ID, CcWebstreamPeer::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 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(CcSchedulePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcSchedulePeer::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(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); - - $criteria->addJoin(CcSchedulePeer::STREAM_ID, CcWebstreamPeer::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 CcWebstream 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 doCountJoinAllExceptCcWebstream(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(CcSchedulePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcSchedulePeer::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(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); - - $criteria->addJoin(CcSchedulePeer::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 CcSchedule objects pre-filled with all related objects except CcShowInstances. - * - * @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 CcSchedule objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCcShowInstances(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); - } - - CcSchedulePeer::addSelectColumns($criteria); - $startcol2 = (CcSchedulePeer::NUM_COLUMNS - CcSchedulePeer::NUM_LAZY_LOAD_COLUMNS); - - CcFilesPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); - - CcWebstreamPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + (CcWebstreamPeer::NUM_COLUMNS - CcWebstreamPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcSchedulePeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $criteria->addJoin(CcSchedulePeer::STREAM_ID, CcWebstreamPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcSchedulePeer::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 = CcSchedulePeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcSchedulePeer::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 (CcSchedule) to the collection in $obj2 (CcFiles) - $obj2->addCcSchedule($obj1); - - } // if joined row is not null - - // Add objects for joined CcWebstream rows - - $key3 = CcWebstreamPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CcWebstreamPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CcWebstreamPeer::getOMClass(false); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CcWebstreamPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (CcSchedule) to the collection in $obj3 (CcWebstream) - $obj3->addCcSchedule($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcSchedule 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 CcSchedule 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); - } - - CcSchedulePeer::addSelectColumns($criteria); - $startcol2 = (CcSchedulePeer::NUM_COLUMNS - CcSchedulePeer::NUM_LAZY_LOAD_COLUMNS); - - CcShowInstancesPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS); - - CcWebstreamPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + (CcWebstreamPeer::NUM_COLUMNS - CcWebstreamPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); - - $criteria->addJoin(CcSchedulePeer::STREAM_ID, CcWebstreamPeer::ID, $join_behavior); + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + /** the table name for this class */ + const TABLE_NAME = 'cc_schedule'; - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcSchedulePeer::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 = CcSchedulePeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcSchedulePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcShowInstances rows - - $key2 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcShowInstancesPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowInstancesPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcShowInstancesPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (CcSchedule) to the collection in $obj2 (CcShowInstances) - $obj2->addCcSchedule($obj1); - - } // if joined row is not null - - // Add objects for joined CcWebstream rows - - $key3 = CcWebstreamPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CcWebstreamPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CcWebstreamPeer::getOMClass(false); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CcWebstreamPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (CcSchedule) to the collection in $obj3 (CcWebstream) - $obj3->addCcSchedule($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcSchedule objects pre-filled with all related objects except CcWebstream. - * - * @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 CcSchedule objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCcWebstream(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); - } - - CcSchedulePeer::addSelectColumns($criteria); - $startcol2 = (CcSchedulePeer::NUM_COLUMNS - CcSchedulePeer::NUM_LAZY_LOAD_COLUMNS); - - CcShowInstancesPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS); - - CcFilesPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); - - $criteria->addJoin(CcSchedulePeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcSchedulePeer::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 = CcSchedulePeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcSchedulePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcShowInstances rows - - $key2 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcShowInstancesPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowInstancesPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcShowInstancesPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (CcSchedule) to the collection in $obj2 (CcShowInstances) - $obj2->addCcSchedule($obj1); - - } // if joined row is not null - - // Add objects for joined CcFiles rows - - $key3 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CcFilesPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CcFilesPeer::getOMClass(false); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CcFilesPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (CcSchedule) to the collection in $obj3 (CcFiles) - $obj3->addCcSchedule($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(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 - } - - if ($criteria->containsKey(CcSchedulePeer::ID) && $criteria->keyContainsValue(CcSchedulePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSchedulePeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(self::DATABASE_NAME); - - 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 int $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; - } + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcSchedule'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcScheduleTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 15; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 15; + + /** the column name for the id field */ + const ID = 'cc_schedule.id'; + + /** the column name for the starts field */ + const STARTS = 'cc_schedule.starts'; + + /** the column name for the ends field */ + const ENDS = 'cc_schedule.ends'; + + /** the column name for the file_id field */ + const FILE_ID = 'cc_schedule.file_id'; + + /** the column name for the stream_id field */ + const STREAM_ID = 'cc_schedule.stream_id'; + + /** the column name for the clip_length field */ + const CLIP_LENGTH = 'cc_schedule.clip_length'; + + /** the column name for the fade_in field */ + const FADE_IN = 'cc_schedule.fade_in'; + + /** the column name for the fade_out field */ + const FADE_OUT = 'cc_schedule.fade_out'; + + /** the column name for the cue_in field */ + const CUE_IN = 'cc_schedule.cue_in'; + + /** the column name for the cue_out field */ + const CUE_OUT = 'cc_schedule.cue_out'; + + /** the column name for the media_item_played field */ + const MEDIA_ITEM_PLAYED = 'cc_schedule.media_item_played'; + + /** the column name for the instance_id field */ + const INSTANCE_ID = 'cc_schedule.instance_id'; + + /** the column name for the playout_status field */ + const PLAYOUT_STATUS = 'cc_schedule.playout_status'; + + /** the column name for the broadcasted field */ + const BROADCASTED = 'cc_schedule.broadcasted'; + + /** the column name for the position field */ + const POSITION = 'cc_schedule.position'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcSchedule objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcSchedule[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcSchedulePeer::$fieldNames[CcSchedulePeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbFileId', 'DbStreamId', 'DbClipLength', 'DbFadeIn', 'DbFadeOut', 'DbCueIn', 'DbCueOut', 'DbMediaItemPlayed', 'DbInstanceId', 'DbPlayoutStatus', 'DbBroadcasted', 'DbPosition', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbFileId', 'dbStreamId', 'dbClipLength', 'dbFadeIn', 'dbFadeOut', 'dbCueIn', 'dbCueOut', 'dbMediaItemPlayed', 'dbInstanceId', 'dbPlayoutStatus', 'dbBroadcasted', 'dbPosition', ), + BasePeer::TYPE_COLNAME => array (CcSchedulePeer::ID, CcSchedulePeer::STARTS, CcSchedulePeer::ENDS, CcSchedulePeer::FILE_ID, CcSchedulePeer::STREAM_ID, CcSchedulePeer::CLIP_LENGTH, CcSchedulePeer::FADE_IN, CcSchedulePeer::FADE_OUT, CcSchedulePeer::CUE_IN, CcSchedulePeer::CUE_OUT, CcSchedulePeer::MEDIA_ITEM_PLAYED, CcSchedulePeer::INSTANCE_ID, CcSchedulePeer::PLAYOUT_STATUS, CcSchedulePeer::BROADCASTED, CcSchedulePeer::POSITION, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'FILE_ID', 'STREAM_ID', 'CLIP_LENGTH', 'FADE_IN', 'FADE_OUT', 'CUE_IN', 'CUE_OUT', 'MEDIA_ITEM_PLAYED', 'INSTANCE_ID', 'PLAYOUT_STATUS', 'BROADCASTED', 'POSITION', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'file_id', 'stream_id', 'clip_length', 'fade_in', 'fade_out', 'cue_in', 'cue_out', 'media_item_played', 'instance_id', 'playout_status', 'broadcasted', 'position', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcSchedulePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbFileId' => 3, 'DbStreamId' => 4, 'DbClipLength' => 5, 'DbFadeIn' => 6, 'DbFadeOut' => 7, 'DbCueIn' => 8, 'DbCueOut' => 9, 'DbMediaItemPlayed' => 10, 'DbInstanceId' => 11, 'DbPlayoutStatus' => 12, 'DbBroadcasted' => 13, 'DbPosition' => 14, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbFileId' => 3, 'dbStreamId' => 4, 'dbClipLength' => 5, 'dbFadeIn' => 6, 'dbFadeOut' => 7, 'dbCueIn' => 8, 'dbCueOut' => 9, 'dbMediaItemPlayed' => 10, 'dbInstanceId' => 11, 'dbPlayoutStatus' => 12, 'dbBroadcasted' => 13, 'dbPosition' => 14, ), + BasePeer::TYPE_COLNAME => array (CcSchedulePeer::ID => 0, CcSchedulePeer::STARTS => 1, CcSchedulePeer::ENDS => 2, CcSchedulePeer::FILE_ID => 3, CcSchedulePeer::STREAM_ID => 4, CcSchedulePeer::CLIP_LENGTH => 5, CcSchedulePeer::FADE_IN => 6, CcSchedulePeer::FADE_OUT => 7, CcSchedulePeer::CUE_IN => 8, CcSchedulePeer::CUE_OUT => 9, CcSchedulePeer::MEDIA_ITEM_PLAYED => 10, CcSchedulePeer::INSTANCE_ID => 11, CcSchedulePeer::PLAYOUT_STATUS => 12, CcSchedulePeer::BROADCASTED => 13, CcSchedulePeer::POSITION => 14, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'FILE_ID' => 3, 'STREAM_ID' => 4, 'CLIP_LENGTH' => 5, 'FADE_IN' => 6, 'FADE_OUT' => 7, 'CUE_IN' => 8, 'CUE_OUT' => 9, 'MEDIA_ITEM_PLAYED' => 10, 'INSTANCE_ID' => 11, 'PLAYOUT_STATUS' => 12, 'BROADCASTED' => 13, 'POSITION' => 14, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'file_id' => 3, 'stream_id' => 4, 'clip_length' => 5, 'fade_in' => 6, 'fade_out' => 7, 'cue_in' => 8, 'cue_out' => 9, 'media_item_played' => 10, 'instance_id' => 11, 'playout_status' => 12, 'broadcasted' => 13, 'position' => 14, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcSchedulePeer::getFieldNames($toType); + $key = isset(CcSchedulePeer::$fieldKeys[$fromType][$name]) ? CcSchedulePeer::$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(CcSchedulePeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcSchedulePeer::$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 CcSchedulePeer::$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::STARTS); + $criteria->addSelectColumn(CcSchedulePeer::ENDS); + $criteria->addSelectColumn(CcSchedulePeer::FILE_ID); + $criteria->addSelectColumn(CcSchedulePeer::STREAM_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); + $criteria->addSelectColumn(CcSchedulePeer::MEDIA_ITEM_PLAYED); + $criteria->addSelectColumn(CcSchedulePeer::INSTANCE_ID); + $criteria->addSelectColumn(CcSchedulePeer::PLAYOUT_STATUS); + $criteria->addSelectColumn(CcSchedulePeer::BROADCASTED); + $criteria->addSelectColumn(CcSchedulePeer::POSITION); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.starts'); + $criteria->addSelectColumn($alias . '.ends'); + $criteria->addSelectColumn($alias . '.file_id'); + $criteria->addSelectColumn($alias . '.stream_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'); + $criteria->addSelectColumn($alias . '.media_item_played'); + $criteria->addSelectColumn($alias . '.instance_id'); + $criteria->addSelectColumn($alias . '.playout_status'); + $criteria->addSelectColumn($alias . '.broadcasted'); + $criteria->addSelectColumn($alias . '.position'); + } + } + + /** + * 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(CcSchedulePeer::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; + } + /** + * Selects 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; + } + /** + * Selects several row from the DB. + * + * @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 directly (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(CcSchedulePeer::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 $obj 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($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcSchedulePeer::$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. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcSchedule) { + $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 CcSchedule object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcSchedulePeer::$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(CcSchedulePeer::$instances[$key])) { + return CcSchedulePeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcSchedulePeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcSchedulePeer::$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() + { + // Invalidate objects in CcWebstreamMetadataPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcWebstreamMetadataPeer::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 = CcSchedulePeer::getOMClass(); + // 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_HYDRATE_COLUMNS; + } else { + $cls = CcSchedulePeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcSchedulePeer::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + + /** + * Returns the number of rows matching criteria, joining the related CcShowInstances 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 doCountJoinCcShowInstances(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(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 + + // Set the correct dbName + $criteria->setDbName(CcSchedulePeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::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 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(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 + + // Set the correct dbName + $criteria->setDbName(CcSchedulePeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcSchedulePeer::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 CcWebstream 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 doCountJoinCcWebstream(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(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 + + // Set the correct dbName + $criteria->setDbName(CcSchedulePeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcSchedulePeer::STREAM_ID, CcWebstreamPeer::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 CcSchedule objects pre-filled with their CcShowInstances 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 CcSchedule objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcShowInstances(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(CcSchedulePeer::DATABASE_NAME); + } + + CcSchedulePeer::addSelectColumns($criteria); + $startcol = CcSchedulePeer::NUM_HYDRATE_COLUMNS; + CcShowInstancesPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcSchedulePeer::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 = CcSchedulePeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcSchedulePeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcShowInstancesPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowInstancesPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcShowInstancesPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcSchedule) to $obj2 (CcShowInstances) + $obj2->addCcSchedule($obj1); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcSchedule 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 CcSchedule 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(CcSchedulePeer::DATABASE_NAME); + } + + CcSchedulePeer::addSelectColumns($criteria); + $startcol = CcSchedulePeer::NUM_HYDRATE_COLUMNS; + CcFilesPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcSchedulePeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcSchedulePeer::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 = CcSchedulePeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcSchedulePeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcFilesPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcFilesPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcFilesPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcSchedule) to $obj2 (CcFiles) + $obj2->addCcSchedule($obj1); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcSchedule objects pre-filled with their CcWebstream 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 CcSchedule objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcWebstream(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(CcSchedulePeer::DATABASE_NAME); + } + + CcSchedulePeer::addSelectColumns($criteria); + $startcol = CcSchedulePeer::NUM_HYDRATE_COLUMNS; + CcWebstreamPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcSchedulePeer::STREAM_ID, CcWebstreamPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcSchedulePeer::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 = CcSchedulePeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcSchedulePeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcWebstreamPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcWebstreamPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcWebstreamPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcWebstreamPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcSchedule) to $obj2 (CcWebstream) + $obj2->addCcSchedule($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(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 + + // Set the correct dbName + $criteria->setDbName(CcSchedulePeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); + + $criteria->addJoin(CcSchedulePeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $criteria->addJoin(CcSchedulePeer::STREAM_ID, CcWebstreamPeer::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 CcSchedule 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 CcSchedule 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(CcSchedulePeer::DATABASE_NAME); + } + + CcSchedulePeer::addSelectColumns($criteria); + $startcol2 = CcSchedulePeer::NUM_HYDRATE_COLUMNS; + + CcShowInstancesPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcShowInstancesPeer::NUM_HYDRATE_COLUMNS; + + CcFilesPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcFilesPeer::NUM_HYDRATE_COLUMNS; + + CcWebstreamPeer::addSelectColumns($criteria); + $startcol5 = $startcol4 + CcWebstreamPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); + + $criteria->addJoin(CcSchedulePeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $criteria->addJoin(CcSchedulePeer::STREAM_ID, CcWebstreamPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcSchedulePeer::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 = CcSchedulePeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcSchedulePeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcShowInstances rows + + $key2 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcShowInstancesPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowInstancesPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcShowInstancesPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcSchedule) to the collection in $obj2 (CcShowInstances) + $obj2->addCcSchedule($obj1); + } // if joined row not null + + // Add objects for joined CcFiles rows + + $key3 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcFilesPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcFilesPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcFilesPeer::addInstanceToPool($obj3, $key3); + } // if obj3 loaded + + // Add the $obj1 (CcSchedule) to the collection in $obj3 (CcFiles) + $obj3->addCcSchedule($obj1); + } // if joined row not null + + // Add objects for joined CcWebstream rows + + $key4 = CcWebstreamPeer::getPrimaryKeyHashFromRow($row, $startcol4); + if ($key4 !== null) { + $obj4 = CcWebstreamPeer::getInstanceFromPool($key4); + if (!$obj4) { + + $cls = CcWebstreamPeer::getOMClass(); + + $obj4 = new $cls(); + $obj4->hydrate($row, $startcol4); + CcWebstreamPeer::addInstanceToPool($obj4, $key4); + } // if obj4 loaded + + // Add the $obj1 (CcSchedule) to the collection in $obj4 (CcWebstream) + $obj4->addCcSchedule($obj1); + } // if joined row not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining the related CcShowInstances 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 doCountJoinAllExceptCcShowInstances(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(CcSchedulePeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcSchedulePeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(CcSchedulePeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcSchedulePeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $criteria->addJoin(CcSchedulePeer::STREAM_ID, CcWebstreamPeer::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 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(CcSchedulePeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcSchedulePeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(CcSchedulePeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); + + $criteria->addJoin(CcSchedulePeer::STREAM_ID, CcWebstreamPeer::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 CcWebstream 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 doCountJoinAllExceptCcWebstream(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(CcSchedulePeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcSchedulePeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(CcSchedulePeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); + + $criteria->addJoin(CcSchedulePeer::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 CcSchedule objects pre-filled with all related objects except CcShowInstances. + * + * @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 CcSchedule objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcShowInstances(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(CcSchedulePeer::DATABASE_NAME); + } + + CcSchedulePeer::addSelectColumns($criteria); + $startcol2 = CcSchedulePeer::NUM_HYDRATE_COLUMNS; + + CcFilesPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcFilesPeer::NUM_HYDRATE_COLUMNS; + + CcWebstreamPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcWebstreamPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcSchedulePeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $criteria->addJoin(CcSchedulePeer::STREAM_ID, CcWebstreamPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcSchedulePeer::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 = CcSchedulePeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcSchedulePeer::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(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcFilesPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcSchedule) to the collection in $obj2 (CcFiles) + $obj2->addCcSchedule($obj1); + + } // if joined row is not null + + // Add objects for joined CcWebstream rows + + $key3 = CcWebstreamPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcWebstreamPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcWebstreamPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcWebstreamPeer::addInstanceToPool($obj3, $key3); + } // if $obj3 already loaded + + // Add the $obj1 (CcSchedule) to the collection in $obj3 (CcWebstream) + $obj3->addCcSchedule($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcSchedule 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 CcSchedule 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(CcSchedulePeer::DATABASE_NAME); + } + + CcSchedulePeer::addSelectColumns($criteria); + $startcol2 = CcSchedulePeer::NUM_HYDRATE_COLUMNS; + + CcShowInstancesPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcShowInstancesPeer::NUM_HYDRATE_COLUMNS; + + CcWebstreamPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcWebstreamPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); + + $criteria->addJoin(CcSchedulePeer::STREAM_ID, CcWebstreamPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcSchedulePeer::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 = CcSchedulePeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcSchedulePeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcShowInstances rows + + $key2 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcShowInstancesPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowInstancesPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcShowInstancesPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcSchedule) to the collection in $obj2 (CcShowInstances) + $obj2->addCcSchedule($obj1); + + } // if joined row is not null + + // Add objects for joined CcWebstream rows + + $key3 = CcWebstreamPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcWebstreamPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcWebstreamPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcWebstreamPeer::addInstanceToPool($obj3, $key3); + } // if $obj3 already loaded + + // Add the $obj1 (CcSchedule) to the collection in $obj3 (CcWebstream) + $obj3->addCcSchedule($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcSchedule objects pre-filled with all related objects except CcWebstream. + * + * @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 CcSchedule objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcWebstream(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(CcSchedulePeer::DATABASE_NAME); + } + + CcSchedulePeer::addSelectColumns($criteria); + $startcol2 = CcSchedulePeer::NUM_HYDRATE_COLUMNS; + + CcShowInstancesPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcShowInstancesPeer::NUM_HYDRATE_COLUMNS; + + CcFilesPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcFilesPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); + + $criteria->addJoin(CcSchedulePeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcSchedulePeer::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 = CcSchedulePeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcSchedulePeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcShowInstances rows + + $key2 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcShowInstancesPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowInstancesPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcShowInstancesPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcSchedule) to the collection in $obj2 (CcShowInstances) + $obj2->addCcSchedule($obj1); + + } // if joined row is not null + + // Add objects for joined CcFiles rows + + $key3 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcFilesPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcFilesPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcFilesPeer::addInstanceToPool($obj3, $key3); + } // if $obj3 already loaded + + // Add the $obj1 (CcSchedule) to the collection in $obj3 (CcFiles) + $obj3->addCcSchedule($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(CcSchedulePeer::DATABASE_NAME)->getTable(CcSchedulePeer::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 \Airtime\map\CcScheduleTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcSchedulePeer::OM_CLASS; + } + + /** + * Performs 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 + } + + if ($criteria->containsKey(CcSchedulePeer::ID) && $criteria->keyContainsValue(CcSchedulePeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSchedulePeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcSchedulePeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs 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(CcSchedulePeer::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(CcSchedulePeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_schedule table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $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 (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs 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(CcSchedulePeer::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(CcSchedulePeer::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 (Exception $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($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->hasColumn($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 int $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 + * @return CcSchedule[] + * @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 diff --git a/airtime_mvc/application/models/airtime/om/BaseCcScheduleQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcScheduleQuery.php index 45448d510..b21fc0086 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcScheduleQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcScheduleQuery.php @@ -1,886 +1,1213 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcSchedule|CcSchedule[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcSchedulePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $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); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcSchedule A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * 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); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcSchedule A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "starts", "ends", "file_id", "stream_id", "clip_length", "fade_in", "fade_out", "cue_in", "cue_out", "media_item_played", "instance_id", "playout_status", "broadcasted", "position" FROM "cc_schedule" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcSchedule(); + $obj->hydrate($row); + CcSchedulePeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcScheduleQuery 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(CcSchedulePeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * Filter the query on the starts column - * - * @param string|array $dbStarts 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 filterByDbStarts($dbStarts = null, $comparison = null) - { - if (is_array($dbStarts)) { - $useMinMax = false; - if (isset($dbStarts['min'])) { - $this->addUsingAlias(CcSchedulePeer::STARTS, $dbStarts['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbStarts['max'])) { - $this->addUsingAlias(CcSchedulePeer::STARTS, $dbStarts['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcSchedulePeer::STARTS, $dbStarts, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcSchedule|CcSchedule[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Filter the query on the ends column - * - * @param string|array $dbEnds 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 filterByDbEnds($dbEnds = null, $comparison = null) - { - if (is_array($dbEnds)) { - $useMinMax = false; - if (isset($dbEnds['min'])) { - $this->addUsingAlias(CcSchedulePeer::ENDS, $dbEnds['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbEnds['max'])) { - $this->addUsingAlias(CcSchedulePeer::ENDS, $dbEnds['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcSchedulePeer::ENDS, $dbEnds, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * 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 CcScheduleQuery 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(CcSchedulePeer::FILE_ID, $dbFileId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbFileId['max'])) { - $this->addUsingAlias(CcSchedulePeer::FILE_ID, $dbFileId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcSchedulePeer::FILE_ID, $dbFileId, $comparison); - } + /** + * 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|CcSchedule[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query on the stream_id column - * - * @param int|array $dbStreamId 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 filterByDbStreamId($dbStreamId = null, $comparison = null) - { - if (is_array($dbStreamId)) { - $useMinMax = false; - if (isset($dbStreamId['min'])) { - $this->addUsingAlias(CcSchedulePeer::STREAM_ID, $dbStreamId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbStreamId['max'])) { - $this->addUsingAlias(CcSchedulePeer::STREAM_ID, $dbStreamId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcSchedulePeer::STREAM_ID, $dbStreamId, $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Filter the query on the clip_length column - * - * @param string $dbClipLength 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 CcScheduleQuery The current query, for fluid interface - */ - public function filterByDbClipLength($dbClipLength = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbClipLength)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbClipLength)) { - $dbClipLength = str_replace('*', '%', $dbClipLength); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcSchedulePeer::CLIP_LENGTH, $dbClipLength, $comparison); - } + /** + * 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) + { - /** - * Filter the query on the fade_in 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 CcScheduleQuery 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(CcSchedulePeer::FADE_IN, $dbFadeIn['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbFadeIn['max'])) { - $this->addUsingAlias(CcSchedulePeer::FADE_IN, $dbFadeIn['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcSchedulePeer::FADE_IN, $dbFadeIn, $comparison); - } + return $this->addUsingAlias(CcSchedulePeer::ID, $key, Criteria::EQUAL); + } - /** - * Filter the query on the fade_out 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 CcScheduleQuery 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(CcSchedulePeer::FADE_OUT, $dbFadeOut['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbFadeOut['max'])) { - $this->addUsingAlias(CcSchedulePeer::FADE_OUT, $dbFadeOut['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcSchedulePeer::FADE_OUT, $dbFadeOut, $comparison); - } + /** + * 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) + { - /** - * Filter the query on the cue_in column - * - * @param string $dbCueIn 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 CcScheduleQuery The current query, for fluid interface - */ - public function filterByDbCueIn($dbCueIn = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbCueIn)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbCueIn)) { - $dbCueIn = str_replace('*', '%', $dbCueIn); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcSchedulePeer::CUE_IN, $dbCueIn, $comparison); - } + return $this->addUsingAlias(CcSchedulePeer::ID, $keys, Criteria::IN); + } - /** - * Filter the query on the cue_out column - * - * @param string $dbCueOut 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 CcScheduleQuery The current query, for fluid interface - */ - public function filterByDbCueOut($dbCueOut = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbCueOut)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbCueOut)) { - $dbCueOut = str_replace('*', '%', $dbCueOut); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcSchedulePeer::CUE_OUT, $dbCueOut, $comparison); - } + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcScheduleQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcSchedulePeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcSchedulePeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Filter the query on the media_item_played column - * - * @param boolean|string $dbMediaItemPlayed The value to use as filter. - * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcScheduleQuery The current query, for fluid interface - */ - public function filterByDbMediaItemPlayed($dbMediaItemPlayed = null, $comparison = null) - { - if (is_string($dbMediaItemPlayed)) { - $media_item_played = in_array(strtolower($dbMediaItemPlayed), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; - } - return $this->addUsingAlias(CcSchedulePeer::MEDIA_ITEM_PLAYED, $dbMediaItemPlayed, $comparison); - } + return $this->addUsingAlias(CcSchedulePeer::ID, $dbId, $comparison); + } - /** - * Filter the query on the instance_id column - * - * @param int|array $dbInstanceId 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 filterByDbInstanceId($dbInstanceId = null, $comparison = null) - { - if (is_array($dbInstanceId)) { - $useMinMax = false; - if (isset($dbInstanceId['min'])) { - $this->addUsingAlias(CcSchedulePeer::INSTANCE_ID, $dbInstanceId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbInstanceId['max'])) { - $this->addUsingAlias(CcSchedulePeer::INSTANCE_ID, $dbInstanceId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcSchedulePeer::INSTANCE_ID, $dbInstanceId, $comparison); - } + /** + * Filter the query on the starts column + * + * Example usage: + * + * $query->filterByDbStarts('2011-03-14'); // WHERE starts = '2011-03-14' + * $query->filterByDbStarts('now'); // WHERE starts = '2011-03-14' + * $query->filterByDbStarts(array('max' => 'yesterday')); // WHERE starts < '2011-03-13' + * + * + * @param mixed $dbStarts The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcScheduleQuery The current query, for fluid interface + */ + public function filterByDbStarts($dbStarts = null, $comparison = null) + { + if (is_array($dbStarts)) { + $useMinMax = false; + if (isset($dbStarts['min'])) { + $this->addUsingAlias(CcSchedulePeer::STARTS, $dbStarts['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbStarts['max'])) { + $this->addUsingAlias(CcSchedulePeer::STARTS, $dbStarts['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Filter the query on the playout_status column - * - * @param int|array $dbPlayoutStatus 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 filterByDbPlayoutStatus($dbPlayoutStatus = null, $comparison = null) - { - if (is_array($dbPlayoutStatus)) { - $useMinMax = false; - if (isset($dbPlayoutStatus['min'])) { - $this->addUsingAlias(CcSchedulePeer::PLAYOUT_STATUS, $dbPlayoutStatus['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbPlayoutStatus['max'])) { - $this->addUsingAlias(CcSchedulePeer::PLAYOUT_STATUS, $dbPlayoutStatus['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcSchedulePeer::PLAYOUT_STATUS, $dbPlayoutStatus, $comparison); - } + return $this->addUsingAlias(CcSchedulePeer::STARTS, $dbStarts, $comparison); + } - /** - * Filter the query on the broadcasted column - * - * @param int|array $dbBroadcasted 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 filterByDbBroadcasted($dbBroadcasted = null, $comparison = null) - { - if (is_array($dbBroadcasted)) { - $useMinMax = false; - if (isset($dbBroadcasted['min'])) { - $this->addUsingAlias(CcSchedulePeer::BROADCASTED, $dbBroadcasted['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbBroadcasted['max'])) { - $this->addUsingAlias(CcSchedulePeer::BROADCASTED, $dbBroadcasted['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcSchedulePeer::BROADCASTED, $dbBroadcasted, $comparison); - } + /** + * Filter the query on the ends column + * + * Example usage: + * + * $query->filterByDbEnds('2011-03-14'); // WHERE ends = '2011-03-14' + * $query->filterByDbEnds('now'); // WHERE ends = '2011-03-14' + * $query->filterByDbEnds(array('max' => 'yesterday')); // WHERE ends < '2011-03-13' + * + * + * @param mixed $dbEnds The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcScheduleQuery The current query, for fluid interface + */ + public function filterByDbEnds($dbEnds = null, $comparison = null) + { + if (is_array($dbEnds)) { + $useMinMax = false; + if (isset($dbEnds['min'])) { + $this->addUsingAlias(CcSchedulePeer::ENDS, $dbEnds['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbEnds['max'])) { + $this->addUsingAlias(CcSchedulePeer::ENDS, $dbEnds['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * 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 CcScheduleQuery 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(CcSchedulePeer::POSITION, $dbPosition['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbPosition['max'])) { - $this->addUsingAlias(CcSchedulePeer::POSITION, $dbPosition['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcSchedulePeer::POSITION, $dbPosition, $comparison); - } + return $this->addUsingAlias(CcSchedulePeer::ENDS, $dbEnds, $comparison); + } - /** - * Filter the query by a related CcShowInstances object - * - * @param CcShowInstances $ccShowInstances the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcScheduleQuery The current query, for fluid interface - */ - public function filterByCcShowInstances($ccShowInstances, $comparison = null) - { - return $this - ->addUsingAlias(CcSchedulePeer::INSTANCE_ID, $ccShowInstances->getDbId(), $comparison); - } + /** + * Filter the query on the file_id column + * + * Example usage: + * + * $query->filterByDbFileId(1234); // WHERE file_id = 1234 + * $query->filterByDbFileId(array(12, 34)); // WHERE file_id IN (12, 34) + * $query->filterByDbFileId(array('min' => 12)); // WHERE file_id >= 12 + * $query->filterByDbFileId(array('max' => 12)); // WHERE file_id <= 12 + * + * + * @see filterByCcFiles() + * + * @param mixed $dbFileId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcScheduleQuery 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(CcSchedulePeer::FILE_ID, $dbFileId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbFileId['max'])) { + $this->addUsingAlias(CcSchedulePeer::FILE_ID, $dbFileId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Adds a JOIN clause to the query using the CcShowInstances relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcScheduleQuery The current query, for fluid interface - */ - public function joinCcShowInstances($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcShowInstances'); - - // 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, 'CcShowInstances'); - } - - return $this; - } + return $this->addUsingAlias(CcSchedulePeer::FILE_ID, $dbFileId, $comparison); + } - /** - * Use the CcShowInstances relation CcShowInstances 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 CcShowInstancesQuery A secondary query class using the current class as primary query - */ - public function useCcShowInstancesQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcShowInstances($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcShowInstances', 'CcShowInstancesQuery'); - } + /** + * Filter the query on the stream_id column + * + * Example usage: + * + * $query->filterByDbStreamId(1234); // WHERE stream_id = 1234 + * $query->filterByDbStreamId(array(12, 34)); // WHERE stream_id IN (12, 34) + * $query->filterByDbStreamId(array('min' => 12)); // WHERE stream_id >= 12 + * $query->filterByDbStreamId(array('max' => 12)); // WHERE stream_id <= 12 + * + * + * @see filterByCcWebstream() + * + * @param mixed $dbStreamId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcScheduleQuery The current query, for fluid interface + */ + public function filterByDbStreamId($dbStreamId = null, $comparison = null) + { + if (is_array($dbStreamId)) { + $useMinMax = false; + if (isset($dbStreamId['min'])) { + $this->addUsingAlias(CcSchedulePeer::STREAM_ID, $dbStreamId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbStreamId['max'])) { + $this->addUsingAlias(CcSchedulePeer::STREAM_ID, $dbStreamId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * 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 CcScheduleQuery The current query, for fluid interface - */ - public function filterByCcFiles($ccFiles, $comparison = null) - { - return $this - ->addUsingAlias(CcSchedulePeer::FILE_ID, $ccFiles->getDbId(), $comparison); - } + return $this->addUsingAlias(CcSchedulePeer::STREAM_ID, $dbStreamId, $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 CcScheduleQuery 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; - } + /** + * Filter the query on the clip_length column + * + * Example usage: + * + * $query->filterByDbClipLength('fooValue'); // WHERE clip_length = 'fooValue' + * $query->filterByDbClipLength('%fooValue%'); // WHERE clip_length LIKE '%fooValue%' + * + * + * @param string $dbClipLength 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 CcScheduleQuery The current query, for fluid interface + */ + public function filterByDbClipLength($dbClipLength = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbClipLength)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbClipLength)) { + $dbClipLength = str_replace('*', '%', $dbClipLength); + $comparison = Criteria::LIKE; + } + } - /** - * 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'); - } + return $this->addUsingAlias(CcSchedulePeer::CLIP_LENGTH, $dbClipLength, $comparison); + } - /** - * Filter the query by a related CcWebstream object - * - * @param CcWebstream $ccWebstream the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcScheduleQuery The current query, for fluid interface - */ - public function filterByCcWebstream($ccWebstream, $comparison = null) - { - return $this - ->addUsingAlias(CcSchedulePeer::STREAM_ID, $ccWebstream->getDbId(), $comparison); - } + /** + * Filter the query on the fade_in column + * + * Example usage: + * + * $query->filterByDbFadeIn('2011-03-14'); // WHERE fade_in = '2011-03-14' + * $query->filterByDbFadeIn('now'); // WHERE fade_in = '2011-03-14' + * $query->filterByDbFadeIn(array('max' => 'yesterday')); // WHERE fade_in < '2011-03-13' + * + * + * @param mixed $dbFadeIn The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcScheduleQuery 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(CcSchedulePeer::FADE_IN, $dbFadeIn['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbFadeIn['max'])) { + $this->addUsingAlias(CcSchedulePeer::FADE_IN, $dbFadeIn['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Adds a JOIN clause to the query using the CcWebstream relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcScheduleQuery The current query, for fluid interface - */ - public function joinCcWebstream($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcWebstream'); - - // 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, 'CcWebstream'); - } - - return $this; - } + return $this->addUsingAlias(CcSchedulePeer::FADE_IN, $dbFadeIn, $comparison); + } - /** - * Use the CcWebstream relation CcWebstream 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 CcWebstreamQuery A secondary query class using the current class as primary query - */ - public function useCcWebstreamQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcWebstream($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcWebstream', 'CcWebstreamQuery'); - } + /** + * Filter the query on the fade_out column + * + * Example usage: + * + * $query->filterByDbFadeOut('2011-03-14'); // WHERE fade_out = '2011-03-14' + * $query->filterByDbFadeOut('now'); // WHERE fade_out = '2011-03-14' + * $query->filterByDbFadeOut(array('max' => 'yesterday')); // WHERE fade_out < '2011-03-13' + * + * + * @param mixed $dbFadeOut The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcScheduleQuery 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(CcSchedulePeer::FADE_OUT, $dbFadeOut['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbFadeOut['max'])) { + $this->addUsingAlias(CcSchedulePeer::FADE_OUT, $dbFadeOut['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Filter the query by a related CcWebstreamMetadata object - * - * @param CcWebstreamMetadata $ccWebstreamMetadata the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcScheduleQuery The current query, for fluid interface - */ - public function filterByCcWebstreamMetadata($ccWebstreamMetadata, $comparison = null) - { - return $this - ->addUsingAlias(CcSchedulePeer::ID, $ccWebstreamMetadata->getDbInstanceId(), $comparison); - } + return $this->addUsingAlias(CcSchedulePeer::FADE_OUT, $dbFadeOut, $comparison); + } - /** - * Adds a JOIN clause to the query using the CcWebstreamMetadata relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcScheduleQuery The current query, for fluid interface - */ - public function joinCcWebstreamMetadata($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcWebstreamMetadata'); - - // 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, 'CcWebstreamMetadata'); - } - - return $this; - } + /** + * Filter the query on the cue_in column + * + * Example usage: + * + * $query->filterByDbCueIn('fooValue'); // WHERE cue_in = 'fooValue' + * $query->filterByDbCueIn('%fooValue%'); // WHERE cue_in LIKE '%fooValue%' + * + * + * @param string $dbCueIn 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 CcScheduleQuery The current query, for fluid interface + */ + public function filterByDbCueIn($dbCueIn = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbCueIn)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbCueIn)) { + $dbCueIn = str_replace('*', '%', $dbCueIn); + $comparison = Criteria::LIKE; + } + } - /** - * Use the CcWebstreamMetadata relation CcWebstreamMetadata 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 CcWebstreamMetadataQuery A secondary query class using the current class as primary query - */ - public function useCcWebstreamMetadataQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcWebstreamMetadata($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcWebstreamMetadata', 'CcWebstreamMetadataQuery'); - } + return $this->addUsingAlias(CcSchedulePeer::CUE_IN, $dbCueIn, $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->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + /** + * Filter the query on the cue_out column + * + * Example usage: + * + * $query->filterByDbCueOut('fooValue'); // WHERE cue_out = 'fooValue' + * $query->filterByDbCueOut('%fooValue%'); // WHERE cue_out LIKE '%fooValue%' + * + * + * @param string $dbCueOut 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 CcScheduleQuery The current query, for fluid interface + */ + public function filterByDbCueOut($dbCueOut = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbCueOut)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbCueOut)) { + $dbCueOut = str_replace('*', '%', $dbCueOut); + $comparison = Criteria::LIKE; + } + } -} // BaseCcScheduleQuery + return $this->addUsingAlias(CcSchedulePeer::CUE_OUT, $dbCueOut, $comparison); + } + + /** + * Filter the query on the media_item_played column + * + * Example usage: + * + * $query->filterByDbMediaItemPlayed(true); // WHERE media_item_played = true + * $query->filterByDbMediaItemPlayed('yes'); // WHERE media_item_played = true + * + * + * @param boolean|string $dbMediaItemPlayed The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcScheduleQuery The current query, for fluid interface + */ + public function filterByDbMediaItemPlayed($dbMediaItemPlayed = null, $comparison = null) + { + if (is_string($dbMediaItemPlayed)) { + $dbMediaItemPlayed = in_array(strtolower($dbMediaItemPlayed), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CcSchedulePeer::MEDIA_ITEM_PLAYED, $dbMediaItemPlayed, $comparison); + } + + /** + * Filter the query on the instance_id column + * + * Example usage: + * + * $query->filterByDbInstanceId(1234); // WHERE instance_id = 1234 + * $query->filterByDbInstanceId(array(12, 34)); // WHERE instance_id IN (12, 34) + * $query->filterByDbInstanceId(array('min' => 12)); // WHERE instance_id >= 12 + * $query->filterByDbInstanceId(array('max' => 12)); // WHERE instance_id <= 12 + * + * + * @see filterByCcShowInstances() + * + * @param mixed $dbInstanceId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcScheduleQuery The current query, for fluid interface + */ + public function filterByDbInstanceId($dbInstanceId = null, $comparison = null) + { + if (is_array($dbInstanceId)) { + $useMinMax = false; + if (isset($dbInstanceId['min'])) { + $this->addUsingAlias(CcSchedulePeer::INSTANCE_ID, $dbInstanceId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbInstanceId['max'])) { + $this->addUsingAlias(CcSchedulePeer::INSTANCE_ID, $dbInstanceId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcSchedulePeer::INSTANCE_ID, $dbInstanceId, $comparison); + } + + /** + * Filter the query on the playout_status column + * + * Example usage: + * + * $query->filterByDbPlayoutStatus(1234); // WHERE playout_status = 1234 + * $query->filterByDbPlayoutStatus(array(12, 34)); // WHERE playout_status IN (12, 34) + * $query->filterByDbPlayoutStatus(array('min' => 12)); // WHERE playout_status >= 12 + * $query->filterByDbPlayoutStatus(array('max' => 12)); // WHERE playout_status <= 12 + * + * + * @param mixed $dbPlayoutStatus The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcScheduleQuery The current query, for fluid interface + */ + public function filterByDbPlayoutStatus($dbPlayoutStatus = null, $comparison = null) + { + if (is_array($dbPlayoutStatus)) { + $useMinMax = false; + if (isset($dbPlayoutStatus['min'])) { + $this->addUsingAlias(CcSchedulePeer::PLAYOUT_STATUS, $dbPlayoutStatus['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbPlayoutStatus['max'])) { + $this->addUsingAlias(CcSchedulePeer::PLAYOUT_STATUS, $dbPlayoutStatus['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcSchedulePeer::PLAYOUT_STATUS, $dbPlayoutStatus, $comparison); + } + + /** + * Filter the query on the broadcasted column + * + * Example usage: + * + * $query->filterByDbBroadcasted(1234); // WHERE broadcasted = 1234 + * $query->filterByDbBroadcasted(array(12, 34)); // WHERE broadcasted IN (12, 34) + * $query->filterByDbBroadcasted(array('min' => 12)); // WHERE broadcasted >= 12 + * $query->filterByDbBroadcasted(array('max' => 12)); // WHERE broadcasted <= 12 + * + * + * @param mixed $dbBroadcasted The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcScheduleQuery The current query, for fluid interface + */ + public function filterByDbBroadcasted($dbBroadcasted = null, $comparison = null) + { + if (is_array($dbBroadcasted)) { + $useMinMax = false; + if (isset($dbBroadcasted['min'])) { + $this->addUsingAlias(CcSchedulePeer::BROADCASTED, $dbBroadcasted['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbBroadcasted['max'])) { + $this->addUsingAlias(CcSchedulePeer::BROADCASTED, $dbBroadcasted['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcSchedulePeer::BROADCASTED, $dbBroadcasted, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByDbPosition(1234); // WHERE position = 1234 + * $query->filterByDbPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByDbPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByDbPosition(array('max' => 12)); // WHERE position <= 12 + * + * + * @param mixed $dbPosition The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcScheduleQuery 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(CcSchedulePeer::POSITION, $dbPosition['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbPosition['max'])) { + $this->addUsingAlias(CcSchedulePeer::POSITION, $dbPosition['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcSchedulePeer::POSITION, $dbPosition, $comparison); + } + + /** + * Filter the query by a related CcShowInstances object + * + * @param CcShowInstances|PropelObjectCollection $ccShowInstances The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcScheduleQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcShowInstances($ccShowInstances, $comparison = null) + { + if ($ccShowInstances instanceof CcShowInstances) { + return $this + ->addUsingAlias(CcSchedulePeer::INSTANCE_ID, $ccShowInstances->getDbId(), $comparison); + } elseif ($ccShowInstances instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcSchedulePeer::INSTANCE_ID, $ccShowInstances->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcShowInstances() only accepts arguments of type CcShowInstances or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcShowInstances relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcScheduleQuery The current query, for fluid interface + */ + public function joinCcShowInstances($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShowInstances'); + + // 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, 'CcShowInstances'); + } + + return $this; + } + + /** + * Use the CcShowInstances relation CcShowInstances 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 \Airtime\CcShowInstancesQuery A secondary query class using the current class as primary query + */ + public function useCcShowInstancesQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcShowInstances($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShowInstances', '\Airtime\CcShowInstancesQuery'); + } + + /** + * Filter the query by a related CcFiles object + * + * @param CcFiles|PropelObjectCollection $ccFiles The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcScheduleQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcFiles($ccFiles, $comparison = null) + { + if ($ccFiles instanceof CcFiles) { + return $this + ->addUsingAlias(CcSchedulePeer::FILE_ID, $ccFiles->getDbId(), $comparison); + } elseif ($ccFiles instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcSchedulePeer::FILE_ID, $ccFiles->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcFiles() only accepts arguments of type CcFiles or PropelCollection'); + } + } + + /** + * 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 CcScheduleQuery The current query, for fluid interface + */ + public function joinCcFiles($relationAlias = null, $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 \Airtime\CcFilesQuery A secondary query class using the current class as primary query + */ + public function useCcFilesQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcFiles($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcFiles', '\Airtime\CcFilesQuery'); + } + + /** + * Filter the query by a related CcWebstream object + * + * @param CcWebstream|PropelObjectCollection $ccWebstream The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcScheduleQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcWebstream($ccWebstream, $comparison = null) + { + if ($ccWebstream instanceof CcWebstream) { + return $this + ->addUsingAlias(CcSchedulePeer::STREAM_ID, $ccWebstream->getDbId(), $comparison); + } elseif ($ccWebstream instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcSchedulePeer::STREAM_ID, $ccWebstream->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcWebstream() only accepts arguments of type CcWebstream or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcWebstream relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcScheduleQuery The current query, for fluid interface + */ + public function joinCcWebstream($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcWebstream'); + + // 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, 'CcWebstream'); + } + + return $this; + } + + /** + * Use the CcWebstream relation CcWebstream 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 \Airtime\CcWebstreamQuery A secondary query class using the current class as primary query + */ + public function useCcWebstreamQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcWebstream($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcWebstream', '\Airtime\CcWebstreamQuery'); + } + + /** + * Filter the query by a related CcWebstreamMetadata object + * + * @param CcWebstreamMetadata|PropelObjectCollection $ccWebstreamMetadata the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcScheduleQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcWebstreamMetadata($ccWebstreamMetadata, $comparison = null) + { + if ($ccWebstreamMetadata instanceof CcWebstreamMetadata) { + return $this + ->addUsingAlias(CcSchedulePeer::ID, $ccWebstreamMetadata->getDbInstanceId(), $comparison); + } elseif ($ccWebstreamMetadata instanceof PropelObjectCollection) { + return $this + ->useCcWebstreamMetadataQuery() + ->filterByPrimaryKeys($ccWebstreamMetadata->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcWebstreamMetadata() only accepts arguments of type CcWebstreamMetadata or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcWebstreamMetadata relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcScheduleQuery The current query, for fluid interface + */ + public function joinCcWebstreamMetadata($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcWebstreamMetadata'); + + // 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, 'CcWebstreamMetadata'); + } + + return $this; + } + + /** + * Use the CcWebstreamMetadata relation CcWebstreamMetadata 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 \Airtime\CcWebstreamMetadataQuery A secondary query class using the current class as primary query + */ + public function useCcWebstreamMetadataQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcWebstreamMetadata($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcWebstreamMetadata', '\Airtime\CcWebstreamMetadataQuery'); + } + + /** + * 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->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcServiceRegister.php b/airtime_mvc/application/models/airtime/om/BaseCcServiceRegister.php index dbb3aa6a2..ac8e43a4e 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcServiceRegister.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcServiceRegister.php @@ -1,708 +1,828 @@ name; - } - - /** - * Get the [ip] column value. - * - * @return string - */ - public function getDbIp() - { - return $this->ip; - } - - /** - * Set the value of [name] column. - * - * @param string $v new value - * @return CcServiceRegister The current object (for fluent API support) - */ - public function setDbName($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->name !== $v) { - $this->name = $v; - $this->modifiedColumns[] = CcServiceRegisterPeer::NAME; - } - - return $this; - } // setDbName() - - /** - * Set the value of [ip] column. - * - * @param string $v new value - * @return CcServiceRegister The current object (for fluent API support) - */ - public function setDbIp($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->ip !== $v) { - $this->ip = $v; - $this->modifiedColumns[] = CcServiceRegisterPeer::IP; - } - - return $this; - } // setDbIp() - - /** - * 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->name = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null; - $this->ip = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 2; // 2 = CcServiceRegisterPeer::NUM_COLUMNS - CcServiceRegisterPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcServiceRegister 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(CcServiceRegisterPeer::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 = CcServiceRegisterPeer::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(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcServiceRegisterQuery::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(CcServiceRegisterPeer::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); - CcServiceRegisterPeer::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 = CcServiceRegisterPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CcServiceRegisterPeer::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 = CcServiceRegisterPeer::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->getDbName(); - break; - case 1: - return $this->getDbIp(); - 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 = CcServiceRegisterPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbName(), - $keys[1] => $this->getDbIp(), - ); - 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 = CcServiceRegisterPeer::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->setDbName($value); - break; - case 1: - $this->setDbIp($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 = CcServiceRegisterPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbName($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbIp($arr[$keys[1]]); - } - - /** - * 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(CcServiceRegisterPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcServiceRegisterPeer::NAME)) $criteria->add(CcServiceRegisterPeer::NAME, $this->name); - if ($this->isColumnModified(CcServiceRegisterPeer::IP)) $criteria->add(CcServiceRegisterPeer::IP, $this->ip); - - 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(CcServiceRegisterPeer::DATABASE_NAME); - $criteria->add(CcServiceRegisterPeer::NAME, $this->name); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return string - */ - public function getPrimaryKey() - { - return $this->getDbName(); - } - - /** - * Generic method to set the primary key (name column). - * - * @param string $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setDbName($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - return null === $this->getDbName(); - } - - /** - * 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 CcServiceRegister (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->setDbIp($this->ip); - - $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 CcServiceRegister 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 CcServiceRegisterPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcServiceRegisterPeer(); - } - return self::$peer; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->name = null; - $this->ip = 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); - } - -} // BaseCcServiceRegister + /** + * Peer class name + */ + const PEER = 'Airtime\\CcServiceRegisterPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcServiceRegisterPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the name field. + * @var string + */ + protected $name; + + /** + * The value for the ip field. + * @var string + */ + protected $ip; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * Get the [name] column value. + * + * @return string + */ + public function getDbName() + { + + return $this->name; + } + + /** + * Get the [ip] column value. + * + * @return string + */ + public function getDbIp() + { + + return $this->ip; + } + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return CcServiceRegister The current object (for fluent API support) + */ + public function setDbName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = CcServiceRegisterPeer::NAME; + } + + + return $this; + } // setDbName() + + /** + * Set the value of [ip] column. + * + * @param string $v new value + * @return CcServiceRegister The current object (for fluent API support) + */ + public function setDbIp($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->ip !== $v) { + $this->ip = $v; + $this->modifiedColumns[] = CcServiceRegisterPeer::IP; + } + + + return $this; + } // setDbIp() + + /** + * 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 resultset 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->name = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null; + $this->ip = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 2; // 2 = CcServiceRegisterPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcServiceRegister 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(CcServiceRegisterPeer::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 = CcServiceRegisterPeer::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 + * @throws Exception + * @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(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcServiceRegisterQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcServiceRegisterPeer::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); + CcServiceRegisterPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcServiceRegisterPeer::NAME)) { + $modifiedColumns[':p' . $index++] = '"name"'; + } + if ($this->isColumnModified(CcServiceRegisterPeer::IP)) { + $modifiedColumns[':p' . $index++] = '"ip"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_service_register" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"name"': + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); + break; + case '"ip"': + $stmt->bindValue($identifier, $this->ip, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcServiceRegisterPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcServiceRegisterPeer::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->getDbName(); + break; + case 1: + return $this->getDbIp(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) + { + if (isset($alreadyDumpedObjects['CcServiceRegister'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcServiceRegister'][$this->getPrimaryKey()] = true; + $keys = CcServiceRegisterPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbName(), + $keys[1] => $this->getDbIp(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcServiceRegisterPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbName($value); + break; + case 1: + $this->setDbIp($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcServiceRegisterPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbName($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbIp($arr[$keys[1]]); + } + + /** + * 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(CcServiceRegisterPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcServiceRegisterPeer::NAME)) $criteria->add(CcServiceRegisterPeer::NAME, $this->name); + if ($this->isColumnModified(CcServiceRegisterPeer::IP)) $criteria->add(CcServiceRegisterPeer::IP, $this->ip); + + 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(CcServiceRegisterPeer::DATABASE_NAME); + $criteria->add(CcServiceRegisterPeer::NAME, $this->name); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getDbName(); + } + + /** + * Generic method to set the primary key (name column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setDbName($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getDbName(); + } + + /** + * 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 CcServiceRegister (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbIp($this->getDbIp()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setDbName(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 CcServiceRegister 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 CcServiceRegisterPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcServiceRegisterPeer(); + } + + return self::$peer; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->name = null; + $this->ip = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcServiceRegisterPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcServiceRegisterPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcServiceRegisterPeer.php index ab7d35634..9087d7640 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcServiceRegisterPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcServiceRegisterPeer.php @@ -1,731 +1,765 @@ array ('DbName', 'DbIp', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbName', 'dbIp', ), - BasePeer::TYPE_COLNAME => array (self::NAME, self::IP, ), - BasePeer::TYPE_RAW_COLNAME => array ('NAME', 'IP', ), - BasePeer::TYPE_FIELDNAME => array ('name', 'ip', ), - BasePeer::TYPE_NUM => array (0, 1, ) - ); - - /** - * 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 ('DbName' => 0, 'DbIp' => 1, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbName' => 0, 'dbIp' => 1, ), - BasePeer::TYPE_COLNAME => array (self::NAME => 0, self::IP => 1, ), - BasePeer::TYPE_RAW_COLNAME => array ('NAME' => 0, 'IP' => 1, ), - BasePeer::TYPE_FIELDNAME => array ('name' => 0, 'ip' => 1, ), - BasePeer::TYPE_NUM => array (0, 1, ) - ); - - /** - * 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. CcServiceRegisterPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcServiceRegisterPeer::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(CcServiceRegisterPeer::NAME); - $criteria->addSelectColumn(CcServiceRegisterPeer::IP); - } else { - $criteria->addSelectColumn($alias . '.NAME'); - $criteria->addSelectColumn($alias . '.IP'); - } - } - - /** - * 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(CcServiceRegisterPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcServiceRegisterPeer::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(CcServiceRegisterPeer::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 CcServiceRegister - * @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 = CcServiceRegisterPeer::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 CcServiceRegisterPeer::populateObjects(CcServiceRegisterPeer::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(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcServiceRegisterPeer::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 CcServiceRegister $value A CcServiceRegister object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcServiceRegister $obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getDbName(); - } // 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 CcServiceRegister object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcServiceRegister) { - $key = (string) $value->getDbName(); - } 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 CcServiceRegister 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 CcServiceRegister 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_service_register - * 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 = CcServiceRegisterPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcServiceRegisterPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcServiceRegisterPeer::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; - CcServiceRegisterPeer::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 (CcServiceRegister object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcServiceRegisterPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcServiceRegisterPeer::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 + CcServiceRegisterPeer::NUM_COLUMNS; - } else { - $cls = CcServiceRegisterPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcServiceRegisterPeer::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(BaseCcServiceRegisterPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcServiceRegisterPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcServiceRegisterTableMap()); - } - } - - /** - * 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 ? CcServiceRegisterPeer::CLASS_DEFAULT : CcServiceRegisterPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcServiceRegister or Criteria object. - * - * @param mixed $values Criteria or CcServiceRegister 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(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcServiceRegister 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 CcServiceRegister or Criteria object. - * - * @param mixed $values Criteria or CcServiceRegister 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(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcServiceRegisterPeer::NAME); - $value = $criteria->remove(CcServiceRegisterPeer::NAME); - if ($value) { - $selectCriteria->add(CcServiceRegisterPeer::NAME, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcServiceRegisterPeer::TABLE_NAME); - } - - } else { // $values is CcServiceRegister 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_service_register 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(CcServiceRegisterPeer::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(CcServiceRegisterPeer::TABLE_NAME, $con, CcServiceRegisterPeer::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). - CcServiceRegisterPeer::clearInstancePool(); - CcServiceRegisterPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcServiceRegister or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcServiceRegister 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(CcServiceRegisterPeer::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. - CcServiceRegisterPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcServiceRegister) { // it's a model object - // invalidate the cache for this single object - CcServiceRegisterPeer::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(CcServiceRegisterPeer::NAME, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcServiceRegisterPeer::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); - CcServiceRegisterPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcServiceRegister 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 CcServiceRegister $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(CcServiceRegister $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcServiceRegisterPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcServiceRegisterPeer::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(CcServiceRegisterPeer::DATABASE_NAME, CcServiceRegisterPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param string $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcServiceRegister - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcServiceRegisterPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcServiceRegisterPeer::DATABASE_NAME); - $criteria->add(CcServiceRegisterPeer::NAME, $pk); - - $v = CcServiceRegisterPeer::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(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcServiceRegisterPeer::DATABASE_NAME); - $criteria->add(CcServiceRegisterPeer::NAME, $pks, Criteria::IN); - $objs = CcServiceRegisterPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcServiceRegisterPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_service_register'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcServiceRegister'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcServiceRegisterTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 2; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 2; + + /** the column name for the name field */ + const NAME = 'cc_service_register.name'; + + /** the column name for the ip field */ + const IP = 'cc_service_register.ip'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcServiceRegister objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcServiceRegister[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcServiceRegisterPeer::$fieldNames[CcServiceRegisterPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbName', 'DbIp', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbName', 'dbIp', ), + BasePeer::TYPE_COLNAME => array (CcServiceRegisterPeer::NAME, CcServiceRegisterPeer::IP, ), + BasePeer::TYPE_RAW_COLNAME => array ('NAME', 'IP', ), + BasePeer::TYPE_FIELDNAME => array ('name', 'ip', ), + BasePeer::TYPE_NUM => array (0, 1, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcServiceRegisterPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbName' => 0, 'DbIp' => 1, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbName' => 0, 'dbIp' => 1, ), + BasePeer::TYPE_COLNAME => array (CcServiceRegisterPeer::NAME => 0, CcServiceRegisterPeer::IP => 1, ), + BasePeer::TYPE_RAW_COLNAME => array ('NAME' => 0, 'IP' => 1, ), + BasePeer::TYPE_FIELDNAME => array ('name' => 0, 'ip' => 1, ), + BasePeer::TYPE_NUM => array (0, 1, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcServiceRegisterPeer::getFieldNames($toType); + $key = isset(CcServiceRegisterPeer::$fieldKeys[$fromType][$name]) ? CcServiceRegisterPeer::$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(CcServiceRegisterPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcServiceRegisterPeer::$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 CcServiceRegisterPeer::$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. CcServiceRegisterPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcServiceRegisterPeer::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(CcServiceRegisterPeer::NAME); + $criteria->addSelectColumn(CcServiceRegisterPeer::IP); + } else { + $criteria->addSelectColumn($alias . '.name'); + $criteria->addSelectColumn($alias . '.ip'); + } + } + + /** + * 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(CcServiceRegisterPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcServiceRegisterPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcServiceRegisterPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcServiceRegisterPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcServiceRegister + * @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 = CcServiceRegisterPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcServiceRegisterPeer::populateObjects(CcServiceRegisterPeer::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 directly (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(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcServiceRegisterPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcServiceRegisterPeer::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 CcServiceRegister $obj A CcServiceRegister object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbName(); + } // if key === null + CcServiceRegisterPeer::$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 CcServiceRegister object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcServiceRegister) { + $key = (string) $value->getDbName(); + } 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 CcServiceRegister object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcServiceRegisterPeer::$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 CcServiceRegister 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(CcServiceRegisterPeer::$instances[$key])) { + return CcServiceRegisterPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcServiceRegisterPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcServiceRegisterPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_service_register + * 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 = CcServiceRegisterPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcServiceRegisterPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcServiceRegisterPeer::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; + CcServiceRegisterPeer::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 (CcServiceRegister object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcServiceRegisterPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcServiceRegisterPeer::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 + CcServiceRegisterPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcServiceRegisterPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcServiceRegisterPeer::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(CcServiceRegisterPeer::DATABASE_NAME)->getTable(CcServiceRegisterPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcServiceRegisterPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcServiceRegisterPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcServiceRegisterTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcServiceRegisterPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcServiceRegister or Criteria object. + * + * @param mixed $values Criteria or CcServiceRegister 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(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcServiceRegister object + } + + + // Set the correct dbName + $criteria->setDbName(CcServiceRegisterPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcServiceRegister or Criteria object. + * + * @param mixed $values Criteria or CcServiceRegister 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(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcServiceRegisterPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcServiceRegisterPeer::NAME); + $value = $criteria->remove(CcServiceRegisterPeer::NAME); + if ($value) { + $selectCriteria->add(CcServiceRegisterPeer::NAME, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcServiceRegisterPeer::TABLE_NAME); + } + + } else { // $values is CcServiceRegister object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcServiceRegisterPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_service_register table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcServiceRegisterPeer::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(CcServiceRegisterPeer::TABLE_NAME, $con, CcServiceRegisterPeer::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). + CcServiceRegisterPeer::clearInstancePool(); + CcServiceRegisterPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcServiceRegister or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcServiceRegister 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(CcServiceRegisterPeer::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. + CcServiceRegisterPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcServiceRegister) { // it's a model object + // invalidate the cache for this single object + CcServiceRegisterPeer::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(CcServiceRegisterPeer::DATABASE_NAME); + $criteria->add(CcServiceRegisterPeer::NAME, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcServiceRegisterPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcServiceRegisterPeer::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); + CcServiceRegisterPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcServiceRegister 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 CcServiceRegister $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcServiceRegisterPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcServiceRegisterPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcServiceRegisterPeer::DATABASE_NAME, CcServiceRegisterPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param string $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcServiceRegister + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcServiceRegisterPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcServiceRegisterPeer::DATABASE_NAME); + $criteria->add(CcServiceRegisterPeer::NAME, $pk); + + $v = CcServiceRegisterPeer::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 + * @return CcServiceRegister[] + * @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(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcServiceRegisterPeer::DATABASE_NAME); + $criteria->add(CcServiceRegisterPeer::NAME, $pks, Criteria::IN); + $objs = CcServiceRegisterPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcServiceRegisterPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcServiceRegisterQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcServiceRegisterQuery.php index a8df529a7..d5879a481 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcServiceRegisterQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcServiceRegisterQuery.php @@ -1,196 +1,309 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcServiceRegister|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcServiceRegisterPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcServiceRegister|CcServiceRegister[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcServiceRegisterPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcServiceRegisterPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcServiceRegisterQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcServiceRegisterPeer::NAME, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcServiceRegister A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbName($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcServiceRegisterQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcServiceRegisterPeer::NAME, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcServiceRegister A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "name", "ip" FROM "cc_service_register" WHERE "name" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcServiceRegister(); + $obj->hydrate($row); + CcServiceRegisterPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcServiceRegisterQuery 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(CcServiceRegisterPeer::NAME, $dbName, $comparison); - } + return $obj; + } - /** - * Filter the query on the ip column - * - * @param string $dbIp 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 CcServiceRegisterQuery The current query, for fluid interface - */ - public function filterByDbIp($dbIp = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbIp)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbIp)) { - $dbIp = str_replace('*', '%', $dbIp); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcServiceRegisterPeer::IP, $dbIp, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcServiceRegister|CcServiceRegister[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Exclude object from result - * - * @param CcServiceRegister $ccServiceRegister Object to remove from the list of results - * - * @return CcServiceRegisterQuery The current query, for fluid interface - */ - public function prune($ccServiceRegister = null) - { - if ($ccServiceRegister) { - $this->addUsingAlias(CcServiceRegisterPeer::NAME, $ccServiceRegister->getDbName(), Criteria::NOT_EQUAL); - } - - return $this; - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } -} // BaseCcServiceRegisterQuery + /** + * 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|CcServiceRegister[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($stmt); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcServiceRegisterQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(CcServiceRegisterPeer::NAME, $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 CcServiceRegisterQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(CcServiceRegisterPeer::NAME, $keys, Criteria::IN); + } + + /** + * Filter the query on the name column + * + * Example usage: + * + * $query->filterByDbName('fooValue'); // WHERE name = 'fooValue' + * $query->filterByDbName('%fooValue%'); // WHERE name LIKE '%fooValue%' + * + * + * @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 CcServiceRegisterQuery 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(CcServiceRegisterPeer::NAME, $dbName, $comparison); + } + + /** + * Filter the query on the ip column + * + * Example usage: + * + * $query->filterByDbIp('fooValue'); // WHERE ip = 'fooValue' + * $query->filterByDbIp('%fooValue%'); // WHERE ip LIKE '%fooValue%' + * + * + * @param string $dbIp 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 CcServiceRegisterQuery The current query, for fluid interface + */ + public function filterByDbIp($dbIp = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbIp)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbIp)) { + $dbIp = str_replace('*', '%', $dbIp); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcServiceRegisterPeer::IP, $dbIp, $comparison); + } + + /** + * Exclude object from result + * + * @param CcServiceRegister $ccServiceRegister Object to remove from the list of results + * + * @return CcServiceRegisterQuery The current query, for fluid interface + */ + public function prune($ccServiceRegister = null) + { + if ($ccServiceRegister) { + $this->addUsingAlias(CcServiceRegisterPeer::NAME, $ccServiceRegister->getDbName(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcSess.php b/airtime_mvc/application/models/airtime/om/BaseCcSess.php deleted file mode 100644 index 8ae2463af..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcSess.php +++ /dev/null @@ -1,949 +0,0 @@ -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->getDbId() !== $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->getDbId()) { - $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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->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->getDbId()); - } - - $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/airtime_mvc/application/models/airtime/om/BaseCcSessPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcSessPeer.php deleted file mode 100644 index 70eab561a..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcSessPeer.php +++ /dev/null @@ -1,979 +0,0 @@ - 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/airtime_mvc/application/models/airtime/om/BaseCcSessQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcSessQuery.php deleted file mode 100644 index f0b500f83..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcSessQuery.php +++ /dev/null @@ -1,334 +0,0 @@ -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->getDbId(), $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/airtime_mvc/application/models/airtime/om/BaseCcShow.php b/airtime_mvc/application/models/airtime/om/BaseCcShow.php index 3cf4dab1f..a7a12a29e 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShow.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShow.php @@ -1,1966 +1,2806 @@ name = ''; - $this->url = ''; - $this->genre = ''; - $this->live_stream_using_airtime_auth = false; - $this->live_stream_using_custom_auth = false; - $this->linked = false; - $this->is_linkable = true; - } - - /** - * 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 [url] column value. - * - * @return string - */ - public function getDbUrl() - { - return $this->url; - } - - /** - * Get the [genre] column value. - * - * @return string - */ - public function getDbGenre() - { - return $this->genre; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDbDescription() - { - return $this->description; - } - - /** - * Get the [color] column value. - * - * @return string - */ - public function getDbColor() - { - return $this->color; - } - - /** - * Get the [background_color] column value. - * - * @return string - */ - public function getDbBackgroundColor() - { - return $this->background_color; - } - - /** - * Get the [live_stream_using_airtime_auth] column value. - * - * @return boolean - */ - public function getDbLiveStreamUsingAirtimeAuth() - { - return $this->live_stream_using_airtime_auth; - } - - /** - * Get the [live_stream_using_custom_auth] column value. - * - * @return boolean - */ - public function getDbLiveStreamUsingCustomAuth() - { - return $this->live_stream_using_custom_auth; - } - - /** - * Get the [live_stream_user] column value. - * - * @return string - */ - public function getDbLiveStreamUser() - { - return $this->live_stream_user; - } - - /** - * Get the [live_stream_pass] column value. - * - * @return string - */ - public function getDbLiveStreamPass() - { - return $this->live_stream_pass; - } - - /** - * Get the [linked] column value. - * - * @return boolean - */ - public function getDbLinked() - { - return $this->linked; - } - - /** - * Get the [is_linkable] column value. - * - * @return boolean - */ - public function getDbIsLinkable() - { - return $this->is_linkable; - } - - /** - * 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() - - /** - * Set the value of [url] column. - * - * @param string $v new value - * @return CcShow The current object (for fluent API support) - */ - public function setDbUrl($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->url !== $v || $this->isNew()) { - $this->url = $v; - $this->modifiedColumns[] = CcShowPeer::URL; - } - - return $this; - } // setDbUrl() - - /** - * Set the value of [genre] column. - * - * @param string $v new value - * @return CcShow The current object (for fluent API support) - */ - public function setDbGenre($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->genre !== $v || $this->isNew()) { - $this->genre = $v; - $this->modifiedColumns[] = CcShowPeer::GENRE; - } - - return $this; - } // setDbGenre() - - /** - * 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() - - /** - * Set the value of [color] column. - * - * @param string $v new value - * @return CcShow The current object (for fluent API support) - */ - public function setDbColor($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->color !== $v) { - $this->color = $v; - $this->modifiedColumns[] = CcShowPeer::COLOR; - } - - return $this; - } // setDbColor() - - /** - * Set the value of [background_color] column. - * - * @param string $v new value - * @return CcShow The current object (for fluent API support) - */ - public function setDbBackgroundColor($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->background_color !== $v) { - $this->background_color = $v; - $this->modifiedColumns[] = CcShowPeer::BACKGROUND_COLOR; - } - - return $this; - } // setDbBackgroundColor() - - /** - * Set the value of [live_stream_using_airtime_auth] column. - * - * @param boolean $v new value - * @return CcShow The current object (for fluent API support) - */ - public function setDbLiveStreamUsingAirtimeAuth($v) - { - if ($v !== null) { - $v = (boolean) $v; - } - - if ($this->live_stream_using_airtime_auth !== $v || $this->isNew()) { - $this->live_stream_using_airtime_auth = $v; - $this->modifiedColumns[] = CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH; - } - - return $this; - } // setDbLiveStreamUsingAirtimeAuth() - - /** - * Set the value of [live_stream_using_custom_auth] column. - * - * @param boolean $v new value - * @return CcShow The current object (for fluent API support) - */ - public function setDbLiveStreamUsingCustomAuth($v) - { - if ($v !== null) { - $v = (boolean) $v; - } - - if ($this->live_stream_using_custom_auth !== $v || $this->isNew()) { - $this->live_stream_using_custom_auth = $v; - $this->modifiedColumns[] = CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH; - } - - return $this; - } // setDbLiveStreamUsingCustomAuth() - - /** - * Set the value of [live_stream_user] column. - * - * @param string $v new value - * @return CcShow The current object (for fluent API support) - */ - public function setDbLiveStreamUser($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->live_stream_user !== $v) { - $this->live_stream_user = $v; - $this->modifiedColumns[] = CcShowPeer::LIVE_STREAM_USER; - } - - return $this; - } // setDbLiveStreamUser() - - /** - * Set the value of [live_stream_pass] column. - * - * @param string $v new value - * @return CcShow The current object (for fluent API support) - */ - public function setDbLiveStreamPass($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->live_stream_pass !== $v) { - $this->live_stream_pass = $v; - $this->modifiedColumns[] = CcShowPeer::LIVE_STREAM_PASS; - } - - return $this; - } // setDbLiveStreamPass() - - /** - * Set the value of [linked] column. - * - * @param boolean $v new value - * @return CcShow The current object (for fluent API support) - */ - public function setDbLinked($v) - { - if ($v !== null) { - $v = (boolean) $v; - } - - if ($this->linked !== $v || $this->isNew()) { - $this->linked = $v; - $this->modifiedColumns[] = CcShowPeer::LINKED; - } - - return $this; - } // setDbLinked() - - /** - * Set the value of [is_linkable] column. - * - * @param boolean $v new value - * @return CcShow The current object (for fluent API support) - */ - public function setDbIsLinkable($v) - { - if ($v !== null) { - $v = (boolean) $v; - } - - if ($this->is_linkable !== $v || $this->isNew()) { - $this->is_linkable = $v; - $this->modifiedColumns[] = CcShowPeer::IS_LINKABLE; - } - - return $this; - } // setDbIsLinkable() - - /** - * 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->url !== '') { - return false; - } - - if ($this->genre !== '') { - return false; - } - - if ($this->live_stream_using_airtime_auth !== false) { - return false; - } - - if ($this->live_stream_using_custom_auth !== false) { - return false; - } - - if ($this->linked !== false) { - return false; - } - - if ($this->is_linkable !== true) { - 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->url = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->genre = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->color = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->background_color = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->live_stream_using_airtime_auth = ($row[$startcol + 7] !== null) ? (boolean) $row[$startcol + 7] : null; - $this->live_stream_using_custom_auth = ($row[$startcol + 8] !== null) ? (boolean) $row[$startcol + 8] : null; - $this->live_stream_user = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; - $this->live_stream_pass = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; - $this->linked = ($row[$startcol + 11] !== null) ? (boolean) $row[$startcol + 11] : null; - $this->is_linkable = ($row[$startcol + 12] !== null) ? (boolean) $row[$startcol + 12] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 13; // 13 = 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? - - $this->collCcShowInstancess = null; - - $this->collCcShowDayss = null; - - $this->collCcShowRebroadcasts = null; - - $this->collCcShowHostss = 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(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' - } - - if ($this->collCcShowInstancess !== null) { - foreach ($this->collCcShowInstancess as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->collCcShowDayss !== null) { - foreach ($this->collCcShowDayss as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->collCcShowRebroadcasts !== null) { - foreach ($this->collCcShowRebroadcasts as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->collCcShowHostss !== null) { - foreach ($this->collCcShowHostss 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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CcShowPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collCcShowInstancess !== null) { - foreach ($this->collCcShowInstancess as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCcShowDayss !== null) { - foreach ($this->collCcShowDayss as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCcShowRebroadcasts !== null) { - foreach ($this->collCcShowRebroadcasts as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCcShowHostss !== null) { - foreach ($this->collCcShowHostss 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 = 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->getDbUrl(); - break; - case 3: - return $this->getDbGenre(); - break; - case 4: - return $this->getDbDescription(); - break; - case 5: - return $this->getDbColor(); - break; - case 6: - return $this->getDbBackgroundColor(); - break; - case 7: - return $this->getDbLiveStreamUsingAirtimeAuth(); - break; - case 8: - return $this->getDbLiveStreamUsingCustomAuth(); - break; - case 9: - return $this->getDbLiveStreamUser(); - break; - case 10: - return $this->getDbLiveStreamPass(); - break; - case 11: - return $this->getDbLinked(); - break; - case 12: - return $this->getDbIsLinkable(); - 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->getDbUrl(), - $keys[3] => $this->getDbGenre(), - $keys[4] => $this->getDbDescription(), - $keys[5] => $this->getDbColor(), - $keys[6] => $this->getDbBackgroundColor(), - $keys[7] => $this->getDbLiveStreamUsingAirtimeAuth(), - $keys[8] => $this->getDbLiveStreamUsingCustomAuth(), - $keys[9] => $this->getDbLiveStreamUser(), - $keys[10] => $this->getDbLiveStreamPass(), - $keys[11] => $this->getDbLinked(), - $keys[12] => $this->getDbIsLinkable(), - ); - 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->setDbUrl($value); - break; - case 3: - $this->setDbGenre($value); - break; - case 4: - $this->setDbDescription($value); - break; - case 5: - $this->setDbColor($value); - break; - case 6: - $this->setDbBackgroundColor($value); - break; - case 7: - $this->setDbLiveStreamUsingAirtimeAuth($value); - break; - case 8: - $this->setDbLiveStreamUsingCustomAuth($value); - break; - case 9: - $this->setDbLiveStreamUser($value); - break; - case 10: - $this->setDbLiveStreamPass($value); - break; - case 11: - $this->setDbLinked($value); - break; - case 12: - $this->setDbIsLinkable($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->setDbUrl($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbGenre($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbDescription($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbColor($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDbBackgroundColor($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setDbLiveStreamUsingAirtimeAuth($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setDbLiveStreamUsingCustomAuth($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setDbLiveStreamUser($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setDbLiveStreamPass($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setDbLinked($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setDbIsLinkable($arr[$keys[12]]); - } - - /** - * 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::URL)) $criteria->add(CcShowPeer::URL, $this->url); - if ($this->isColumnModified(CcShowPeer::GENRE)) $criteria->add(CcShowPeer::GENRE, $this->genre); - if ($this->isColumnModified(CcShowPeer::DESCRIPTION)) $criteria->add(CcShowPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(CcShowPeer::COLOR)) $criteria->add(CcShowPeer::COLOR, $this->color); - if ($this->isColumnModified(CcShowPeer::BACKGROUND_COLOR)) $criteria->add(CcShowPeer::BACKGROUND_COLOR, $this->background_color); - if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH)) $criteria->add(CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH, $this->live_stream_using_airtime_auth); - if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH)) $criteria->add(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH, $this->live_stream_using_custom_auth); - if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_USER)) $criteria->add(CcShowPeer::LIVE_STREAM_USER, $this->live_stream_user); - if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_PASS)) $criteria->add(CcShowPeer::LIVE_STREAM_PASS, $this->live_stream_pass); - if ($this->isColumnModified(CcShowPeer::LINKED)) $criteria->add(CcShowPeer::LINKED, $this->linked); - if ($this->isColumnModified(CcShowPeer::IS_LINKABLE)) $criteria->add(CcShowPeer::IS_LINKABLE, $this->is_linkable); - - 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->setDbUrl($this->url); - $copyObj->setDbGenre($this->genre); - $copyObj->setDbDescription($this->description); - $copyObj->setDbColor($this->color); - $copyObj->setDbBackgroundColor($this->background_color); - $copyObj->setDbLiveStreamUsingAirtimeAuth($this->live_stream_using_airtime_auth); - $copyObj->setDbLiveStreamUsingCustomAuth($this->live_stream_using_custom_auth); - $copyObj->setDbLiveStreamUser($this->live_stream_user); - $copyObj->setDbLiveStreamPass($this->live_stream_pass); - $copyObj->setDbLinked($this->linked); - $copyObj->setDbIsLinkable($this->is_linkable); - - 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->getCcShowInstancess() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcShowInstances($relObj->copy($deepCopy)); - } - } - - foreach ($this->getCcShowDayss() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcShowDays($relObj->copy($deepCopy)); - } - } - - foreach ($this->getCcShowRebroadcasts() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcShowRebroadcast($relObj->copy($deepCopy)); - } - } - - foreach ($this->getCcShowHostss() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcShowHosts($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 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 out the collCcShowInstancess 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 addCcShowInstancess() - */ - public function clearCcShowInstancess() - { - $this->collCcShowInstancess = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcShowInstancess collection. - * - * By default this just sets the collCcShowInstancess collection to an empty array (like clearcollCcShowInstancess()); - * 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 initCcShowInstancess() - { - $this->collCcShowInstancess = new PropelObjectCollection(); - $this->collCcShowInstancess->setModel('CcShowInstances'); - } - - /** - * Gets an array of CcShowInstances 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 CcShow 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 CcShowInstances[] List of CcShowInstances objects - * @throws PropelException - */ - public function getCcShowInstancess($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcShowInstancess || null !== $criteria) { - if ($this->isNew() && null === $this->collCcShowInstancess) { - // return empty collection - $this->initCcShowInstancess(); - } else { - $collCcShowInstancess = CcShowInstancesQuery::create(null, $criteria) - ->filterByCcShow($this) - ->find($con); - if (null !== $criteria) { - return $collCcShowInstancess; - } - $this->collCcShowInstancess = $collCcShowInstancess; - } - } - return $this->collCcShowInstancess; - } - - /** - * Returns the number of related CcShowInstances objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcShowInstances objects. - * @throws PropelException - */ - public function countCcShowInstancess(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcShowInstancess || null !== $criteria) { - if ($this->isNew() && null === $this->collCcShowInstancess) { - return 0; - } else { - $query = CcShowInstancesQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcShow($this) - ->count($con); - } - } else { - return count($this->collCcShowInstancess); - } - } - - /** - * Method called to associate a CcShowInstances object to this object - * through the CcShowInstances foreign key attribute. - * - * @param CcShowInstances $l CcShowInstances - * @return void - * @throws PropelException - */ - public function addCcShowInstances(CcShowInstances $l) - { - if ($this->collCcShowInstancess === null) { - $this->initCcShowInstancess(); - } - if (!$this->collCcShowInstancess->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcShowInstancess[]= $l; - $l->setCcShow($this); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcShow is new, it will return - * an empty collection; or if this CcShow has previously - * been saved, it will retrieve related CcShowInstancess 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 CcShow. - * - * @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 CcShowInstances[] List of CcShowInstances objects - */ - public function getCcShowInstancessJoinCcShowInstancesRelatedByDbOriginalShow($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcShowInstancesQuery::create(null, $criteria); - $query->joinWith('CcShowInstancesRelatedByDbOriginalShow', $join_behavior); - - return $this->getCcShowInstancess($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcShow is new, it will return - * an empty collection; or if this CcShow has previously - * been saved, it will retrieve related CcShowInstancess 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 CcShow. - * - * @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 CcShowInstances[] List of CcShowInstances objects - */ - public function getCcShowInstancessJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcShowInstancesQuery::create(null, $criteria); - $query->joinWith('CcFiles', $join_behavior); - - return $this->getCcShowInstancess($query, $con); - } - - /** - * Clears out the collCcShowDayss 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 addCcShowDayss() - */ - public function clearCcShowDayss() - { - $this->collCcShowDayss = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcShowDayss collection. - * - * By default this just sets the collCcShowDayss collection to an empty array (like clearcollCcShowDayss()); - * 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 initCcShowDayss() - { - $this->collCcShowDayss = new PropelObjectCollection(); - $this->collCcShowDayss->setModel('CcShowDays'); - } - - /** - * Gets an array of CcShowDays 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 CcShow 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 CcShowDays[] List of CcShowDays objects - * @throws PropelException - */ - public function getCcShowDayss($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcShowDayss || null !== $criteria) { - if ($this->isNew() && null === $this->collCcShowDayss) { - // return empty collection - $this->initCcShowDayss(); - } else { - $collCcShowDayss = CcShowDaysQuery::create(null, $criteria) - ->filterByCcShow($this) - ->find($con); - if (null !== $criteria) { - return $collCcShowDayss; - } - $this->collCcShowDayss = $collCcShowDayss; - } - } - return $this->collCcShowDayss; - } - - /** - * Returns the number of related CcShowDays objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcShowDays objects. - * @throws PropelException - */ - public function countCcShowDayss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcShowDayss || null !== $criteria) { - if ($this->isNew() && null === $this->collCcShowDayss) { - return 0; - } else { - $query = CcShowDaysQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcShow($this) - ->count($con); - } - } else { - return count($this->collCcShowDayss); - } - } - - /** - * Method called to associate a CcShowDays object to this object - * through the CcShowDays foreign key attribute. - * - * @param CcShowDays $l CcShowDays - * @return void - * @throws PropelException - */ - public function addCcShowDays(CcShowDays $l) - { - if ($this->collCcShowDayss === null) { - $this->initCcShowDayss(); - } - if (!$this->collCcShowDayss->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcShowDayss[]= $l; - $l->setCcShow($this); - } - } - - /** - * Clears out the collCcShowRebroadcasts 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 addCcShowRebroadcasts() - */ - public function clearCcShowRebroadcasts() - { - $this->collCcShowRebroadcasts = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcShowRebroadcasts collection. - * - * By default this just sets the collCcShowRebroadcasts collection to an empty array (like clearcollCcShowRebroadcasts()); - * 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 initCcShowRebroadcasts() - { - $this->collCcShowRebroadcasts = new PropelObjectCollection(); - $this->collCcShowRebroadcasts->setModel('CcShowRebroadcast'); - } - - /** - * Gets an array of CcShowRebroadcast 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 CcShow 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 CcShowRebroadcast[] List of CcShowRebroadcast objects - * @throws PropelException - */ - public function getCcShowRebroadcasts($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcShowRebroadcasts || null !== $criteria) { - if ($this->isNew() && null === $this->collCcShowRebroadcasts) { - // return empty collection - $this->initCcShowRebroadcasts(); - } else { - $collCcShowRebroadcasts = CcShowRebroadcastQuery::create(null, $criteria) - ->filterByCcShow($this) - ->find($con); - if (null !== $criteria) { - return $collCcShowRebroadcasts; - } - $this->collCcShowRebroadcasts = $collCcShowRebroadcasts; - } - } - return $this->collCcShowRebroadcasts; - } - - /** - * Returns the number of related CcShowRebroadcast objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcShowRebroadcast objects. - * @throws PropelException - */ - public function countCcShowRebroadcasts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcShowRebroadcasts || null !== $criteria) { - if ($this->isNew() && null === $this->collCcShowRebroadcasts) { - return 0; - } else { - $query = CcShowRebroadcastQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcShow($this) - ->count($con); - } - } else { - return count($this->collCcShowRebroadcasts); - } - } - - /** - * Method called to associate a CcShowRebroadcast object to this object - * through the CcShowRebroadcast foreign key attribute. - * - * @param CcShowRebroadcast $l CcShowRebroadcast - * @return void - * @throws PropelException - */ - public function addCcShowRebroadcast(CcShowRebroadcast $l) - { - if ($this->collCcShowRebroadcasts === null) { - $this->initCcShowRebroadcasts(); - } - if (!$this->collCcShowRebroadcasts->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcShowRebroadcasts[]= $l; - $l->setCcShow($this); - } - } - - /** - * Clears out the collCcShowHostss 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 addCcShowHostss() - */ - public function clearCcShowHostss() - { - $this->collCcShowHostss = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcShowHostss collection. - * - * By default this just sets the collCcShowHostss collection to an empty array (like clearcollCcShowHostss()); - * 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 initCcShowHostss() - { - $this->collCcShowHostss = new PropelObjectCollection(); - $this->collCcShowHostss->setModel('CcShowHosts'); - } - - /** - * Gets an array of CcShowHosts 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 CcShow 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 CcShowHosts[] List of CcShowHosts objects - * @throws PropelException - */ - public function getCcShowHostss($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcShowHostss || null !== $criteria) { - if ($this->isNew() && null === $this->collCcShowHostss) { - // return empty collection - $this->initCcShowHostss(); - } else { - $collCcShowHostss = CcShowHostsQuery::create(null, $criteria) - ->filterByCcShow($this) - ->find($con); - if (null !== $criteria) { - return $collCcShowHostss; - } - $this->collCcShowHostss = $collCcShowHostss; - } - } - return $this->collCcShowHostss; - } - - /** - * Returns the number of related CcShowHosts objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcShowHosts objects. - * @throws PropelException - */ - public function countCcShowHostss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcShowHostss || null !== $criteria) { - if ($this->isNew() && null === $this->collCcShowHostss) { - return 0; - } else { - $query = CcShowHostsQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcShow($this) - ->count($con); - } - } else { - return count($this->collCcShowHostss); - } - } - - /** - * Method called to associate a CcShowHosts object to this object - * through the CcShowHosts foreign key attribute. - * - * @param CcShowHosts $l CcShowHosts - * @return void - * @throws PropelException - */ - public function addCcShowHosts(CcShowHosts $l) - { - if ($this->collCcShowHostss === null) { - $this->initCcShowHostss(); - } - if (!$this->collCcShowHostss->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcShowHostss[]= $l; - $l->setCcShow($this); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcShow is new, it will return - * an empty collection; or if this CcShow has previously - * been saved, it will retrieve related CcShowHostss 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 CcShow. - * - * @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 CcShowHosts[] List of CcShowHosts objects - */ - public function getCcShowHostssJoinCcSubjs($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcShowHostsQuery::create(null, $criteria); - $query->joinWith('CcSubjs', $join_behavior); - - return $this->getCcShowHostss($query, $con); - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->name = null; - $this->url = null; - $this->genre = null; - $this->description = null; - $this->color = null; - $this->background_color = null; - $this->live_stream_using_airtime_auth = null; - $this->live_stream_using_custom_auth = null; - $this->live_stream_user = null; - $this->live_stream_pass = null; - $this->linked = null; - $this->is_linkable = 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->collCcShowInstancess) { - foreach ((array) $this->collCcShowInstancess as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCcShowDayss) { - foreach ((array) $this->collCcShowDayss as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCcShowRebroadcasts) { - foreach ((array) $this->collCcShowRebroadcasts as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCcShowHostss) { - foreach ((array) $this->collCcShowHostss as $o) { - $o->clearAllReferences($deep); - } - } - } // if ($deep) - - $this->collCcShowInstancess = null; - $this->collCcShowDayss = null; - $this->collCcShowRebroadcasts = null; - $this->collCcShowHostss = 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); - } - -} // BaseCcShow + /** + * Peer class name + */ + const PEER = 'Airtime\\CcShowPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcShowPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the name field. + * Note: this column has a database default value of: '' + * @var string + */ + protected $name; + + /** + * The value for the url field. + * Note: this column has a database default value of: '' + * @var string + */ + protected $url; + + /** + * The value for the genre field. + * Note: this column has a database default value of: '' + * @var string + */ + protected $genre; + + /** + * The value for the description field. + * @var string + */ + protected $description; + + /** + * The value for the color field. + * @var string + */ + protected $color; + + /** + * The value for the background_color field. + * @var string + */ + protected $background_color; + + /** + * The value for the live_stream_using_airtime_auth field. + * Note: this column has a database default value of: false + * @var boolean + */ + protected $live_stream_using_airtime_auth; + + /** + * The value for the live_stream_using_custom_auth field. + * Note: this column has a database default value of: false + * @var boolean + */ + protected $live_stream_using_custom_auth; + + /** + * The value for the live_stream_user field. + * @var string + */ + protected $live_stream_user; + + /** + * The value for the live_stream_pass field. + * @var string + */ + protected $live_stream_pass; + + /** + * The value for the linked field. + * Note: this column has a database default value of: false + * @var boolean + */ + protected $linked; + + /** + * The value for the is_linkable field. + * Note: this column has a database default value of: true + * @var boolean + */ + protected $is_linkable; + + /** + * @var PropelObjectCollection|CcShowInstances[] Collection to store aggregation of CcShowInstances objects. + */ + protected $collCcShowInstancess; + protected $collCcShowInstancessPartial; + + /** + * @var PropelObjectCollection|CcShowDays[] Collection to store aggregation of CcShowDays objects. + */ + protected $collCcShowDayss; + protected $collCcShowDayssPartial; + + /** + * @var PropelObjectCollection|CcShowRebroadcast[] Collection to store aggregation of CcShowRebroadcast objects. + */ + protected $collCcShowRebroadcasts; + protected $collCcShowRebroadcastsPartial; + + /** + * @var PropelObjectCollection|CcShowHosts[] Collection to store aggregation of CcShowHosts objects. + */ + protected $collCcShowHostss; + protected $collCcShowHostssPartial; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccShowInstancessScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccShowDayssScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccShowRebroadcastsScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccShowHostssScheduledForDeletion = null; + + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->name = ''; + $this->url = ''; + $this->genre = ''; + $this->live_stream_using_airtime_auth = false; + $this->live_stream_using_custom_auth = false; + $this->linked = false; + $this->is_linkable = true; + } + + /** + * 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 [url] column value. + * + * @return string + */ + public function getDbUrl() + { + + return $this->url; + } + + /** + * Get the [genre] column value. + * + * @return string + */ + public function getDbGenre() + { + + return $this->genre; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDbDescription() + { + + return $this->description; + } + + /** + * Get the [color] column value. + * + * @return string + */ + public function getDbColor() + { + + return $this->color; + } + + /** + * Get the [background_color] column value. + * + * @return string + */ + public function getDbBackgroundColor() + { + + return $this->background_color; + } + + /** + * Get the [live_stream_using_airtime_auth] column value. + * + * @return boolean + */ + public function getDbLiveStreamUsingAirtimeAuth() + { + + return $this->live_stream_using_airtime_auth; + } + + /** + * Get the [live_stream_using_custom_auth] column value. + * + * @return boolean + */ + public function getDbLiveStreamUsingCustomAuth() + { + + return $this->live_stream_using_custom_auth; + } + + /** + * Get the [live_stream_user] column value. + * + * @return string + */ + public function getDbLiveStreamUser() + { + + return $this->live_stream_user; + } + + /** + * Get the [live_stream_pass] column value. + * + * @return string + */ + public function getDbLiveStreamPass() + { + + return $this->live_stream_pass; + } + + /** + * Get the [linked] column value. + * + * @return boolean + */ + public function getDbLinked() + { + + return $this->linked; + } + + /** + * Get the [is_linkable] column value. + * + * @return boolean + */ + public function getDbIsLinkable() + { + + return $this->is_linkable; + } + + /** + * 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 && is_numeric($v)) { + $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 && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = CcShowPeer::NAME; + } + + + return $this; + } // setDbName() + + /** + * Set the value of [url] column. + * + * @param string $v new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbUrl($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->url !== $v) { + $this->url = $v; + $this->modifiedColumns[] = CcShowPeer::URL; + } + + + return $this; + } // setDbUrl() + + /** + * Set the value of [genre] column. + * + * @param string $v new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbGenre($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->genre !== $v) { + $this->genre = $v; + $this->modifiedColumns[] = CcShowPeer::GENRE; + } + + + return $this; + } // setDbGenre() + + /** + * 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 && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = CcShowPeer::DESCRIPTION; + } + + + return $this; + } // setDbDescription() + + /** + * Set the value of [color] column. + * + * @param string $v new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbColor($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->color !== $v) { + $this->color = $v; + $this->modifiedColumns[] = CcShowPeer::COLOR; + } + + + return $this; + } // setDbColor() + + /** + * Set the value of [background_color] column. + * + * @param string $v new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbBackgroundColor($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->background_color !== $v) { + $this->background_color = $v; + $this->modifiedColumns[] = CcShowPeer::BACKGROUND_COLOR; + } + + + return $this; + } // setDbBackgroundColor() + + /** + * Sets the value of the [live_stream_using_airtime_auth] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbLiveStreamUsingAirtimeAuth($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->live_stream_using_airtime_auth !== $v) { + $this->live_stream_using_airtime_auth = $v; + $this->modifiedColumns[] = CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH; + } + + + return $this; + } // setDbLiveStreamUsingAirtimeAuth() + + /** + * Sets the value of the [live_stream_using_custom_auth] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbLiveStreamUsingCustomAuth($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->live_stream_using_custom_auth !== $v) { + $this->live_stream_using_custom_auth = $v; + $this->modifiedColumns[] = CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH; + } + + + return $this; + } // setDbLiveStreamUsingCustomAuth() + + /** + * Set the value of [live_stream_user] column. + * + * @param string $v new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbLiveStreamUser($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->live_stream_user !== $v) { + $this->live_stream_user = $v; + $this->modifiedColumns[] = CcShowPeer::LIVE_STREAM_USER; + } + + + return $this; + } // setDbLiveStreamUser() + + /** + * Set the value of [live_stream_pass] column. + * + * @param string $v new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbLiveStreamPass($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->live_stream_pass !== $v) { + $this->live_stream_pass = $v; + $this->modifiedColumns[] = CcShowPeer::LIVE_STREAM_PASS; + } + + + return $this; + } // setDbLiveStreamPass() + + /** + * Sets the value of the [linked] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbLinked($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->linked !== $v) { + $this->linked = $v; + $this->modifiedColumns[] = CcShowPeer::LINKED; + } + + + return $this; + } // setDbLinked() + + /** + * Sets the value of the [is_linkable] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return CcShow The current object (for fluent API support) + */ + public function setDbIsLinkable($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_linkable !== $v) { + $this->is_linkable = $v; + $this->modifiedColumns[] = CcShowPeer::IS_LINKABLE; + } + + + return $this; + } // setDbIsLinkable() + + /** + * 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->url !== '') { + return false; + } + + if ($this->genre !== '') { + return false; + } + + if ($this->live_stream_using_airtime_auth !== false) { + return false; + } + + if ($this->live_stream_using_custom_auth !== false) { + return false; + } + + if ($this->linked !== false) { + return false; + } + + if ($this->is_linkable !== true) { + 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 resultset 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->url = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->genre = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->color = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->background_color = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->live_stream_using_airtime_auth = ($row[$startcol + 7] !== null) ? (boolean) $row[$startcol + 7] : null; + $this->live_stream_using_custom_auth = ($row[$startcol + 8] !== null) ? (boolean) $row[$startcol + 8] : null; + $this->live_stream_user = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->live_stream_pass = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; + $this->linked = ($row[$startcol + 11] !== null) ? (boolean) $row[$startcol + 11] : null; + $this->is_linkable = ($row[$startcol + 12] !== null) ? (boolean) $row[$startcol + 12] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 13; // 13 = CcShowPeer::NUM_HYDRATE_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? + + $this->collCcShowInstancess = null; + + $this->collCcShowDayss = null; + + $this->collCcShowRebroadcasts = null; + + $this->collCcShowHostss = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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 { + $deleteQuery = CcShowQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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 (Exception $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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->ccShowInstancessScheduledForDeletion !== null) { + if (!$this->ccShowInstancessScheduledForDeletion->isEmpty()) { + CcShowInstancesQuery::create() + ->filterByPrimaryKeys($this->ccShowInstancessScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccShowInstancessScheduledForDeletion = null; + } + } + + if ($this->collCcShowInstancess !== null) { + foreach ($this->collCcShowInstancess as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ccShowDayssScheduledForDeletion !== null) { + if (!$this->ccShowDayssScheduledForDeletion->isEmpty()) { + CcShowDaysQuery::create() + ->filterByPrimaryKeys($this->ccShowDayssScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccShowDayssScheduledForDeletion = null; + } + } + + if ($this->collCcShowDayss !== null) { + foreach ($this->collCcShowDayss as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ccShowRebroadcastsScheduledForDeletion !== null) { + if (!$this->ccShowRebroadcastsScheduledForDeletion->isEmpty()) { + CcShowRebroadcastQuery::create() + ->filterByPrimaryKeys($this->ccShowRebroadcastsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccShowRebroadcastsScheduledForDeletion = null; + } + } + + if ($this->collCcShowRebroadcasts !== null) { + foreach ($this->collCcShowRebroadcasts as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ccShowHostssScheduledForDeletion !== null) { + if (!$this->ccShowHostssScheduledForDeletion->isEmpty()) { + CcShowHostsQuery::create() + ->filterByPrimaryKeys($this->ccShowHostssScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccShowHostssScheduledForDeletion = null; + } + } + + if ($this->collCcShowHostss !== null) { + foreach ($this->collCcShowHostss as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcShowPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcShowPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_show_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcShowPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcShowPeer::NAME)) { + $modifiedColumns[':p' . $index++] = '"name"'; + } + if ($this->isColumnModified(CcShowPeer::URL)) { + $modifiedColumns[':p' . $index++] = '"url"'; + } + if ($this->isColumnModified(CcShowPeer::GENRE)) { + $modifiedColumns[':p' . $index++] = '"genre"'; + } + if ($this->isColumnModified(CcShowPeer::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = '"description"'; + } + if ($this->isColumnModified(CcShowPeer::COLOR)) { + $modifiedColumns[':p' . $index++] = '"color"'; + } + if ($this->isColumnModified(CcShowPeer::BACKGROUND_COLOR)) { + $modifiedColumns[':p' . $index++] = '"background_color"'; + } + if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH)) { + $modifiedColumns[':p' . $index++] = '"live_stream_using_airtime_auth"'; + } + if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH)) { + $modifiedColumns[':p' . $index++] = '"live_stream_using_custom_auth"'; + } + if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_USER)) { + $modifiedColumns[':p' . $index++] = '"live_stream_user"'; + } + if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_PASS)) { + $modifiedColumns[':p' . $index++] = '"live_stream_pass"'; + } + if ($this->isColumnModified(CcShowPeer::LINKED)) { + $modifiedColumns[':p' . $index++] = '"linked"'; + } + if ($this->isColumnModified(CcShowPeer::IS_LINKABLE)) { + $modifiedColumns[':p' . $index++] = '"is_linkable"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_show" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"name"': + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); + break; + case '"url"': + $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR); + break; + case '"genre"': + $stmt->bindValue($identifier, $this->genre, PDO::PARAM_STR); + break; + case '"description"': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case '"color"': + $stmt->bindValue($identifier, $this->color, PDO::PARAM_STR); + break; + case '"background_color"': + $stmt->bindValue($identifier, $this->background_color, PDO::PARAM_STR); + break; + case '"live_stream_using_airtime_auth"': + $stmt->bindValue($identifier, $this->live_stream_using_airtime_auth, PDO::PARAM_BOOL); + break; + case '"live_stream_using_custom_auth"': + $stmt->bindValue($identifier, $this->live_stream_using_custom_auth, PDO::PARAM_BOOL); + break; + case '"live_stream_user"': + $stmt->bindValue($identifier, $this->live_stream_user, PDO::PARAM_STR); + break; + case '"live_stream_pass"': + $stmt->bindValue($identifier, $this->live_stream_pass, PDO::PARAM_STR); + break; + case '"linked"': + $stmt->bindValue($identifier, $this->linked, PDO::PARAM_BOOL); + break; + case '"is_linkable"': + $stmt->bindValue($identifier, $this->is_linkable, PDO::PARAM_BOOL); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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); + } + + + if ($this->collCcShowInstancess !== null) { + foreach ($this->collCcShowInstancess as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collCcShowDayss !== null) { + foreach ($this->collCcShowDayss as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collCcShowRebroadcasts !== null) { + foreach ($this->collCcShowRebroadcasts as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collCcShowHostss !== null) { + foreach ($this->collCcShowHostss 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @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->getDbUrl(); + break; + case 3: + return $this->getDbGenre(); + break; + case 4: + return $this->getDbDescription(); + break; + case 5: + return $this->getDbColor(); + break; + case 6: + return $this->getDbBackgroundColor(); + break; + case 7: + return $this->getDbLiveStreamUsingAirtimeAuth(); + break; + case 8: + return $this->getDbLiveStreamUsingCustomAuth(); + break; + case 9: + return $this->getDbLiveStreamUser(); + break; + case 10: + return $this->getDbLiveStreamPass(); + break; + case 11: + return $this->getDbLinked(); + break; + case 12: + return $this->getDbIsLinkable(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcShow'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcShow'][$this->getPrimaryKey()] = true; + $keys = CcShowPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbName(), + $keys[2] => $this->getDbUrl(), + $keys[3] => $this->getDbGenre(), + $keys[4] => $this->getDbDescription(), + $keys[5] => $this->getDbColor(), + $keys[6] => $this->getDbBackgroundColor(), + $keys[7] => $this->getDbLiveStreamUsingAirtimeAuth(), + $keys[8] => $this->getDbLiveStreamUsingCustomAuth(), + $keys[9] => $this->getDbLiveStreamUser(), + $keys[10] => $this->getDbLiveStreamPass(), + $keys[11] => $this->getDbLinked(), + $keys[12] => $this->getDbIsLinkable(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->collCcShowInstancess) { + $result['CcShowInstancess'] = $this->collCcShowInstancess->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCcShowDayss) { + $result['CcShowDayss'] = $this->collCcShowDayss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCcShowRebroadcasts) { + $result['CcShowRebroadcasts'] = $this->collCcShowRebroadcasts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCcShowHostss) { + $result['CcShowHostss'] = $this->collCcShowHostss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcShowPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbUrl($value); + break; + case 3: + $this->setDbGenre($value); + break; + case 4: + $this->setDbDescription($value); + break; + case 5: + $this->setDbColor($value); + break; + case 6: + $this->setDbBackgroundColor($value); + break; + case 7: + $this->setDbLiveStreamUsingAirtimeAuth($value); + break; + case 8: + $this->setDbLiveStreamUsingCustomAuth($value); + break; + case 9: + $this->setDbLiveStreamUser($value); + break; + case 10: + $this->setDbLiveStreamPass($value); + break; + case 11: + $this->setDbLinked($value); + break; + case 12: + $this->setDbIsLinkable($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 BasePeer::TYPE_PHPNAME + * + * @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->setDbUrl($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbGenre($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbDescription($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbColor($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbBackgroundColor($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbLiveStreamUsingAirtimeAuth($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setDbLiveStreamUsingCustomAuth($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDbLiveStreamUser($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setDbLiveStreamPass($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setDbLinked($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setDbIsLinkable($arr[$keys[12]]); + } + + /** + * 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::URL)) $criteria->add(CcShowPeer::URL, $this->url); + if ($this->isColumnModified(CcShowPeer::GENRE)) $criteria->add(CcShowPeer::GENRE, $this->genre); + if ($this->isColumnModified(CcShowPeer::DESCRIPTION)) $criteria->add(CcShowPeer::DESCRIPTION, $this->description); + if ($this->isColumnModified(CcShowPeer::COLOR)) $criteria->add(CcShowPeer::COLOR, $this->color); + if ($this->isColumnModified(CcShowPeer::BACKGROUND_COLOR)) $criteria->add(CcShowPeer::BACKGROUND_COLOR, $this->background_color); + if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH)) $criteria->add(CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH, $this->live_stream_using_airtime_auth); + if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH)) $criteria->add(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH, $this->live_stream_using_custom_auth); + if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_USER)) $criteria->add(CcShowPeer::LIVE_STREAM_USER, $this->live_stream_user); + if ($this->isColumnModified(CcShowPeer::LIVE_STREAM_PASS)) $criteria->add(CcShowPeer::LIVE_STREAM_PASS, $this->live_stream_pass); + if ($this->isColumnModified(CcShowPeer::LINKED)) $criteria->add(CcShowPeer::LINKED, $this->linked); + if ($this->isColumnModified(CcShowPeer::IS_LINKABLE)) $criteria->add(CcShowPeer::IS_LINKABLE, $this->is_linkable); + + 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. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbName($this->getDbName()); + $copyObj->setDbUrl($this->getDbUrl()); + $copyObj->setDbGenre($this->getDbGenre()); + $copyObj->setDbDescription($this->getDbDescription()); + $copyObj->setDbColor($this->getDbColor()); + $copyObj->setDbBackgroundColor($this->getDbBackgroundColor()); + $copyObj->setDbLiveStreamUsingAirtimeAuth($this->getDbLiveStreamUsingAirtimeAuth()); + $copyObj->setDbLiveStreamUsingCustomAuth($this->getDbLiveStreamUsingCustomAuth()); + $copyObj->setDbLiveStreamUser($this->getDbLiveStreamUser()); + $copyObj->setDbLiveStreamPass($this->getDbLiveStreamPass()); + $copyObj->setDbLinked($this->getDbLinked()); + $copyObj->setDbIsLinkable($this->getDbIsLinkable()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + foreach ($this->getCcShowInstancess() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcShowInstances($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCcShowDayss() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcShowDays($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCcShowRebroadcasts() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcShowRebroadcast($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCcShowHostss() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcShowHosts($relObj->copy($deepCopy)); + } + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('CcShowInstances' == $relationName) { + $this->initCcShowInstancess(); + } + if ('CcShowDays' == $relationName) { + $this->initCcShowDayss(); + } + if ('CcShowRebroadcast' == $relationName) { + $this->initCcShowRebroadcasts(); + } + if ('CcShowHosts' == $relationName) { + $this->initCcShowHostss(); + } + } + + /** + * Clears out the collCcShowInstancess 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 CcShow The current object (for fluent API support) + * @see addCcShowInstancess() + */ + public function clearCcShowInstancess() + { + $this->collCcShowInstancess = null; // important to set this to null since that means it is uninitialized + $this->collCcShowInstancessPartial = null; + + return $this; + } + + /** + * reset is the collCcShowInstancess collection loaded partially + * + * @return void + */ + public function resetPartialCcShowInstancess($v = true) + { + $this->collCcShowInstancessPartial = $v; + } + + /** + * Initializes the collCcShowInstancess collection. + * + * By default this just sets the collCcShowInstancess collection to an empty array (like clearcollCcShowInstancess()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcShowInstancess($overrideExisting = true) + { + if (null !== $this->collCcShowInstancess && !$overrideExisting) { + return; + } + $this->collCcShowInstancess = new PropelObjectCollection(); + $this->collCcShowInstancess->setModel('CcShowInstances'); + } + + /** + * Gets an array of CcShowInstances 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 CcShow 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 PropelObjectCollection|CcShowInstances[] List of CcShowInstances objects + * @throws PropelException + */ + public function getCcShowInstancess($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcShowInstancessPartial && !$this->isNew(); + if (null === $this->collCcShowInstancess || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcShowInstancess) { + // return empty collection + $this->initCcShowInstancess(); + } else { + $collCcShowInstancess = CcShowInstancesQuery::create(null, $criteria) + ->filterByCcShow($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcShowInstancessPartial && count($collCcShowInstancess)) { + $this->initCcShowInstancess(false); + + foreach ($collCcShowInstancess as $obj) { + if (false == $this->collCcShowInstancess->contains($obj)) { + $this->collCcShowInstancess->append($obj); + } + } + + $this->collCcShowInstancessPartial = true; + } + + $collCcShowInstancess->getInternalIterator()->rewind(); + + return $collCcShowInstancess; + } + + if ($partial && $this->collCcShowInstancess) { + foreach ($this->collCcShowInstancess as $obj) { + if ($obj->isNew()) { + $collCcShowInstancess[] = $obj; + } + } + } + + $this->collCcShowInstancess = $collCcShowInstancess; + $this->collCcShowInstancessPartial = false; + } + } + + return $this->collCcShowInstancess; + } + + /** + * Sets a collection of CcShowInstances objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccShowInstancess A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcShow The current object (for fluent API support) + */ + public function setCcShowInstancess(PropelCollection $ccShowInstancess, PropelPDO $con = null) + { + $ccShowInstancessToDelete = $this->getCcShowInstancess(new Criteria(), $con)->diff($ccShowInstancess); + + + $this->ccShowInstancessScheduledForDeletion = $ccShowInstancessToDelete; + + foreach ($ccShowInstancessToDelete as $ccShowInstancesRemoved) { + $ccShowInstancesRemoved->setCcShow(null); + } + + $this->collCcShowInstancess = null; + foreach ($ccShowInstancess as $ccShowInstances) { + $this->addCcShowInstances($ccShowInstances); + } + + $this->collCcShowInstancess = $ccShowInstancess; + $this->collCcShowInstancessPartial = false; + + return $this; + } + + /** + * Returns the number of related CcShowInstances objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcShowInstances objects. + * @throws PropelException + */ + public function countCcShowInstancess(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcShowInstancessPartial && !$this->isNew(); + if (null === $this->collCcShowInstancess || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcShowInstancess) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcShowInstancess()); + } + $query = CcShowInstancesQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcShow($this) + ->count($con); + } + + return count($this->collCcShowInstancess); + } + + /** + * Method called to associate a CcShowInstances object to this object + * through the CcShowInstances foreign key attribute. + * + * @param CcShowInstances $l CcShowInstances + * @return CcShow The current object (for fluent API support) + */ + public function addCcShowInstances(CcShowInstances $l) + { + if ($this->collCcShowInstancess === null) { + $this->initCcShowInstancess(); + $this->collCcShowInstancessPartial = true; + } + + if (!in_array($l, $this->collCcShowInstancess->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcShowInstances($l); + + if ($this->ccShowInstancessScheduledForDeletion and $this->ccShowInstancessScheduledForDeletion->contains($l)) { + $this->ccShowInstancessScheduledForDeletion->remove($this->ccShowInstancessScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcShowInstances $ccShowInstances The ccShowInstances object to add. + */ + protected function doAddCcShowInstances($ccShowInstances) + { + $this->collCcShowInstancess[]= $ccShowInstances; + $ccShowInstances->setCcShow($this); + } + + /** + * @param CcShowInstances $ccShowInstances The ccShowInstances object to remove. + * @return CcShow The current object (for fluent API support) + */ + public function removeCcShowInstances($ccShowInstances) + { + if ($this->getCcShowInstancess()->contains($ccShowInstances)) { + $this->collCcShowInstancess->remove($this->collCcShowInstancess->search($ccShowInstances)); + if (null === $this->ccShowInstancessScheduledForDeletion) { + $this->ccShowInstancessScheduledForDeletion = clone $this->collCcShowInstancess; + $this->ccShowInstancessScheduledForDeletion->clear(); + } + $this->ccShowInstancessScheduledForDeletion[]= clone $ccShowInstances; + $ccShowInstances->setCcShow(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcShow is new, it will return + * an empty collection; or if this CcShow has previously + * been saved, it will retrieve related CcShowInstancess 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 CcShow. + * + * @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 PropelObjectCollection|CcShowInstances[] List of CcShowInstances objects + */ + public function getCcShowInstancessJoinCcShowInstancesRelatedByDbOriginalShow($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcShowInstancesQuery::create(null, $criteria); + $query->joinWith('CcShowInstancesRelatedByDbOriginalShow', $join_behavior); + + return $this->getCcShowInstancess($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcShow is new, it will return + * an empty collection; or if this CcShow has previously + * been saved, it will retrieve related CcShowInstancess 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 CcShow. + * + * @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 PropelObjectCollection|CcShowInstances[] List of CcShowInstances objects + */ + public function getCcShowInstancessJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcShowInstancesQuery::create(null, $criteria); + $query->joinWith('CcFiles', $join_behavior); + + return $this->getCcShowInstancess($query, $con); + } + + /** + * Clears out the collCcShowDayss 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 CcShow The current object (for fluent API support) + * @see addCcShowDayss() + */ + public function clearCcShowDayss() + { + $this->collCcShowDayss = null; // important to set this to null since that means it is uninitialized + $this->collCcShowDayssPartial = null; + + return $this; + } + + /** + * reset is the collCcShowDayss collection loaded partially + * + * @return void + */ + public function resetPartialCcShowDayss($v = true) + { + $this->collCcShowDayssPartial = $v; + } + + /** + * Initializes the collCcShowDayss collection. + * + * By default this just sets the collCcShowDayss collection to an empty array (like clearcollCcShowDayss()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcShowDayss($overrideExisting = true) + { + if (null !== $this->collCcShowDayss && !$overrideExisting) { + return; + } + $this->collCcShowDayss = new PropelObjectCollection(); + $this->collCcShowDayss->setModel('CcShowDays'); + } + + /** + * Gets an array of CcShowDays 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 CcShow 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 PropelObjectCollection|CcShowDays[] List of CcShowDays objects + * @throws PropelException + */ + public function getCcShowDayss($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcShowDayssPartial && !$this->isNew(); + if (null === $this->collCcShowDayss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcShowDayss) { + // return empty collection + $this->initCcShowDayss(); + } else { + $collCcShowDayss = CcShowDaysQuery::create(null, $criteria) + ->filterByCcShow($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcShowDayssPartial && count($collCcShowDayss)) { + $this->initCcShowDayss(false); + + foreach ($collCcShowDayss as $obj) { + if (false == $this->collCcShowDayss->contains($obj)) { + $this->collCcShowDayss->append($obj); + } + } + + $this->collCcShowDayssPartial = true; + } + + $collCcShowDayss->getInternalIterator()->rewind(); + + return $collCcShowDayss; + } + + if ($partial && $this->collCcShowDayss) { + foreach ($this->collCcShowDayss as $obj) { + if ($obj->isNew()) { + $collCcShowDayss[] = $obj; + } + } + } + + $this->collCcShowDayss = $collCcShowDayss; + $this->collCcShowDayssPartial = false; + } + } + + return $this->collCcShowDayss; + } + + /** + * Sets a collection of CcShowDays objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccShowDayss A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcShow The current object (for fluent API support) + */ + public function setCcShowDayss(PropelCollection $ccShowDayss, PropelPDO $con = null) + { + $ccShowDayssToDelete = $this->getCcShowDayss(new Criteria(), $con)->diff($ccShowDayss); + + + $this->ccShowDayssScheduledForDeletion = $ccShowDayssToDelete; + + foreach ($ccShowDayssToDelete as $ccShowDaysRemoved) { + $ccShowDaysRemoved->setCcShow(null); + } + + $this->collCcShowDayss = null; + foreach ($ccShowDayss as $ccShowDays) { + $this->addCcShowDays($ccShowDays); + } + + $this->collCcShowDayss = $ccShowDayss; + $this->collCcShowDayssPartial = false; + + return $this; + } + + /** + * Returns the number of related CcShowDays objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcShowDays objects. + * @throws PropelException + */ + public function countCcShowDayss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcShowDayssPartial && !$this->isNew(); + if (null === $this->collCcShowDayss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcShowDayss) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcShowDayss()); + } + $query = CcShowDaysQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcShow($this) + ->count($con); + } + + return count($this->collCcShowDayss); + } + + /** + * Method called to associate a CcShowDays object to this object + * through the CcShowDays foreign key attribute. + * + * @param CcShowDays $l CcShowDays + * @return CcShow The current object (for fluent API support) + */ + public function addCcShowDays(CcShowDays $l) + { + if ($this->collCcShowDayss === null) { + $this->initCcShowDayss(); + $this->collCcShowDayssPartial = true; + } + + if (!in_array($l, $this->collCcShowDayss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcShowDays($l); + + if ($this->ccShowDayssScheduledForDeletion and $this->ccShowDayssScheduledForDeletion->contains($l)) { + $this->ccShowDayssScheduledForDeletion->remove($this->ccShowDayssScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcShowDays $ccShowDays The ccShowDays object to add. + */ + protected function doAddCcShowDays($ccShowDays) + { + $this->collCcShowDayss[]= $ccShowDays; + $ccShowDays->setCcShow($this); + } + + /** + * @param CcShowDays $ccShowDays The ccShowDays object to remove. + * @return CcShow The current object (for fluent API support) + */ + public function removeCcShowDays($ccShowDays) + { + if ($this->getCcShowDayss()->contains($ccShowDays)) { + $this->collCcShowDayss->remove($this->collCcShowDayss->search($ccShowDays)); + if (null === $this->ccShowDayssScheduledForDeletion) { + $this->ccShowDayssScheduledForDeletion = clone $this->collCcShowDayss; + $this->ccShowDayssScheduledForDeletion->clear(); + } + $this->ccShowDayssScheduledForDeletion[]= clone $ccShowDays; + $ccShowDays->setCcShow(null); + } + + return $this; + } + + /** + * Clears out the collCcShowRebroadcasts 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 CcShow The current object (for fluent API support) + * @see addCcShowRebroadcasts() + */ + public function clearCcShowRebroadcasts() + { + $this->collCcShowRebroadcasts = null; // important to set this to null since that means it is uninitialized + $this->collCcShowRebroadcastsPartial = null; + + return $this; + } + + /** + * reset is the collCcShowRebroadcasts collection loaded partially + * + * @return void + */ + public function resetPartialCcShowRebroadcasts($v = true) + { + $this->collCcShowRebroadcastsPartial = $v; + } + + /** + * Initializes the collCcShowRebroadcasts collection. + * + * By default this just sets the collCcShowRebroadcasts collection to an empty array (like clearcollCcShowRebroadcasts()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcShowRebroadcasts($overrideExisting = true) + { + if (null !== $this->collCcShowRebroadcasts && !$overrideExisting) { + return; + } + $this->collCcShowRebroadcasts = new PropelObjectCollection(); + $this->collCcShowRebroadcasts->setModel('CcShowRebroadcast'); + } + + /** + * Gets an array of CcShowRebroadcast 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 CcShow 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 PropelObjectCollection|CcShowRebroadcast[] List of CcShowRebroadcast objects + * @throws PropelException + */ + public function getCcShowRebroadcasts($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcShowRebroadcastsPartial && !$this->isNew(); + if (null === $this->collCcShowRebroadcasts || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcShowRebroadcasts) { + // return empty collection + $this->initCcShowRebroadcasts(); + } else { + $collCcShowRebroadcasts = CcShowRebroadcastQuery::create(null, $criteria) + ->filterByCcShow($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcShowRebroadcastsPartial && count($collCcShowRebroadcasts)) { + $this->initCcShowRebroadcasts(false); + + foreach ($collCcShowRebroadcasts as $obj) { + if (false == $this->collCcShowRebroadcasts->contains($obj)) { + $this->collCcShowRebroadcasts->append($obj); + } + } + + $this->collCcShowRebroadcastsPartial = true; + } + + $collCcShowRebroadcasts->getInternalIterator()->rewind(); + + return $collCcShowRebroadcasts; + } + + if ($partial && $this->collCcShowRebroadcasts) { + foreach ($this->collCcShowRebroadcasts as $obj) { + if ($obj->isNew()) { + $collCcShowRebroadcasts[] = $obj; + } + } + } + + $this->collCcShowRebroadcasts = $collCcShowRebroadcasts; + $this->collCcShowRebroadcastsPartial = false; + } + } + + return $this->collCcShowRebroadcasts; + } + + /** + * Sets a collection of CcShowRebroadcast objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccShowRebroadcasts A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcShow The current object (for fluent API support) + */ + public function setCcShowRebroadcasts(PropelCollection $ccShowRebroadcasts, PropelPDO $con = null) + { + $ccShowRebroadcastsToDelete = $this->getCcShowRebroadcasts(new Criteria(), $con)->diff($ccShowRebroadcasts); + + + $this->ccShowRebroadcastsScheduledForDeletion = $ccShowRebroadcastsToDelete; + + foreach ($ccShowRebroadcastsToDelete as $ccShowRebroadcastRemoved) { + $ccShowRebroadcastRemoved->setCcShow(null); + } + + $this->collCcShowRebroadcasts = null; + foreach ($ccShowRebroadcasts as $ccShowRebroadcast) { + $this->addCcShowRebroadcast($ccShowRebroadcast); + } + + $this->collCcShowRebroadcasts = $ccShowRebroadcasts; + $this->collCcShowRebroadcastsPartial = false; + + return $this; + } + + /** + * Returns the number of related CcShowRebroadcast objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcShowRebroadcast objects. + * @throws PropelException + */ + public function countCcShowRebroadcasts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcShowRebroadcastsPartial && !$this->isNew(); + if (null === $this->collCcShowRebroadcasts || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcShowRebroadcasts) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcShowRebroadcasts()); + } + $query = CcShowRebroadcastQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcShow($this) + ->count($con); + } + + return count($this->collCcShowRebroadcasts); + } + + /** + * Method called to associate a CcShowRebroadcast object to this object + * through the CcShowRebroadcast foreign key attribute. + * + * @param CcShowRebroadcast $l CcShowRebroadcast + * @return CcShow The current object (for fluent API support) + */ + public function addCcShowRebroadcast(CcShowRebroadcast $l) + { + if ($this->collCcShowRebroadcasts === null) { + $this->initCcShowRebroadcasts(); + $this->collCcShowRebroadcastsPartial = true; + } + + if (!in_array($l, $this->collCcShowRebroadcasts->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcShowRebroadcast($l); + + if ($this->ccShowRebroadcastsScheduledForDeletion and $this->ccShowRebroadcastsScheduledForDeletion->contains($l)) { + $this->ccShowRebroadcastsScheduledForDeletion->remove($this->ccShowRebroadcastsScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcShowRebroadcast $ccShowRebroadcast The ccShowRebroadcast object to add. + */ + protected function doAddCcShowRebroadcast($ccShowRebroadcast) + { + $this->collCcShowRebroadcasts[]= $ccShowRebroadcast; + $ccShowRebroadcast->setCcShow($this); + } + + /** + * @param CcShowRebroadcast $ccShowRebroadcast The ccShowRebroadcast object to remove. + * @return CcShow The current object (for fluent API support) + */ + public function removeCcShowRebroadcast($ccShowRebroadcast) + { + if ($this->getCcShowRebroadcasts()->contains($ccShowRebroadcast)) { + $this->collCcShowRebroadcasts->remove($this->collCcShowRebroadcasts->search($ccShowRebroadcast)); + if (null === $this->ccShowRebroadcastsScheduledForDeletion) { + $this->ccShowRebroadcastsScheduledForDeletion = clone $this->collCcShowRebroadcasts; + $this->ccShowRebroadcastsScheduledForDeletion->clear(); + } + $this->ccShowRebroadcastsScheduledForDeletion[]= clone $ccShowRebroadcast; + $ccShowRebroadcast->setCcShow(null); + } + + return $this; + } + + /** + * Clears out the collCcShowHostss 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 CcShow The current object (for fluent API support) + * @see addCcShowHostss() + */ + public function clearCcShowHostss() + { + $this->collCcShowHostss = null; // important to set this to null since that means it is uninitialized + $this->collCcShowHostssPartial = null; + + return $this; + } + + /** + * reset is the collCcShowHostss collection loaded partially + * + * @return void + */ + public function resetPartialCcShowHostss($v = true) + { + $this->collCcShowHostssPartial = $v; + } + + /** + * Initializes the collCcShowHostss collection. + * + * By default this just sets the collCcShowHostss collection to an empty array (like clearcollCcShowHostss()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcShowHostss($overrideExisting = true) + { + if (null !== $this->collCcShowHostss && !$overrideExisting) { + return; + } + $this->collCcShowHostss = new PropelObjectCollection(); + $this->collCcShowHostss->setModel('CcShowHosts'); + } + + /** + * Gets an array of CcShowHosts 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 CcShow 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 PropelObjectCollection|CcShowHosts[] List of CcShowHosts objects + * @throws PropelException + */ + public function getCcShowHostss($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcShowHostssPartial && !$this->isNew(); + if (null === $this->collCcShowHostss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcShowHostss) { + // return empty collection + $this->initCcShowHostss(); + } else { + $collCcShowHostss = CcShowHostsQuery::create(null, $criteria) + ->filterByCcShow($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcShowHostssPartial && count($collCcShowHostss)) { + $this->initCcShowHostss(false); + + foreach ($collCcShowHostss as $obj) { + if (false == $this->collCcShowHostss->contains($obj)) { + $this->collCcShowHostss->append($obj); + } + } + + $this->collCcShowHostssPartial = true; + } + + $collCcShowHostss->getInternalIterator()->rewind(); + + return $collCcShowHostss; + } + + if ($partial && $this->collCcShowHostss) { + foreach ($this->collCcShowHostss as $obj) { + if ($obj->isNew()) { + $collCcShowHostss[] = $obj; + } + } + } + + $this->collCcShowHostss = $collCcShowHostss; + $this->collCcShowHostssPartial = false; + } + } + + return $this->collCcShowHostss; + } + + /** + * Sets a collection of CcShowHosts objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccShowHostss A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcShow The current object (for fluent API support) + */ + public function setCcShowHostss(PropelCollection $ccShowHostss, PropelPDO $con = null) + { + $ccShowHostssToDelete = $this->getCcShowHostss(new Criteria(), $con)->diff($ccShowHostss); + + + $this->ccShowHostssScheduledForDeletion = $ccShowHostssToDelete; + + foreach ($ccShowHostssToDelete as $ccShowHostsRemoved) { + $ccShowHostsRemoved->setCcShow(null); + } + + $this->collCcShowHostss = null; + foreach ($ccShowHostss as $ccShowHosts) { + $this->addCcShowHosts($ccShowHosts); + } + + $this->collCcShowHostss = $ccShowHostss; + $this->collCcShowHostssPartial = false; + + return $this; + } + + /** + * Returns the number of related CcShowHosts objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcShowHosts objects. + * @throws PropelException + */ + public function countCcShowHostss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcShowHostssPartial && !$this->isNew(); + if (null === $this->collCcShowHostss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcShowHostss) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcShowHostss()); + } + $query = CcShowHostsQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcShow($this) + ->count($con); + } + + return count($this->collCcShowHostss); + } + + /** + * Method called to associate a CcShowHosts object to this object + * through the CcShowHosts foreign key attribute. + * + * @param CcShowHosts $l CcShowHosts + * @return CcShow The current object (for fluent API support) + */ + public function addCcShowHosts(CcShowHosts $l) + { + if ($this->collCcShowHostss === null) { + $this->initCcShowHostss(); + $this->collCcShowHostssPartial = true; + } + + if (!in_array($l, $this->collCcShowHostss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcShowHosts($l); + + if ($this->ccShowHostssScheduledForDeletion and $this->ccShowHostssScheduledForDeletion->contains($l)) { + $this->ccShowHostssScheduledForDeletion->remove($this->ccShowHostssScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcShowHosts $ccShowHosts The ccShowHosts object to add. + */ + protected function doAddCcShowHosts($ccShowHosts) + { + $this->collCcShowHostss[]= $ccShowHosts; + $ccShowHosts->setCcShow($this); + } + + /** + * @param CcShowHosts $ccShowHosts The ccShowHosts object to remove. + * @return CcShow The current object (for fluent API support) + */ + public function removeCcShowHosts($ccShowHosts) + { + if ($this->getCcShowHostss()->contains($ccShowHosts)) { + $this->collCcShowHostss->remove($this->collCcShowHostss->search($ccShowHosts)); + if (null === $this->ccShowHostssScheduledForDeletion) { + $this->ccShowHostssScheduledForDeletion = clone $this->collCcShowHostss; + $this->ccShowHostssScheduledForDeletion->clear(); + } + $this->ccShowHostssScheduledForDeletion[]= clone $ccShowHosts; + $ccShowHosts->setCcShow(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcShow is new, it will return + * an empty collection; or if this CcShow has previously + * been saved, it will retrieve related CcShowHostss 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 CcShow. + * + * @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 PropelObjectCollection|CcShowHosts[] List of CcShowHosts objects + */ + public function getCcShowHostssJoinCcSubjs($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcShowHostsQuery::create(null, $criteria); + $query->joinWith('CcSubjs', $join_behavior); + + return $this->getCcShowHostss($query, $con); + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->name = null; + $this->url = null; + $this->genre = null; + $this->description = null; + $this->color = null; + $this->background_color = null; + $this->live_stream_using_airtime_auth = null; + $this->live_stream_using_custom_auth = null; + $this->live_stream_user = null; + $this->live_stream_pass = null; + $this->linked = null; + $this->is_linkable = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->collCcShowInstancess) { + foreach ($this->collCcShowInstancess as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcShowDayss) { + foreach ($this->collCcShowDayss as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcShowRebroadcasts) { + foreach ($this->collCcShowRebroadcasts as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcShowHostss) { + foreach ($this->collCcShowHostss as $o) { + $o->clearAllReferences($deep); + } + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + if ($this->collCcShowInstancess instanceof PropelCollection) { + $this->collCcShowInstancess->clearIterator(); + } + $this->collCcShowInstancess = null; + if ($this->collCcShowDayss instanceof PropelCollection) { + $this->collCcShowDayss->clearIterator(); + } + $this->collCcShowDayss = null; + if ($this->collCcShowRebroadcasts instanceof PropelCollection) { + $this->collCcShowRebroadcasts->clearIterator(); + } + $this->collCcShowRebroadcasts = null; + if ($this->collCcShowHostss instanceof PropelCollection) { + $this->collCcShowHostss->clearIterator(); + } + $this->collCcShowHostss = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcShowPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowDays.php b/airtime_mvc/application/models/airtime/om/BaseCcShowDays.php index be9f66086..04b15aa8b 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowDays.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowDays.php @@ -1,1476 +1,1592 @@ record = 0; - } - - /** - * Initializes internal state of BaseCcShowDays 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 [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 [timezone] column value. - * - * @return string - */ - public function getDbTimezone() - { - return $this->timezone; - } - - /** - * Get the [duration] column value. - * - * @return string - */ - public function getDbDuration() - { - return $this->duration; - } - - /** - * Get the [day] column value. - * - * @return int - */ - public function getDbDay() - { - return $this->day; - } - - /** - * Get the [repeat_type] column value. - * - * @return int - */ - public function getDbRepeatType() - { - return $this->repeat_type; - } - - /** - * Get the [optionally formatted] temporal [next_pop_date] 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 getDbNextPopDate($format = '%x') - { - if ($this->next_pop_date === null) { - return null; - } - - - - try { - $dt = new DateTime($this->next_pop_date); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->next_pop_date, 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 [show_id] column value. - * - * @return int - */ - public function getDbShowId() - { - return $this->show_id; - } - - /** - * Get the [record] column value. - * - * @return int - */ - public function getDbRecord() - { - return $this->record; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcShowDays 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[] = CcShowDaysPeer::ID; - } - - return $this; - } // setDbId() - - /** - * 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 CcShowDays 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[] = CcShowDaysPeer::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 CcShowDays 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[] = CcShowDaysPeer::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 CcShowDays 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[] = CcShowDaysPeer::START_TIME; - } - } // if either are not null - - return $this; - } // setDbStartTime() - - /** - * Set the value of [timezone] column. - * - * @param string $v new value - * @return CcShowDays The current object (for fluent API support) - */ - public function setDbTimezone($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->timezone !== $v) { - $this->timezone = $v; - $this->modifiedColumns[] = CcShowDaysPeer::TIMEZONE; - } - - return $this; - } // setDbTimezone() - - /** - * Set the value of [duration] column. - * - * @param string $v new value - * @return CcShowDays The current object (for fluent API support) - */ - public function setDbDuration($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->duration !== $v) { - $this->duration = $v; - $this->modifiedColumns[] = CcShowDaysPeer::DURATION; - } - - return $this; - } // setDbDuration() - - /** - * Set the value of [day] column. - * - * @param int $v new value - * @return CcShowDays 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[] = CcShowDaysPeer::DAY; - } - - return $this; - } // setDbDay() - - /** - * Set the value of [repeat_type] column. - * - * @param int $v new value - * @return CcShowDays The current object (for fluent API support) - */ - public function setDbRepeatType($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->repeat_type !== $v) { - $this->repeat_type = $v; - $this->modifiedColumns[] = CcShowDaysPeer::REPEAT_TYPE; - } - - return $this; - } // setDbRepeatType() - - /** - * Sets the value of [next_pop_date] 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 CcShowDays The current object (for fluent API support) - */ - public function setDbNextPopDate($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->next_pop_date !== null || $dt !== null ) { - // (nested ifs are a little easier to read in this case) - - $currNorm = ($this->next_pop_date !== null && $tmpDt = new DateTime($this->next_pop_date)) ? $tmpDt->format('Y-m-d') : null; - $newNorm = ($dt !== null) ? $dt->format('Y-m-d') : null; - - if ( ($currNorm !== $newNorm) // normalized values don't match - ) - { - $this->next_pop_date = ($dt ? $dt->format('Y-m-d') : null); - $this->modifiedColumns[] = CcShowDaysPeer::NEXT_POP_DATE; - } - } // if either are not null - - return $this; - } // setDbNextPopDate() - - /** - * Set the value of [show_id] column. - * - * @param int $v new value - * @return CcShowDays The current object (for fluent API support) - */ - public function setDbShowId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->show_id !== $v) { - $this->show_id = $v; - $this->modifiedColumns[] = CcShowDaysPeer::SHOW_ID; - } - - if ($this->aCcShow !== null && $this->aCcShow->getDbId() !== $v) { - $this->aCcShow = null; - } - - return $this; - } // setDbShowId() - - /** - * Set the value of [record] column. - * - * @param int $v new value - * @return CcShowDays The current object (for fluent API support) - */ - public function setDbRecord($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->record !== $v || $this->isNew()) { - $this->record = $v; - $this->modifiedColumns[] = CcShowDaysPeer::RECORD; - } - - return $this; - } // setDbRecord() - - /** - * 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->record !== 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->first_show = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->last_show = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->start_time = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->timezone = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->duration = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->day = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; - $this->repeat_type = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null; - $this->next_pop_date = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; - $this->show_id = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null; - $this->record = ($row[$startcol + 10] !== null) ? (int) $row[$startcol + 10] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 11; // 11 = CcShowDaysPeer::NUM_COLUMNS - CcShowDaysPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcShowDays 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->aCcShow !== null && $this->show_id !== $this->aCcShow->getDbId()) { - $this->aCcShow = 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(CcShowDaysPeer::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 = CcShowDaysPeer::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->aCcShow = 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(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcShowDaysQuery::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(CcShowDaysPeer::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); - CcShowDaysPeer::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->aCcShow !== null) { - if ($this->aCcShow->isModified() || $this->aCcShow->isNew()) { - $affectedRows += $this->aCcShow->save($con); - } - $this->setCcShow($this->aCcShow); - } - - if ($this->isNew() ) { - $this->modifiedColumns[] = CcShowDaysPeer::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(CcShowDaysPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowDaysPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows += 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows += CcShowDaysPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcShow !== null) { - if (!$this->aCcShow->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcShow->getValidationFailures()); - } - } - - - if (($retval = CcShowDaysPeer::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 = CcShowDaysPeer::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->getDbFirstShow(); - break; - case 2: - return $this->getDbLastShow(); - break; - case 3: - return $this->getDbStartTime(); - break; - case 4: - return $this->getDbTimezone(); - break; - case 5: - return $this->getDbDuration(); - break; - case 6: - return $this->getDbDay(); - break; - case 7: - return $this->getDbRepeatType(); - break; - case 8: - return $this->getDbNextPopDate(); - break; - case 9: - return $this->getDbShowId(); - break; - case 10: - return $this->getDbRecord(); - 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 = CcShowDaysPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbFirstShow(), - $keys[2] => $this->getDbLastShow(), - $keys[3] => $this->getDbStartTime(), - $keys[4] => $this->getDbTimezone(), - $keys[5] => $this->getDbDuration(), - $keys[6] => $this->getDbDay(), - $keys[7] => $this->getDbRepeatType(), - $keys[8] => $this->getDbNextPopDate(), - $keys[9] => $this->getDbShowId(), - $keys[10] => $this->getDbRecord(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCcShow) { - $result['CcShow'] = $this->aCcShow->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 = CcShowDaysPeer::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->setDbFirstShow($value); - break; - case 2: - $this->setDbLastShow($value); - break; - case 3: - $this->setDbStartTime($value); - break; - case 4: - $this->setDbTimezone($value); - break; - case 5: - $this->setDbDuration($value); - break; - case 6: - $this->setDbDay($value); - break; - case 7: - $this->setDbRepeatType($value); - break; - case 8: - $this->setDbNextPopDate($value); - break; - case 9: - $this->setDbShowId($value); - break; - case 10: - $this->setDbRecord($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 = CcShowDaysPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbFirstShow($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbLastShow($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbStartTime($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbTimezone($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbDuration($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDbDay($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setDbRepeatType($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setDbNextPopDate($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setDbShowId($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setDbRecord($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(CcShowDaysPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcShowDaysPeer::ID)) $criteria->add(CcShowDaysPeer::ID, $this->id); - if ($this->isColumnModified(CcShowDaysPeer::FIRST_SHOW)) $criteria->add(CcShowDaysPeer::FIRST_SHOW, $this->first_show); - if ($this->isColumnModified(CcShowDaysPeer::LAST_SHOW)) $criteria->add(CcShowDaysPeer::LAST_SHOW, $this->last_show); - if ($this->isColumnModified(CcShowDaysPeer::START_TIME)) $criteria->add(CcShowDaysPeer::START_TIME, $this->start_time); - if ($this->isColumnModified(CcShowDaysPeer::TIMEZONE)) $criteria->add(CcShowDaysPeer::TIMEZONE, $this->timezone); - if ($this->isColumnModified(CcShowDaysPeer::DURATION)) $criteria->add(CcShowDaysPeer::DURATION, $this->duration); - if ($this->isColumnModified(CcShowDaysPeer::DAY)) $criteria->add(CcShowDaysPeer::DAY, $this->day); - if ($this->isColumnModified(CcShowDaysPeer::REPEAT_TYPE)) $criteria->add(CcShowDaysPeer::REPEAT_TYPE, $this->repeat_type); - if ($this->isColumnModified(CcShowDaysPeer::NEXT_POP_DATE)) $criteria->add(CcShowDaysPeer::NEXT_POP_DATE, $this->next_pop_date); - if ($this->isColumnModified(CcShowDaysPeer::SHOW_ID)) $criteria->add(CcShowDaysPeer::SHOW_ID, $this->show_id); - if ($this->isColumnModified(CcShowDaysPeer::RECORD)) $criteria->add(CcShowDaysPeer::RECORD, $this->record); - - 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(CcShowDaysPeer::DATABASE_NAME); - $criteria->add(CcShowDaysPeer::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 CcShowDays (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->setDbFirstShow($this->first_show); - $copyObj->setDbLastShow($this->last_show); - $copyObj->setDbStartTime($this->start_time); - $copyObj->setDbTimezone($this->timezone); - $copyObj->setDbDuration($this->duration); - $copyObj->setDbDay($this->day); - $copyObj->setDbRepeatType($this->repeat_type); - $copyObj->setDbNextPopDate($this->next_pop_date); - $copyObj->setDbShowId($this->show_id); - $copyObj->setDbRecord($this->record); - - $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 CcShowDays 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 CcShowDaysPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcShowDaysPeer(); - } - return self::$peer; - } - - /** - * Declares an association between this object and a CcShow object. - * - * @param CcShow $v - * @return CcShowDays The current object (for fluent API support) - * @throws PropelException - */ - public function setCcShow(CcShow $v = null) - { - if ($v === null) { - $this->setDbShowId(NULL); - } else { - $this->setDbShowId($v->getDbId()); - } - - $this->aCcShow = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcShow object, it will not be re-added. - if ($v !== null) { - $v->addCcShowDays($this); - } - - return $this; - } - - - /** - * Get the associated CcShow object - * - * @param PropelPDO Optional Connection object. - * @return CcShow The associated CcShow object. - * @throws PropelException - */ - public function getCcShow(PropelPDO $con = null) - { - if ($this->aCcShow === null && ($this->show_id !== null)) { - $this->aCcShow = CcShowQuery::create()->findPk($this->show_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->aCcShow->addCcShowDayss($this); - */ - } - return $this->aCcShow; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->first_show = null; - $this->last_show = null; - $this->start_time = null; - $this->timezone = null; - $this->duration = null; - $this->day = null; - $this->repeat_type = null; - $this->next_pop_date = null; - $this->show_id = null; - $this->record = 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->aCcShow = 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); - } - -} // BaseCcShowDays + /** + * Peer class name + */ + const PEER = 'Airtime\\CcShowDaysPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcShowDaysPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the first_show field. + * @var string + */ + protected $first_show; + + /** + * The value for the last_show field. + * @var string + */ + protected $last_show; + + /** + * The value for the start_time field. + * @var string + */ + protected $start_time; + + /** + * The value for the timezone field. + * @var string + */ + protected $timezone; + + /** + * The value for the duration field. + * @var string + */ + protected $duration; + + /** + * The value for the day field. + * @var int + */ + protected $day; + + /** + * The value for the repeat_type field. + * @var int + */ + protected $repeat_type; + + /** + * The value for the next_pop_date field. + * @var string + */ + protected $next_pop_date; + + /** + * The value for the show_id field. + * @var int + */ + protected $show_id; + + /** + * The value for the record field. + * Note: this column has a database default value of: 0 + * @var int + */ + protected $record; + + /** + * @var CcShow + */ + protected $aCcShow; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->record = 0; + } + + /** + * Initializes internal state of BaseCcShowDays 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 [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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + 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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + 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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [timezone] column value. + * + * @return string + */ + public function getDbTimezone() + { + + return $this->timezone; + } + + /** + * Get the [duration] column value. + * + * @return string + */ + public function getDbDuration() + { + + return $this->duration; + } + + /** + * Get the [day] column value. + * + * @return int + */ + public function getDbDay() + { + + return $this->day; + } + + /** + * Get the [repeat_type] column value. + * + * @return int + */ + public function getDbRepeatType() + { + + return $this->repeat_type; + } + + /** + * Get the [optionally formatted] temporal [next_pop_date] 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 getDbNextPopDate($format = '%x') + { + if ($this->next_pop_date === null) { + return null; + } + + + try { + $dt = new DateTime($this->next_pop_date); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->next_pop_date, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [show_id] column value. + * + * @return int + */ + public function getDbShowId() + { + + return $this->show_id; + } + + /** + * Get the [record] column value. + * + * @return int + */ + public function getDbRecord() + { + + return $this->record; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcShowDays The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcShowDaysPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * 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 strings are treated as null. + * @return CcShowDays The current object (for fluent API support) + */ + public function setDbFirstShow($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->first_show !== null || $dt !== null) { + $currentDateAsString = ($this->first_show !== null && $tmpDt = new DateTime($this->first_show)) ? $tmpDt->format('Y-m-d') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->first_show = $newDateAsString; + $this->modifiedColumns[] = CcShowDaysPeer::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 strings are treated as null. + * @return CcShowDays The current object (for fluent API support) + */ + public function setDbLastShow($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->last_show !== null || $dt !== null) { + $currentDateAsString = ($this->last_show !== null && $tmpDt = new DateTime($this->last_show)) ? $tmpDt->format('Y-m-d') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->last_show = $newDateAsString; + $this->modifiedColumns[] = CcShowDaysPeer::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 strings are treated as null. + * @return CcShowDays The current object (for fluent API support) + */ + public function setDbStartTime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->start_time !== null || $dt !== null) { + $currentDateAsString = ($this->start_time !== null && $tmpDt = new DateTime($this->start_time)) ? $tmpDt->format('H:i:s') : null; + $newDateAsString = $dt ? $dt->format('H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->start_time = $newDateAsString; + $this->modifiedColumns[] = CcShowDaysPeer::START_TIME; + } + } // if either are not null + + + return $this; + } // setDbStartTime() + + /** + * Set the value of [timezone] column. + * + * @param string $v new value + * @return CcShowDays The current object (for fluent API support) + */ + public function setDbTimezone($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->timezone !== $v) { + $this->timezone = $v; + $this->modifiedColumns[] = CcShowDaysPeer::TIMEZONE; + } + + + return $this; + } // setDbTimezone() + + /** + * Set the value of [duration] column. + * + * @param string $v new value + * @return CcShowDays The current object (for fluent API support) + */ + public function setDbDuration($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->duration !== $v) { + $this->duration = $v; + $this->modifiedColumns[] = CcShowDaysPeer::DURATION; + } + + + return $this; + } // setDbDuration() + + /** + * Set the value of [day] column. + * + * @param int $v new value + * @return CcShowDays The current object (for fluent API support) + */ + public function setDbDay($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->day !== $v) { + $this->day = $v; + $this->modifiedColumns[] = CcShowDaysPeer::DAY; + } + + + return $this; + } // setDbDay() + + /** + * Set the value of [repeat_type] column. + * + * @param int $v new value + * @return CcShowDays The current object (for fluent API support) + */ + public function setDbRepeatType($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->repeat_type !== $v) { + $this->repeat_type = $v; + $this->modifiedColumns[] = CcShowDaysPeer::REPEAT_TYPE; + } + + + return $this; + } // setDbRepeatType() + + /** + * Sets the value of [next_pop_date] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return CcShowDays The current object (for fluent API support) + */ + public function setDbNextPopDate($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->next_pop_date !== null || $dt !== null) { + $currentDateAsString = ($this->next_pop_date !== null && $tmpDt = new DateTime($this->next_pop_date)) ? $tmpDt->format('Y-m-d') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->next_pop_date = $newDateAsString; + $this->modifiedColumns[] = CcShowDaysPeer::NEXT_POP_DATE; + } + } // if either are not null + + + return $this; + } // setDbNextPopDate() + + /** + * Set the value of [show_id] column. + * + * @param int $v new value + * @return CcShowDays The current object (for fluent API support) + */ + public function setDbShowId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->show_id !== $v) { + $this->show_id = $v; + $this->modifiedColumns[] = CcShowDaysPeer::SHOW_ID; + } + + if ($this->aCcShow !== null && $this->aCcShow->getDbId() !== $v) { + $this->aCcShow = null; + } + + + return $this; + } // setDbShowId() + + /** + * Set the value of [record] column. + * + * @param int $v new value + * @return CcShowDays The current object (for fluent API support) + */ + public function setDbRecord($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->record !== $v) { + $this->record = $v; + $this->modifiedColumns[] = CcShowDaysPeer::RECORD; + } + + + return $this; + } // setDbRecord() + + /** + * 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->record !== 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 resultset 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->first_show = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->last_show = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->start_time = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->timezone = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->duration = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->day = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; + $this->repeat_type = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null; + $this->next_pop_date = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->show_id = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null; + $this->record = ($row[$startcol + 10] !== null) ? (int) $row[$startcol + 10] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 11; // 11 = CcShowDaysPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcShowDays 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->aCcShow !== null && $this->show_id !== $this->aCcShow->getDbId()) { + $this->aCcShow = 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(CcShowDaysPeer::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 = CcShowDaysPeer::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->aCcShow = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcShowDaysQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcShowDaysPeer::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); + CcShowDaysPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcShow !== null) { + if ($this->aCcShow->isModified() || $this->aCcShow->isNew()) { + $affectedRows += $this->aCcShow->save($con); + } + $this->setCcShow($this->aCcShow); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcShowDaysPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcShowDaysPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_show_days_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcShowDaysPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcShowDaysPeer::FIRST_SHOW)) { + $modifiedColumns[':p' . $index++] = '"first_show"'; + } + if ($this->isColumnModified(CcShowDaysPeer::LAST_SHOW)) { + $modifiedColumns[':p' . $index++] = '"last_show"'; + } + if ($this->isColumnModified(CcShowDaysPeer::START_TIME)) { + $modifiedColumns[':p' . $index++] = '"start_time"'; + } + if ($this->isColumnModified(CcShowDaysPeer::TIMEZONE)) { + $modifiedColumns[':p' . $index++] = '"timezone"'; + } + if ($this->isColumnModified(CcShowDaysPeer::DURATION)) { + $modifiedColumns[':p' . $index++] = '"duration"'; + } + if ($this->isColumnModified(CcShowDaysPeer::DAY)) { + $modifiedColumns[':p' . $index++] = '"day"'; + } + if ($this->isColumnModified(CcShowDaysPeer::REPEAT_TYPE)) { + $modifiedColumns[':p' . $index++] = '"repeat_type"'; + } + if ($this->isColumnModified(CcShowDaysPeer::NEXT_POP_DATE)) { + $modifiedColumns[':p' . $index++] = '"next_pop_date"'; + } + if ($this->isColumnModified(CcShowDaysPeer::SHOW_ID)) { + $modifiedColumns[':p' . $index++] = '"show_id"'; + } + if ($this->isColumnModified(CcShowDaysPeer::RECORD)) { + $modifiedColumns[':p' . $index++] = '"record"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_show_days" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"first_show"': + $stmt->bindValue($identifier, $this->first_show, PDO::PARAM_STR); + break; + case '"last_show"': + $stmt->bindValue($identifier, $this->last_show, PDO::PARAM_STR); + break; + case '"start_time"': + $stmt->bindValue($identifier, $this->start_time, PDO::PARAM_STR); + break; + case '"timezone"': + $stmt->bindValue($identifier, $this->timezone, PDO::PARAM_STR); + break; + case '"duration"': + $stmt->bindValue($identifier, $this->duration, PDO::PARAM_STR); + break; + case '"day"': + $stmt->bindValue($identifier, $this->day, PDO::PARAM_INT); + break; + case '"repeat_type"': + $stmt->bindValue($identifier, $this->repeat_type, PDO::PARAM_INT); + break; + case '"next_pop_date"': + $stmt->bindValue($identifier, $this->next_pop_date, PDO::PARAM_STR); + break; + case '"show_id"': + $stmt->bindValue($identifier, $this->show_id, PDO::PARAM_INT); + break; + case '"record"': + $stmt->bindValue($identifier, $this->record, PDO::PARAM_INT); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcShow !== null) { + if (!$this->aCcShow->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcShow->getValidationFailures()); + } + } + + + if (($retval = CcShowDaysPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcShowDaysPeer::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->getDbFirstShow(); + break; + case 2: + return $this->getDbLastShow(); + break; + case 3: + return $this->getDbStartTime(); + break; + case 4: + return $this->getDbTimezone(); + break; + case 5: + return $this->getDbDuration(); + break; + case 6: + return $this->getDbDay(); + break; + case 7: + return $this->getDbRepeatType(); + break; + case 8: + return $this->getDbNextPopDate(); + break; + case 9: + return $this->getDbShowId(); + break; + case 10: + return $this->getDbRecord(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcShowDays'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcShowDays'][$this->getPrimaryKey()] = true; + $keys = CcShowDaysPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbFirstShow(), + $keys[2] => $this->getDbLastShow(), + $keys[3] => $this->getDbStartTime(), + $keys[4] => $this->getDbTimezone(), + $keys[5] => $this->getDbDuration(), + $keys[6] => $this->getDbDay(), + $keys[7] => $this->getDbRepeatType(), + $keys[8] => $this->getDbNextPopDate(), + $keys[9] => $this->getDbShowId(), + $keys[10] => $this->getDbRecord(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcShow) { + $result['CcShow'] = $this->aCcShow->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcShowDaysPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbFirstShow($value); + break; + case 2: + $this->setDbLastShow($value); + break; + case 3: + $this->setDbStartTime($value); + break; + case 4: + $this->setDbTimezone($value); + break; + case 5: + $this->setDbDuration($value); + break; + case 6: + $this->setDbDay($value); + break; + case 7: + $this->setDbRepeatType($value); + break; + case 8: + $this->setDbNextPopDate($value); + break; + case 9: + $this->setDbShowId($value); + break; + case 10: + $this->setDbRecord($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcShowDaysPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbFirstShow($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbLastShow($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbStartTime($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbTimezone($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbDuration($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbDay($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbRepeatType($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setDbNextPopDate($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDbShowId($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setDbRecord($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(CcShowDaysPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcShowDaysPeer::ID)) $criteria->add(CcShowDaysPeer::ID, $this->id); + if ($this->isColumnModified(CcShowDaysPeer::FIRST_SHOW)) $criteria->add(CcShowDaysPeer::FIRST_SHOW, $this->first_show); + if ($this->isColumnModified(CcShowDaysPeer::LAST_SHOW)) $criteria->add(CcShowDaysPeer::LAST_SHOW, $this->last_show); + if ($this->isColumnModified(CcShowDaysPeer::START_TIME)) $criteria->add(CcShowDaysPeer::START_TIME, $this->start_time); + if ($this->isColumnModified(CcShowDaysPeer::TIMEZONE)) $criteria->add(CcShowDaysPeer::TIMEZONE, $this->timezone); + if ($this->isColumnModified(CcShowDaysPeer::DURATION)) $criteria->add(CcShowDaysPeer::DURATION, $this->duration); + if ($this->isColumnModified(CcShowDaysPeer::DAY)) $criteria->add(CcShowDaysPeer::DAY, $this->day); + if ($this->isColumnModified(CcShowDaysPeer::REPEAT_TYPE)) $criteria->add(CcShowDaysPeer::REPEAT_TYPE, $this->repeat_type); + if ($this->isColumnModified(CcShowDaysPeer::NEXT_POP_DATE)) $criteria->add(CcShowDaysPeer::NEXT_POP_DATE, $this->next_pop_date); + if ($this->isColumnModified(CcShowDaysPeer::SHOW_ID)) $criteria->add(CcShowDaysPeer::SHOW_ID, $this->show_id); + if ($this->isColumnModified(CcShowDaysPeer::RECORD)) $criteria->add(CcShowDaysPeer::RECORD, $this->record); + + 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(CcShowDaysPeer::DATABASE_NAME); + $criteria->add(CcShowDaysPeer::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 CcShowDays (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbFirstShow($this->getDbFirstShow()); + $copyObj->setDbLastShow($this->getDbLastShow()); + $copyObj->setDbStartTime($this->getDbStartTime()); + $copyObj->setDbTimezone($this->getDbTimezone()); + $copyObj->setDbDuration($this->getDbDuration()); + $copyObj->setDbDay($this->getDbDay()); + $copyObj->setDbRepeatType($this->getDbRepeatType()); + $copyObj->setDbNextPopDate($this->getDbNextPopDate()); + $copyObj->setDbShowId($this->getDbShowId()); + $copyObj->setDbRecord($this->getDbRecord()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcShowDays 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 CcShowDaysPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcShowDaysPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a CcShow object. + * + * @param CcShow $v + * @return CcShowDays The current object (for fluent API support) + * @throws PropelException + */ + public function setCcShow(CcShow $v = null) + { + if ($v === null) { + $this->setDbShowId(NULL); + } else { + $this->setDbShowId($v->getDbId()); + } + + $this->aCcShow = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcShow object, it will not be re-added. + if ($v !== null) { + $v->addCcShowDays($this); + } + + + return $this; + } + + + /** + * Get the associated CcShow object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcShow The associated CcShow object. + * @throws PropelException + */ + public function getCcShow(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcShow === null && ($this->show_id !== null) && $doQuery) { + $this->aCcShow = CcShowQuery::create()->findPk($this->show_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->aCcShow->addCcShowDayss($this); + */ + } + + return $this->aCcShow; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->first_show = null; + $this->last_show = null; + $this->start_time = null; + $this->timezone = null; + $this->duration = null; + $this->day = null; + $this->repeat_type = null; + $this->next_pop_date = null; + $this->show_id = null; + $this->record = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCcShow instanceof Persistent) { + $this->aCcShow->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + $this->aCcShow = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcShowDaysPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowDaysPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcShowDaysPeer.php index df6b9081d..84e109f8f 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowDaysPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowDaysPeer.php @@ -1,1014 +1,1053 @@ array ('DbId', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbTimezone', 'DbDuration', 'DbDay', 'DbRepeatType', 'DbNextPopDate', 'DbShowId', 'DbRecord', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbTimezone', 'dbDuration', 'dbDay', 'dbRepeatType', 'dbNextPopDate', 'dbShowId', 'dbRecord', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::FIRST_SHOW, self::LAST_SHOW, self::START_TIME, self::TIMEZONE, self::DURATION, self::DAY, self::REPEAT_TYPE, self::NEXT_POP_DATE, self::SHOW_ID, self::RECORD, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'TIMEZONE', 'DURATION', 'DAY', 'REPEAT_TYPE', 'NEXT_POP_DATE', 'SHOW_ID', 'RECORD', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'first_show', 'last_show', 'start_time', 'timezone', 'duration', 'day', 'repeat_type', 'next_pop_date', 'show_id', 'record', ), - 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 ('DbId' => 0, 'DbFirstShow' => 1, 'DbLastShow' => 2, 'DbStartTime' => 3, 'DbTimezone' => 4, 'DbDuration' => 5, 'DbDay' => 6, 'DbRepeatType' => 7, 'DbNextPopDate' => 8, 'DbShowId' => 9, 'DbRecord' => 10, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbFirstShow' => 1, 'dbLastShow' => 2, 'dbStartTime' => 3, 'dbTimezone' => 4, 'dbDuration' => 5, 'dbDay' => 6, 'dbRepeatType' => 7, 'dbNextPopDate' => 8, 'dbShowId' => 9, 'dbRecord' => 10, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::FIRST_SHOW => 1, self::LAST_SHOW => 2, self::START_TIME => 3, self::TIMEZONE => 4, self::DURATION => 5, self::DAY => 6, self::REPEAT_TYPE => 7, self::NEXT_POP_DATE => 8, self::SHOW_ID => 9, self::RECORD => 10, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FIRST_SHOW' => 1, 'LAST_SHOW' => 2, 'START_TIME' => 3, 'TIMEZONE' => 4, 'DURATION' => 5, 'DAY' => 6, 'REPEAT_TYPE' => 7, 'NEXT_POP_DATE' => 8, 'SHOW_ID' => 9, 'RECORD' => 10, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'first_show' => 1, 'last_show' => 2, 'start_time' => 3, 'timezone' => 4, 'duration' => 5, 'day' => 6, 'repeat_type' => 7, 'next_pop_date' => 8, 'show_id' => 9, 'record' => 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. CcShowDaysPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcShowDaysPeer::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(CcShowDaysPeer::ID); - $criteria->addSelectColumn(CcShowDaysPeer::FIRST_SHOW); - $criteria->addSelectColumn(CcShowDaysPeer::LAST_SHOW); - $criteria->addSelectColumn(CcShowDaysPeer::START_TIME); - $criteria->addSelectColumn(CcShowDaysPeer::TIMEZONE); - $criteria->addSelectColumn(CcShowDaysPeer::DURATION); - $criteria->addSelectColumn(CcShowDaysPeer::DAY); - $criteria->addSelectColumn(CcShowDaysPeer::REPEAT_TYPE); - $criteria->addSelectColumn(CcShowDaysPeer::NEXT_POP_DATE); - $criteria->addSelectColumn(CcShowDaysPeer::SHOW_ID); - $criteria->addSelectColumn(CcShowDaysPeer::RECORD); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.FIRST_SHOW'); - $criteria->addSelectColumn($alias . '.LAST_SHOW'); - $criteria->addSelectColumn($alias . '.START_TIME'); - $criteria->addSelectColumn($alias . '.TIMEZONE'); - $criteria->addSelectColumn($alias . '.DURATION'); - $criteria->addSelectColumn($alias . '.DAY'); - $criteria->addSelectColumn($alias . '.REPEAT_TYPE'); - $criteria->addSelectColumn($alias . '.NEXT_POP_DATE'); - $criteria->addSelectColumn($alias . '.SHOW_ID'); - $criteria->addSelectColumn($alias . '.RECORD'); - } - } - - /** - * 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(CcShowDaysPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowDaysPeer::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(CcShowDaysPeer::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 CcShowDays - * @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 = CcShowDaysPeer::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 CcShowDaysPeer::populateObjects(CcShowDaysPeer::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(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcShowDaysPeer::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 CcShowDays $value A CcShowDays object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcShowDays $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 CcShowDays object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcShowDays) { - $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 CcShowDays 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 CcShowDays 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_days - * 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 = CcShowDaysPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcShowDaysPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcShowDaysPeer::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; - CcShowDaysPeer::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 (CcShowDays object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcShowDaysPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcShowDaysPeer::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 + CcShowDaysPeer::NUM_COLUMNS; - } else { - $cls = CcShowDaysPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcShowDaysPeer::addInstanceToPool($obj, $key); - } - return array($obj, $col); - } - - /** - * Returns the number of rows matching criteria, joining the related CcShow 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 doCountJoinCcShow(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(CcShowDaysPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowDaysPeer::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(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcShowDaysPeer::SHOW_ID, CcShowPeer::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 CcShowDays objects pre-filled with their CcShow 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 CcShowDays objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCcShow(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); - } - - CcShowDaysPeer::addSelectColumns($criteria); - $startcol = (CcShowDaysPeer::NUM_COLUMNS - CcShowDaysPeer::NUM_LAZY_LOAD_COLUMNS); - CcShowPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcShowDaysPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcShowDaysPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcShowDaysPeer::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 = CcShowDaysPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcShowDaysPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcShowPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcShowPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcShowDays) to $obj2 (CcShow) - $obj2->addCcShowDays($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(CcShowDaysPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowDaysPeer::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(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcShowDaysPeer::SHOW_ID, CcShowPeer::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 CcShowDays 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 CcShowDays 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); - } - - CcShowDaysPeer::addSelectColumns($criteria); - $startcol2 = (CcShowDaysPeer::NUM_COLUMNS - CcShowDaysPeer::NUM_LAZY_LOAD_COLUMNS); - - CcShowPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcShowDaysPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcShowDaysPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcShowDaysPeer::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 = CcShowDaysPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcShowDaysPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcShow rows - - $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcShowPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcShowPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (CcShowDays) to the collection in $obj2 (CcShow) - $obj2->addCcShowDays($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(BaseCcShowDaysPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcShowDaysPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcShowDaysTableMap()); - } - } - - /** - * 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 ? CcShowDaysPeer::CLASS_DEFAULT : CcShowDaysPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcShowDays or Criteria object. - * - * @param mixed $values Criteria or CcShowDays 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(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcShowDays object - } - - if ($criteria->containsKey(CcShowDaysPeer::ID) && $criteria->keyContainsValue(CcShowDaysPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowDaysPeer::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 CcShowDays or Criteria object. - * - * @param mixed $values Criteria or CcShowDays 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(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcShowDaysPeer::ID); - $value = $criteria->remove(CcShowDaysPeer::ID); - if ($value) { - $selectCriteria->add(CcShowDaysPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcShowDaysPeer::TABLE_NAME); - } - - } else { // $values is CcShowDays 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_days 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(CcShowDaysPeer::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(CcShowDaysPeer::TABLE_NAME, $con, CcShowDaysPeer::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). - CcShowDaysPeer::clearInstancePool(); - CcShowDaysPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcShowDays or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcShowDays 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(CcShowDaysPeer::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. - CcShowDaysPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcShowDays) { // it's a model object - // invalidate the cache for this single object - CcShowDaysPeer::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(CcShowDaysPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcShowDaysPeer::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); - CcShowDaysPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcShowDays 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 CcShowDays $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(CcShowDays $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcShowDaysPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcShowDaysPeer::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(CcShowDaysPeer::DATABASE_NAME, CcShowDaysPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcShowDays - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcShowDaysPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcShowDaysPeer::DATABASE_NAME); - $criteria->add(CcShowDaysPeer::ID, $pk); - - $v = CcShowDaysPeer::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(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcShowDaysPeer::DATABASE_NAME); - $criteria->add(CcShowDaysPeer::ID, $pks, Criteria::IN); - $objs = CcShowDaysPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcShowDaysPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_show_days'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcShowDays'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcShowDaysTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 11; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 11; + + /** the column name for the id field */ + const ID = 'cc_show_days.id'; + + /** the column name for the first_show field */ + const FIRST_SHOW = 'cc_show_days.first_show'; + + /** the column name for the last_show field */ + const LAST_SHOW = 'cc_show_days.last_show'; + + /** the column name for the start_time field */ + const START_TIME = 'cc_show_days.start_time'; + + /** the column name for the timezone field */ + const TIMEZONE = 'cc_show_days.timezone'; + + /** the column name for the duration field */ + const DURATION = 'cc_show_days.duration'; + + /** the column name for the day field */ + const DAY = 'cc_show_days.day'; + + /** the column name for the repeat_type field */ + const REPEAT_TYPE = 'cc_show_days.repeat_type'; + + /** the column name for the next_pop_date field */ + const NEXT_POP_DATE = 'cc_show_days.next_pop_date'; + + /** the column name for the show_id field */ + const SHOW_ID = 'cc_show_days.show_id'; + + /** the column name for the record field */ + const RECORD = 'cc_show_days.record'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcShowDays objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcShowDays[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcShowDaysPeer::$fieldNames[CcShowDaysPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbTimezone', 'DbDuration', 'DbDay', 'DbRepeatType', 'DbNextPopDate', 'DbShowId', 'DbRecord', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbTimezone', 'dbDuration', 'dbDay', 'dbRepeatType', 'dbNextPopDate', 'dbShowId', 'dbRecord', ), + BasePeer::TYPE_COLNAME => array (CcShowDaysPeer::ID, CcShowDaysPeer::FIRST_SHOW, CcShowDaysPeer::LAST_SHOW, CcShowDaysPeer::START_TIME, CcShowDaysPeer::TIMEZONE, CcShowDaysPeer::DURATION, CcShowDaysPeer::DAY, CcShowDaysPeer::REPEAT_TYPE, CcShowDaysPeer::NEXT_POP_DATE, CcShowDaysPeer::SHOW_ID, CcShowDaysPeer::RECORD, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'TIMEZONE', 'DURATION', 'DAY', 'REPEAT_TYPE', 'NEXT_POP_DATE', 'SHOW_ID', 'RECORD', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'first_show', 'last_show', 'start_time', 'timezone', 'duration', 'day', 'repeat_type', 'next_pop_date', 'show_id', 'record', ), + 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. CcShowDaysPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbFirstShow' => 1, 'DbLastShow' => 2, 'DbStartTime' => 3, 'DbTimezone' => 4, 'DbDuration' => 5, 'DbDay' => 6, 'DbRepeatType' => 7, 'DbNextPopDate' => 8, 'DbShowId' => 9, 'DbRecord' => 10, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbFirstShow' => 1, 'dbLastShow' => 2, 'dbStartTime' => 3, 'dbTimezone' => 4, 'dbDuration' => 5, 'dbDay' => 6, 'dbRepeatType' => 7, 'dbNextPopDate' => 8, 'dbShowId' => 9, 'dbRecord' => 10, ), + BasePeer::TYPE_COLNAME => array (CcShowDaysPeer::ID => 0, CcShowDaysPeer::FIRST_SHOW => 1, CcShowDaysPeer::LAST_SHOW => 2, CcShowDaysPeer::START_TIME => 3, CcShowDaysPeer::TIMEZONE => 4, CcShowDaysPeer::DURATION => 5, CcShowDaysPeer::DAY => 6, CcShowDaysPeer::REPEAT_TYPE => 7, CcShowDaysPeer::NEXT_POP_DATE => 8, CcShowDaysPeer::SHOW_ID => 9, CcShowDaysPeer::RECORD => 10, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FIRST_SHOW' => 1, 'LAST_SHOW' => 2, 'START_TIME' => 3, 'TIMEZONE' => 4, 'DURATION' => 5, 'DAY' => 6, 'REPEAT_TYPE' => 7, 'NEXT_POP_DATE' => 8, 'SHOW_ID' => 9, 'RECORD' => 10, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'first_show' => 1, 'last_show' => 2, 'start_time' => 3, 'timezone' => 4, 'duration' => 5, 'day' => 6, 'repeat_type' => 7, 'next_pop_date' => 8, 'show_id' => 9, 'record' => 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcShowDaysPeer::getFieldNames($toType); + $key = isset(CcShowDaysPeer::$fieldKeys[$fromType][$name]) ? CcShowDaysPeer::$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(CcShowDaysPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcShowDaysPeer::$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 CcShowDaysPeer::$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. CcShowDaysPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcShowDaysPeer::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(CcShowDaysPeer::ID); + $criteria->addSelectColumn(CcShowDaysPeer::FIRST_SHOW); + $criteria->addSelectColumn(CcShowDaysPeer::LAST_SHOW); + $criteria->addSelectColumn(CcShowDaysPeer::START_TIME); + $criteria->addSelectColumn(CcShowDaysPeer::TIMEZONE); + $criteria->addSelectColumn(CcShowDaysPeer::DURATION); + $criteria->addSelectColumn(CcShowDaysPeer::DAY); + $criteria->addSelectColumn(CcShowDaysPeer::REPEAT_TYPE); + $criteria->addSelectColumn(CcShowDaysPeer::NEXT_POP_DATE); + $criteria->addSelectColumn(CcShowDaysPeer::SHOW_ID); + $criteria->addSelectColumn(CcShowDaysPeer::RECORD); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.first_show'); + $criteria->addSelectColumn($alias . '.last_show'); + $criteria->addSelectColumn($alias . '.start_time'); + $criteria->addSelectColumn($alias . '.timezone'); + $criteria->addSelectColumn($alias . '.duration'); + $criteria->addSelectColumn($alias . '.day'); + $criteria->addSelectColumn($alias . '.repeat_type'); + $criteria->addSelectColumn($alias . '.next_pop_date'); + $criteria->addSelectColumn($alias . '.show_id'); + $criteria->addSelectColumn($alias . '.record'); + } + } + + /** + * 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(CcShowDaysPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowDaysPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcShowDaysPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcShowDaysPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcShowDays + * @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 = CcShowDaysPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcShowDaysPeer::populateObjects(CcShowDaysPeer::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 directly (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(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcShowDaysPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcShowDaysPeer::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 CcShowDays $obj A CcShowDays object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcShowDaysPeer::$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 CcShowDays object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcShowDays) { + $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 CcShowDays object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcShowDaysPeer::$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 CcShowDays 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(CcShowDaysPeer::$instances[$key])) { + return CcShowDaysPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcShowDaysPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcShowDaysPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_show_days + * 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 = CcShowDaysPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcShowDaysPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcShowDaysPeer::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; + CcShowDaysPeer::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 (CcShowDays object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcShowDaysPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcShowDaysPeer::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 + CcShowDaysPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcShowDaysPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcShowDaysPeer::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + + /** + * Returns the number of rows matching criteria, joining the related CcShow 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 doCountJoinCcShow(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(CcShowDaysPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowDaysPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcShowDaysPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowDaysPeer::SHOW_ID, CcShowPeer::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 CcShowDays objects pre-filled with their CcShow 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 CcShowDays objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcShow(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(CcShowDaysPeer::DATABASE_NAME); + } + + CcShowDaysPeer::addSelectColumns($criteria); + $startcol = CcShowDaysPeer::NUM_HYDRATE_COLUMNS; + CcShowPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcShowDaysPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowDaysPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowDaysPeer::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 = CcShowDaysPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowDaysPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcShowPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcShowPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcShowDays) to $obj2 (CcShow) + $obj2->addCcShowDays($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(CcShowDaysPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowDaysPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcShowDaysPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowDaysPeer::SHOW_ID, CcShowPeer::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 CcShowDays 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 CcShowDays 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(CcShowDaysPeer::DATABASE_NAME); + } + + CcShowDaysPeer::addSelectColumns($criteria); + $startcol2 = CcShowDaysPeer::NUM_HYDRATE_COLUMNS; + + CcShowPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcShowPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcShowDaysPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowDaysPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowDaysPeer::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 = CcShowDaysPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowDaysPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcShow rows + + $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcShowPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcShowPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcShowDays) to the collection in $obj2 (CcShow) + $obj2->addCcShowDays($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(CcShowDaysPeer::DATABASE_NAME)->getTable(CcShowDaysPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcShowDaysPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcShowDaysPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcShowDaysTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcShowDaysPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcShowDays or Criteria object. + * + * @param mixed $values Criteria or CcShowDays 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(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcShowDays object + } + + if ($criteria->containsKey(CcShowDaysPeer::ID) && $criteria->keyContainsValue(CcShowDaysPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowDaysPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcShowDaysPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcShowDays or Criteria object. + * + * @param mixed $values Criteria or CcShowDays 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(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcShowDaysPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcShowDaysPeer::ID); + $value = $criteria->remove(CcShowDaysPeer::ID); + if ($value) { + $selectCriteria->add(CcShowDaysPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcShowDaysPeer::TABLE_NAME); + } + + } else { // $values is CcShowDays object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcShowDaysPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_show_days table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcShowDaysPeer::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(CcShowDaysPeer::TABLE_NAME, $con, CcShowDaysPeer::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). + CcShowDaysPeer::clearInstancePool(); + CcShowDaysPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcShowDays or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcShowDays 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(CcShowDaysPeer::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. + CcShowDaysPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcShowDays) { // it's a model object + // invalidate the cache for this single object + CcShowDaysPeer::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(CcShowDaysPeer::DATABASE_NAME); + $criteria->add(CcShowDaysPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcShowDaysPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcShowDaysPeer::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); + CcShowDaysPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcShowDays 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 CcShowDays $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcShowDaysPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcShowDaysPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcShowDaysPeer::DATABASE_NAME, CcShowDaysPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcShowDays + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcShowDaysPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcShowDaysPeer::DATABASE_NAME); + $criteria->add(CcShowDaysPeer::ID, $pk); + + $v = CcShowDaysPeer::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 + * @return CcShowDays[] + * @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(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcShowDaysPeer::DATABASE_NAME); + $criteria->add(CcShowDaysPeer::ID, $pks, Criteria::IN); + $objs = CcShowDaysPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcShowDaysPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowDaysQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcShowDaysQuery.php index 18653bd70..555ac7cad 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowDaysQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowDaysQuery.php @@ -1,565 +1,812 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcShowDays|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcShowDaysPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcShowDays|CcShowDays[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcShowDaysPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcShowDaysPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcShowDaysQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcShowDaysPeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcShowDays A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcShowDaysQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcShowDaysPeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcShowDays A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "first_show", "last_show", "start_time", "timezone", "duration", "day", "repeat_type", "next_pop_date", "show_id", "record" FROM "cc_show_days" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcShowDays(); + $obj->hydrate($row); + CcShowDaysPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcShowDaysQuery 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(CcShowDaysPeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * 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 CcShowDaysQuery 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(CcShowDaysPeer::FIRST_SHOW, $dbFirstShow['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbFirstShow['max'])) { - $this->addUsingAlias(CcShowDaysPeer::FIRST_SHOW, $dbFirstShow['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowDaysPeer::FIRST_SHOW, $dbFirstShow, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcShowDays|CcShowDays[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * 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 CcShowDaysQuery 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(CcShowDaysPeer::LAST_SHOW, $dbLastShow['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbLastShow['max'])) { - $this->addUsingAlias(CcShowDaysPeer::LAST_SHOW, $dbLastShow['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowDaysPeer::LAST_SHOW, $dbLastShow, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * 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 CcShowDaysQuery 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(CcShowDaysPeer::START_TIME, $dbStartTime['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbStartTime['max'])) { - $this->addUsingAlias(CcShowDaysPeer::START_TIME, $dbStartTime['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowDaysPeer::START_TIME, $dbStartTime, $comparison); - } + /** + * 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|CcShowDays[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query on the timezone column - * - * @param string $dbTimezone 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 CcShowDaysQuery The current query, for fluid interface - */ - public function filterByDbTimezone($dbTimezone = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbTimezone)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbTimezone)) { - $dbTimezone = str_replace('*', '%', $dbTimezone); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcShowDaysPeer::TIMEZONE, $dbTimezone, $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Filter the query on the duration column - * - * @param string $dbDuration 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 CcShowDaysQuery The current query, for fluid interface - */ - public function filterByDbDuration($dbDuration = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbDuration)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbDuration)) { - $dbDuration = str_replace('*', '%', $dbDuration); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcShowDaysPeer::DURATION, $dbDuration, $comparison); - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcShowDaysQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { - /** - * 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 CcShowDaysQuery 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(CcShowDaysPeer::DAY, $dbDay['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbDay['max'])) { - $this->addUsingAlias(CcShowDaysPeer::DAY, $dbDay['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowDaysPeer::DAY, $dbDay, $comparison); - } + return $this->addUsingAlias(CcShowDaysPeer::ID, $key, Criteria::EQUAL); + } - /** - * Filter the query on the repeat_type column - * - * @param int|array $dbRepeatType 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 CcShowDaysQuery The current query, for fluid interface - */ - public function filterByDbRepeatType($dbRepeatType = null, $comparison = null) - { - if (is_array($dbRepeatType)) { - $useMinMax = false; - if (isset($dbRepeatType['min'])) { - $this->addUsingAlias(CcShowDaysPeer::REPEAT_TYPE, $dbRepeatType['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbRepeatType['max'])) { - $this->addUsingAlias(CcShowDaysPeer::REPEAT_TYPE, $dbRepeatType['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowDaysPeer::REPEAT_TYPE, $dbRepeatType, $comparison); - } + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return CcShowDaysQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { - /** - * Filter the query on the next_pop_date column - * - * @param string|array $dbNextPopDate 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 CcShowDaysQuery The current query, for fluid interface - */ - public function filterByDbNextPopDate($dbNextPopDate = null, $comparison = null) - { - if (is_array($dbNextPopDate)) { - $useMinMax = false; - if (isset($dbNextPopDate['min'])) { - $this->addUsingAlias(CcShowDaysPeer::NEXT_POP_DATE, $dbNextPopDate['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbNextPopDate['max'])) { - $this->addUsingAlias(CcShowDaysPeer::NEXT_POP_DATE, $dbNextPopDate['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowDaysPeer::NEXT_POP_DATE, $dbNextPopDate, $comparison); - } + return $this->addUsingAlias(CcShowDaysPeer::ID, $keys, Criteria::IN); + } - /** - * Filter the query on the show_id column - * - * @param int|array $dbShowId 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 CcShowDaysQuery The current query, for fluid interface - */ - public function filterByDbShowId($dbShowId = null, $comparison = null) - { - if (is_array($dbShowId)) { - $useMinMax = false; - if (isset($dbShowId['min'])) { - $this->addUsingAlias(CcShowDaysPeer::SHOW_ID, $dbShowId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbShowId['max'])) { - $this->addUsingAlias(CcShowDaysPeer::SHOW_ID, $dbShowId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowDaysPeer::SHOW_ID, $dbShowId, $comparison); - } + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowDaysQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcShowDaysPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcShowDaysPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Filter the query on the record column - * - * @param int|array $dbRecord 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 CcShowDaysQuery The current query, for fluid interface - */ - public function filterByDbRecord($dbRecord = null, $comparison = null) - { - if (is_array($dbRecord)) { - $useMinMax = false; - if (isset($dbRecord['min'])) { - $this->addUsingAlias(CcShowDaysPeer::RECORD, $dbRecord['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbRecord['max'])) { - $this->addUsingAlias(CcShowDaysPeer::RECORD, $dbRecord['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowDaysPeer::RECORD, $dbRecord, $comparison); - } + return $this->addUsingAlias(CcShowDaysPeer::ID, $dbId, $comparison); + } - /** - * Filter the query by a related CcShow object - * - * @param CcShow $ccShow the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowDaysQuery The current query, for fluid interface - */ - public function filterByCcShow($ccShow, $comparison = null) - { - return $this - ->addUsingAlias(CcShowDaysPeer::SHOW_ID, $ccShow->getDbId(), $comparison); - } + /** + * Filter the query on the first_show column + * + * Example usage: + * + * $query->filterByDbFirstShow('2011-03-14'); // WHERE first_show = '2011-03-14' + * $query->filterByDbFirstShow('now'); // WHERE first_show = '2011-03-14' + * $query->filterByDbFirstShow(array('max' => 'yesterday')); // WHERE first_show < '2011-03-13' + * + * + * @param mixed $dbFirstShow The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowDaysQuery 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(CcShowDaysPeer::FIRST_SHOW, $dbFirstShow['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbFirstShow['max'])) { + $this->addUsingAlias(CcShowDaysPeer::FIRST_SHOW, $dbFirstShow['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Adds a JOIN clause to the query using the CcShow relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcShowDaysQuery The current query, for fluid interface - */ - public function joinCcShow($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcShow'); - - // 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, 'CcShow'); - } - - return $this; - } + return $this->addUsingAlias(CcShowDaysPeer::FIRST_SHOW, $dbFirstShow, $comparison); + } - /** - * Use the CcShow relation CcShow 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 CcShowQuery A secondary query class using the current class as primary query - */ - public function useCcShowQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcShow($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcShow', 'CcShowQuery'); - } + /** + * Filter the query on the last_show column + * + * Example usage: + * + * $query->filterByDbLastShow('2011-03-14'); // WHERE last_show = '2011-03-14' + * $query->filterByDbLastShow('now'); // WHERE last_show = '2011-03-14' + * $query->filterByDbLastShow(array('max' => 'yesterday')); // WHERE last_show < '2011-03-13' + * + * + * @param mixed $dbLastShow The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowDaysQuery 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(CcShowDaysPeer::LAST_SHOW, $dbLastShow['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbLastShow['max'])) { + $this->addUsingAlias(CcShowDaysPeer::LAST_SHOW, $dbLastShow['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Exclude object from result - * - * @param CcShowDays $ccShowDays Object to remove from the list of results - * - * @return CcShowDaysQuery The current query, for fluid interface - */ - public function prune($ccShowDays = null) - { - if ($ccShowDays) { - $this->addUsingAlias(CcShowDaysPeer::ID, $ccShowDays->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + return $this->addUsingAlias(CcShowDaysPeer::LAST_SHOW, $dbLastShow, $comparison); + } -} // BaseCcShowDaysQuery + /** + * Filter the query on the start_time column + * + * Example usage: + * + * $query->filterByDbStartTime('2011-03-14'); // WHERE start_time = '2011-03-14' + * $query->filterByDbStartTime('now'); // WHERE start_time = '2011-03-14' + * $query->filterByDbStartTime(array('max' => 'yesterday')); // WHERE start_time < '2011-03-13' + * + * + * @param mixed $dbStartTime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowDaysQuery 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(CcShowDaysPeer::START_TIME, $dbStartTime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbStartTime['max'])) { + $this->addUsingAlias(CcShowDaysPeer::START_TIME, $dbStartTime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcShowDaysPeer::START_TIME, $dbStartTime, $comparison); + } + + /** + * Filter the query on the timezone column + * + * Example usage: + * + * $query->filterByDbTimezone('fooValue'); // WHERE timezone = 'fooValue' + * $query->filterByDbTimezone('%fooValue%'); // WHERE timezone LIKE '%fooValue%' + * + * + * @param string $dbTimezone 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 CcShowDaysQuery The current query, for fluid interface + */ + public function filterByDbTimezone($dbTimezone = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbTimezone)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbTimezone)) { + $dbTimezone = str_replace('*', '%', $dbTimezone); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcShowDaysPeer::TIMEZONE, $dbTimezone, $comparison); + } + + /** + * Filter the query on the duration column + * + * Example usage: + * + * $query->filterByDbDuration('fooValue'); // WHERE duration = 'fooValue' + * $query->filterByDbDuration('%fooValue%'); // WHERE duration LIKE '%fooValue%' + * + * + * @param string $dbDuration 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 CcShowDaysQuery The current query, for fluid interface + */ + public function filterByDbDuration($dbDuration = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbDuration)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbDuration)) { + $dbDuration = str_replace('*', '%', $dbDuration); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcShowDaysPeer::DURATION, $dbDuration, $comparison); + } + + /** + * Filter the query on the day column + * + * Example usage: + * + * $query->filterByDbDay(1234); // WHERE day = 1234 + * $query->filterByDbDay(array(12, 34)); // WHERE day IN (12, 34) + * $query->filterByDbDay(array('min' => 12)); // WHERE day >= 12 + * $query->filterByDbDay(array('max' => 12)); // WHERE day <= 12 + * + * + * @param mixed $dbDay The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowDaysQuery 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(CcShowDaysPeer::DAY, $dbDay['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbDay['max'])) { + $this->addUsingAlias(CcShowDaysPeer::DAY, $dbDay['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcShowDaysPeer::DAY, $dbDay, $comparison); + } + + /** + * Filter the query on the repeat_type column + * + * Example usage: + * + * $query->filterByDbRepeatType(1234); // WHERE repeat_type = 1234 + * $query->filterByDbRepeatType(array(12, 34)); // WHERE repeat_type IN (12, 34) + * $query->filterByDbRepeatType(array('min' => 12)); // WHERE repeat_type >= 12 + * $query->filterByDbRepeatType(array('max' => 12)); // WHERE repeat_type <= 12 + * + * + * @param mixed $dbRepeatType The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowDaysQuery The current query, for fluid interface + */ + public function filterByDbRepeatType($dbRepeatType = null, $comparison = null) + { + if (is_array($dbRepeatType)) { + $useMinMax = false; + if (isset($dbRepeatType['min'])) { + $this->addUsingAlias(CcShowDaysPeer::REPEAT_TYPE, $dbRepeatType['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbRepeatType['max'])) { + $this->addUsingAlias(CcShowDaysPeer::REPEAT_TYPE, $dbRepeatType['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcShowDaysPeer::REPEAT_TYPE, $dbRepeatType, $comparison); + } + + /** + * Filter the query on the next_pop_date column + * + * Example usage: + * + * $query->filterByDbNextPopDate('2011-03-14'); // WHERE next_pop_date = '2011-03-14' + * $query->filterByDbNextPopDate('now'); // WHERE next_pop_date = '2011-03-14' + * $query->filterByDbNextPopDate(array('max' => 'yesterday')); // WHERE next_pop_date < '2011-03-13' + * + * + * @param mixed $dbNextPopDate The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowDaysQuery The current query, for fluid interface + */ + public function filterByDbNextPopDate($dbNextPopDate = null, $comparison = null) + { + if (is_array($dbNextPopDate)) { + $useMinMax = false; + if (isset($dbNextPopDate['min'])) { + $this->addUsingAlias(CcShowDaysPeer::NEXT_POP_DATE, $dbNextPopDate['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbNextPopDate['max'])) { + $this->addUsingAlias(CcShowDaysPeer::NEXT_POP_DATE, $dbNextPopDate['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcShowDaysPeer::NEXT_POP_DATE, $dbNextPopDate, $comparison); + } + + /** + * Filter the query on the show_id column + * + * Example usage: + * + * $query->filterByDbShowId(1234); // WHERE show_id = 1234 + * $query->filterByDbShowId(array(12, 34)); // WHERE show_id IN (12, 34) + * $query->filterByDbShowId(array('min' => 12)); // WHERE show_id >= 12 + * $query->filterByDbShowId(array('max' => 12)); // WHERE show_id <= 12 + * + * + * @see filterByCcShow() + * + * @param mixed $dbShowId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowDaysQuery The current query, for fluid interface + */ + public function filterByDbShowId($dbShowId = null, $comparison = null) + { + if (is_array($dbShowId)) { + $useMinMax = false; + if (isset($dbShowId['min'])) { + $this->addUsingAlias(CcShowDaysPeer::SHOW_ID, $dbShowId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbShowId['max'])) { + $this->addUsingAlias(CcShowDaysPeer::SHOW_ID, $dbShowId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcShowDaysPeer::SHOW_ID, $dbShowId, $comparison); + } + + /** + * Filter the query on the record column + * + * Example usage: + * + * $query->filterByDbRecord(1234); // WHERE record = 1234 + * $query->filterByDbRecord(array(12, 34)); // WHERE record IN (12, 34) + * $query->filterByDbRecord(array('min' => 12)); // WHERE record >= 12 + * $query->filterByDbRecord(array('max' => 12)); // WHERE record <= 12 + * + * + * @param mixed $dbRecord The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowDaysQuery The current query, for fluid interface + */ + public function filterByDbRecord($dbRecord = null, $comparison = null) + { + if (is_array($dbRecord)) { + $useMinMax = false; + if (isset($dbRecord['min'])) { + $this->addUsingAlias(CcShowDaysPeer::RECORD, $dbRecord['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbRecord['max'])) { + $this->addUsingAlias(CcShowDaysPeer::RECORD, $dbRecord['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcShowDaysPeer::RECORD, $dbRecord, $comparison); + } + + /** + * Filter the query by a related CcShow object + * + * @param CcShow|PropelObjectCollection $ccShow The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowDaysQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcShow($ccShow, $comparison = null) + { + if ($ccShow instanceof CcShow) { + return $this + ->addUsingAlias(CcShowDaysPeer::SHOW_ID, $ccShow->getDbId(), $comparison); + } elseif ($ccShow instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcShowDaysPeer::SHOW_ID, $ccShow->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcShow() only accepts arguments of type CcShow or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcShow relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowDaysQuery The current query, for fluid interface + */ + public function joinCcShow($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShow'); + + // 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, 'CcShow'); + } + + return $this; + } + + /** + * Use the CcShow relation CcShow 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 \Airtime\CcShowQuery A secondary query class using the current class as primary query + */ + public function useCcShowQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcShow($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShow', '\Airtime\CcShowQuery'); + } + + /** + * Exclude object from result + * + * @param CcShowDays $ccShowDays Object to remove from the list of results + * + * @return CcShowDaysQuery The current query, for fluid interface + */ + public function prune($ccShowDays = null) + { + if ($ccShowDays) { + $this->addUsingAlias(CcShowDaysPeer::ID, $ccShowDays->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowHosts.php b/airtime_mvc/application/models/airtime/om/BaseCcShowHosts.php index ca4d11449..d816af2a3 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowHosts.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowHosts.php @@ -1,936 +1,1098 @@ id; - } - - /** - * Get the [show_id] column value. - * - * @return int - */ - public function getDbShow() - { - return $this->show_id; - } - - /** - * Get the [subjs_id] column value. - * - * @return int - */ - public function getDbHost() - { - return $this->subjs_id; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcShowHosts 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[] = CcShowHostsPeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [show_id] column. - * - * @param int $v new value - * @return CcShowHosts The current object (for fluent API support) - */ - public function setDbShow($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->show_id !== $v) { - $this->show_id = $v; - $this->modifiedColumns[] = CcShowHostsPeer::SHOW_ID; - } - - if ($this->aCcShow !== null && $this->aCcShow->getDbId() !== $v) { - $this->aCcShow = null; - } - - return $this; - } // setDbShow() - - /** - * Set the value of [subjs_id] column. - * - * @param int $v new value - * @return CcShowHosts The current object (for fluent API support) - */ - public function setDbHost($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->subjs_id !== $v) { - $this->subjs_id = $v; - $this->modifiedColumns[] = CcShowHostsPeer::SUBJS_ID; - } - - if ($this->aCcSubjs !== null && $this->aCcSubjs->getDbId() !== $v) { - $this->aCcSubjs = null; - } - - return $this; - } // setDbHost() - - /** - * 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->show_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->subjs_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 3; // 3 = CcShowHostsPeer::NUM_COLUMNS - CcShowHostsPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcShowHosts 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->aCcShow !== null && $this->show_id !== $this->aCcShow->getDbId()) { - $this->aCcShow = null; - } - if ($this->aCcSubjs !== null && $this->subjs_id !== $this->aCcSubjs->getDbId()) { - $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(CcShowHostsPeer::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 = CcShowHostsPeer::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->aCcShow = null; - $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(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcShowHostsQuery::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(CcShowHostsPeer::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); - CcShowHostsPeer::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->aCcShow !== null) { - if ($this->aCcShow->isModified() || $this->aCcShow->isNew()) { - $affectedRows += $this->aCcShow->save($con); - } - $this->setCcShow($this->aCcShow); - } - - 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[] = CcShowHostsPeer::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(CcShowHostsPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowHostsPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows += 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows += CcShowHostsPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcShow !== null) { - if (!$this->aCcShow->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcShow->getValidationFailures()); - } - } - - if ($this->aCcSubjs !== null) { - if (!$this->aCcSubjs->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcSubjs->getValidationFailures()); - } - } - - - if (($retval = CcShowHostsPeer::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 = CcShowHostsPeer::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->getDbShow(); - break; - case 2: - return $this->getDbHost(); - 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 = CcShowHostsPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbShow(), - $keys[2] => $this->getDbHost(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCcShow) { - $result['CcShow'] = $this->aCcShow->toArray($keyType, $includeLazyLoadColumns, true); - } - 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 = CcShowHostsPeer::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->setDbShow($value); - break; - case 2: - $this->setDbHost($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 = CcShowHostsPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbShow($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbHost($arr[$keys[2]]); - } - - /** - * 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(CcShowHostsPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcShowHostsPeer::ID)) $criteria->add(CcShowHostsPeer::ID, $this->id); - if ($this->isColumnModified(CcShowHostsPeer::SHOW_ID)) $criteria->add(CcShowHostsPeer::SHOW_ID, $this->show_id); - if ($this->isColumnModified(CcShowHostsPeer::SUBJS_ID)) $criteria->add(CcShowHostsPeer::SUBJS_ID, $this->subjs_id); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(CcShowHostsPeer::DATABASE_NAME); - $criteria->add(CcShowHostsPeer::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 CcShowHosts (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->setDbShow($this->show_id); - $copyObj->setDbHost($this->subjs_id); - - $copyObj->setNew(true); - $copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return CcShowHosts 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 CcShowHostsPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcShowHostsPeer(); - } - return self::$peer; - } - - /** - * Declares an association between this object and a CcShow object. - * - * @param CcShow $v - * @return CcShowHosts The current object (for fluent API support) - * @throws PropelException - */ - public function setCcShow(CcShow $v = null) - { - if ($v === null) { - $this->setDbShow(NULL); - } else { - $this->setDbShow($v->getDbId()); - } - - $this->aCcShow = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcShow object, it will not be re-added. - if ($v !== null) { - $v->addCcShowHosts($this); - } - - return $this; - } - - - /** - * Get the associated CcShow object - * - * @param PropelPDO Optional Connection object. - * @return CcShow The associated CcShow object. - * @throws PropelException - */ - public function getCcShow(PropelPDO $con = null) - { - if ($this->aCcShow === null && ($this->show_id !== null)) { - $this->aCcShow = CcShowQuery::create()->findPk($this->show_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->aCcShow->addCcShowHostss($this); - */ - } - return $this->aCcShow; - } - - /** - * Declares an association between this object and a CcSubjs object. - * - * @param CcSubjs $v - * @return CcShowHosts The current object (for fluent API support) - * @throws PropelException - */ - public function setCcSubjs(CcSubjs $v = null) - { - if ($v === null) { - $this->setDbHost(NULL); - } else { - $this->setDbHost($v->getDbId()); - } - - $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->addCcShowHosts($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->subjs_id !== null)) { - $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->subjs_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->aCcSubjs->addCcShowHostss($this); - */ - } - return $this->aCcSubjs; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->show_id = null; - $this->subjs_id = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all collections of referencing foreign keys. - * - * This method is a user-space workaround for PHP's inability to garbage collect objects - * with circular references. This is currently necessary when using Propel in certain - * daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all associated objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep) { - } // if ($deep) - - $this->aCcShow = 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); - } - -} // BaseCcShowHosts + /** + * Peer class name + */ + const PEER = 'Airtime\\CcShowHostsPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcShowHostsPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the show_id field. + * @var int + */ + protected $show_id; + + /** + * The value for the subjs_id field. + * @var int + */ + protected $subjs_id; + + /** + * @var CcShow + */ + protected $aCcShow; + + /** + * @var CcSubjs + */ + protected $aCcSubjs; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * Get the [id] column value. + * + * @return int + */ + public function getDbId() + { + + return $this->id; + } + + /** + * Get the [show_id] column value. + * + * @return int + */ + public function getDbShow() + { + + return $this->show_id; + } + + /** + * Get the [subjs_id] column value. + * + * @return int + */ + public function getDbHost() + { + + return $this->subjs_id; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcShowHosts The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcShowHostsPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [show_id] column. + * + * @param int $v new value + * @return CcShowHosts The current object (for fluent API support) + */ + public function setDbShow($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->show_id !== $v) { + $this->show_id = $v; + $this->modifiedColumns[] = CcShowHostsPeer::SHOW_ID; + } + + if ($this->aCcShow !== null && $this->aCcShow->getDbId() !== $v) { + $this->aCcShow = null; + } + + + return $this; + } // setDbShow() + + /** + * Set the value of [subjs_id] column. + * + * @param int $v new value + * @return CcShowHosts The current object (for fluent API support) + */ + public function setDbHost($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->subjs_id !== $v) { + $this->subjs_id = $v; + $this->modifiedColumns[] = CcShowHostsPeer::SUBJS_ID; + } + + if ($this->aCcSubjs !== null && $this->aCcSubjs->getDbId() !== $v) { + $this->aCcSubjs = null; + } + + + return $this; + } // setDbHost() + + /** + * 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 resultset 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->show_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->subjs_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 3; // 3 = CcShowHostsPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcShowHosts 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->aCcShow !== null && $this->show_id !== $this->aCcShow->getDbId()) { + $this->aCcShow = null; + } + if ($this->aCcSubjs !== null && $this->subjs_id !== $this->aCcSubjs->getDbId()) { + $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(CcShowHostsPeer::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 = CcShowHostsPeer::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->aCcShow = null; + $this->aCcSubjs = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcShowHostsQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcShowHostsPeer::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); + CcShowHostsPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcShow !== null) { + if ($this->aCcShow->isModified() || $this->aCcShow->isNew()) { + $affectedRows += $this->aCcShow->save($con); + } + $this->setCcShow($this->aCcShow); + } + + if ($this->aCcSubjs !== null) { + if ($this->aCcSubjs->isModified() || $this->aCcSubjs->isNew()) { + $affectedRows += $this->aCcSubjs->save($con); + } + $this->setCcSubjs($this->aCcSubjs); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcShowHostsPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcShowHostsPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_show_hosts_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcShowHostsPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcShowHostsPeer::SHOW_ID)) { + $modifiedColumns[':p' . $index++] = '"show_id"'; + } + if ($this->isColumnModified(CcShowHostsPeer::SUBJS_ID)) { + $modifiedColumns[':p' . $index++] = '"subjs_id"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_show_hosts" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"show_id"': + $stmt->bindValue($identifier, $this->show_id, PDO::PARAM_INT); + break; + case '"subjs_id"': + $stmt->bindValue($identifier, $this->subjs_id, PDO::PARAM_INT); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcShow !== null) { + if (!$this->aCcShow->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcShow->getValidationFailures()); + } + } + + if ($this->aCcSubjs !== null) { + if (!$this->aCcSubjs->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcSubjs->getValidationFailures()); + } + } + + + if (($retval = CcShowHostsPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcShowHostsPeer::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->getDbShow(); + break; + case 2: + return $this->getDbHost(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcShowHosts'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcShowHosts'][$this->getPrimaryKey()] = true; + $keys = CcShowHostsPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbShow(), + $keys[2] => $this->getDbHost(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcShow) { + $result['CcShow'] = $this->aCcShow->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aCcSubjs) { + $result['CcSubjs'] = $this->aCcSubjs->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcShowHostsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbShow($value); + break; + case 2: + $this->setDbHost($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcShowHostsPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbShow($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbHost($arr[$keys[2]]); + } + + /** + * 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(CcShowHostsPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcShowHostsPeer::ID)) $criteria->add(CcShowHostsPeer::ID, $this->id); + if ($this->isColumnModified(CcShowHostsPeer::SHOW_ID)) $criteria->add(CcShowHostsPeer::SHOW_ID, $this->show_id); + if ($this->isColumnModified(CcShowHostsPeer::SUBJS_ID)) $criteria->add(CcShowHostsPeer::SUBJS_ID, $this->subjs_id); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(CcShowHostsPeer::DATABASE_NAME); + $criteria->add(CcShowHostsPeer::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 CcShowHosts (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbShow($this->getDbShow()); + $copyObj->setDbHost($this->getDbHost()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcShowHosts 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 CcShowHostsPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcShowHostsPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a CcShow object. + * + * @param CcShow $v + * @return CcShowHosts The current object (for fluent API support) + * @throws PropelException + */ + public function setCcShow(CcShow $v = null) + { + if ($v === null) { + $this->setDbShow(NULL); + } else { + $this->setDbShow($v->getDbId()); + } + + $this->aCcShow = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcShow object, it will not be re-added. + if ($v !== null) { + $v->addCcShowHosts($this); + } + + + return $this; + } + + + /** + * Get the associated CcShow object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcShow The associated CcShow object. + * @throws PropelException + */ + public function getCcShow(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcShow === null && ($this->show_id !== null) && $doQuery) { + $this->aCcShow = CcShowQuery::create()->findPk($this->show_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->aCcShow->addCcShowHostss($this); + */ + } + + return $this->aCcShow; + } + + /** + * Declares an association between this object and a CcSubjs object. + * + * @param CcSubjs $v + * @return CcShowHosts The current object (for fluent API support) + * @throws PropelException + */ + public function setCcSubjs(CcSubjs $v = null) + { + if ($v === null) { + $this->setDbHost(NULL); + } else { + $this->setDbHost($v->getDbId()); + } + + $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->addCcShowHosts($this); + } + + + return $this; + } + + + /** + * Get the associated CcSubjs object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getCcSubjs(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcSubjs === null && ($this->subjs_id !== null) && $doQuery) { + $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->subjs_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->aCcSubjs->addCcShowHostss($this); + */ + } + + return $this->aCcSubjs; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->show_id = null; + $this->subjs_id = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCcShow instanceof Persistent) { + $this->aCcShow->clearAllReferences($deep); + } + if ($this->aCcSubjs instanceof Persistent) { + $this->aCcSubjs->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + $this->aCcShow = null; + $this->aCcSubjs = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcShowHostsPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowHostsPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcShowHostsPeer.php index 33a82f0d9..187f31bd1 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowHostsPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowHostsPeer.php @@ -1,1361 +1,1407 @@ array ('DbId', 'DbShow', 'DbHost', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbShow', 'dbHost', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::SHOW_ID, self::SUBJS_ID, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'SHOW_ID', 'SUBJS_ID', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'show_id', 'subjs_id', ), - BasePeer::TYPE_NUM => array (0, 1, 2, ) - ); - - /** - * 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, 'DbShow' => 1, 'DbHost' => 2, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbShow' => 1, 'dbHost' => 2, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::SHOW_ID => 1, self::SUBJS_ID => 2, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'SHOW_ID' => 1, 'SUBJS_ID' => 2, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'show_id' => 1, 'subjs_id' => 2, ), - BasePeer::TYPE_NUM => array (0, 1, 2, ) - ); - - /** - * 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. CcShowHostsPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcShowHostsPeer::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(CcShowHostsPeer::ID); - $criteria->addSelectColumn(CcShowHostsPeer::SHOW_ID); - $criteria->addSelectColumn(CcShowHostsPeer::SUBJS_ID); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.SHOW_ID'); - $criteria->addSelectColumn($alias . '.SUBJS_ID'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CcShowHostsPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowHostsPeer::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(CcShowHostsPeer::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 CcShowHosts - * @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 = CcShowHostsPeer::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 CcShowHostsPeer::populateObjects(CcShowHostsPeer::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(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcShowHostsPeer::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 CcShowHosts $value A CcShowHosts object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcShowHosts $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 CcShowHosts object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcShowHosts) { - $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 CcShowHosts 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 CcShowHosts 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_hosts - * 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 = CcShowHostsPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcShowHostsPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcShowHostsPeer::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; - CcShowHostsPeer::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 (CcShowHosts object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcShowHostsPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcShowHostsPeer::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 + CcShowHostsPeer::NUM_COLUMNS; - } else { - $cls = CcShowHostsPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcShowHostsPeer::addInstanceToPool($obj, $key); - } - return array($obj, $col); - } - - /** - * Returns the number of rows matching criteria, joining the related CcShow 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 doCountJoinCcShow(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(CcShowHostsPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowHostsPeer::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(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcShowHostsPeer::SHOW_ID, CcShowPeer::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 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(CcShowHostsPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowHostsPeer::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(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcShowHostsPeer::SUBJS_ID, 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 CcShowHosts objects pre-filled with their CcShow 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 CcShowHosts objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCcShow(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); - } - - CcShowHostsPeer::addSelectColumns($criteria); - $startcol = (CcShowHostsPeer::NUM_COLUMNS - CcShowHostsPeer::NUM_LAZY_LOAD_COLUMNS); - CcShowPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcShowHostsPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcShowHostsPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcShowHostsPeer::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 = CcShowHostsPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcShowHostsPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcShowPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcShowPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcShowHosts) to $obj2 (CcShow) - $obj2->addCcShowHosts($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcShowHosts 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 CcShowHosts 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); - } - - CcShowHostsPeer::addSelectColumns($criteria); - $startcol = (CcShowHostsPeer::NUM_COLUMNS - CcShowHostsPeer::NUM_LAZY_LOAD_COLUMNS); - CcSubjsPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcShowHostsPeer::SUBJS_ID, CcSubjsPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcShowHostsPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcShowHostsPeer::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 = CcShowHostsPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcShowHostsPeer::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 (CcShowHosts) to $obj2 (CcSubjs) - $obj2->addCcShowHosts($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(CcShowHostsPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowHostsPeer::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(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcShowHostsPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); - - $criteria->addJoin(CcShowHostsPeer::SUBJS_ID, 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 CcShowHosts 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 CcShowHosts 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); - } - - CcShowHostsPeer::addSelectColumns($criteria); - $startcol2 = (CcShowHostsPeer::NUM_COLUMNS - CcShowHostsPeer::NUM_LAZY_LOAD_COLUMNS); - - CcShowPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS); - - CcSubjsPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + (CcSubjsPeer::NUM_COLUMNS - CcSubjsPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcShowHostsPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); - - $criteria->addJoin(CcShowHostsPeer::SUBJS_ID, CcSubjsPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcShowHostsPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcShowHostsPeer::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 = CcShowHostsPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcShowHostsPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcShow rows - - $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcShowPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcShowPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (CcShowHosts) to the collection in $obj2 (CcShow) - $obj2->addCcShowHosts($obj1); - } // if joined row not null - - // Add objects for joined CcSubjs rows - - $key3 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CcSubjsPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CcSubjsPeer::getOMClass(false); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CcSubjsPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (CcShowHosts) to the collection in $obj3 (CcSubjs) - $obj3->addCcShowHosts($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related CcShow 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 doCountJoinAllExceptCcShow(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(CcShowHostsPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowHostsPeer::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(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcShowHostsPeer::SUBJS_ID, 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; - } - - - /** - * 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 doCountJoinAllExceptCcSubjs(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(CcShowHostsPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowHostsPeer::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(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcShowHostsPeer::SHOW_ID, CcShowPeer::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 CcShowHosts objects pre-filled with all related objects except CcShow. - * - * @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 CcShowHosts objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCcShow(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); - } - - CcShowHostsPeer::addSelectColumns($criteria); - $startcol2 = (CcShowHostsPeer::NUM_COLUMNS - CcShowHostsPeer::NUM_LAZY_LOAD_COLUMNS); - - CcSubjsPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcSubjsPeer::NUM_COLUMNS - CcSubjsPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcShowHostsPeer::SUBJS_ID, CcSubjsPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcShowHostsPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcShowHostsPeer::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 = CcShowHostsPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcShowHostsPeer::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 already loaded - - // Add the $obj1 (CcShowHosts) to the collection in $obj2 (CcSubjs) - $obj2->addCcShowHosts($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcShowHosts objects pre-filled with all related objects except CcSubjs. - * - * @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 CcShowHosts objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCcSubjs(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); - } - - CcShowHostsPeer::addSelectColumns($criteria); - $startcol2 = (CcShowHostsPeer::NUM_COLUMNS - CcShowHostsPeer::NUM_LAZY_LOAD_COLUMNS); - - CcShowPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcShowHostsPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcShowHostsPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcShowHostsPeer::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 = CcShowHostsPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcShowHostsPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcShow rows - - $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcShowPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcShowPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (CcShowHosts) to the collection in $obj2 (CcShow) - $obj2->addCcShowHosts($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(BaseCcShowHostsPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcShowHostsPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcShowHostsTableMap()); - } - } - - /** - * 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 ? CcShowHostsPeer::CLASS_DEFAULT : CcShowHostsPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcShowHosts or Criteria object. - * - * @param mixed $values Criteria or CcShowHosts 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(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcShowHosts object - } - - if ($criteria->containsKey(CcShowHostsPeer::ID) && $criteria->keyContainsValue(CcShowHostsPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowHostsPeer::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 CcShowHosts or Criteria object. - * - * @param mixed $values Criteria or CcShowHosts 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(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcShowHostsPeer::ID); - $value = $criteria->remove(CcShowHostsPeer::ID); - if ($value) { - $selectCriteria->add(CcShowHostsPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcShowHostsPeer::TABLE_NAME); - } - - } else { // $values is CcShowHosts 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_hosts 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(CcShowHostsPeer::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(CcShowHostsPeer::TABLE_NAME, $con, CcShowHostsPeer::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). - CcShowHostsPeer::clearInstancePool(); - CcShowHostsPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcShowHosts or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcShowHosts 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(CcShowHostsPeer::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. - CcShowHostsPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcShowHosts) { // it's a model object - // invalidate the cache for this single object - CcShowHostsPeer::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(CcShowHostsPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcShowHostsPeer::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); - CcShowHostsPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcShowHosts 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 CcShowHosts $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(CcShowHosts $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcShowHostsPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcShowHostsPeer::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(CcShowHostsPeer::DATABASE_NAME, CcShowHostsPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcShowHosts - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcShowHostsPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcShowHostsPeer::DATABASE_NAME); - $criteria->add(CcShowHostsPeer::ID, $pk); - - $v = CcShowHostsPeer::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(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcShowHostsPeer::DATABASE_NAME); - $criteria->add(CcShowHostsPeer::ID, $pks, Criteria::IN); - $objs = CcShowHostsPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcShowHostsPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_show_hosts'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcShowHosts'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcShowHostsTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 3; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 3; + + /** the column name for the id field */ + const ID = 'cc_show_hosts.id'; + + /** the column name for the show_id field */ + const SHOW_ID = 'cc_show_hosts.show_id'; + + /** the column name for the subjs_id field */ + const SUBJS_ID = 'cc_show_hosts.subjs_id'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcShowHosts objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcShowHosts[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcShowHostsPeer::$fieldNames[CcShowHostsPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbShow', 'DbHost', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbShow', 'dbHost', ), + BasePeer::TYPE_COLNAME => array (CcShowHostsPeer::ID, CcShowHostsPeer::SHOW_ID, CcShowHostsPeer::SUBJS_ID, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'SHOW_ID', 'SUBJS_ID', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'show_id', 'subjs_id', ), + BasePeer::TYPE_NUM => array (0, 1, 2, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcShowHostsPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbShow' => 1, 'DbHost' => 2, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbShow' => 1, 'dbHost' => 2, ), + BasePeer::TYPE_COLNAME => array (CcShowHostsPeer::ID => 0, CcShowHostsPeer::SHOW_ID => 1, CcShowHostsPeer::SUBJS_ID => 2, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'SHOW_ID' => 1, 'SUBJS_ID' => 2, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'show_id' => 1, 'subjs_id' => 2, ), + BasePeer::TYPE_NUM => array (0, 1, 2, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcShowHostsPeer::getFieldNames($toType); + $key = isset(CcShowHostsPeer::$fieldKeys[$fromType][$name]) ? CcShowHostsPeer::$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(CcShowHostsPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcShowHostsPeer::$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 CcShowHostsPeer::$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. CcShowHostsPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcShowHostsPeer::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(CcShowHostsPeer::ID); + $criteria->addSelectColumn(CcShowHostsPeer::SHOW_ID); + $criteria->addSelectColumn(CcShowHostsPeer::SUBJS_ID); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.show_id'); + $criteria->addSelectColumn($alias . '.subjs_id'); + } + } + + /** + * Returns the number of rows matching criteria. + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. + * @param PropelPDO $con + * @return int Number of matching rows. + */ + public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) + { + // we may modify criteria, so copy it first + $criteria = clone $criteria; + + // We need to set the primary table name, since in the case that there are no WHERE columns + // it will be impossible for the BasePeer::createSelectSql() method to determine which + // tables go into the FROM clause. + $criteria->setPrimaryTableName(CcShowHostsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowHostsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcShowHostsPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcShowHostsPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcShowHosts + * @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 = CcShowHostsPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcShowHostsPeer::populateObjects(CcShowHostsPeer::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 directly (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(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcShowHostsPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcShowHostsPeer::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 CcShowHosts $obj A CcShowHosts object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcShowHostsPeer::$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 CcShowHosts object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcShowHosts) { + $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 CcShowHosts object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcShowHostsPeer::$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 CcShowHosts 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(CcShowHostsPeer::$instances[$key])) { + return CcShowHostsPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcShowHostsPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcShowHostsPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_show_hosts + * 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 = CcShowHostsPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcShowHostsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcShowHostsPeer::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; + CcShowHostsPeer::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 (CcShowHosts object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcShowHostsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcShowHostsPeer::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 + CcShowHostsPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcShowHostsPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcShowHostsPeer::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + + /** + * Returns the number of rows matching criteria, joining the related CcShow 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 doCountJoinCcShow(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(CcShowHostsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowHostsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcShowHostsPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowHostsPeer::SHOW_ID, CcShowPeer::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 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(CcShowHostsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowHostsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcShowHostsPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowHostsPeer::SUBJS_ID, 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 CcShowHosts objects pre-filled with their CcShow 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 CcShowHosts objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcShow(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(CcShowHostsPeer::DATABASE_NAME); + } + + CcShowHostsPeer::addSelectColumns($criteria); + $startcol = CcShowHostsPeer::NUM_HYDRATE_COLUMNS; + CcShowPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcShowHostsPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowHostsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowHostsPeer::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 = CcShowHostsPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowHostsPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcShowPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcShowPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcShowHosts) to $obj2 (CcShow) + $obj2->addCcShowHosts($obj1); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcShowHosts 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 CcShowHosts 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(CcShowHostsPeer::DATABASE_NAME); + } + + CcShowHostsPeer::addSelectColumns($criteria); + $startcol = CcShowHostsPeer::NUM_HYDRATE_COLUMNS; + CcSubjsPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcShowHostsPeer::SUBJS_ID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowHostsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowHostsPeer::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 = CcShowHostsPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowHostsPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcShowHosts) to $obj2 (CcSubjs) + $obj2->addCcShowHosts($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(CcShowHostsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowHostsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcShowHostsPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowHostsPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $criteria->addJoin(CcShowHostsPeer::SUBJS_ID, 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 CcShowHosts 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 CcShowHosts 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(CcShowHostsPeer::DATABASE_NAME); + } + + CcShowHostsPeer::addSelectColumns($criteria); + $startcol2 = CcShowHostsPeer::NUM_HYDRATE_COLUMNS; + + CcShowPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcShowPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcShowHostsPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $criteria->addJoin(CcShowHostsPeer::SUBJS_ID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowHostsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowHostsPeer::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 = CcShowHostsPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowHostsPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcShow rows + + $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcShowPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcShowPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcShowHosts) to the collection in $obj2 (CcShow) + $obj2->addCcShowHosts($obj1); + } // if joined row not null + + // Add objects for joined CcSubjs rows + + $key3 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcSubjsPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcSubjsPeer::addInstanceToPool($obj3, $key3); + } // if obj3 loaded + + // Add the $obj1 (CcShowHosts) to the collection in $obj3 (CcSubjs) + $obj3->addCcShowHosts($obj1); + } // if joined row not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining the related CcShow 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 doCountJoinAllExceptCcShow(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(CcShowHostsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowHostsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(CcShowHostsPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowHostsPeer::SUBJS_ID, 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; + } + + + /** + * 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 doCountJoinAllExceptCcSubjs(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(CcShowHostsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowHostsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(CcShowHostsPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowHostsPeer::SHOW_ID, CcShowPeer::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 CcShowHosts objects pre-filled with all related objects except CcShow. + * + * @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 CcShowHosts objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcShow(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(CcShowHostsPeer::DATABASE_NAME); + } + + CcShowHostsPeer::addSelectColumns($criteria); + $startcol2 = CcShowHostsPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcShowHostsPeer::SUBJS_ID, CcSubjsPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowHostsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowHostsPeer::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 = CcShowHostsPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowHostsPeer::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(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcShowHosts) to the collection in $obj2 (CcSubjs) + $obj2->addCcShowHosts($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcShowHosts objects pre-filled with all related objects except CcSubjs. + * + * @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 CcShowHosts objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcSubjs(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(CcShowHostsPeer::DATABASE_NAME); + } + + CcShowHostsPeer::addSelectColumns($criteria); + $startcol2 = CcShowHostsPeer::NUM_HYDRATE_COLUMNS; + + CcShowPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcShowPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcShowHostsPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowHostsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowHostsPeer::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 = CcShowHostsPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowHostsPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcShow rows + + $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcShowPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcShowPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcShowHosts) to the collection in $obj2 (CcShow) + $obj2->addCcShowHosts($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(CcShowHostsPeer::DATABASE_NAME)->getTable(CcShowHostsPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcShowHostsPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcShowHostsPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcShowHostsTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcShowHostsPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcShowHosts or Criteria object. + * + * @param mixed $values Criteria or CcShowHosts 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(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcShowHosts object + } + + if ($criteria->containsKey(CcShowHostsPeer::ID) && $criteria->keyContainsValue(CcShowHostsPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowHostsPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcShowHostsPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcShowHosts or Criteria object. + * + * @param mixed $values Criteria or CcShowHosts 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(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcShowHostsPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcShowHostsPeer::ID); + $value = $criteria->remove(CcShowHostsPeer::ID); + if ($value) { + $selectCriteria->add(CcShowHostsPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcShowHostsPeer::TABLE_NAME); + } + + } else { // $values is CcShowHosts object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcShowHostsPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_show_hosts table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcShowHostsPeer::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(CcShowHostsPeer::TABLE_NAME, $con, CcShowHostsPeer::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). + CcShowHostsPeer::clearInstancePool(); + CcShowHostsPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcShowHosts or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcShowHosts 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(CcShowHostsPeer::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. + CcShowHostsPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcShowHosts) { // it's a model object + // invalidate the cache for this single object + CcShowHostsPeer::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(CcShowHostsPeer::DATABASE_NAME); + $criteria->add(CcShowHostsPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcShowHostsPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcShowHostsPeer::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); + CcShowHostsPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcShowHosts 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 CcShowHosts $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcShowHostsPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcShowHostsPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcShowHostsPeer::DATABASE_NAME, CcShowHostsPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcShowHosts + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcShowHostsPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcShowHostsPeer::DATABASE_NAME); + $criteria->add(CcShowHostsPeer::ID, $pk); + + $v = CcShowHostsPeer::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 + * @return CcShowHosts[] + * @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(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcShowHostsPeer::DATABASE_NAME); + $criteria->add(CcShowHostsPeer::ID, $pks, Criteria::IN); + $objs = CcShowHostsPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcShowHostsPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowHostsQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcShowHostsQuery.php index 2b910a52b..33cd81a8d 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowHostsQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowHostsQuery.php @@ -1,371 +1,549 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcShowHosts|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcShowHostsPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcShowHosts|CcShowHosts[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcShowHostsPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcShowHostsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcShowHostsQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcShowHostsPeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcShowHosts A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcShowHostsQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcShowHostsPeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcShowHosts A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "show_id", "subjs_id" FROM "cc_show_hosts" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcShowHosts(); + $obj->hydrate($row); + CcShowHostsPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcShowHostsQuery 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(CcShowHostsPeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * Filter the query on the show_id column - * - * @param int|array $dbShow 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 CcShowHostsQuery The current query, for fluid interface - */ - public function filterByDbShow($dbShow = null, $comparison = null) - { - if (is_array($dbShow)) { - $useMinMax = false; - if (isset($dbShow['min'])) { - $this->addUsingAlias(CcShowHostsPeer::SHOW_ID, $dbShow['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbShow['max'])) { - $this->addUsingAlias(CcShowHostsPeer::SHOW_ID, $dbShow['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowHostsPeer::SHOW_ID, $dbShow, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcShowHosts|CcShowHosts[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Filter the query on the subjs_id column - * - * @param int|array $dbHost 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 CcShowHostsQuery The current query, for fluid interface - */ - public function filterByDbHost($dbHost = null, $comparison = null) - { - if (is_array($dbHost)) { - $useMinMax = false; - if (isset($dbHost['min'])) { - $this->addUsingAlias(CcShowHostsPeer::SUBJS_ID, $dbHost['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbHost['max'])) { - $this->addUsingAlias(CcShowHostsPeer::SUBJS_ID, $dbHost['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowHostsPeer::SUBJS_ID, $dbHost, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query by a related CcShow object - * - * @param CcShow $ccShow the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowHostsQuery The current query, for fluid interface - */ - public function filterByCcShow($ccShow, $comparison = null) - { - return $this - ->addUsingAlias(CcShowHostsPeer::SHOW_ID, $ccShow->getDbId(), $comparison); - } + /** + * 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|CcShowHosts[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Adds a JOIN clause to the query using the CcShow relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcShowHostsQuery The current query, for fluid interface - */ - public function joinCcShow($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcShow'); - - // 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, 'CcShow'); - } - - return $this; - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Use the CcShow relation CcShow 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 CcShowQuery A secondary query class using the current class as primary query - */ - public function useCcShowQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcShow($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcShow', 'CcShowQuery'); - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcShowHostsQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { - /** - * 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 CcShowHostsQuery The current query, for fluid interface - */ - public function filterByCcSubjs($ccSubjs, $comparison = null) - { - return $this - ->addUsingAlias(CcShowHostsPeer::SUBJS_ID, $ccSubjs->getDbId(), $comparison); - } + return $this->addUsingAlias(CcShowHostsPeer::ID, $key, Criteria::EQUAL); + } - /** - * 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 CcShowHostsQuery The current query, for fluid interface - */ - public function joinCcSubjs($relationAlias = '', $joinType = Criteria::INNER_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; - } + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return CcShowHostsQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { - /** - * 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::INNER_JOIN) - { - return $this - ->joinCcSubjs($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', 'CcSubjsQuery'); - } + return $this->addUsingAlias(CcShowHostsPeer::ID, $keys, Criteria::IN); + } - /** - * Exclude object from result - * - * @param CcShowHosts $ccShowHosts Object to remove from the list of results - * - * @return CcShowHostsQuery The current query, for fluid interface - */ - public function prune($ccShowHosts = null) - { - if ($ccShowHosts) { - $this->addUsingAlias(CcShowHostsPeer::ID, $ccShowHosts->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowHostsQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcShowHostsPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcShowHostsPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } -} // BaseCcShowHostsQuery + return $this->addUsingAlias(CcShowHostsPeer::ID, $dbId, $comparison); + } + + /** + * Filter the query on the show_id column + * + * Example usage: + * + * $query->filterByDbShow(1234); // WHERE show_id = 1234 + * $query->filterByDbShow(array(12, 34)); // WHERE show_id IN (12, 34) + * $query->filterByDbShow(array('min' => 12)); // WHERE show_id >= 12 + * $query->filterByDbShow(array('max' => 12)); // WHERE show_id <= 12 + * + * + * @see filterByCcShow() + * + * @param mixed $dbShow The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowHostsQuery The current query, for fluid interface + */ + public function filterByDbShow($dbShow = null, $comparison = null) + { + if (is_array($dbShow)) { + $useMinMax = false; + if (isset($dbShow['min'])) { + $this->addUsingAlias(CcShowHostsPeer::SHOW_ID, $dbShow['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbShow['max'])) { + $this->addUsingAlias(CcShowHostsPeer::SHOW_ID, $dbShow['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcShowHostsPeer::SHOW_ID, $dbShow, $comparison); + } + + /** + * Filter the query on the subjs_id column + * + * Example usage: + * + * $query->filterByDbHost(1234); // WHERE subjs_id = 1234 + * $query->filterByDbHost(array(12, 34)); // WHERE subjs_id IN (12, 34) + * $query->filterByDbHost(array('min' => 12)); // WHERE subjs_id >= 12 + * $query->filterByDbHost(array('max' => 12)); // WHERE subjs_id <= 12 + * + * + * @see filterByCcSubjs() + * + * @param mixed $dbHost The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowHostsQuery The current query, for fluid interface + */ + public function filterByDbHost($dbHost = null, $comparison = null) + { + if (is_array($dbHost)) { + $useMinMax = false; + if (isset($dbHost['min'])) { + $this->addUsingAlias(CcShowHostsPeer::SUBJS_ID, $dbHost['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbHost['max'])) { + $this->addUsingAlias(CcShowHostsPeer::SUBJS_ID, $dbHost['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcShowHostsPeer::SUBJS_ID, $dbHost, $comparison); + } + + /** + * Filter the query by a related CcShow object + * + * @param CcShow|PropelObjectCollection $ccShow The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowHostsQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcShow($ccShow, $comparison = null) + { + if ($ccShow instanceof CcShow) { + return $this + ->addUsingAlias(CcShowHostsPeer::SHOW_ID, $ccShow->getDbId(), $comparison); + } elseif ($ccShow instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcShowHostsPeer::SHOW_ID, $ccShow->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcShow() only accepts arguments of type CcShow or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcShow relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowHostsQuery The current query, for fluid interface + */ + public function joinCcShow($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShow'); + + // 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, 'CcShow'); + } + + return $this; + } + + /** + * Use the CcShow relation CcShow 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 \Airtime\CcShowQuery A secondary query class using the current class as primary query + */ + public function useCcShowQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcShow($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShow', '\Airtime\CcShowQuery'); + } + + /** + * Filter the query by a related CcSubjs object + * + * @param CcSubjs|PropelObjectCollection $ccSubjs The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowHostsQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcSubjs($ccSubjs, $comparison = null) + { + if ($ccSubjs instanceof CcSubjs) { + return $this + ->addUsingAlias(CcShowHostsPeer::SUBJS_ID, $ccSubjs->getDbId(), $comparison); + } elseif ($ccSubjs instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcShowHostsPeer::SUBJS_ID, $ccSubjs->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcSubjs() only accepts arguments of type CcSubjs or PropelCollection'); + } + } + + /** + * 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 CcShowHostsQuery The current query, for fluid interface + */ + public function joinCcSubjs($relationAlias = null, $joinType = Criteria::INNER_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 \Airtime\CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcSubjs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', '\Airtime\CcSubjsQuery'); + } + + /** + * Exclude object from result + * + * @param CcShowHosts $ccShowHosts Object to remove from the list of results + * + * @return CcShowHostsQuery The current query, for fluid interface + */ + public function prune($ccShowHosts = null) + { + if ($ccShowHosts) { + $this->addUsingAlias(CcShowHostsPeer::ID, $ccShowHosts->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowInstances.php b/airtime_mvc/application/models/airtime/om/BaseCcShowInstances.php index a783a8e20..0119203c0 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowInstances.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowInstances.php @@ -1,2265 +1,2846 @@ record = 0; - $this->rebroadcast = 0; - $this->time_filled = '00:00:00'; - $this->modified_instance = false; - } - - /** - * Initializes internal state of BaseCcShowInstances 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 [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 getDbStarts($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 getDbEnds($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 [show_id] column value. - * - * @return int - */ - public function getDbShowId() - { - return $this->show_id; - } - - /** - * Get the [record] column value. - * - * @return int - */ - public function getDbRecord() - { - return $this->record; - } - - /** - * Get the [rebroadcast] column value. - * - * @return int - */ - public function getDbRebroadcast() - { - return $this->rebroadcast; - } - - /** - * Get the [instance_id] column value. - * - * @return int - */ - public function getDbOriginalShow() - { - return $this->instance_id; - } - - /** - * Get the [file_id] column value. - * - * @return int - */ - public function getDbRecordedFile() - { - return $this->file_id; - } - - /** - * Get the [time_filled] column value. - * - * @return string - */ - public function getDbTimeFilled() - { - return $this->time_filled; - } - - /** - * Get the [optionally formatted] temporal [created] 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 getDbCreated($format = 'Y-m-d H:i:s') - { - if ($this->created === null) { - return null; - } - - - - try { - $dt = new DateTime($this->created); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created, 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_scheduled] 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 getDbLastScheduled($format = 'Y-m-d H:i:s') - { - if ($this->last_scheduled === null) { - return null; - } - - - - try { - $dt = new DateTime($this->last_scheduled); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->last_scheduled, 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 [modified_instance] column value. - * - * @return boolean - */ - public function getDbModifiedInstance() - { - return $this->modified_instance; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcShowInstances 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[] = CcShowInstancesPeer::ID; - } - - return $this; - } // setDbId() - - /** - * 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 CcShowInstances The current object (for fluent API support) - */ - public function setDbStarts($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[] = CcShowInstancesPeer::STARTS; - } - } // if either are not null - - return $this; - } // setDbStarts() - - /** - * 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 CcShowInstances The current object (for fluent API support) - */ - public function setDbEnds($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[] = CcShowInstancesPeer::ENDS; - } - } // if either are not null - - return $this; - } // setDbEnds() - - /** - * Set the value of [show_id] column. - * - * @param int $v new value - * @return CcShowInstances The current object (for fluent API support) - */ - public function setDbShowId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->show_id !== $v) { - $this->show_id = $v; - $this->modifiedColumns[] = CcShowInstancesPeer::SHOW_ID; - } - - if ($this->aCcShow !== null && $this->aCcShow->getDbId() !== $v) { - $this->aCcShow = null; - } - - return $this; - } // setDbShowId() - - /** - * Set the value of [record] column. - * - * @param int $v new value - * @return CcShowInstances The current object (for fluent API support) - */ - public function setDbRecord($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->record !== $v || $this->isNew()) { - $this->record = $v; - $this->modifiedColumns[] = CcShowInstancesPeer::RECORD; - } - - return $this; - } // setDbRecord() - - /** - * Set the value of [rebroadcast] column. - * - * @param int $v new value - * @return CcShowInstances The current object (for fluent API support) - */ - public function setDbRebroadcast($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->rebroadcast !== $v || $this->isNew()) { - $this->rebroadcast = $v; - $this->modifiedColumns[] = CcShowInstancesPeer::REBROADCAST; - } - - return $this; - } // setDbRebroadcast() - - /** - * Set the value of [instance_id] column. - * - * @param int $v new value - * @return CcShowInstances The current object (for fluent API support) - */ - public function setDbOriginalShow($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->instance_id !== $v) { - $this->instance_id = $v; - $this->modifiedColumns[] = CcShowInstancesPeer::INSTANCE_ID; - } - - if ($this->aCcShowInstancesRelatedByDbOriginalShow !== null && $this->aCcShowInstancesRelatedByDbOriginalShow->getDbId() !== $v) { - $this->aCcShowInstancesRelatedByDbOriginalShow = null; - } - - return $this; - } // setDbOriginalShow() - - /** - * Set the value of [file_id] column. - * - * @param int $v new value - * @return CcShowInstances The current object (for fluent API support) - */ - public function setDbRecordedFile($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->file_id !== $v) { - $this->file_id = $v; - $this->modifiedColumns[] = CcShowInstancesPeer::FILE_ID; - } - - if ($this->aCcFiles !== null && $this->aCcFiles->getDbId() !== $v) { - $this->aCcFiles = null; - } - - return $this; - } // setDbRecordedFile() - - /** - * Set the value of [time_filled] column. - * - * @param string $v new value - * @return CcShowInstances The current object (for fluent API support) - */ - public function setDbTimeFilled($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->time_filled !== $v || $this->isNew()) { - $this->time_filled = $v; - $this->modifiedColumns[] = CcShowInstancesPeer::TIME_FILLED; - } - - return $this; - } // setDbTimeFilled() - - /** - * Sets the value of [created] 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 CcShowInstances The current object (for fluent API support) - */ - public function setDbCreated($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->created !== null || $dt !== null ) { - // (nested ifs are a little easier to read in this case) - - $currNorm = ($this->created !== null && $tmpDt = new DateTime($this->created)) ? $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->created = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); - $this->modifiedColumns[] = CcShowInstancesPeer::CREATED; - } - } // if either are not null - - return $this; - } // setDbCreated() - - /** - * Sets the value of [last_scheduled] 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 CcShowInstances The current object (for fluent API support) - */ - public function setDbLastScheduled($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_scheduled !== null || $dt !== null ) { - // (nested ifs are a little easier to read in this case) - - $currNorm = ($this->last_scheduled !== null && $tmpDt = new DateTime($this->last_scheduled)) ? $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->last_scheduled = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); - $this->modifiedColumns[] = CcShowInstancesPeer::LAST_SCHEDULED; - } - } // if either are not null - - return $this; - } // setDbLastScheduled() - - /** - * Set the value of [modified_instance] column. - * - * @param boolean $v new value - * @return CcShowInstances The current object (for fluent API support) - */ - public function setDbModifiedInstance($v) - { - if ($v !== null) { - $v = (boolean) $v; - } - - if ($this->modified_instance !== $v || $this->isNew()) { - $this->modified_instance = $v; - $this->modifiedColumns[] = CcShowInstancesPeer::MODIFIED_INSTANCE; - } - - return $this; - } // setDbModifiedInstance() - - /** - * 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->record !== 0) { - return false; - } - - if ($this->rebroadcast !== 0) { - return false; - } - - if ($this->time_filled !== '00:00:00') { - return false; - } - - if ($this->modified_instance !== false) { - 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->starts = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->ends = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->show_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->record = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->rebroadcast = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; - $this->instance_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; - $this->file_id = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null; - $this->time_filled = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; - $this->created = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; - $this->last_scheduled = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; - $this->modified_instance = ($row[$startcol + 11] !== null) ? (boolean) $row[$startcol + 11] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 12; // 12 = CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcShowInstances 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->aCcShow !== null && $this->show_id !== $this->aCcShow->getDbId()) { - $this->aCcShow = null; - } - if ($this->aCcShowInstancesRelatedByDbOriginalShow !== null && $this->instance_id !== $this->aCcShowInstancesRelatedByDbOriginalShow->getDbId()) { - $this->aCcShowInstancesRelatedByDbOriginalShow = 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(CcShowInstancesPeer::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 = CcShowInstancesPeer::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->aCcShow = null; - $this->aCcShowInstancesRelatedByDbOriginalShow = null; - $this->aCcFiles = null; - $this->collCcShowInstancessRelatedByDbId = null; - - $this->collCcSchedules = null; - - $this->collCcPlayoutHistorys = 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(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcShowInstancesQuery::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(CcShowInstancesPeer::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); - CcShowInstancesPeer::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->aCcShow !== null) { - if ($this->aCcShow->isModified() || $this->aCcShow->isNew()) { - $affectedRows += $this->aCcShow->save($con); - } - $this->setCcShow($this->aCcShow); - } - - if ($this->aCcShowInstancesRelatedByDbOriginalShow !== null) { - if ($this->aCcShowInstancesRelatedByDbOriginalShow->isModified() || $this->aCcShowInstancesRelatedByDbOriginalShow->isNew()) { - $affectedRows += $this->aCcShowInstancesRelatedByDbOriginalShow->save($con); - } - $this->setCcShowInstancesRelatedByDbOriginalShow($this->aCcShowInstancesRelatedByDbOriginalShow); - } - - if ($this->aCcFiles !== null) { - if ($this->aCcFiles->isModified() || $this->aCcFiles->isNew()) { - $affectedRows += $this->aCcFiles->save($con); - } - $this->setCcFiles($this->aCcFiles); - } - - if ($this->isNew() ) { - $this->modifiedColumns[] = CcShowInstancesPeer::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(CcShowInstancesPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowInstancesPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows += 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows += CcShowInstancesPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - if ($this->collCcShowInstancessRelatedByDbId !== null) { - foreach ($this->collCcShowInstancessRelatedByDbId as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->collCcSchedules !== null) { - foreach ($this->collCcSchedules as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->collCcPlayoutHistorys !== null) { - foreach ($this->collCcPlayoutHistorys 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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcShow !== null) { - if (!$this->aCcShow->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcShow->getValidationFailures()); - } - } - - if ($this->aCcShowInstancesRelatedByDbOriginalShow !== null) { - if (!$this->aCcShowInstancesRelatedByDbOriginalShow->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcShowInstancesRelatedByDbOriginalShow->getValidationFailures()); - } - } - - if ($this->aCcFiles !== null) { - if (!$this->aCcFiles->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcFiles->getValidationFailures()); - } - } - - - if (($retval = CcShowInstancesPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collCcShowInstancessRelatedByDbId !== null) { - foreach ($this->collCcShowInstancessRelatedByDbId as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCcSchedules !== null) { - foreach ($this->collCcSchedules as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCcPlayoutHistorys !== null) { - foreach ($this->collCcPlayoutHistorys 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 = CcShowInstancesPeer::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->getDbStarts(); - break; - case 2: - return $this->getDbEnds(); - break; - case 3: - return $this->getDbShowId(); - break; - case 4: - return $this->getDbRecord(); - break; - case 5: - return $this->getDbRebroadcast(); - break; - case 6: - return $this->getDbOriginalShow(); - break; - case 7: - return $this->getDbRecordedFile(); - break; - case 8: - return $this->getDbTimeFilled(); - break; - case 9: - return $this->getDbCreated(); - break; - case 10: - return $this->getDbLastScheduled(); - break; - case 11: - return $this->getDbModifiedInstance(); - 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 = CcShowInstancesPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbStarts(), - $keys[2] => $this->getDbEnds(), - $keys[3] => $this->getDbShowId(), - $keys[4] => $this->getDbRecord(), - $keys[5] => $this->getDbRebroadcast(), - $keys[6] => $this->getDbOriginalShow(), - $keys[7] => $this->getDbRecordedFile(), - $keys[8] => $this->getDbTimeFilled(), - $keys[9] => $this->getDbCreated(), - $keys[10] => $this->getDbLastScheduled(), - $keys[11] => $this->getDbModifiedInstance(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCcShow) { - $result['CcShow'] = $this->aCcShow->toArray($keyType, $includeLazyLoadColumns, true); - } - if (null !== $this->aCcShowInstancesRelatedByDbOriginalShow) { - $result['CcShowInstancesRelatedByDbOriginalShow'] = $this->aCcShowInstancesRelatedByDbOriginalShow->toArray($keyType, $includeLazyLoadColumns, true); - } - if (null !== $this->aCcFiles) { - $result['CcFiles'] = $this->aCcFiles->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 = CcShowInstancesPeer::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->setDbStarts($value); - break; - case 2: - $this->setDbEnds($value); - break; - case 3: - $this->setDbShowId($value); - break; - case 4: - $this->setDbRecord($value); - break; - case 5: - $this->setDbRebroadcast($value); - break; - case 6: - $this->setDbOriginalShow($value); - break; - case 7: - $this->setDbRecordedFile($value); - break; - case 8: - $this->setDbTimeFilled($value); - break; - case 9: - $this->setDbCreated($value); - break; - case 10: - $this->setDbLastScheduled($value); - break; - case 11: - $this->setDbModifiedInstance($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 = CcShowInstancesPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbStarts($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbEnds($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbShowId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbRecord($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbRebroadcast($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDbOriginalShow($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setDbRecordedFile($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setDbTimeFilled($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setDbCreated($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setDbLastScheduled($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setDbModifiedInstance($arr[$keys[11]]); - } - - /** - * 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(CcShowInstancesPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcShowInstancesPeer::ID)) $criteria->add(CcShowInstancesPeer::ID, $this->id); - if ($this->isColumnModified(CcShowInstancesPeer::STARTS)) $criteria->add(CcShowInstancesPeer::STARTS, $this->starts); - if ($this->isColumnModified(CcShowInstancesPeer::ENDS)) $criteria->add(CcShowInstancesPeer::ENDS, $this->ends); - if ($this->isColumnModified(CcShowInstancesPeer::SHOW_ID)) $criteria->add(CcShowInstancesPeer::SHOW_ID, $this->show_id); - if ($this->isColumnModified(CcShowInstancesPeer::RECORD)) $criteria->add(CcShowInstancesPeer::RECORD, $this->record); - if ($this->isColumnModified(CcShowInstancesPeer::REBROADCAST)) $criteria->add(CcShowInstancesPeer::REBROADCAST, $this->rebroadcast); - if ($this->isColumnModified(CcShowInstancesPeer::INSTANCE_ID)) $criteria->add(CcShowInstancesPeer::INSTANCE_ID, $this->instance_id); - if ($this->isColumnModified(CcShowInstancesPeer::FILE_ID)) $criteria->add(CcShowInstancesPeer::FILE_ID, $this->file_id); - if ($this->isColumnModified(CcShowInstancesPeer::TIME_FILLED)) $criteria->add(CcShowInstancesPeer::TIME_FILLED, $this->time_filled); - if ($this->isColumnModified(CcShowInstancesPeer::CREATED)) $criteria->add(CcShowInstancesPeer::CREATED, $this->created); - if ($this->isColumnModified(CcShowInstancesPeer::LAST_SCHEDULED)) $criteria->add(CcShowInstancesPeer::LAST_SCHEDULED, $this->last_scheduled); - if ($this->isColumnModified(CcShowInstancesPeer::MODIFIED_INSTANCE)) $criteria->add(CcShowInstancesPeer::MODIFIED_INSTANCE, $this->modified_instance); - - 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(CcShowInstancesPeer::DATABASE_NAME); - $criteria->add(CcShowInstancesPeer::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 CcShowInstances (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->setDbStarts($this->starts); - $copyObj->setDbEnds($this->ends); - $copyObj->setDbShowId($this->show_id); - $copyObj->setDbRecord($this->record); - $copyObj->setDbRebroadcast($this->rebroadcast); - $copyObj->setDbOriginalShow($this->instance_id); - $copyObj->setDbRecordedFile($this->file_id); - $copyObj->setDbTimeFilled($this->time_filled); - $copyObj->setDbCreated($this->created); - $copyObj->setDbLastScheduled($this->last_scheduled); - $copyObj->setDbModifiedInstance($this->modified_instance); - - 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->getCcShowInstancessRelatedByDbId() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcShowInstancesRelatedByDbId($relObj->copy($deepCopy)); - } - } - - foreach ($this->getCcSchedules() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcSchedule($relObj->copy($deepCopy)); - } - } - - foreach ($this->getCcPlayoutHistorys() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcPlayoutHistory($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 CcShowInstances 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 CcShowInstancesPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcShowInstancesPeer(); - } - return self::$peer; - } - - /** - * Declares an association between this object and a CcShow object. - * - * @param CcShow $v - * @return CcShowInstances The current object (for fluent API support) - * @throws PropelException - */ - public function setCcShow(CcShow $v = null) - { - if ($v === null) { - $this->setDbShowId(NULL); - } else { - $this->setDbShowId($v->getDbId()); - } - - $this->aCcShow = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcShow object, it will not be re-added. - if ($v !== null) { - $v->addCcShowInstances($this); - } - - return $this; - } - - - /** - * Get the associated CcShow object - * - * @param PropelPDO Optional Connection object. - * @return CcShow The associated CcShow object. - * @throws PropelException - */ - public function getCcShow(PropelPDO $con = null) - { - if ($this->aCcShow === null && ($this->show_id !== null)) { - $this->aCcShow = CcShowQuery::create()->findPk($this->show_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->aCcShow->addCcShowInstancess($this); - */ - } - return $this->aCcShow; - } - - /** - * Declares an association between this object and a CcShowInstances object. - * - * @param CcShowInstances $v - * @return CcShowInstances The current object (for fluent API support) - * @throws PropelException - */ - public function setCcShowInstancesRelatedByDbOriginalShow(CcShowInstances $v = null) - { - if ($v === null) { - $this->setDbOriginalShow(NULL); - } else { - $this->setDbOriginalShow($v->getDbId()); - } - - $this->aCcShowInstancesRelatedByDbOriginalShow = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcShowInstances object, it will not be re-added. - if ($v !== null) { - $v->addCcShowInstancesRelatedByDbId($this); - } - - return $this; - } - - - /** - * Get the associated CcShowInstances object - * - * @param PropelPDO Optional Connection object. - * @return CcShowInstances The associated CcShowInstances object. - * @throws PropelException - */ - public function getCcShowInstancesRelatedByDbOriginalShow(PropelPDO $con = null) - { - if ($this->aCcShowInstancesRelatedByDbOriginalShow === null && ($this->instance_id !== null)) { - $this->aCcShowInstancesRelatedByDbOriginalShow = CcShowInstancesQuery::create()->findPk($this->instance_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->aCcShowInstancesRelatedByDbOriginalShow->addCcShowInstancessRelatedByDbId($this); - */ - } - return $this->aCcShowInstancesRelatedByDbOriginalShow; - } - - /** - * Declares an association between this object and a CcFiles object. - * - * @param CcFiles $v - * @return CcShowInstances The current object (for fluent API support) - * @throws PropelException - */ - public function setCcFiles(CcFiles $v = null) - { - if ($v === null) { - $this->setDbRecordedFile(NULL); - } else { - $this->setDbRecordedFile($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->addCcShowInstances($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->addCcShowInstancess($this); - */ - } - return $this->aCcFiles; - } - - /** - * Clears out the collCcShowInstancessRelatedByDbId 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 addCcShowInstancessRelatedByDbId() - */ - public function clearCcShowInstancessRelatedByDbId() - { - $this->collCcShowInstancessRelatedByDbId = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcShowInstancessRelatedByDbId collection. - * - * By default this just sets the collCcShowInstancessRelatedByDbId collection to an empty array (like clearcollCcShowInstancessRelatedByDbId()); - * 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 initCcShowInstancessRelatedByDbId() - { - $this->collCcShowInstancessRelatedByDbId = new PropelObjectCollection(); - $this->collCcShowInstancessRelatedByDbId->setModel('CcShowInstances'); - } - - /** - * Gets an array of CcShowInstances 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 CcShowInstances 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 CcShowInstances[] List of CcShowInstances objects - * @throws PropelException - */ - public function getCcShowInstancessRelatedByDbId($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcShowInstancessRelatedByDbId || null !== $criteria) { - if ($this->isNew() && null === $this->collCcShowInstancessRelatedByDbId) { - // return empty collection - $this->initCcShowInstancessRelatedByDbId(); - } else { - $collCcShowInstancessRelatedByDbId = CcShowInstancesQuery::create(null, $criteria) - ->filterByCcShowInstancesRelatedByDbOriginalShow($this) - ->find($con); - if (null !== $criteria) { - return $collCcShowInstancessRelatedByDbId; - } - $this->collCcShowInstancessRelatedByDbId = $collCcShowInstancessRelatedByDbId; - } - } - return $this->collCcShowInstancessRelatedByDbId; - } - - /** - * Returns the number of related CcShowInstances objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcShowInstances objects. - * @throws PropelException - */ - public function countCcShowInstancessRelatedByDbId(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcShowInstancessRelatedByDbId || null !== $criteria) { - if ($this->isNew() && null === $this->collCcShowInstancessRelatedByDbId) { - return 0; - } else { - $query = CcShowInstancesQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcShowInstancesRelatedByDbOriginalShow($this) - ->count($con); - } - } else { - return count($this->collCcShowInstancessRelatedByDbId); - } - } - - /** - * Method called to associate a CcShowInstances object to this object - * through the CcShowInstances foreign key attribute. - * - * @param CcShowInstances $l CcShowInstances - * @return void - * @throws PropelException - */ - public function addCcShowInstancesRelatedByDbId(CcShowInstances $l) - { - if ($this->collCcShowInstancessRelatedByDbId === null) { - $this->initCcShowInstancessRelatedByDbId(); - } - if (!$this->collCcShowInstancessRelatedByDbId->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcShowInstancessRelatedByDbId[]= $l; - $l->setCcShowInstancesRelatedByDbOriginalShow($this); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcShowInstances is new, it will return - * an empty collection; or if this CcShowInstances has previously - * been saved, it will retrieve related CcShowInstancessRelatedByDbId 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 CcShowInstances. - * - * @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 CcShowInstances[] List of CcShowInstances objects - */ - public function getCcShowInstancessRelatedByDbIdJoinCcShow($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcShowInstancesQuery::create(null, $criteria); - $query->joinWith('CcShow', $join_behavior); - - return $this->getCcShowInstancessRelatedByDbId($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcShowInstances is new, it will return - * an empty collection; or if this CcShowInstances has previously - * been saved, it will retrieve related CcShowInstancessRelatedByDbId 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 CcShowInstances. - * - * @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 CcShowInstances[] List of CcShowInstances objects - */ - public function getCcShowInstancessRelatedByDbIdJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcShowInstancesQuery::create(null, $criteria); - $query->joinWith('CcFiles', $join_behavior); - - return $this->getCcShowInstancessRelatedByDbId($query, $con); - } - - /** - * Clears out the collCcSchedules 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 addCcSchedules() - */ - public function clearCcSchedules() - { - $this->collCcSchedules = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcSchedules collection. - * - * By default this just sets the collCcSchedules collection to an empty array (like clearcollCcSchedules()); - * 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 initCcSchedules() - { - $this->collCcSchedules = new PropelObjectCollection(); - $this->collCcSchedules->setModel('CcSchedule'); - } - - /** - * Gets an array of CcSchedule 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 CcShowInstances 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 CcSchedule[] List of CcSchedule objects - * @throws PropelException - */ - public function getCcSchedules($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcSchedules || null !== $criteria) { - if ($this->isNew() && null === $this->collCcSchedules) { - // return empty collection - $this->initCcSchedules(); - } else { - $collCcSchedules = CcScheduleQuery::create(null, $criteria) - ->filterByCcShowInstances($this) - ->find($con); - if (null !== $criteria) { - return $collCcSchedules; - } - $this->collCcSchedules = $collCcSchedules; - } - } - return $this->collCcSchedules; - } - - /** - * Returns the number of related CcSchedule objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcSchedule objects. - * @throws PropelException - */ - public function countCcSchedules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcSchedules || null !== $criteria) { - if ($this->isNew() && null === $this->collCcSchedules) { - return 0; - } else { - $query = CcScheduleQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcShowInstances($this) - ->count($con); - } - } else { - return count($this->collCcSchedules); - } - } - - /** - * Method called to associate a CcSchedule object to this object - * through the CcSchedule foreign key attribute. - * - * @param CcSchedule $l CcSchedule - * @return void - * @throws PropelException - */ - public function addCcSchedule(CcSchedule $l) - { - if ($this->collCcSchedules === null) { - $this->initCcSchedules(); - } - if (!$this->collCcSchedules->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcSchedules[]= $l; - $l->setCcShowInstances($this); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcShowInstances is new, it will return - * an empty collection; or if this CcShowInstances has previously - * been saved, it will retrieve related CcSchedules 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 CcShowInstances. - * - * @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 CcSchedule[] List of CcSchedule objects - */ - public function getCcSchedulesJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcScheduleQuery::create(null, $criteria); - $query->joinWith('CcFiles', $join_behavior); - - return $this->getCcSchedules($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcShowInstances is new, it will return - * an empty collection; or if this CcShowInstances has previously - * been saved, it will retrieve related CcSchedules 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 CcShowInstances. - * - * @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 CcSchedule[] List of CcSchedule objects - */ - public function getCcSchedulesJoinCcWebstream($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcScheduleQuery::create(null, $criteria); - $query->joinWith('CcWebstream', $join_behavior); - - return $this->getCcSchedules($query, $con); - } - - /** - * Clears out the collCcPlayoutHistorys 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 addCcPlayoutHistorys() - */ - public function clearCcPlayoutHistorys() - { - $this->collCcPlayoutHistorys = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcPlayoutHistorys collection. - * - * By default this just sets the collCcPlayoutHistorys collection to an empty array (like clearcollCcPlayoutHistorys()); - * 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 initCcPlayoutHistorys() - { - $this->collCcPlayoutHistorys = new PropelObjectCollection(); - $this->collCcPlayoutHistorys->setModel('CcPlayoutHistory'); - } - - /** - * Gets an array of CcPlayoutHistory 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 CcShowInstances 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 CcPlayoutHistory[] List of CcPlayoutHistory objects - * @throws PropelException - */ - public function getCcPlayoutHistorys($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcPlayoutHistorys || null !== $criteria) { - if ($this->isNew() && null === $this->collCcPlayoutHistorys) { - // return empty collection - $this->initCcPlayoutHistorys(); - } else { - $collCcPlayoutHistorys = CcPlayoutHistoryQuery::create(null, $criteria) - ->filterByCcShowInstances($this) - ->find($con); - if (null !== $criteria) { - return $collCcPlayoutHistorys; - } - $this->collCcPlayoutHistorys = $collCcPlayoutHistorys; - } - } - return $this->collCcPlayoutHistorys; - } - - /** - * Returns the number of related CcPlayoutHistory objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcPlayoutHistory objects. - * @throws PropelException - */ - public function countCcPlayoutHistorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcPlayoutHistorys || null !== $criteria) { - if ($this->isNew() && null === $this->collCcPlayoutHistorys) { - return 0; - } else { - $query = CcPlayoutHistoryQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcShowInstances($this) - ->count($con); - } - } else { - return count($this->collCcPlayoutHistorys); - } - } - - /** - * Method called to associate a CcPlayoutHistory object to this object - * through the CcPlayoutHistory foreign key attribute. - * - * @param CcPlayoutHistory $l CcPlayoutHistory - * @return void - * @throws PropelException - */ - public function addCcPlayoutHistory(CcPlayoutHistory $l) - { - if ($this->collCcPlayoutHistorys === null) { - $this->initCcPlayoutHistorys(); - } - if (!$this->collCcPlayoutHistorys->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcPlayoutHistorys[]= $l; - $l->setCcShowInstances($this); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcShowInstances is new, it will return - * an empty collection; or if this CcShowInstances has previously - * been saved, it will retrieve related CcPlayoutHistorys 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 CcShowInstances. - * - * @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 CcPlayoutHistory[] List of CcPlayoutHistory objects - */ - public function getCcPlayoutHistorysJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcPlayoutHistoryQuery::create(null, $criteria); - $query->joinWith('CcFiles', $join_behavior); - - return $this->getCcPlayoutHistorys($query, $con); - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->starts = null; - $this->ends = null; - $this->show_id = null; - $this->record = null; - $this->rebroadcast = null; - $this->instance_id = null; - $this->file_id = null; - $this->time_filled = null; - $this->created = null; - $this->last_scheduled = null; - $this->modified_instance = 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->collCcShowInstancessRelatedByDbId) { - foreach ((array) $this->collCcShowInstancessRelatedByDbId as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCcSchedules) { - foreach ((array) $this->collCcSchedules as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCcPlayoutHistorys) { - foreach ((array) $this->collCcPlayoutHistorys as $o) { - $o->clearAllReferences($deep); - } - } - } // if ($deep) - - $this->collCcShowInstancessRelatedByDbId = null; - $this->collCcSchedules = null; - $this->collCcPlayoutHistorys = null; - $this->aCcShow = null; - $this->aCcShowInstancesRelatedByDbOriginalShow = null; - $this->aCcFiles = 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); - } - -} // BaseCcShowInstances + /** + * Peer class name + */ + const PEER = 'Airtime\\CcShowInstancesPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcShowInstancesPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the starts field. + * @var string + */ + protected $starts; + + /** + * The value for the ends field. + * @var string + */ + protected $ends; + + /** + * The value for the show_id field. + * @var int + */ + protected $show_id; + + /** + * The value for the record field. + * Note: this column has a database default value of: 0 + * @var int + */ + protected $record; + + /** + * The value for the rebroadcast field. + * Note: this column has a database default value of: 0 + * @var int + */ + protected $rebroadcast; + + /** + * The value for the instance_id field. + * @var int + */ + protected $instance_id; + + /** + * The value for the file_id field. + * @var int + */ + protected $file_id; + + /** + * The value for the time_filled field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $time_filled; + + /** + * The value for the created field. + * @var string + */ + protected $created; + + /** + * The value for the last_scheduled field. + * @var string + */ + protected $last_scheduled; + + /** + * The value for the modified_instance field. + * Note: this column has a database default value of: false + * @var boolean + */ + protected $modified_instance; + + /** + * @var CcShow + */ + protected $aCcShow; + + /** + * @var CcShowInstances + */ + protected $aCcShowInstancesRelatedByDbOriginalShow; + + /** + * @var CcFiles + */ + protected $aCcFiles; + + /** + * @var PropelObjectCollection|CcShowInstances[] Collection to store aggregation of CcShowInstances objects. + */ + protected $collCcShowInstancessRelatedByDbId; + protected $collCcShowInstancessRelatedByDbIdPartial; + + /** + * @var PropelObjectCollection|CcSchedule[] Collection to store aggregation of CcSchedule objects. + */ + protected $collCcSchedules; + protected $collCcSchedulesPartial; + + /** + * @var PropelObjectCollection|CcPlayoutHistory[] Collection to store aggregation of CcPlayoutHistory objects. + */ + protected $collCcPlayoutHistorys; + protected $collCcPlayoutHistorysPartial; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccShowInstancessRelatedByDbIdScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccSchedulesScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccPlayoutHistorysScheduledForDeletion = null; + + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->record = 0; + $this->rebroadcast = 0; + $this->time_filled = '00:00:00'; + $this->modified_instance = false; + } + + /** + * Initializes internal state of BaseCcShowInstances 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 [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 getDbStarts($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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + 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 getDbEnds($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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [show_id] column value. + * + * @return int + */ + public function getDbShowId() + { + + return $this->show_id; + } + + /** + * Get the [record] column value. + * + * @return int + */ + public function getDbRecord() + { + + return $this->record; + } + + /** + * Get the [rebroadcast] column value. + * + * @return int + */ + public function getDbRebroadcast() + { + + return $this->rebroadcast; + } + + /** + * Get the [instance_id] column value. + * + * @return int + */ + public function getDbOriginalShow() + { + + return $this->instance_id; + } + + /** + * Get the [file_id] column value. + * + * @return int + */ + public function getDbRecordedFile() + { + + return $this->file_id; + } + + /** + * Get the [time_filled] column value. + * + * @return string + */ + public function getDbTimeFilled() + { + + return $this->time_filled; + } + + /** + * Get the [optionally formatted] temporal [created] 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 getDbCreated($format = 'Y-m-d H:i:s') + { + if ($this->created === null) { + return null; + } + + + try { + $dt = new DateTime($this->created); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [optionally formatted] temporal [last_scheduled] 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 getDbLastScheduled($format = 'Y-m-d H:i:s') + { + if ($this->last_scheduled === null) { + return null; + } + + + try { + $dt = new DateTime($this->last_scheduled); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->last_scheduled, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [modified_instance] column value. + * + * @return boolean + */ + public function getDbModifiedInstance() + { + + return $this->modified_instance; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcShowInstancesPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * 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 strings are treated as null. + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbStarts($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->starts !== null || $dt !== null) { + $currentDateAsString = ($this->starts !== null && $tmpDt = new DateTime($this->starts)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->starts = $newDateAsString; + $this->modifiedColumns[] = CcShowInstancesPeer::STARTS; + } + } // if either are not null + + + return $this; + } // setDbStarts() + + /** + * 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 strings are treated as null. + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbEnds($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->ends !== null || $dt !== null) { + $currentDateAsString = ($this->ends !== null && $tmpDt = new DateTime($this->ends)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->ends = $newDateAsString; + $this->modifiedColumns[] = CcShowInstancesPeer::ENDS; + } + } // if either are not null + + + return $this; + } // setDbEnds() + + /** + * Set the value of [show_id] column. + * + * @param int $v new value + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbShowId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->show_id !== $v) { + $this->show_id = $v; + $this->modifiedColumns[] = CcShowInstancesPeer::SHOW_ID; + } + + if ($this->aCcShow !== null && $this->aCcShow->getDbId() !== $v) { + $this->aCcShow = null; + } + + + return $this; + } // setDbShowId() + + /** + * Set the value of [record] column. + * + * @param int $v new value + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbRecord($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->record !== $v) { + $this->record = $v; + $this->modifiedColumns[] = CcShowInstancesPeer::RECORD; + } + + + return $this; + } // setDbRecord() + + /** + * Set the value of [rebroadcast] column. + * + * @param int $v new value + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbRebroadcast($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->rebroadcast !== $v) { + $this->rebroadcast = $v; + $this->modifiedColumns[] = CcShowInstancesPeer::REBROADCAST; + } + + + return $this; + } // setDbRebroadcast() + + /** + * Set the value of [instance_id] column. + * + * @param int $v new value + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbOriginalShow($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->instance_id !== $v) { + $this->instance_id = $v; + $this->modifiedColumns[] = CcShowInstancesPeer::INSTANCE_ID; + } + + if ($this->aCcShowInstancesRelatedByDbOriginalShow !== null && $this->aCcShowInstancesRelatedByDbOriginalShow->getDbId() !== $v) { + $this->aCcShowInstancesRelatedByDbOriginalShow = null; + } + + + return $this; + } // setDbOriginalShow() + + /** + * Set the value of [file_id] column. + * + * @param int $v new value + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbRecordedFile($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->file_id !== $v) { + $this->file_id = $v; + $this->modifiedColumns[] = CcShowInstancesPeer::FILE_ID; + } + + if ($this->aCcFiles !== null && $this->aCcFiles->getDbId() !== $v) { + $this->aCcFiles = null; + } + + + return $this; + } // setDbRecordedFile() + + /** + * Set the value of [time_filled] column. + * + * @param string $v new value + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbTimeFilled($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->time_filled !== $v) { + $this->time_filled = $v; + $this->modifiedColumns[] = CcShowInstancesPeer::TIME_FILLED; + } + + + return $this; + } // setDbTimeFilled() + + /** + * Sets the value of [created] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbCreated($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->created !== null || $dt !== null) { + $currentDateAsString = ($this->created !== null && $tmpDt = new DateTime($this->created)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->created = $newDateAsString; + $this->modifiedColumns[] = CcShowInstancesPeer::CREATED; + } + } // if either are not null + + + return $this; + } // setDbCreated() + + /** + * Sets the value of [last_scheduled] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbLastScheduled($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->last_scheduled !== null || $dt !== null) { + $currentDateAsString = ($this->last_scheduled !== null && $tmpDt = new DateTime($this->last_scheduled)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->last_scheduled = $newDateAsString; + $this->modifiedColumns[] = CcShowInstancesPeer::LAST_SCHEDULED; + } + } // if either are not null + + + return $this; + } // setDbLastScheduled() + + /** + * Sets the value of the [modified_instance] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return CcShowInstances The current object (for fluent API support) + */ + public function setDbModifiedInstance($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->modified_instance !== $v) { + $this->modified_instance = $v; + $this->modifiedColumns[] = CcShowInstancesPeer::MODIFIED_INSTANCE; + } + + + return $this; + } // setDbModifiedInstance() + + /** + * 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->record !== 0) { + return false; + } + + if ($this->rebroadcast !== 0) { + return false; + } + + if ($this->time_filled !== '00:00:00') { + return false; + } + + if ($this->modified_instance !== false) { + 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 resultset 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->starts = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->ends = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->show_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; + $this->record = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; + $this->rebroadcast = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; + $this->instance_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; + $this->file_id = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null; + $this->time_filled = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->created = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->last_scheduled = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; + $this->modified_instance = ($row[$startcol + 11] !== null) ? (boolean) $row[$startcol + 11] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 12; // 12 = CcShowInstancesPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcShowInstances 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->aCcShow !== null && $this->show_id !== $this->aCcShow->getDbId()) { + $this->aCcShow = null; + } + if ($this->aCcShowInstancesRelatedByDbOriginalShow !== null && $this->instance_id !== $this->aCcShowInstancesRelatedByDbOriginalShow->getDbId()) { + $this->aCcShowInstancesRelatedByDbOriginalShow = 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(CcShowInstancesPeer::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 = CcShowInstancesPeer::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->aCcShow = null; + $this->aCcShowInstancesRelatedByDbOriginalShow = null; + $this->aCcFiles = null; + $this->collCcShowInstancessRelatedByDbId = null; + + $this->collCcSchedules = null; + + $this->collCcPlayoutHistorys = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcShowInstancesQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcShowInstancesPeer::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); + CcShowInstancesPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcShow !== null) { + if ($this->aCcShow->isModified() || $this->aCcShow->isNew()) { + $affectedRows += $this->aCcShow->save($con); + } + $this->setCcShow($this->aCcShow); + } + + if ($this->aCcShowInstancesRelatedByDbOriginalShow !== null) { + if ($this->aCcShowInstancesRelatedByDbOriginalShow->isModified() || $this->aCcShowInstancesRelatedByDbOriginalShow->isNew()) { + $affectedRows += $this->aCcShowInstancesRelatedByDbOriginalShow->save($con); + } + $this->setCcShowInstancesRelatedByDbOriginalShow($this->aCcShowInstancesRelatedByDbOriginalShow); + } + + if ($this->aCcFiles !== null) { + if ($this->aCcFiles->isModified() || $this->aCcFiles->isNew()) { + $affectedRows += $this->aCcFiles->save($con); + } + $this->setCcFiles($this->aCcFiles); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->ccShowInstancessRelatedByDbIdScheduledForDeletion !== null) { + if (!$this->ccShowInstancessRelatedByDbIdScheduledForDeletion->isEmpty()) { + CcShowInstancesQuery::create() + ->filterByPrimaryKeys($this->ccShowInstancessRelatedByDbIdScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccShowInstancessRelatedByDbIdScheduledForDeletion = null; + } + } + + if ($this->collCcShowInstancessRelatedByDbId !== null) { + foreach ($this->collCcShowInstancessRelatedByDbId as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ccSchedulesScheduledForDeletion !== null) { + if (!$this->ccSchedulesScheduledForDeletion->isEmpty()) { + CcScheduleQuery::create() + ->filterByPrimaryKeys($this->ccSchedulesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccSchedulesScheduledForDeletion = null; + } + } + + if ($this->collCcSchedules !== null) { + foreach ($this->collCcSchedules as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ccPlayoutHistorysScheduledForDeletion !== null) { + if (!$this->ccPlayoutHistorysScheduledForDeletion->isEmpty()) { + foreach ($this->ccPlayoutHistorysScheduledForDeletion as $ccPlayoutHistory) { + // need to save related object because we set the relation to null + $ccPlayoutHistory->save($con); + } + $this->ccPlayoutHistorysScheduledForDeletion = null; + } + } + + if ($this->collCcPlayoutHistorys !== null) { + foreach ($this->collCcPlayoutHistorys as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcShowInstancesPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcShowInstancesPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_show_instances_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcShowInstancesPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcShowInstancesPeer::STARTS)) { + $modifiedColumns[':p' . $index++] = '"starts"'; + } + if ($this->isColumnModified(CcShowInstancesPeer::ENDS)) { + $modifiedColumns[':p' . $index++] = '"ends"'; + } + if ($this->isColumnModified(CcShowInstancesPeer::SHOW_ID)) { + $modifiedColumns[':p' . $index++] = '"show_id"'; + } + if ($this->isColumnModified(CcShowInstancesPeer::RECORD)) { + $modifiedColumns[':p' . $index++] = '"record"'; + } + if ($this->isColumnModified(CcShowInstancesPeer::REBROADCAST)) { + $modifiedColumns[':p' . $index++] = '"rebroadcast"'; + } + if ($this->isColumnModified(CcShowInstancesPeer::INSTANCE_ID)) { + $modifiedColumns[':p' . $index++] = '"instance_id"'; + } + if ($this->isColumnModified(CcShowInstancesPeer::FILE_ID)) { + $modifiedColumns[':p' . $index++] = '"file_id"'; + } + if ($this->isColumnModified(CcShowInstancesPeer::TIME_FILLED)) { + $modifiedColumns[':p' . $index++] = '"time_filled"'; + } + if ($this->isColumnModified(CcShowInstancesPeer::CREATED)) { + $modifiedColumns[':p' . $index++] = '"created"'; + } + if ($this->isColumnModified(CcShowInstancesPeer::LAST_SCHEDULED)) { + $modifiedColumns[':p' . $index++] = '"last_scheduled"'; + } + if ($this->isColumnModified(CcShowInstancesPeer::MODIFIED_INSTANCE)) { + $modifiedColumns[':p' . $index++] = '"modified_instance"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_show_instances" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"starts"': + $stmt->bindValue($identifier, $this->starts, PDO::PARAM_STR); + break; + case '"ends"': + $stmt->bindValue($identifier, $this->ends, PDO::PARAM_STR); + break; + case '"show_id"': + $stmt->bindValue($identifier, $this->show_id, PDO::PARAM_INT); + break; + case '"record"': + $stmt->bindValue($identifier, $this->record, PDO::PARAM_INT); + break; + case '"rebroadcast"': + $stmt->bindValue($identifier, $this->rebroadcast, PDO::PARAM_INT); + break; + case '"instance_id"': + $stmt->bindValue($identifier, $this->instance_id, PDO::PARAM_INT); + break; + case '"file_id"': + $stmt->bindValue($identifier, $this->file_id, PDO::PARAM_INT); + break; + case '"time_filled"': + $stmt->bindValue($identifier, $this->time_filled, PDO::PARAM_STR); + break; + case '"created"': + $stmt->bindValue($identifier, $this->created, PDO::PARAM_STR); + break; + case '"last_scheduled"': + $stmt->bindValue($identifier, $this->last_scheduled, PDO::PARAM_STR); + break; + case '"modified_instance"': + $stmt->bindValue($identifier, $this->modified_instance, PDO::PARAM_BOOL); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcShow !== null) { + if (!$this->aCcShow->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcShow->getValidationFailures()); + } + } + + if ($this->aCcShowInstancesRelatedByDbOriginalShow !== null) { + if (!$this->aCcShowInstancesRelatedByDbOriginalShow->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcShowInstancesRelatedByDbOriginalShow->getValidationFailures()); + } + } + + if ($this->aCcFiles !== null) { + if (!$this->aCcFiles->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcFiles->getValidationFailures()); + } + } + + + if (($retval = CcShowInstancesPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collCcShowInstancessRelatedByDbId !== null) { + foreach ($this->collCcShowInstancessRelatedByDbId as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collCcSchedules !== null) { + foreach ($this->collCcSchedules as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collCcPlayoutHistorys !== null) { + foreach ($this->collCcPlayoutHistorys 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcShowInstancesPeer::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->getDbStarts(); + break; + case 2: + return $this->getDbEnds(); + break; + case 3: + return $this->getDbShowId(); + break; + case 4: + return $this->getDbRecord(); + break; + case 5: + return $this->getDbRebroadcast(); + break; + case 6: + return $this->getDbOriginalShow(); + break; + case 7: + return $this->getDbRecordedFile(); + break; + case 8: + return $this->getDbTimeFilled(); + break; + case 9: + return $this->getDbCreated(); + break; + case 10: + return $this->getDbLastScheduled(); + break; + case 11: + return $this->getDbModifiedInstance(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcShowInstances'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcShowInstances'][$this->getPrimaryKey()] = true; + $keys = CcShowInstancesPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbStarts(), + $keys[2] => $this->getDbEnds(), + $keys[3] => $this->getDbShowId(), + $keys[4] => $this->getDbRecord(), + $keys[5] => $this->getDbRebroadcast(), + $keys[6] => $this->getDbOriginalShow(), + $keys[7] => $this->getDbRecordedFile(), + $keys[8] => $this->getDbTimeFilled(), + $keys[9] => $this->getDbCreated(), + $keys[10] => $this->getDbLastScheduled(), + $keys[11] => $this->getDbModifiedInstance(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcShow) { + $result['CcShow'] = $this->aCcShow->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aCcShowInstancesRelatedByDbOriginalShow) { + $result['CcShowInstancesRelatedByDbOriginalShow'] = $this->aCcShowInstancesRelatedByDbOriginalShow->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aCcFiles) { + $result['CcFiles'] = $this->aCcFiles->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collCcShowInstancessRelatedByDbId) { + $result['CcShowInstancessRelatedByDbId'] = $this->collCcShowInstancessRelatedByDbId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCcSchedules) { + $result['CcSchedules'] = $this->collCcSchedules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCcPlayoutHistorys) { + $result['CcPlayoutHistorys'] = $this->collCcPlayoutHistorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcShowInstancesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbStarts($value); + break; + case 2: + $this->setDbEnds($value); + break; + case 3: + $this->setDbShowId($value); + break; + case 4: + $this->setDbRecord($value); + break; + case 5: + $this->setDbRebroadcast($value); + break; + case 6: + $this->setDbOriginalShow($value); + break; + case 7: + $this->setDbRecordedFile($value); + break; + case 8: + $this->setDbTimeFilled($value); + break; + case 9: + $this->setDbCreated($value); + break; + case 10: + $this->setDbLastScheduled($value); + break; + case 11: + $this->setDbModifiedInstance($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcShowInstancesPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbStarts($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbEnds($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbShowId($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbRecord($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbRebroadcast($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbOriginalShow($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbRecordedFile($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setDbTimeFilled($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDbCreated($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setDbLastScheduled($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setDbModifiedInstance($arr[$keys[11]]); + } + + /** + * 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(CcShowInstancesPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcShowInstancesPeer::ID)) $criteria->add(CcShowInstancesPeer::ID, $this->id); + if ($this->isColumnModified(CcShowInstancesPeer::STARTS)) $criteria->add(CcShowInstancesPeer::STARTS, $this->starts); + if ($this->isColumnModified(CcShowInstancesPeer::ENDS)) $criteria->add(CcShowInstancesPeer::ENDS, $this->ends); + if ($this->isColumnModified(CcShowInstancesPeer::SHOW_ID)) $criteria->add(CcShowInstancesPeer::SHOW_ID, $this->show_id); + if ($this->isColumnModified(CcShowInstancesPeer::RECORD)) $criteria->add(CcShowInstancesPeer::RECORD, $this->record); + if ($this->isColumnModified(CcShowInstancesPeer::REBROADCAST)) $criteria->add(CcShowInstancesPeer::REBROADCAST, $this->rebroadcast); + if ($this->isColumnModified(CcShowInstancesPeer::INSTANCE_ID)) $criteria->add(CcShowInstancesPeer::INSTANCE_ID, $this->instance_id); + if ($this->isColumnModified(CcShowInstancesPeer::FILE_ID)) $criteria->add(CcShowInstancesPeer::FILE_ID, $this->file_id); + if ($this->isColumnModified(CcShowInstancesPeer::TIME_FILLED)) $criteria->add(CcShowInstancesPeer::TIME_FILLED, $this->time_filled); + if ($this->isColumnModified(CcShowInstancesPeer::CREATED)) $criteria->add(CcShowInstancesPeer::CREATED, $this->created); + if ($this->isColumnModified(CcShowInstancesPeer::LAST_SCHEDULED)) $criteria->add(CcShowInstancesPeer::LAST_SCHEDULED, $this->last_scheduled); + if ($this->isColumnModified(CcShowInstancesPeer::MODIFIED_INSTANCE)) $criteria->add(CcShowInstancesPeer::MODIFIED_INSTANCE, $this->modified_instance); + + 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(CcShowInstancesPeer::DATABASE_NAME); + $criteria->add(CcShowInstancesPeer::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 CcShowInstances (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbStarts($this->getDbStarts()); + $copyObj->setDbEnds($this->getDbEnds()); + $copyObj->setDbShowId($this->getDbShowId()); + $copyObj->setDbRecord($this->getDbRecord()); + $copyObj->setDbRebroadcast($this->getDbRebroadcast()); + $copyObj->setDbOriginalShow($this->getDbOriginalShow()); + $copyObj->setDbRecordedFile($this->getDbRecordedFile()); + $copyObj->setDbTimeFilled($this->getDbTimeFilled()); + $copyObj->setDbCreated($this->getDbCreated()); + $copyObj->setDbLastScheduled($this->getDbLastScheduled()); + $copyObj->setDbModifiedInstance($this->getDbModifiedInstance()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + foreach ($this->getCcShowInstancessRelatedByDbId() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcShowInstancesRelatedByDbId($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCcSchedules() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcSchedule($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCcPlayoutHistorys() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcPlayoutHistory($relObj->copy($deepCopy)); + } + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcShowInstances 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 CcShowInstancesPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcShowInstancesPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a CcShow object. + * + * @param CcShow $v + * @return CcShowInstances The current object (for fluent API support) + * @throws PropelException + */ + public function setCcShow(CcShow $v = null) + { + if ($v === null) { + $this->setDbShowId(NULL); + } else { + $this->setDbShowId($v->getDbId()); + } + + $this->aCcShow = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcShow object, it will not be re-added. + if ($v !== null) { + $v->addCcShowInstances($this); + } + + + return $this; + } + + + /** + * Get the associated CcShow object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcShow The associated CcShow object. + * @throws PropelException + */ + public function getCcShow(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcShow === null && ($this->show_id !== null) && $doQuery) { + $this->aCcShow = CcShowQuery::create()->findPk($this->show_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->aCcShow->addCcShowInstancess($this); + */ + } + + return $this->aCcShow; + } + + /** + * Declares an association between this object and a CcShowInstances object. + * + * @param CcShowInstances $v + * @return CcShowInstances The current object (for fluent API support) + * @throws PropelException + */ + public function setCcShowInstancesRelatedByDbOriginalShow(CcShowInstances $v = null) + { + if ($v === null) { + $this->setDbOriginalShow(NULL); + } else { + $this->setDbOriginalShow($v->getDbId()); + } + + $this->aCcShowInstancesRelatedByDbOriginalShow = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcShowInstances object, it will not be re-added. + if ($v !== null) { + $v->addCcShowInstancesRelatedByDbId($this); + } + + + return $this; + } + + + /** + * Get the associated CcShowInstances object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcShowInstances The associated CcShowInstances object. + * @throws PropelException + */ + public function getCcShowInstancesRelatedByDbOriginalShow(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcShowInstancesRelatedByDbOriginalShow === null && ($this->instance_id !== null) && $doQuery) { + $this->aCcShowInstancesRelatedByDbOriginalShow = CcShowInstancesQuery::create()->findPk($this->instance_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->aCcShowInstancesRelatedByDbOriginalShow->addCcShowInstancessRelatedByDbId($this); + */ + } + + return $this->aCcShowInstancesRelatedByDbOriginalShow; + } + + /** + * Declares an association between this object and a CcFiles object. + * + * @param CcFiles $v + * @return CcShowInstances The current object (for fluent API support) + * @throws PropelException + */ + public function setCcFiles(CcFiles $v = null) + { + if ($v === null) { + $this->setDbRecordedFile(NULL); + } else { + $this->setDbRecordedFile($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->addCcShowInstances($this); + } + + + return $this; + } + + + /** + * Get the associated CcFiles object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcFiles The associated CcFiles object. + * @throws PropelException + */ + public function getCcFiles(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcFiles === null && ($this->file_id !== null) && $doQuery) { + $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->addCcShowInstancess($this); + */ + } + + return $this->aCcFiles; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('CcShowInstancesRelatedByDbId' == $relationName) { + $this->initCcShowInstancessRelatedByDbId(); + } + if ('CcSchedule' == $relationName) { + $this->initCcSchedules(); + } + if ('CcPlayoutHistory' == $relationName) { + $this->initCcPlayoutHistorys(); + } + } + + /** + * Clears out the collCcShowInstancessRelatedByDbId 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 CcShowInstances The current object (for fluent API support) + * @see addCcShowInstancessRelatedByDbId() + */ + public function clearCcShowInstancessRelatedByDbId() + { + $this->collCcShowInstancessRelatedByDbId = null; // important to set this to null since that means it is uninitialized + $this->collCcShowInstancessRelatedByDbIdPartial = null; + + return $this; + } + + /** + * reset is the collCcShowInstancessRelatedByDbId collection loaded partially + * + * @return void + */ + public function resetPartialCcShowInstancessRelatedByDbId($v = true) + { + $this->collCcShowInstancessRelatedByDbIdPartial = $v; + } + + /** + * Initializes the collCcShowInstancessRelatedByDbId collection. + * + * By default this just sets the collCcShowInstancessRelatedByDbId collection to an empty array (like clearcollCcShowInstancessRelatedByDbId()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcShowInstancessRelatedByDbId($overrideExisting = true) + { + if (null !== $this->collCcShowInstancessRelatedByDbId && !$overrideExisting) { + return; + } + $this->collCcShowInstancessRelatedByDbId = new PropelObjectCollection(); + $this->collCcShowInstancessRelatedByDbId->setModel('CcShowInstances'); + } + + /** + * Gets an array of CcShowInstances 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 CcShowInstances 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 PropelObjectCollection|CcShowInstances[] List of CcShowInstances objects + * @throws PropelException + */ + public function getCcShowInstancessRelatedByDbId($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcShowInstancessRelatedByDbIdPartial && !$this->isNew(); + if (null === $this->collCcShowInstancessRelatedByDbId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcShowInstancessRelatedByDbId) { + // return empty collection + $this->initCcShowInstancessRelatedByDbId(); + } else { + $collCcShowInstancessRelatedByDbId = CcShowInstancesQuery::create(null, $criteria) + ->filterByCcShowInstancesRelatedByDbOriginalShow($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcShowInstancessRelatedByDbIdPartial && count($collCcShowInstancessRelatedByDbId)) { + $this->initCcShowInstancessRelatedByDbId(false); + + foreach ($collCcShowInstancessRelatedByDbId as $obj) { + if (false == $this->collCcShowInstancessRelatedByDbId->contains($obj)) { + $this->collCcShowInstancessRelatedByDbId->append($obj); + } + } + + $this->collCcShowInstancessRelatedByDbIdPartial = true; + } + + $collCcShowInstancessRelatedByDbId->getInternalIterator()->rewind(); + + return $collCcShowInstancessRelatedByDbId; + } + + if ($partial && $this->collCcShowInstancessRelatedByDbId) { + foreach ($this->collCcShowInstancessRelatedByDbId as $obj) { + if ($obj->isNew()) { + $collCcShowInstancessRelatedByDbId[] = $obj; + } + } + } + + $this->collCcShowInstancessRelatedByDbId = $collCcShowInstancessRelatedByDbId; + $this->collCcShowInstancessRelatedByDbIdPartial = false; + } + } + + return $this->collCcShowInstancessRelatedByDbId; + } + + /** + * Sets a collection of CcShowInstancesRelatedByDbId objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccShowInstancessRelatedByDbId A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcShowInstances The current object (for fluent API support) + */ + public function setCcShowInstancessRelatedByDbId(PropelCollection $ccShowInstancessRelatedByDbId, PropelPDO $con = null) + { + $ccShowInstancessRelatedByDbIdToDelete = $this->getCcShowInstancessRelatedByDbId(new Criteria(), $con)->diff($ccShowInstancessRelatedByDbId); + + + $this->ccShowInstancessRelatedByDbIdScheduledForDeletion = $ccShowInstancessRelatedByDbIdToDelete; + + foreach ($ccShowInstancessRelatedByDbIdToDelete as $ccShowInstancesRelatedByDbIdRemoved) { + $ccShowInstancesRelatedByDbIdRemoved->setCcShowInstancesRelatedByDbOriginalShow(null); + } + + $this->collCcShowInstancessRelatedByDbId = null; + foreach ($ccShowInstancessRelatedByDbId as $ccShowInstancesRelatedByDbId) { + $this->addCcShowInstancesRelatedByDbId($ccShowInstancesRelatedByDbId); + } + + $this->collCcShowInstancessRelatedByDbId = $ccShowInstancessRelatedByDbId; + $this->collCcShowInstancessRelatedByDbIdPartial = false; + + return $this; + } + + /** + * Returns the number of related CcShowInstances objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcShowInstances objects. + * @throws PropelException + */ + public function countCcShowInstancessRelatedByDbId(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcShowInstancessRelatedByDbIdPartial && !$this->isNew(); + if (null === $this->collCcShowInstancessRelatedByDbId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcShowInstancessRelatedByDbId) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcShowInstancessRelatedByDbId()); + } + $query = CcShowInstancesQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcShowInstancesRelatedByDbOriginalShow($this) + ->count($con); + } + + return count($this->collCcShowInstancessRelatedByDbId); + } + + /** + * Method called to associate a CcShowInstances object to this object + * through the CcShowInstances foreign key attribute. + * + * @param CcShowInstances $l CcShowInstances + * @return CcShowInstances The current object (for fluent API support) + */ + public function addCcShowInstancesRelatedByDbId(CcShowInstances $l) + { + if ($this->collCcShowInstancessRelatedByDbId === null) { + $this->initCcShowInstancessRelatedByDbId(); + $this->collCcShowInstancessRelatedByDbIdPartial = true; + } + + if (!in_array($l, $this->collCcShowInstancessRelatedByDbId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcShowInstancesRelatedByDbId($l); + + if ($this->ccShowInstancessRelatedByDbIdScheduledForDeletion and $this->ccShowInstancessRelatedByDbIdScheduledForDeletion->contains($l)) { + $this->ccShowInstancessRelatedByDbIdScheduledForDeletion->remove($this->ccShowInstancessRelatedByDbIdScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcShowInstancesRelatedByDbId $ccShowInstancesRelatedByDbId The ccShowInstancesRelatedByDbId object to add. + */ + protected function doAddCcShowInstancesRelatedByDbId($ccShowInstancesRelatedByDbId) + { + $this->collCcShowInstancessRelatedByDbId[]= $ccShowInstancesRelatedByDbId; + $ccShowInstancesRelatedByDbId->setCcShowInstancesRelatedByDbOriginalShow($this); + } + + /** + * @param CcShowInstancesRelatedByDbId $ccShowInstancesRelatedByDbId The ccShowInstancesRelatedByDbId object to remove. + * @return CcShowInstances The current object (for fluent API support) + */ + public function removeCcShowInstancesRelatedByDbId($ccShowInstancesRelatedByDbId) + { + if ($this->getCcShowInstancessRelatedByDbId()->contains($ccShowInstancesRelatedByDbId)) { + $this->collCcShowInstancessRelatedByDbId->remove($this->collCcShowInstancessRelatedByDbId->search($ccShowInstancesRelatedByDbId)); + if (null === $this->ccShowInstancessRelatedByDbIdScheduledForDeletion) { + $this->ccShowInstancessRelatedByDbIdScheduledForDeletion = clone $this->collCcShowInstancessRelatedByDbId; + $this->ccShowInstancessRelatedByDbIdScheduledForDeletion->clear(); + } + $this->ccShowInstancessRelatedByDbIdScheduledForDeletion[]= $ccShowInstancesRelatedByDbId; + $ccShowInstancesRelatedByDbId->setCcShowInstancesRelatedByDbOriginalShow(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcShowInstances is new, it will return + * an empty collection; or if this CcShowInstances has previously + * been saved, it will retrieve related CcShowInstancessRelatedByDbId 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 CcShowInstances. + * + * @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 PropelObjectCollection|CcShowInstances[] List of CcShowInstances objects + */ + public function getCcShowInstancessRelatedByDbIdJoinCcShow($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcShowInstancesQuery::create(null, $criteria); + $query->joinWith('CcShow', $join_behavior); + + return $this->getCcShowInstancessRelatedByDbId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcShowInstances is new, it will return + * an empty collection; or if this CcShowInstances has previously + * been saved, it will retrieve related CcShowInstancessRelatedByDbId 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 CcShowInstances. + * + * @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 PropelObjectCollection|CcShowInstances[] List of CcShowInstances objects + */ + public function getCcShowInstancessRelatedByDbIdJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcShowInstancesQuery::create(null, $criteria); + $query->joinWith('CcFiles', $join_behavior); + + return $this->getCcShowInstancessRelatedByDbId($query, $con); + } + + /** + * Clears out the collCcSchedules 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 CcShowInstances The current object (for fluent API support) + * @see addCcSchedules() + */ + public function clearCcSchedules() + { + $this->collCcSchedules = null; // important to set this to null since that means it is uninitialized + $this->collCcSchedulesPartial = null; + + return $this; + } + + /** + * reset is the collCcSchedules collection loaded partially + * + * @return void + */ + public function resetPartialCcSchedules($v = true) + { + $this->collCcSchedulesPartial = $v; + } + + /** + * Initializes the collCcSchedules collection. + * + * By default this just sets the collCcSchedules collection to an empty array (like clearcollCcSchedules()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcSchedules($overrideExisting = true) + { + if (null !== $this->collCcSchedules && !$overrideExisting) { + return; + } + $this->collCcSchedules = new PropelObjectCollection(); + $this->collCcSchedules->setModel('CcSchedule'); + } + + /** + * Gets an array of CcSchedule 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 CcShowInstances 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 PropelObjectCollection|CcSchedule[] List of CcSchedule objects + * @throws PropelException + */ + public function getCcSchedules($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcSchedulesPartial && !$this->isNew(); + if (null === $this->collCcSchedules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcSchedules) { + // return empty collection + $this->initCcSchedules(); + } else { + $collCcSchedules = CcScheduleQuery::create(null, $criteria) + ->filterByCcShowInstances($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcSchedulesPartial && count($collCcSchedules)) { + $this->initCcSchedules(false); + + foreach ($collCcSchedules as $obj) { + if (false == $this->collCcSchedules->contains($obj)) { + $this->collCcSchedules->append($obj); + } + } + + $this->collCcSchedulesPartial = true; + } + + $collCcSchedules->getInternalIterator()->rewind(); + + return $collCcSchedules; + } + + if ($partial && $this->collCcSchedules) { + foreach ($this->collCcSchedules as $obj) { + if ($obj->isNew()) { + $collCcSchedules[] = $obj; + } + } + } + + $this->collCcSchedules = $collCcSchedules; + $this->collCcSchedulesPartial = false; + } + } + + return $this->collCcSchedules; + } + + /** + * Sets a collection of CcSchedule objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccSchedules A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcShowInstances The current object (for fluent API support) + */ + public function setCcSchedules(PropelCollection $ccSchedules, PropelPDO $con = null) + { + $ccSchedulesToDelete = $this->getCcSchedules(new Criteria(), $con)->diff($ccSchedules); + + + $this->ccSchedulesScheduledForDeletion = $ccSchedulesToDelete; + + foreach ($ccSchedulesToDelete as $ccScheduleRemoved) { + $ccScheduleRemoved->setCcShowInstances(null); + } + + $this->collCcSchedules = null; + foreach ($ccSchedules as $ccSchedule) { + $this->addCcSchedule($ccSchedule); + } + + $this->collCcSchedules = $ccSchedules; + $this->collCcSchedulesPartial = false; + + return $this; + } + + /** + * Returns the number of related CcSchedule objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcSchedule objects. + * @throws PropelException + */ + public function countCcSchedules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcSchedulesPartial && !$this->isNew(); + if (null === $this->collCcSchedules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcSchedules) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcSchedules()); + } + $query = CcScheduleQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcShowInstances($this) + ->count($con); + } + + return count($this->collCcSchedules); + } + + /** + * Method called to associate a CcSchedule object to this object + * through the CcSchedule foreign key attribute. + * + * @param CcSchedule $l CcSchedule + * @return CcShowInstances The current object (for fluent API support) + */ + public function addCcSchedule(CcSchedule $l) + { + if ($this->collCcSchedules === null) { + $this->initCcSchedules(); + $this->collCcSchedulesPartial = true; + } + + if (!in_array($l, $this->collCcSchedules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcSchedule($l); + + if ($this->ccSchedulesScheduledForDeletion and $this->ccSchedulesScheduledForDeletion->contains($l)) { + $this->ccSchedulesScheduledForDeletion->remove($this->ccSchedulesScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcSchedule $ccSchedule The ccSchedule object to add. + */ + protected function doAddCcSchedule($ccSchedule) + { + $this->collCcSchedules[]= $ccSchedule; + $ccSchedule->setCcShowInstances($this); + } + + /** + * @param CcSchedule $ccSchedule The ccSchedule object to remove. + * @return CcShowInstances The current object (for fluent API support) + */ + public function removeCcSchedule($ccSchedule) + { + if ($this->getCcSchedules()->contains($ccSchedule)) { + $this->collCcSchedules->remove($this->collCcSchedules->search($ccSchedule)); + if (null === $this->ccSchedulesScheduledForDeletion) { + $this->ccSchedulesScheduledForDeletion = clone $this->collCcSchedules; + $this->ccSchedulesScheduledForDeletion->clear(); + } + $this->ccSchedulesScheduledForDeletion[]= clone $ccSchedule; + $ccSchedule->setCcShowInstances(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcShowInstances is new, it will return + * an empty collection; or if this CcShowInstances has previously + * been saved, it will retrieve related CcSchedules 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 CcShowInstances. + * + * @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 PropelObjectCollection|CcSchedule[] List of CcSchedule objects + */ + public function getCcSchedulesJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcScheduleQuery::create(null, $criteria); + $query->joinWith('CcFiles', $join_behavior); + + return $this->getCcSchedules($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcShowInstances is new, it will return + * an empty collection; or if this CcShowInstances has previously + * been saved, it will retrieve related CcSchedules 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 CcShowInstances. + * + * @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 PropelObjectCollection|CcSchedule[] List of CcSchedule objects + */ + public function getCcSchedulesJoinCcWebstream($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcScheduleQuery::create(null, $criteria); + $query->joinWith('CcWebstream', $join_behavior); + + return $this->getCcSchedules($query, $con); + } + + /** + * Clears out the collCcPlayoutHistorys 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 CcShowInstances The current object (for fluent API support) + * @see addCcPlayoutHistorys() + */ + public function clearCcPlayoutHistorys() + { + $this->collCcPlayoutHistorys = null; // important to set this to null since that means it is uninitialized + $this->collCcPlayoutHistorysPartial = null; + + return $this; + } + + /** + * reset is the collCcPlayoutHistorys collection loaded partially + * + * @return void + */ + public function resetPartialCcPlayoutHistorys($v = true) + { + $this->collCcPlayoutHistorysPartial = $v; + } + + /** + * Initializes the collCcPlayoutHistorys collection. + * + * By default this just sets the collCcPlayoutHistorys collection to an empty array (like clearcollCcPlayoutHistorys()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcPlayoutHistorys($overrideExisting = true) + { + if (null !== $this->collCcPlayoutHistorys && !$overrideExisting) { + return; + } + $this->collCcPlayoutHistorys = new PropelObjectCollection(); + $this->collCcPlayoutHistorys->setModel('CcPlayoutHistory'); + } + + /** + * Gets an array of CcPlayoutHistory 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 CcShowInstances 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 PropelObjectCollection|CcPlayoutHistory[] List of CcPlayoutHistory objects + * @throws PropelException + */ + public function getCcPlayoutHistorys($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcPlayoutHistorysPartial && !$this->isNew(); + if (null === $this->collCcPlayoutHistorys || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPlayoutHistorys) { + // return empty collection + $this->initCcPlayoutHistorys(); + } else { + $collCcPlayoutHistorys = CcPlayoutHistoryQuery::create(null, $criteria) + ->filterByCcShowInstances($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcPlayoutHistorysPartial && count($collCcPlayoutHistorys)) { + $this->initCcPlayoutHistorys(false); + + foreach ($collCcPlayoutHistorys as $obj) { + if (false == $this->collCcPlayoutHistorys->contains($obj)) { + $this->collCcPlayoutHistorys->append($obj); + } + } + + $this->collCcPlayoutHistorysPartial = true; + } + + $collCcPlayoutHistorys->getInternalIterator()->rewind(); + + return $collCcPlayoutHistorys; + } + + if ($partial && $this->collCcPlayoutHistorys) { + foreach ($this->collCcPlayoutHistorys as $obj) { + if ($obj->isNew()) { + $collCcPlayoutHistorys[] = $obj; + } + } + } + + $this->collCcPlayoutHistorys = $collCcPlayoutHistorys; + $this->collCcPlayoutHistorysPartial = false; + } + } + + return $this->collCcPlayoutHistorys; + } + + /** + * Sets a collection of CcPlayoutHistory objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccPlayoutHistorys A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcShowInstances The current object (for fluent API support) + */ + public function setCcPlayoutHistorys(PropelCollection $ccPlayoutHistorys, PropelPDO $con = null) + { + $ccPlayoutHistorysToDelete = $this->getCcPlayoutHistorys(new Criteria(), $con)->diff($ccPlayoutHistorys); + + + $this->ccPlayoutHistorysScheduledForDeletion = $ccPlayoutHistorysToDelete; + + foreach ($ccPlayoutHistorysToDelete as $ccPlayoutHistoryRemoved) { + $ccPlayoutHistoryRemoved->setCcShowInstances(null); + } + + $this->collCcPlayoutHistorys = null; + foreach ($ccPlayoutHistorys as $ccPlayoutHistory) { + $this->addCcPlayoutHistory($ccPlayoutHistory); + } + + $this->collCcPlayoutHistorys = $ccPlayoutHistorys; + $this->collCcPlayoutHistorysPartial = false; + + return $this; + } + + /** + * Returns the number of related CcPlayoutHistory objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcPlayoutHistory objects. + * @throws PropelException + */ + public function countCcPlayoutHistorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcPlayoutHistorysPartial && !$this->isNew(); + if (null === $this->collCcPlayoutHistorys || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPlayoutHistorys) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcPlayoutHistorys()); + } + $query = CcPlayoutHistoryQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcShowInstances($this) + ->count($con); + } + + return count($this->collCcPlayoutHistorys); + } + + /** + * Method called to associate a CcPlayoutHistory object to this object + * through the CcPlayoutHistory foreign key attribute. + * + * @param CcPlayoutHistory $l CcPlayoutHistory + * @return CcShowInstances The current object (for fluent API support) + */ + public function addCcPlayoutHistory(CcPlayoutHistory $l) + { + if ($this->collCcPlayoutHistorys === null) { + $this->initCcPlayoutHistorys(); + $this->collCcPlayoutHistorysPartial = true; + } + + if (!in_array($l, $this->collCcPlayoutHistorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcPlayoutHistory($l); + + if ($this->ccPlayoutHistorysScheduledForDeletion and $this->ccPlayoutHistorysScheduledForDeletion->contains($l)) { + $this->ccPlayoutHistorysScheduledForDeletion->remove($this->ccPlayoutHistorysScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcPlayoutHistory $ccPlayoutHistory The ccPlayoutHistory object to add. + */ + protected function doAddCcPlayoutHistory($ccPlayoutHistory) + { + $this->collCcPlayoutHistorys[]= $ccPlayoutHistory; + $ccPlayoutHistory->setCcShowInstances($this); + } + + /** + * @param CcPlayoutHistory $ccPlayoutHistory The ccPlayoutHistory object to remove. + * @return CcShowInstances The current object (for fluent API support) + */ + public function removeCcPlayoutHistory($ccPlayoutHistory) + { + if ($this->getCcPlayoutHistorys()->contains($ccPlayoutHistory)) { + $this->collCcPlayoutHistorys->remove($this->collCcPlayoutHistorys->search($ccPlayoutHistory)); + if (null === $this->ccPlayoutHistorysScheduledForDeletion) { + $this->ccPlayoutHistorysScheduledForDeletion = clone $this->collCcPlayoutHistorys; + $this->ccPlayoutHistorysScheduledForDeletion->clear(); + } + $this->ccPlayoutHistorysScheduledForDeletion[]= $ccPlayoutHistory; + $ccPlayoutHistory->setCcShowInstances(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcShowInstances is new, it will return + * an empty collection; or if this CcShowInstances has previously + * been saved, it will retrieve related CcPlayoutHistorys 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 CcShowInstances. + * + * @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 PropelObjectCollection|CcPlayoutHistory[] List of CcPlayoutHistory objects + */ + public function getCcPlayoutHistorysJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcPlayoutHistoryQuery::create(null, $criteria); + $query->joinWith('CcFiles', $join_behavior); + + return $this->getCcPlayoutHistorys($query, $con); + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->starts = null; + $this->ends = null; + $this->show_id = null; + $this->record = null; + $this->rebroadcast = null; + $this->instance_id = null; + $this->file_id = null; + $this->time_filled = null; + $this->created = null; + $this->last_scheduled = null; + $this->modified_instance = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->collCcShowInstancessRelatedByDbId) { + foreach ($this->collCcShowInstancessRelatedByDbId as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcSchedules) { + foreach ($this->collCcSchedules as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcPlayoutHistorys) { + foreach ($this->collCcPlayoutHistorys as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->aCcShow instanceof Persistent) { + $this->aCcShow->clearAllReferences($deep); + } + if ($this->aCcShowInstancesRelatedByDbOriginalShow instanceof Persistent) { + $this->aCcShowInstancesRelatedByDbOriginalShow->clearAllReferences($deep); + } + if ($this->aCcFiles instanceof Persistent) { + $this->aCcFiles->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + if ($this->collCcShowInstancessRelatedByDbId instanceof PropelCollection) { + $this->collCcShowInstancessRelatedByDbId->clearIterator(); + } + $this->collCcShowInstancessRelatedByDbId = null; + if ($this->collCcSchedules instanceof PropelCollection) { + $this->collCcSchedules->clearIterator(); + } + $this->collCcSchedules = null; + if ($this->collCcPlayoutHistorys instanceof PropelCollection) { + $this->collCcPlayoutHistorys->clearIterator(); + } + $this->collCcPlayoutHistorys = null; + $this->aCcShow = null; + $this->aCcShowInstancesRelatedByDbOriginalShow = null; + $this->aCcFiles = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcShowInstancesPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesPeer.php index ad91f182c..aae7d4122 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesPeer.php @@ -1,1564 +1,1614 @@ array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', 'DbTimeFilled', 'DbCreated', 'DbLastScheduled', 'DbModifiedInstance', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', 'dbTimeFilled', 'dbCreated', 'dbLastScheduled', 'dbModifiedInstance', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::STARTS, self::ENDS, self::SHOW_ID, self::RECORD, self::REBROADCAST, self::INSTANCE_ID, self::FILE_ID, self::TIME_FILLED, self::CREATED, self::LAST_SCHEDULED, self::MODIFIED_INSTANCE, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', 'TIME_FILLED', 'CREATED', 'LAST_SCHEDULED', 'MODIFIED_INSTANCE', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', 'time_filled', 'created', 'last_scheduled', 'modified_instance', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) - ); - - /** - * 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, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, 'DbRecord' => 4, 'DbRebroadcast' => 5, 'DbOriginalShow' => 6, 'DbRecordedFile' => 7, 'DbTimeFilled' => 8, 'DbCreated' => 9, 'DbLastScheduled' => 10, 'DbModifiedInstance' => 11, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, 'dbRecord' => 4, 'dbRebroadcast' => 5, 'dbOriginalShow' => 6, 'dbRecordedFile' => 7, 'dbTimeFilled' => 8, 'dbCreated' => 9, 'dbLastScheduled' => 10, 'dbModifiedInstance' => 11, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::STARTS => 1, self::ENDS => 2, self::SHOW_ID => 3, self::RECORD => 4, self::REBROADCAST => 5, self::INSTANCE_ID => 6, self::FILE_ID => 7, self::TIME_FILLED => 8, self::CREATED => 9, self::LAST_SCHEDULED => 10, self::MODIFIED_INSTANCE => 11, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, 'RECORD' => 4, 'REBROADCAST' => 5, 'INSTANCE_ID' => 6, 'FILE_ID' => 7, 'TIME_FILLED' => 8, 'CREATED' => 9, 'LAST_SCHEDULED' => 10, 'MODIFIED_INSTANCE' => 11, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, 'record' => 4, 'rebroadcast' => 5, 'instance_id' => 6, 'file_id' => 7, 'time_filled' => 8, 'created' => 9, 'last_scheduled' => 10, 'modified_instance' => 11, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) - ); - - /** - * 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. CcShowInstancesPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcShowInstancesPeer::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(CcShowInstancesPeer::ID); - $criteria->addSelectColumn(CcShowInstancesPeer::STARTS); - $criteria->addSelectColumn(CcShowInstancesPeer::ENDS); - $criteria->addSelectColumn(CcShowInstancesPeer::SHOW_ID); - $criteria->addSelectColumn(CcShowInstancesPeer::RECORD); - $criteria->addSelectColumn(CcShowInstancesPeer::REBROADCAST); - $criteria->addSelectColumn(CcShowInstancesPeer::INSTANCE_ID); - $criteria->addSelectColumn(CcShowInstancesPeer::FILE_ID); - $criteria->addSelectColumn(CcShowInstancesPeer::TIME_FILLED); - $criteria->addSelectColumn(CcShowInstancesPeer::CREATED); - $criteria->addSelectColumn(CcShowInstancesPeer::LAST_SCHEDULED); - $criteria->addSelectColumn(CcShowInstancesPeer::MODIFIED_INSTANCE); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.STARTS'); - $criteria->addSelectColumn($alias . '.ENDS'); - $criteria->addSelectColumn($alias . '.SHOW_ID'); - $criteria->addSelectColumn($alias . '.RECORD'); - $criteria->addSelectColumn($alias . '.REBROADCAST'); - $criteria->addSelectColumn($alias . '.INSTANCE_ID'); - $criteria->addSelectColumn($alias . '.FILE_ID'); - $criteria->addSelectColumn($alias . '.TIME_FILLED'); - $criteria->addSelectColumn($alias . '.CREATED'); - $criteria->addSelectColumn($alias . '.LAST_SCHEDULED'); - $criteria->addSelectColumn($alias . '.MODIFIED_INSTANCE'); - } - } - - /** - * 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(CcShowInstancesPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowInstancesPeer::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(CcShowInstancesPeer::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 CcShowInstances - * @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 = CcShowInstancesPeer::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 CcShowInstancesPeer::populateObjects(CcShowInstancesPeer::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(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcShowInstancesPeer::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 CcShowInstances $value A CcShowInstances object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcShowInstances $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 CcShowInstances object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcShowInstances) { - $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 CcShowInstances 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 CcShowInstances 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_instances - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in CcShowInstancesPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcShowInstancesPeer::clearInstancePool(); - // Invalidate objects in CcSchedulePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcSchedulePeer::clearInstancePool(); - // Invalidate objects in CcPlayoutHistoryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcPlayoutHistoryPeer::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 = CcShowInstancesPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcShowInstancesPeer::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; - CcShowInstancesPeer::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 (CcShowInstances object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcShowInstancesPeer::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 + CcShowInstancesPeer::NUM_COLUMNS; - } else { - $cls = CcShowInstancesPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcShowInstancesPeer::addInstanceToPool($obj, $key); - } - return array($obj, $col); - } - - /** - * Returns the number of rows matching criteria, joining the related CcShow 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 doCountJoinCcShow(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(CcShowInstancesPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowInstancesPeer::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(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::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 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(CcShowInstancesPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowInstancesPeer::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(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcShowInstancesPeer::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 CcShowInstances objects pre-filled with their CcShow 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 CcShowInstances objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCcShow(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); - } - - CcShowInstancesPeer::addSelectColumns($criteria); - $startcol = (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS); - CcShowPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcShowInstancesPeer::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 = CcShowInstancesPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcShowInstancesPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcShowPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcShowPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcShowInstances) to $obj2 (CcShow) - $obj2->addCcShowInstances($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcShowInstances 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 CcShowInstances 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); - } - - CcShowInstancesPeer::addSelectColumns($criteria); - $startcol = (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS); - CcFilesPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcShowInstancesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcShowInstancesPeer::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 = CcShowInstancesPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcShowInstancesPeer::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 (CcShowInstances) to $obj2 (CcFiles) - $obj2->addCcShowInstances($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(CcShowInstancesPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowInstancesPeer::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(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); - - $criteria->addJoin(CcShowInstancesPeer::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 CcShowInstances 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 CcShowInstances 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); - } - - CcShowInstancesPeer::addSelectColumns($criteria); - $startcol2 = (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS); - - CcShowPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS); - - CcFilesPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); - - $criteria->addJoin(CcShowInstancesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcShowInstancesPeer::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 = CcShowInstancesPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcShowInstancesPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcShow rows - - $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcShowPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcShowPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (CcShowInstances) to the collection in $obj2 (CcShow) - $obj2->addCcShowInstances($obj1); - } // if joined row not null - - // Add objects for joined CcFiles rows - - $key3 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CcFilesPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CcFilesPeer::getOMClass(false); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CcFilesPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (CcShowInstances) to the collection in $obj3 (CcFiles) - $obj3->addCcShowInstances($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related CcShow 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 doCountJoinAllExceptCcShow(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(CcShowInstancesPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowInstancesPeer::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(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcShowInstancesPeer::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 CcShowInstancesRelatedByDbOriginalShow 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 doCountJoinAllExceptCcShowInstancesRelatedByDbOriginalShow(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(CcShowInstancesPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowInstancesPeer::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(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); - - $criteria->addJoin(CcShowInstancesPeer::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 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(CcShowInstancesPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowInstancesPeer::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(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::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 CcShowInstances objects pre-filled with all related objects except CcShow. - * - * @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 CcShowInstances objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCcShow(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); - } - - CcShowInstancesPeer::addSelectColumns($criteria); - $startcol2 = (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS); - - CcFilesPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcShowInstancesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcShowInstancesPeer::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 = CcShowInstancesPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcShowInstancesPeer::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 (CcShowInstances) to the collection in $obj2 (CcFiles) - $obj2->addCcShowInstances($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcShowInstances objects pre-filled with all related objects except CcShowInstancesRelatedByDbOriginalShow. - * - * @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 CcShowInstances objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCcShowInstancesRelatedByDbOriginalShow(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); - } - - CcShowInstancesPeer::addSelectColumns($criteria); - $startcol2 = (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS); - - CcShowPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS); - - CcFilesPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + (CcFilesPeer::NUM_COLUMNS - CcFilesPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); - - $criteria->addJoin(CcShowInstancesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcShowInstancesPeer::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 = CcShowInstancesPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcShowInstancesPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcShow rows - - $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcShowPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcShowPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (CcShowInstances) to the collection in $obj2 (CcShow) - $obj2->addCcShowInstances($obj1); - - } // if joined row is not null - - // Add objects for joined CcFiles rows - - $key3 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CcFilesPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CcFilesPeer::getOMClass(false); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CcFilesPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (CcShowInstances) to the collection in $obj3 (CcFiles) - $obj3->addCcShowInstances($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - return $results; - } - - - /** - * Selects a collection of CcShowInstances 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 CcShowInstances 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); - } - - CcShowInstancesPeer::addSelectColumns($criteria); - $startcol2 = (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS); - - CcShowPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcShowInstancesPeer::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 = CcShowInstancesPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcShowInstancesPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcShow rows - - $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcShowPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcShowPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (CcShowInstances) to the collection in $obj2 (CcShow) - $obj2->addCcShowInstances($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(BaseCcShowInstancesPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcShowInstancesPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcShowInstancesTableMap()); - } - } - - /** - * 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 ? CcShowInstancesPeer::CLASS_DEFAULT : CcShowInstancesPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcShowInstances or Criteria object. - * - * @param mixed $values Criteria or CcShowInstances 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(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcShowInstances object - } - - if ($criteria->containsKey(CcShowInstancesPeer::ID) && $criteria->keyContainsValue(CcShowInstancesPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowInstancesPeer::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 CcShowInstances or Criteria object. - * - * @param mixed $values Criteria or CcShowInstances 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(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcShowInstancesPeer::ID); - $value = $criteria->remove(CcShowInstancesPeer::ID); - if ($value) { - $selectCriteria->add(CcShowInstancesPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcShowInstancesPeer::TABLE_NAME); - } - - } else { // $values is CcShowInstances 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_instances 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(CcShowInstancesPeer::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(CcShowInstancesPeer::TABLE_NAME, $con, CcShowInstancesPeer::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). - CcShowInstancesPeer::clearInstancePool(); - CcShowInstancesPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcShowInstances or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcShowInstances 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(CcShowInstancesPeer::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. - CcShowInstancesPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcShowInstances) { // it's a model object - // invalidate the cache for this single object - CcShowInstancesPeer::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(CcShowInstancesPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcShowInstancesPeer::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); - CcShowInstancesPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcShowInstances 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 CcShowInstances $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(CcShowInstances $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcShowInstancesPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcShowInstancesPeer::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(CcShowInstancesPeer::DATABASE_NAME, CcShowInstancesPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcShowInstances - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcShowInstancesPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcShowInstancesPeer::DATABASE_NAME); - $criteria->add(CcShowInstancesPeer::ID, $pk); - - $v = CcShowInstancesPeer::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(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcShowInstancesPeer::DATABASE_NAME); - $criteria->add(CcShowInstancesPeer::ID, $pks, Criteria::IN); - $objs = CcShowInstancesPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcShowInstancesPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_show_instances'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcShowInstances'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcShowInstancesTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 12; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 12; + + /** the column name for the id field */ + const ID = 'cc_show_instances.id'; + + /** the column name for the starts field */ + const STARTS = 'cc_show_instances.starts'; + + /** the column name for the ends field */ + const ENDS = 'cc_show_instances.ends'; + + /** the column name for the show_id field */ + const SHOW_ID = 'cc_show_instances.show_id'; + + /** the column name for the record field */ + const RECORD = 'cc_show_instances.record'; + + /** the column name for the rebroadcast field */ + const REBROADCAST = 'cc_show_instances.rebroadcast'; + + /** the column name for the instance_id field */ + const INSTANCE_ID = 'cc_show_instances.instance_id'; + + /** the column name for the file_id field */ + const FILE_ID = 'cc_show_instances.file_id'; + + /** the column name for the time_filled field */ + const TIME_FILLED = 'cc_show_instances.time_filled'; + + /** the column name for the created field */ + const CREATED = 'cc_show_instances.created'; + + /** the column name for the last_scheduled field */ + const LAST_SCHEDULED = 'cc_show_instances.last_scheduled'; + + /** the column name for the modified_instance field */ + const MODIFIED_INSTANCE = 'cc_show_instances.modified_instance'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcShowInstances objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcShowInstances[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcShowInstancesPeer::$fieldNames[CcShowInstancesPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbStarts', 'DbEnds', 'DbShowId', 'DbRecord', 'DbRebroadcast', 'DbOriginalShow', 'DbRecordedFile', 'DbTimeFilled', 'DbCreated', 'DbLastScheduled', 'DbModifiedInstance', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbStarts', 'dbEnds', 'dbShowId', 'dbRecord', 'dbRebroadcast', 'dbOriginalShow', 'dbRecordedFile', 'dbTimeFilled', 'dbCreated', 'dbLastScheduled', 'dbModifiedInstance', ), + BasePeer::TYPE_COLNAME => array (CcShowInstancesPeer::ID, CcShowInstancesPeer::STARTS, CcShowInstancesPeer::ENDS, CcShowInstancesPeer::SHOW_ID, CcShowInstancesPeer::RECORD, CcShowInstancesPeer::REBROADCAST, CcShowInstancesPeer::INSTANCE_ID, CcShowInstancesPeer::FILE_ID, CcShowInstancesPeer::TIME_FILLED, CcShowInstancesPeer::CREATED, CcShowInstancesPeer::LAST_SCHEDULED, CcShowInstancesPeer::MODIFIED_INSTANCE, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'STARTS', 'ENDS', 'SHOW_ID', 'RECORD', 'REBROADCAST', 'INSTANCE_ID', 'FILE_ID', 'TIME_FILLED', 'CREATED', 'LAST_SCHEDULED', 'MODIFIED_INSTANCE', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'starts', 'ends', 'show_id', 'record', 'rebroadcast', 'instance_id', 'file_id', 'time_filled', 'created', 'last_scheduled', 'modified_instance', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcShowInstancesPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbStarts' => 1, 'DbEnds' => 2, 'DbShowId' => 3, 'DbRecord' => 4, 'DbRebroadcast' => 5, 'DbOriginalShow' => 6, 'DbRecordedFile' => 7, 'DbTimeFilled' => 8, 'DbCreated' => 9, 'DbLastScheduled' => 10, 'DbModifiedInstance' => 11, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbStarts' => 1, 'dbEnds' => 2, 'dbShowId' => 3, 'dbRecord' => 4, 'dbRebroadcast' => 5, 'dbOriginalShow' => 6, 'dbRecordedFile' => 7, 'dbTimeFilled' => 8, 'dbCreated' => 9, 'dbLastScheduled' => 10, 'dbModifiedInstance' => 11, ), + BasePeer::TYPE_COLNAME => array (CcShowInstancesPeer::ID => 0, CcShowInstancesPeer::STARTS => 1, CcShowInstancesPeer::ENDS => 2, CcShowInstancesPeer::SHOW_ID => 3, CcShowInstancesPeer::RECORD => 4, CcShowInstancesPeer::REBROADCAST => 5, CcShowInstancesPeer::INSTANCE_ID => 6, CcShowInstancesPeer::FILE_ID => 7, CcShowInstancesPeer::TIME_FILLED => 8, CcShowInstancesPeer::CREATED => 9, CcShowInstancesPeer::LAST_SCHEDULED => 10, CcShowInstancesPeer::MODIFIED_INSTANCE => 11, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'STARTS' => 1, 'ENDS' => 2, 'SHOW_ID' => 3, 'RECORD' => 4, 'REBROADCAST' => 5, 'INSTANCE_ID' => 6, 'FILE_ID' => 7, 'TIME_FILLED' => 8, 'CREATED' => 9, 'LAST_SCHEDULED' => 10, 'MODIFIED_INSTANCE' => 11, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'starts' => 1, 'ends' => 2, 'show_id' => 3, 'record' => 4, 'rebroadcast' => 5, 'instance_id' => 6, 'file_id' => 7, 'time_filled' => 8, 'created' => 9, 'last_scheduled' => 10, 'modified_instance' => 11, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcShowInstancesPeer::getFieldNames($toType); + $key = isset(CcShowInstancesPeer::$fieldKeys[$fromType][$name]) ? CcShowInstancesPeer::$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(CcShowInstancesPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcShowInstancesPeer::$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 CcShowInstancesPeer::$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. CcShowInstancesPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcShowInstancesPeer::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(CcShowInstancesPeer::ID); + $criteria->addSelectColumn(CcShowInstancesPeer::STARTS); + $criteria->addSelectColumn(CcShowInstancesPeer::ENDS); + $criteria->addSelectColumn(CcShowInstancesPeer::SHOW_ID); + $criteria->addSelectColumn(CcShowInstancesPeer::RECORD); + $criteria->addSelectColumn(CcShowInstancesPeer::REBROADCAST); + $criteria->addSelectColumn(CcShowInstancesPeer::INSTANCE_ID); + $criteria->addSelectColumn(CcShowInstancesPeer::FILE_ID); + $criteria->addSelectColumn(CcShowInstancesPeer::TIME_FILLED); + $criteria->addSelectColumn(CcShowInstancesPeer::CREATED); + $criteria->addSelectColumn(CcShowInstancesPeer::LAST_SCHEDULED); + $criteria->addSelectColumn(CcShowInstancesPeer::MODIFIED_INSTANCE); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.starts'); + $criteria->addSelectColumn($alias . '.ends'); + $criteria->addSelectColumn($alias . '.show_id'); + $criteria->addSelectColumn($alias . '.record'); + $criteria->addSelectColumn($alias . '.rebroadcast'); + $criteria->addSelectColumn($alias . '.instance_id'); + $criteria->addSelectColumn($alias . '.file_id'); + $criteria->addSelectColumn($alias . '.time_filled'); + $criteria->addSelectColumn($alias . '.created'); + $criteria->addSelectColumn($alias . '.last_scheduled'); + $criteria->addSelectColumn($alias . '.modified_instance'); + } + } + + /** + * 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(CcShowInstancesPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowInstancesPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcShowInstancesPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcShowInstancesPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcShowInstances + * @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 = CcShowInstancesPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcShowInstancesPeer::populateObjects(CcShowInstancesPeer::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 directly (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(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcShowInstancesPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcShowInstancesPeer::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 CcShowInstances $obj A CcShowInstances object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcShowInstancesPeer::$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 CcShowInstances object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcShowInstances) { + $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 CcShowInstances object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcShowInstancesPeer::$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 CcShowInstances 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(CcShowInstancesPeer::$instances[$key])) { + return CcShowInstancesPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcShowInstancesPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcShowInstancesPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_show_instances + * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in CcShowInstancesPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcShowInstancesPeer::clearInstancePool(); + // Invalidate objects in CcSchedulePeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcSchedulePeer::clearInstancePool(); + // Invalidate objects in CcPlayoutHistoryPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcPlayoutHistoryPeer::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 = CcShowInstancesPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcShowInstancesPeer::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; + CcShowInstancesPeer::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 (CcShowInstances object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcShowInstancesPeer::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 + CcShowInstancesPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcShowInstancesPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcShowInstancesPeer::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + + /** + * Returns the number of rows matching criteria, joining the related CcShow 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 doCountJoinCcShow(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(CcShowInstancesPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowInstancesPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcShowInstancesPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::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 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(CcShowInstancesPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowInstancesPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcShowInstancesPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowInstancesPeer::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 CcShowInstances objects pre-filled with their CcShow 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 CcShowInstances objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcShow(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(CcShowInstancesPeer::DATABASE_NAME); + } + + CcShowInstancesPeer::addSelectColumns($criteria); + $startcol = CcShowInstancesPeer::NUM_HYDRATE_COLUMNS; + CcShowPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowInstancesPeer::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 = CcShowInstancesPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowInstancesPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcShowPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcShowPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcShowInstances) to $obj2 (CcShow) + $obj2->addCcShowInstances($obj1); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcShowInstances 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 CcShowInstances 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(CcShowInstancesPeer::DATABASE_NAME); + } + + CcShowInstancesPeer::addSelectColumns($criteria); + $startcol = CcShowInstancesPeer::NUM_HYDRATE_COLUMNS; + CcFilesPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcShowInstancesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowInstancesPeer::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 = CcShowInstancesPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowInstancesPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcFilesPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcFilesPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcFilesPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcShowInstances) to $obj2 (CcFiles) + $obj2->addCcShowInstances($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(CcShowInstancesPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowInstancesPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcShowInstancesPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $criteria->addJoin(CcShowInstancesPeer::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 CcShowInstances 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 CcShowInstances 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(CcShowInstancesPeer::DATABASE_NAME); + } + + CcShowInstancesPeer::addSelectColumns($criteria); + $startcol2 = CcShowInstancesPeer::NUM_HYDRATE_COLUMNS; + + CcShowPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcShowPeer::NUM_HYDRATE_COLUMNS; + + CcFilesPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcFilesPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $criteria->addJoin(CcShowInstancesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowInstancesPeer::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 = CcShowInstancesPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowInstancesPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcShow rows + + $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcShowPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcShowPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcShowInstances) to the collection in $obj2 (CcShow) + $obj2->addCcShowInstances($obj1); + } // if joined row not null + + // Add objects for joined CcFiles rows + + $key3 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcFilesPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcFilesPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcFilesPeer::addInstanceToPool($obj3, $key3); + } // if obj3 loaded + + // Add the $obj1 (CcShowInstances) to the collection in $obj3 (CcFiles) + $obj3->addCcShowInstances($obj1); + } // if joined row not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining the related CcShow 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 doCountJoinAllExceptCcShow(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(CcShowInstancesPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowInstancesPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(CcShowInstancesPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowInstancesPeer::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 CcShowInstancesRelatedByDbOriginalShow 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 doCountJoinAllExceptCcShowInstancesRelatedByDbOriginalShow(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(CcShowInstancesPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowInstancesPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(CcShowInstancesPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $criteria->addJoin(CcShowInstancesPeer::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 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(CcShowInstancesPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowInstancesPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(CcShowInstancesPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::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 CcShowInstances objects pre-filled with all related objects except CcShow. + * + * @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 CcShowInstances objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcShow(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(CcShowInstancesPeer::DATABASE_NAME); + } + + CcShowInstancesPeer::addSelectColumns($criteria); + $startcol2 = CcShowInstancesPeer::NUM_HYDRATE_COLUMNS; + + CcFilesPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcFilesPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcShowInstancesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowInstancesPeer::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 = CcShowInstancesPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowInstancesPeer::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(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcFilesPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcShowInstances) to the collection in $obj2 (CcFiles) + $obj2->addCcShowInstances($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcShowInstances objects pre-filled with all related objects except CcShowInstancesRelatedByDbOriginalShow. + * + * @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 CcShowInstances objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcShowInstancesRelatedByDbOriginalShow(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(CcShowInstancesPeer::DATABASE_NAME); + } + + CcShowInstancesPeer::addSelectColumns($criteria); + $startcol2 = CcShowInstancesPeer::NUM_HYDRATE_COLUMNS; + + CcShowPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcShowPeer::NUM_HYDRATE_COLUMNS; + + CcFilesPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcFilesPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $criteria->addJoin(CcShowInstancesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowInstancesPeer::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 = CcShowInstancesPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowInstancesPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcShow rows + + $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcShowPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcShowPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcShowInstances) to the collection in $obj2 (CcShow) + $obj2->addCcShowInstances($obj1); + + } // if joined row is not null + + // Add objects for joined CcFiles rows + + $key3 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcFilesPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcFilesPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcFilesPeer::addInstanceToPool($obj3, $key3); + } // if $obj3 already loaded + + // Add the $obj1 (CcShowInstances) to the collection in $obj3 (CcFiles) + $obj3->addCcShowInstances($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of CcShowInstances 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 CcShowInstances 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(CcShowInstancesPeer::DATABASE_NAME); + } + + CcShowInstancesPeer::addSelectColumns($criteria); + $startcol2 = CcShowInstancesPeer::NUM_HYDRATE_COLUMNS; + + CcShowPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcShowPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcShowInstancesPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowInstancesPeer::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 = CcShowInstancesPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowInstancesPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcShow rows + + $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcShowPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcShowPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (CcShowInstances) to the collection in $obj2 (CcShow) + $obj2->addCcShowInstances($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(CcShowInstancesPeer::DATABASE_NAME)->getTable(CcShowInstancesPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcShowInstancesPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcShowInstancesPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcShowInstancesTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcShowInstancesPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcShowInstances or Criteria object. + * + * @param mixed $values Criteria or CcShowInstances 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(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcShowInstances object + } + + if ($criteria->containsKey(CcShowInstancesPeer::ID) && $criteria->keyContainsValue(CcShowInstancesPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowInstancesPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcShowInstancesPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcShowInstances or Criteria object. + * + * @param mixed $values Criteria or CcShowInstances 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(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcShowInstancesPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcShowInstancesPeer::ID); + $value = $criteria->remove(CcShowInstancesPeer::ID); + if ($value) { + $selectCriteria->add(CcShowInstancesPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcShowInstancesPeer::TABLE_NAME); + } + + } else { // $values is CcShowInstances object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcShowInstancesPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_show_instances table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcShowInstancesPeer::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(CcShowInstancesPeer::TABLE_NAME, $con, CcShowInstancesPeer::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). + CcShowInstancesPeer::clearInstancePool(); + CcShowInstancesPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcShowInstances or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcShowInstances 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(CcShowInstancesPeer::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. + CcShowInstancesPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcShowInstances) { // it's a model object + // invalidate the cache for this single object + CcShowInstancesPeer::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(CcShowInstancesPeer::DATABASE_NAME); + $criteria->add(CcShowInstancesPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcShowInstancesPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcShowInstancesPeer::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); + CcShowInstancesPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcShowInstances 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 CcShowInstances $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcShowInstancesPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcShowInstancesPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcShowInstancesPeer::DATABASE_NAME, CcShowInstancesPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcShowInstances + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcShowInstancesPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcShowInstancesPeer::DATABASE_NAME); + $criteria->add(CcShowInstancesPeer::ID, $pk); + + $v = CcShowInstancesPeer::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 + * @return CcShowInstances[] + * @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(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcShowInstancesPeer::DATABASE_NAME); + $criteria->add(CcShowInstancesPeer::ID, $pks, Criteria::IN); + $objs = CcShowInstancesPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcShowInstancesPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesQuery.php index 871b907ae..64d5b6b19 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowInstancesQuery.php @@ -1,935 +1,1257 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcShowInstances|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcShowInstancesPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcShowInstances|CcShowInstances[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcShowInstancesPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcShowInstancesPeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcShowInstances A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcShowInstancesPeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcShowInstances A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "starts", "ends", "show_id", "record", "rebroadcast", "instance_id", "file_id", "time_filled", "created", "last_scheduled", "modified_instance" FROM "cc_show_instances" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcShowInstances(); + $obj->hydrate($row); + CcShowInstancesPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcShowInstancesQuery 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(CcShowInstancesPeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * Filter the query on the starts column - * - * @param string|array $dbStarts 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 CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByDbStarts($dbStarts = null, $comparison = null) - { - if (is_array($dbStarts)) { - $useMinMax = false; - if (isset($dbStarts['min'])) { - $this->addUsingAlias(CcShowInstancesPeer::STARTS, $dbStarts['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbStarts['max'])) { - $this->addUsingAlias(CcShowInstancesPeer::STARTS, $dbStarts['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowInstancesPeer::STARTS, $dbStarts, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcShowInstances|CcShowInstances[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Filter the query on the ends column - * - * @param string|array $dbEnds 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 CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByDbEnds($dbEnds = null, $comparison = null) - { - if (is_array($dbEnds)) { - $useMinMax = false; - if (isset($dbEnds['min'])) { - $this->addUsingAlias(CcShowInstancesPeer::ENDS, $dbEnds['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbEnds['max'])) { - $this->addUsingAlias(CcShowInstancesPeer::ENDS, $dbEnds['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowInstancesPeer::ENDS, $dbEnds, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query on the show_id column - * - * @param int|array $dbShowId 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 CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByDbShowId($dbShowId = null, $comparison = null) - { - if (is_array($dbShowId)) { - $useMinMax = false; - if (isset($dbShowId['min'])) { - $this->addUsingAlias(CcShowInstancesPeer::SHOW_ID, $dbShowId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbShowId['max'])) { - $this->addUsingAlias(CcShowInstancesPeer::SHOW_ID, $dbShowId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowInstancesPeer::SHOW_ID, $dbShowId, $comparison); - } + /** + * 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|CcShowInstances[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query on the record column - * - * @param int|array $dbRecord 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 CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByDbRecord($dbRecord = null, $comparison = null) - { - if (is_array($dbRecord)) { - $useMinMax = false; - if (isset($dbRecord['min'])) { - $this->addUsingAlias(CcShowInstancesPeer::RECORD, $dbRecord['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbRecord['max'])) { - $this->addUsingAlias(CcShowInstancesPeer::RECORD, $dbRecord['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowInstancesPeer::RECORD, $dbRecord, $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Filter the query on the rebroadcast column - * - * @param int|array $dbRebroadcast 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 CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByDbRebroadcast($dbRebroadcast = null, $comparison = null) - { - if (is_array($dbRebroadcast)) { - $useMinMax = false; - if (isset($dbRebroadcast['min'])) { - $this->addUsingAlias(CcShowInstancesPeer::REBROADCAST, $dbRebroadcast['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbRebroadcast['max'])) { - $this->addUsingAlias(CcShowInstancesPeer::REBROADCAST, $dbRebroadcast['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowInstancesPeer::REBROADCAST, $dbRebroadcast, $comparison); - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { - /** - * Filter the query on the instance_id column - * - * @param int|array $dbOriginalShow 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 CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByDbOriginalShow($dbOriginalShow = null, $comparison = null) - { - if (is_array($dbOriginalShow)) { - $useMinMax = false; - if (isset($dbOriginalShow['min'])) { - $this->addUsingAlias(CcShowInstancesPeer::INSTANCE_ID, $dbOriginalShow['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbOriginalShow['max'])) { - $this->addUsingAlias(CcShowInstancesPeer::INSTANCE_ID, $dbOriginalShow['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowInstancesPeer::INSTANCE_ID, $dbOriginalShow, $comparison); - } + return $this->addUsingAlias(CcShowInstancesPeer::ID, $key, Criteria::EQUAL); + } - /** - * Filter the query on the file_id column - * - * @param int|array $dbRecordedFile 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 CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByDbRecordedFile($dbRecordedFile = null, $comparison = null) - { - if (is_array($dbRecordedFile)) { - $useMinMax = false; - if (isset($dbRecordedFile['min'])) { - $this->addUsingAlias(CcShowInstancesPeer::FILE_ID, $dbRecordedFile['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbRecordedFile['max'])) { - $this->addUsingAlias(CcShowInstancesPeer::FILE_ID, $dbRecordedFile['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowInstancesPeer::FILE_ID, $dbRecordedFile, $comparison); - } + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { - /** - * Filter the query on the time_filled column - * - * @param string $dbTimeFilled 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 CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByDbTimeFilled($dbTimeFilled = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbTimeFilled)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbTimeFilled)) { - $dbTimeFilled = str_replace('*', '%', $dbTimeFilled); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcShowInstancesPeer::TIME_FILLED, $dbTimeFilled, $comparison); - } + return $this->addUsingAlias(CcShowInstancesPeer::ID, $keys, Criteria::IN); + } - /** - * Filter the query on the created column - * - * @param string|array $dbCreated 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 CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByDbCreated($dbCreated = null, $comparison = null) - { - if (is_array($dbCreated)) { - $useMinMax = false; - if (isset($dbCreated['min'])) { - $this->addUsingAlias(CcShowInstancesPeer::CREATED, $dbCreated['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbCreated['max'])) { - $this->addUsingAlias(CcShowInstancesPeer::CREATED, $dbCreated['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowInstancesPeer::CREATED, $dbCreated, $comparison); - } + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcShowInstancesPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcShowInstancesPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Filter the query on the last_scheduled column - * - * @param string|array $dbLastScheduled 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 CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByDbLastScheduled($dbLastScheduled = null, $comparison = null) - { - if (is_array($dbLastScheduled)) { - $useMinMax = false; - if (isset($dbLastScheduled['min'])) { - $this->addUsingAlias(CcShowInstancesPeer::LAST_SCHEDULED, $dbLastScheduled['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbLastScheduled['max'])) { - $this->addUsingAlias(CcShowInstancesPeer::LAST_SCHEDULED, $dbLastScheduled['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowInstancesPeer::LAST_SCHEDULED, $dbLastScheduled, $comparison); - } + return $this->addUsingAlias(CcShowInstancesPeer::ID, $dbId, $comparison); + } - /** - * Filter the query on the modified_instance column - * - * @param boolean|string $dbModifiedInstance The value to use as filter. - * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByDbModifiedInstance($dbModifiedInstance = null, $comparison = null) - { - if (is_string($dbModifiedInstance)) { - $modified_instance = in_array(strtolower($dbModifiedInstance), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; - } - return $this->addUsingAlias(CcShowInstancesPeer::MODIFIED_INSTANCE, $dbModifiedInstance, $comparison); - } + /** + * Filter the query on the starts column + * + * Example usage: + * + * $query->filterByDbStarts('2011-03-14'); // WHERE starts = '2011-03-14' + * $query->filterByDbStarts('now'); // WHERE starts = '2011-03-14' + * $query->filterByDbStarts(array('max' => 'yesterday')); // WHERE starts < '2011-03-13' + * + * + * @param mixed $dbStarts The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbStarts($dbStarts = null, $comparison = null) + { + if (is_array($dbStarts)) { + $useMinMax = false; + if (isset($dbStarts['min'])) { + $this->addUsingAlias(CcShowInstancesPeer::STARTS, $dbStarts['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbStarts['max'])) { + $this->addUsingAlias(CcShowInstancesPeer::STARTS, $dbStarts['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Filter the query by a related CcShow object - * - * @param CcShow $ccShow the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByCcShow($ccShow, $comparison = null) - { - return $this - ->addUsingAlias(CcShowInstancesPeer::SHOW_ID, $ccShow->getDbId(), $comparison); - } + return $this->addUsingAlias(CcShowInstancesPeer::STARTS, $dbStarts, $comparison); + } - /** - * Adds a JOIN clause to the query using the CcShow relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcShowInstancesQuery The current query, for fluid interface - */ - public function joinCcShow($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcShow'); - - // 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, 'CcShow'); - } - - return $this; - } + /** + * Filter the query on the ends column + * + * Example usage: + * + * $query->filterByDbEnds('2011-03-14'); // WHERE ends = '2011-03-14' + * $query->filterByDbEnds('now'); // WHERE ends = '2011-03-14' + * $query->filterByDbEnds(array('max' => 'yesterday')); // WHERE ends < '2011-03-13' + * + * + * @param mixed $dbEnds The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbEnds($dbEnds = null, $comparison = null) + { + if (is_array($dbEnds)) { + $useMinMax = false; + if (isset($dbEnds['min'])) { + $this->addUsingAlias(CcShowInstancesPeer::ENDS, $dbEnds['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbEnds['max'])) { + $this->addUsingAlias(CcShowInstancesPeer::ENDS, $dbEnds['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Use the CcShow relation CcShow 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 CcShowQuery A secondary query class using the current class as primary query - */ - public function useCcShowQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcShow($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcShow', 'CcShowQuery'); - } + return $this->addUsingAlias(CcShowInstancesPeer::ENDS, $dbEnds, $comparison); + } - /** - * Filter the query by a related CcShowInstances object - * - * @param CcShowInstances $ccShowInstances the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByCcShowInstancesRelatedByDbOriginalShow($ccShowInstances, $comparison = null) - { - return $this - ->addUsingAlias(CcShowInstancesPeer::INSTANCE_ID, $ccShowInstances->getDbId(), $comparison); - } + /** + * Filter the query on the show_id column + * + * Example usage: + * + * $query->filterByDbShowId(1234); // WHERE show_id = 1234 + * $query->filterByDbShowId(array(12, 34)); // WHERE show_id IN (12, 34) + * $query->filterByDbShowId(array('min' => 12)); // WHERE show_id >= 12 + * $query->filterByDbShowId(array('max' => 12)); // WHERE show_id <= 12 + * + * + * @see filterByCcShow() + * + * @param mixed $dbShowId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbShowId($dbShowId = null, $comparison = null) + { + if (is_array($dbShowId)) { + $useMinMax = false; + if (isset($dbShowId['min'])) { + $this->addUsingAlias(CcShowInstancesPeer::SHOW_ID, $dbShowId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbShowId['max'])) { + $this->addUsingAlias(CcShowInstancesPeer::SHOW_ID, $dbShowId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Adds a JOIN clause to the query using the CcShowInstancesRelatedByDbOriginalShow relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcShowInstancesQuery The current query, for fluid interface - */ - public function joinCcShowInstancesRelatedByDbOriginalShow($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcShowInstancesRelatedByDbOriginalShow'); - - // 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, 'CcShowInstancesRelatedByDbOriginalShow'); - } - - return $this; - } + return $this->addUsingAlias(CcShowInstancesPeer::SHOW_ID, $dbShowId, $comparison); + } - /** - * Use the CcShowInstancesRelatedByDbOriginalShow relation CcShowInstances 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 CcShowInstancesQuery A secondary query class using the current class as primary query - */ - public function useCcShowInstancesRelatedByDbOriginalShowQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcShowInstancesRelatedByDbOriginalShow($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcShowInstancesRelatedByDbOriginalShow', 'CcShowInstancesQuery'); - } + /** + * Filter the query on the record column + * + * Example usage: + * + * $query->filterByDbRecord(1234); // WHERE record = 1234 + * $query->filterByDbRecord(array(12, 34)); // WHERE record IN (12, 34) + * $query->filterByDbRecord(array('min' => 12)); // WHERE record >= 12 + * $query->filterByDbRecord(array('max' => 12)); // WHERE record <= 12 + * + * + * @param mixed $dbRecord The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbRecord($dbRecord = null, $comparison = null) + { + if (is_array($dbRecord)) { + $useMinMax = false; + if (isset($dbRecord['min'])) { + $this->addUsingAlias(CcShowInstancesPeer::RECORD, $dbRecord['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbRecord['max'])) { + $this->addUsingAlias(CcShowInstancesPeer::RECORD, $dbRecord['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * 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 CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByCcFiles($ccFiles, $comparison = null) - { - return $this - ->addUsingAlias(CcShowInstancesPeer::FILE_ID, $ccFiles->getDbId(), $comparison); - } + return $this->addUsingAlias(CcShowInstancesPeer::RECORD, $dbRecord, $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 CcShowInstancesQuery 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; - } + /** + * Filter the query on the rebroadcast column + * + * Example usage: + * + * $query->filterByDbRebroadcast(1234); // WHERE rebroadcast = 1234 + * $query->filterByDbRebroadcast(array(12, 34)); // WHERE rebroadcast IN (12, 34) + * $query->filterByDbRebroadcast(array('min' => 12)); // WHERE rebroadcast >= 12 + * $query->filterByDbRebroadcast(array('max' => 12)); // WHERE rebroadcast <= 12 + * + * + * @param mixed $dbRebroadcast The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbRebroadcast($dbRebroadcast = null, $comparison = null) + { + if (is_array($dbRebroadcast)) { + $useMinMax = false; + if (isset($dbRebroadcast['min'])) { + $this->addUsingAlias(CcShowInstancesPeer::REBROADCAST, $dbRebroadcast['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbRebroadcast['max'])) { + $this->addUsingAlias(CcShowInstancesPeer::REBROADCAST, $dbRebroadcast['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * 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'); - } + return $this->addUsingAlias(CcShowInstancesPeer::REBROADCAST, $dbRebroadcast, $comparison); + } - /** - * Filter the query by a related CcShowInstances object - * - * @param CcShowInstances $ccShowInstances the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByCcShowInstancesRelatedByDbId($ccShowInstances, $comparison = null) - { - return $this - ->addUsingAlias(CcShowInstancesPeer::ID, $ccShowInstances->getDbOriginalShow(), $comparison); - } + /** + * Filter the query on the instance_id column + * + * Example usage: + * + * $query->filterByDbOriginalShow(1234); // WHERE instance_id = 1234 + * $query->filterByDbOriginalShow(array(12, 34)); // WHERE instance_id IN (12, 34) + * $query->filterByDbOriginalShow(array('min' => 12)); // WHERE instance_id >= 12 + * $query->filterByDbOriginalShow(array('max' => 12)); // WHERE instance_id <= 12 + * + * + * @see filterByCcShowInstancesRelatedByDbOriginalShow() + * + * @param mixed $dbOriginalShow The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbOriginalShow($dbOriginalShow = null, $comparison = null) + { + if (is_array($dbOriginalShow)) { + $useMinMax = false; + if (isset($dbOriginalShow['min'])) { + $this->addUsingAlias(CcShowInstancesPeer::INSTANCE_ID, $dbOriginalShow['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbOriginalShow['max'])) { + $this->addUsingAlias(CcShowInstancesPeer::INSTANCE_ID, $dbOriginalShow['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Adds a JOIN clause to the query using the CcShowInstancesRelatedByDbId relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcShowInstancesQuery The current query, for fluid interface - */ - public function joinCcShowInstancesRelatedByDbId($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcShowInstancesRelatedByDbId'); - - // 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, 'CcShowInstancesRelatedByDbId'); - } - - return $this; - } + return $this->addUsingAlias(CcShowInstancesPeer::INSTANCE_ID, $dbOriginalShow, $comparison); + } - /** - * Use the CcShowInstancesRelatedByDbId relation CcShowInstances 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 CcShowInstancesQuery A secondary query class using the current class as primary query - */ - public function useCcShowInstancesRelatedByDbIdQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcShowInstancesRelatedByDbId($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcShowInstancesRelatedByDbId', 'CcShowInstancesQuery'); - } + /** + * Filter the query on the file_id column + * + * Example usage: + * + * $query->filterByDbRecordedFile(1234); // WHERE file_id = 1234 + * $query->filterByDbRecordedFile(array(12, 34)); // WHERE file_id IN (12, 34) + * $query->filterByDbRecordedFile(array('min' => 12)); // WHERE file_id >= 12 + * $query->filterByDbRecordedFile(array('max' => 12)); // WHERE file_id <= 12 + * + * + * @see filterByCcFiles() + * + * @param mixed $dbRecordedFile The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbRecordedFile($dbRecordedFile = null, $comparison = null) + { + if (is_array($dbRecordedFile)) { + $useMinMax = false; + if (isset($dbRecordedFile['min'])) { + $this->addUsingAlias(CcShowInstancesPeer::FILE_ID, $dbRecordedFile['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbRecordedFile['max'])) { + $this->addUsingAlias(CcShowInstancesPeer::FILE_ID, $dbRecordedFile['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Filter the query by a related CcSchedule object - * - * @param CcSchedule $ccSchedule the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByCcSchedule($ccSchedule, $comparison = null) - { - return $this - ->addUsingAlias(CcShowInstancesPeer::ID, $ccSchedule->getDbInstanceId(), $comparison); - } + return $this->addUsingAlias(CcShowInstancesPeer::FILE_ID, $dbRecordedFile, $comparison); + } - /** - * Adds a JOIN clause to the query using the CcSchedule relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcShowInstancesQuery The current query, for fluid interface - */ - public function joinCcSchedule($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcSchedule'); - - // 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, 'CcSchedule'); - } - - return $this; - } + /** + * Filter the query on the time_filled column + * + * Example usage: + * + * $query->filterByDbTimeFilled('fooValue'); // WHERE time_filled = 'fooValue' + * $query->filterByDbTimeFilled('%fooValue%'); // WHERE time_filled LIKE '%fooValue%' + * + * + * @param string $dbTimeFilled 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 CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbTimeFilled($dbTimeFilled = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbTimeFilled)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbTimeFilled)) { + $dbTimeFilled = str_replace('*', '%', $dbTimeFilled); + $comparison = Criteria::LIKE; + } + } - /** - * Use the CcSchedule relation CcSchedule 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 CcScheduleQuery A secondary query class using the current class as primary query - */ - public function useCcScheduleQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcSchedule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcSchedule', 'CcScheduleQuery'); - } + return $this->addUsingAlias(CcShowInstancesPeer::TIME_FILLED, $dbTimeFilled, $comparison); + } - /** - * Filter the query by a related CcPlayoutHistory object - * - * @param CcPlayoutHistory $ccPlayoutHistory the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowInstancesQuery The current query, for fluid interface - */ - public function filterByCcPlayoutHistory($ccPlayoutHistory, $comparison = null) - { - return $this - ->addUsingAlias(CcShowInstancesPeer::ID, $ccPlayoutHistory->getDbInstanceId(), $comparison); - } + /** + * Filter the query on the created column + * + * Example usage: + * + * $query->filterByDbCreated('2011-03-14'); // WHERE created = '2011-03-14' + * $query->filterByDbCreated('now'); // WHERE created = '2011-03-14' + * $query->filterByDbCreated(array('max' => 'yesterday')); // WHERE created < '2011-03-13' + * + * + * @param mixed $dbCreated The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbCreated($dbCreated = null, $comparison = null) + { + if (is_array($dbCreated)) { + $useMinMax = false; + if (isset($dbCreated['min'])) { + $this->addUsingAlias(CcShowInstancesPeer::CREATED, $dbCreated['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbCreated['max'])) { + $this->addUsingAlias(CcShowInstancesPeer::CREATED, $dbCreated['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Adds a JOIN clause to the query using the CcPlayoutHistory relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcShowInstancesQuery The current query, for fluid interface - */ - public function joinCcPlayoutHistory($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcPlayoutHistory'); - - // 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, 'CcPlayoutHistory'); - } - - return $this; - } + return $this->addUsingAlias(CcShowInstancesPeer::CREATED, $dbCreated, $comparison); + } - /** - * Use the CcPlayoutHistory relation CcPlayoutHistory 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 CcPlayoutHistoryQuery A secondary query class using the current class as primary query - */ - public function useCcPlayoutHistoryQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcPlayoutHistory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcPlayoutHistory', 'CcPlayoutHistoryQuery'); - } + /** + * Filter the query on the last_scheduled column + * + * Example usage: + * + * $query->filterByDbLastScheduled('2011-03-14'); // WHERE last_scheduled = '2011-03-14' + * $query->filterByDbLastScheduled('now'); // WHERE last_scheduled = '2011-03-14' + * $query->filterByDbLastScheduled(array('max' => 'yesterday')); // WHERE last_scheduled < '2011-03-13' + * + * + * @param mixed $dbLastScheduled The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbLastScheduled($dbLastScheduled = null, $comparison = null) + { + if (is_array($dbLastScheduled)) { + $useMinMax = false; + if (isset($dbLastScheduled['min'])) { + $this->addUsingAlias(CcShowInstancesPeer::LAST_SCHEDULED, $dbLastScheduled['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbLastScheduled['max'])) { + $this->addUsingAlias(CcShowInstancesPeer::LAST_SCHEDULED, $dbLastScheduled['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Exclude object from result - * - * @param CcShowInstances $ccShowInstances Object to remove from the list of results - * - * @return CcShowInstancesQuery The current query, for fluid interface - */ - public function prune($ccShowInstances = null) - { - if ($ccShowInstances) { - $this->addUsingAlias(CcShowInstancesPeer::ID, $ccShowInstances->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + return $this->addUsingAlias(CcShowInstancesPeer::LAST_SCHEDULED, $dbLastScheduled, $comparison); + } -} // BaseCcShowInstancesQuery + /** + * Filter the query on the modified_instance column + * + * Example usage: + * + * $query->filterByDbModifiedInstance(true); // WHERE modified_instance = true + * $query->filterByDbModifiedInstance('yes'); // WHERE modified_instance = true + * + * + * @param boolean|string $dbModifiedInstance The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function filterByDbModifiedInstance($dbModifiedInstance = null, $comparison = null) + { + if (is_string($dbModifiedInstance)) { + $dbModifiedInstance = in_array(strtolower($dbModifiedInstance), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CcShowInstancesPeer::MODIFIED_INSTANCE, $dbModifiedInstance, $comparison); + } + + /** + * Filter the query by a related CcShow object + * + * @param CcShow|PropelObjectCollection $ccShow The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcShow($ccShow, $comparison = null) + { + if ($ccShow instanceof CcShow) { + return $this + ->addUsingAlias(CcShowInstancesPeer::SHOW_ID, $ccShow->getDbId(), $comparison); + } elseif ($ccShow instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcShowInstancesPeer::SHOW_ID, $ccShow->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcShow() only accepts arguments of type CcShow or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcShow relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function joinCcShow($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShow'); + + // 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, 'CcShow'); + } + + return $this; + } + + /** + * Use the CcShow relation CcShow 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 \Airtime\CcShowQuery A secondary query class using the current class as primary query + */ + public function useCcShowQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcShow($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShow', '\Airtime\CcShowQuery'); + } + + /** + * Filter the query by a related CcShowInstances object + * + * @param CcShowInstances|PropelObjectCollection $ccShowInstances The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcShowInstancesRelatedByDbOriginalShow($ccShowInstances, $comparison = null) + { + if ($ccShowInstances instanceof CcShowInstances) { + return $this + ->addUsingAlias(CcShowInstancesPeer::INSTANCE_ID, $ccShowInstances->getDbId(), $comparison); + } elseif ($ccShowInstances instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcShowInstancesPeer::INSTANCE_ID, $ccShowInstances->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcShowInstancesRelatedByDbOriginalShow() only accepts arguments of type CcShowInstances or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcShowInstancesRelatedByDbOriginalShow relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function joinCcShowInstancesRelatedByDbOriginalShow($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShowInstancesRelatedByDbOriginalShow'); + + // 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, 'CcShowInstancesRelatedByDbOriginalShow'); + } + + return $this; + } + + /** + * Use the CcShowInstancesRelatedByDbOriginalShow relation CcShowInstances 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 \Airtime\CcShowInstancesQuery A secondary query class using the current class as primary query + */ + public function useCcShowInstancesRelatedByDbOriginalShowQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcShowInstancesRelatedByDbOriginalShow($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShowInstancesRelatedByDbOriginalShow', '\Airtime\CcShowInstancesQuery'); + } + + /** + * Filter the query by a related CcFiles object + * + * @param CcFiles|PropelObjectCollection $ccFiles The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcFiles($ccFiles, $comparison = null) + { + if ($ccFiles instanceof CcFiles) { + return $this + ->addUsingAlias(CcShowInstancesPeer::FILE_ID, $ccFiles->getDbId(), $comparison); + } elseif ($ccFiles instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcShowInstancesPeer::FILE_ID, $ccFiles->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcFiles() only accepts arguments of type CcFiles or PropelCollection'); + } + } + + /** + * 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 CcShowInstancesQuery The current query, for fluid interface + */ + public function joinCcFiles($relationAlias = null, $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 \Airtime\CcFilesQuery A secondary query class using the current class as primary query + */ + public function useCcFilesQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcFiles($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcFiles', '\Airtime\CcFilesQuery'); + } + + /** + * Filter the query by a related CcShowInstances object + * + * @param CcShowInstances|PropelObjectCollection $ccShowInstances the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcShowInstancesRelatedByDbId($ccShowInstances, $comparison = null) + { + if ($ccShowInstances instanceof CcShowInstances) { + return $this + ->addUsingAlias(CcShowInstancesPeer::ID, $ccShowInstances->getDbOriginalShow(), $comparison); + } elseif ($ccShowInstances instanceof PropelObjectCollection) { + return $this + ->useCcShowInstancesRelatedByDbIdQuery() + ->filterByPrimaryKeys($ccShowInstances->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcShowInstancesRelatedByDbId() only accepts arguments of type CcShowInstances or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcShowInstancesRelatedByDbId relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function joinCcShowInstancesRelatedByDbId($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShowInstancesRelatedByDbId'); + + // 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, 'CcShowInstancesRelatedByDbId'); + } + + return $this; + } + + /** + * Use the CcShowInstancesRelatedByDbId relation CcShowInstances 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 \Airtime\CcShowInstancesQuery A secondary query class using the current class as primary query + */ + public function useCcShowInstancesRelatedByDbIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcShowInstancesRelatedByDbId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShowInstancesRelatedByDbId', '\Airtime\CcShowInstancesQuery'); + } + + /** + * Filter the query by a related CcSchedule object + * + * @param CcSchedule|PropelObjectCollection $ccSchedule the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcSchedule($ccSchedule, $comparison = null) + { + if ($ccSchedule instanceof CcSchedule) { + return $this + ->addUsingAlias(CcShowInstancesPeer::ID, $ccSchedule->getDbInstanceId(), $comparison); + } elseif ($ccSchedule instanceof PropelObjectCollection) { + return $this + ->useCcScheduleQuery() + ->filterByPrimaryKeys($ccSchedule->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcSchedule() only accepts arguments of type CcSchedule or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcSchedule relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function joinCcSchedule($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcSchedule'); + + // 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, 'CcSchedule'); + } + + return $this; + } + + /** + * Use the CcSchedule relation CcSchedule 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 \Airtime\CcScheduleQuery A secondary query class using the current class as primary query + */ + public function useCcScheduleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcSchedule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSchedule', '\Airtime\CcScheduleQuery'); + } + + /** + * Filter the query by a related CcPlayoutHistory object + * + * @param CcPlayoutHistory|PropelObjectCollection $ccPlayoutHistory the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowInstancesQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcPlayoutHistory($ccPlayoutHistory, $comparison = null) + { + if ($ccPlayoutHistory instanceof CcPlayoutHistory) { + return $this + ->addUsingAlias(CcShowInstancesPeer::ID, $ccPlayoutHistory->getDbInstanceId(), $comparison); + } elseif ($ccPlayoutHistory instanceof PropelObjectCollection) { + return $this + ->useCcPlayoutHistoryQuery() + ->filterByPrimaryKeys($ccPlayoutHistory->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcPlayoutHistory() only accepts arguments of type CcPlayoutHistory or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcPlayoutHistory relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function joinCcPlayoutHistory($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcPlayoutHistory'); + + // 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, 'CcPlayoutHistory'); + } + + return $this; + } + + /** + * Use the CcPlayoutHistory relation CcPlayoutHistory 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 \Airtime\PlayoutHistory\CcPlayoutHistoryQuery A secondary query class using the current class as primary query + */ + public function useCcPlayoutHistoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcPlayoutHistory($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPlayoutHistory', '\Airtime\PlayoutHistory\CcPlayoutHistoryQuery'); + } + + /** + * Exclude object from result + * + * @param CcShowInstances $ccShowInstances Object to remove from the list of results + * + * @return CcShowInstancesQuery The current query, for fluid interface + */ + public function prune($ccShowInstances = null) + { + if ($ccShowInstances) { + $this->addUsingAlias(CcShowInstancesPeer::ID, $ccShowInstances->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcShowPeer.php index c49ef60fb..8ef2811f0 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowPeer.php @@ -1,802 +1,840 @@ array ('DbId', 'DbName', 'DbUrl', 'DbGenre', 'DbDescription', 'DbColor', 'DbBackgroundColor', 'DbLiveStreamUsingAirtimeAuth', 'DbLiveStreamUsingCustomAuth', 'DbLiveStreamUser', 'DbLiveStreamPass', 'DbLinked', 'DbIsLinkable', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbUrl', 'dbGenre', 'dbDescription', 'dbColor', 'dbBackgroundColor', 'dbLiveStreamUsingAirtimeAuth', 'dbLiveStreamUsingCustomAuth', 'dbLiveStreamUser', 'dbLiveStreamPass', 'dbLinked', 'dbIsLinkable', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::URL, self::GENRE, self::DESCRIPTION, self::COLOR, self::BACKGROUND_COLOR, self::LIVE_STREAM_USING_AIRTIME_AUTH, self::LIVE_STREAM_USING_CUSTOM_AUTH, self::LIVE_STREAM_USER, self::LIVE_STREAM_PASS, self::LINKED, self::IS_LINKABLE, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'URL', 'GENRE', 'DESCRIPTION', 'COLOR', 'BACKGROUND_COLOR', 'LIVE_STREAM_USING_AIRTIME_AUTH', 'LIVE_STREAM_USING_CUSTOM_AUTH', 'LIVE_STREAM_USER', 'LIVE_STREAM_PASS', 'LINKED', 'IS_LINKABLE', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'url', 'genre', 'description', 'color', 'background_color', 'live_stream_using_airtime_auth', 'live_stream_using_custom_auth', 'live_stream_user', 'live_stream_pass', 'linked', 'is_linkable', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) - ); - - /** - * 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, 'DbUrl' => 2, 'DbGenre' => 3, 'DbDescription' => 4, 'DbColor' => 5, 'DbBackgroundColor' => 6, 'DbLiveStreamUsingAirtimeAuth' => 7, 'DbLiveStreamUsingCustomAuth' => 8, 'DbLiveStreamUser' => 9, 'DbLiveStreamPass' => 10, 'DbLinked' => 11, 'DbIsLinkable' => 12, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbUrl' => 2, 'dbGenre' => 3, 'dbDescription' => 4, 'dbColor' => 5, 'dbBackgroundColor' => 6, 'dbLiveStreamUsingAirtimeAuth' => 7, 'dbLiveStreamUsingCustomAuth' => 8, 'dbLiveStreamUser' => 9, 'dbLiveStreamPass' => 10, 'dbLinked' => 11, 'dbIsLinkable' => 12, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::URL => 2, self::GENRE => 3, self::DESCRIPTION => 4, self::COLOR => 5, self::BACKGROUND_COLOR => 6, self::LIVE_STREAM_USING_AIRTIME_AUTH => 7, self::LIVE_STREAM_USING_CUSTOM_AUTH => 8, self::LIVE_STREAM_USER => 9, self::LIVE_STREAM_PASS => 10, self::LINKED => 11, self::IS_LINKABLE => 12, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'URL' => 2, 'GENRE' => 3, 'DESCRIPTION' => 4, 'COLOR' => 5, 'BACKGROUND_COLOR' => 6, 'LIVE_STREAM_USING_AIRTIME_AUTH' => 7, 'LIVE_STREAM_USING_CUSTOM_AUTH' => 8, 'LIVE_STREAM_USER' => 9, 'LIVE_STREAM_PASS' => 10, 'LINKED' => 11, 'IS_LINKABLE' => 12, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'url' => 2, 'genre' => 3, 'description' => 4, 'color' => 5, 'background_color' => 6, 'live_stream_using_airtime_auth' => 7, 'live_stream_using_custom_auth' => 8, 'live_stream_user' => 9, 'live_stream_pass' => 10, 'linked' => 11, 'is_linkable' => 12, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) - ); - - /** - * 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::URL); - $criteria->addSelectColumn(CcShowPeer::GENRE); - $criteria->addSelectColumn(CcShowPeer::DESCRIPTION); - $criteria->addSelectColumn(CcShowPeer::COLOR); - $criteria->addSelectColumn(CcShowPeer::BACKGROUND_COLOR); - $criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH); - $criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH); - $criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_USER); - $criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_PASS); - $criteria->addSelectColumn(CcShowPeer::LINKED); - $criteria->addSelectColumn(CcShowPeer::IS_LINKABLE); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.NAME'); - $criteria->addSelectColumn($alias . '.URL'); - $criteria->addSelectColumn($alias . '.GENRE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.COLOR'); - $criteria->addSelectColumn($alias . '.BACKGROUND_COLOR'); - $criteria->addSelectColumn($alias . '.LIVE_STREAM_USING_AIRTIME_AUTH'); - $criteria->addSelectColumn($alias . '.LIVE_STREAM_USING_CUSTOM_AUTH'); - $criteria->addSelectColumn($alias . '.LIVE_STREAM_USER'); - $criteria->addSelectColumn($alias . '.LIVE_STREAM_PASS'); - $criteria->addSelectColumn($alias . '.LINKED'); - $criteria->addSelectColumn($alias . '.IS_LINKABLE'); - } - } - - /** - * 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() - { - // Invalidate objects in CcShowInstancesPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcShowInstancesPeer::clearInstancePool(); - // Invalidate objects in CcShowDaysPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcShowDaysPeer::clearInstancePool(); - // Invalidate objects in CcShowRebroadcastPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcShowRebroadcastPeer::clearInstancePool(); - // Invalidate objects in CcShowHostsPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcShowHostsPeer::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 = 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; - } +abstract class BaseCcShowPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_show'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcShow'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcShowTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 13; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 13; + + /** the column name for the id field */ + const ID = 'cc_show.id'; + + /** the column name for the name field */ + const NAME = 'cc_show.name'; + + /** the column name for the url field */ + const URL = 'cc_show.url'; + + /** the column name for the genre field */ + const GENRE = 'cc_show.genre'; + + /** the column name for the description field */ + const DESCRIPTION = 'cc_show.description'; + + /** the column name for the color field */ + const COLOR = 'cc_show.color'; + + /** the column name for the background_color field */ + const BACKGROUND_COLOR = 'cc_show.background_color'; + + /** the column name for the live_stream_using_airtime_auth field */ + const LIVE_STREAM_USING_AIRTIME_AUTH = 'cc_show.live_stream_using_airtime_auth'; + + /** the column name for the live_stream_using_custom_auth field */ + const LIVE_STREAM_USING_CUSTOM_AUTH = 'cc_show.live_stream_using_custom_auth'; + + /** the column name for the live_stream_user field */ + const LIVE_STREAM_USER = 'cc_show.live_stream_user'; + + /** the column name for the live_stream_pass field */ + const LIVE_STREAM_PASS = 'cc_show.live_stream_pass'; + + /** the column name for the linked field */ + const LINKED = 'cc_show.linked'; + + /** the column name for the is_linkable field */ + const IS_LINKABLE = 'cc_show.is_linkable'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcShow objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcShow[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcShowPeer::$fieldNames[CcShowPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbUrl', 'DbGenre', 'DbDescription', 'DbColor', 'DbBackgroundColor', 'DbLiveStreamUsingAirtimeAuth', 'DbLiveStreamUsingCustomAuth', 'DbLiveStreamUser', 'DbLiveStreamPass', 'DbLinked', 'DbIsLinkable', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbUrl', 'dbGenre', 'dbDescription', 'dbColor', 'dbBackgroundColor', 'dbLiveStreamUsingAirtimeAuth', 'dbLiveStreamUsingCustomAuth', 'dbLiveStreamUser', 'dbLiveStreamPass', 'dbLinked', 'dbIsLinkable', ), + BasePeer::TYPE_COLNAME => array (CcShowPeer::ID, CcShowPeer::NAME, CcShowPeer::URL, CcShowPeer::GENRE, CcShowPeer::DESCRIPTION, CcShowPeer::COLOR, CcShowPeer::BACKGROUND_COLOR, CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH, CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH, CcShowPeer::LIVE_STREAM_USER, CcShowPeer::LIVE_STREAM_PASS, CcShowPeer::LINKED, CcShowPeer::IS_LINKABLE, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'URL', 'GENRE', 'DESCRIPTION', 'COLOR', 'BACKGROUND_COLOR', 'LIVE_STREAM_USING_AIRTIME_AUTH', 'LIVE_STREAM_USING_CUSTOM_AUTH', 'LIVE_STREAM_USER', 'LIVE_STREAM_PASS', 'LINKED', 'IS_LINKABLE', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'url', 'genre', 'description', 'color', 'background_color', 'live_stream_using_airtime_auth', 'live_stream_using_custom_auth', 'live_stream_user', 'live_stream_pass', 'linked', 'is_linkable', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcShowPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbUrl' => 2, 'DbGenre' => 3, 'DbDescription' => 4, 'DbColor' => 5, 'DbBackgroundColor' => 6, 'DbLiveStreamUsingAirtimeAuth' => 7, 'DbLiveStreamUsingCustomAuth' => 8, 'DbLiveStreamUser' => 9, 'DbLiveStreamPass' => 10, 'DbLinked' => 11, 'DbIsLinkable' => 12, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbUrl' => 2, 'dbGenre' => 3, 'dbDescription' => 4, 'dbColor' => 5, 'dbBackgroundColor' => 6, 'dbLiveStreamUsingAirtimeAuth' => 7, 'dbLiveStreamUsingCustomAuth' => 8, 'dbLiveStreamUser' => 9, 'dbLiveStreamPass' => 10, 'dbLinked' => 11, 'dbIsLinkable' => 12, ), + BasePeer::TYPE_COLNAME => array (CcShowPeer::ID => 0, CcShowPeer::NAME => 1, CcShowPeer::URL => 2, CcShowPeer::GENRE => 3, CcShowPeer::DESCRIPTION => 4, CcShowPeer::COLOR => 5, CcShowPeer::BACKGROUND_COLOR => 6, CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH => 7, CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH => 8, CcShowPeer::LIVE_STREAM_USER => 9, CcShowPeer::LIVE_STREAM_PASS => 10, CcShowPeer::LINKED => 11, CcShowPeer::IS_LINKABLE => 12, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'URL' => 2, 'GENRE' => 3, 'DESCRIPTION' => 4, 'COLOR' => 5, 'BACKGROUND_COLOR' => 6, 'LIVE_STREAM_USING_AIRTIME_AUTH' => 7, 'LIVE_STREAM_USING_CUSTOM_AUTH' => 8, 'LIVE_STREAM_USER' => 9, 'LIVE_STREAM_PASS' => 10, 'LINKED' => 11, 'IS_LINKABLE' => 12, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'url' => 2, 'genre' => 3, 'description' => 4, 'color' => 5, 'background_color' => 6, 'live_stream_using_airtime_auth' => 7, 'live_stream_using_custom_auth' => 8, 'live_stream_user' => 9, 'live_stream_pass' => 10, 'linked' => 11, 'is_linkable' => 12, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcShowPeer::getFieldNames($toType); + $key = isset(CcShowPeer::$fieldKeys[$fromType][$name]) ? CcShowPeer::$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(CcShowPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcShowPeer::$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 CcShowPeer::$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::URL); + $criteria->addSelectColumn(CcShowPeer::GENRE); + $criteria->addSelectColumn(CcShowPeer::DESCRIPTION); + $criteria->addSelectColumn(CcShowPeer::COLOR); + $criteria->addSelectColumn(CcShowPeer::BACKGROUND_COLOR); + $criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH); + $criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH); + $criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_USER); + $criteria->addSelectColumn(CcShowPeer::LIVE_STREAM_PASS); + $criteria->addSelectColumn(CcShowPeer::LINKED); + $criteria->addSelectColumn(CcShowPeer::IS_LINKABLE); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.name'); + $criteria->addSelectColumn($alias . '.url'); + $criteria->addSelectColumn($alias . '.genre'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.color'); + $criteria->addSelectColumn($alias . '.background_color'); + $criteria->addSelectColumn($alias . '.live_stream_using_airtime_auth'); + $criteria->addSelectColumn($alias . '.live_stream_using_custom_auth'); + $criteria->addSelectColumn($alias . '.live_stream_user'); + $criteria->addSelectColumn($alias . '.live_stream_pass'); + $criteria->addSelectColumn($alias . '.linked'); + $criteria->addSelectColumn($alias . '.is_linkable'); + } + } + + /** + * 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(CcShowPeer::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; + } + /** + * Selects 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; + } + /** + * Selects several row from the DB. + * + * @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 directly (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(CcShowPeer::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 $obj 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($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcShowPeer::$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. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + 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(CcShowPeer::$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(CcShowPeer::$instances[$key])) { + return CcShowPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcShowPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcShowPeer::$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() + { + // Invalidate objects in CcShowInstancesPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcShowInstancesPeer::clearInstancePool(); + // Invalidate objects in CcShowDaysPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcShowDaysPeer::clearInstancePool(); + // Invalidate objects in CcShowRebroadcastPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcShowRebroadcastPeer::clearInstancePool(); + // Invalidate objects in CcShowHostsPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcShowHostsPeer::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 = CcShowPeer::getOMClass(); + // 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_HYDRATE_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(CcShowPeer::DATABASE_NAME)->getTable(CcShowPeer::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 \Airtime\map\CcShowTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcShowPeer::OM_CLASS; + } + + /** + * Performs 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(CcShowPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs 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(CcShowPeer::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(CcShowPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_show table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $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 (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs 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(CcShowPeer::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(CcShowPeer::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 (Exception $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($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->hasColumn($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 + * @return CcShow[] + * @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 diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcShowQuery.php index 687335e03..5f681bbe7 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowQuery.php @@ -1,729 +1,995 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcShow|CcShow[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcShowPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcShowPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $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); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcShow A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * 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); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcShow A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "name", "url", "genre", "description", "color", "background_color", "live_stream_using_airtime_auth", "live_stream_using_custom_auth", "live_stream_user", "live_stream_pass", "linked", "is_linkable" FROM "cc_show" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcShow(); + $obj->hydrate($row); + CcShowPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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); - } + return $obj; + } - /** - * 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); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcShow|CcShow[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Filter the query on the url column - * - * @param string $dbUrl 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 filterByDbUrl($dbUrl = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbUrl)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbUrl)) { - $dbUrl = str_replace('*', '%', $dbUrl); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcShowPeer::URL, $dbUrl, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query on the genre column - * - * @param string $dbGenre 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 filterByDbGenre($dbGenre = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbGenre)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbGenre)) { - $dbGenre = str_replace('*', '%', $dbGenre); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcShowPeer::GENRE, $dbGenre, $comparison); - } + /** + * 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|CcShow[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * 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); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Filter the query on the color column - * - * @param string $dbColor 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 filterByDbColor($dbColor = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbColor)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbColor)) { - $dbColor = str_replace('*', '%', $dbColor); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcShowPeer::COLOR, $dbColor, $comparison); - } + /** + * 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) + { - /** - * Filter the query on the background_color column - * - * @param string $dbBackgroundColor 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 filterByDbBackgroundColor($dbBackgroundColor = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbBackgroundColor)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbBackgroundColor)) { - $dbBackgroundColor = str_replace('*', '%', $dbBackgroundColor); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcShowPeer::BACKGROUND_COLOR, $dbBackgroundColor, $comparison); - } + return $this->addUsingAlias(CcShowPeer::ID, $key, Criteria::EQUAL); + } - /** - * Filter the query on the live_stream_using_airtime_auth column - * - * @param boolean|string $dbLiveStreamUsingAirtimeAuth The value to use as filter. - * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowQuery The current query, for fluid interface - */ - public function filterByDbLiveStreamUsingAirtimeAuth($dbLiveStreamUsingAirtimeAuth = null, $comparison = null) - { - if (is_string($dbLiveStreamUsingAirtimeAuth)) { - $live_stream_using_airtime_auth = in_array(strtolower($dbLiveStreamUsingAirtimeAuth), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; - } - return $this->addUsingAlias(CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH, $dbLiveStreamUsingAirtimeAuth, $comparison); - } + /** + * 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) + { - /** - * Filter the query on the live_stream_using_custom_auth column - * - * @param boolean|string $dbLiveStreamUsingCustomAuth The value to use as filter. - * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowQuery The current query, for fluid interface - */ - public function filterByDbLiveStreamUsingCustomAuth($dbLiveStreamUsingCustomAuth = null, $comparison = null) - { - if (is_string($dbLiveStreamUsingCustomAuth)) { - $live_stream_using_custom_auth = in_array(strtolower($dbLiveStreamUsingCustomAuth), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; - } - return $this->addUsingAlias(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH, $dbLiveStreamUsingCustomAuth, $comparison); - } + return $this->addUsingAlias(CcShowPeer::ID, $keys, Criteria::IN); + } - /** - * Filter the query on the live_stream_user column - * - * @param string $dbLiveStreamUser 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 filterByDbLiveStreamUser($dbLiveStreamUser = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbLiveStreamUser)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbLiveStreamUser)) { - $dbLiveStreamUser = str_replace('*', '%', $dbLiveStreamUser); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcShowPeer::LIVE_STREAM_USER, $dbLiveStreamUser, $comparison); - } + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @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)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcShowPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcShowPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Filter the query on the live_stream_pass column - * - * @param string $dbLiveStreamPass 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 filterByDbLiveStreamPass($dbLiveStreamPass = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbLiveStreamPass)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbLiveStreamPass)) { - $dbLiveStreamPass = str_replace('*', '%', $dbLiveStreamPass); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcShowPeer::LIVE_STREAM_PASS, $dbLiveStreamPass, $comparison); - } + return $this->addUsingAlias(CcShowPeer::ID, $dbId, $comparison); + } - /** - * Filter the query on the linked column - * - * @param boolean|string $dbLinked The value to use as filter. - * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowQuery The current query, for fluid interface - */ - public function filterByDbLinked($dbLinked = null, $comparison = null) - { - if (is_string($dbLinked)) { - $linked = in_array(strtolower($dbLinked), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; - } - return $this->addUsingAlias(CcShowPeer::LINKED, $dbLinked, $comparison); - } + /** + * Filter the query on the name column + * + * Example usage: + * + * $query->filterByDbName('fooValue'); // WHERE name = 'fooValue' + * $query->filterByDbName('%fooValue%'); // WHERE name LIKE '%fooValue%' + * + * + * @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; + } + } - /** - * Filter the query on the is_linkable column - * - * @param boolean|string $dbIsLinkable The value to use as filter. - * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowQuery The current query, for fluid interface - */ - public function filterByDbIsLinkable($dbIsLinkable = null, $comparison = null) - { - if (is_string($dbIsLinkable)) { - $is_linkable = in_array(strtolower($dbIsLinkable), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; - } - return $this->addUsingAlias(CcShowPeer::IS_LINKABLE, $dbIsLinkable, $comparison); - } + return $this->addUsingAlias(CcShowPeer::NAME, $dbName, $comparison); + } - /** - * Filter the query by a related CcShowInstances object - * - * @param CcShowInstances $ccShowInstances the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowQuery The current query, for fluid interface - */ - public function filterByCcShowInstances($ccShowInstances, $comparison = null) - { - return $this - ->addUsingAlias(CcShowPeer::ID, $ccShowInstances->getDbShowId(), $comparison); - } + /** + * Filter the query on the url column + * + * Example usage: + * + * $query->filterByDbUrl('fooValue'); // WHERE url = 'fooValue' + * $query->filterByDbUrl('%fooValue%'); // WHERE url LIKE '%fooValue%' + * + * + * @param string $dbUrl 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 filterByDbUrl($dbUrl = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbUrl)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbUrl)) { + $dbUrl = str_replace('*', '%', $dbUrl); + $comparison = Criteria::LIKE; + } + } - /** - * Adds a JOIN clause to the query using the CcShowInstances relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcShowQuery The current query, for fluid interface - */ - public function joinCcShowInstances($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcShowInstances'); - - // 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, 'CcShowInstances'); - } - - return $this; - } + return $this->addUsingAlias(CcShowPeer::URL, $dbUrl, $comparison); + } - /** - * Use the CcShowInstances relation CcShowInstances 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 CcShowInstancesQuery A secondary query class using the current class as primary query - */ - public function useCcShowInstancesQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcShowInstances($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcShowInstances', 'CcShowInstancesQuery'); - } + /** + * Filter the query on the genre column + * + * Example usage: + * + * $query->filterByDbGenre('fooValue'); // WHERE genre = 'fooValue' + * $query->filterByDbGenre('%fooValue%'); // WHERE genre LIKE '%fooValue%' + * + * + * @param string $dbGenre 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 filterByDbGenre($dbGenre = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbGenre)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbGenre)) { + $dbGenre = str_replace('*', '%', $dbGenre); + $comparison = Criteria::LIKE; + } + } - /** - * Filter the query by a related CcShowDays object - * - * @param CcShowDays $ccShowDays the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowQuery The current query, for fluid interface - */ - public function filterByCcShowDays($ccShowDays, $comparison = null) - { - return $this - ->addUsingAlias(CcShowPeer::ID, $ccShowDays->getDbShowId(), $comparison); - } + return $this->addUsingAlias(CcShowPeer::GENRE, $dbGenre, $comparison); + } - /** - * Adds a JOIN clause to the query using the CcShowDays relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcShowQuery The current query, for fluid interface - */ - public function joinCcShowDays($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcShowDays'); - - // 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, 'CcShowDays'); - } - - return $this; - } + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDbDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDbDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @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; + } + } - /** - * Use the CcShowDays relation CcShowDays 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 CcShowDaysQuery A secondary query class using the current class as primary query - */ - public function useCcShowDaysQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcShowDays($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcShowDays', 'CcShowDaysQuery'); - } + return $this->addUsingAlias(CcShowPeer::DESCRIPTION, $dbDescription, $comparison); + } - /** - * Filter the query by a related CcShowRebroadcast object - * - * @param CcShowRebroadcast $ccShowRebroadcast the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowQuery The current query, for fluid interface - */ - public function filterByCcShowRebroadcast($ccShowRebroadcast, $comparison = null) - { - return $this - ->addUsingAlias(CcShowPeer::ID, $ccShowRebroadcast->getDbShowId(), $comparison); - } + /** + * Filter the query on the color column + * + * Example usage: + * + * $query->filterByDbColor('fooValue'); // WHERE color = 'fooValue' + * $query->filterByDbColor('%fooValue%'); // WHERE color LIKE '%fooValue%' + * + * + * @param string $dbColor 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 filterByDbColor($dbColor = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbColor)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbColor)) { + $dbColor = str_replace('*', '%', $dbColor); + $comparison = Criteria::LIKE; + } + } - /** - * Adds a JOIN clause to the query using the CcShowRebroadcast relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcShowQuery The current query, for fluid interface - */ - public function joinCcShowRebroadcast($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcShowRebroadcast'); - - // 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, 'CcShowRebroadcast'); - } - - return $this; - } + return $this->addUsingAlias(CcShowPeer::COLOR, $dbColor, $comparison); + } - /** - * Use the CcShowRebroadcast relation CcShowRebroadcast 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 CcShowRebroadcastQuery A secondary query class using the current class as primary query - */ - public function useCcShowRebroadcastQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcShowRebroadcast($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcShowRebroadcast', 'CcShowRebroadcastQuery'); - } + /** + * Filter the query on the background_color column + * + * Example usage: + * + * $query->filterByDbBackgroundColor('fooValue'); // WHERE background_color = 'fooValue' + * $query->filterByDbBackgroundColor('%fooValue%'); // WHERE background_color LIKE '%fooValue%' + * + * + * @param string $dbBackgroundColor 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 filterByDbBackgroundColor($dbBackgroundColor = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbBackgroundColor)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbBackgroundColor)) { + $dbBackgroundColor = str_replace('*', '%', $dbBackgroundColor); + $comparison = Criteria::LIKE; + } + } - /** - * Filter the query by a related CcShowHosts object - * - * @param CcShowHosts $ccShowHosts the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowQuery The current query, for fluid interface - */ - public function filterByCcShowHosts($ccShowHosts, $comparison = null) - { - return $this - ->addUsingAlias(CcShowPeer::ID, $ccShowHosts->getDbShow(), $comparison); - } + return $this->addUsingAlias(CcShowPeer::BACKGROUND_COLOR, $dbBackgroundColor, $comparison); + } - /** - * Adds a JOIN clause to the query using the CcShowHosts relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcShowQuery The current query, for fluid interface - */ - public function joinCcShowHosts($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcShowHosts'); - - // 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, 'CcShowHosts'); - } - - return $this; - } + /** + * Filter the query on the live_stream_using_airtime_auth column + * + * Example usage: + * + * $query->filterByDbLiveStreamUsingAirtimeAuth(true); // WHERE live_stream_using_airtime_auth = true + * $query->filterByDbLiveStreamUsingAirtimeAuth('yes'); // WHERE live_stream_using_airtime_auth = true + * + * + * @param boolean|string $dbLiveStreamUsingAirtimeAuth The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowQuery The current query, for fluid interface + */ + public function filterByDbLiveStreamUsingAirtimeAuth($dbLiveStreamUsingAirtimeAuth = null, $comparison = null) + { + if (is_string($dbLiveStreamUsingAirtimeAuth)) { + $dbLiveStreamUsingAirtimeAuth = in_array(strtolower($dbLiveStreamUsingAirtimeAuth), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } - /** - * Use the CcShowHosts relation CcShowHosts 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 CcShowHostsQuery A secondary query class using the current class as primary query - */ - public function useCcShowHostsQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcShowHosts($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcShowHosts', 'CcShowHostsQuery'); - } + return $this->addUsingAlias(CcShowPeer::LIVE_STREAM_USING_AIRTIME_AUTH, $dbLiveStreamUsingAirtimeAuth, $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; - } + /** + * Filter the query on the live_stream_using_custom_auth column + * + * Example usage: + * + * $query->filterByDbLiveStreamUsingCustomAuth(true); // WHERE live_stream_using_custom_auth = true + * $query->filterByDbLiveStreamUsingCustomAuth('yes'); // WHERE live_stream_using_custom_auth = true + * + * + * @param boolean|string $dbLiveStreamUsingCustomAuth The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowQuery The current query, for fluid interface + */ + public function filterByDbLiveStreamUsingCustomAuth($dbLiveStreamUsingCustomAuth = null, $comparison = null) + { + if (is_string($dbLiveStreamUsingCustomAuth)) { + $dbLiveStreamUsingCustomAuth = in_array(strtolower($dbLiveStreamUsingCustomAuth), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } -} // BaseCcShowQuery + return $this->addUsingAlias(CcShowPeer::LIVE_STREAM_USING_CUSTOM_AUTH, $dbLiveStreamUsingCustomAuth, $comparison); + } + + /** + * Filter the query on the live_stream_user column + * + * Example usage: + * + * $query->filterByDbLiveStreamUser('fooValue'); // WHERE live_stream_user = 'fooValue' + * $query->filterByDbLiveStreamUser('%fooValue%'); // WHERE live_stream_user LIKE '%fooValue%' + * + * + * @param string $dbLiveStreamUser 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 filterByDbLiveStreamUser($dbLiveStreamUser = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLiveStreamUser)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLiveStreamUser)) { + $dbLiveStreamUser = str_replace('*', '%', $dbLiveStreamUser); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcShowPeer::LIVE_STREAM_USER, $dbLiveStreamUser, $comparison); + } + + /** + * Filter the query on the live_stream_pass column + * + * Example usage: + * + * $query->filterByDbLiveStreamPass('fooValue'); // WHERE live_stream_pass = 'fooValue' + * $query->filterByDbLiveStreamPass('%fooValue%'); // WHERE live_stream_pass LIKE '%fooValue%' + * + * + * @param string $dbLiveStreamPass 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 filterByDbLiveStreamPass($dbLiveStreamPass = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLiveStreamPass)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLiveStreamPass)) { + $dbLiveStreamPass = str_replace('*', '%', $dbLiveStreamPass); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcShowPeer::LIVE_STREAM_PASS, $dbLiveStreamPass, $comparison); + } + + /** + * Filter the query on the linked column + * + * Example usage: + * + * $query->filterByDbLinked(true); // WHERE linked = true + * $query->filterByDbLinked('yes'); // WHERE linked = true + * + * + * @param boolean|string $dbLinked The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowQuery The current query, for fluid interface + */ + public function filterByDbLinked($dbLinked = null, $comparison = null) + { + if (is_string($dbLinked)) { + $dbLinked = in_array(strtolower($dbLinked), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CcShowPeer::LINKED, $dbLinked, $comparison); + } + + /** + * Filter the query on the is_linkable column + * + * Example usage: + * + * $query->filterByDbIsLinkable(true); // WHERE is_linkable = true + * $query->filterByDbIsLinkable('yes'); // WHERE is_linkable = true + * + * + * @param boolean|string $dbIsLinkable The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowQuery The current query, for fluid interface + */ + public function filterByDbIsLinkable($dbIsLinkable = null, $comparison = null) + { + if (is_string($dbIsLinkable)) { + $dbIsLinkable = in_array(strtolower($dbIsLinkable), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CcShowPeer::IS_LINKABLE, $dbIsLinkable, $comparison); + } + + /** + * Filter the query by a related CcShowInstances object + * + * @param CcShowInstances|PropelObjectCollection $ccShowInstances the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcShowInstances($ccShowInstances, $comparison = null) + { + if ($ccShowInstances instanceof CcShowInstances) { + return $this + ->addUsingAlias(CcShowPeer::ID, $ccShowInstances->getDbShowId(), $comparison); + } elseif ($ccShowInstances instanceof PropelObjectCollection) { + return $this + ->useCcShowInstancesQuery() + ->filterByPrimaryKeys($ccShowInstances->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcShowInstances() only accepts arguments of type CcShowInstances or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcShowInstances relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowQuery The current query, for fluid interface + */ + public function joinCcShowInstances($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShowInstances'); + + // 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, 'CcShowInstances'); + } + + return $this; + } + + /** + * Use the CcShowInstances relation CcShowInstances 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 \Airtime\CcShowInstancesQuery A secondary query class using the current class as primary query + */ + public function useCcShowInstancesQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcShowInstances($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShowInstances', '\Airtime\CcShowInstancesQuery'); + } + + /** + * Filter the query by a related CcShowDays object + * + * @param CcShowDays|PropelObjectCollection $ccShowDays the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcShowDays($ccShowDays, $comparison = null) + { + if ($ccShowDays instanceof CcShowDays) { + return $this + ->addUsingAlias(CcShowPeer::ID, $ccShowDays->getDbShowId(), $comparison); + } elseif ($ccShowDays instanceof PropelObjectCollection) { + return $this + ->useCcShowDaysQuery() + ->filterByPrimaryKeys($ccShowDays->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcShowDays() only accepts arguments of type CcShowDays or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcShowDays relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowQuery The current query, for fluid interface + */ + public function joinCcShowDays($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShowDays'); + + // 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, 'CcShowDays'); + } + + return $this; + } + + /** + * Use the CcShowDays relation CcShowDays 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 \Airtime\CcShowDaysQuery A secondary query class using the current class as primary query + */ + public function useCcShowDaysQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcShowDays($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShowDays', '\Airtime\CcShowDaysQuery'); + } + + /** + * Filter the query by a related CcShowRebroadcast object + * + * @param CcShowRebroadcast|PropelObjectCollection $ccShowRebroadcast the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcShowRebroadcast($ccShowRebroadcast, $comparison = null) + { + if ($ccShowRebroadcast instanceof CcShowRebroadcast) { + return $this + ->addUsingAlias(CcShowPeer::ID, $ccShowRebroadcast->getDbShowId(), $comparison); + } elseif ($ccShowRebroadcast instanceof PropelObjectCollection) { + return $this + ->useCcShowRebroadcastQuery() + ->filterByPrimaryKeys($ccShowRebroadcast->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcShowRebroadcast() only accepts arguments of type CcShowRebroadcast or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcShowRebroadcast relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowQuery The current query, for fluid interface + */ + public function joinCcShowRebroadcast($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShowRebroadcast'); + + // 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, 'CcShowRebroadcast'); + } + + return $this; + } + + /** + * Use the CcShowRebroadcast relation CcShowRebroadcast 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 \Airtime\CcShowRebroadcastQuery A secondary query class using the current class as primary query + */ + public function useCcShowRebroadcastQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcShowRebroadcast($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShowRebroadcast', '\Airtime\CcShowRebroadcastQuery'); + } + + /** + * Filter the query by a related CcShowHosts object + * + * @param CcShowHosts|PropelObjectCollection $ccShowHosts the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcShowHosts($ccShowHosts, $comparison = null) + { + if ($ccShowHosts instanceof CcShowHosts) { + return $this + ->addUsingAlias(CcShowPeer::ID, $ccShowHosts->getDbShow(), $comparison); + } elseif ($ccShowHosts instanceof PropelObjectCollection) { + return $this + ->useCcShowHostsQuery() + ->filterByPrimaryKeys($ccShowHosts->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcShowHosts() only accepts arguments of type CcShowHosts or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcShowHosts relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowQuery The current query, for fluid interface + */ + public function joinCcShowHosts($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShowHosts'); + + // 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, 'CcShowHosts'); + } + + return $this; + } + + /** + * Use the CcShowHosts relation CcShowHosts 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 \Airtime\CcShowHostsQuery A secondary query class using the current class as primary query + */ + public function useCcShowHostsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcShowHosts($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShowHosts', '\Airtime\CcShowHostsQuery'); + } + + /** + * 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; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowRebroadcast.php b/airtime_mvc/application/models/airtime/om/BaseCcShowRebroadcast.php index aabd37d79..6db2c7393 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowRebroadcast.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowRebroadcast.php @@ -1,957 +1,1095 @@ id; - } - - /** - * Get the [day_offset] column value. - * - * @return string - */ - public function getDbDayOffset() - { - return $this->day_offset; - } - - /** - * 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 [show_id] column value. - * - * @return int - */ - public function getDbShowId() - { - return $this->show_id; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcShowRebroadcast 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[] = CcShowRebroadcastPeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [day_offset] column. - * - * @param string $v new value - * @return CcShowRebroadcast The current object (for fluent API support) - */ - public function setDbDayOffset($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->day_offset !== $v) { - $this->day_offset = $v; - $this->modifiedColumns[] = CcShowRebroadcastPeer::DAY_OFFSET; - } - - return $this; - } // setDbDayOffset() - - /** - * 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 CcShowRebroadcast 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[] = CcShowRebroadcastPeer::START_TIME; - } - } // if either are not null - - return $this; - } // setDbStartTime() - - /** - * Set the value of [show_id] column. - * - * @param int $v new value - * @return CcShowRebroadcast The current object (for fluent API support) - */ - public function setDbShowId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->show_id !== $v) { - $this->show_id = $v; - $this->modifiedColumns[] = CcShowRebroadcastPeer::SHOW_ID; - } - - if ($this->aCcShow !== null && $this->aCcShow->getDbId() !== $v) { - $this->aCcShow = null; - } - - return $this; - } // setDbShowId() - - /** - * 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->day_offset = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->start_time = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->show_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 4; // 4 = CcShowRebroadcastPeer::NUM_COLUMNS - CcShowRebroadcastPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcShowRebroadcast 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->aCcShow !== null && $this->show_id !== $this->aCcShow->getDbId()) { - $this->aCcShow = 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(CcShowRebroadcastPeer::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 = CcShowRebroadcastPeer::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->aCcShow = 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(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcShowRebroadcastQuery::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(CcShowRebroadcastPeer::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); - CcShowRebroadcastPeer::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->aCcShow !== null) { - if ($this->aCcShow->isModified() || $this->aCcShow->isNew()) { - $affectedRows += $this->aCcShow->save($con); - } - $this->setCcShow($this->aCcShow); - } - - if ($this->isNew() ) { - $this->modifiedColumns[] = CcShowRebroadcastPeer::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(CcShowRebroadcastPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowRebroadcastPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows += 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows += CcShowRebroadcastPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcShow !== null) { - if (!$this->aCcShow->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcShow->getValidationFailures()); - } - } - - - if (($retval = CcShowRebroadcastPeer::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 = CcShowRebroadcastPeer::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->getDbDayOffset(); - break; - case 2: - return $this->getDbStartTime(); - break; - case 3: - return $this->getDbShowId(); - 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 = CcShowRebroadcastPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbDayOffset(), - $keys[2] => $this->getDbStartTime(), - $keys[3] => $this->getDbShowId(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCcShow) { - $result['CcShow'] = $this->aCcShow->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 = CcShowRebroadcastPeer::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->setDbDayOffset($value); - break; - case 2: - $this->setDbStartTime($value); - break; - case 3: - $this->setDbShowId($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 = CcShowRebroadcastPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbDayOffset($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbStartTime($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbShowId($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(CcShowRebroadcastPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcShowRebroadcastPeer::ID)) $criteria->add(CcShowRebroadcastPeer::ID, $this->id); - if ($this->isColumnModified(CcShowRebroadcastPeer::DAY_OFFSET)) $criteria->add(CcShowRebroadcastPeer::DAY_OFFSET, $this->day_offset); - if ($this->isColumnModified(CcShowRebroadcastPeer::START_TIME)) $criteria->add(CcShowRebroadcastPeer::START_TIME, $this->start_time); - if ($this->isColumnModified(CcShowRebroadcastPeer::SHOW_ID)) $criteria->add(CcShowRebroadcastPeer::SHOW_ID, $this->show_id); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(CcShowRebroadcastPeer::DATABASE_NAME); - $criteria->add(CcShowRebroadcastPeer::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 CcShowRebroadcast (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->setDbDayOffset($this->day_offset); - $copyObj->setDbStartTime($this->start_time); - $copyObj->setDbShowId($this->show_id); - - $copyObj->setNew(true); - $copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return CcShowRebroadcast 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 CcShowRebroadcastPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcShowRebroadcastPeer(); - } - return self::$peer; - } - - /** - * Declares an association between this object and a CcShow object. - * - * @param CcShow $v - * @return CcShowRebroadcast The current object (for fluent API support) - * @throws PropelException - */ - public function setCcShow(CcShow $v = null) - { - if ($v === null) { - $this->setDbShowId(NULL); - } else { - $this->setDbShowId($v->getDbId()); - } - - $this->aCcShow = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcShow object, it will not be re-added. - if ($v !== null) { - $v->addCcShowRebroadcast($this); - } - - return $this; - } - - - /** - * Get the associated CcShow object - * - * @param PropelPDO Optional Connection object. - * @return CcShow The associated CcShow object. - * @throws PropelException - */ - public function getCcShow(PropelPDO $con = null) - { - if ($this->aCcShow === null && ($this->show_id !== null)) { - $this->aCcShow = CcShowQuery::create()->findPk($this->show_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->aCcShow->addCcShowRebroadcasts($this); - */ - } - return $this->aCcShow; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->day_offset = null; - $this->start_time = null; - $this->show_id = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all collections of referencing foreign keys. - * - * This method is a user-space workaround for PHP's inability to garbage collect objects - * with circular references. This is currently necessary when using Propel in certain - * daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all associated objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep) { - } // if ($deep) - - $this->aCcShow = 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); - } - -} // BaseCcShowRebroadcast + /** + * Peer class name + */ + const PEER = 'Airtime\\CcShowRebroadcastPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcShowRebroadcastPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the day_offset field. + * @var string + */ + protected $day_offset; + + /** + * The value for the start_time field. + * @var string + */ + protected $start_time; + + /** + * The value for the show_id field. + * @var int + */ + protected $show_id; + + /** + * @var CcShow + */ + protected $aCcShow; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * Get the [id] column value. + * + * @return int + */ + public function getDbId() + { + + return $this->id; + } + + /** + * Get the [day_offset] column value. + * + * @return string + */ + public function getDbDayOffset() + { + + return $this->day_offset; + } + + /** + * 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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [show_id] column value. + * + * @return int + */ + public function getDbShowId() + { + + return $this->show_id; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcShowRebroadcast The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcShowRebroadcastPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [day_offset] column. + * + * @param string $v new value + * @return CcShowRebroadcast The current object (for fluent API support) + */ + public function setDbDayOffset($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->day_offset !== $v) { + $this->day_offset = $v; + $this->modifiedColumns[] = CcShowRebroadcastPeer::DAY_OFFSET; + } + + + return $this; + } // setDbDayOffset() + + /** + * 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 strings are treated as null. + * @return CcShowRebroadcast The current object (for fluent API support) + */ + public function setDbStartTime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->start_time !== null || $dt !== null) { + $currentDateAsString = ($this->start_time !== null && $tmpDt = new DateTime($this->start_time)) ? $tmpDt->format('H:i:s') : null; + $newDateAsString = $dt ? $dt->format('H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->start_time = $newDateAsString; + $this->modifiedColumns[] = CcShowRebroadcastPeer::START_TIME; + } + } // if either are not null + + + return $this; + } // setDbStartTime() + + /** + * Set the value of [show_id] column. + * + * @param int $v new value + * @return CcShowRebroadcast The current object (for fluent API support) + */ + public function setDbShowId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->show_id !== $v) { + $this->show_id = $v; + $this->modifiedColumns[] = CcShowRebroadcastPeer::SHOW_ID; + } + + if ($this->aCcShow !== null && $this->aCcShow->getDbId() !== $v) { + $this->aCcShow = null; + } + + + return $this; + } // setDbShowId() + + /** + * 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 resultset 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->day_offset = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->start_time = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->show_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 4; // 4 = CcShowRebroadcastPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcShowRebroadcast 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->aCcShow !== null && $this->show_id !== $this->aCcShow->getDbId()) { + $this->aCcShow = 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(CcShowRebroadcastPeer::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 = CcShowRebroadcastPeer::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->aCcShow = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcShowRebroadcastQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcShowRebroadcastPeer::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); + CcShowRebroadcastPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcShow !== null) { + if ($this->aCcShow->isModified() || $this->aCcShow->isNew()) { + $affectedRows += $this->aCcShow->save($con); + } + $this->setCcShow($this->aCcShow); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcShowRebroadcastPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcShowRebroadcastPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_show_rebroadcast_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcShowRebroadcastPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcShowRebroadcastPeer::DAY_OFFSET)) { + $modifiedColumns[':p' . $index++] = '"day_offset"'; + } + if ($this->isColumnModified(CcShowRebroadcastPeer::START_TIME)) { + $modifiedColumns[':p' . $index++] = '"start_time"'; + } + if ($this->isColumnModified(CcShowRebroadcastPeer::SHOW_ID)) { + $modifiedColumns[':p' . $index++] = '"show_id"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_show_rebroadcast" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"day_offset"': + $stmt->bindValue($identifier, $this->day_offset, PDO::PARAM_STR); + break; + case '"start_time"': + $stmt->bindValue($identifier, $this->start_time, PDO::PARAM_STR); + break; + case '"show_id"': + $stmt->bindValue($identifier, $this->show_id, PDO::PARAM_INT); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcShow !== null) { + if (!$this->aCcShow->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcShow->getValidationFailures()); + } + } + + + if (($retval = CcShowRebroadcastPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcShowRebroadcastPeer::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->getDbDayOffset(); + break; + case 2: + return $this->getDbStartTime(); + break; + case 3: + return $this->getDbShowId(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcShowRebroadcast'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcShowRebroadcast'][$this->getPrimaryKey()] = true; + $keys = CcShowRebroadcastPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbDayOffset(), + $keys[2] => $this->getDbStartTime(), + $keys[3] => $this->getDbShowId(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcShow) { + $result['CcShow'] = $this->aCcShow->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcShowRebroadcastPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbDayOffset($value); + break; + case 2: + $this->setDbStartTime($value); + break; + case 3: + $this->setDbShowId($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcShowRebroadcastPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbDayOffset($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbStartTime($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbShowId($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(CcShowRebroadcastPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcShowRebroadcastPeer::ID)) $criteria->add(CcShowRebroadcastPeer::ID, $this->id); + if ($this->isColumnModified(CcShowRebroadcastPeer::DAY_OFFSET)) $criteria->add(CcShowRebroadcastPeer::DAY_OFFSET, $this->day_offset); + if ($this->isColumnModified(CcShowRebroadcastPeer::START_TIME)) $criteria->add(CcShowRebroadcastPeer::START_TIME, $this->start_time); + if ($this->isColumnModified(CcShowRebroadcastPeer::SHOW_ID)) $criteria->add(CcShowRebroadcastPeer::SHOW_ID, $this->show_id); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(CcShowRebroadcastPeer::DATABASE_NAME); + $criteria->add(CcShowRebroadcastPeer::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 CcShowRebroadcast (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbDayOffset($this->getDbDayOffset()); + $copyObj->setDbStartTime($this->getDbStartTime()); + $copyObj->setDbShowId($this->getDbShowId()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcShowRebroadcast 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 CcShowRebroadcastPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcShowRebroadcastPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a CcShow object. + * + * @param CcShow $v + * @return CcShowRebroadcast The current object (for fluent API support) + * @throws PropelException + */ + public function setCcShow(CcShow $v = null) + { + if ($v === null) { + $this->setDbShowId(NULL); + } else { + $this->setDbShowId($v->getDbId()); + } + + $this->aCcShow = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcShow object, it will not be re-added. + if ($v !== null) { + $v->addCcShowRebroadcast($this); + } + + + return $this; + } + + + /** + * Get the associated CcShow object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcShow The associated CcShow object. + * @throws PropelException + */ + public function getCcShow(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcShow === null && ($this->show_id !== null) && $doQuery) { + $this->aCcShow = CcShowQuery::create()->findPk($this->show_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->aCcShow->addCcShowRebroadcasts($this); + */ + } + + return $this->aCcShow; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->day_offset = null; + $this->start_time = null; + $this->show_id = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCcShow instanceof Persistent) { + $this->aCcShow->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + $this->aCcShow = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcShowRebroadcastPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowRebroadcastPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcShowRebroadcastPeer.php index ef0434c70..90c3d3d87 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowRebroadcastPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowRebroadcastPeer.php @@ -1,979 +1,1018 @@ array ('DbId', 'DbDayOffset', 'DbStartTime', 'DbShowId', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbDayOffset', 'dbStartTime', 'dbShowId', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::DAY_OFFSET, self::START_TIME, self::SHOW_ID, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'DAY_OFFSET', 'START_TIME', 'SHOW_ID', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'day_offset', 'start_time', 'show_id', ), - 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 ('DbId' => 0, 'DbDayOffset' => 1, 'DbStartTime' => 2, 'DbShowId' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbDayOffset' => 1, 'dbStartTime' => 2, 'dbShowId' => 3, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::DAY_OFFSET => 1, self::START_TIME => 2, self::SHOW_ID => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'DAY_OFFSET' => 1, 'START_TIME' => 2, 'SHOW_ID' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'day_offset' => 1, 'start_time' => 2, 'show_id' => 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. CcShowRebroadcastPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcShowRebroadcastPeer::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(CcShowRebroadcastPeer::ID); - $criteria->addSelectColumn(CcShowRebroadcastPeer::DAY_OFFSET); - $criteria->addSelectColumn(CcShowRebroadcastPeer::START_TIME); - $criteria->addSelectColumn(CcShowRebroadcastPeer::SHOW_ID); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.DAY_OFFSET'); - $criteria->addSelectColumn($alias . '.START_TIME'); - $criteria->addSelectColumn($alias . '.SHOW_ID'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CcShowRebroadcastPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowRebroadcastPeer::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(CcShowRebroadcastPeer::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 CcShowRebroadcast - * @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 = CcShowRebroadcastPeer::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 CcShowRebroadcastPeer::populateObjects(CcShowRebroadcastPeer::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(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcShowRebroadcastPeer::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 CcShowRebroadcast $value A CcShowRebroadcast object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcShowRebroadcast $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 CcShowRebroadcast object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcShowRebroadcast) { - $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 CcShowRebroadcast 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 CcShowRebroadcast 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_rebroadcast - * 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 = CcShowRebroadcastPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcShowRebroadcastPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcShowRebroadcastPeer::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; - CcShowRebroadcastPeer::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 (CcShowRebroadcast object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcShowRebroadcastPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcShowRebroadcastPeer::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 + CcShowRebroadcastPeer::NUM_COLUMNS; - } else { - $cls = CcShowRebroadcastPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcShowRebroadcastPeer::addInstanceToPool($obj, $key); - } - return array($obj, $col); - } - - /** - * Returns the number of rows matching criteria, joining the related CcShow 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 doCountJoinCcShow(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(CcShowRebroadcastPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowRebroadcastPeer::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(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcShowRebroadcastPeer::SHOW_ID, CcShowPeer::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 CcShowRebroadcast objects pre-filled with their CcShow 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 CcShowRebroadcast objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCcShow(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); - } - - CcShowRebroadcastPeer::addSelectColumns($criteria); - $startcol = (CcShowRebroadcastPeer::NUM_COLUMNS - CcShowRebroadcastPeer::NUM_LAZY_LOAD_COLUMNS); - CcShowPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcShowRebroadcastPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcShowRebroadcastPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcShowRebroadcastPeer::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 = CcShowRebroadcastPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcShowRebroadcastPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcShowPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcShowPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcShowRebroadcast) to $obj2 (CcShow) - $obj2->addCcShowRebroadcast($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(CcShowRebroadcastPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowRebroadcastPeer::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(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcShowRebroadcastPeer::SHOW_ID, CcShowPeer::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 CcShowRebroadcast 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 CcShowRebroadcast 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); - } - - CcShowRebroadcastPeer::addSelectColumns($criteria); - $startcol2 = (CcShowRebroadcastPeer::NUM_COLUMNS - CcShowRebroadcastPeer::NUM_LAZY_LOAD_COLUMNS); - - CcShowPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcShowRebroadcastPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcShowRebroadcastPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcShowRebroadcastPeer::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 = CcShowRebroadcastPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcShowRebroadcastPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcShow rows - - $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcShowPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcShowPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (CcShowRebroadcast) to the collection in $obj2 (CcShow) - $obj2->addCcShowRebroadcast($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(BaseCcShowRebroadcastPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcShowRebroadcastPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcShowRebroadcastTableMap()); - } - } - - /** - * 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 ? CcShowRebroadcastPeer::CLASS_DEFAULT : CcShowRebroadcastPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcShowRebroadcast or Criteria object. - * - * @param mixed $values Criteria or CcShowRebroadcast 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(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcShowRebroadcast object - } - - if ($criteria->containsKey(CcShowRebroadcastPeer::ID) && $criteria->keyContainsValue(CcShowRebroadcastPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowRebroadcastPeer::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 CcShowRebroadcast or Criteria object. - * - * @param mixed $values Criteria or CcShowRebroadcast 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(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcShowRebroadcastPeer::ID); - $value = $criteria->remove(CcShowRebroadcastPeer::ID); - if ($value) { - $selectCriteria->add(CcShowRebroadcastPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcShowRebroadcastPeer::TABLE_NAME); - } - - } else { // $values is CcShowRebroadcast 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_rebroadcast 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(CcShowRebroadcastPeer::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(CcShowRebroadcastPeer::TABLE_NAME, $con, CcShowRebroadcastPeer::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). - CcShowRebroadcastPeer::clearInstancePool(); - CcShowRebroadcastPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcShowRebroadcast or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcShowRebroadcast 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(CcShowRebroadcastPeer::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. - CcShowRebroadcastPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcShowRebroadcast) { // it's a model object - // invalidate the cache for this single object - CcShowRebroadcastPeer::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(CcShowRebroadcastPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcShowRebroadcastPeer::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); - CcShowRebroadcastPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcShowRebroadcast 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 CcShowRebroadcast $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(CcShowRebroadcast $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcShowRebroadcastPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcShowRebroadcastPeer::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(CcShowRebroadcastPeer::DATABASE_NAME, CcShowRebroadcastPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcShowRebroadcast - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcShowRebroadcastPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcShowRebroadcastPeer::DATABASE_NAME); - $criteria->add(CcShowRebroadcastPeer::ID, $pk); - - $v = CcShowRebroadcastPeer::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(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcShowRebroadcastPeer::DATABASE_NAME); - $criteria->add(CcShowRebroadcastPeer::ID, $pks, Criteria::IN); - $objs = CcShowRebroadcastPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcShowRebroadcastPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_show_rebroadcast'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcShowRebroadcast'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcShowRebroadcastTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 4; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 4; + + /** the column name for the id field */ + const ID = 'cc_show_rebroadcast.id'; + + /** the column name for the day_offset field */ + const DAY_OFFSET = 'cc_show_rebroadcast.day_offset'; + + /** the column name for the start_time field */ + const START_TIME = 'cc_show_rebroadcast.start_time'; + + /** the column name for the show_id field */ + const SHOW_ID = 'cc_show_rebroadcast.show_id'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcShowRebroadcast objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcShowRebroadcast[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcShowRebroadcastPeer::$fieldNames[CcShowRebroadcastPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbDayOffset', 'DbStartTime', 'DbShowId', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbDayOffset', 'dbStartTime', 'dbShowId', ), + BasePeer::TYPE_COLNAME => array (CcShowRebroadcastPeer::ID, CcShowRebroadcastPeer::DAY_OFFSET, CcShowRebroadcastPeer::START_TIME, CcShowRebroadcastPeer::SHOW_ID, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'DAY_OFFSET', 'START_TIME', 'SHOW_ID', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'day_offset', 'start_time', 'show_id', ), + 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. CcShowRebroadcastPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbDayOffset' => 1, 'DbStartTime' => 2, 'DbShowId' => 3, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbDayOffset' => 1, 'dbStartTime' => 2, 'dbShowId' => 3, ), + BasePeer::TYPE_COLNAME => array (CcShowRebroadcastPeer::ID => 0, CcShowRebroadcastPeer::DAY_OFFSET => 1, CcShowRebroadcastPeer::START_TIME => 2, CcShowRebroadcastPeer::SHOW_ID => 3, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'DAY_OFFSET' => 1, 'START_TIME' => 2, 'SHOW_ID' => 3, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'day_offset' => 1, 'start_time' => 2, 'show_id' => 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcShowRebroadcastPeer::getFieldNames($toType); + $key = isset(CcShowRebroadcastPeer::$fieldKeys[$fromType][$name]) ? CcShowRebroadcastPeer::$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(CcShowRebroadcastPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcShowRebroadcastPeer::$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 CcShowRebroadcastPeer::$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. CcShowRebroadcastPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcShowRebroadcastPeer::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(CcShowRebroadcastPeer::ID); + $criteria->addSelectColumn(CcShowRebroadcastPeer::DAY_OFFSET); + $criteria->addSelectColumn(CcShowRebroadcastPeer::START_TIME); + $criteria->addSelectColumn(CcShowRebroadcastPeer::SHOW_ID); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.day_offset'); + $criteria->addSelectColumn($alias . '.start_time'); + $criteria->addSelectColumn($alias . '.show_id'); + } + } + + /** + * Returns the number of rows matching criteria. + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. + * @param PropelPDO $con + * @return int Number of matching rows. + */ + public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) + { + // we may modify criteria, so copy it first + $criteria = clone $criteria; + + // We need to set the primary table name, since in the case that there are no WHERE columns + // it will be impossible for the BasePeer::createSelectSql() method to determine which + // tables go into the FROM clause. + $criteria->setPrimaryTableName(CcShowRebroadcastPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowRebroadcastPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcShowRebroadcastPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcShowRebroadcast + * @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 = CcShowRebroadcastPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcShowRebroadcastPeer::populateObjects(CcShowRebroadcastPeer::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 directly (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(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcShowRebroadcastPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcShowRebroadcastPeer::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 CcShowRebroadcast $obj A CcShowRebroadcast object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcShowRebroadcastPeer::$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 CcShowRebroadcast object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcShowRebroadcast) { + $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 CcShowRebroadcast object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcShowRebroadcastPeer::$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 CcShowRebroadcast 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(CcShowRebroadcastPeer::$instances[$key])) { + return CcShowRebroadcastPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcShowRebroadcastPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcShowRebroadcastPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_show_rebroadcast + * 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 = CcShowRebroadcastPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcShowRebroadcastPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcShowRebroadcastPeer::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; + CcShowRebroadcastPeer::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 (CcShowRebroadcast object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcShowRebroadcastPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcShowRebroadcastPeer::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 + CcShowRebroadcastPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcShowRebroadcastPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcShowRebroadcastPeer::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + + /** + * Returns the number of rows matching criteria, joining the related CcShow 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 doCountJoinCcShow(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(CcShowRebroadcastPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowRebroadcastPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcShowRebroadcastPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowRebroadcastPeer::SHOW_ID, CcShowPeer::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 CcShowRebroadcast objects pre-filled with their CcShow 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 CcShowRebroadcast objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcShow(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(CcShowRebroadcastPeer::DATABASE_NAME); + } + + CcShowRebroadcastPeer::addSelectColumns($criteria); + $startcol = CcShowRebroadcastPeer::NUM_HYDRATE_COLUMNS; + CcShowPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcShowRebroadcastPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowRebroadcastPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowRebroadcastPeer::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 = CcShowRebroadcastPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowRebroadcastPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcShowPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcShowPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcShowRebroadcast) to $obj2 (CcShow) + $obj2->addCcShowRebroadcast($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(CcShowRebroadcastPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcShowRebroadcastPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcShowRebroadcastPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcShowRebroadcastPeer::SHOW_ID, CcShowPeer::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 CcShowRebroadcast 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 CcShowRebroadcast 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(CcShowRebroadcastPeer::DATABASE_NAME); + } + + CcShowRebroadcastPeer::addSelectColumns($criteria); + $startcol2 = CcShowRebroadcastPeer::NUM_HYDRATE_COLUMNS; + + CcShowPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcShowPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcShowRebroadcastPeer::SHOW_ID, CcShowPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcShowRebroadcastPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcShowRebroadcastPeer::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 = CcShowRebroadcastPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcShowRebroadcastPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcShow rows + + $key2 = CcShowPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcShowPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcShowPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcShowPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcShowRebroadcast) to the collection in $obj2 (CcShow) + $obj2->addCcShowRebroadcast($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(CcShowRebroadcastPeer::DATABASE_NAME)->getTable(CcShowRebroadcastPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcShowRebroadcastPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcShowRebroadcastPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcShowRebroadcastTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcShowRebroadcastPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcShowRebroadcast or Criteria object. + * + * @param mixed $values Criteria or CcShowRebroadcast 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(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcShowRebroadcast object + } + + if ($criteria->containsKey(CcShowRebroadcastPeer::ID) && $criteria->keyContainsValue(CcShowRebroadcastPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowRebroadcastPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcShowRebroadcastPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcShowRebroadcast or Criteria object. + * + * @param mixed $values Criteria or CcShowRebroadcast 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(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcShowRebroadcastPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcShowRebroadcastPeer::ID); + $value = $criteria->remove(CcShowRebroadcastPeer::ID); + if ($value) { + $selectCriteria->add(CcShowRebroadcastPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcShowRebroadcastPeer::TABLE_NAME); + } + + } else { // $values is CcShowRebroadcast object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcShowRebroadcastPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_show_rebroadcast table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::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(CcShowRebroadcastPeer::TABLE_NAME, $con, CcShowRebroadcastPeer::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). + CcShowRebroadcastPeer::clearInstancePool(); + CcShowRebroadcastPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcShowRebroadcast or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcShowRebroadcast 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(CcShowRebroadcastPeer::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. + CcShowRebroadcastPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcShowRebroadcast) { // it's a model object + // invalidate the cache for this single object + CcShowRebroadcastPeer::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(CcShowRebroadcastPeer::DATABASE_NAME); + $criteria->add(CcShowRebroadcastPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcShowRebroadcastPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcShowRebroadcastPeer::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); + CcShowRebroadcastPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcShowRebroadcast 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 CcShowRebroadcast $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcShowRebroadcastPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcShowRebroadcastPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcShowRebroadcastPeer::DATABASE_NAME, CcShowRebroadcastPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcShowRebroadcast + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcShowRebroadcastPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcShowRebroadcastPeer::DATABASE_NAME); + $criteria->add(CcShowRebroadcastPeer::ID, $pk); + + $v = CcShowRebroadcastPeer::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 + * @return CcShowRebroadcast[] + * @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(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcShowRebroadcastPeer::DATABASE_NAME); + $criteria->add(CcShowRebroadcastPeer::ID, $pks, Criteria::IN); + $objs = CcShowRebroadcastPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcShowRebroadcastPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowRebroadcastQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcShowRebroadcastQuery.php index d7fedf8e9..0d9991299 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowRebroadcastQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcShowRebroadcastQuery.php @@ -1,329 +1,500 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcShowRebroadcast|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcShowRebroadcastPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcShowRebroadcast|CcShowRebroadcast[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcShowRebroadcastPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcShowRebroadcastPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcShowRebroadcastQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcShowRebroadcastPeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcShowRebroadcast A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcShowRebroadcastQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcShowRebroadcastPeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcShowRebroadcast A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "day_offset", "start_time", "show_id" FROM "cc_show_rebroadcast" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcShowRebroadcast(); + $obj->hydrate($row); + CcShowRebroadcastPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcShowRebroadcastQuery 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(CcShowRebroadcastPeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * Filter the query on the day_offset column - * - * @param string $dbDayOffset 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 CcShowRebroadcastQuery The current query, for fluid interface - */ - public function filterByDbDayOffset($dbDayOffset = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbDayOffset)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbDayOffset)) { - $dbDayOffset = str_replace('*', '%', $dbDayOffset); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcShowRebroadcastPeer::DAY_OFFSET, $dbDayOffset, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcShowRebroadcast|CcShowRebroadcast[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * 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 CcShowRebroadcastQuery 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(CcShowRebroadcastPeer::START_TIME, $dbStartTime['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbStartTime['max'])) { - $this->addUsingAlias(CcShowRebroadcastPeer::START_TIME, $dbStartTime['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowRebroadcastPeer::START_TIME, $dbStartTime, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query on the show_id column - * - * @param int|array $dbShowId 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 CcShowRebroadcastQuery The current query, for fluid interface - */ - public function filterByDbShowId($dbShowId = null, $comparison = null) - { - if (is_array($dbShowId)) { - $useMinMax = false; - if (isset($dbShowId['min'])) { - $this->addUsingAlias(CcShowRebroadcastPeer::SHOW_ID, $dbShowId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbShowId['max'])) { - $this->addUsingAlias(CcShowRebroadcastPeer::SHOW_ID, $dbShowId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowRebroadcastPeer::SHOW_ID, $dbShowId, $comparison); - } + /** + * 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|CcShowRebroadcast[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query by a related CcShow object - * - * @param CcShow $ccShow the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowRebroadcastQuery The current query, for fluid interface - */ - public function filterByCcShow($ccShow, $comparison = null) - { - return $this - ->addUsingAlias(CcShowRebroadcastPeer::SHOW_ID, $ccShow->getDbId(), $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Adds a JOIN clause to the query using the CcShow relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcShowRebroadcastQuery The current query, for fluid interface - */ - public function joinCcShow($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcShow'); - - // 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, 'CcShow'); - } - - return $this; - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcShowRebroadcastQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { - /** - * Use the CcShow relation CcShow 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 CcShowQuery A secondary query class using the current class as primary query - */ - public function useCcShowQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcShow($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcShow', 'CcShowQuery'); - } + return $this->addUsingAlias(CcShowRebroadcastPeer::ID, $key, Criteria::EQUAL); + } - /** - * Exclude object from result - * - * @param CcShowRebroadcast $ccShowRebroadcast Object to remove from the list of results - * - * @return CcShowRebroadcastQuery The current query, for fluid interface - */ - public function prune($ccShowRebroadcast = null) - { - if ($ccShowRebroadcast) { - $this->addUsingAlias(CcShowRebroadcastPeer::ID, $ccShowRebroadcast->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return CcShowRebroadcastQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { -} // BaseCcShowRebroadcastQuery + return $this->addUsingAlias(CcShowRebroadcastPeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowRebroadcastQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcShowRebroadcastPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcShowRebroadcastPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcShowRebroadcastPeer::ID, $dbId, $comparison); + } + + /** + * Filter the query on the day_offset column + * + * Example usage: + * + * $query->filterByDbDayOffset('fooValue'); // WHERE day_offset = 'fooValue' + * $query->filterByDbDayOffset('%fooValue%'); // WHERE day_offset LIKE '%fooValue%' + * + * + * @param string $dbDayOffset 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 CcShowRebroadcastQuery The current query, for fluid interface + */ + public function filterByDbDayOffset($dbDayOffset = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbDayOffset)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbDayOffset)) { + $dbDayOffset = str_replace('*', '%', $dbDayOffset); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcShowRebroadcastPeer::DAY_OFFSET, $dbDayOffset, $comparison); + } + + /** + * Filter the query on the start_time column + * + * Example usage: + * + * $query->filterByDbStartTime('2011-03-14'); // WHERE start_time = '2011-03-14' + * $query->filterByDbStartTime('now'); // WHERE start_time = '2011-03-14' + * $query->filterByDbStartTime(array('max' => 'yesterday')); // WHERE start_time < '2011-03-13' + * + * + * @param mixed $dbStartTime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowRebroadcastQuery 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(CcShowRebroadcastPeer::START_TIME, $dbStartTime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbStartTime['max'])) { + $this->addUsingAlias(CcShowRebroadcastPeer::START_TIME, $dbStartTime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcShowRebroadcastPeer::START_TIME, $dbStartTime, $comparison); + } + + /** + * Filter the query on the show_id column + * + * Example usage: + * + * $query->filterByDbShowId(1234); // WHERE show_id = 1234 + * $query->filterByDbShowId(array(12, 34)); // WHERE show_id IN (12, 34) + * $query->filterByDbShowId(array('min' => 12)); // WHERE show_id >= 12 + * $query->filterByDbShowId(array('max' => 12)); // WHERE show_id <= 12 + * + * + * @see filterByCcShow() + * + * @param mixed $dbShowId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowRebroadcastQuery The current query, for fluid interface + */ + public function filterByDbShowId($dbShowId = null, $comparison = null) + { + if (is_array($dbShowId)) { + $useMinMax = false; + if (isset($dbShowId['min'])) { + $this->addUsingAlias(CcShowRebroadcastPeer::SHOW_ID, $dbShowId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbShowId['max'])) { + $this->addUsingAlias(CcShowRebroadcastPeer::SHOW_ID, $dbShowId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcShowRebroadcastPeer::SHOW_ID, $dbShowId, $comparison); + } + + /** + * Filter the query by a related CcShow object + * + * @param CcShow|PropelObjectCollection $ccShow The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcShowRebroadcastQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcShow($ccShow, $comparison = null) + { + if ($ccShow instanceof CcShow) { + return $this + ->addUsingAlias(CcShowRebroadcastPeer::SHOW_ID, $ccShow->getDbId(), $comparison); + } elseif ($ccShow instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcShowRebroadcastPeer::SHOW_ID, $ccShow->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcShow() only accepts arguments of type CcShow or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcShow relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcShowRebroadcastQuery The current query, for fluid interface + */ + public function joinCcShow($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShow'); + + // 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, 'CcShow'); + } + + return $this; + } + + /** + * Use the CcShow relation CcShow 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 \Airtime\CcShowQuery A secondary query class using the current class as primary query + */ + public function useCcShowQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcShow($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShow', '\Airtime\CcShowQuery'); + } + + /** + * Exclude object from result + * + * @param CcShowRebroadcast $ccShowRebroadcast Object to remove from the list of results + * + * @return CcShowRebroadcastQuery The current query, for fluid interface + */ + public function prune($ccShowRebroadcast = null) + { + if ($ccShowRebroadcast) { + $this->addUsingAlias(CcShowRebroadcastPeer::ID, $ccShowRebroadcast->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowSchedule.php b/airtime_mvc/application/models/airtime/om/BaseCcShowSchedule.php deleted file mode 100644 index bf8b384e6..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowSchedule.php +++ /dev/null @@ -1,905 +0,0 @@ -id; - } - - /** - * Get the [instance_id] column value. - * - * @return int - */ - public function getDbInstanceId() - { - return $this->instance_id; - } - - /** - * Get the [position] column value. - * - * @return int - */ - public function getDbPosition() - { - return $this->position; - } - - /** - * Get the [group_id] column value. - * - * @return int - */ - public function getDbGroupId() - { - return $this->group_id; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcShowSchedule 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[] = CcShowSchedulePeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [instance_id] column. - * - * @param int $v new value - * @return CcShowSchedule The current object (for fluent API support) - */ - public function setDbInstanceId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->instance_id !== $v) { - $this->instance_id = $v; - $this->modifiedColumns[] = CcShowSchedulePeer::INSTANCE_ID; - } - - if ($this->aCcShowInstances !== null && $this->aCcShowInstances->getDbId() !== $v) { - $this->aCcShowInstances = null; - } - - return $this; - } // setDbInstanceId() - - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return CcShowSchedule 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[] = CcShowSchedulePeer::POSITION; - } - - return $this; - } // setDbPosition() - - /** - * Set the value of [group_id] column. - * - * @param int $v new value - * @return CcShowSchedule The current object (for fluent API support) - */ - public function setDbGroupId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->group_id !== $v) { - $this->group_id = $v; - $this->modifiedColumns[] = CcShowSchedulePeer::GROUP_ID; - } - - return $this; - } // setDbGroupId() - - /** - * 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->instance_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->position = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->group_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 4; // 4 = CcShowSchedulePeer::NUM_COLUMNS - CcShowSchedulePeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcShowSchedule 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->aCcShowInstances !== null && $this->instance_id !== $this->aCcShowInstances->getDbId()) { - $this->aCcShowInstances = 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(CcShowSchedulePeer::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 = CcShowSchedulePeer::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->aCcShowInstances = 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(CcShowSchedulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcShowScheduleQuery::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(CcShowSchedulePeer::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); - CcShowSchedulePeer::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->aCcShowInstances !== null) { - if ($this->aCcShowInstances->isModified() || $this->aCcShowInstances->isNew()) { - $affectedRows += $this->aCcShowInstances->save($con); - } - $this->setCcShowInstances($this->aCcShowInstances); - } - - if ($this->isNew() ) { - $this->modifiedColumns[] = CcShowSchedulePeer::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(CcShowSchedulePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowSchedulePeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows += 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows += CcShowSchedulePeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcShowInstances !== null) { - if (!$this->aCcShowInstances->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcShowInstances->getValidationFailures()); - } - } - - - if (($retval = CcShowSchedulePeer::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 = CcShowSchedulePeer::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->getDbInstanceId(); - break; - case 2: - return $this->getDbPosition(); - break; - case 3: - return $this->getDbGroupId(); - 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 = CcShowSchedulePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbInstanceId(), - $keys[2] => $this->getDbPosition(), - $keys[3] => $this->getDbGroupId(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCcShowInstances) { - $result['CcShowInstances'] = $this->aCcShowInstances->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 = CcShowSchedulePeer::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->setDbInstanceId($value); - break; - case 2: - $this->setDbPosition($value); - break; - case 3: - $this->setDbGroupId($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 = CcShowSchedulePeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbInstanceId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbPosition($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbGroupId($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(CcShowSchedulePeer::DATABASE_NAME); - - if ($this->isColumnModified(CcShowSchedulePeer::ID)) $criteria->add(CcShowSchedulePeer::ID, $this->id); - if ($this->isColumnModified(CcShowSchedulePeer::INSTANCE_ID)) $criteria->add(CcShowSchedulePeer::INSTANCE_ID, $this->instance_id); - if ($this->isColumnModified(CcShowSchedulePeer::POSITION)) $criteria->add(CcShowSchedulePeer::POSITION, $this->position); - if ($this->isColumnModified(CcShowSchedulePeer::GROUP_ID)) $criteria->add(CcShowSchedulePeer::GROUP_ID, $this->group_id); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(CcShowSchedulePeer::DATABASE_NAME); - $criteria->add(CcShowSchedulePeer::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 CcShowSchedule (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->setDbInstanceId($this->instance_id); - $copyObj->setDbPosition($this->position); - $copyObj->setDbGroupId($this->group_id); - - $copyObj->setNew(true); - $copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return CcShowSchedule 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 CcShowSchedulePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcShowSchedulePeer(); - } - return self::$peer; - } - - /** - * Declares an association between this object and a CcShowInstances object. - * - * @param CcShowInstances $v - * @return CcShowSchedule The current object (for fluent API support) - * @throws PropelException - */ - public function setCcShowInstances(CcShowInstances $v = null) - { - if ($v === null) { - $this->setDbInstanceId(NULL); - } else { - $this->setDbInstanceId($v->getDbId()); - } - - $this->aCcShowInstances = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcShowInstances object, it will not be re-added. - if ($v !== null) { - $v->addCcShowSchedule($this); - } - - return $this; - } - - - /** - * Get the associated CcShowInstances object - * - * @param PropelPDO Optional Connection object. - * @return CcShowInstances The associated CcShowInstances object. - * @throws PropelException - */ - public function getCcShowInstances(PropelPDO $con = null) - { - if ($this->aCcShowInstances === null && ($this->instance_id !== null)) { - $this->aCcShowInstances = CcShowInstancesQuery::create()->findPk($this->instance_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->aCcShowInstances->addCcShowSchedules($this); - */ - } - return $this->aCcShowInstances; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->instance_id = null; - $this->position = null; - $this->group_id = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all collections of referencing foreign keys. - * - * This method is a user-space workaround for PHP's inability to garbage collect objects - * with circular references. This is currently necessary when using Propel in certain - * daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all associated objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep) { - } // if ($deep) - - $this->aCcShowInstances = 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); - } - -} // BaseCcShowSchedule diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowSchedulePeer.php b/airtime_mvc/application/models/airtime/om/BaseCcShowSchedulePeer.php deleted file mode 100644 index 677ff8447..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowSchedulePeer.php +++ /dev/null @@ -1,983 +0,0 @@ - array ('DbId', 'DbInstanceId', 'DbPosition', 'DbGroupId', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbInstanceId', 'dbPosition', 'dbGroupId', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::INSTANCE_ID, self::POSITION, self::GROUP_ID, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'INSTANCE_ID', 'POSITION', 'GROUP_ID', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'instance_id', 'position', 'group_id', ), - 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 ('DbId' => 0, 'DbInstanceId' => 1, 'DbPosition' => 2, 'DbGroupId' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbInstanceId' => 1, 'dbPosition' => 2, 'dbGroupId' => 3, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::INSTANCE_ID => 1, self::POSITION => 2, self::GROUP_ID => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'INSTANCE_ID' => 1, 'POSITION' => 2, 'GROUP_ID' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'instance_id' => 1, 'position' => 2, 'group_id' => 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. CcShowSchedulePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcShowSchedulePeer::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(CcShowSchedulePeer::ID); - $criteria->addSelectColumn(CcShowSchedulePeer::INSTANCE_ID); - $criteria->addSelectColumn(CcShowSchedulePeer::POSITION); - $criteria->addSelectColumn(CcShowSchedulePeer::GROUP_ID); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.INSTANCE_ID'); - $criteria->addSelectColumn($alias . '.POSITION'); - $criteria->addSelectColumn($alias . '.GROUP_ID'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CcShowSchedulePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowSchedulePeer::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(CcShowSchedulePeer::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 CcShowSchedule - * @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 = CcShowSchedulePeer::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 CcShowSchedulePeer::populateObjects(CcShowSchedulePeer::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(CcShowSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcShowSchedulePeer::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 CcShowSchedule $value A CcShowSchedule object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcShowSchedule $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 CcShowSchedule object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcShowSchedule) { - $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 CcShowSchedule 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 CcShowSchedule 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_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 (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 = CcShowSchedulePeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcShowSchedulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcShowSchedulePeer::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; - CcShowSchedulePeer::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 (CcShowSchedule object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcShowSchedulePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcShowSchedulePeer::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 + CcShowSchedulePeer::NUM_COLUMNS; - } else { - $cls = CcShowSchedulePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcShowSchedulePeer::addInstanceToPool($obj, $key); - } - return array($obj, $col); - } - - /** - * Returns the number of rows matching criteria, joining the related CcShowInstances 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 doCountJoinCcShowInstances(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(CcShowSchedulePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowSchedulePeer::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(CcShowSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcShowSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::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 CcShowSchedule objects pre-filled with their CcShowInstances 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 CcShowSchedule objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCcShowInstances(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); - } - - CcShowSchedulePeer::addSelectColumns($criteria); - $startcol = (CcShowSchedulePeer::NUM_COLUMNS - CcShowSchedulePeer::NUM_LAZY_LOAD_COLUMNS); - CcShowInstancesPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcShowSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcShowSchedulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcShowSchedulePeer::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 = CcShowSchedulePeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcShowSchedulePeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcShowInstancesPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowInstancesPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcShowInstancesPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcShowSchedule) to $obj2 (CcShowInstances) - $obj2->addCcShowSchedule($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(CcShowSchedulePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcShowSchedulePeer::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(CcShowSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcShowSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::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 CcShowSchedule 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 CcShowSchedule 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); - } - - CcShowSchedulePeer::addSelectColumns($criteria); - $startcol2 = (CcShowSchedulePeer::NUM_COLUMNS - CcShowSchedulePeer::NUM_LAZY_LOAD_COLUMNS); - - CcShowInstancesPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcShowInstancesPeer::NUM_COLUMNS - CcShowInstancesPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcShowSchedulePeer::INSTANCE_ID, CcShowInstancesPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcShowSchedulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcShowSchedulePeer::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 = CcShowSchedulePeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcShowSchedulePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcShowInstances rows - - $key2 = CcShowInstancesPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcShowInstancesPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcShowInstancesPeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcShowInstancesPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (CcShowSchedule) to the collection in $obj2 (CcShowInstances) - $obj2->addCcShowSchedule($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(BaseCcShowSchedulePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcShowSchedulePeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcShowScheduleTableMap()); - } - } - - /** - * 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 ? CcShowSchedulePeer::CLASS_DEFAULT : CcShowSchedulePeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcShowSchedule or Criteria object. - * - * @param mixed $values Criteria or CcShowSchedule 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(CcShowSchedulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcShowSchedule object - } - - if ($criteria->containsKey(CcShowSchedulePeer::ID) && $criteria->keyContainsValue(CcShowSchedulePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcShowSchedulePeer::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 CcShowSchedule or Criteria object. - * - * @param mixed $values Criteria or CcShowSchedule 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(CcShowSchedulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcShowSchedulePeer::ID); - $value = $criteria->remove(CcShowSchedulePeer::ID); - if ($value) { - $selectCriteria->add(CcShowSchedulePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcShowSchedulePeer::TABLE_NAME); - } - - } else { // $values is CcShowSchedule 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_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(CcShowSchedulePeer::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(CcShowSchedulePeer::TABLE_NAME, $con, CcShowSchedulePeer::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). - CcShowSchedulePeer::clearInstancePool(); - CcShowSchedulePeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcShowSchedule or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcShowSchedule 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(CcShowSchedulePeer::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. - CcShowSchedulePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcShowSchedule) { // it's a model object - // invalidate the cache for this single object - CcShowSchedulePeer::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(CcShowSchedulePeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcShowSchedulePeer::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); - CcShowSchedulePeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcShowSchedule 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 CcShowSchedule $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(CcShowSchedule $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcShowSchedulePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcShowSchedulePeer::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(CcShowSchedulePeer::DATABASE_NAME, CcShowSchedulePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcShowSchedule - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcShowSchedulePeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcShowSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcShowSchedulePeer::DATABASE_NAME); - $criteria->add(CcShowSchedulePeer::ID, $pk); - - $v = CcShowSchedulePeer::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(CcShowSchedulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcShowSchedulePeer::DATABASE_NAME); - $criteria->add(CcShowSchedulePeer::ID, $pks, Criteria::IN); - $objs = CcShowSchedulePeer::doSelect($criteria, $con); - } - return $objs; - } - -} // BaseCcShowSchedulePeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseCcShowSchedulePeer::buildTableMap(); - diff --git a/airtime_mvc/application/models/airtime/om/BaseCcShowScheduleQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcShowScheduleQuery.php deleted file mode 100644 index 2cb1b65c8..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcShowScheduleQuery.php +++ /dev/null @@ -1,338 +0,0 @@ -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 CcShowSchedule|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcShowSchedulePeer::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 CcShowScheduleQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcShowSchedulePeer::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 CcShowScheduleQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcShowSchedulePeer::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 CcShowScheduleQuery 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(CcShowSchedulePeer::ID, $dbId, $comparison); - } - - /** - * Filter the query on the instance_id column - * - * @param int|array $dbInstanceId 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 CcShowScheduleQuery The current query, for fluid interface - */ - public function filterByDbInstanceId($dbInstanceId = null, $comparison = null) - { - if (is_array($dbInstanceId)) { - $useMinMax = false; - if (isset($dbInstanceId['min'])) { - $this->addUsingAlias(CcShowSchedulePeer::INSTANCE_ID, $dbInstanceId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbInstanceId['max'])) { - $this->addUsingAlias(CcShowSchedulePeer::INSTANCE_ID, $dbInstanceId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowSchedulePeer::INSTANCE_ID, $dbInstanceId, $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 CcShowScheduleQuery 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(CcShowSchedulePeer::POSITION, $dbPosition['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbPosition['max'])) { - $this->addUsingAlias(CcShowSchedulePeer::POSITION, $dbPosition['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowSchedulePeer::POSITION, $dbPosition, $comparison); - } - - /** - * Filter the query on the group_id column - * - * @param int|array $dbGroupId 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 CcShowScheduleQuery The current query, for fluid interface - */ - public function filterByDbGroupId($dbGroupId = null, $comparison = null) - { - if (is_array($dbGroupId)) { - $useMinMax = false; - if (isset($dbGroupId['min'])) { - $this->addUsingAlias(CcShowSchedulePeer::GROUP_ID, $dbGroupId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbGroupId['max'])) { - $this->addUsingAlias(CcShowSchedulePeer::GROUP_ID, $dbGroupId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcShowSchedulePeer::GROUP_ID, $dbGroupId, $comparison); - } - - /** - * Filter the query by a related CcShowInstances object - * - * @param CcShowInstances $ccShowInstances the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcShowScheduleQuery The current query, for fluid interface - */ - public function filterByCcShowInstances($ccShowInstances, $comparison = null) - { - return $this - ->addUsingAlias(CcShowSchedulePeer::INSTANCE_ID, $ccShowInstances->getDbId(), $comparison); - } - - /** - * Adds a JOIN clause to the query using the CcShowInstances relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcShowScheduleQuery The current query, for fluid interface - */ - public function joinCcShowInstances($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcShowInstances'); - - // 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, 'CcShowInstances'); - } - - return $this; - } - - /** - * Use the CcShowInstances relation CcShowInstances 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 CcShowInstancesQuery A secondary query class using the current class as primary query - */ - public function useCcShowInstancesQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcShowInstances($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcShowInstances', 'CcShowInstancesQuery'); - } - - /** - * Exclude object from result - * - * @param CcShowSchedule $ccShowSchedule Object to remove from the list of results - * - * @return CcShowScheduleQuery The current query, for fluid interface - */ - public function prune($ccShowSchedule = null) - { - if ($ccShowSchedule) { - $this->addUsingAlias(CcShowSchedulePeer::ID, $ccShowSchedule->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } - -} // BaseCcShowScheduleQuery diff --git a/airtime_mvc/application/models/airtime/om/BaseCcSmemb.php b/airtime_mvc/application/models/airtime/om/BaseCcSmemb.php deleted file mode 100644 index 7fc4dbc9b..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcSmemb.php +++ /dev/null @@ -1,891 +0,0 @@ -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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - 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/airtime_mvc/application/models/airtime/om/BaseCcSmembPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcSmembPeer.php deleted file mode 100644 index 849c13423..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcSmembPeer.php +++ /dev/null @@ -1,750 +0,0 @@ - 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/airtime_mvc/application/models/airtime/om/BaseCcSmembQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcSmembQuery.php deleted file mode 100644 index 06b24502c..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcSmembQuery.php +++ /dev/null @@ -1,305 +0,0 @@ -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/airtime_mvc/application/models/airtime/om/BaseCcStreamSetting.php b/airtime_mvc/application/models/airtime/om/BaseCcStreamSetting.php index 6dadc9b67..ff1fe720c 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcStreamSetting.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcStreamSetting.php @@ -1,756 +1,884 @@ keyname; - } - - /** - * Get the [value] column value. - * - * @return string - */ - public function getDbValue() - { - return $this->value; - } - - /** - * Get the [type] column value. - * - * @return string - */ - public function getDbType() - { - return $this->type; - } - - /** - * Set the value of [keyname] column. - * - * @param string $v new value - * @return CcStreamSetting The current object (for fluent API support) - */ - public function setDbKeyName($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->keyname !== $v) { - $this->keyname = $v; - $this->modifiedColumns[] = CcStreamSettingPeer::KEYNAME; - } - - return $this; - } // setDbKeyName() - - /** - * Set the value of [value] column. - * - * @param string $v new value - * @return CcStreamSetting The current object (for fluent API support) - */ - public function setDbValue($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->value !== $v) { - $this->value = $v; - $this->modifiedColumns[] = CcStreamSettingPeer::VALUE; - } - - return $this; - } // setDbValue() - - /** - * Set the value of [type] column. - * - * @param string $v new value - * @return CcStreamSetting The current object (for fluent API support) - */ - public function setDbType($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->type !== $v) { - $this->type = $v; - $this->modifiedColumns[] = CcStreamSettingPeer::TYPE; - } - - return $this; - } // setDbType() - - /** - * 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->keyname = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null; - $this->value = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->type = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 3; // 3 = CcStreamSettingPeer::NUM_COLUMNS - CcStreamSettingPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcStreamSetting 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(CcStreamSettingPeer::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 = CcStreamSettingPeer::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(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcStreamSettingQuery::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(CcStreamSettingPeer::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); - CcStreamSettingPeer::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 = CcStreamSettingPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CcStreamSettingPeer::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 = CcStreamSettingPeer::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->getDbKeyName(); - break; - case 1: - return $this->getDbValue(); - break; - case 2: - return $this->getDbType(); - 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 = CcStreamSettingPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbKeyName(), - $keys[1] => $this->getDbValue(), - $keys[2] => $this->getDbType(), - ); - 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 = CcStreamSettingPeer::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->setDbKeyName($value); - break; - case 1: - $this->setDbValue($value); - break; - case 2: - $this->setDbType($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 = CcStreamSettingPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbKeyName($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbValue($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbType($arr[$keys[2]]); - } - - /** - * 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(CcStreamSettingPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcStreamSettingPeer::KEYNAME)) $criteria->add(CcStreamSettingPeer::KEYNAME, $this->keyname); - if ($this->isColumnModified(CcStreamSettingPeer::VALUE)) $criteria->add(CcStreamSettingPeer::VALUE, $this->value); - if ($this->isColumnModified(CcStreamSettingPeer::TYPE)) $criteria->add(CcStreamSettingPeer::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(CcStreamSettingPeer::DATABASE_NAME); - $criteria->add(CcStreamSettingPeer::KEYNAME, $this->keyname); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return string - */ - public function getPrimaryKey() - { - return $this->getDbKeyName(); - } - - /** - * Generic method to set the primary key (keyname column). - * - * @param string $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setDbKeyName($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - return null === $this->getDbKeyName(); - } - - /** - * 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 CcStreamSetting (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->setDbKeyName($this->keyname); - $copyObj->setDbValue($this->value); - $copyObj->setDbType($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 CcStreamSetting 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 CcStreamSettingPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcStreamSettingPeer(); - } - return self::$peer; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->keyname = null; - $this->value = 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) - - } - - /** - * 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); - } - -} // BaseCcStreamSetting + /** + * Peer class name + */ + const PEER = 'Airtime\\CcStreamSettingPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcStreamSettingPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the keyname field. + * @var string + */ + protected $keyname; + + /** + * The value for the value field. + * @var string + */ + protected $value; + + /** + * The value for the type field. + * @var string + */ + protected $type; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * Get the [keyname] column value. + * + * @return string + */ + public function getDbKeyName() + { + + return $this->keyname; + } + + /** + * Get the [value] column value. + * + * @return string + */ + public function getDbValue() + { + + return $this->value; + } + + /** + * Get the [type] column value. + * + * @return string + */ + public function getDbType() + { + + return $this->type; + } + + /** + * Set the value of [keyname] column. + * + * @param string $v new value + * @return CcStreamSetting The current object (for fluent API support) + */ + public function setDbKeyName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->keyname !== $v) { + $this->keyname = $v; + $this->modifiedColumns[] = CcStreamSettingPeer::KEYNAME; + } + + + return $this; + } // setDbKeyName() + + /** + * Set the value of [value] column. + * + * @param string $v new value + * @return CcStreamSetting The current object (for fluent API support) + */ + public function setDbValue($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->value !== $v) { + $this->value = $v; + $this->modifiedColumns[] = CcStreamSettingPeer::VALUE; + } + + + return $this; + } // setDbValue() + + /** + * Set the value of [type] column. + * + * @param string $v new value + * @return CcStreamSetting The current object (for fluent API support) + */ + public function setDbType($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->type !== $v) { + $this->type = $v; + $this->modifiedColumns[] = CcStreamSettingPeer::TYPE; + } + + + return $this; + } // setDbType() + + /** + * 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 resultset 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->keyname = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null; + $this->value = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->type = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 3; // 3 = CcStreamSettingPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcStreamSetting 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(CcStreamSettingPeer::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 = CcStreamSettingPeer::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 + * @throws Exception + * @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(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcStreamSettingQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcStreamSettingPeer::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); + CcStreamSettingPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcStreamSettingPeer::KEYNAME)) { + $modifiedColumns[':p' . $index++] = '"keyname"'; + } + if ($this->isColumnModified(CcStreamSettingPeer::VALUE)) { + $modifiedColumns[':p' . $index++] = '"value"'; + } + if ($this->isColumnModified(CcStreamSettingPeer::TYPE)) { + $modifiedColumns[':p' . $index++] = '"type"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_stream_setting" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"keyname"': + $stmt->bindValue($identifier, $this->keyname, PDO::PARAM_STR); + break; + case '"value"': + $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); + break; + case '"type"': + $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcStreamSettingPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcStreamSettingPeer::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->getDbKeyName(); + break; + case 1: + return $this->getDbValue(); + break; + case 2: + return $this->getDbType(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) + { + if (isset($alreadyDumpedObjects['CcStreamSetting'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcStreamSetting'][$this->getPrimaryKey()] = true; + $keys = CcStreamSettingPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbKeyName(), + $keys[1] => $this->getDbValue(), + $keys[2] => $this->getDbType(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcStreamSettingPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbKeyName($value); + break; + case 1: + $this->setDbValue($value); + break; + case 2: + $this->setDbType($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcStreamSettingPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbKeyName($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbValue($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbType($arr[$keys[2]]); + } + + /** + * 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(CcStreamSettingPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcStreamSettingPeer::KEYNAME)) $criteria->add(CcStreamSettingPeer::KEYNAME, $this->keyname); + if ($this->isColumnModified(CcStreamSettingPeer::VALUE)) $criteria->add(CcStreamSettingPeer::VALUE, $this->value); + if ($this->isColumnModified(CcStreamSettingPeer::TYPE)) $criteria->add(CcStreamSettingPeer::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(CcStreamSettingPeer::DATABASE_NAME); + $criteria->add(CcStreamSettingPeer::KEYNAME, $this->keyname); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getDbKeyName(); + } + + /** + * Generic method to set the primary key (keyname column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setDbKeyName($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getDbKeyName(); + } + + /** + * 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 CcStreamSetting (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbValue($this->getDbValue()); + $copyObj->setDbType($this->getDbType()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setDbKeyName(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 CcStreamSetting 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 CcStreamSettingPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcStreamSettingPeer(); + } + + return self::$peer; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->keyname = null; + $this->value = null; + $this->type = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcStreamSettingPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcStreamSettingPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcStreamSettingPeer.php index f5e680b20..75609e6b9 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcStreamSettingPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcStreamSettingPeer.php @@ -1,736 +1,770 @@ array ('DbKeyName', 'DbValue', 'DbType', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbKeyName', 'dbValue', 'dbType', ), - BasePeer::TYPE_COLNAME => array (self::KEYNAME, self::VALUE, self::TYPE, ), - BasePeer::TYPE_RAW_COLNAME => array ('KEYNAME', 'VALUE', 'TYPE', ), - BasePeer::TYPE_FIELDNAME => array ('keyname', 'value', 'type', ), - BasePeer::TYPE_NUM => array (0, 1, 2, ) - ); - - /** - * 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 ('DbKeyName' => 0, 'DbValue' => 1, 'DbType' => 2, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbKeyName' => 0, 'dbValue' => 1, 'dbType' => 2, ), - BasePeer::TYPE_COLNAME => array (self::KEYNAME => 0, self::VALUE => 1, self::TYPE => 2, ), - BasePeer::TYPE_RAW_COLNAME => array ('KEYNAME' => 0, 'VALUE' => 1, 'TYPE' => 2, ), - BasePeer::TYPE_FIELDNAME => array ('keyname' => 0, 'value' => 1, 'type' => 2, ), - BasePeer::TYPE_NUM => array (0, 1, 2, ) - ); - - /** - * 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. CcStreamSettingPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcStreamSettingPeer::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(CcStreamSettingPeer::KEYNAME); - $criteria->addSelectColumn(CcStreamSettingPeer::VALUE); - $criteria->addSelectColumn(CcStreamSettingPeer::TYPE); - } else { - $criteria->addSelectColumn($alias . '.KEYNAME'); - $criteria->addSelectColumn($alias . '.VALUE'); - $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(CcStreamSettingPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcStreamSettingPeer::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(CcStreamSettingPeer::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 CcStreamSetting - * @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 = CcStreamSettingPeer::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 CcStreamSettingPeer::populateObjects(CcStreamSettingPeer::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(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcStreamSettingPeer::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 CcStreamSetting $value A CcStreamSetting object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcStreamSetting $obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getDbKeyName(); - } // 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 CcStreamSetting object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcStreamSetting) { - $key = (string) $value->getDbKeyName(); - } 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 CcStreamSetting 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 CcStreamSetting 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_stream_setting - * 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 = CcStreamSettingPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcStreamSettingPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcStreamSettingPeer::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; - CcStreamSettingPeer::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 (CcStreamSetting object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcStreamSettingPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcStreamSettingPeer::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 + CcStreamSettingPeer::NUM_COLUMNS; - } else { - $cls = CcStreamSettingPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcStreamSettingPeer::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(BaseCcStreamSettingPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcStreamSettingPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcStreamSettingTableMap()); - } - } - - /** - * 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 ? CcStreamSettingPeer::CLASS_DEFAULT : CcStreamSettingPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcStreamSetting or Criteria object. - * - * @param mixed $values Criteria or CcStreamSetting 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(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcStreamSetting 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 CcStreamSetting or Criteria object. - * - * @param mixed $values Criteria or CcStreamSetting 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(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcStreamSettingPeer::KEYNAME); - $value = $criteria->remove(CcStreamSettingPeer::KEYNAME); - if ($value) { - $selectCriteria->add(CcStreamSettingPeer::KEYNAME, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcStreamSettingPeer::TABLE_NAME); - } - - } else { // $values is CcStreamSetting 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_stream_setting 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(CcStreamSettingPeer::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(CcStreamSettingPeer::TABLE_NAME, $con, CcStreamSettingPeer::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). - CcStreamSettingPeer::clearInstancePool(); - CcStreamSettingPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcStreamSetting or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcStreamSetting 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(CcStreamSettingPeer::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. - CcStreamSettingPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcStreamSetting) { // it's a model object - // invalidate the cache for this single object - CcStreamSettingPeer::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(CcStreamSettingPeer::KEYNAME, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcStreamSettingPeer::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); - CcStreamSettingPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcStreamSetting 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 CcStreamSetting $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(CcStreamSetting $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcStreamSettingPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcStreamSettingPeer::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(CcStreamSettingPeer::DATABASE_NAME, CcStreamSettingPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param string $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcStreamSetting - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcStreamSettingPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcStreamSettingPeer::DATABASE_NAME); - $criteria->add(CcStreamSettingPeer::KEYNAME, $pk); - - $v = CcStreamSettingPeer::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(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcStreamSettingPeer::DATABASE_NAME); - $criteria->add(CcStreamSettingPeer::KEYNAME, $pks, Criteria::IN); - $objs = CcStreamSettingPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcStreamSettingPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_stream_setting'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcStreamSetting'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcStreamSettingTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 3; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 3; + + /** the column name for the keyname field */ + const KEYNAME = 'cc_stream_setting.keyname'; + + /** the column name for the value field */ + const VALUE = 'cc_stream_setting.value'; + + /** the column name for the type field */ + const TYPE = 'cc_stream_setting.type'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcStreamSetting objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcStreamSetting[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcStreamSettingPeer::$fieldNames[CcStreamSettingPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbKeyName', 'DbValue', 'DbType', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbKeyName', 'dbValue', 'dbType', ), + BasePeer::TYPE_COLNAME => array (CcStreamSettingPeer::KEYNAME, CcStreamSettingPeer::VALUE, CcStreamSettingPeer::TYPE, ), + BasePeer::TYPE_RAW_COLNAME => array ('KEYNAME', 'VALUE', 'TYPE', ), + BasePeer::TYPE_FIELDNAME => array ('keyname', 'value', 'type', ), + BasePeer::TYPE_NUM => array (0, 1, 2, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcStreamSettingPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbKeyName' => 0, 'DbValue' => 1, 'DbType' => 2, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbKeyName' => 0, 'dbValue' => 1, 'dbType' => 2, ), + BasePeer::TYPE_COLNAME => array (CcStreamSettingPeer::KEYNAME => 0, CcStreamSettingPeer::VALUE => 1, CcStreamSettingPeer::TYPE => 2, ), + BasePeer::TYPE_RAW_COLNAME => array ('KEYNAME' => 0, 'VALUE' => 1, 'TYPE' => 2, ), + BasePeer::TYPE_FIELDNAME => array ('keyname' => 0, 'value' => 1, 'type' => 2, ), + BasePeer::TYPE_NUM => array (0, 1, 2, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcStreamSettingPeer::getFieldNames($toType); + $key = isset(CcStreamSettingPeer::$fieldKeys[$fromType][$name]) ? CcStreamSettingPeer::$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(CcStreamSettingPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcStreamSettingPeer::$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 CcStreamSettingPeer::$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. CcStreamSettingPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcStreamSettingPeer::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(CcStreamSettingPeer::KEYNAME); + $criteria->addSelectColumn(CcStreamSettingPeer::VALUE); + $criteria->addSelectColumn(CcStreamSettingPeer::TYPE); + } else { + $criteria->addSelectColumn($alias . '.keyname'); + $criteria->addSelectColumn($alias . '.value'); + $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(CcStreamSettingPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcStreamSettingPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcStreamSettingPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcStreamSettingPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcStreamSetting + * @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 = CcStreamSettingPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcStreamSettingPeer::populateObjects(CcStreamSettingPeer::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 directly (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(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcStreamSettingPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcStreamSettingPeer::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 CcStreamSetting $obj A CcStreamSetting object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbKeyName(); + } // if key === null + CcStreamSettingPeer::$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 CcStreamSetting object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcStreamSetting) { + $key = (string) $value->getDbKeyName(); + } 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 CcStreamSetting object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcStreamSettingPeer::$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 CcStreamSetting 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(CcStreamSettingPeer::$instances[$key])) { + return CcStreamSettingPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcStreamSettingPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcStreamSettingPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_stream_setting + * 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 = CcStreamSettingPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcStreamSettingPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcStreamSettingPeer::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; + CcStreamSettingPeer::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 (CcStreamSetting object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcStreamSettingPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcStreamSettingPeer::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 + CcStreamSettingPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcStreamSettingPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcStreamSettingPeer::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(CcStreamSettingPeer::DATABASE_NAME)->getTable(CcStreamSettingPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcStreamSettingPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcStreamSettingPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcStreamSettingTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcStreamSettingPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcStreamSetting or Criteria object. + * + * @param mixed $values Criteria or CcStreamSetting 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(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcStreamSetting object + } + + + // Set the correct dbName + $criteria->setDbName(CcStreamSettingPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcStreamSetting or Criteria object. + * + * @param mixed $values Criteria or CcStreamSetting 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(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcStreamSettingPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcStreamSettingPeer::KEYNAME); + $value = $criteria->remove(CcStreamSettingPeer::KEYNAME); + if ($value) { + $selectCriteria->add(CcStreamSettingPeer::KEYNAME, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcStreamSettingPeer::TABLE_NAME); + } + + } else { // $values is CcStreamSetting object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcStreamSettingPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_stream_setting table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcStreamSettingPeer::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(CcStreamSettingPeer::TABLE_NAME, $con, CcStreamSettingPeer::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). + CcStreamSettingPeer::clearInstancePool(); + CcStreamSettingPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcStreamSetting or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcStreamSetting 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(CcStreamSettingPeer::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. + CcStreamSettingPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcStreamSetting) { // it's a model object + // invalidate the cache for this single object + CcStreamSettingPeer::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(CcStreamSettingPeer::DATABASE_NAME); + $criteria->add(CcStreamSettingPeer::KEYNAME, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcStreamSettingPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcStreamSettingPeer::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); + CcStreamSettingPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcStreamSetting 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 CcStreamSetting $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcStreamSettingPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcStreamSettingPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcStreamSettingPeer::DATABASE_NAME, CcStreamSettingPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param string $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcStreamSetting + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcStreamSettingPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcStreamSettingPeer::DATABASE_NAME); + $criteria->add(CcStreamSettingPeer::KEYNAME, $pk); + + $v = CcStreamSettingPeer::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 + * @return CcStreamSetting[] + * @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(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcStreamSettingPeer::DATABASE_NAME); + $criteria->add(CcStreamSettingPeer::KEYNAME, $pks, Criteria::IN); + $objs = CcStreamSettingPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcStreamSettingPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcStreamSettingQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcStreamSettingQuery.php index 666106d6f..1266cd16d 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcStreamSettingQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcStreamSettingQuery.php @@ -1,222 +1,342 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcStreamSetting|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcStreamSettingPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcStreamSetting|CcStreamSetting[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcStreamSettingPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcStreamSettingPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcStreamSettingQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcStreamSettingPeer::KEYNAME, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcStreamSetting A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbKeyName($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcStreamSettingQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcStreamSettingPeer::KEYNAME, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcStreamSetting A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "keyname", "value", "type" FROM "cc_stream_setting" WHERE "keyname" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcStreamSetting(); + $obj->hydrate($row); + CcStreamSettingPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * Filter the query on the keyname column - * - * @param string $dbKeyName 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 CcStreamSettingQuery The current query, for fluid interface - */ - public function filterByDbKeyName($dbKeyName = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbKeyName)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbKeyName)) { - $dbKeyName = str_replace('*', '%', $dbKeyName); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcStreamSettingPeer::KEYNAME, $dbKeyName, $comparison); - } + return $obj; + } - /** - * Filter the query on the value column - * - * @param string $dbValue The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcStreamSettingQuery The current query, for fluid interface - */ - public function filterByDbValue($dbValue = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbValue)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbValue)) { - $dbValue = str_replace('*', '%', $dbValue); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcStreamSettingPeer::VALUE, $dbValue, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcStreamSetting|CcStreamSetting[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Filter the query on the type column - * - * @param string $dbType The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcStreamSettingQuery The current query, for fluid interface - */ - public function filterByDbType($dbType = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbType)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbType)) { - $dbType = str_replace('*', '%', $dbType); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcStreamSettingPeer::TYPE, $dbType, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Exclude object from result - * - * @param CcStreamSetting $ccStreamSetting Object to remove from the list of results - * - * @return CcStreamSettingQuery The current query, for fluid interface - */ - public function prune($ccStreamSetting = null) - { - if ($ccStreamSetting) { - $this->addUsingAlias(CcStreamSettingPeer::KEYNAME, $ccStreamSetting->getDbKeyName(), Criteria::NOT_EQUAL); - } - - return $this; - } + /** + * 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|CcStreamSetting[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); -} // BaseCcStreamSettingQuery + return $criteria->getFormatter()->init($criteria)->format($stmt); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcStreamSettingQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(CcStreamSettingPeer::KEYNAME, $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 CcStreamSettingQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(CcStreamSettingPeer::KEYNAME, $keys, Criteria::IN); + } + + /** + * Filter the query on the keyname column + * + * Example usage: + * + * $query->filterByDbKeyName('fooValue'); // WHERE keyname = 'fooValue' + * $query->filterByDbKeyName('%fooValue%'); // WHERE keyname LIKE '%fooValue%' + * + * + * @param string $dbKeyName 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 CcStreamSettingQuery The current query, for fluid interface + */ + public function filterByDbKeyName($dbKeyName = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbKeyName)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbKeyName)) { + $dbKeyName = str_replace('*', '%', $dbKeyName); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcStreamSettingPeer::KEYNAME, $dbKeyName, $comparison); + } + + /** + * Filter the query on the value column + * + * Example usage: + * + * $query->filterByDbValue('fooValue'); // WHERE value = 'fooValue' + * $query->filterByDbValue('%fooValue%'); // WHERE value LIKE '%fooValue%' + * + * + * @param string $dbValue The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcStreamSettingQuery The current query, for fluid interface + */ + public function filterByDbValue($dbValue = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbValue)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbValue)) { + $dbValue = str_replace('*', '%', $dbValue); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcStreamSettingPeer::VALUE, $dbValue, $comparison); + } + + /** + * Filter the query on the type column + * + * Example usage: + * + * $query->filterByDbType('fooValue'); // WHERE type = 'fooValue' + * $query->filterByDbType('%fooValue%'); // WHERE type LIKE '%fooValue%' + * + * + * @param string $dbType The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcStreamSettingQuery The current query, for fluid interface + */ + public function filterByDbType($dbType = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbType)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbType)) { + $dbType = str_replace('*', '%', $dbType); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcStreamSettingPeer::TYPE, $dbType, $comparison); + } + + /** + * Exclude object from result + * + * @param CcStreamSetting $ccStreamSetting Object to remove from the list of results + * + * @return CcStreamSettingQuery The current query, for fluid interface + */ + public function prune($ccStreamSetting = null) + { + if ($ccStreamSetting) { + $this->addUsingAlias(CcStreamSettingPeer::KEYNAME, $ccStreamSetting->getDbKeyName(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcSubjs.php b/airtime_mvc/application/models/airtime/om/BaseCcSubjs.php index c335d7158..2a58692db 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcSubjs.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcSubjs.php @@ -1,2784 +1,5273 @@ login = ''; - $this->pass = ''; - $this->type = 'U'; - $this->first_name = ''; - $this->last_name = ''; - $this->login_attempts = 0; - } - - /** - * Initializes internal state of BaseCcSubjs 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 [login] column value. - * - * @return string - */ - public function getDbLogin() - { - return $this->login; - } - - /** - * Get the [pass] column value. - * - * @return string - */ - public function getDbPass() - { - return $this->pass; - } - - /** - * Get the [type] column value. - * - * @return string - */ - public function getDbType() - { - return $this->type; - } - - /** - * Get the [first_name] column value. - * - * @return string - */ - public function getDbFirstName() - { - return $this->first_name; - } - - /** - * Get the [last_name] column value. - * - * @return string - */ - public function getDbLastName() - { - return $this->last_name; - } - - /** - * 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 getDbLastlogin($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 getDbLastfail($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); - } - } - - /** - * Get the [skype_contact] column value. - * - * @return string - */ - public function getDbSkypeContact() - { - return $this->skype_contact; - } - - /** - * Get the [jabber_contact] column value. - * - * @return string - */ - public function getDbJabberContact() - { - return $this->jabber_contact; - } - - /** - * Get the [email] column value. - * - * @return string - */ - public function getDbEmail() - { - return $this->email; - } - - /** - * Get the [cell_phone] column value. - * - * @return string - */ - public function getDbCellPhone() - { - return $this->cell_phone; - } - - /** - * Get the [login_attempts] column value. - * - * @return int - */ - public function getDbLoginAttempts() - { - return $this->login_attempts; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcSubjs 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[] = CcSubjsPeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [login] column. - * - * @param string $v new value - * @return CcSubjs The current object (for fluent API support) - */ - public function setDbLogin($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->login !== $v || $this->isNew()) { - $this->login = $v; - $this->modifiedColumns[] = CcSubjsPeer::LOGIN; - } - - return $this; - } // setDbLogin() - - /** - * Set the value of [pass] column. - * - * @param string $v new value - * @return CcSubjs The current object (for fluent API support) - */ - public function setDbPass($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->pass !== $v || $this->isNew()) { - $this->pass = $v; - $this->modifiedColumns[] = CcSubjsPeer::PASS; - } - - return $this; - } // setDbPass() - - /** - * Set the value of [type] column. - * - * @param string $v new value - * @return CcSubjs The current object (for fluent API support) - */ - public function setDbType($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->type !== $v || $this->isNew()) { - $this->type = $v; - $this->modifiedColumns[] = CcSubjsPeer::TYPE; - } - - return $this; - } // setDbType() - - /** - * Set the value of [first_name] column. - * - * @param string $v new value - * @return CcSubjs The current object (for fluent API support) - */ - public function setDbFirstName($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->first_name !== $v || $this->isNew()) { - $this->first_name = $v; - $this->modifiedColumns[] = CcSubjsPeer::FIRST_NAME; - } - - return $this; - } // setDbFirstName() - - /** - * Set the value of [last_name] column. - * - * @param string $v new value - * @return CcSubjs The current object (for fluent API support) - */ - public function setDbLastName($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->last_name !== $v || $this->isNew()) { - $this->last_name = $v; - $this->modifiedColumns[] = CcSubjsPeer::LAST_NAME; - } - - return $this; - } // setDbLastName() - - /** - * 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 setDbLastlogin($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; - } // setDbLastlogin() - - /** - * 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 setDbLastfail($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; - } // setDbLastfail() - - /** - * Set the value of [skype_contact] column. - * - * @param string $v new value - * @return CcSubjs The current object (for fluent API support) - */ - public function setDbSkypeContact($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->skype_contact !== $v) { - $this->skype_contact = $v; - $this->modifiedColumns[] = CcSubjsPeer::SKYPE_CONTACT; - } - - return $this; - } // setDbSkypeContact() - - /** - * Set the value of [jabber_contact] column. - * - * @param string $v new value - * @return CcSubjs The current object (for fluent API support) - */ - public function setDbJabberContact($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->jabber_contact !== $v) { - $this->jabber_contact = $v; - $this->modifiedColumns[] = CcSubjsPeer::JABBER_CONTACT; - } - - return $this; - } // setDbJabberContact() - - /** - * Set the value of [email] column. - * - * @param string $v new value - * @return CcSubjs The current object (for fluent API support) - */ - public function setDbEmail($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->email !== $v) { - $this->email = $v; - $this->modifiedColumns[] = CcSubjsPeer::EMAIL; - } - - return $this; - } // setDbEmail() - - /** - * Set the value of [cell_phone] column. - * - * @param string $v new value - * @return CcSubjs The current object (for fluent API support) - */ - public function setDbCellPhone($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->cell_phone !== $v) { - $this->cell_phone = $v; - $this->modifiedColumns[] = CcSubjsPeer::CELL_PHONE; - } - - return $this; - } // setDbCellPhone() - - /** - * Set the value of [login_attempts] column. - * - * @param int $v new value - * @return CcSubjs The current object (for fluent API support) - */ - public function setDbLoginAttempts($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->login_attempts !== $v || $this->isNew()) { - $this->login_attempts = $v; - $this->modifiedColumns[] = CcSubjsPeer::LOGIN_ATTEMPTS; - } - - return $this; - } // setDbLoginAttempts() - - /** - * 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->first_name !== '') { - return false; - } - - if ($this->last_name !== '') { - return false; - } - - if ($this->login_attempts !== 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->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->first_name = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->last_name = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->lastlogin = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->lastfail = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->skype_contact = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; - $this->jabber_contact = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; - $this->email = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; - $this->cell_phone = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null; - $this->login_attempts = ($row[$startcol + 12] !== null) ? (int) $row[$startcol + 12] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 13; // 13 = 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->collCcFilessRelatedByDbOwnerId = null; - - $this->collCcFilessRelatedByDbEditedby = null; - - $this->collCcPermss = null; - - $this->collCcShowHostss = null; - - $this->collCcPlaylists = null; - - $this->collCcBlocks = null; - - $this->collCcPrefs = null; - - $this->collCcSesss = null; - - $this->collCcSubjsTokens = 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->isNew() ) { - $this->modifiedColumns[] = CcSubjsPeer::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(CcSubjsPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSubjsPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows = 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows = CcSubjsPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - if ($this->collCcFilessRelatedByDbOwnerId !== null) { - foreach ($this->collCcFilessRelatedByDbOwnerId as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->collCcFilessRelatedByDbEditedby !== null) { - foreach ($this->collCcFilessRelatedByDbEditedby 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->collCcShowHostss !== null) { - foreach ($this->collCcShowHostss 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->collCcBlocks !== null) { - foreach ($this->collCcBlocks 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); - } - } - } - - if ($this->collCcSubjsTokens !== null) { - foreach ($this->collCcSubjsTokens 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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CcSubjsPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collCcFilessRelatedByDbOwnerId !== null) { - foreach ($this->collCcFilessRelatedByDbOwnerId as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCcFilessRelatedByDbEditedby !== null) { - foreach ($this->collCcFilessRelatedByDbEditedby 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->collCcShowHostss !== null) { - foreach ($this->collCcShowHostss 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->collCcBlocks !== null) { - foreach ($this->collCcBlocks 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()); - } - } - } - - if ($this->collCcSubjsTokens !== null) { - foreach ($this->collCcSubjsTokens 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->getDbId(); - break; - case 1: - return $this->getDbLogin(); - break; - case 2: - return $this->getDbPass(); - break; - case 3: - return $this->getDbType(); - break; - case 4: - return $this->getDbFirstName(); - break; - case 5: - return $this->getDbLastName(); - break; - case 6: - return $this->getDbLastlogin(); - break; - case 7: - return $this->getDbLastfail(); - break; - case 8: - return $this->getDbSkypeContact(); - break; - case 9: - return $this->getDbJabberContact(); - break; - case 10: - return $this->getDbEmail(); - break; - case 11: - return $this->getDbCellPhone(); - break; - case 12: - return $this->getDbLoginAttempts(); - 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->getDbId(), - $keys[1] => $this->getDbLogin(), - $keys[2] => $this->getDbPass(), - $keys[3] => $this->getDbType(), - $keys[4] => $this->getDbFirstName(), - $keys[5] => $this->getDbLastName(), - $keys[6] => $this->getDbLastlogin(), - $keys[7] => $this->getDbLastfail(), - $keys[8] => $this->getDbSkypeContact(), - $keys[9] => $this->getDbJabberContact(), - $keys[10] => $this->getDbEmail(), - $keys[11] => $this->getDbCellPhone(), - $keys[12] => $this->getDbLoginAttempts(), - ); - 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->setDbId($value); - break; - case 1: - $this->setDbLogin($value); - break; - case 2: - $this->setDbPass($value); - break; - case 3: - $this->setDbType($value); - break; - case 4: - $this->setDbFirstName($value); - break; - case 5: - $this->setDbLastName($value); - break; - case 6: - $this->setDbLastlogin($value); - break; - case 7: - $this->setDbLastfail($value); - break; - case 8: - $this->setDbSkypeContact($value); - break; - case 9: - $this->setDbJabberContact($value); - break; - case 10: - $this->setDbEmail($value); - break; - case 11: - $this->setDbCellPhone($value); - break; - case 12: - $this->setDbLoginAttempts($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->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbLogin($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbPass($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbType($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbFirstName($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbLastName($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDbLastlogin($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setDbLastfail($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setDbSkypeContact($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setDbJabberContact($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setDbEmail($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setDbCellPhone($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setDbLoginAttempts($arr[$keys[12]]); - } - - /** - * 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::FIRST_NAME)) $criteria->add(CcSubjsPeer::FIRST_NAME, $this->first_name); - if ($this->isColumnModified(CcSubjsPeer::LAST_NAME)) $criteria->add(CcSubjsPeer::LAST_NAME, $this->last_name); - if ($this->isColumnModified(CcSubjsPeer::LASTLOGIN)) $criteria->add(CcSubjsPeer::LASTLOGIN, $this->lastlogin); - if ($this->isColumnModified(CcSubjsPeer::LASTFAIL)) $criteria->add(CcSubjsPeer::LASTFAIL, $this->lastfail); - if ($this->isColumnModified(CcSubjsPeer::SKYPE_CONTACT)) $criteria->add(CcSubjsPeer::SKYPE_CONTACT, $this->skype_contact); - if ($this->isColumnModified(CcSubjsPeer::JABBER_CONTACT)) $criteria->add(CcSubjsPeer::JABBER_CONTACT, $this->jabber_contact); - if ($this->isColumnModified(CcSubjsPeer::EMAIL)) $criteria->add(CcSubjsPeer::EMAIL, $this->email); - if ($this->isColumnModified(CcSubjsPeer::CELL_PHONE)) $criteria->add(CcSubjsPeer::CELL_PHONE, $this->cell_phone); - if ($this->isColumnModified(CcSubjsPeer::LOGIN_ATTEMPTS)) $criteria->add(CcSubjsPeer::LOGIN_ATTEMPTS, $this->login_attempts); - - 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->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 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->setDbLogin($this->login); - $copyObj->setDbPass($this->pass); - $copyObj->setDbType($this->type); - $copyObj->setDbFirstName($this->first_name); - $copyObj->setDbLastName($this->last_name); - $copyObj->setDbLastlogin($this->lastlogin); - $copyObj->setDbLastfail($this->lastfail); - $copyObj->setDbSkypeContact($this->skype_contact); - $copyObj->setDbJabberContact($this->jabber_contact); - $copyObj->setDbEmail($this->email); - $copyObj->setDbCellPhone($this->cell_phone); - $copyObj->setDbLoginAttempts($this->login_attempts); - - 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->getCcFilessRelatedByDbOwnerId() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcFilesRelatedByDbOwnerId($relObj->copy($deepCopy)); - } - } - - foreach ($this->getCcFilessRelatedByDbEditedby() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcFilesRelatedByDbEditedby($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->getCcShowHostss() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcShowHosts($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->getCcBlocks() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcBlock($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)); - } - } - - foreach ($this->getCcSubjsTokens() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcSubjsToken($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 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 collCcFilessRelatedByDbOwnerId 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 addCcFilessRelatedByDbOwnerId() - */ - public function clearCcFilessRelatedByDbOwnerId() - { - $this->collCcFilessRelatedByDbOwnerId = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcFilessRelatedByDbOwnerId collection. - * - * By default this just sets the collCcFilessRelatedByDbOwnerId collection to an empty array (like clearcollCcFilessRelatedByDbOwnerId()); - * 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 initCcFilessRelatedByDbOwnerId() - { - $this->collCcFilessRelatedByDbOwnerId = new PropelObjectCollection(); - $this->collCcFilessRelatedByDbOwnerId->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 getCcFilessRelatedByDbOwnerId($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcFilessRelatedByDbOwnerId || null !== $criteria) { - if ($this->isNew() && null === $this->collCcFilessRelatedByDbOwnerId) { - // return empty collection - $this->initCcFilessRelatedByDbOwnerId(); - } else { - $collCcFilessRelatedByDbOwnerId = CcFilesQuery::create(null, $criteria) - ->filterByFkOwner($this) - ->find($con); - if (null !== $criteria) { - return $collCcFilessRelatedByDbOwnerId; - } - $this->collCcFilessRelatedByDbOwnerId = $collCcFilessRelatedByDbOwnerId; - } - } - return $this->collCcFilessRelatedByDbOwnerId; - } - - /** - * 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 countCcFilessRelatedByDbOwnerId(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcFilessRelatedByDbOwnerId || null !== $criteria) { - if ($this->isNew() && null === $this->collCcFilessRelatedByDbOwnerId) { - return 0; - } else { - $query = CcFilesQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByFkOwner($this) - ->count($con); - } - } else { - return count($this->collCcFilessRelatedByDbOwnerId); - } - } - - /** - * 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 addCcFilesRelatedByDbOwnerId(CcFiles $l) - { - if ($this->collCcFilessRelatedByDbOwnerId === null) { - $this->initCcFilessRelatedByDbOwnerId(); - } - if (!$this->collCcFilessRelatedByDbOwnerId->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcFilessRelatedByDbOwnerId[]= $l; - $l->setFkOwner($this); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcSubjs is new, it will return - * an empty collection; or if this CcSubjs has previously - * been saved, it will retrieve related CcFilessRelatedByDbOwnerId 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 CcSubjs. - * - * @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 CcFiles[] List of CcFiles objects - */ - public function getCcFilessRelatedByDbOwnerIdJoinCcMusicDirs($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcFilesQuery::create(null, $criteria); - $query->joinWith('CcMusicDirs', $join_behavior); - - return $this->getCcFilessRelatedByDbOwnerId($query, $con); - } - - /** - * Clears out the collCcFilessRelatedByDbEditedby 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 addCcFilessRelatedByDbEditedby() - */ - public function clearCcFilessRelatedByDbEditedby() - { - $this->collCcFilessRelatedByDbEditedby = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcFilessRelatedByDbEditedby collection. - * - * By default this just sets the collCcFilessRelatedByDbEditedby collection to an empty array (like clearcollCcFilessRelatedByDbEditedby()); - * 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 initCcFilessRelatedByDbEditedby() - { - $this->collCcFilessRelatedByDbEditedby = new PropelObjectCollection(); - $this->collCcFilessRelatedByDbEditedby->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 getCcFilessRelatedByDbEditedby($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcFilessRelatedByDbEditedby || null !== $criteria) { - if ($this->isNew() && null === $this->collCcFilessRelatedByDbEditedby) { - // return empty collection - $this->initCcFilessRelatedByDbEditedby(); - } else { - $collCcFilessRelatedByDbEditedby = CcFilesQuery::create(null, $criteria) - ->filterByCcSubjsRelatedByDbEditedby($this) - ->find($con); - if (null !== $criteria) { - return $collCcFilessRelatedByDbEditedby; - } - $this->collCcFilessRelatedByDbEditedby = $collCcFilessRelatedByDbEditedby; - } - } - return $this->collCcFilessRelatedByDbEditedby; - } - - /** - * 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 countCcFilessRelatedByDbEditedby(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcFilessRelatedByDbEditedby || null !== $criteria) { - if ($this->isNew() && null === $this->collCcFilessRelatedByDbEditedby) { - return 0; - } else { - $query = CcFilesQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcSubjsRelatedByDbEditedby($this) - ->count($con); - } - } else { - return count($this->collCcFilessRelatedByDbEditedby); - } - } - - /** - * 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 addCcFilesRelatedByDbEditedby(CcFiles $l) - { - if ($this->collCcFilessRelatedByDbEditedby === null) { - $this->initCcFilessRelatedByDbEditedby(); - } - if (!$this->collCcFilessRelatedByDbEditedby->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcFilessRelatedByDbEditedby[]= $l; - $l->setCcSubjsRelatedByDbEditedby($this); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcSubjs is new, it will return - * an empty collection; or if this CcSubjs has previously - * been saved, it will retrieve related CcFilessRelatedByDbEditedby 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 CcSubjs. - * - * @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 CcFiles[] List of CcFiles objects - */ - public function getCcFilessRelatedByDbEditedbyJoinCcMusicDirs($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcFilesQuery::create(null, $criteria); - $query->joinWith('CcMusicDirs', $join_behavior); - - return $this->getCcFilessRelatedByDbEditedby($query, $con); - } - - /** - * 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 collCcShowHostss 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 addCcShowHostss() - */ - public function clearCcShowHostss() - { - $this->collCcShowHostss = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcShowHostss collection. - * - * By default this just sets the collCcShowHostss collection to an empty array (like clearcollCcShowHostss()); - * 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 initCcShowHostss() - { - $this->collCcShowHostss = new PropelObjectCollection(); - $this->collCcShowHostss->setModel('CcShowHosts'); - } - - /** - * Gets an array of CcShowHosts 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 CcShowHosts[] List of CcShowHosts objects - * @throws PropelException - */ - public function getCcShowHostss($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcShowHostss || null !== $criteria) { - if ($this->isNew() && null === $this->collCcShowHostss) { - // return empty collection - $this->initCcShowHostss(); - } else { - $collCcShowHostss = CcShowHostsQuery::create(null, $criteria) - ->filterByCcSubjs($this) - ->find($con); - if (null !== $criteria) { - return $collCcShowHostss; - } - $this->collCcShowHostss = $collCcShowHostss; - } - } - return $this->collCcShowHostss; - } - - /** - * Returns the number of related CcShowHosts objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcShowHosts objects. - * @throws PropelException - */ - public function countCcShowHostss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcShowHostss || null !== $criteria) { - if ($this->isNew() && null === $this->collCcShowHostss) { - return 0; - } else { - $query = CcShowHostsQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcSubjs($this) - ->count($con); - } - } else { - return count($this->collCcShowHostss); - } - } - - /** - * Method called to associate a CcShowHosts object to this object - * through the CcShowHosts foreign key attribute. - * - * @param CcShowHosts $l CcShowHosts - * @return void - * @throws PropelException - */ - public function addCcShowHosts(CcShowHosts $l) - { - if ($this->collCcShowHostss === null) { - $this->initCcShowHostss(); - } - if (!$this->collCcShowHostss->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcShowHostss[]= $l; - $l->setCcSubjs($this); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcSubjs is new, it will return - * an empty collection; or if this CcSubjs has previously - * been saved, it will retrieve related CcShowHostss 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 CcSubjs. - * - * @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 CcShowHosts[] List of CcShowHosts objects - */ - public function getCcShowHostssJoinCcShow($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcShowHostsQuery::create(null, $criteria); - $query->joinWith('CcShow', $join_behavior); - - return $this->getCcShowHostss($query, $con); - } - - /** - * 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 collCcBlocks 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 addCcBlocks() - */ - public function clearCcBlocks() - { - $this->collCcBlocks = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcBlocks collection. - * - * By default this just sets the collCcBlocks collection to an empty array (like clearcollCcBlocks()); - * 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 initCcBlocks() - { - $this->collCcBlocks = new PropelObjectCollection(); - $this->collCcBlocks->setModel('CcBlock'); - } - - /** - * Gets an array of CcBlock 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 CcBlock[] List of CcBlock objects - * @throws PropelException - */ - public function getCcBlocks($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcBlocks || null !== $criteria) { - if ($this->isNew() && null === $this->collCcBlocks) { - // return empty collection - $this->initCcBlocks(); - } else { - $collCcBlocks = CcBlockQuery::create(null, $criteria) - ->filterByCcSubjs($this) - ->find($con); - if (null !== $criteria) { - return $collCcBlocks; - } - $this->collCcBlocks = $collCcBlocks; - } - } - return $this->collCcBlocks; - } - - /** - * Returns the number of related CcBlock objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcBlock objects. - * @throws PropelException - */ - public function countCcBlocks(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcBlocks || null !== $criteria) { - if ($this->isNew() && null === $this->collCcBlocks) { - return 0; - } else { - $query = CcBlockQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcSubjs($this) - ->count($con); - } - } else { - return count($this->collCcBlocks); - } - } - - /** - * Method called to associate a CcBlock object to this object - * through the CcBlock foreign key attribute. - * - * @param CcBlock $l CcBlock - * @return void - * @throws PropelException - */ - public function addCcBlock(CcBlock $l) - { - if ($this->collCcBlocks === null) { - $this->initCcBlocks(); - } - if (!$this->collCcBlocks->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcBlocks[]= $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 out the collCcSubjsTokens 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 addCcSubjsTokens() - */ - public function clearCcSubjsTokens() - { - $this->collCcSubjsTokens = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcSubjsTokens collection. - * - * By default this just sets the collCcSubjsTokens collection to an empty array (like clearcollCcSubjsTokens()); - * 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 initCcSubjsTokens() - { - $this->collCcSubjsTokens = new PropelObjectCollection(); - $this->collCcSubjsTokens->setModel('CcSubjsToken'); - } - - /** - * Gets an array of CcSubjsToken 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 CcSubjsToken[] List of CcSubjsToken objects - * @throws PropelException - */ - public function getCcSubjsTokens($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcSubjsTokens || null !== $criteria) { - if ($this->isNew() && null === $this->collCcSubjsTokens) { - // return empty collection - $this->initCcSubjsTokens(); - } else { - $collCcSubjsTokens = CcSubjsTokenQuery::create(null, $criteria) - ->filterByCcSubjs($this) - ->find($con); - if (null !== $criteria) { - return $collCcSubjsTokens; - } - $this->collCcSubjsTokens = $collCcSubjsTokens; - } - } - return $this->collCcSubjsTokens; - } - - /** - * Returns the number of related CcSubjsToken objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcSubjsToken objects. - * @throws PropelException - */ - public function countCcSubjsTokens(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcSubjsTokens || null !== $criteria) { - if ($this->isNew() && null === $this->collCcSubjsTokens) { - return 0; - } else { - $query = CcSubjsTokenQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcSubjs($this) - ->count($con); - } - } else { - return count($this->collCcSubjsTokens); - } - } - - /** - * Method called to associate a CcSubjsToken object to this object - * through the CcSubjsToken foreign key attribute. - * - * @param CcSubjsToken $l CcSubjsToken - * @return void - * @throws PropelException - */ - public function addCcSubjsToken(CcSubjsToken $l) - { - if ($this->collCcSubjsTokens === null) { - $this->initCcSubjsTokens(); - } - if (!$this->collCcSubjsTokens->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcSubjsTokens[]= $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->first_name = null; - $this->last_name = null; - $this->lastlogin = null; - $this->lastfail = null; - $this->skype_contact = null; - $this->jabber_contact = null; - $this->email = null; - $this->cell_phone = null; - $this->login_attempts = 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->collCcFilessRelatedByDbOwnerId) { - foreach ((array) $this->collCcFilessRelatedByDbOwnerId as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCcFilessRelatedByDbEditedby) { - foreach ((array) $this->collCcFilessRelatedByDbEditedby as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCcPermss) { - foreach ((array) $this->collCcPermss as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCcShowHostss) { - foreach ((array) $this->collCcShowHostss as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCcPlaylists) { - foreach ((array) $this->collCcPlaylists as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCcBlocks) { - foreach ((array) $this->collCcBlocks 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 ($this->collCcSubjsTokens) { - foreach ((array) $this->collCcSubjsTokens as $o) { - $o->clearAllReferences($deep); - } - } - } // if ($deep) - - $this->collCcFilessRelatedByDbOwnerId = null; - $this->collCcFilessRelatedByDbEditedby = null; - $this->collCcPermss = null; - $this->collCcShowHostss = null; - $this->collCcPlaylists = null; - $this->collCcBlocks = null; - $this->collCcPrefs = null; - $this->collCcSesss = null; - $this->collCcSubjsTokens = 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 + /** + * Peer class name + */ + const PEER = 'Airtime\\CcSubjsPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcSubjsPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the login field. + * Note: this column has a database default value of: '' + * @var string + */ + protected $login; + + /** + * The value for the pass field. + * Note: this column has a database default value of: '' + * @var string + */ + protected $pass; + + /** + * The value for the type field. + * Note: this column has a database default value of: 'U' + * @var string + */ + protected $type; + + /** + * The value for the first_name field. + * Note: this column has a database default value of: '' + * @var string + */ + protected $first_name; + + /** + * The value for the last_name field. + * Note: this column has a database default value of: '' + * @var string + */ + protected $last_name; + + /** + * The value for the lastlogin field. + * @var string + */ + protected $lastlogin; + + /** + * The value for the lastfail field. + * @var string + */ + protected $lastfail; + + /** + * The value for the skype_contact field. + * @var string + */ + protected $skype_contact; + + /** + * The value for the jabber_contact field. + * @var string + */ + protected $jabber_contact; + + /** + * The value for the email field. + * @var string + */ + protected $email; + + /** + * The value for the cell_phone field. + * @var string + */ + protected $cell_phone; + + /** + * The value for the login_attempts field. + * Note: this column has a database default value of: 0 + * @var int + */ + protected $login_attempts; + + /** + * @var PropelObjectCollection|CcFiles[] Collection to store aggregation of CcFiles objects. + */ + protected $collCcFilessRelatedByDbOwnerId; + protected $collCcFilessRelatedByDbOwnerIdPartial; + + /** + * @var PropelObjectCollection|CcFiles[] Collection to store aggregation of CcFiles objects. + */ + protected $collCcFilessRelatedByDbEditedby; + protected $collCcFilessRelatedByDbEditedbyPartial; + + /** + * @var PropelObjectCollection|CcShowHosts[] Collection to store aggregation of CcShowHosts objects. + */ + protected $collCcShowHostss; + protected $collCcShowHostssPartial; + + /** + * @var PropelObjectCollection|CcPlaylist[] Collection to store aggregation of CcPlaylist objects. + */ + protected $collCcPlaylists; + protected $collCcPlaylistsPartial; + + /** + * @var PropelObjectCollection|CcBlock[] Collection to store aggregation of CcBlock objects. + */ + protected $collCcBlocks; + protected $collCcBlocksPartial; + + /** + * @var PropelObjectCollection|CcPref[] Collection to store aggregation of CcPref objects. + */ + protected $collCcPrefs; + protected $collCcPrefsPartial; + + /** + * @var PropelObjectCollection|CcSubjsToken[] Collection to store aggregation of CcSubjsToken objects. + */ + protected $collCcSubjsTokens; + protected $collCcSubjsTokensPartial; + + /** + * @var PropelObjectCollection|MediaItem[] Collection to store aggregation of MediaItem objects. + */ + protected $collMediaItems; + protected $collMediaItemsPartial; + + /** + * @var PropelObjectCollection|AudioFile[] Collection to store aggregation of AudioFile objects. + */ + protected $collAudioFiles; + protected $collAudioFilesPartial; + + /** + * @var PropelObjectCollection|Webstream[] Collection to store aggregation of Webstream objects. + */ + protected $collWebstreams; + protected $collWebstreamsPartial; + + /** + * @var PropelObjectCollection|Playlist[] Collection to store aggregation of Playlist objects. + */ + protected $collPlaylists; + protected $collPlaylistsPartial; + + /** + * @var PropelObjectCollection|Block[] Collection to store aggregation of Block objects. + */ + protected $collBlocks; + protected $collBlocksPartial; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccFilessRelatedByDbOwnerIdScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccFilessRelatedByDbEditedbyScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccShowHostssScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccPlaylistsScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccBlocksScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccPrefsScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccSubjsTokensScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $mediaItemsScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $audioFilesScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $webstreamsScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $playlistsScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $blocksScheduledForDeletion = null; + + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->login = ''; + $this->pass = ''; + $this->type = 'U'; + $this->first_name = ''; + $this->last_name = ''; + $this->login_attempts = 0; + } + + /** + * Initializes internal state of BaseCcSubjs 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 [login] column value. + * + * @return string + */ + public function getDbLogin() + { + + return $this->login; + } + + /** + * Get the [pass] column value. + * + * @return string + */ + public function getDbPass() + { + + return $this->pass; + } + + /** + * Get the [type] column value. + * + * @return string + */ + public function getDbType() + { + + return $this->type; + } + + /** + * Get the [first_name] column value. + * + * @return string + */ + public function getDbFirstName() + { + + return $this->first_name; + } + + /** + * Get the [last_name] column value. + * + * @return string + */ + public function getDbLastName() + { + + return $this->last_name; + } + + /** + * 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 getDbLastlogin($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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + 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 getDbLastfail($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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [skype_contact] column value. + * + * @return string + */ + public function getDbSkypeContact() + { + + return $this->skype_contact; + } + + /** + * Get the [jabber_contact] column value. + * + * @return string + */ + public function getDbJabberContact() + { + + return $this->jabber_contact; + } + + /** + * Get the [email] column value. + * + * @return string + */ + public function getDbEmail() + { + + return $this->email; + } + + /** + * Get the [cell_phone] column value. + * + * @return string + */ + public function getDbCellPhone() + { + + return $this->cell_phone; + } + + /** + * Get the [login_attempts] column value. + * + * @return int + */ + public function getDbLoginAttempts() + { + + return $this->login_attempts; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcSubjs The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcSubjsPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [login] column. + * + * @param string $v new value + * @return CcSubjs The current object (for fluent API support) + */ + public function setDbLogin($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->login !== $v) { + $this->login = $v; + $this->modifiedColumns[] = CcSubjsPeer::LOGIN; + } + + + return $this; + } // setDbLogin() + + /** + * Set the value of [pass] column. + * + * @param string $v new value + * @return CcSubjs The current object (for fluent API support) + */ + public function setDbPass($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->pass !== $v) { + $this->pass = $v; + $this->modifiedColumns[] = CcSubjsPeer::PASS; + } + + + return $this; + } // setDbPass() + + /** + * Set the value of [type] column. + * + * @param string $v new value + * @return CcSubjs The current object (for fluent API support) + */ + public function setDbType($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->type !== $v) { + $this->type = $v; + $this->modifiedColumns[] = CcSubjsPeer::TYPE; + } + + + return $this; + } // setDbType() + + /** + * Set the value of [first_name] column. + * + * @param string $v new value + * @return CcSubjs The current object (for fluent API support) + */ + public function setDbFirstName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->first_name !== $v) { + $this->first_name = $v; + $this->modifiedColumns[] = CcSubjsPeer::FIRST_NAME; + } + + + return $this; + } // setDbFirstName() + + /** + * Set the value of [last_name] column. + * + * @param string $v new value + * @return CcSubjs The current object (for fluent API support) + */ + public function setDbLastName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->last_name !== $v) { + $this->last_name = $v; + $this->modifiedColumns[] = CcSubjsPeer::LAST_NAME; + } + + + return $this; + } // setDbLastName() + + /** + * 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 strings are treated as null. + * @return CcSubjs The current object (for fluent API support) + */ + public function setDbLastlogin($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->lastlogin !== null || $dt !== null) { + $currentDateAsString = ($this->lastlogin !== null && $tmpDt = new DateTime($this->lastlogin)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->lastlogin = $newDateAsString; + $this->modifiedColumns[] = CcSubjsPeer::LASTLOGIN; + } + } // if either are not null + + + return $this; + } // setDbLastlogin() + + /** + * 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 strings are treated as null. + * @return CcSubjs The current object (for fluent API support) + */ + public function setDbLastfail($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->lastfail !== null || $dt !== null) { + $currentDateAsString = ($this->lastfail !== null && $tmpDt = new DateTime($this->lastfail)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->lastfail = $newDateAsString; + $this->modifiedColumns[] = CcSubjsPeer::LASTFAIL; + } + } // if either are not null + + + return $this; + } // setDbLastfail() + + /** + * Set the value of [skype_contact] column. + * + * @param string $v new value + * @return CcSubjs The current object (for fluent API support) + */ + public function setDbSkypeContact($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->skype_contact !== $v) { + $this->skype_contact = $v; + $this->modifiedColumns[] = CcSubjsPeer::SKYPE_CONTACT; + } + + + return $this; + } // setDbSkypeContact() + + /** + * Set the value of [jabber_contact] column. + * + * @param string $v new value + * @return CcSubjs The current object (for fluent API support) + */ + public function setDbJabberContact($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->jabber_contact !== $v) { + $this->jabber_contact = $v; + $this->modifiedColumns[] = CcSubjsPeer::JABBER_CONTACT; + } + + + return $this; + } // setDbJabberContact() + + /** + * Set the value of [email] column. + * + * @param string $v new value + * @return CcSubjs The current object (for fluent API support) + */ + public function setDbEmail($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->email !== $v) { + $this->email = $v; + $this->modifiedColumns[] = CcSubjsPeer::EMAIL; + } + + + return $this; + } // setDbEmail() + + /** + * Set the value of [cell_phone] column. + * + * @param string $v new value + * @return CcSubjs The current object (for fluent API support) + */ + public function setDbCellPhone($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->cell_phone !== $v) { + $this->cell_phone = $v; + $this->modifiedColumns[] = CcSubjsPeer::CELL_PHONE; + } + + + return $this; + } // setDbCellPhone() + + /** + * Set the value of [login_attempts] column. + * + * @param int $v new value + * @return CcSubjs The current object (for fluent API support) + */ + public function setDbLoginAttempts($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->login_attempts !== $v) { + $this->login_attempts = $v; + $this->modifiedColumns[] = CcSubjsPeer::LOGIN_ATTEMPTS; + } + + + return $this; + } // setDbLoginAttempts() + + /** + * 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->first_name !== '') { + return false; + } + + if ($this->last_name !== '') { + return false; + } + + if ($this->login_attempts !== 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 resultset 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->first_name = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->last_name = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->lastlogin = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->lastfail = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; + $this->skype_contact = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->jabber_contact = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->email = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; + $this->cell_phone = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null; + $this->login_attempts = ($row[$startcol + 12] !== null) ? (int) $row[$startcol + 12] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 13; // 13 = CcSubjsPeer::NUM_HYDRATE_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->collCcFilessRelatedByDbOwnerId = null; + + $this->collCcFilessRelatedByDbEditedby = null; + + $this->collCcShowHostss = null; + + $this->collCcPlaylists = null; + + $this->collCcBlocks = null; + + $this->collCcPrefs = null; + + $this->collCcSubjsTokens = null; + + $this->collMediaItems = null; + + $this->collAudioFiles = null; + + $this->collWebstreams = null; + + $this->collPlaylists = null; + + $this->collBlocks = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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 { + $deleteQuery = CcSubjsQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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 (Exception $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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->ccFilessRelatedByDbOwnerIdScheduledForDeletion !== null) { + if (!$this->ccFilessRelatedByDbOwnerIdScheduledForDeletion->isEmpty()) { + foreach ($this->ccFilessRelatedByDbOwnerIdScheduledForDeletion as $ccFilesRelatedByDbOwnerId) { + // need to save related object because we set the relation to null + $ccFilesRelatedByDbOwnerId->save($con); + } + $this->ccFilessRelatedByDbOwnerIdScheduledForDeletion = null; + } + } + + if ($this->collCcFilessRelatedByDbOwnerId !== null) { + foreach ($this->collCcFilessRelatedByDbOwnerId as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ccFilessRelatedByDbEditedbyScheduledForDeletion !== null) { + if (!$this->ccFilessRelatedByDbEditedbyScheduledForDeletion->isEmpty()) { + foreach ($this->ccFilessRelatedByDbEditedbyScheduledForDeletion as $ccFilesRelatedByDbEditedby) { + // need to save related object because we set the relation to null + $ccFilesRelatedByDbEditedby->save($con); + } + $this->ccFilessRelatedByDbEditedbyScheduledForDeletion = null; + } + } + + if ($this->collCcFilessRelatedByDbEditedby !== null) { + foreach ($this->collCcFilessRelatedByDbEditedby as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ccShowHostssScheduledForDeletion !== null) { + if (!$this->ccShowHostssScheduledForDeletion->isEmpty()) { + CcShowHostsQuery::create() + ->filterByPrimaryKeys($this->ccShowHostssScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccShowHostssScheduledForDeletion = null; + } + } + + if ($this->collCcShowHostss !== null) { + foreach ($this->collCcShowHostss as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ccPlaylistsScheduledForDeletion !== null) { + if (!$this->ccPlaylistsScheduledForDeletion->isEmpty()) { + CcPlaylistQuery::create() + ->filterByPrimaryKeys($this->ccPlaylistsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccPlaylistsScheduledForDeletion = null; + } + } + + if ($this->collCcPlaylists !== null) { + foreach ($this->collCcPlaylists as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ccBlocksScheduledForDeletion !== null) { + if (!$this->ccBlocksScheduledForDeletion->isEmpty()) { + CcBlockQuery::create() + ->filterByPrimaryKeys($this->ccBlocksScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccBlocksScheduledForDeletion = null; + } + } + + if ($this->collCcBlocks !== null) { + foreach ($this->collCcBlocks as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ccPrefsScheduledForDeletion !== null) { + if (!$this->ccPrefsScheduledForDeletion->isEmpty()) { + CcPrefQuery::create() + ->filterByPrimaryKeys($this->ccPrefsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccPrefsScheduledForDeletion = null; + } + } + + if ($this->collCcPrefs !== null) { + foreach ($this->collCcPrefs as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ccSubjsTokensScheduledForDeletion !== null) { + if (!$this->ccSubjsTokensScheduledForDeletion->isEmpty()) { + CcSubjsTokenQuery::create() + ->filterByPrimaryKeys($this->ccSubjsTokensScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccSubjsTokensScheduledForDeletion = null; + } + } + + if ($this->collCcSubjsTokens !== null) { + foreach ($this->collCcSubjsTokens as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->mediaItemsScheduledForDeletion !== null) { + if (!$this->mediaItemsScheduledForDeletion->isEmpty()) { + foreach ($this->mediaItemsScheduledForDeletion as $mediaItem) { + // need to save related object because we set the relation to null + $mediaItem->save($con); + } + $this->mediaItemsScheduledForDeletion = null; + } + } + + if ($this->collMediaItems !== null) { + foreach ($this->collMediaItems as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->audioFilesScheduledForDeletion !== null) { + if (!$this->audioFilesScheduledForDeletion->isEmpty()) { + foreach ($this->audioFilesScheduledForDeletion as $audioFile) { + // need to save related object because we set the relation to null + $audioFile->save($con); + } + $this->audioFilesScheduledForDeletion = null; + } + } + + if ($this->collAudioFiles !== null) { + foreach ($this->collAudioFiles as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->webstreamsScheduledForDeletion !== null) { + if (!$this->webstreamsScheduledForDeletion->isEmpty()) { + foreach ($this->webstreamsScheduledForDeletion as $webstream) { + // need to save related object because we set the relation to null + $webstream->save($con); + } + $this->webstreamsScheduledForDeletion = null; + } + } + + if ($this->collWebstreams !== null) { + foreach ($this->collWebstreams as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->playlistsScheduledForDeletion !== null) { + if (!$this->playlistsScheduledForDeletion->isEmpty()) { + foreach ($this->playlistsScheduledForDeletion as $playlist) { + // need to save related object because we set the relation to null + $playlist->save($con); + } + $this->playlistsScheduledForDeletion = null; + } + } + + if ($this->collPlaylists !== null) { + foreach ($this->collPlaylists as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->blocksScheduledForDeletion !== null) { + if (!$this->blocksScheduledForDeletion->isEmpty()) { + foreach ($this->blocksScheduledForDeletion as $block) { + // need to save related object because we set the relation to null + $block->save($con); + } + $this->blocksScheduledForDeletion = null; + } + } + + if ($this->collBlocks !== null) { + foreach ($this->collBlocks as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcSubjsPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcSubjsPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_subjs_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcSubjsPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcSubjsPeer::LOGIN)) { + $modifiedColumns[':p' . $index++] = '"login"'; + } + if ($this->isColumnModified(CcSubjsPeer::PASS)) { + $modifiedColumns[':p' . $index++] = '"pass"'; + } + if ($this->isColumnModified(CcSubjsPeer::TYPE)) { + $modifiedColumns[':p' . $index++] = '"type"'; + } + if ($this->isColumnModified(CcSubjsPeer::FIRST_NAME)) { + $modifiedColumns[':p' . $index++] = '"first_name"'; + } + if ($this->isColumnModified(CcSubjsPeer::LAST_NAME)) { + $modifiedColumns[':p' . $index++] = '"last_name"'; + } + if ($this->isColumnModified(CcSubjsPeer::LASTLOGIN)) { + $modifiedColumns[':p' . $index++] = '"lastlogin"'; + } + if ($this->isColumnModified(CcSubjsPeer::LASTFAIL)) { + $modifiedColumns[':p' . $index++] = '"lastfail"'; + } + if ($this->isColumnModified(CcSubjsPeer::SKYPE_CONTACT)) { + $modifiedColumns[':p' . $index++] = '"skype_contact"'; + } + if ($this->isColumnModified(CcSubjsPeer::JABBER_CONTACT)) { + $modifiedColumns[':p' . $index++] = '"jabber_contact"'; + } + if ($this->isColumnModified(CcSubjsPeer::EMAIL)) { + $modifiedColumns[':p' . $index++] = '"email"'; + } + if ($this->isColumnModified(CcSubjsPeer::CELL_PHONE)) { + $modifiedColumns[':p' . $index++] = '"cell_phone"'; + } + if ($this->isColumnModified(CcSubjsPeer::LOGIN_ATTEMPTS)) { + $modifiedColumns[':p' . $index++] = '"login_attempts"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_subjs" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"login"': + $stmt->bindValue($identifier, $this->login, PDO::PARAM_STR); + break; + case '"pass"': + $stmt->bindValue($identifier, $this->pass, PDO::PARAM_STR); + break; + case '"type"': + $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR); + break; + case '"first_name"': + $stmt->bindValue($identifier, $this->first_name, PDO::PARAM_STR); + break; + case '"last_name"': + $stmt->bindValue($identifier, $this->last_name, PDO::PARAM_STR); + break; + case '"lastlogin"': + $stmt->bindValue($identifier, $this->lastlogin, PDO::PARAM_STR); + break; + case '"lastfail"': + $stmt->bindValue($identifier, $this->lastfail, PDO::PARAM_STR); + break; + case '"skype_contact"': + $stmt->bindValue($identifier, $this->skype_contact, PDO::PARAM_STR); + break; + case '"jabber_contact"': + $stmt->bindValue($identifier, $this->jabber_contact, PDO::PARAM_STR); + break; + case '"email"': + $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR); + break; + case '"cell_phone"': + $stmt->bindValue($identifier, $this->cell_phone, PDO::PARAM_STR); + break; + case '"login_attempts"': + $stmt->bindValue($identifier, $this->login_attempts, PDO::PARAM_INT); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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->collCcFilessRelatedByDbOwnerId !== null) { + foreach ($this->collCcFilessRelatedByDbOwnerId as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collCcFilessRelatedByDbEditedby !== null) { + foreach ($this->collCcFilessRelatedByDbEditedby as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collCcShowHostss !== null) { + foreach ($this->collCcShowHostss 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->collCcBlocks !== null) { + foreach ($this->collCcBlocks 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->collCcSubjsTokens !== null) { + foreach ($this->collCcSubjsTokens as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collMediaItems !== null) { + foreach ($this->collMediaItems as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collAudioFiles !== null) { + foreach ($this->collAudioFiles as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collWebstreams !== null) { + foreach ($this->collWebstreams as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collPlaylists !== null) { + foreach ($this->collPlaylists as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collBlocks !== null) { + foreach ($this->collBlocks 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @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->getDbId(); + break; + case 1: + return $this->getDbLogin(); + break; + case 2: + return $this->getDbPass(); + break; + case 3: + return $this->getDbType(); + break; + case 4: + return $this->getDbFirstName(); + break; + case 5: + return $this->getDbLastName(); + break; + case 6: + return $this->getDbLastlogin(); + break; + case 7: + return $this->getDbLastfail(); + break; + case 8: + return $this->getDbSkypeContact(); + break; + case 9: + return $this->getDbJabberContact(); + break; + case 10: + return $this->getDbEmail(); + break; + case 11: + return $this->getDbCellPhone(); + break; + case 12: + return $this->getDbLoginAttempts(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcSubjs'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcSubjs'][$this->getPrimaryKey()] = true; + $keys = CcSubjsPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbLogin(), + $keys[2] => $this->getDbPass(), + $keys[3] => $this->getDbType(), + $keys[4] => $this->getDbFirstName(), + $keys[5] => $this->getDbLastName(), + $keys[6] => $this->getDbLastlogin(), + $keys[7] => $this->getDbLastfail(), + $keys[8] => $this->getDbSkypeContact(), + $keys[9] => $this->getDbJabberContact(), + $keys[10] => $this->getDbEmail(), + $keys[11] => $this->getDbCellPhone(), + $keys[12] => $this->getDbLoginAttempts(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->collCcFilessRelatedByDbOwnerId) { + $result['CcFilessRelatedByDbOwnerId'] = $this->collCcFilessRelatedByDbOwnerId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCcFilessRelatedByDbEditedby) { + $result['CcFilessRelatedByDbEditedby'] = $this->collCcFilessRelatedByDbEditedby->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCcShowHostss) { + $result['CcShowHostss'] = $this->collCcShowHostss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCcPlaylists) { + $result['CcPlaylists'] = $this->collCcPlaylists->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCcBlocks) { + $result['CcBlocks'] = $this->collCcBlocks->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCcPrefs) { + $result['CcPrefs'] = $this->collCcPrefs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCcSubjsTokens) { + $result['CcSubjsTokens'] = $this->collCcSubjsTokens->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collMediaItems) { + $result['MediaItems'] = $this->collMediaItems->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collAudioFiles) { + $result['AudioFiles'] = $this->collAudioFiles->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collWebstreams) { + $result['Webstreams'] = $this->collWebstreams->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collPlaylists) { + $result['Playlists'] = $this->collPlaylists->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collBlocks) { + $result['Blocks'] = $this->collBlocks->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcSubjsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbLogin($value); + break; + case 2: + $this->setDbPass($value); + break; + case 3: + $this->setDbType($value); + break; + case 4: + $this->setDbFirstName($value); + break; + case 5: + $this->setDbLastName($value); + break; + case 6: + $this->setDbLastlogin($value); + break; + case 7: + $this->setDbLastfail($value); + break; + case 8: + $this->setDbSkypeContact($value); + break; + case 9: + $this->setDbJabberContact($value); + break; + case 10: + $this->setDbEmail($value); + break; + case 11: + $this->setDbCellPhone($value); + break; + case 12: + $this->setDbLoginAttempts($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 BasePeer::TYPE_PHPNAME + * + * @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->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbLogin($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbPass($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbType($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbFirstName($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbLastName($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbLastlogin($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbLastfail($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setDbSkypeContact($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDbJabberContact($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setDbEmail($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setDbCellPhone($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setDbLoginAttempts($arr[$keys[12]]); + } + + /** + * 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::FIRST_NAME)) $criteria->add(CcSubjsPeer::FIRST_NAME, $this->first_name); + if ($this->isColumnModified(CcSubjsPeer::LAST_NAME)) $criteria->add(CcSubjsPeer::LAST_NAME, $this->last_name); + if ($this->isColumnModified(CcSubjsPeer::LASTLOGIN)) $criteria->add(CcSubjsPeer::LASTLOGIN, $this->lastlogin); + if ($this->isColumnModified(CcSubjsPeer::LASTFAIL)) $criteria->add(CcSubjsPeer::LASTFAIL, $this->lastfail); + if ($this->isColumnModified(CcSubjsPeer::SKYPE_CONTACT)) $criteria->add(CcSubjsPeer::SKYPE_CONTACT, $this->skype_contact); + if ($this->isColumnModified(CcSubjsPeer::JABBER_CONTACT)) $criteria->add(CcSubjsPeer::JABBER_CONTACT, $this->jabber_contact); + if ($this->isColumnModified(CcSubjsPeer::EMAIL)) $criteria->add(CcSubjsPeer::EMAIL, $this->email); + if ($this->isColumnModified(CcSubjsPeer::CELL_PHONE)) $criteria->add(CcSubjsPeer::CELL_PHONE, $this->cell_phone); + if ($this->isColumnModified(CcSubjsPeer::LOGIN_ATTEMPTS)) $criteria->add(CcSubjsPeer::LOGIN_ATTEMPTS, $this->login_attempts); + + 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->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 CcSubjs (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbLogin($this->getDbLogin()); + $copyObj->setDbPass($this->getDbPass()); + $copyObj->setDbType($this->getDbType()); + $copyObj->setDbFirstName($this->getDbFirstName()); + $copyObj->setDbLastName($this->getDbLastName()); + $copyObj->setDbLastlogin($this->getDbLastlogin()); + $copyObj->setDbLastfail($this->getDbLastfail()); + $copyObj->setDbSkypeContact($this->getDbSkypeContact()); + $copyObj->setDbJabberContact($this->getDbJabberContact()); + $copyObj->setDbEmail($this->getDbEmail()); + $copyObj->setDbCellPhone($this->getDbCellPhone()); + $copyObj->setDbLoginAttempts($this->getDbLoginAttempts()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + foreach ($this->getCcFilessRelatedByDbOwnerId() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcFilesRelatedByDbOwnerId($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCcFilessRelatedByDbEditedby() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcFilesRelatedByDbEditedby($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCcShowHostss() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcShowHosts($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->getCcBlocks() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcBlock($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->getCcSubjsTokens() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcSubjsToken($relObj->copy($deepCopy)); + } + } + + foreach ($this->getMediaItems() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addMediaItem($relObj->copy($deepCopy)); + } + } + + foreach ($this->getAudioFiles() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addAudioFile($relObj->copy($deepCopy)); + } + } + + foreach ($this->getWebstreams() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addWebstream($relObj->copy($deepCopy)); + } + } + + foreach ($this->getPlaylists() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addPlaylist($relObj->copy($deepCopy)); + } + } + + foreach ($this->getBlocks() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addBlock($relObj->copy($deepCopy)); + } + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 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; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('CcFilesRelatedByDbOwnerId' == $relationName) { + $this->initCcFilessRelatedByDbOwnerId(); + } + if ('CcFilesRelatedByDbEditedby' == $relationName) { + $this->initCcFilessRelatedByDbEditedby(); + } + if ('CcShowHosts' == $relationName) { + $this->initCcShowHostss(); + } + if ('CcPlaylist' == $relationName) { + $this->initCcPlaylists(); + } + if ('CcBlock' == $relationName) { + $this->initCcBlocks(); + } + if ('CcPref' == $relationName) { + $this->initCcPrefs(); + } + if ('CcSubjsToken' == $relationName) { + $this->initCcSubjsTokens(); + } + if ('MediaItem' == $relationName) { + $this->initMediaItems(); + } + if ('AudioFile' == $relationName) { + $this->initAudioFiles(); + } + if ('Webstream' == $relationName) { + $this->initWebstreams(); + } + if ('Playlist' == $relationName) { + $this->initPlaylists(); + } + if ('Block' == $relationName) { + $this->initBlocks(); + } + } + + /** + * Clears out the collCcFilessRelatedByDbOwnerId 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 CcSubjs The current object (for fluent API support) + * @see addCcFilessRelatedByDbOwnerId() + */ + public function clearCcFilessRelatedByDbOwnerId() + { + $this->collCcFilessRelatedByDbOwnerId = null; // important to set this to null since that means it is uninitialized + $this->collCcFilessRelatedByDbOwnerIdPartial = null; + + return $this; + } + + /** + * reset is the collCcFilessRelatedByDbOwnerId collection loaded partially + * + * @return void + */ + public function resetPartialCcFilessRelatedByDbOwnerId($v = true) + { + $this->collCcFilessRelatedByDbOwnerIdPartial = $v; + } + + /** + * Initializes the collCcFilessRelatedByDbOwnerId collection. + * + * By default this just sets the collCcFilessRelatedByDbOwnerId collection to an empty array (like clearcollCcFilessRelatedByDbOwnerId()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcFilessRelatedByDbOwnerId($overrideExisting = true) + { + if (null !== $this->collCcFilessRelatedByDbOwnerId && !$overrideExisting) { + return; + } + $this->collCcFilessRelatedByDbOwnerId = new PropelObjectCollection(); + $this->collCcFilessRelatedByDbOwnerId->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 PropelObjectCollection|CcFiles[] List of CcFiles objects + * @throws PropelException + */ + public function getCcFilessRelatedByDbOwnerId($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcFilessRelatedByDbOwnerIdPartial && !$this->isNew(); + if (null === $this->collCcFilessRelatedByDbOwnerId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcFilessRelatedByDbOwnerId) { + // return empty collection + $this->initCcFilessRelatedByDbOwnerId(); + } else { + $collCcFilessRelatedByDbOwnerId = CcFilesQuery::create(null, $criteria) + ->filterByFkOwner($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcFilessRelatedByDbOwnerIdPartial && count($collCcFilessRelatedByDbOwnerId)) { + $this->initCcFilessRelatedByDbOwnerId(false); + + foreach ($collCcFilessRelatedByDbOwnerId as $obj) { + if (false == $this->collCcFilessRelatedByDbOwnerId->contains($obj)) { + $this->collCcFilessRelatedByDbOwnerId->append($obj); + } + } + + $this->collCcFilessRelatedByDbOwnerIdPartial = true; + } + + $collCcFilessRelatedByDbOwnerId->getInternalIterator()->rewind(); + + return $collCcFilessRelatedByDbOwnerId; + } + + if ($partial && $this->collCcFilessRelatedByDbOwnerId) { + foreach ($this->collCcFilessRelatedByDbOwnerId as $obj) { + if ($obj->isNew()) { + $collCcFilessRelatedByDbOwnerId[] = $obj; + } + } + } + + $this->collCcFilessRelatedByDbOwnerId = $collCcFilessRelatedByDbOwnerId; + $this->collCcFilessRelatedByDbOwnerIdPartial = false; + } + } + + return $this->collCcFilessRelatedByDbOwnerId; + } + + /** + * Sets a collection of CcFilesRelatedByDbOwnerId objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccFilessRelatedByDbOwnerId A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcSubjs The current object (for fluent API support) + */ + public function setCcFilessRelatedByDbOwnerId(PropelCollection $ccFilessRelatedByDbOwnerId, PropelPDO $con = null) + { + $ccFilessRelatedByDbOwnerIdToDelete = $this->getCcFilessRelatedByDbOwnerId(new Criteria(), $con)->diff($ccFilessRelatedByDbOwnerId); + + + $this->ccFilessRelatedByDbOwnerIdScheduledForDeletion = $ccFilessRelatedByDbOwnerIdToDelete; + + foreach ($ccFilessRelatedByDbOwnerIdToDelete as $ccFilesRelatedByDbOwnerIdRemoved) { + $ccFilesRelatedByDbOwnerIdRemoved->setFkOwner(null); + } + + $this->collCcFilessRelatedByDbOwnerId = null; + foreach ($ccFilessRelatedByDbOwnerId as $ccFilesRelatedByDbOwnerId) { + $this->addCcFilesRelatedByDbOwnerId($ccFilesRelatedByDbOwnerId); + } + + $this->collCcFilessRelatedByDbOwnerId = $ccFilessRelatedByDbOwnerId; + $this->collCcFilessRelatedByDbOwnerIdPartial = false; + + return $this; + } + + /** + * 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 countCcFilessRelatedByDbOwnerId(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcFilessRelatedByDbOwnerIdPartial && !$this->isNew(); + if (null === $this->collCcFilessRelatedByDbOwnerId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcFilessRelatedByDbOwnerId) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcFilessRelatedByDbOwnerId()); + } + $query = CcFilesQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFkOwner($this) + ->count($con); + } + + return count($this->collCcFilessRelatedByDbOwnerId); + } + + /** + * Method called to associate a CcFiles object to this object + * through the CcFiles foreign key attribute. + * + * @param CcFiles $l CcFiles + * @return CcSubjs The current object (for fluent API support) + */ + public function addCcFilesRelatedByDbOwnerId(CcFiles $l) + { + if ($this->collCcFilessRelatedByDbOwnerId === null) { + $this->initCcFilessRelatedByDbOwnerId(); + $this->collCcFilessRelatedByDbOwnerIdPartial = true; + } + + if (!in_array($l, $this->collCcFilessRelatedByDbOwnerId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcFilesRelatedByDbOwnerId($l); + + if ($this->ccFilessRelatedByDbOwnerIdScheduledForDeletion and $this->ccFilessRelatedByDbOwnerIdScheduledForDeletion->contains($l)) { + $this->ccFilessRelatedByDbOwnerIdScheduledForDeletion->remove($this->ccFilessRelatedByDbOwnerIdScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcFilesRelatedByDbOwnerId $ccFilesRelatedByDbOwnerId The ccFilesRelatedByDbOwnerId object to add. + */ + protected function doAddCcFilesRelatedByDbOwnerId($ccFilesRelatedByDbOwnerId) + { + $this->collCcFilessRelatedByDbOwnerId[]= $ccFilesRelatedByDbOwnerId; + $ccFilesRelatedByDbOwnerId->setFkOwner($this); + } + + /** + * @param CcFilesRelatedByDbOwnerId $ccFilesRelatedByDbOwnerId The ccFilesRelatedByDbOwnerId object to remove. + * @return CcSubjs The current object (for fluent API support) + */ + public function removeCcFilesRelatedByDbOwnerId($ccFilesRelatedByDbOwnerId) + { + if ($this->getCcFilessRelatedByDbOwnerId()->contains($ccFilesRelatedByDbOwnerId)) { + $this->collCcFilessRelatedByDbOwnerId->remove($this->collCcFilessRelatedByDbOwnerId->search($ccFilesRelatedByDbOwnerId)); + if (null === $this->ccFilessRelatedByDbOwnerIdScheduledForDeletion) { + $this->ccFilessRelatedByDbOwnerIdScheduledForDeletion = clone $this->collCcFilessRelatedByDbOwnerId; + $this->ccFilessRelatedByDbOwnerIdScheduledForDeletion->clear(); + } + $this->ccFilessRelatedByDbOwnerIdScheduledForDeletion[]= $ccFilesRelatedByDbOwnerId; + $ccFilesRelatedByDbOwnerId->setFkOwner(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcSubjs is new, it will return + * an empty collection; or if this CcSubjs has previously + * been saved, it will retrieve related CcFilessRelatedByDbOwnerId 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 CcSubjs. + * + * @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 PropelObjectCollection|CcFiles[] List of CcFiles objects + */ + public function getCcFilessRelatedByDbOwnerIdJoinCcMusicDirs($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcFilesQuery::create(null, $criteria); + $query->joinWith('CcMusicDirs', $join_behavior); + + return $this->getCcFilessRelatedByDbOwnerId($query, $con); + } + + /** + * Clears out the collCcFilessRelatedByDbEditedby 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 CcSubjs The current object (for fluent API support) + * @see addCcFilessRelatedByDbEditedby() + */ + public function clearCcFilessRelatedByDbEditedby() + { + $this->collCcFilessRelatedByDbEditedby = null; // important to set this to null since that means it is uninitialized + $this->collCcFilessRelatedByDbEditedbyPartial = null; + + return $this; + } + + /** + * reset is the collCcFilessRelatedByDbEditedby collection loaded partially + * + * @return void + */ + public function resetPartialCcFilessRelatedByDbEditedby($v = true) + { + $this->collCcFilessRelatedByDbEditedbyPartial = $v; + } + + /** + * Initializes the collCcFilessRelatedByDbEditedby collection. + * + * By default this just sets the collCcFilessRelatedByDbEditedby collection to an empty array (like clearcollCcFilessRelatedByDbEditedby()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcFilessRelatedByDbEditedby($overrideExisting = true) + { + if (null !== $this->collCcFilessRelatedByDbEditedby && !$overrideExisting) { + return; + } + $this->collCcFilessRelatedByDbEditedby = new PropelObjectCollection(); + $this->collCcFilessRelatedByDbEditedby->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 PropelObjectCollection|CcFiles[] List of CcFiles objects + * @throws PropelException + */ + public function getCcFilessRelatedByDbEditedby($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcFilessRelatedByDbEditedbyPartial && !$this->isNew(); + if (null === $this->collCcFilessRelatedByDbEditedby || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcFilessRelatedByDbEditedby) { + // return empty collection + $this->initCcFilessRelatedByDbEditedby(); + } else { + $collCcFilessRelatedByDbEditedby = CcFilesQuery::create(null, $criteria) + ->filterByCcSubjsRelatedByDbEditedby($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcFilessRelatedByDbEditedbyPartial && count($collCcFilessRelatedByDbEditedby)) { + $this->initCcFilessRelatedByDbEditedby(false); + + foreach ($collCcFilessRelatedByDbEditedby as $obj) { + if (false == $this->collCcFilessRelatedByDbEditedby->contains($obj)) { + $this->collCcFilessRelatedByDbEditedby->append($obj); + } + } + + $this->collCcFilessRelatedByDbEditedbyPartial = true; + } + + $collCcFilessRelatedByDbEditedby->getInternalIterator()->rewind(); + + return $collCcFilessRelatedByDbEditedby; + } + + if ($partial && $this->collCcFilessRelatedByDbEditedby) { + foreach ($this->collCcFilessRelatedByDbEditedby as $obj) { + if ($obj->isNew()) { + $collCcFilessRelatedByDbEditedby[] = $obj; + } + } + } + + $this->collCcFilessRelatedByDbEditedby = $collCcFilessRelatedByDbEditedby; + $this->collCcFilessRelatedByDbEditedbyPartial = false; + } + } + + return $this->collCcFilessRelatedByDbEditedby; + } + + /** + * Sets a collection of CcFilesRelatedByDbEditedby objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccFilessRelatedByDbEditedby A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcSubjs The current object (for fluent API support) + */ + public function setCcFilessRelatedByDbEditedby(PropelCollection $ccFilessRelatedByDbEditedby, PropelPDO $con = null) + { + $ccFilessRelatedByDbEditedbyToDelete = $this->getCcFilessRelatedByDbEditedby(new Criteria(), $con)->diff($ccFilessRelatedByDbEditedby); + + + $this->ccFilessRelatedByDbEditedbyScheduledForDeletion = $ccFilessRelatedByDbEditedbyToDelete; + + foreach ($ccFilessRelatedByDbEditedbyToDelete as $ccFilesRelatedByDbEditedbyRemoved) { + $ccFilesRelatedByDbEditedbyRemoved->setCcSubjsRelatedByDbEditedby(null); + } + + $this->collCcFilessRelatedByDbEditedby = null; + foreach ($ccFilessRelatedByDbEditedby as $ccFilesRelatedByDbEditedby) { + $this->addCcFilesRelatedByDbEditedby($ccFilesRelatedByDbEditedby); + } + + $this->collCcFilessRelatedByDbEditedby = $ccFilessRelatedByDbEditedby; + $this->collCcFilessRelatedByDbEditedbyPartial = false; + + return $this; + } + + /** + * 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 countCcFilessRelatedByDbEditedby(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcFilessRelatedByDbEditedbyPartial && !$this->isNew(); + if (null === $this->collCcFilessRelatedByDbEditedby || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcFilessRelatedByDbEditedby) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcFilessRelatedByDbEditedby()); + } + $query = CcFilesQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcSubjsRelatedByDbEditedby($this) + ->count($con); + } + + return count($this->collCcFilessRelatedByDbEditedby); + } + + /** + * Method called to associate a CcFiles object to this object + * through the CcFiles foreign key attribute. + * + * @param CcFiles $l CcFiles + * @return CcSubjs The current object (for fluent API support) + */ + public function addCcFilesRelatedByDbEditedby(CcFiles $l) + { + if ($this->collCcFilessRelatedByDbEditedby === null) { + $this->initCcFilessRelatedByDbEditedby(); + $this->collCcFilessRelatedByDbEditedbyPartial = true; + } + + if (!in_array($l, $this->collCcFilessRelatedByDbEditedby->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcFilesRelatedByDbEditedby($l); + + if ($this->ccFilessRelatedByDbEditedbyScheduledForDeletion and $this->ccFilessRelatedByDbEditedbyScheduledForDeletion->contains($l)) { + $this->ccFilessRelatedByDbEditedbyScheduledForDeletion->remove($this->ccFilessRelatedByDbEditedbyScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcFilesRelatedByDbEditedby $ccFilesRelatedByDbEditedby The ccFilesRelatedByDbEditedby object to add. + */ + protected function doAddCcFilesRelatedByDbEditedby($ccFilesRelatedByDbEditedby) + { + $this->collCcFilessRelatedByDbEditedby[]= $ccFilesRelatedByDbEditedby; + $ccFilesRelatedByDbEditedby->setCcSubjsRelatedByDbEditedby($this); + } + + /** + * @param CcFilesRelatedByDbEditedby $ccFilesRelatedByDbEditedby The ccFilesRelatedByDbEditedby object to remove. + * @return CcSubjs The current object (for fluent API support) + */ + public function removeCcFilesRelatedByDbEditedby($ccFilesRelatedByDbEditedby) + { + if ($this->getCcFilessRelatedByDbEditedby()->contains($ccFilesRelatedByDbEditedby)) { + $this->collCcFilessRelatedByDbEditedby->remove($this->collCcFilessRelatedByDbEditedby->search($ccFilesRelatedByDbEditedby)); + if (null === $this->ccFilessRelatedByDbEditedbyScheduledForDeletion) { + $this->ccFilessRelatedByDbEditedbyScheduledForDeletion = clone $this->collCcFilessRelatedByDbEditedby; + $this->ccFilessRelatedByDbEditedbyScheduledForDeletion->clear(); + } + $this->ccFilessRelatedByDbEditedbyScheduledForDeletion[]= $ccFilesRelatedByDbEditedby; + $ccFilesRelatedByDbEditedby->setCcSubjsRelatedByDbEditedby(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcSubjs is new, it will return + * an empty collection; or if this CcSubjs has previously + * been saved, it will retrieve related CcFilessRelatedByDbEditedby 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 CcSubjs. + * + * @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 PropelObjectCollection|CcFiles[] List of CcFiles objects + */ + public function getCcFilessRelatedByDbEditedbyJoinCcMusicDirs($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcFilesQuery::create(null, $criteria); + $query->joinWith('CcMusicDirs', $join_behavior); + + return $this->getCcFilessRelatedByDbEditedby($query, $con); + } + + /** + * Clears out the collCcShowHostss 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 CcSubjs The current object (for fluent API support) + * @see addCcShowHostss() + */ + public function clearCcShowHostss() + { + $this->collCcShowHostss = null; // important to set this to null since that means it is uninitialized + $this->collCcShowHostssPartial = null; + + return $this; + } + + /** + * reset is the collCcShowHostss collection loaded partially + * + * @return void + */ + public function resetPartialCcShowHostss($v = true) + { + $this->collCcShowHostssPartial = $v; + } + + /** + * Initializes the collCcShowHostss collection. + * + * By default this just sets the collCcShowHostss collection to an empty array (like clearcollCcShowHostss()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcShowHostss($overrideExisting = true) + { + if (null !== $this->collCcShowHostss && !$overrideExisting) { + return; + } + $this->collCcShowHostss = new PropelObjectCollection(); + $this->collCcShowHostss->setModel('CcShowHosts'); + } + + /** + * Gets an array of CcShowHosts 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 PropelObjectCollection|CcShowHosts[] List of CcShowHosts objects + * @throws PropelException + */ + public function getCcShowHostss($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcShowHostssPartial && !$this->isNew(); + if (null === $this->collCcShowHostss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcShowHostss) { + // return empty collection + $this->initCcShowHostss(); + } else { + $collCcShowHostss = CcShowHostsQuery::create(null, $criteria) + ->filterByCcSubjs($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcShowHostssPartial && count($collCcShowHostss)) { + $this->initCcShowHostss(false); + + foreach ($collCcShowHostss as $obj) { + if (false == $this->collCcShowHostss->contains($obj)) { + $this->collCcShowHostss->append($obj); + } + } + + $this->collCcShowHostssPartial = true; + } + + $collCcShowHostss->getInternalIterator()->rewind(); + + return $collCcShowHostss; + } + + if ($partial && $this->collCcShowHostss) { + foreach ($this->collCcShowHostss as $obj) { + if ($obj->isNew()) { + $collCcShowHostss[] = $obj; + } + } + } + + $this->collCcShowHostss = $collCcShowHostss; + $this->collCcShowHostssPartial = false; + } + } + + return $this->collCcShowHostss; + } + + /** + * Sets a collection of CcShowHosts objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccShowHostss A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcSubjs The current object (for fluent API support) + */ + public function setCcShowHostss(PropelCollection $ccShowHostss, PropelPDO $con = null) + { + $ccShowHostssToDelete = $this->getCcShowHostss(new Criteria(), $con)->diff($ccShowHostss); + + + $this->ccShowHostssScheduledForDeletion = $ccShowHostssToDelete; + + foreach ($ccShowHostssToDelete as $ccShowHostsRemoved) { + $ccShowHostsRemoved->setCcSubjs(null); + } + + $this->collCcShowHostss = null; + foreach ($ccShowHostss as $ccShowHosts) { + $this->addCcShowHosts($ccShowHosts); + } + + $this->collCcShowHostss = $ccShowHostss; + $this->collCcShowHostssPartial = false; + + return $this; + } + + /** + * Returns the number of related CcShowHosts objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcShowHosts objects. + * @throws PropelException + */ + public function countCcShowHostss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcShowHostssPartial && !$this->isNew(); + if (null === $this->collCcShowHostss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcShowHostss) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcShowHostss()); + } + $query = CcShowHostsQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcSubjs($this) + ->count($con); + } + + return count($this->collCcShowHostss); + } + + /** + * Method called to associate a CcShowHosts object to this object + * through the CcShowHosts foreign key attribute. + * + * @param CcShowHosts $l CcShowHosts + * @return CcSubjs The current object (for fluent API support) + */ + public function addCcShowHosts(CcShowHosts $l) + { + if ($this->collCcShowHostss === null) { + $this->initCcShowHostss(); + $this->collCcShowHostssPartial = true; + } + + if (!in_array($l, $this->collCcShowHostss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcShowHosts($l); + + if ($this->ccShowHostssScheduledForDeletion and $this->ccShowHostssScheduledForDeletion->contains($l)) { + $this->ccShowHostssScheduledForDeletion->remove($this->ccShowHostssScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcShowHosts $ccShowHosts The ccShowHosts object to add. + */ + protected function doAddCcShowHosts($ccShowHosts) + { + $this->collCcShowHostss[]= $ccShowHosts; + $ccShowHosts->setCcSubjs($this); + } + + /** + * @param CcShowHosts $ccShowHosts The ccShowHosts object to remove. + * @return CcSubjs The current object (for fluent API support) + */ + public function removeCcShowHosts($ccShowHosts) + { + if ($this->getCcShowHostss()->contains($ccShowHosts)) { + $this->collCcShowHostss->remove($this->collCcShowHostss->search($ccShowHosts)); + if (null === $this->ccShowHostssScheduledForDeletion) { + $this->ccShowHostssScheduledForDeletion = clone $this->collCcShowHostss; + $this->ccShowHostssScheduledForDeletion->clear(); + } + $this->ccShowHostssScheduledForDeletion[]= clone $ccShowHosts; + $ccShowHosts->setCcSubjs(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcSubjs is new, it will return + * an empty collection; or if this CcSubjs has previously + * been saved, it will retrieve related CcShowHostss 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 CcSubjs. + * + * @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 PropelObjectCollection|CcShowHosts[] List of CcShowHosts objects + */ + public function getCcShowHostssJoinCcShow($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcShowHostsQuery::create(null, $criteria); + $query->joinWith('CcShow', $join_behavior); + + return $this->getCcShowHostss($query, $con); + } + + /** + * 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 CcSubjs The current object (for fluent API support) + * @see addCcPlaylists() + */ + public function clearCcPlaylists() + { + $this->collCcPlaylists = null; // important to set this to null since that means it is uninitialized + $this->collCcPlaylistsPartial = null; + + return $this; + } + + /** + * reset is the collCcPlaylists collection loaded partially + * + * @return void + */ + public function resetPartialCcPlaylists($v = true) + { + $this->collCcPlaylistsPartial = $v; + } + + /** + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcPlaylists($overrideExisting = true) + { + if (null !== $this->collCcPlaylists && !$overrideExisting) { + return; + } + $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 PropelObjectCollection|CcPlaylist[] List of CcPlaylist objects + * @throws PropelException + */ + public function getCcPlaylists($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcPlaylistsPartial && !$this->isNew(); + if (null === $this->collCcPlaylists || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPlaylists) { + // return empty collection + $this->initCcPlaylists(); + } else { + $collCcPlaylists = CcPlaylistQuery::create(null, $criteria) + ->filterByCcSubjs($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcPlaylistsPartial && count($collCcPlaylists)) { + $this->initCcPlaylists(false); + + foreach ($collCcPlaylists as $obj) { + if (false == $this->collCcPlaylists->contains($obj)) { + $this->collCcPlaylists->append($obj); + } + } + + $this->collCcPlaylistsPartial = true; + } + + $collCcPlaylists->getInternalIterator()->rewind(); + + return $collCcPlaylists; + } + + if ($partial && $this->collCcPlaylists) { + foreach ($this->collCcPlaylists as $obj) { + if ($obj->isNew()) { + $collCcPlaylists[] = $obj; + } + } + } + + $this->collCcPlaylists = $collCcPlaylists; + $this->collCcPlaylistsPartial = false; + } + } + + return $this->collCcPlaylists; + } + + /** + * Sets a collection of CcPlaylist objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccPlaylists A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcSubjs The current object (for fluent API support) + */ + public function setCcPlaylists(PropelCollection $ccPlaylists, PropelPDO $con = null) + { + $ccPlaylistsToDelete = $this->getCcPlaylists(new Criteria(), $con)->diff($ccPlaylists); + + + $this->ccPlaylistsScheduledForDeletion = $ccPlaylistsToDelete; + + foreach ($ccPlaylistsToDelete as $ccPlaylistRemoved) { + $ccPlaylistRemoved->setCcSubjs(null); + } + + $this->collCcPlaylists = null; + foreach ($ccPlaylists as $ccPlaylist) { + $this->addCcPlaylist($ccPlaylist); + } + + $this->collCcPlaylists = $ccPlaylists; + $this->collCcPlaylistsPartial = false; + + return $this; + } + + /** + * 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) + { + $partial = $this->collCcPlaylistsPartial && !$this->isNew(); + if (null === $this->collCcPlaylists || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPlaylists) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcPlaylists()); + } + $query = CcPlaylistQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcSubjs($this) + ->count($con); + } + + 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 CcSubjs The current object (for fluent API support) + */ + public function addCcPlaylist(CcPlaylist $l) + { + if ($this->collCcPlaylists === null) { + $this->initCcPlaylists(); + $this->collCcPlaylistsPartial = true; + } + + if (!in_array($l, $this->collCcPlaylists->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcPlaylist($l); + + if ($this->ccPlaylistsScheduledForDeletion and $this->ccPlaylistsScheduledForDeletion->contains($l)) { + $this->ccPlaylistsScheduledForDeletion->remove($this->ccPlaylistsScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcPlaylist $ccPlaylist The ccPlaylist object to add. + */ + protected function doAddCcPlaylist($ccPlaylist) + { + $this->collCcPlaylists[]= $ccPlaylist; + $ccPlaylist->setCcSubjs($this); + } + + /** + * @param CcPlaylist $ccPlaylist The ccPlaylist object to remove. + * @return CcSubjs The current object (for fluent API support) + */ + public function removeCcPlaylist($ccPlaylist) + { + if ($this->getCcPlaylists()->contains($ccPlaylist)) { + $this->collCcPlaylists->remove($this->collCcPlaylists->search($ccPlaylist)); + if (null === $this->ccPlaylistsScheduledForDeletion) { + $this->ccPlaylistsScheduledForDeletion = clone $this->collCcPlaylists; + $this->ccPlaylistsScheduledForDeletion->clear(); + } + $this->ccPlaylistsScheduledForDeletion[]= $ccPlaylist; + $ccPlaylist->setCcSubjs(null); + } + + return $this; + } + + /** + * Clears out the collCcBlocks 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 CcSubjs The current object (for fluent API support) + * @see addCcBlocks() + */ + public function clearCcBlocks() + { + $this->collCcBlocks = null; // important to set this to null since that means it is uninitialized + $this->collCcBlocksPartial = null; + + return $this; + } + + /** + * reset is the collCcBlocks collection loaded partially + * + * @return void + */ + public function resetPartialCcBlocks($v = true) + { + $this->collCcBlocksPartial = $v; + } + + /** + * Initializes the collCcBlocks collection. + * + * By default this just sets the collCcBlocks collection to an empty array (like clearcollCcBlocks()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcBlocks($overrideExisting = true) + { + if (null !== $this->collCcBlocks && !$overrideExisting) { + return; + } + $this->collCcBlocks = new PropelObjectCollection(); + $this->collCcBlocks->setModel('CcBlock'); + } + + /** + * Gets an array of CcBlock 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 PropelObjectCollection|CcBlock[] List of CcBlock objects + * @throws PropelException + */ + public function getCcBlocks($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcBlocksPartial && !$this->isNew(); + if (null === $this->collCcBlocks || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcBlocks) { + // return empty collection + $this->initCcBlocks(); + } else { + $collCcBlocks = CcBlockQuery::create(null, $criteria) + ->filterByCcSubjs($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcBlocksPartial && count($collCcBlocks)) { + $this->initCcBlocks(false); + + foreach ($collCcBlocks as $obj) { + if (false == $this->collCcBlocks->contains($obj)) { + $this->collCcBlocks->append($obj); + } + } + + $this->collCcBlocksPartial = true; + } + + $collCcBlocks->getInternalIterator()->rewind(); + + return $collCcBlocks; + } + + if ($partial && $this->collCcBlocks) { + foreach ($this->collCcBlocks as $obj) { + if ($obj->isNew()) { + $collCcBlocks[] = $obj; + } + } + } + + $this->collCcBlocks = $collCcBlocks; + $this->collCcBlocksPartial = false; + } + } + + return $this->collCcBlocks; + } + + /** + * Sets a collection of CcBlock objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccBlocks A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcSubjs The current object (for fluent API support) + */ + public function setCcBlocks(PropelCollection $ccBlocks, PropelPDO $con = null) + { + $ccBlocksToDelete = $this->getCcBlocks(new Criteria(), $con)->diff($ccBlocks); + + + $this->ccBlocksScheduledForDeletion = $ccBlocksToDelete; + + foreach ($ccBlocksToDelete as $ccBlockRemoved) { + $ccBlockRemoved->setCcSubjs(null); + } + + $this->collCcBlocks = null; + foreach ($ccBlocks as $ccBlock) { + $this->addCcBlock($ccBlock); + } + + $this->collCcBlocks = $ccBlocks; + $this->collCcBlocksPartial = false; + + return $this; + } + + /** + * Returns the number of related CcBlock objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcBlock objects. + * @throws PropelException + */ + public function countCcBlocks(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcBlocksPartial && !$this->isNew(); + if (null === $this->collCcBlocks || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcBlocks) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcBlocks()); + } + $query = CcBlockQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcSubjs($this) + ->count($con); + } + + return count($this->collCcBlocks); + } + + /** + * Method called to associate a CcBlock object to this object + * through the CcBlock foreign key attribute. + * + * @param CcBlock $l CcBlock + * @return CcSubjs The current object (for fluent API support) + */ + public function addCcBlock(CcBlock $l) + { + if ($this->collCcBlocks === null) { + $this->initCcBlocks(); + $this->collCcBlocksPartial = true; + } + + if (!in_array($l, $this->collCcBlocks->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcBlock($l); + + if ($this->ccBlocksScheduledForDeletion and $this->ccBlocksScheduledForDeletion->contains($l)) { + $this->ccBlocksScheduledForDeletion->remove($this->ccBlocksScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcBlock $ccBlock The ccBlock object to add. + */ + protected function doAddCcBlock($ccBlock) + { + $this->collCcBlocks[]= $ccBlock; + $ccBlock->setCcSubjs($this); + } + + /** + * @param CcBlock $ccBlock The ccBlock object to remove. + * @return CcSubjs The current object (for fluent API support) + */ + public function removeCcBlock($ccBlock) + { + if ($this->getCcBlocks()->contains($ccBlock)) { + $this->collCcBlocks->remove($this->collCcBlocks->search($ccBlock)); + if (null === $this->ccBlocksScheduledForDeletion) { + $this->ccBlocksScheduledForDeletion = clone $this->collCcBlocks; + $this->ccBlocksScheduledForDeletion->clear(); + } + $this->ccBlocksScheduledForDeletion[]= $ccBlock; + $ccBlock->setCcSubjs(null); + } + + return $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 CcSubjs The current object (for fluent API support) + * @see addCcPrefs() + */ + public function clearCcPrefs() + { + $this->collCcPrefs = null; // important to set this to null since that means it is uninitialized + $this->collCcPrefsPartial = null; + + return $this; + } + + /** + * reset is the collCcPrefs collection loaded partially + * + * @return void + */ + public function resetPartialCcPrefs($v = true) + { + $this->collCcPrefsPartial = $v; + } + + /** + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcPrefs($overrideExisting = true) + { + if (null !== $this->collCcPrefs && !$overrideExisting) { + return; + } + $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 PropelObjectCollection|CcPref[] List of CcPref objects + * @throws PropelException + */ + public function getCcPrefs($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcPrefsPartial && !$this->isNew(); + if (null === $this->collCcPrefs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPrefs) { + // return empty collection + $this->initCcPrefs(); + } else { + $collCcPrefs = CcPrefQuery::create(null, $criteria) + ->filterByCcSubjs($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcPrefsPartial && count($collCcPrefs)) { + $this->initCcPrefs(false); + + foreach ($collCcPrefs as $obj) { + if (false == $this->collCcPrefs->contains($obj)) { + $this->collCcPrefs->append($obj); + } + } + + $this->collCcPrefsPartial = true; + } + + $collCcPrefs->getInternalIterator()->rewind(); + + return $collCcPrefs; + } + + if ($partial && $this->collCcPrefs) { + foreach ($this->collCcPrefs as $obj) { + if ($obj->isNew()) { + $collCcPrefs[] = $obj; + } + } + } + + $this->collCcPrefs = $collCcPrefs; + $this->collCcPrefsPartial = false; + } + } + + return $this->collCcPrefs; + } + + /** + * Sets a collection of CcPref objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccPrefs A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcSubjs The current object (for fluent API support) + */ + public function setCcPrefs(PropelCollection $ccPrefs, PropelPDO $con = null) + { + $ccPrefsToDelete = $this->getCcPrefs(new Criteria(), $con)->diff($ccPrefs); + + + $this->ccPrefsScheduledForDeletion = $ccPrefsToDelete; + + foreach ($ccPrefsToDelete as $ccPrefRemoved) { + $ccPrefRemoved->setCcSubjs(null); + } + + $this->collCcPrefs = null; + foreach ($ccPrefs as $ccPref) { + $this->addCcPref($ccPref); + } + + $this->collCcPrefs = $ccPrefs; + $this->collCcPrefsPartial = false; + + return $this; + } + + /** + * 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) + { + $partial = $this->collCcPrefsPartial && !$this->isNew(); + if (null === $this->collCcPrefs || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcPrefs) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcPrefs()); + } + $query = CcPrefQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcSubjs($this) + ->count($con); + } + + 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 CcSubjs The current object (for fluent API support) + */ + public function addCcPref(CcPref $l) + { + if ($this->collCcPrefs === null) { + $this->initCcPrefs(); + $this->collCcPrefsPartial = true; + } + + if (!in_array($l, $this->collCcPrefs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcPref($l); + + if ($this->ccPrefsScheduledForDeletion and $this->ccPrefsScheduledForDeletion->contains($l)) { + $this->ccPrefsScheduledForDeletion->remove($this->ccPrefsScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcPref $ccPref The ccPref object to add. + */ + protected function doAddCcPref($ccPref) + { + $this->collCcPrefs[]= $ccPref; + $ccPref->setCcSubjs($this); + } + + /** + * @param CcPref $ccPref The ccPref object to remove. + * @return CcSubjs The current object (for fluent API support) + */ + public function removeCcPref($ccPref) + { + if ($this->getCcPrefs()->contains($ccPref)) { + $this->collCcPrefs->remove($this->collCcPrefs->search($ccPref)); + if (null === $this->ccPrefsScheduledForDeletion) { + $this->ccPrefsScheduledForDeletion = clone $this->collCcPrefs; + $this->ccPrefsScheduledForDeletion->clear(); + } + $this->ccPrefsScheduledForDeletion[]= $ccPref; + $ccPref->setCcSubjs(null); + } + + return $this; + } + + /** + * Clears out the collCcSubjsTokens 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 CcSubjs The current object (for fluent API support) + * @see addCcSubjsTokens() + */ + public function clearCcSubjsTokens() + { + $this->collCcSubjsTokens = null; // important to set this to null since that means it is uninitialized + $this->collCcSubjsTokensPartial = null; + + return $this; + } + + /** + * reset is the collCcSubjsTokens collection loaded partially + * + * @return void + */ + public function resetPartialCcSubjsTokens($v = true) + { + $this->collCcSubjsTokensPartial = $v; + } + + /** + * Initializes the collCcSubjsTokens collection. + * + * By default this just sets the collCcSubjsTokens collection to an empty array (like clearcollCcSubjsTokens()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcSubjsTokens($overrideExisting = true) + { + if (null !== $this->collCcSubjsTokens && !$overrideExisting) { + return; + } + $this->collCcSubjsTokens = new PropelObjectCollection(); + $this->collCcSubjsTokens->setModel('CcSubjsToken'); + } + + /** + * Gets an array of CcSubjsToken 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 PropelObjectCollection|CcSubjsToken[] List of CcSubjsToken objects + * @throws PropelException + */ + public function getCcSubjsTokens($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcSubjsTokensPartial && !$this->isNew(); + if (null === $this->collCcSubjsTokens || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcSubjsTokens) { + // return empty collection + $this->initCcSubjsTokens(); + } else { + $collCcSubjsTokens = CcSubjsTokenQuery::create(null, $criteria) + ->filterByCcSubjs($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcSubjsTokensPartial && count($collCcSubjsTokens)) { + $this->initCcSubjsTokens(false); + + foreach ($collCcSubjsTokens as $obj) { + if (false == $this->collCcSubjsTokens->contains($obj)) { + $this->collCcSubjsTokens->append($obj); + } + } + + $this->collCcSubjsTokensPartial = true; + } + + $collCcSubjsTokens->getInternalIterator()->rewind(); + + return $collCcSubjsTokens; + } + + if ($partial && $this->collCcSubjsTokens) { + foreach ($this->collCcSubjsTokens as $obj) { + if ($obj->isNew()) { + $collCcSubjsTokens[] = $obj; + } + } + } + + $this->collCcSubjsTokens = $collCcSubjsTokens; + $this->collCcSubjsTokensPartial = false; + } + } + + return $this->collCcSubjsTokens; + } + + /** + * Sets a collection of CcSubjsToken objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccSubjsTokens A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcSubjs The current object (for fluent API support) + */ + public function setCcSubjsTokens(PropelCollection $ccSubjsTokens, PropelPDO $con = null) + { + $ccSubjsTokensToDelete = $this->getCcSubjsTokens(new Criteria(), $con)->diff($ccSubjsTokens); + + + $this->ccSubjsTokensScheduledForDeletion = $ccSubjsTokensToDelete; + + foreach ($ccSubjsTokensToDelete as $ccSubjsTokenRemoved) { + $ccSubjsTokenRemoved->setCcSubjs(null); + } + + $this->collCcSubjsTokens = null; + foreach ($ccSubjsTokens as $ccSubjsToken) { + $this->addCcSubjsToken($ccSubjsToken); + } + + $this->collCcSubjsTokens = $ccSubjsTokens; + $this->collCcSubjsTokensPartial = false; + + return $this; + } + + /** + * Returns the number of related CcSubjsToken objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcSubjsToken objects. + * @throws PropelException + */ + public function countCcSubjsTokens(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcSubjsTokensPartial && !$this->isNew(); + if (null === $this->collCcSubjsTokens || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcSubjsTokens) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcSubjsTokens()); + } + $query = CcSubjsTokenQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcSubjs($this) + ->count($con); + } + + return count($this->collCcSubjsTokens); + } + + /** + * Method called to associate a CcSubjsToken object to this object + * through the CcSubjsToken foreign key attribute. + * + * @param CcSubjsToken $l CcSubjsToken + * @return CcSubjs The current object (for fluent API support) + */ + public function addCcSubjsToken(CcSubjsToken $l) + { + if ($this->collCcSubjsTokens === null) { + $this->initCcSubjsTokens(); + $this->collCcSubjsTokensPartial = true; + } + + if (!in_array($l, $this->collCcSubjsTokens->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcSubjsToken($l); + + if ($this->ccSubjsTokensScheduledForDeletion and $this->ccSubjsTokensScheduledForDeletion->contains($l)) { + $this->ccSubjsTokensScheduledForDeletion->remove($this->ccSubjsTokensScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcSubjsToken $ccSubjsToken The ccSubjsToken object to add. + */ + protected function doAddCcSubjsToken($ccSubjsToken) + { + $this->collCcSubjsTokens[]= $ccSubjsToken; + $ccSubjsToken->setCcSubjs($this); + } + + /** + * @param CcSubjsToken $ccSubjsToken The ccSubjsToken object to remove. + * @return CcSubjs The current object (for fluent API support) + */ + public function removeCcSubjsToken($ccSubjsToken) + { + if ($this->getCcSubjsTokens()->contains($ccSubjsToken)) { + $this->collCcSubjsTokens->remove($this->collCcSubjsTokens->search($ccSubjsToken)); + if (null === $this->ccSubjsTokensScheduledForDeletion) { + $this->ccSubjsTokensScheduledForDeletion = clone $this->collCcSubjsTokens; + $this->ccSubjsTokensScheduledForDeletion->clear(); + } + $this->ccSubjsTokensScheduledForDeletion[]= clone $ccSubjsToken; + $ccSubjsToken->setCcSubjs(null); + } + + return $this; + } + + /** + * Clears out the collMediaItems 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 CcSubjs The current object (for fluent API support) + * @see addMediaItems() + */ + public function clearMediaItems() + { + $this->collMediaItems = null; // important to set this to null since that means it is uninitialized + $this->collMediaItemsPartial = null; + + return $this; + } + + /** + * reset is the collMediaItems collection loaded partially + * + * @return void + */ + public function resetPartialMediaItems($v = true) + { + $this->collMediaItemsPartial = $v; + } + + /** + * Initializes the collMediaItems collection. + * + * By default this just sets the collMediaItems collection to an empty array (like clearcollMediaItems()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initMediaItems($overrideExisting = true) + { + if (null !== $this->collMediaItems && !$overrideExisting) { + return; + } + $this->collMediaItems = new PropelObjectCollection(); + $this->collMediaItems->setModel('MediaItem'); + } + + /** + * Gets an array of MediaItem 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 PropelObjectCollection|MediaItem[] List of MediaItem objects + * @throws PropelException + */ + public function getMediaItems($criteria = null, PropelPDO $con = null) + { + $partial = $this->collMediaItemsPartial && !$this->isNew(); + if (null === $this->collMediaItems || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collMediaItems) { + // return empty collection + $this->initMediaItems(); + } else { + $collMediaItems = MediaItemQuery::create(null, $criteria) + ->filterByCcSubjs($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collMediaItemsPartial && count($collMediaItems)) { + $this->initMediaItems(false); + + foreach ($collMediaItems as $obj) { + if (false == $this->collMediaItems->contains($obj)) { + $this->collMediaItems->append($obj); + } + } + + $this->collMediaItemsPartial = true; + } + + $collMediaItems->getInternalIterator()->rewind(); + + return $collMediaItems; + } + + if ($partial && $this->collMediaItems) { + foreach ($this->collMediaItems as $obj) { + if ($obj->isNew()) { + $collMediaItems[] = $obj; + } + } + } + + $this->collMediaItems = $collMediaItems; + $this->collMediaItemsPartial = false; + } + } + + return $this->collMediaItems; + } + + /** + * Sets a collection of MediaItem objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $mediaItems A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcSubjs The current object (for fluent API support) + */ + public function setMediaItems(PropelCollection $mediaItems, PropelPDO $con = null) + { + $mediaItemsToDelete = $this->getMediaItems(new Criteria(), $con)->diff($mediaItems); + + + $this->mediaItemsScheduledForDeletion = $mediaItemsToDelete; + + foreach ($mediaItemsToDelete as $mediaItemRemoved) { + $mediaItemRemoved->setCcSubjs(null); + } + + $this->collMediaItems = null; + foreach ($mediaItems as $mediaItem) { + $this->addMediaItem($mediaItem); + } + + $this->collMediaItems = $mediaItems; + $this->collMediaItemsPartial = false; + + return $this; + } + + /** + * Returns the number of related MediaItem objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related MediaItem objects. + * @throws PropelException + */ + public function countMediaItems(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collMediaItemsPartial && !$this->isNew(); + if (null === $this->collMediaItems || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collMediaItems) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getMediaItems()); + } + $query = MediaItemQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcSubjs($this) + ->count($con); + } + + return count($this->collMediaItems); + } + + /** + * Method called to associate a MediaItem object to this object + * through the MediaItem foreign key attribute. + * + * @param MediaItem $l MediaItem + * @return CcSubjs The current object (for fluent API support) + */ + public function addMediaItem(MediaItem $l) + { + if ($this->collMediaItems === null) { + $this->initMediaItems(); + $this->collMediaItemsPartial = true; + } + + if (!in_array($l, $this->collMediaItems->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddMediaItem($l); + + if ($this->mediaItemsScheduledForDeletion and $this->mediaItemsScheduledForDeletion->contains($l)) { + $this->mediaItemsScheduledForDeletion->remove($this->mediaItemsScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param MediaItem $mediaItem The mediaItem object to add. + */ + protected function doAddMediaItem($mediaItem) + { + $this->collMediaItems[]= $mediaItem; + $mediaItem->setCcSubjs($this); + } + + /** + * @param MediaItem $mediaItem The mediaItem object to remove. + * @return CcSubjs The current object (for fluent API support) + */ + public function removeMediaItem($mediaItem) + { + if ($this->getMediaItems()->contains($mediaItem)) { + $this->collMediaItems->remove($this->collMediaItems->search($mediaItem)); + if (null === $this->mediaItemsScheduledForDeletion) { + $this->mediaItemsScheduledForDeletion = clone $this->collMediaItems; + $this->mediaItemsScheduledForDeletion->clear(); + } + $this->mediaItemsScheduledForDeletion[]= $mediaItem; + $mediaItem->setCcSubjs(null); + } + + return $this; + } + + /** + * Clears out the collAudioFiles 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 CcSubjs The current object (for fluent API support) + * @see addAudioFiles() + */ + public function clearAudioFiles() + { + $this->collAudioFiles = null; // important to set this to null since that means it is uninitialized + $this->collAudioFilesPartial = null; + + return $this; + } + + /** + * reset is the collAudioFiles collection loaded partially + * + * @return void + */ + public function resetPartialAudioFiles($v = true) + { + $this->collAudioFilesPartial = $v; + } + + /** + * Initializes the collAudioFiles collection. + * + * By default this just sets the collAudioFiles collection to an empty array (like clearcollAudioFiles()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initAudioFiles($overrideExisting = true) + { + if (null !== $this->collAudioFiles && !$overrideExisting) { + return; + } + $this->collAudioFiles = new PropelObjectCollection(); + $this->collAudioFiles->setModel('AudioFile'); + } + + /** + * Gets an array of AudioFile 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 PropelObjectCollection|AudioFile[] List of AudioFile objects + * @throws PropelException + */ + public function getAudioFiles($criteria = null, PropelPDO $con = null) + { + $partial = $this->collAudioFilesPartial && !$this->isNew(); + if (null === $this->collAudioFiles || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAudioFiles) { + // return empty collection + $this->initAudioFiles(); + } else { + $collAudioFiles = AudioFileQuery::create(null, $criteria) + ->filterByCcSubjs($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collAudioFilesPartial && count($collAudioFiles)) { + $this->initAudioFiles(false); + + foreach ($collAudioFiles as $obj) { + if (false == $this->collAudioFiles->contains($obj)) { + $this->collAudioFiles->append($obj); + } + } + + $this->collAudioFilesPartial = true; + } + + $collAudioFiles->getInternalIterator()->rewind(); + + return $collAudioFiles; + } + + if ($partial && $this->collAudioFiles) { + foreach ($this->collAudioFiles as $obj) { + if ($obj->isNew()) { + $collAudioFiles[] = $obj; + } + } + } + + $this->collAudioFiles = $collAudioFiles; + $this->collAudioFilesPartial = false; + } + } + + return $this->collAudioFiles; + } + + /** + * Sets a collection of AudioFile objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $audioFiles A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcSubjs The current object (for fluent API support) + */ + public function setAudioFiles(PropelCollection $audioFiles, PropelPDO $con = null) + { + $audioFilesToDelete = $this->getAudioFiles(new Criteria(), $con)->diff($audioFiles); + + + $this->audioFilesScheduledForDeletion = $audioFilesToDelete; + + foreach ($audioFilesToDelete as $audioFileRemoved) { + $audioFileRemoved->setCcSubjs(null); + } + + $this->collAudioFiles = null; + foreach ($audioFiles as $audioFile) { + $this->addAudioFile($audioFile); + } + + $this->collAudioFiles = $audioFiles; + $this->collAudioFilesPartial = false; + + return $this; + } + + /** + * Returns the number of related AudioFile objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related AudioFile objects. + * @throws PropelException + */ + public function countAudioFiles(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collAudioFilesPartial && !$this->isNew(); + if (null === $this->collAudioFiles || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAudioFiles) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getAudioFiles()); + } + $query = AudioFileQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcSubjs($this) + ->count($con); + } + + return count($this->collAudioFiles); + } + + /** + * Method called to associate a AudioFile object to this object + * through the AudioFile foreign key attribute. + * + * @param AudioFile $l AudioFile + * @return CcSubjs The current object (for fluent API support) + */ + public function addAudioFile(AudioFile $l) + { + if ($this->collAudioFiles === null) { + $this->initAudioFiles(); + $this->collAudioFilesPartial = true; + } + + if (!in_array($l, $this->collAudioFiles->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddAudioFile($l); + + if ($this->audioFilesScheduledForDeletion and $this->audioFilesScheduledForDeletion->contains($l)) { + $this->audioFilesScheduledForDeletion->remove($this->audioFilesScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param AudioFile $audioFile The audioFile object to add. + */ + protected function doAddAudioFile($audioFile) + { + $this->collAudioFiles[]= $audioFile; + $audioFile->setCcSubjs($this); + } + + /** + * @param AudioFile $audioFile The audioFile object to remove. + * @return CcSubjs The current object (for fluent API support) + */ + public function removeAudioFile($audioFile) + { + if ($this->getAudioFiles()->contains($audioFile)) { + $this->collAudioFiles->remove($this->collAudioFiles->search($audioFile)); + if (null === $this->audioFilesScheduledForDeletion) { + $this->audioFilesScheduledForDeletion = clone $this->collAudioFiles; + $this->audioFilesScheduledForDeletion->clear(); + } + $this->audioFilesScheduledForDeletion[]= $audioFile; + $audioFile->setCcSubjs(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcSubjs is new, it will return + * an empty collection; or if this CcSubjs has previously + * been saved, it will retrieve related AudioFiles 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 CcSubjs. + * + * @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 PropelObjectCollection|AudioFile[] List of AudioFile objects + */ + public function getAudioFilesJoinCcMusicDirs($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = AudioFileQuery::create(null, $criteria); + $query->joinWith('CcMusicDirs', $join_behavior); + + return $this->getAudioFiles($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcSubjs is new, it will return + * an empty collection; or if this CcSubjs has previously + * been saved, it will retrieve related AudioFiles 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 CcSubjs. + * + * @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 PropelObjectCollection|AudioFile[] List of AudioFile objects + */ + public function getAudioFilesJoinMediaItem($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = AudioFileQuery::create(null, $criteria); + $query->joinWith('MediaItem', $join_behavior); + + return $this->getAudioFiles($query, $con); + } + + /** + * Clears out the collWebstreams 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 CcSubjs The current object (for fluent API support) + * @see addWebstreams() + */ + public function clearWebstreams() + { + $this->collWebstreams = null; // important to set this to null since that means it is uninitialized + $this->collWebstreamsPartial = null; + + return $this; + } + + /** + * reset is the collWebstreams collection loaded partially + * + * @return void + */ + public function resetPartialWebstreams($v = true) + { + $this->collWebstreamsPartial = $v; + } + + /** + * Initializes the collWebstreams collection. + * + * By default this just sets the collWebstreams collection to an empty array (like clearcollWebstreams()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initWebstreams($overrideExisting = true) + { + if (null !== $this->collWebstreams && !$overrideExisting) { + return; + } + $this->collWebstreams = new PropelObjectCollection(); + $this->collWebstreams->setModel('Webstream'); + } + + /** + * Gets an array of Webstream 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 PropelObjectCollection|Webstream[] List of Webstream objects + * @throws PropelException + */ + public function getWebstreams($criteria = null, PropelPDO $con = null) + { + $partial = $this->collWebstreamsPartial && !$this->isNew(); + if (null === $this->collWebstreams || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collWebstreams) { + // return empty collection + $this->initWebstreams(); + } else { + $collWebstreams = WebstreamQuery::create(null, $criteria) + ->filterByCcSubjs($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collWebstreamsPartial && count($collWebstreams)) { + $this->initWebstreams(false); + + foreach ($collWebstreams as $obj) { + if (false == $this->collWebstreams->contains($obj)) { + $this->collWebstreams->append($obj); + } + } + + $this->collWebstreamsPartial = true; + } + + $collWebstreams->getInternalIterator()->rewind(); + + return $collWebstreams; + } + + if ($partial && $this->collWebstreams) { + foreach ($this->collWebstreams as $obj) { + if ($obj->isNew()) { + $collWebstreams[] = $obj; + } + } + } + + $this->collWebstreams = $collWebstreams; + $this->collWebstreamsPartial = false; + } + } + + return $this->collWebstreams; + } + + /** + * Sets a collection of Webstream objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $webstreams A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcSubjs The current object (for fluent API support) + */ + public function setWebstreams(PropelCollection $webstreams, PropelPDO $con = null) + { + $webstreamsToDelete = $this->getWebstreams(new Criteria(), $con)->diff($webstreams); + + + $this->webstreamsScheduledForDeletion = $webstreamsToDelete; + + foreach ($webstreamsToDelete as $webstreamRemoved) { + $webstreamRemoved->setCcSubjs(null); + } + + $this->collWebstreams = null; + foreach ($webstreams as $webstream) { + $this->addWebstream($webstream); + } + + $this->collWebstreams = $webstreams; + $this->collWebstreamsPartial = false; + + return $this; + } + + /** + * Returns the number of related Webstream objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related Webstream objects. + * @throws PropelException + */ + public function countWebstreams(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collWebstreamsPartial && !$this->isNew(); + if (null === $this->collWebstreams || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collWebstreams) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getWebstreams()); + } + $query = WebstreamQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcSubjs($this) + ->count($con); + } + + return count($this->collWebstreams); + } + + /** + * Method called to associate a Webstream object to this object + * through the Webstream foreign key attribute. + * + * @param Webstream $l Webstream + * @return CcSubjs The current object (for fluent API support) + */ + public function addWebstream(Webstream $l) + { + if ($this->collWebstreams === null) { + $this->initWebstreams(); + $this->collWebstreamsPartial = true; + } + + if (!in_array($l, $this->collWebstreams->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddWebstream($l); + + if ($this->webstreamsScheduledForDeletion and $this->webstreamsScheduledForDeletion->contains($l)) { + $this->webstreamsScheduledForDeletion->remove($this->webstreamsScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param Webstream $webstream The webstream object to add. + */ + protected function doAddWebstream($webstream) + { + $this->collWebstreams[]= $webstream; + $webstream->setCcSubjs($this); + } + + /** + * @param Webstream $webstream The webstream object to remove. + * @return CcSubjs The current object (for fluent API support) + */ + public function removeWebstream($webstream) + { + if ($this->getWebstreams()->contains($webstream)) { + $this->collWebstreams->remove($this->collWebstreams->search($webstream)); + if (null === $this->webstreamsScheduledForDeletion) { + $this->webstreamsScheduledForDeletion = clone $this->collWebstreams; + $this->webstreamsScheduledForDeletion->clear(); + } + $this->webstreamsScheduledForDeletion[]= $webstream; + $webstream->setCcSubjs(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcSubjs is new, it will return + * an empty collection; or if this CcSubjs has previously + * been saved, it will retrieve related Webstreams 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 CcSubjs. + * + * @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 PropelObjectCollection|Webstream[] List of Webstream objects + */ + public function getWebstreamsJoinMediaItem($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = WebstreamQuery::create(null, $criteria); + $query->joinWith('MediaItem', $join_behavior); + + return $this->getWebstreams($query, $con); + } + + /** + * Clears out the collPlaylists 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 CcSubjs The current object (for fluent API support) + * @see addPlaylists() + */ + public function clearPlaylists() + { + $this->collPlaylists = null; // important to set this to null since that means it is uninitialized + $this->collPlaylistsPartial = null; + + return $this; + } + + /** + * reset is the collPlaylists collection loaded partially + * + * @return void + */ + public function resetPartialPlaylists($v = true) + { + $this->collPlaylistsPartial = $v; + } + + /** + * Initializes the collPlaylists collection. + * + * By default this just sets the collPlaylists collection to an empty array (like clearcollPlaylists()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initPlaylists($overrideExisting = true) + { + if (null !== $this->collPlaylists && !$overrideExisting) { + return; + } + $this->collPlaylists = new PropelObjectCollection(); + $this->collPlaylists->setModel('Playlist'); + } + + /** + * Gets an array of Playlist 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 PropelObjectCollection|Playlist[] List of Playlist objects + * @throws PropelException + */ + public function getPlaylists($criteria = null, PropelPDO $con = null) + { + $partial = $this->collPlaylistsPartial && !$this->isNew(); + if (null === $this->collPlaylists || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collPlaylists) { + // return empty collection + $this->initPlaylists(); + } else { + $collPlaylists = PlaylistQuery::create(null, $criteria) + ->filterByCcSubjs($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collPlaylistsPartial && count($collPlaylists)) { + $this->initPlaylists(false); + + foreach ($collPlaylists as $obj) { + if (false == $this->collPlaylists->contains($obj)) { + $this->collPlaylists->append($obj); + } + } + + $this->collPlaylistsPartial = true; + } + + $collPlaylists->getInternalIterator()->rewind(); + + return $collPlaylists; + } + + if ($partial && $this->collPlaylists) { + foreach ($this->collPlaylists as $obj) { + if ($obj->isNew()) { + $collPlaylists[] = $obj; + } + } + } + + $this->collPlaylists = $collPlaylists; + $this->collPlaylistsPartial = false; + } + } + + return $this->collPlaylists; + } + + /** + * Sets a collection of Playlist objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $playlists A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcSubjs The current object (for fluent API support) + */ + public function setPlaylists(PropelCollection $playlists, PropelPDO $con = null) + { + $playlistsToDelete = $this->getPlaylists(new Criteria(), $con)->diff($playlists); + + + $this->playlistsScheduledForDeletion = $playlistsToDelete; + + foreach ($playlistsToDelete as $playlistRemoved) { + $playlistRemoved->setCcSubjs(null); + } + + $this->collPlaylists = null; + foreach ($playlists as $playlist) { + $this->addPlaylist($playlist); + } + + $this->collPlaylists = $playlists; + $this->collPlaylistsPartial = false; + + return $this; + } + + /** + * Returns the number of related Playlist objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related Playlist objects. + * @throws PropelException + */ + public function countPlaylists(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collPlaylistsPartial && !$this->isNew(); + if (null === $this->collPlaylists || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collPlaylists) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getPlaylists()); + } + $query = PlaylistQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcSubjs($this) + ->count($con); + } + + return count($this->collPlaylists); + } + + /** + * Method called to associate a Playlist object to this object + * through the Playlist foreign key attribute. + * + * @param Playlist $l Playlist + * @return CcSubjs The current object (for fluent API support) + */ + public function addPlaylist(Playlist $l) + { + if ($this->collPlaylists === null) { + $this->initPlaylists(); + $this->collPlaylistsPartial = true; + } + + if (!in_array($l, $this->collPlaylists->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddPlaylist($l); + + if ($this->playlistsScheduledForDeletion and $this->playlistsScheduledForDeletion->contains($l)) { + $this->playlistsScheduledForDeletion->remove($this->playlistsScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param Playlist $playlist The playlist object to add. + */ + protected function doAddPlaylist($playlist) + { + $this->collPlaylists[]= $playlist; + $playlist->setCcSubjs($this); + } + + /** + * @param Playlist $playlist The playlist object to remove. + * @return CcSubjs The current object (for fluent API support) + */ + public function removePlaylist($playlist) + { + if ($this->getPlaylists()->contains($playlist)) { + $this->collPlaylists->remove($this->collPlaylists->search($playlist)); + if (null === $this->playlistsScheduledForDeletion) { + $this->playlistsScheduledForDeletion = clone $this->collPlaylists; + $this->playlistsScheduledForDeletion->clear(); + } + $this->playlistsScheduledForDeletion[]= $playlist; + $playlist->setCcSubjs(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcSubjs is new, it will return + * an empty collection; or if this CcSubjs has previously + * been saved, it will retrieve related Playlists 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 CcSubjs. + * + * @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 PropelObjectCollection|Playlist[] List of Playlist objects + */ + public function getPlaylistsJoinMediaItem($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = PlaylistQuery::create(null, $criteria); + $query->joinWith('MediaItem', $join_behavior); + + return $this->getPlaylists($query, $con); + } + + /** + * Clears out the collBlocks 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 CcSubjs The current object (for fluent API support) + * @see addBlocks() + */ + public function clearBlocks() + { + $this->collBlocks = null; // important to set this to null since that means it is uninitialized + $this->collBlocksPartial = null; + + return $this; + } + + /** + * reset is the collBlocks collection loaded partially + * + * @return void + */ + public function resetPartialBlocks($v = true) + { + $this->collBlocksPartial = $v; + } + + /** + * Initializes the collBlocks collection. + * + * By default this just sets the collBlocks collection to an empty array (like clearcollBlocks()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initBlocks($overrideExisting = true) + { + if (null !== $this->collBlocks && !$overrideExisting) { + return; + } + $this->collBlocks = new PropelObjectCollection(); + $this->collBlocks->setModel('Block'); + } + + /** + * Gets an array of Block 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 PropelObjectCollection|Block[] List of Block objects + * @throws PropelException + */ + public function getBlocks($criteria = null, PropelPDO $con = null) + { + $partial = $this->collBlocksPartial && !$this->isNew(); + if (null === $this->collBlocks || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collBlocks) { + // return empty collection + $this->initBlocks(); + } else { + $collBlocks = BlockQuery::create(null, $criteria) + ->filterByCcSubjs($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collBlocksPartial && count($collBlocks)) { + $this->initBlocks(false); + + foreach ($collBlocks as $obj) { + if (false == $this->collBlocks->contains($obj)) { + $this->collBlocks->append($obj); + } + } + + $this->collBlocksPartial = true; + } + + $collBlocks->getInternalIterator()->rewind(); + + return $collBlocks; + } + + if ($partial && $this->collBlocks) { + foreach ($this->collBlocks as $obj) { + if ($obj->isNew()) { + $collBlocks[] = $obj; + } + } + } + + $this->collBlocks = $collBlocks; + $this->collBlocksPartial = false; + } + } + + return $this->collBlocks; + } + + /** + * Sets a collection of Block objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $blocks A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcSubjs The current object (for fluent API support) + */ + public function setBlocks(PropelCollection $blocks, PropelPDO $con = null) + { + $blocksToDelete = $this->getBlocks(new Criteria(), $con)->diff($blocks); + + + $this->blocksScheduledForDeletion = $blocksToDelete; + + foreach ($blocksToDelete as $blockRemoved) { + $blockRemoved->setCcSubjs(null); + } + + $this->collBlocks = null; + foreach ($blocks as $block) { + $this->addBlock($block); + } + + $this->collBlocks = $blocks; + $this->collBlocksPartial = false; + + return $this; + } + + /** + * Returns the number of related Block objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related Block objects. + * @throws PropelException + */ + public function countBlocks(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collBlocksPartial && !$this->isNew(); + if (null === $this->collBlocks || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collBlocks) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getBlocks()); + } + $query = BlockQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcSubjs($this) + ->count($con); + } + + return count($this->collBlocks); + } + + /** + * Method called to associate a Block object to this object + * through the Block foreign key attribute. + * + * @param Block $l Block + * @return CcSubjs The current object (for fluent API support) + */ + public function addBlock(Block $l) + { + if ($this->collBlocks === null) { + $this->initBlocks(); + $this->collBlocksPartial = true; + } + + if (!in_array($l, $this->collBlocks->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddBlock($l); + + if ($this->blocksScheduledForDeletion and $this->blocksScheduledForDeletion->contains($l)) { + $this->blocksScheduledForDeletion->remove($this->blocksScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param Block $block The block object to add. + */ + protected function doAddBlock($block) + { + $this->collBlocks[]= $block; + $block->setCcSubjs($this); + } + + /** + * @param Block $block The block object to remove. + * @return CcSubjs The current object (for fluent API support) + */ + public function removeBlock($block) + { + if ($this->getBlocks()->contains($block)) { + $this->collBlocks->remove($this->collBlocks->search($block)); + if (null === $this->blocksScheduledForDeletion) { + $this->blocksScheduledForDeletion = clone $this->collBlocks; + $this->blocksScheduledForDeletion->clear(); + } + $this->blocksScheduledForDeletion[]= $block; + $block->setCcSubjs(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcSubjs is new, it will return + * an empty collection; or if this CcSubjs has previously + * been saved, it will retrieve related Blocks 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 CcSubjs. + * + * @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 PropelObjectCollection|Block[] List of Block objects + */ + public function getBlocksJoinPlaylist($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = BlockQuery::create(null, $criteria); + $query->joinWith('Playlist', $join_behavior); + + return $this->getBlocks($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcSubjs is new, it will return + * an empty collection; or if this CcSubjs has previously + * been saved, it will retrieve related Blocks 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 CcSubjs. + * + * @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 PropelObjectCollection|Block[] List of Block objects + */ + public function getBlocksJoinMediaItem($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = BlockQuery::create(null, $criteria); + $query->joinWith('MediaItem', $join_behavior); + + return $this->getBlocks($query, $con); + } + + /** + * 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->first_name = null; + $this->last_name = null; + $this->lastlogin = null; + $this->lastfail = null; + $this->skype_contact = null; + $this->jabber_contact = null; + $this->email = null; + $this->cell_phone = null; + $this->login_attempts = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->collCcFilessRelatedByDbOwnerId) { + foreach ($this->collCcFilessRelatedByDbOwnerId as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcFilessRelatedByDbEditedby) { + foreach ($this->collCcFilessRelatedByDbEditedby as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcShowHostss) { + foreach ($this->collCcShowHostss as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcPlaylists) { + foreach ($this->collCcPlaylists as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcBlocks) { + foreach ($this->collCcBlocks as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcPrefs) { + foreach ($this->collCcPrefs as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCcSubjsTokens) { + foreach ($this->collCcSubjsTokens as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collMediaItems) { + foreach ($this->collMediaItems as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collAudioFiles) { + foreach ($this->collAudioFiles as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collWebstreams) { + foreach ($this->collWebstreams as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collPlaylists) { + foreach ($this->collPlaylists as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collBlocks) { + foreach ($this->collBlocks as $o) { + $o->clearAllReferences($deep); + } + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + if ($this->collCcFilessRelatedByDbOwnerId instanceof PropelCollection) { + $this->collCcFilessRelatedByDbOwnerId->clearIterator(); + } + $this->collCcFilessRelatedByDbOwnerId = null; + if ($this->collCcFilessRelatedByDbEditedby instanceof PropelCollection) { + $this->collCcFilessRelatedByDbEditedby->clearIterator(); + } + $this->collCcFilessRelatedByDbEditedby = null; + if ($this->collCcShowHostss instanceof PropelCollection) { + $this->collCcShowHostss->clearIterator(); + } + $this->collCcShowHostss = null; + if ($this->collCcPlaylists instanceof PropelCollection) { + $this->collCcPlaylists->clearIterator(); + } + $this->collCcPlaylists = null; + if ($this->collCcBlocks instanceof PropelCollection) { + $this->collCcBlocks->clearIterator(); + } + $this->collCcBlocks = null; + if ($this->collCcPrefs instanceof PropelCollection) { + $this->collCcPrefs->clearIterator(); + } + $this->collCcPrefs = null; + if ($this->collCcSubjsTokens instanceof PropelCollection) { + $this->collCcSubjsTokens->clearIterator(); + } + $this->collCcSubjsTokens = null; + if ($this->collMediaItems instanceof PropelCollection) { + $this->collMediaItems->clearIterator(); + } + $this->collMediaItems = null; + if ($this->collAudioFiles instanceof PropelCollection) { + $this->collAudioFiles->clearIterator(); + } + $this->collAudioFiles = null; + if ($this->collWebstreams instanceof PropelCollection) { + $this->collWebstreams->clearIterator(); + } + $this->collWebstreams = null; + if ($this->collPlaylists instanceof PropelCollection) { + $this->collPlaylists->clearIterator(); + } + $this->collPlaylists = null; + if ($this->collBlocks instanceof PropelCollection) { + $this->collBlocks->clearIterator(); + } + $this->collBlocks = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcSubjsPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcSubjsPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcSubjsPeer.php index ad60edbb4..228e487f0 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcSubjsPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcSubjsPeer.php @@ -1,811 +1,844 @@ array ('DbId', 'DbLogin', 'DbPass', 'DbType', 'DbFirstName', 'DbLastName', 'DbLastlogin', 'DbLastfail', 'DbSkypeContact', 'DbJabberContact', 'DbEmail', 'DbCellPhone', 'DbLoginAttempts', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbLogin', 'dbPass', 'dbType', 'dbFirstName', 'dbLastName', 'dbLastlogin', 'dbLastfail', 'dbSkypeContact', 'dbJabberContact', 'dbEmail', 'dbCellPhone', 'dbLoginAttempts', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::LOGIN, self::PASS, self::TYPE, self::FIRST_NAME, self::LAST_NAME, self::LASTLOGIN, self::LASTFAIL, self::SKYPE_CONTACT, self::JABBER_CONTACT, self::EMAIL, self::CELL_PHONE, self::LOGIN_ATTEMPTS, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOGIN', 'PASS', 'TYPE', 'FIRST_NAME', 'LAST_NAME', 'LASTLOGIN', 'LASTFAIL', 'SKYPE_CONTACT', 'JABBER_CONTACT', 'EMAIL', 'CELL_PHONE', 'LOGIN_ATTEMPTS', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'login', 'pass', 'type', 'first_name', 'last_name', 'lastlogin', 'lastfail', 'skype_contact', 'jabber_contact', 'email', 'cell_phone', 'login_attempts', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) - ); - - /** - * 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, 'DbLogin' => 1, 'DbPass' => 2, 'DbType' => 3, 'DbFirstName' => 4, 'DbLastName' => 5, 'DbLastlogin' => 6, 'DbLastfail' => 7, 'DbSkypeContact' => 8, 'DbJabberContact' => 9, 'DbEmail' => 10, 'DbCellPhone' => 11, 'DbLoginAttempts' => 12, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbLogin' => 1, 'dbPass' => 2, 'dbType' => 3, 'dbFirstName' => 4, 'dbLastName' => 5, 'dbLastlogin' => 6, 'dbLastfail' => 7, 'dbSkypeContact' => 8, 'dbJabberContact' => 9, 'dbEmail' => 10, 'dbCellPhone' => 11, 'dbLoginAttempts' => 12, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::LOGIN => 1, self::PASS => 2, self::TYPE => 3, self::FIRST_NAME => 4, self::LAST_NAME => 5, self::LASTLOGIN => 6, self::LASTFAIL => 7, self::SKYPE_CONTACT => 8, self::JABBER_CONTACT => 9, self::EMAIL => 10, self::CELL_PHONE => 11, self::LOGIN_ATTEMPTS => 12, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOGIN' => 1, 'PASS' => 2, 'TYPE' => 3, 'FIRST_NAME' => 4, 'LAST_NAME' => 5, 'LASTLOGIN' => 6, 'LASTFAIL' => 7, 'SKYPE_CONTACT' => 8, 'JABBER_CONTACT' => 9, 'EMAIL' => 10, 'CELL_PHONE' => 11, 'LOGIN_ATTEMPTS' => 12, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'login' => 1, 'pass' => 2, 'type' => 3, 'first_name' => 4, 'last_name' => 5, 'lastlogin' => 6, 'lastfail' => 7, 'skype_contact' => 8, 'jabber_contact' => 9, 'email' => 10, 'cell_phone' => 11, 'login_attempts' => 12, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) - ); - - /** - * 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::FIRST_NAME); - $criteria->addSelectColumn(CcSubjsPeer::LAST_NAME); - $criteria->addSelectColumn(CcSubjsPeer::LASTLOGIN); - $criteria->addSelectColumn(CcSubjsPeer::LASTFAIL); - $criteria->addSelectColumn(CcSubjsPeer::SKYPE_CONTACT); - $criteria->addSelectColumn(CcSubjsPeer::JABBER_CONTACT); - $criteria->addSelectColumn(CcSubjsPeer::EMAIL); - $criteria->addSelectColumn(CcSubjsPeer::CELL_PHONE); - $criteria->addSelectColumn(CcSubjsPeer::LOGIN_ATTEMPTS); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOGIN'); - $criteria->addSelectColumn($alias . '.PASS'); - $criteria->addSelectColumn($alias . '.TYPE'); - $criteria->addSelectColumn($alias . '.FIRST_NAME'); - $criteria->addSelectColumn($alias . '.LAST_NAME'); - $criteria->addSelectColumn($alias . '.LASTLOGIN'); - $criteria->addSelectColumn($alias . '.LASTFAIL'); - $criteria->addSelectColumn($alias . '.SKYPE_CONTACT'); - $criteria->addSelectColumn($alias . '.JABBER_CONTACT'); - $criteria->addSelectColumn($alias . '.EMAIL'); - $criteria->addSelectColumn($alias . '.CELL_PHONE'); - $criteria->addSelectColumn($alias . '.LOGIN_ATTEMPTS'); - } - } - - /** - * 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->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 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->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 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 CcShowHostsPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcShowHostsPeer::clearInstancePool(); - // Invalidate objects in CcPlaylistPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcPlaylistPeer::clearInstancePool(); - // Invalidate objects in CcBlockPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcBlockPeer::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(); - // Invalidate objects in CcSubjsTokenPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcSubjsTokenPeer::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 - } - - if ($criteria->containsKey(CcSubjsPeer::ID) && $criteria->keyContainsValue(CcSubjsPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSubjsPeer::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 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; - } +abstract class BaseCcSubjsPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_subjs'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcSubjs'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcSubjsTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 13; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 13; + + /** the column name for the id field */ + const ID = 'cc_subjs.id'; + + /** the column name for the login field */ + const LOGIN = 'cc_subjs.login'; + + /** the column name for the pass field */ + const PASS = 'cc_subjs.pass'; + + /** the column name for the type field */ + const TYPE = 'cc_subjs.type'; + + /** the column name for the first_name field */ + const FIRST_NAME = 'cc_subjs.first_name'; + + /** the column name for the last_name field */ + const LAST_NAME = 'cc_subjs.last_name'; + + /** the column name for the lastlogin field */ + const LASTLOGIN = 'cc_subjs.lastlogin'; + + /** the column name for the lastfail field */ + const LASTFAIL = 'cc_subjs.lastfail'; + + /** the column name for the skype_contact field */ + const SKYPE_CONTACT = 'cc_subjs.skype_contact'; + + /** the column name for the jabber_contact field */ + const JABBER_CONTACT = 'cc_subjs.jabber_contact'; + + /** the column name for the email field */ + const EMAIL = 'cc_subjs.email'; + + /** the column name for the cell_phone field */ + const CELL_PHONE = 'cc_subjs.cell_phone'; + + /** the column name for the login_attempts field */ + const LOGIN_ATTEMPTS = 'cc_subjs.login_attempts'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcSubjs objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcSubjs[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcSubjsPeer::$fieldNames[CcSubjsPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbLogin', 'DbPass', 'DbType', 'DbFirstName', 'DbLastName', 'DbLastlogin', 'DbLastfail', 'DbSkypeContact', 'DbJabberContact', 'DbEmail', 'DbCellPhone', 'DbLoginAttempts', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbLogin', 'dbPass', 'dbType', 'dbFirstName', 'dbLastName', 'dbLastlogin', 'dbLastfail', 'dbSkypeContact', 'dbJabberContact', 'dbEmail', 'dbCellPhone', 'dbLoginAttempts', ), + BasePeer::TYPE_COLNAME => array (CcSubjsPeer::ID, CcSubjsPeer::LOGIN, CcSubjsPeer::PASS, CcSubjsPeer::TYPE, CcSubjsPeer::FIRST_NAME, CcSubjsPeer::LAST_NAME, CcSubjsPeer::LASTLOGIN, CcSubjsPeer::LASTFAIL, CcSubjsPeer::SKYPE_CONTACT, CcSubjsPeer::JABBER_CONTACT, CcSubjsPeer::EMAIL, CcSubjsPeer::CELL_PHONE, CcSubjsPeer::LOGIN_ATTEMPTS, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOGIN', 'PASS', 'TYPE', 'FIRST_NAME', 'LAST_NAME', 'LASTLOGIN', 'LASTFAIL', 'SKYPE_CONTACT', 'JABBER_CONTACT', 'EMAIL', 'CELL_PHONE', 'LOGIN_ATTEMPTS', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'login', 'pass', 'type', 'first_name', 'last_name', 'lastlogin', 'lastfail', 'skype_contact', 'jabber_contact', 'email', 'cell_phone', 'login_attempts', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcSubjsPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbLogin' => 1, 'DbPass' => 2, 'DbType' => 3, 'DbFirstName' => 4, 'DbLastName' => 5, 'DbLastlogin' => 6, 'DbLastfail' => 7, 'DbSkypeContact' => 8, 'DbJabberContact' => 9, 'DbEmail' => 10, 'DbCellPhone' => 11, 'DbLoginAttempts' => 12, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbLogin' => 1, 'dbPass' => 2, 'dbType' => 3, 'dbFirstName' => 4, 'dbLastName' => 5, 'dbLastlogin' => 6, 'dbLastfail' => 7, 'dbSkypeContact' => 8, 'dbJabberContact' => 9, 'dbEmail' => 10, 'dbCellPhone' => 11, 'dbLoginAttempts' => 12, ), + BasePeer::TYPE_COLNAME => array (CcSubjsPeer::ID => 0, CcSubjsPeer::LOGIN => 1, CcSubjsPeer::PASS => 2, CcSubjsPeer::TYPE => 3, CcSubjsPeer::FIRST_NAME => 4, CcSubjsPeer::LAST_NAME => 5, CcSubjsPeer::LASTLOGIN => 6, CcSubjsPeer::LASTFAIL => 7, CcSubjsPeer::SKYPE_CONTACT => 8, CcSubjsPeer::JABBER_CONTACT => 9, CcSubjsPeer::EMAIL => 10, CcSubjsPeer::CELL_PHONE => 11, CcSubjsPeer::LOGIN_ATTEMPTS => 12, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOGIN' => 1, 'PASS' => 2, 'TYPE' => 3, 'FIRST_NAME' => 4, 'LAST_NAME' => 5, 'LASTLOGIN' => 6, 'LASTFAIL' => 7, 'SKYPE_CONTACT' => 8, 'JABBER_CONTACT' => 9, 'EMAIL' => 10, 'CELL_PHONE' => 11, 'LOGIN_ATTEMPTS' => 12, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'login' => 1, 'pass' => 2, 'type' => 3, 'first_name' => 4, 'last_name' => 5, 'lastlogin' => 6, 'lastfail' => 7, 'skype_contact' => 8, 'jabber_contact' => 9, 'email' => 10, 'cell_phone' => 11, 'login_attempts' => 12, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcSubjsPeer::getFieldNames($toType); + $key = isset(CcSubjsPeer::$fieldKeys[$fromType][$name]) ? CcSubjsPeer::$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(CcSubjsPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcSubjsPeer::$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 CcSubjsPeer::$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::FIRST_NAME); + $criteria->addSelectColumn(CcSubjsPeer::LAST_NAME); + $criteria->addSelectColumn(CcSubjsPeer::LASTLOGIN); + $criteria->addSelectColumn(CcSubjsPeer::LASTFAIL); + $criteria->addSelectColumn(CcSubjsPeer::SKYPE_CONTACT); + $criteria->addSelectColumn(CcSubjsPeer::JABBER_CONTACT); + $criteria->addSelectColumn(CcSubjsPeer::EMAIL); + $criteria->addSelectColumn(CcSubjsPeer::CELL_PHONE); + $criteria->addSelectColumn(CcSubjsPeer::LOGIN_ATTEMPTS); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.login'); + $criteria->addSelectColumn($alias . '.pass'); + $criteria->addSelectColumn($alias . '.type'); + $criteria->addSelectColumn($alias . '.first_name'); + $criteria->addSelectColumn($alias . '.last_name'); + $criteria->addSelectColumn($alias . '.lastlogin'); + $criteria->addSelectColumn($alias . '.lastfail'); + $criteria->addSelectColumn($alias . '.skype_contact'); + $criteria->addSelectColumn($alias . '.jabber_contact'); + $criteria->addSelectColumn($alias . '.email'); + $criteria->addSelectColumn($alias . '.cell_phone'); + $criteria->addSelectColumn($alias . '.login_attempts'); + } + } + + /** + * 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(CcSubjsPeer::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; + } + /** + * Selects 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; + } + /** + * Selects several row from the DB. + * + * @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 directly (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(CcSubjsPeer::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 $obj 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($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcSubjsPeer::$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. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcSubjs) { + $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 CcSubjs object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcSubjsPeer::$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(CcSubjsPeer::$instances[$key])) { + return CcSubjsPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcSubjsPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcSubjsPeer::$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 CcShowHostsPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcShowHostsPeer::clearInstancePool(); + // Invalidate objects in CcPlaylistPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcPlaylistPeer::clearInstancePool(); + // Invalidate objects in CcBlockPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcBlockPeer::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 CcSubjsTokenPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcSubjsTokenPeer::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(); + // 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_HYDRATE_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(CcSubjsPeer::DATABASE_NAME)->getTable(CcSubjsPeer::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 \Airtime\map\CcSubjsTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcSubjsPeer::OM_CLASS; + } + + /** + * Performs 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 + } + + if ($criteria->containsKey(CcSubjsPeer::ID) && $criteria->keyContainsValue(CcSubjsPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSubjsPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcSubjsPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs 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(CcSubjsPeer::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(CcSubjsPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_subjs table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $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 (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs 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(CcSubjsPeer::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(CcSubjsPeer::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 (Exception $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($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->hasColumn($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 + * @return CcSubjs[] + * @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 diff --git a/airtime_mvc/application/models/airtime/om/BaseCcSubjsQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcSubjsQuery.php index 38703d208..fe2553e8b 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcSubjsQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcSubjsQuery.php @@ -1,1116 +1,1675 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcSubjs|CcSubjs[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcSubjsPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcSubjsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $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); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcSubjs A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * 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); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcSubjs A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "login", "pass", "type", "first_name", "last_name", "lastlogin", "lastfail", "skype_contact", "jabber_contact", "email", "cell_phone", "login_attempts" FROM "cc_subjs" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcSubjs(); + $obj->hydrate($row); + CcSubjsPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcSubjsQuery 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(CcSubjsPeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * Filter the query on the login column - * - * @param string $dbLogin 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 filterByDbLogin($dbLogin = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbLogin)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbLogin)) { - $dbLogin = str_replace('*', '%', $dbLogin); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcSubjsPeer::LOGIN, $dbLogin, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcSubjs|CcSubjs[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Filter the query on the pass column - * - * @param string $dbPass 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 filterByDbPass($dbPass = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbPass)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbPass)) { - $dbPass = str_replace('*', '%', $dbPass); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcSubjsPeer::PASS, $dbPass, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query on the type column - * - * @param string $dbType The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcSubjsQuery The current query, for fluid interface - */ - public function filterByDbType($dbType = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbType)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbType)) { - $dbType = str_replace('*', '%', $dbType); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcSubjsPeer::TYPE, $dbType, $comparison); - } + /** + * 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|CcSubjs[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query on the first_name column - * - * @param string $dbFirstName 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 filterByDbFirstName($dbFirstName = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbFirstName)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbFirstName)) { - $dbFirstName = str_replace('*', '%', $dbFirstName); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcSubjsPeer::FIRST_NAME, $dbFirstName, $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Filter the query on the last_name column - * - * @param string $dbLastName 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 filterByDbLastName($dbLastName = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbLastName)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbLastName)) { - $dbLastName = str_replace('*', '%', $dbLastName); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcSubjsPeer::LAST_NAME, $dbLastName, $comparison); - } + /** + * 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) + { - /** - * Filter the query on the lastlogin column - * - * @param string|array $dbLastlogin 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 filterByDbLastlogin($dbLastlogin = null, $comparison = null) - { - if (is_array($dbLastlogin)) { - $useMinMax = false; - if (isset($dbLastlogin['min'])) { - $this->addUsingAlias(CcSubjsPeer::LASTLOGIN, $dbLastlogin['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbLastlogin['max'])) { - $this->addUsingAlias(CcSubjsPeer::LASTLOGIN, $dbLastlogin['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcSubjsPeer::LASTLOGIN, $dbLastlogin, $comparison); - } + return $this->addUsingAlias(CcSubjsPeer::ID, $key, Criteria::EQUAL); + } - /** - * Filter the query on the lastfail column - * - * @param string|array $dbLastfail 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 filterByDbLastfail($dbLastfail = null, $comparison = null) - { - if (is_array($dbLastfail)) { - $useMinMax = false; - if (isset($dbLastfail['min'])) { - $this->addUsingAlias(CcSubjsPeer::LASTFAIL, $dbLastfail['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbLastfail['max'])) { - $this->addUsingAlias(CcSubjsPeer::LASTFAIL, $dbLastfail['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcSubjsPeer::LASTFAIL, $dbLastfail, $comparison); - } + /** + * 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) + { - /** - * Filter the query on the skype_contact column - * - * @param string $dbSkypeContact 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 filterByDbSkypeContact($dbSkypeContact = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbSkypeContact)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbSkypeContact)) { - $dbSkypeContact = str_replace('*', '%', $dbSkypeContact); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcSubjsPeer::SKYPE_CONTACT, $dbSkypeContact, $comparison); - } + return $this->addUsingAlias(CcSubjsPeer::ID, $keys, Criteria::IN); + } - /** - * Filter the query on the jabber_contact column - * - * @param string $dbJabberContact 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 filterByDbJabberContact($dbJabberContact = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbJabberContact)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbJabberContact)) { - $dbJabberContact = str_replace('*', '%', $dbJabberContact); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcSubjsPeer::JABBER_CONTACT, $dbJabberContact, $comparison); - } + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcSubjsQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcSubjsPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcSubjsPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Filter the query on the email column - * - * @param string $dbEmail 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 filterByDbEmail($dbEmail = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbEmail)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbEmail)) { - $dbEmail = str_replace('*', '%', $dbEmail); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcSubjsPeer::EMAIL, $dbEmail, $comparison); - } + return $this->addUsingAlias(CcSubjsPeer::ID, $dbId, $comparison); + } - /** - * Filter the query on the cell_phone column - * - * @param string $dbCellPhone 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 filterByDbCellPhone($dbCellPhone = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbCellPhone)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbCellPhone)) { - $dbCellPhone = str_replace('*', '%', $dbCellPhone); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcSubjsPeer::CELL_PHONE, $dbCellPhone, $comparison); - } + /** + * Filter the query on the login column + * + * Example usage: + * + * $query->filterByDbLogin('fooValue'); // WHERE login = 'fooValue' + * $query->filterByDbLogin('%fooValue%'); // WHERE login LIKE '%fooValue%' + * + * + * @param string $dbLogin 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 filterByDbLogin($dbLogin = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLogin)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLogin)) { + $dbLogin = str_replace('*', '%', $dbLogin); + $comparison = Criteria::LIKE; + } + } - /** - * Filter the query on the login_attempts column - * - * @param int|array $dbLoginAttempts 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 filterByDbLoginAttempts($dbLoginAttempts = null, $comparison = null) - { - if (is_array($dbLoginAttempts)) { - $useMinMax = false; - if (isset($dbLoginAttempts['min'])) { - $this->addUsingAlias(CcSubjsPeer::LOGIN_ATTEMPTS, $dbLoginAttempts['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbLoginAttempts['max'])) { - $this->addUsingAlias(CcSubjsPeer::LOGIN_ATTEMPTS, $dbLoginAttempts['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcSubjsPeer::LOGIN_ATTEMPTS, $dbLoginAttempts, $comparison); - } + return $this->addUsingAlias(CcSubjsPeer::LOGIN, $dbLogin, $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 CcSubjsQuery The current query, for fluid interface - */ - public function filterByCcFilesRelatedByDbOwnerId($ccFiles, $comparison = null) - { - return $this - ->addUsingAlias(CcSubjsPeer::ID, $ccFiles->getDbOwnerId(), $comparison); - } + /** + * Filter the query on the pass column + * + * Example usage: + * + * $query->filterByDbPass('fooValue'); // WHERE pass = 'fooValue' + * $query->filterByDbPass('%fooValue%'); // WHERE pass LIKE '%fooValue%' + * + * + * @param string $dbPass 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 filterByDbPass($dbPass = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbPass)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbPass)) { + $dbPass = str_replace('*', '%', $dbPass); + $comparison = Criteria::LIKE; + } + } - /** - * Adds a JOIN clause to the query using the CcFilesRelatedByDbOwnerId 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 joinCcFilesRelatedByDbOwnerId($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcFilesRelatedByDbOwnerId'); - - // 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, 'CcFilesRelatedByDbOwnerId'); - } - - return $this; - } + return $this->addUsingAlias(CcSubjsPeer::PASS, $dbPass, $comparison); + } - /** - * Use the CcFilesRelatedByDbOwnerId 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 useCcFilesRelatedByDbOwnerIdQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcFilesRelatedByDbOwnerId($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcFilesRelatedByDbOwnerId', 'CcFilesQuery'); - } + /** + * Filter the query on the type column + * + * Example usage: + * + * $query->filterByDbType('fooValue'); // WHERE type = 'fooValue' + * $query->filterByDbType('%fooValue%'); // WHERE type LIKE '%fooValue%' + * + * + * @param string $dbType The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcSubjsQuery The current query, for fluid interface + */ + public function filterByDbType($dbType = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbType)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbType)) { + $dbType = str_replace('*', '%', $dbType); + $comparison = Criteria::LIKE; + } + } - /** - * 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 filterByCcFilesRelatedByDbEditedby($ccFiles, $comparison = null) - { - return $this - ->addUsingAlias(CcSubjsPeer::ID, $ccFiles->getDbEditedby(), $comparison); - } + return $this->addUsingAlias(CcSubjsPeer::TYPE, $dbType, $comparison); + } - /** - * Adds a JOIN clause to the query using the CcFilesRelatedByDbEditedby 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 joinCcFilesRelatedByDbEditedby($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcFilesRelatedByDbEditedby'); - - // 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, 'CcFilesRelatedByDbEditedby'); - } - - return $this; - } + /** + * Filter the query on the first_name column + * + * Example usage: + * + * $query->filterByDbFirstName('fooValue'); // WHERE first_name = 'fooValue' + * $query->filterByDbFirstName('%fooValue%'); // WHERE first_name LIKE '%fooValue%' + * + * + * @param string $dbFirstName 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 filterByDbFirstName($dbFirstName = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbFirstName)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbFirstName)) { + $dbFirstName = str_replace('*', '%', $dbFirstName); + $comparison = Criteria::LIKE; + } + } - /** - * Use the CcFilesRelatedByDbEditedby 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 useCcFilesRelatedByDbEditedbyQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcFilesRelatedByDbEditedby($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcFilesRelatedByDbEditedby', 'CcFilesQuery'); - } + return $this->addUsingAlias(CcSubjsPeer::FIRST_NAME, $dbFirstName, $comparison); + } - /** - * 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); - } + /** + * Filter the query on the last_name column + * + * Example usage: + * + * $query->filterByDbLastName('fooValue'); // WHERE last_name = 'fooValue' + * $query->filterByDbLastName('%fooValue%'); // WHERE last_name LIKE '%fooValue%' + * + * + * @param string $dbLastName 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 filterByDbLastName($dbLastName = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLastName)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLastName)) { + $dbLastName = str_replace('*', '%', $dbLastName); + $comparison = Criteria::LIKE; + } + } - /** - * 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; - } + return $this->addUsingAlias(CcSubjsPeer::LAST_NAME, $dbLastName, $comparison); + } - /** - * 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 on the lastlogin column + * + * Example usage: + * + * $query->filterByDbLastlogin('2011-03-14'); // WHERE lastlogin = '2011-03-14' + * $query->filterByDbLastlogin('now'); // WHERE lastlogin = '2011-03-14' + * $query->filterByDbLastlogin(array('max' => 'yesterday')); // WHERE lastlogin < '2011-03-13' + * + * + * @param mixed $dbLastlogin The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcSubjsQuery The current query, for fluid interface + */ + public function filterByDbLastlogin($dbLastlogin = null, $comparison = null) + { + if (is_array($dbLastlogin)) { + $useMinMax = false; + if (isset($dbLastlogin['min'])) { + $this->addUsingAlias(CcSubjsPeer::LASTLOGIN, $dbLastlogin['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbLastlogin['max'])) { + $this->addUsingAlias(CcSubjsPeer::LASTLOGIN, $dbLastlogin['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Filter the query by a related CcShowHosts object - * - * @param CcShowHosts $ccShowHosts 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 filterByCcShowHosts($ccShowHosts, $comparison = null) - { - return $this - ->addUsingAlias(CcSubjsPeer::ID, $ccShowHosts->getDbHost(), $comparison); - } + return $this->addUsingAlias(CcSubjsPeer::LASTLOGIN, $dbLastlogin, $comparison); + } - /** - * Adds a JOIN clause to the query using the CcShowHosts 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 joinCcShowHosts($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcShowHosts'); - - // 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, 'CcShowHosts'); - } - - return $this; - } + /** + * Filter the query on the lastfail column + * + * Example usage: + * + * $query->filterByDbLastfail('2011-03-14'); // WHERE lastfail = '2011-03-14' + * $query->filterByDbLastfail('now'); // WHERE lastfail = '2011-03-14' + * $query->filterByDbLastfail(array('max' => 'yesterday')); // WHERE lastfail < '2011-03-13' + * + * + * @param mixed $dbLastfail The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcSubjsQuery The current query, for fluid interface + */ + public function filterByDbLastfail($dbLastfail = null, $comparison = null) + { + if (is_array($dbLastfail)) { + $useMinMax = false; + if (isset($dbLastfail['min'])) { + $this->addUsingAlias(CcSubjsPeer::LASTFAIL, $dbLastfail['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbLastfail['max'])) { + $this->addUsingAlias(CcSubjsPeer::LASTFAIL, $dbLastfail['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Use the CcShowHosts relation CcShowHosts 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 CcShowHostsQuery A secondary query class using the current class as primary query - */ - public function useCcShowHostsQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcShowHosts($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcShowHosts', 'CcShowHostsQuery'); - } + return $this->addUsingAlias(CcSubjsPeer::LASTFAIL, $dbLastfail, $comparison); + } - /** - * Filter the query by a related CcPlaylist object - * - * @param CcPlaylist $ccPlaylist the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcSubjsQuery The current query, for fluid interface - */ - public function filterByCcPlaylist($ccPlaylist, $comparison = null) - { - return $this - ->addUsingAlias(CcSubjsPeer::ID, $ccPlaylist->getDbCreatorId(), $comparison); - } + /** + * Filter the query on the skype_contact column + * + * Example usage: + * + * $query->filterByDbSkypeContact('fooValue'); // WHERE skype_contact = 'fooValue' + * $query->filterByDbSkypeContact('%fooValue%'); // WHERE skype_contact LIKE '%fooValue%' + * + * + * @param string $dbSkypeContact 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 filterByDbSkypeContact($dbSkypeContact = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbSkypeContact)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbSkypeContact)) { + $dbSkypeContact = str_replace('*', '%', $dbSkypeContact); + $comparison = Criteria::LIKE; + } + } - /** - * 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; - } + return $this->addUsingAlias(CcSubjsPeer::SKYPE_CONTACT, $dbSkypeContact, $comparison); + } - /** - * 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 on the jabber_contact column + * + * Example usage: + * + * $query->filterByDbJabberContact('fooValue'); // WHERE jabber_contact = 'fooValue' + * $query->filterByDbJabberContact('%fooValue%'); // WHERE jabber_contact LIKE '%fooValue%' + * + * + * @param string $dbJabberContact 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 filterByDbJabberContact($dbJabberContact = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbJabberContact)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbJabberContact)) { + $dbJabberContact = str_replace('*', '%', $dbJabberContact); + $comparison = Criteria::LIKE; + } + } - /** - * Filter the query by a related CcBlock object - * - * @param CcBlock $ccBlock 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 filterByCcBlock($ccBlock, $comparison = null) - { - return $this - ->addUsingAlias(CcSubjsPeer::ID, $ccBlock->getDbCreatorId(), $comparison); - } + return $this->addUsingAlias(CcSubjsPeer::JABBER_CONTACT, $dbJabberContact, $comparison); + } - /** - * Adds a JOIN clause to the query using the CcBlock 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 joinCcBlock($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcBlock'); - - // 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, 'CcBlock'); - } - - return $this; - } + /** + * Filter the query on the email column + * + * Example usage: + * + * $query->filterByDbEmail('fooValue'); // WHERE email = 'fooValue' + * $query->filterByDbEmail('%fooValue%'); // WHERE email LIKE '%fooValue%' + * + * + * @param string $dbEmail 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 filterByDbEmail($dbEmail = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbEmail)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbEmail)) { + $dbEmail = str_replace('*', '%', $dbEmail); + $comparison = Criteria::LIKE; + } + } - /** - * Use the CcBlock relation CcBlock 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 CcBlockQuery A secondary query class using the current class as primary query - */ - public function useCcBlockQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcBlock($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcBlock', 'CcBlockQuery'); - } + return $this->addUsingAlias(CcSubjsPeer::EMAIL, $dbEmail, $comparison); + } - /** - * 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); - } + /** + * Filter the query on the cell_phone column + * + * Example usage: + * + * $query->filterByDbCellPhone('fooValue'); // WHERE cell_phone = 'fooValue' + * $query->filterByDbCellPhone('%fooValue%'); // WHERE cell_phone LIKE '%fooValue%' + * + * + * @param string $dbCellPhone 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 filterByDbCellPhone($dbCellPhone = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbCellPhone)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbCellPhone)) { + $dbCellPhone = str_replace('*', '%', $dbCellPhone); + $comparison = Criteria::LIKE; + } + } - /** - * 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; - } + return $this->addUsingAlias(CcSubjsPeer::CELL_PHONE, $dbCellPhone, $comparison); + } - /** - * 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 on the login_attempts column + * + * Example usage: + * + * $query->filterByDbLoginAttempts(1234); // WHERE login_attempts = 1234 + * $query->filterByDbLoginAttempts(array(12, 34)); // WHERE login_attempts IN (12, 34) + * $query->filterByDbLoginAttempts(array('min' => 12)); // WHERE login_attempts >= 12 + * $query->filterByDbLoginAttempts(array('max' => 12)); // WHERE login_attempts <= 12 + * + * + * @param mixed $dbLoginAttempts The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcSubjsQuery The current query, for fluid interface + */ + public function filterByDbLoginAttempts($dbLoginAttempts = null, $comparison = null) + { + if (is_array($dbLoginAttempts)) { + $useMinMax = false; + if (isset($dbLoginAttempts['min'])) { + $this->addUsingAlias(CcSubjsPeer::LOGIN_ATTEMPTS, $dbLoginAttempts['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbLoginAttempts['max'])) { + $this->addUsingAlias(CcSubjsPeer::LOGIN_ATTEMPTS, $dbLoginAttempts['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * 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); - } + return $this->addUsingAlias(CcSubjsPeer::LOGIN_ATTEMPTS, $dbLoginAttempts, $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; - } + /** + * Filter the query by a related CcFiles object + * + * @param CcFiles|PropelObjectCollection $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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcFilesRelatedByDbOwnerId($ccFiles, $comparison = null) + { + if ($ccFiles instanceof CcFiles) { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $ccFiles->getDbOwnerId(), $comparison); + } elseif ($ccFiles instanceof PropelObjectCollection) { + return $this + ->useCcFilesRelatedByDbOwnerIdQuery() + ->filterByPrimaryKeys($ccFiles->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcFilesRelatedByDbOwnerId() only accepts arguments of type CcFiles or PropelCollection'); + } + } - /** - * 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'); - } + /** + * Adds a JOIN clause to the query using the CcFilesRelatedByDbOwnerId 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 joinCcFilesRelatedByDbOwnerId($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcFilesRelatedByDbOwnerId'); - /** - * Filter the query by a related CcSubjsToken object - * - * @param CcSubjsToken $ccSubjsToken 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 filterByCcSubjsToken($ccSubjsToken, $comparison = null) - { - return $this - ->addUsingAlias(CcSubjsPeer::ID, $ccSubjsToken->getDbUserId(), $comparison); - } + // 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); + } - /** - * Adds a JOIN clause to the query using the CcSubjsToken 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 joinCcSubjsToken($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcSubjsToken'); - - // 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, 'CcSubjsToken'); - } - - return $this; - } + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CcFilesRelatedByDbOwnerId'); + } - /** - * Use the CcSubjsToken relation CcSubjsToken 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 CcSubjsTokenQuery A secondary query class using the current class as primary query - */ - public function useCcSubjsTokenQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcSubjsToken($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcSubjsToken', 'CcSubjsTokenQuery'); - } + return $this; + } - /** - * 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->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + /** + * Use the CcFilesRelatedByDbOwnerId 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 \Airtime\CcFilesQuery A secondary query class using the current class as primary query + */ + public function useCcFilesRelatedByDbOwnerIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcFilesRelatedByDbOwnerId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcFilesRelatedByDbOwnerId', '\Airtime\CcFilesQuery'); + } -} // BaseCcSubjsQuery + /** + * Filter the query by a related CcFiles object + * + * @param CcFiles|PropelObjectCollection $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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcFilesRelatedByDbEditedby($ccFiles, $comparison = null) + { + if ($ccFiles instanceof CcFiles) { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $ccFiles->getDbEditedby(), $comparison); + } elseif ($ccFiles instanceof PropelObjectCollection) { + return $this + ->useCcFilesRelatedByDbEditedbyQuery() + ->filterByPrimaryKeys($ccFiles->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcFilesRelatedByDbEditedby() only accepts arguments of type CcFiles or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcFilesRelatedByDbEditedby 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 joinCcFilesRelatedByDbEditedby($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcFilesRelatedByDbEditedby'); + + // 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, 'CcFilesRelatedByDbEditedby'); + } + + return $this; + } + + /** + * Use the CcFilesRelatedByDbEditedby 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 \Airtime\CcFilesQuery A secondary query class using the current class as primary query + */ + public function useCcFilesRelatedByDbEditedbyQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcFilesRelatedByDbEditedby($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcFilesRelatedByDbEditedby', '\Airtime\CcFilesQuery'); + } + + /** + * Filter the query by a related CcShowHosts object + * + * @param CcShowHosts|PropelObjectCollection $ccShowHosts 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcShowHosts($ccShowHosts, $comparison = null) + { + if ($ccShowHosts instanceof CcShowHosts) { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $ccShowHosts->getDbHost(), $comparison); + } elseif ($ccShowHosts instanceof PropelObjectCollection) { + return $this + ->useCcShowHostsQuery() + ->filterByPrimaryKeys($ccShowHosts->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcShowHosts() only accepts arguments of type CcShowHosts or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcShowHosts 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 joinCcShowHosts($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcShowHosts'); + + // 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, 'CcShowHosts'); + } + + return $this; + } + + /** + * Use the CcShowHosts relation CcShowHosts 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 \Airtime\CcShowHostsQuery A secondary query class using the current class as primary query + */ + public function useCcShowHostsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcShowHosts($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcShowHosts', '\Airtime\CcShowHostsQuery'); + } + + /** + * Filter the query by a related CcPlaylist object + * + * @param CcPlaylist|PropelObjectCollection $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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcPlaylist($ccPlaylist, $comparison = null) + { + if ($ccPlaylist instanceof CcPlaylist) { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $ccPlaylist->getDbCreatorId(), $comparison); + } elseif ($ccPlaylist instanceof PropelObjectCollection) { + return $this + ->useCcPlaylistQuery() + ->filterByPrimaryKeys($ccPlaylist->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcPlaylist() only accepts arguments of type CcPlaylist or PropelCollection'); + } + } + + /** + * 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 = null, $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 \Airtime\CcPlaylistQuery A secondary query class using the current class as primary query + */ + public function useCcPlaylistQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcPlaylist($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPlaylist', '\Airtime\CcPlaylistQuery'); + } + + /** + * Filter the query by a related CcBlock object + * + * @param CcBlock|PropelObjectCollection $ccBlock 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcBlock($ccBlock, $comparison = null) + { + if ($ccBlock instanceof CcBlock) { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $ccBlock->getDbCreatorId(), $comparison); + } elseif ($ccBlock instanceof PropelObjectCollection) { + return $this + ->useCcBlockQuery() + ->filterByPrimaryKeys($ccBlock->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcBlock() only accepts arguments of type CcBlock or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcBlock 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 joinCcBlock($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcBlock'); + + // 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, 'CcBlock'); + } + + return $this; + } + + /** + * Use the CcBlock relation CcBlock 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 \Airtime\CcBlockQuery A secondary query class using the current class as primary query + */ + public function useCcBlockQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcBlock($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcBlock', '\Airtime\CcBlockQuery'); + } + + /** + * Filter the query by a related CcPref object + * + * @param CcPref|PropelObjectCollection $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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcPref($ccPref, $comparison = null) + { + if ($ccPref instanceof CcPref) { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $ccPref->getSubjid(), $comparison); + } elseif ($ccPref instanceof PropelObjectCollection) { + return $this + ->useCcPrefQuery() + ->filterByPrimaryKeys($ccPref->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcPref() only accepts arguments of type CcPref or PropelCollection'); + } + } + + /** + * 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 = null, $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 \Airtime\CcPrefQuery A secondary query class using the current class as primary query + */ + public function useCcPrefQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcPref($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcPref', '\Airtime\CcPrefQuery'); + } + + /** + * Filter the query by a related CcSubjsToken object + * + * @param CcSubjsToken|PropelObjectCollection $ccSubjsToken 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcSubjsToken($ccSubjsToken, $comparison = null) + { + if ($ccSubjsToken instanceof CcSubjsToken) { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $ccSubjsToken->getDbUserId(), $comparison); + } elseif ($ccSubjsToken instanceof PropelObjectCollection) { + return $this + ->useCcSubjsTokenQuery() + ->filterByPrimaryKeys($ccSubjsToken->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcSubjsToken() only accepts arguments of type CcSubjsToken or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcSubjsToken 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 joinCcSubjsToken($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcSubjsToken'); + + // 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, 'CcSubjsToken'); + } + + return $this; + } + + /** + * Use the CcSubjsToken relation CcSubjsToken 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 \Airtime\CcSubjsTokenQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsTokenQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcSubjsToken($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjsToken', '\Airtime\CcSubjsTokenQuery'); + } + + /** + * Filter the query by a related MediaItem object + * + * @param MediaItem|PropelObjectCollection $mediaItem 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByMediaItem($mediaItem, $comparison = null) + { + if ($mediaItem instanceof MediaItem) { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $mediaItem->getOwnerId(), $comparison); + } elseif ($mediaItem instanceof PropelObjectCollection) { + return $this + ->useMediaItemQuery() + ->filterByPrimaryKeys($mediaItem->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByMediaItem() only accepts arguments of type MediaItem or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the MediaItem 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 joinMediaItem($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('MediaItem'); + + // 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, 'MediaItem'); + } + + return $this; + } + + /** + * Use the MediaItem relation MediaItem 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 \Airtime\MediaItemQuery A secondary query class using the current class as primary query + */ + public function useMediaItemQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinMediaItem($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'MediaItem', '\Airtime\MediaItemQuery'); + } + + /** + * Filter the query by a related AudioFile object + * + * @param AudioFile|PropelObjectCollection $audioFile 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByAudioFile($audioFile, $comparison = null) + { + if ($audioFile instanceof AudioFile) { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $audioFile->getOwnerId(), $comparison); + } elseif ($audioFile instanceof PropelObjectCollection) { + return $this + ->useAudioFileQuery() + ->filterByPrimaryKeys($audioFile->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByAudioFile() only accepts arguments of type AudioFile or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the AudioFile 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 joinAudioFile($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('AudioFile'); + + // 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, 'AudioFile'); + } + + return $this; + } + + /** + * Use the AudioFile relation AudioFile 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 \Airtime\MediaItem\AudioFileQuery A secondary query class using the current class as primary query + */ + public function useAudioFileQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinAudioFile($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'AudioFile', '\Airtime\MediaItem\AudioFileQuery'); + } + + /** + * Filter the query by a related Webstream object + * + * @param Webstream|PropelObjectCollection $webstream 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByWebstream($webstream, $comparison = null) + { + if ($webstream instanceof Webstream) { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $webstream->getOwnerId(), $comparison); + } elseif ($webstream instanceof PropelObjectCollection) { + return $this + ->useWebstreamQuery() + ->filterByPrimaryKeys($webstream->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByWebstream() only accepts arguments of type Webstream or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the Webstream 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 joinWebstream($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Webstream'); + + // 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, 'Webstream'); + } + + return $this; + } + + /** + * Use the Webstream relation Webstream 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 \Airtime\MediaItem\WebstreamQuery A secondary query class using the current class as primary query + */ + public function useWebstreamQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinWebstream($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Webstream', '\Airtime\MediaItem\WebstreamQuery'); + } + + /** + * Filter the query by a related Playlist object + * + * @param Playlist|PropelObjectCollection $playlist 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByPlaylist($playlist, $comparison = null) + { + if ($playlist instanceof Playlist) { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $playlist->getOwnerId(), $comparison); + } elseif ($playlist instanceof PropelObjectCollection) { + return $this + ->usePlaylistQuery() + ->filterByPrimaryKeys($playlist->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByPlaylist() only accepts arguments of type Playlist or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the Playlist 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 joinPlaylist($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Playlist'); + + // 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, 'Playlist'); + } + + return $this; + } + + /** + * Use the Playlist relation Playlist 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 \Airtime\MediaItem\PlaylistQuery A secondary query class using the current class as primary query + */ + public function usePlaylistQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinPlaylist($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Playlist', '\Airtime\MediaItem\PlaylistQuery'); + } + + /** + * Filter the query by a related Block object + * + * @param Block|PropelObjectCollection $block 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 + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByBlock($block, $comparison = null) + { + if ($block instanceof Block) { + return $this + ->addUsingAlias(CcSubjsPeer::ID, $block->getOwnerId(), $comparison); + } elseif ($block instanceof PropelObjectCollection) { + return $this + ->useBlockQuery() + ->filterByPrimaryKeys($block->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByBlock() only accepts arguments of type Block or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the Block 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 joinBlock($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Block'); + + // 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, 'Block'); + } + + return $this; + } + + /** + * Use the Block relation Block 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 \Airtime\MediaItem\BlockQuery A secondary query class using the current class as primary query + */ + public function useBlockQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinBlock($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Block', '\Airtime\MediaItem\BlockQuery'); + } + + /** + * 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->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcSubjsToken.php b/airtime_mvc/application/models/airtime/om/BaseCcSubjsToken.php index e0a4ba9bb..9a4e0e1da 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcSubjsToken.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcSubjsToken.php @@ -1,1005 +1,1151 @@ id; - } - - /** - * Get the [user_id] column value. - * - * @return int - */ - public function getDbUserId() - { - return $this->user_id; - } - - /** - * Get the [action] column value. - * - * @return string - */ - public function getDbAction() - { - return $this->action; - } - - /** - * Get the [token] column value. - * - * @return string - */ - public function getDbToken() - { - return $this->token; - } - - /** - * Get the [optionally formatted] temporal [created] 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 getDbCreated($format = 'Y-m-d H:i:s') - { - if ($this->created === null) { - return null; - } - - - - try { - $dt = new DateTime($this->created); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created, 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 CcSubjsToken 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[] = CcSubjsTokenPeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [user_id] column. - * - * @param int $v new value - * @return CcSubjsToken The current object (for fluent API support) - */ - public function setDbUserId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->user_id !== $v) { - $this->user_id = $v; - $this->modifiedColumns[] = CcSubjsTokenPeer::USER_ID; - } - - if ($this->aCcSubjs !== null && $this->aCcSubjs->getDbId() !== $v) { - $this->aCcSubjs = null; - } - - return $this; - } // setDbUserId() - - /** - * Set the value of [action] column. - * - * @param string $v new value - * @return CcSubjsToken The current object (for fluent API support) - */ - public function setDbAction($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->action !== $v) { - $this->action = $v; - $this->modifiedColumns[] = CcSubjsTokenPeer::ACTION; - } - - return $this; - } // setDbAction() - - /** - * Set the value of [token] column. - * - * @param string $v new value - * @return CcSubjsToken The current object (for fluent API support) - */ - public function setDbToken($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->token !== $v) { - $this->token = $v; - $this->modifiedColumns[] = CcSubjsTokenPeer::TOKEN; - } - - return $this; - } // setDbToken() - - /** - * Sets the value of [created] 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 CcSubjsToken The current object (for fluent API support) - */ - public function setDbCreated($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->created !== null || $dt !== null ) { - // (nested ifs are a little easier to read in this case) - - $currNorm = ($this->created !== null && $tmpDt = new DateTime($this->created)) ? $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->created = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); - $this->modifiedColumns[] = CcSubjsTokenPeer::CREATED; - } - } // if either are not null - - return $this; - } // setDbCreated() - - /** - * 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->user_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->action = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->token = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->created = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 5; // 5 = CcSubjsTokenPeer::NUM_COLUMNS - CcSubjsTokenPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcSubjsToken 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->user_id !== $this->aCcSubjs->getDbId()) { - $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(CcSubjsTokenPeer::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 = CcSubjsTokenPeer::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(CcSubjsTokenPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcSubjsTokenQuery::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(CcSubjsTokenPeer::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); - CcSubjsTokenPeer::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[] = CcSubjsTokenPeer::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(CcSubjsTokenPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSubjsTokenPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows += 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows += CcSubjsTokenPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcSubjs !== null) { - if (!$this->aCcSubjs->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcSubjs->getValidationFailures()); - } - } - - - if (($retval = CcSubjsTokenPeer::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 = CcSubjsTokenPeer::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->getDbUserId(); - break; - case 2: - return $this->getDbAction(); - break; - case 3: - return $this->getDbToken(); - break; - case 4: - return $this->getDbCreated(); - 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 = CcSubjsTokenPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbUserId(), - $keys[2] => $this->getDbAction(), - $keys[3] => $this->getDbToken(), - $keys[4] => $this->getDbCreated(), - ); - 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 = CcSubjsTokenPeer::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->setDbUserId($value); - break; - case 2: - $this->setDbAction($value); - break; - case 3: - $this->setDbToken($value); - break; - case 4: - $this->setDbCreated($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 = CcSubjsTokenPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbUserId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbAction($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbToken($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbCreated($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(CcSubjsTokenPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcSubjsTokenPeer::ID)) $criteria->add(CcSubjsTokenPeer::ID, $this->id); - if ($this->isColumnModified(CcSubjsTokenPeer::USER_ID)) $criteria->add(CcSubjsTokenPeer::USER_ID, $this->user_id); - if ($this->isColumnModified(CcSubjsTokenPeer::ACTION)) $criteria->add(CcSubjsTokenPeer::ACTION, $this->action); - if ($this->isColumnModified(CcSubjsTokenPeer::TOKEN)) $criteria->add(CcSubjsTokenPeer::TOKEN, $this->token); - if ($this->isColumnModified(CcSubjsTokenPeer::CREATED)) $criteria->add(CcSubjsTokenPeer::CREATED, $this->created); - - 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(CcSubjsTokenPeer::DATABASE_NAME); - $criteria->add(CcSubjsTokenPeer::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 CcSubjsToken (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->setDbUserId($this->user_id); - $copyObj->setDbAction($this->action); - $copyObj->setDbToken($this->token); - $copyObj->setDbCreated($this->created); - - $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 CcSubjsToken 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 CcSubjsTokenPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcSubjsTokenPeer(); - } - return self::$peer; - } - - /** - * Declares an association between this object and a CcSubjs object. - * - * @param CcSubjs $v - * @return CcSubjsToken The current object (for fluent API support) - * @throws PropelException - */ - public function setCcSubjs(CcSubjs $v = null) - { - if ($v === null) { - $this->setDbUserId(NULL); - } else { - $this->setDbUserId($v->getDbId()); - } - - $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->addCcSubjsToken($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->user_id !== null)) { - $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->user_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->aCcSubjs->addCcSubjsTokens($this); - */ - } - return $this->aCcSubjs; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->user_id = null; - $this->action = null; - $this->token = null; - $this->created = 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); - } - -} // BaseCcSubjsToken + /** + * Peer class name + */ + const PEER = 'Airtime\\CcSubjsTokenPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcSubjsTokenPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the user_id field. + * @var int + */ + protected $user_id; + + /** + * The value for the action field. + * @var string + */ + protected $action; + + /** + * The value for the token field. + * @var string + */ + protected $token; + + /** + * The value for the created field. + * @var string + */ + protected $created; + + /** + * @var CcSubjs + */ + protected $aCcSubjs; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * Get the [id] column value. + * + * @return int + */ + public function getDbId() + { + + return $this->id; + } + + /** + * Get the [user_id] column value. + * + * @return int + */ + public function getDbUserId() + { + + return $this->user_id; + } + + /** + * Get the [action] column value. + * + * @return string + */ + public function getDbAction() + { + + return $this->action; + } + + /** + * Get the [token] column value. + * + * @return string + */ + public function getDbToken() + { + + return $this->token; + } + + /** + * Get the [optionally formatted] temporal [created] 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 getDbCreated($format = 'Y-m-d H:i:s') + { + if ($this->created === null) { + return null; + } + + + try { + $dt = new DateTime($this->created); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcSubjsToken The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcSubjsTokenPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [user_id] column. + * + * @param int $v new value + * @return CcSubjsToken The current object (for fluent API support) + */ + public function setDbUserId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->user_id !== $v) { + $this->user_id = $v; + $this->modifiedColumns[] = CcSubjsTokenPeer::USER_ID; + } + + if ($this->aCcSubjs !== null && $this->aCcSubjs->getDbId() !== $v) { + $this->aCcSubjs = null; + } + + + return $this; + } // setDbUserId() + + /** + * Set the value of [action] column. + * + * @param string $v new value + * @return CcSubjsToken The current object (for fluent API support) + */ + public function setDbAction($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->action !== $v) { + $this->action = $v; + $this->modifiedColumns[] = CcSubjsTokenPeer::ACTION; + } + + + return $this; + } // setDbAction() + + /** + * Set the value of [token] column. + * + * @param string $v new value + * @return CcSubjsToken The current object (for fluent API support) + */ + public function setDbToken($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->token !== $v) { + $this->token = $v; + $this->modifiedColumns[] = CcSubjsTokenPeer::TOKEN; + } + + + return $this; + } // setDbToken() + + /** + * Sets the value of [created] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return CcSubjsToken The current object (for fluent API support) + */ + public function setDbCreated($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->created !== null || $dt !== null) { + $currentDateAsString = ($this->created !== null && $tmpDt = new DateTime($this->created)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->created = $newDateAsString; + $this->modifiedColumns[] = CcSubjsTokenPeer::CREATED; + } + } // if either are not null + + + return $this; + } // setDbCreated() + + /** + * 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 resultset 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->user_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->action = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->token = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->created = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 5; // 5 = CcSubjsTokenPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcSubjsToken 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->user_id !== $this->aCcSubjs->getDbId()) { + $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(CcSubjsTokenPeer::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 = CcSubjsTokenPeer::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 + * @throws Exception + * @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(CcSubjsTokenPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcSubjsTokenQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcSubjsTokenPeer::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); + CcSubjsTokenPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding 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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcSubjsTokenPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcSubjsTokenPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_subjs_token_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcSubjsTokenPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcSubjsTokenPeer::USER_ID)) { + $modifiedColumns[':p' . $index++] = '"user_id"'; + } + if ($this->isColumnModified(CcSubjsTokenPeer::ACTION)) { + $modifiedColumns[':p' . $index++] = '"action"'; + } + if ($this->isColumnModified(CcSubjsTokenPeer::TOKEN)) { + $modifiedColumns[':p' . $index++] = '"token"'; + } + if ($this->isColumnModified(CcSubjsTokenPeer::CREATED)) { + $modifiedColumns[':p' . $index++] = '"created"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_subjs_token" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"user_id"': + $stmt->bindValue($identifier, $this->user_id, PDO::PARAM_INT); + break; + case '"action"': + $stmt->bindValue($identifier, $this->action, PDO::PARAM_STR); + break; + case '"token"': + $stmt->bindValue($identifier, $this->token, PDO::PARAM_STR); + break; + case '"created"': + $stmt->bindValue($identifier, $this->created, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding 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 = CcSubjsTokenPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcSubjsTokenPeer::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->getDbUserId(); + break; + case 2: + return $this->getDbAction(); + break; + case 3: + return $this->getDbToken(); + break; + case 4: + return $this->getDbCreated(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcSubjsToken'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcSubjsToken'][$this->getPrimaryKey()] = true; + $keys = CcSubjsTokenPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbUserId(), + $keys[2] => $this->getDbAction(), + $keys[3] => $this->getDbToken(), + $keys[4] => $this->getDbCreated(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcSubjs) { + $result['CcSubjs'] = $this->aCcSubjs->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcSubjsTokenPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbUserId($value); + break; + case 2: + $this->setDbAction($value); + break; + case 3: + $this->setDbToken($value); + break; + case 4: + $this->setDbCreated($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcSubjsTokenPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbUserId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbAction($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbToken($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbCreated($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(CcSubjsTokenPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcSubjsTokenPeer::ID)) $criteria->add(CcSubjsTokenPeer::ID, $this->id); + if ($this->isColumnModified(CcSubjsTokenPeer::USER_ID)) $criteria->add(CcSubjsTokenPeer::USER_ID, $this->user_id); + if ($this->isColumnModified(CcSubjsTokenPeer::ACTION)) $criteria->add(CcSubjsTokenPeer::ACTION, $this->action); + if ($this->isColumnModified(CcSubjsTokenPeer::TOKEN)) $criteria->add(CcSubjsTokenPeer::TOKEN, $this->token); + if ($this->isColumnModified(CcSubjsTokenPeer::CREATED)) $criteria->add(CcSubjsTokenPeer::CREATED, $this->created); + + 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(CcSubjsTokenPeer::DATABASE_NAME); + $criteria->add(CcSubjsTokenPeer::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 CcSubjsToken (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbUserId($this->getDbUserId()); + $copyObj->setDbAction($this->getDbAction()); + $copyObj->setDbToken($this->getDbToken()); + $copyObj->setDbCreated($this->getDbCreated()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcSubjsToken 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 CcSubjsTokenPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcSubjsTokenPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a CcSubjs object. + * + * @param CcSubjs $v + * @return CcSubjsToken The current object (for fluent API support) + * @throws PropelException + */ + public function setCcSubjs(CcSubjs $v = null) + { + if ($v === null) { + $this->setDbUserId(NULL); + } else { + $this->setDbUserId($v->getDbId()); + } + + $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->addCcSubjsToken($this); + } + + + return $this; + } + + + /** + * Get the associated CcSubjs object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getCcSubjs(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcSubjs === null && ($this->user_id !== null) && $doQuery) { + $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->user_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->aCcSubjs->addCcSubjsTokens($this); + */ + } + + return $this->aCcSubjs; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->user_id = null; + $this->action = null; + $this->token = null; + $this->created = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCcSubjs instanceof Persistent) { + $this->aCcSubjs->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + $this->aCcSubjs = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcSubjsTokenPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcSubjsTokenPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcSubjsTokenPeer.php index 7f08ba6a7..ad2deb491 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcSubjsTokenPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcSubjsTokenPeer.php @@ -1,984 +1,1023 @@ array ('DbId', 'DbUserId', 'DbAction', 'DbToken', 'DbCreated', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbUserId', 'dbAction', 'dbToken', 'dbCreated', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::USER_ID, self::ACTION, self::TOKEN, self::CREATED, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'USER_ID', 'ACTION', 'TOKEN', 'CREATED', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'user_id', 'action', 'token', 'created', ), - 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 ('DbId' => 0, 'DbUserId' => 1, 'DbAction' => 2, 'DbToken' => 3, 'DbCreated' => 4, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbUserId' => 1, 'dbAction' => 2, 'dbToken' => 3, 'dbCreated' => 4, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::USER_ID => 1, self::ACTION => 2, self::TOKEN => 3, self::CREATED => 4, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'USER_ID' => 1, 'ACTION' => 2, 'TOKEN' => 3, 'CREATED' => 4, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'user_id' => 1, 'action' => 2, 'token' => 3, 'created' => 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. CcSubjsTokenPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcSubjsTokenPeer::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(CcSubjsTokenPeer::ID); - $criteria->addSelectColumn(CcSubjsTokenPeer::USER_ID); - $criteria->addSelectColumn(CcSubjsTokenPeer::ACTION); - $criteria->addSelectColumn(CcSubjsTokenPeer::TOKEN); - $criteria->addSelectColumn(CcSubjsTokenPeer::CREATED); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.USER_ID'); - $criteria->addSelectColumn($alias . '.ACTION'); - $criteria->addSelectColumn($alias . '.TOKEN'); - $criteria->addSelectColumn($alias . '.CREATED'); - } - } - - /** - * 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(CcSubjsTokenPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcSubjsTokenPeer::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(CcSubjsTokenPeer::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 CcSubjsToken - * @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 = CcSubjsTokenPeer::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 CcSubjsTokenPeer::populateObjects(CcSubjsTokenPeer::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(CcSubjsTokenPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcSubjsTokenPeer::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 CcSubjsToken $value A CcSubjsToken object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcSubjsToken $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 CcSubjsToken object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcSubjsToken) { - $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 CcSubjsToken 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 CcSubjsToken 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_token - * 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 = CcSubjsTokenPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcSubjsTokenPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcSubjsTokenPeer::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; - CcSubjsTokenPeer::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 (CcSubjsToken object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcSubjsTokenPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcSubjsTokenPeer::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 + CcSubjsTokenPeer::NUM_COLUMNS; - } else { - $cls = CcSubjsTokenPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcSubjsTokenPeer::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(CcSubjsTokenPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcSubjsTokenPeer::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(CcSubjsTokenPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcSubjsTokenPeer::USER_ID, 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 CcSubjsToken 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 CcSubjsToken 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); - } - - CcSubjsTokenPeer::addSelectColumns($criteria); - $startcol = (CcSubjsTokenPeer::NUM_COLUMNS - CcSubjsTokenPeer::NUM_LAZY_LOAD_COLUMNS); - CcSubjsPeer::addSelectColumns($criteria); - - $criteria->addJoin(CcSubjsTokenPeer::USER_ID, CcSubjsPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcSubjsTokenPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcSubjsTokenPeer::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 = CcSubjsTokenPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcSubjsTokenPeer::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 (CcSubjsToken) to $obj2 (CcSubjs) - $obj2->addCcSubjsToken($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(CcSubjsTokenPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcSubjsTokenPeer::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(CcSubjsTokenPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcSubjsTokenPeer::USER_ID, 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 CcSubjsToken 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 CcSubjsToken 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); - } - - CcSubjsTokenPeer::addSelectColumns($criteria); - $startcol2 = (CcSubjsTokenPeer::NUM_COLUMNS - CcSubjsTokenPeer::NUM_LAZY_LOAD_COLUMNS); - - CcSubjsPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcSubjsPeer::NUM_COLUMNS - CcSubjsPeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcSubjsTokenPeer::USER_ID, CcSubjsPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcSubjsTokenPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcSubjsTokenPeer::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 = CcSubjsTokenPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcSubjsTokenPeer::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 (CcSubjsToken) to the collection in $obj2 (CcSubjs) - $obj2->addCcSubjsToken($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(BaseCcSubjsTokenPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcSubjsTokenPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcSubjsTokenTableMap()); - } - } - - /** - * 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 ? CcSubjsTokenPeer::CLASS_DEFAULT : CcSubjsTokenPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcSubjsToken or Criteria object. - * - * @param mixed $values Criteria or CcSubjsToken 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(CcSubjsTokenPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcSubjsToken object - } - - if ($criteria->containsKey(CcSubjsTokenPeer::ID) && $criteria->keyContainsValue(CcSubjsTokenPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSubjsTokenPeer::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 CcSubjsToken or Criteria object. - * - * @param mixed $values Criteria or CcSubjsToken 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(CcSubjsTokenPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcSubjsTokenPeer::ID); - $value = $criteria->remove(CcSubjsTokenPeer::ID); - if ($value) { - $selectCriteria->add(CcSubjsTokenPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcSubjsTokenPeer::TABLE_NAME); - } - - } else { // $values is CcSubjsToken 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_token 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(CcSubjsTokenPeer::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(CcSubjsTokenPeer::TABLE_NAME, $con, CcSubjsTokenPeer::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). - CcSubjsTokenPeer::clearInstancePool(); - CcSubjsTokenPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcSubjsToken or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcSubjsToken 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(CcSubjsTokenPeer::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. - CcSubjsTokenPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcSubjsToken) { // it's a model object - // invalidate the cache for this single object - CcSubjsTokenPeer::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(CcSubjsTokenPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcSubjsTokenPeer::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); - CcSubjsTokenPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcSubjsToken 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 CcSubjsToken $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(CcSubjsToken $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcSubjsTokenPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcSubjsTokenPeer::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(CcSubjsTokenPeer::DATABASE_NAME, CcSubjsTokenPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcSubjsToken - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcSubjsTokenPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcSubjsTokenPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcSubjsTokenPeer::DATABASE_NAME); - $criteria->add(CcSubjsTokenPeer::ID, $pk); - - $v = CcSubjsTokenPeer::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(CcSubjsTokenPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcSubjsTokenPeer::DATABASE_NAME); - $criteria->add(CcSubjsTokenPeer::ID, $pks, Criteria::IN); - $objs = CcSubjsTokenPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcSubjsTokenPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_subjs_token'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcSubjsToken'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcSubjsTokenTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 5; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 5; + + /** the column name for the id field */ + const ID = 'cc_subjs_token.id'; + + /** the column name for the user_id field */ + const USER_ID = 'cc_subjs_token.user_id'; + + /** the column name for the action field */ + const ACTION = 'cc_subjs_token.action'; + + /** the column name for the token field */ + const TOKEN = 'cc_subjs_token.token'; + + /** the column name for the created field */ + const CREATED = 'cc_subjs_token.created'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcSubjsToken objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcSubjsToken[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcSubjsTokenPeer::$fieldNames[CcSubjsTokenPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbUserId', 'DbAction', 'DbToken', 'DbCreated', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbUserId', 'dbAction', 'dbToken', 'dbCreated', ), + BasePeer::TYPE_COLNAME => array (CcSubjsTokenPeer::ID, CcSubjsTokenPeer::USER_ID, CcSubjsTokenPeer::ACTION, CcSubjsTokenPeer::TOKEN, CcSubjsTokenPeer::CREATED, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'USER_ID', 'ACTION', 'TOKEN', 'CREATED', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'user_id', 'action', 'token', 'created', ), + 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. CcSubjsTokenPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbUserId' => 1, 'DbAction' => 2, 'DbToken' => 3, 'DbCreated' => 4, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbUserId' => 1, 'dbAction' => 2, 'dbToken' => 3, 'dbCreated' => 4, ), + BasePeer::TYPE_COLNAME => array (CcSubjsTokenPeer::ID => 0, CcSubjsTokenPeer::USER_ID => 1, CcSubjsTokenPeer::ACTION => 2, CcSubjsTokenPeer::TOKEN => 3, CcSubjsTokenPeer::CREATED => 4, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'USER_ID' => 1, 'ACTION' => 2, 'TOKEN' => 3, 'CREATED' => 4, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'user_id' => 1, 'action' => 2, 'token' => 3, 'created' => 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcSubjsTokenPeer::getFieldNames($toType); + $key = isset(CcSubjsTokenPeer::$fieldKeys[$fromType][$name]) ? CcSubjsTokenPeer::$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(CcSubjsTokenPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcSubjsTokenPeer::$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 CcSubjsTokenPeer::$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. CcSubjsTokenPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcSubjsTokenPeer::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(CcSubjsTokenPeer::ID); + $criteria->addSelectColumn(CcSubjsTokenPeer::USER_ID); + $criteria->addSelectColumn(CcSubjsTokenPeer::ACTION); + $criteria->addSelectColumn(CcSubjsTokenPeer::TOKEN); + $criteria->addSelectColumn(CcSubjsTokenPeer::CREATED); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.user_id'); + $criteria->addSelectColumn($alias . '.action'); + $criteria->addSelectColumn($alias . '.token'); + $criteria->addSelectColumn($alias . '.created'); + } + } + + /** + * 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(CcSubjsTokenPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcSubjsTokenPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcSubjsTokenPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcSubjsTokenPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcSubjsToken + * @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 = CcSubjsTokenPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcSubjsTokenPeer::populateObjects(CcSubjsTokenPeer::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 directly (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(CcSubjsTokenPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcSubjsTokenPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcSubjsTokenPeer::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 CcSubjsToken $obj A CcSubjsToken object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcSubjsTokenPeer::$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 CcSubjsToken object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcSubjsToken) { + $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 CcSubjsToken object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcSubjsTokenPeer::$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 CcSubjsToken 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(CcSubjsTokenPeer::$instances[$key])) { + return CcSubjsTokenPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcSubjsTokenPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcSubjsTokenPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_subjs_token + * 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 = CcSubjsTokenPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcSubjsTokenPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcSubjsTokenPeer::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; + CcSubjsTokenPeer::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 (CcSubjsToken object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcSubjsTokenPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcSubjsTokenPeer::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 + CcSubjsTokenPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcSubjsTokenPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcSubjsTokenPeer::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(CcSubjsTokenPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcSubjsTokenPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcSubjsTokenPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcSubjsTokenPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcSubjsTokenPeer::USER_ID, 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 CcSubjsToken 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 CcSubjsToken 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(CcSubjsTokenPeer::DATABASE_NAME); + } + + CcSubjsTokenPeer::addSelectColumns($criteria); + $startcol = CcSubjsTokenPeer::NUM_HYDRATE_COLUMNS; + CcSubjsPeer::addSelectColumns($criteria); + + $criteria->addJoin(CcSubjsTokenPeer::USER_ID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcSubjsTokenPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcSubjsTokenPeer::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 = CcSubjsTokenPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcSubjsTokenPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcSubjsToken) to $obj2 (CcSubjs) + $obj2->addCcSubjsToken($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(CcSubjsTokenPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcSubjsTokenPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcSubjsTokenPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcSubjsTokenPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcSubjsTokenPeer::USER_ID, 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 CcSubjsToken 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 CcSubjsToken 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(CcSubjsTokenPeer::DATABASE_NAME); + } + + CcSubjsTokenPeer::addSelectColumns($criteria); + $startcol2 = CcSubjsTokenPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcSubjsTokenPeer::USER_ID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcSubjsTokenPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcSubjsTokenPeer::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 = CcSubjsTokenPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcSubjsTokenPeer::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(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcSubjsToken) to the collection in $obj2 (CcSubjs) + $obj2->addCcSubjsToken($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(CcSubjsTokenPeer::DATABASE_NAME)->getTable(CcSubjsTokenPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcSubjsTokenPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcSubjsTokenPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcSubjsTokenTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcSubjsTokenPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcSubjsToken or Criteria object. + * + * @param mixed $values Criteria or CcSubjsToken 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(CcSubjsTokenPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcSubjsToken object + } + + if ($criteria->containsKey(CcSubjsTokenPeer::ID) && $criteria->keyContainsValue(CcSubjsTokenPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSubjsTokenPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcSubjsTokenPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcSubjsToken or Criteria object. + * + * @param mixed $values Criteria or CcSubjsToken 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(CcSubjsTokenPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcSubjsTokenPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcSubjsTokenPeer::ID); + $value = $criteria->remove(CcSubjsTokenPeer::ID); + if ($value) { + $selectCriteria->add(CcSubjsTokenPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcSubjsTokenPeer::TABLE_NAME); + } + + } else { // $values is CcSubjsToken object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcSubjsTokenPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_subjs_token table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcSubjsTokenPeer::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(CcSubjsTokenPeer::TABLE_NAME, $con, CcSubjsTokenPeer::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). + CcSubjsTokenPeer::clearInstancePool(); + CcSubjsTokenPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcSubjsToken or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcSubjsToken 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(CcSubjsTokenPeer::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. + CcSubjsTokenPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcSubjsToken) { // it's a model object + // invalidate the cache for this single object + CcSubjsTokenPeer::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(CcSubjsTokenPeer::DATABASE_NAME); + $criteria->add(CcSubjsTokenPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcSubjsTokenPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcSubjsTokenPeer::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); + CcSubjsTokenPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcSubjsToken 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 CcSubjsToken $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcSubjsTokenPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcSubjsTokenPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcSubjsTokenPeer::DATABASE_NAME, CcSubjsTokenPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcSubjsToken + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcSubjsTokenPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcSubjsTokenPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcSubjsTokenPeer::DATABASE_NAME); + $criteria->add(CcSubjsTokenPeer::ID, $pk); + + $v = CcSubjsTokenPeer::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 + * @return CcSubjsToken[] + * @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(CcSubjsTokenPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcSubjsTokenPeer::DATABASE_NAME); + $criteria->add(CcSubjsTokenPeer::ID, $pks, Criteria::IN); + $objs = CcSubjsTokenPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcSubjsTokenPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcSubjsTokenQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcSubjsTokenQuery.php index c2ee6f7bf..d73c0d535 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcSubjsTokenQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcSubjsTokenQuery.php @@ -1,355 +1,533 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcSubjsToken|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcSubjsTokenPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcSubjsToken|CcSubjsToken[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcSubjsTokenPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcSubjsTokenPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcSubjsTokenQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcSubjsTokenPeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcSubjsToken A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcSubjsTokenQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcSubjsTokenPeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcSubjsToken A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "user_id", "action", "token", "created" FROM "cc_subjs_token" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcSubjsToken(); + $obj->hydrate($row); + CcSubjsTokenPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcSubjsTokenQuery 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(CcSubjsTokenPeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * Filter the query on the user_id column - * - * @param int|array $dbUserId 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 CcSubjsTokenQuery The current query, for fluid interface - */ - public function filterByDbUserId($dbUserId = null, $comparison = null) - { - if (is_array($dbUserId)) { - $useMinMax = false; - if (isset($dbUserId['min'])) { - $this->addUsingAlias(CcSubjsTokenPeer::USER_ID, $dbUserId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbUserId['max'])) { - $this->addUsingAlias(CcSubjsTokenPeer::USER_ID, $dbUserId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcSubjsTokenPeer::USER_ID, $dbUserId, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcSubjsToken|CcSubjsToken[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Filter the query on the action column - * - * @param string $dbAction 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 CcSubjsTokenQuery The current query, for fluid interface - */ - public function filterByDbAction($dbAction = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbAction)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbAction)) { - $dbAction = str_replace('*', '%', $dbAction); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcSubjsTokenPeer::ACTION, $dbAction, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query on the token column - * - * @param string $dbToken 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 CcSubjsTokenQuery The current query, for fluid interface - */ - public function filterByDbToken($dbToken = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbToken)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbToken)) { - $dbToken = str_replace('*', '%', $dbToken); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcSubjsTokenPeer::TOKEN, $dbToken, $comparison); - } + /** + * 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|CcSubjsToken[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query on the created column - * - * @param string|array $dbCreated 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 CcSubjsTokenQuery The current query, for fluid interface - */ - public function filterByDbCreated($dbCreated = null, $comparison = null) - { - if (is_array($dbCreated)) { - $useMinMax = false; - if (isset($dbCreated['min'])) { - $this->addUsingAlias(CcSubjsTokenPeer::CREATED, $dbCreated['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbCreated['max'])) { - $this->addUsingAlias(CcSubjsTokenPeer::CREATED, $dbCreated['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcSubjsTokenPeer::CREATED, $dbCreated, $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * 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 CcSubjsTokenQuery The current query, for fluid interface - */ - public function filterByCcSubjs($ccSubjs, $comparison = null) - { - return $this - ->addUsingAlias(CcSubjsTokenPeer::USER_ID, $ccSubjs->getDbId(), $comparison); - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcSubjsTokenQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { - /** - * 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 CcSubjsTokenQuery The current query, for fluid interface - */ - public function joinCcSubjs($relationAlias = '', $joinType = Criteria::INNER_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; - } + return $this->addUsingAlias(CcSubjsTokenPeer::ID, $key, Criteria::EQUAL); + } - /** - * 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::INNER_JOIN) - { - return $this - ->joinCcSubjs($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', 'CcSubjsQuery'); - } + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return CcSubjsTokenQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { - /** - * Exclude object from result - * - * @param CcSubjsToken $ccSubjsToken Object to remove from the list of results - * - * @return CcSubjsTokenQuery The current query, for fluid interface - */ - public function prune($ccSubjsToken = null) - { - if ($ccSubjsToken) { - $this->addUsingAlias(CcSubjsTokenPeer::ID, $ccSubjsToken->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + return $this->addUsingAlias(CcSubjsTokenPeer::ID, $keys, Criteria::IN); + } -} // BaseCcSubjsTokenQuery + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcSubjsTokenQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcSubjsTokenPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcSubjsTokenPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcSubjsTokenPeer::ID, $dbId, $comparison); + } + + /** + * Filter the query on the user_id column + * + * Example usage: + * + * $query->filterByDbUserId(1234); // WHERE user_id = 1234 + * $query->filterByDbUserId(array(12, 34)); // WHERE user_id IN (12, 34) + * $query->filterByDbUserId(array('min' => 12)); // WHERE user_id >= 12 + * $query->filterByDbUserId(array('max' => 12)); // WHERE user_id <= 12 + * + * + * @see filterByCcSubjs() + * + * @param mixed $dbUserId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcSubjsTokenQuery The current query, for fluid interface + */ + public function filterByDbUserId($dbUserId = null, $comparison = null) + { + if (is_array($dbUserId)) { + $useMinMax = false; + if (isset($dbUserId['min'])) { + $this->addUsingAlias(CcSubjsTokenPeer::USER_ID, $dbUserId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbUserId['max'])) { + $this->addUsingAlias(CcSubjsTokenPeer::USER_ID, $dbUserId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcSubjsTokenPeer::USER_ID, $dbUserId, $comparison); + } + + /** + * Filter the query on the action column + * + * Example usage: + * + * $query->filterByDbAction('fooValue'); // WHERE action = 'fooValue' + * $query->filterByDbAction('%fooValue%'); // WHERE action LIKE '%fooValue%' + * + * + * @param string $dbAction 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 CcSubjsTokenQuery The current query, for fluid interface + */ + public function filterByDbAction($dbAction = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbAction)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbAction)) { + $dbAction = str_replace('*', '%', $dbAction); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcSubjsTokenPeer::ACTION, $dbAction, $comparison); + } + + /** + * Filter the query on the token column + * + * Example usage: + * + * $query->filterByDbToken('fooValue'); // WHERE token = 'fooValue' + * $query->filterByDbToken('%fooValue%'); // WHERE token LIKE '%fooValue%' + * + * + * @param string $dbToken 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 CcSubjsTokenQuery The current query, for fluid interface + */ + public function filterByDbToken($dbToken = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbToken)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbToken)) { + $dbToken = str_replace('*', '%', $dbToken); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcSubjsTokenPeer::TOKEN, $dbToken, $comparison); + } + + /** + * Filter the query on the created column + * + * Example usage: + * + * $query->filterByDbCreated('2011-03-14'); // WHERE created = '2011-03-14' + * $query->filterByDbCreated('now'); // WHERE created = '2011-03-14' + * $query->filterByDbCreated(array('max' => 'yesterday')); // WHERE created < '2011-03-13' + * + * + * @param mixed $dbCreated The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcSubjsTokenQuery The current query, for fluid interface + */ + public function filterByDbCreated($dbCreated = null, $comparison = null) + { + if (is_array($dbCreated)) { + $useMinMax = false; + if (isset($dbCreated['min'])) { + $this->addUsingAlias(CcSubjsTokenPeer::CREATED, $dbCreated['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbCreated['max'])) { + $this->addUsingAlias(CcSubjsTokenPeer::CREATED, $dbCreated['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcSubjsTokenPeer::CREATED, $dbCreated, $comparison); + } + + /** + * Filter the query by a related CcSubjs object + * + * @param CcSubjs|PropelObjectCollection $ccSubjs The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcSubjsTokenQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcSubjs($ccSubjs, $comparison = null) + { + if ($ccSubjs instanceof CcSubjs) { + return $this + ->addUsingAlias(CcSubjsTokenPeer::USER_ID, $ccSubjs->getDbId(), $comparison); + } elseif ($ccSubjs instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcSubjsTokenPeer::USER_ID, $ccSubjs->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcSubjs() only accepts arguments of type CcSubjs or PropelCollection'); + } + } + + /** + * 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 CcSubjsTokenQuery The current query, for fluid interface + */ + public function joinCcSubjs($relationAlias = null, $joinType = Criteria::INNER_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 \Airtime\CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcSubjs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', '\Airtime\CcSubjsQuery'); + } + + /** + * Exclude object from result + * + * @param CcSubjsToken $ccSubjsToken Object to remove from the list of results + * + * @return CcSubjsTokenQuery The current query, for fluid interface + */ + public function prune($ccSubjsToken = null) + { + if ($ccSubjsToken) { + $this->addUsingAlias(CcSubjsTokenPeer::ID, $ccSubjsToken->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcTag.php b/airtime_mvc/application/models/airtime/om/BaseCcTag.php deleted file mode 100644 index af656868b..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcTag.php +++ /dev/null @@ -1,1306 +0,0 @@ -tag_type = 'boolean'; - } - - /** - * Initializes internal state of BaseCcTag 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 [tag_name] column value. - * - * @return string - */ - public function getDbTagName() - { - return $this->tag_name; - } - - /** - * Get the [tag_type] column value. - * - * @return string - */ - public function getDbTagType() - { - return $this->tag_type; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcTag 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[] = CcTagPeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [tag_name] column. - * - * @param string $v new value - * @return CcTag The current object (for fluent API support) - */ - public function setDbTagName($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->tag_name !== $v) { - $this->tag_name = $v; - $this->modifiedColumns[] = CcTagPeer::TAG_NAME; - } - - return $this; - } // setDbTagName() - - /** - * Set the value of [tag_type] column. - * - * @param string $v new value - * @return CcTag The current object (for fluent API support) - */ - public function setDbTagType($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->tag_type !== $v || $this->isNew()) { - $this->tag_type = $v; - $this->modifiedColumns[] = CcTagPeer::TAG_TYPE; - } - - return $this; - } // setDbTagType() - - /** - * 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->tag_type !== 'boolean') { - 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->tag_name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->tag_type = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 3; // 3 = CcTagPeer::NUM_COLUMNS - CcTagPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcTag 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(CcTagPeer::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 = CcTagPeer::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->collCcFileTags = null; - - $this->collCcPlayoutHistoryMetaDatas = null; - - $this->collCcPlayoutHistoryTemplateTags = 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(CcTagPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcTagQuery::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(CcTagPeer::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); - CcTagPeer::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[] = CcTagPeer::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(CcTagPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcTagPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows = 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows = CcTagPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - if ($this->collCcFileTags !== null) { - foreach ($this->collCcFileTags as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->collCcPlayoutHistoryMetaDatas !== null) { - foreach ($this->collCcPlayoutHistoryMetaDatas as $referrerFK) { - if (!$referrerFK->isDeleted()) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->collCcPlayoutHistoryTemplateTags !== null) { - foreach ($this->collCcPlayoutHistoryTemplateTags 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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CcTagPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collCcFileTags !== null) { - foreach ($this->collCcFileTags as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCcPlayoutHistoryMetaDatas !== null) { - foreach ($this->collCcPlayoutHistoryMetaDatas as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCcPlayoutHistoryTemplateTags !== null) { - foreach ($this->collCcPlayoutHistoryTemplateTags 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 = CcTagPeer::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->getDbTagName(); - break; - case 2: - return $this->getDbTagType(); - 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 = CcTagPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbTagName(), - $keys[2] => $this->getDbTagType(), - ); - 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 = CcTagPeer::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->setDbTagName($value); - break; - case 2: - $this->setDbTagType($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 = CcTagPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbTagName($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbTagType($arr[$keys[2]]); - } - - /** - * 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(CcTagPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcTagPeer::ID)) $criteria->add(CcTagPeer::ID, $this->id); - if ($this->isColumnModified(CcTagPeer::TAG_NAME)) $criteria->add(CcTagPeer::TAG_NAME, $this->tag_name); - if ($this->isColumnModified(CcTagPeer::TAG_TYPE)) $criteria->add(CcTagPeer::TAG_TYPE, $this->tag_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(CcTagPeer::DATABASE_NAME); - $criteria->add(CcTagPeer::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 CcTag (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->setDbTagName($this->tag_name); - $copyObj->setDbTagType($this->tag_type); - - 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->getCcFileTags() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcFileTag($relObj->copy($deepCopy)); - } - } - - foreach ($this->getCcPlayoutHistoryMetaDatas() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcPlayoutHistoryMetaData($relObj->copy($deepCopy)); - } - } - - foreach ($this->getCcPlayoutHistoryTemplateTags() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcPlayoutHistoryTemplateTag($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 CcTag 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 CcTagPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcTagPeer(); - } - return self::$peer; - } - - /** - * Clears out the collCcFileTags 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 addCcFileTags() - */ - public function clearCcFileTags() - { - $this->collCcFileTags = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcFileTags collection. - * - * By default this just sets the collCcFileTags collection to an empty array (like clearcollCcFileTags()); - * 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 initCcFileTags() - { - $this->collCcFileTags = new PropelObjectCollection(); - $this->collCcFileTags->setModel('CcFileTag'); - } - - /** - * Gets an array of CcFileTag 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 CcTag 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 CcFileTag[] List of CcFileTag objects - * @throws PropelException - */ - public function getCcFileTags($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcFileTags || null !== $criteria) { - if ($this->isNew() && null === $this->collCcFileTags) { - // return empty collection - $this->initCcFileTags(); - } else { - $collCcFileTags = CcFileTagQuery::create(null, $criteria) - ->filterByCcTag($this) - ->find($con); - if (null !== $criteria) { - return $collCcFileTags; - } - $this->collCcFileTags = $collCcFileTags; - } - } - return $this->collCcFileTags; - } - - /** - * Returns the number of related CcFileTag objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcFileTag objects. - * @throws PropelException - */ - public function countCcFileTags(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcFileTags || null !== $criteria) { - if ($this->isNew() && null === $this->collCcFileTags) { - return 0; - } else { - $query = CcFileTagQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcTag($this) - ->count($con); - } - } else { - return count($this->collCcFileTags); - } - } - - /** - * Method called to associate a CcFileTag object to this object - * through the CcFileTag foreign key attribute. - * - * @param CcFileTag $l CcFileTag - * @return void - * @throws PropelException - */ - public function addCcFileTag(CcFileTag $l) - { - if ($this->collCcFileTags === null) { - $this->initCcFileTags(); - } - if (!$this->collCcFileTags->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcFileTags[]= $l; - $l->setCcTag($this); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcTag is new, it will return - * an empty collection; or if this CcTag has previously - * been saved, it will retrieve related CcFileTags 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 CcTag. - * - * @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 CcFileTag[] List of CcFileTag objects - */ - public function getCcFileTagsJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcFileTagQuery::create(null, $criteria); - $query->joinWith('CcFiles', $join_behavior); - - return $this->getCcFileTags($query, $con); - } - - /** - * Clears out the collCcPlayoutHistoryMetaDatas 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 addCcPlayoutHistoryMetaDatas() - */ - public function clearCcPlayoutHistoryMetaDatas() - { - $this->collCcPlayoutHistoryMetaDatas = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcPlayoutHistoryMetaDatas collection. - * - * By default this just sets the collCcPlayoutHistoryMetaDatas collection to an empty array (like clearcollCcPlayoutHistoryMetaDatas()); - * 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 initCcPlayoutHistoryMetaDatas() - { - $this->collCcPlayoutHistoryMetaDatas = new PropelObjectCollection(); - $this->collCcPlayoutHistoryMetaDatas->setModel('CcPlayoutHistoryMetaData'); - } - - /** - * Gets an array of CcPlayoutHistoryMetaData 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 CcTag 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 CcPlayoutHistoryMetaData[] List of CcPlayoutHistoryMetaData objects - * @throws PropelException - */ - public function getCcPlayoutHistoryMetaDatas($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcPlayoutHistoryMetaDatas || null !== $criteria) { - if ($this->isNew() && null === $this->collCcPlayoutHistoryMetaDatas) { - // return empty collection - $this->initCcPlayoutHistoryMetaDatas(); - } else { - $collCcPlayoutHistoryMetaDatas = CcPlayoutHistoryMetaDataQuery::create(null, $criteria) - ->filterByCcTag($this) - ->find($con); - if (null !== $criteria) { - return $collCcPlayoutHistoryMetaDatas; - } - $this->collCcPlayoutHistoryMetaDatas = $collCcPlayoutHistoryMetaDatas; - } - } - return $this->collCcPlayoutHistoryMetaDatas; - } - - /** - * Returns the number of related CcPlayoutHistoryMetaData objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcPlayoutHistoryMetaData objects. - * @throws PropelException - */ - public function countCcPlayoutHistoryMetaDatas(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcPlayoutHistoryMetaDatas || null !== $criteria) { - if ($this->isNew() && null === $this->collCcPlayoutHistoryMetaDatas) { - return 0; - } else { - $query = CcPlayoutHistoryMetaDataQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcTag($this) - ->count($con); - } - } else { - return count($this->collCcPlayoutHistoryMetaDatas); - } - } - - /** - * Method called to associate a CcPlayoutHistoryMetaData object to this object - * through the CcPlayoutHistoryMetaData foreign key attribute. - * - * @param CcPlayoutHistoryMetaData $l CcPlayoutHistoryMetaData - * @return void - * @throws PropelException - */ - public function addCcPlayoutHistoryMetaData(CcPlayoutHistoryMetaData $l) - { - if ($this->collCcPlayoutHistoryMetaDatas === null) { - $this->initCcPlayoutHistoryMetaDatas(); - } - if (!$this->collCcPlayoutHistoryMetaDatas->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcPlayoutHistoryMetaDatas[]= $l; - $l->setCcTag($this); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcTag is new, it will return - * an empty collection; or if this CcTag has previously - * been saved, it will retrieve related CcPlayoutHistoryMetaDatas 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 CcTag. - * - * @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 CcPlayoutHistoryMetaData[] List of CcPlayoutHistoryMetaData objects - */ - public function getCcPlayoutHistoryMetaDatasJoinCcPlayoutHistory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcPlayoutHistoryMetaDataQuery::create(null, $criteria); - $query->joinWith('CcPlayoutHistory', $join_behavior); - - return $this->getCcPlayoutHistoryMetaDatas($query, $con); - } - - /** - * Clears out the collCcPlayoutHistoryTemplateTags 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 addCcPlayoutHistoryTemplateTags() - */ - public function clearCcPlayoutHistoryTemplateTags() - { - $this->collCcPlayoutHistoryTemplateTags = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcPlayoutHistoryTemplateTags collection. - * - * By default this just sets the collCcPlayoutHistoryTemplateTags collection to an empty array (like clearcollCcPlayoutHistoryTemplateTags()); - * 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 initCcPlayoutHistoryTemplateTags() - { - $this->collCcPlayoutHistoryTemplateTags = new PropelObjectCollection(); - $this->collCcPlayoutHistoryTemplateTags->setModel('CcPlayoutHistoryTemplateTag'); - } - - /** - * Gets an array of CcPlayoutHistoryTemplateTag 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 CcTag 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 CcPlayoutHistoryTemplateTag[] List of CcPlayoutHistoryTemplateTag objects - * @throws PropelException - */ - public function getCcPlayoutHistoryTemplateTags($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcPlayoutHistoryTemplateTags || null !== $criteria) { - if ($this->isNew() && null === $this->collCcPlayoutHistoryTemplateTags) { - // return empty collection - $this->initCcPlayoutHistoryTemplateTags(); - } else { - $collCcPlayoutHistoryTemplateTags = CcPlayoutHistoryTemplateTagQuery::create(null, $criteria) - ->filterByCcTag($this) - ->find($con); - if (null !== $criteria) { - return $collCcPlayoutHistoryTemplateTags; - } - $this->collCcPlayoutHistoryTemplateTags = $collCcPlayoutHistoryTemplateTags; - } - } - return $this->collCcPlayoutHistoryTemplateTags; - } - - /** - * Returns the number of related CcPlayoutHistoryTemplateTag objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcPlayoutHistoryTemplateTag objects. - * @throws PropelException - */ - public function countCcPlayoutHistoryTemplateTags(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcPlayoutHistoryTemplateTags || null !== $criteria) { - if ($this->isNew() && null === $this->collCcPlayoutHistoryTemplateTags) { - return 0; - } else { - $query = CcPlayoutHistoryTemplateTagQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcTag($this) - ->count($con); - } - } else { - return count($this->collCcPlayoutHistoryTemplateTags); - } - } - - /** - * Method called to associate a CcPlayoutHistoryTemplateTag object to this object - * through the CcPlayoutHistoryTemplateTag foreign key attribute. - * - * @param CcPlayoutHistoryTemplateTag $l CcPlayoutHistoryTemplateTag - * @return void - * @throws PropelException - */ - public function addCcPlayoutHistoryTemplateTag(CcPlayoutHistoryTemplateTag $l) - { - if ($this->collCcPlayoutHistoryTemplateTags === null) { - $this->initCcPlayoutHistoryTemplateTags(); - } - if (!$this->collCcPlayoutHistoryTemplateTags->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcPlayoutHistoryTemplateTags[]= $l; - $l->setCcTag($this); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcTag is new, it will return - * an empty collection; or if this CcTag has previously - * been saved, it will retrieve related CcPlayoutHistoryTemplateTags 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 CcTag. - * - * @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 CcPlayoutHistoryTemplateTag[] List of CcPlayoutHistoryTemplateTag objects - */ - public function getCcPlayoutHistoryTemplateTagsJoinCcPlayoutHistoryTemplate($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcPlayoutHistoryTemplateTagQuery::create(null, $criteria); - $query->joinWith('CcPlayoutHistoryTemplate', $join_behavior); - - return $this->getCcPlayoutHistoryTemplateTags($query, $con); - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->tag_name = null; - $this->tag_type = 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->collCcFileTags) { - foreach ((array) $this->collCcFileTags as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCcPlayoutHistoryMetaDatas) { - foreach ((array) $this->collCcPlayoutHistoryMetaDatas as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCcPlayoutHistoryTemplateTags) { - foreach ((array) $this->collCcPlayoutHistoryTemplateTags as $o) { - $o->clearAllReferences($deep); - } - } - } // if ($deep) - - $this->collCcFileTags = null; - $this->collCcPlayoutHistoryMetaDatas = null; - $this->collCcPlayoutHistoryTemplateTags = 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); - } - -} // BaseCcTag diff --git a/airtime_mvc/application/models/airtime/om/BaseCcTagPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcTagPeer.php deleted file mode 100644 index 6a68b6ede..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcTagPeer.php +++ /dev/null @@ -1,753 +0,0 @@ - array ('DbId', 'DbTagName', 'DbTagType', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbTagName', 'dbTagType', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::TAG_NAME, self::TAG_TYPE, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TAG_NAME', 'TAG_TYPE', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'tag_name', 'tag_type', ), - BasePeer::TYPE_NUM => array (0, 1, 2, ) - ); - - /** - * 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, 'DbTagName' => 1, 'DbTagType' => 2, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbTagName' => 1, 'dbTagType' => 2, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::TAG_NAME => 1, self::TAG_TYPE => 2, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TAG_NAME' => 1, 'TAG_TYPE' => 2, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'tag_name' => 1, 'tag_type' => 2, ), - BasePeer::TYPE_NUM => array (0, 1, 2, ) - ); - - /** - * 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. CcTagPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcTagPeer::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(CcTagPeer::ID); - $criteria->addSelectColumn(CcTagPeer::TAG_NAME); - $criteria->addSelectColumn(CcTagPeer::TAG_TYPE); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.TAG_NAME'); - $criteria->addSelectColumn($alias . '.TAG_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(CcTagPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcTagPeer::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(CcTagPeer::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 CcTag - * @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 = CcTagPeer::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 CcTagPeer::populateObjects(CcTagPeer::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(CcTagPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcTagPeer::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 CcTag $value A CcTag object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcTag $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 CcTag object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcTag) { - $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 CcTag 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 CcTag 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_tag - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in CcFileTagPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcFileTagPeer::clearInstancePool(); - // Invalidate objects in CcPlayoutHistoryMetaDataPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcPlayoutHistoryMetaDataPeer::clearInstancePool(); - // Invalidate objects in CcPlayoutHistoryTemplateTagPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcPlayoutHistoryTemplateTagPeer::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 = CcTagPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcTagPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcTagPeer::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; - CcTagPeer::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 (CcTag object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcTagPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcTagPeer::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 + CcTagPeer::NUM_COLUMNS; - } else { - $cls = CcTagPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcTagPeer::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(BaseCcTagPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcTagPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcTagTableMap()); - } - } - - /** - * 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 ? CcTagPeer::CLASS_DEFAULT : CcTagPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcTag or Criteria object. - * - * @param mixed $values Criteria or CcTag 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(CcTagPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcTag object - } - - if ($criteria->containsKey(CcTagPeer::ID) && $criteria->keyContainsValue(CcTagPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcTagPeer::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 CcTag or Criteria object. - * - * @param mixed $values Criteria or CcTag 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(CcTagPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcTagPeer::ID); - $value = $criteria->remove(CcTagPeer::ID); - if ($value) { - $selectCriteria->add(CcTagPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcTagPeer::TABLE_NAME); - } - - } else { // $values is CcTag 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_tag 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(CcTagPeer::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(CcTagPeer::TABLE_NAME, $con, CcTagPeer::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). - CcTagPeer::clearInstancePool(); - CcTagPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcTag or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcTag 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(CcTagPeer::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. - CcTagPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcTag) { // it's a model object - // invalidate the cache for this single object - CcTagPeer::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(CcTagPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcTagPeer::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); - CcTagPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcTag 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 CcTag $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(CcTag $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcTagPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcTagPeer::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(CcTagPeer::DATABASE_NAME, CcTagPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcTag - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcTagPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcTagPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcTagPeer::DATABASE_NAME); - $criteria->add(CcTagPeer::ID, $pk); - - $v = CcTagPeer::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(CcTagPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcTagPeer::DATABASE_NAME); - $criteria->add(CcTagPeer::ID, $pks, Criteria::IN); - $objs = CcTagPeer::doSelect($criteria, $con); - } - return $objs; - } - -} // BaseCcTagPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseCcTagPeer::buildTableMap(); - diff --git a/airtime_mvc/application/models/airtime/om/BaseCcTagQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcTagQuery.php deleted file mode 100644 index c90d8cb09..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcTagQuery.php +++ /dev/null @@ -1,421 +0,0 @@ -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 CcTag|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcTagPeer::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 CcTagQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcTagPeer::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 CcTagQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcTagPeer::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 CcTagQuery 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(CcTagPeer::ID, $dbId, $comparison); - } - - /** - * Filter the query on the tag_name column - * - * @param string $dbTagName 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 CcTagQuery The current query, for fluid interface - */ - public function filterByDbTagName($dbTagName = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbTagName)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbTagName)) { - $dbTagName = str_replace('*', '%', $dbTagName); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcTagPeer::TAG_NAME, $dbTagName, $comparison); - } - - /** - * Filter the query on the tag_type column - * - * @param string $dbTagType 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 CcTagQuery The current query, for fluid interface - */ - public function filterByDbTagType($dbTagType = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbTagType)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbTagType)) { - $dbTagType = str_replace('*', '%', $dbTagType); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcTagPeer::TAG_TYPE, $dbTagType, $comparison); - } - - /** - * Filter the query by a related CcFileTag object - * - * @param CcFileTag $ccFileTag the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcTagQuery The current query, for fluid interface - */ - public function filterByCcFileTag($ccFileTag, $comparison = null) - { - return $this - ->addUsingAlias(CcTagPeer::ID, $ccFileTag->getDbTagId(), $comparison); - } - - /** - * Adds a JOIN clause to the query using the CcFileTag relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcTagQuery The current query, for fluid interface - */ - public function joinCcFileTag($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcFileTag'); - - // 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, 'CcFileTag'); - } - - return $this; - } - - /** - * Use the CcFileTag relation CcFileTag 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 CcFileTagQuery A secondary query class using the current class as primary query - */ - public function useCcFileTagQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcFileTag($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcFileTag', 'CcFileTagQuery'); - } - - /** - * Filter the query by a related CcPlayoutHistoryMetaData object - * - * @param CcPlayoutHistoryMetaData $ccPlayoutHistoryMetaData the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcTagQuery The current query, for fluid interface - */ - public function filterByCcPlayoutHistoryMetaData($ccPlayoutHistoryMetaData, $comparison = null) - { - return $this - ->addUsingAlias(CcTagPeer::ID, $ccPlayoutHistoryMetaData->getDbTagId(), $comparison); - } - - /** - * Adds a JOIN clause to the query using the CcPlayoutHistoryMetaData relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcTagQuery The current query, for fluid interface - */ - public function joinCcPlayoutHistoryMetaData($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcPlayoutHistoryMetaData'); - - // 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, 'CcPlayoutHistoryMetaData'); - } - - return $this; - } - - /** - * Use the CcPlayoutHistoryMetaData relation CcPlayoutHistoryMetaData 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 CcPlayoutHistoryMetaDataQuery A secondary query class using the current class as primary query - */ - public function useCcPlayoutHistoryMetaDataQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcPlayoutHistoryMetaData($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcPlayoutHistoryMetaData', 'CcPlayoutHistoryMetaDataQuery'); - } - - /** - * Filter the query by a related CcPlayoutHistoryTemplateTag object - * - * @param CcPlayoutHistoryTemplateTag $ccPlayoutHistoryTemplateTag the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcTagQuery The current query, for fluid interface - */ - public function filterByCcPlayoutHistoryTemplateTag($ccPlayoutHistoryTemplateTag, $comparison = null) - { - return $this - ->addUsingAlias(CcTagPeer::ID, $ccPlayoutHistoryTemplateTag->getDbTagId(), $comparison); - } - - /** - * Adds a JOIN clause to the query using the CcPlayoutHistoryTemplateTag relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcTagQuery The current query, for fluid interface - */ - public function joinCcPlayoutHistoryTemplateTag($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcPlayoutHistoryTemplateTag'); - - // 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, 'CcPlayoutHistoryTemplateTag'); - } - - return $this; - } - - /** - * Use the CcPlayoutHistoryTemplateTag relation CcPlayoutHistoryTemplateTag 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 CcPlayoutHistoryTemplateTagQuery A secondary query class using the current class as primary query - */ - public function useCcPlayoutHistoryTemplateTagQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcPlayoutHistoryTemplateTag($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcPlayoutHistoryTemplateTag', 'CcPlayoutHistoryTemplateTagQuery'); - } - - /** - * Exclude object from result - * - * @param CcTag $ccTag Object to remove from the list of results - * - * @return CcTagQuery The current query, for fluid interface - */ - public function prune($ccTag = null) - { - if ($ccTag) { - $this->addUsingAlias(CcTagPeer::ID, $ccTag->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } - -} // BaseCcTagQuery diff --git a/airtime_mvc/application/models/airtime/om/BaseCcTimestamp.php b/airtime_mvc/application/models/airtime/om/BaseCcTimestamp.php index d61b8e513..4776e4888 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcTimestamp.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcTimestamp.php @@ -1,945 +1,1212 @@ id; - } - - /** - * Get the [optionally formatted] temporal [timestamp] 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 getDbTimestamp($format = 'Y-m-d H:i:s') - { - if ($this->timestamp === null) { - return null; - } - - - - try { - $dt = new DateTime($this->timestamp); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->timestamp, 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 CcTimestamp 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[] = CcTimestampPeer::ID; - } - - return $this; - } // setDbId() - - /** - * Sets the value of [timestamp] 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 CcTimestamp The current object (for fluent API support) - */ - public function setDbTimestamp($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->timestamp !== null || $dt !== null ) { - // (nested ifs are a little easier to read in this case) - - $currNorm = ($this->timestamp !== null && $tmpDt = new DateTime($this->timestamp)) ? $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->timestamp = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); - $this->modifiedColumns[] = CcTimestampPeer::TIMESTAMP; - } - } // if either are not null - - return $this; - } // setDbTimestamp() - - /** - * 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->timestamp = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 2; // 2 = CcTimestampPeer::NUM_COLUMNS - CcTimestampPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcTimestamp 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(CcTimestampPeer::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 = CcTimestampPeer::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->collCcListenerCounts = 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(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcTimestampQuery::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(CcTimestampPeer::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); - CcTimestampPeer::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[] = CcTimestampPeer::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(CcTimestampPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcTimestampPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows = 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows = CcTimestampPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - if ($this->collCcListenerCounts !== null) { - foreach ($this->collCcListenerCounts 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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CcTimestampPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collCcListenerCounts !== null) { - foreach ($this->collCcListenerCounts 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 = CcTimestampPeer::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->getDbTimestamp(); - 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 = CcTimestampPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbTimestamp(), - ); - 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 = CcTimestampPeer::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->setDbTimestamp($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 = CcTimestampPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbTimestamp($arr[$keys[1]]); - } - - /** - * 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(CcTimestampPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcTimestampPeer::ID)) $criteria->add(CcTimestampPeer::ID, $this->id); - if ($this->isColumnModified(CcTimestampPeer::TIMESTAMP)) $criteria->add(CcTimestampPeer::TIMESTAMP, $this->timestamp); - - 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(CcTimestampPeer::DATABASE_NAME); - $criteria->add(CcTimestampPeer::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 CcTimestamp (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->setDbTimestamp($this->timestamp); - - 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->getCcListenerCounts() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcListenerCount($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 CcTimestamp 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 CcTimestampPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcTimestampPeer(); - } - return self::$peer; - } - - /** - * Clears out the collCcListenerCounts 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 addCcListenerCounts() - */ - public function clearCcListenerCounts() - { - $this->collCcListenerCounts = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcListenerCounts collection. - * - * By default this just sets the collCcListenerCounts collection to an empty array (like clearcollCcListenerCounts()); - * 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 initCcListenerCounts() - { - $this->collCcListenerCounts = new PropelObjectCollection(); - $this->collCcListenerCounts->setModel('CcListenerCount'); - } - - /** - * Gets an array of CcListenerCount 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 CcTimestamp 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 CcListenerCount[] List of CcListenerCount objects - * @throws PropelException - */ - public function getCcListenerCounts($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcListenerCounts || null !== $criteria) { - if ($this->isNew() && null === $this->collCcListenerCounts) { - // return empty collection - $this->initCcListenerCounts(); - } else { - $collCcListenerCounts = CcListenerCountQuery::create(null, $criteria) - ->filterByCcTimestamp($this) - ->find($con); - if (null !== $criteria) { - return $collCcListenerCounts; - } - $this->collCcListenerCounts = $collCcListenerCounts; - } - } - return $this->collCcListenerCounts; - } - - /** - * Returns the number of related CcListenerCount objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcListenerCount objects. - * @throws PropelException - */ - public function countCcListenerCounts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcListenerCounts || null !== $criteria) { - if ($this->isNew() && null === $this->collCcListenerCounts) { - return 0; - } else { - $query = CcListenerCountQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcTimestamp($this) - ->count($con); - } - } else { - return count($this->collCcListenerCounts); - } - } - - /** - * Method called to associate a CcListenerCount object to this object - * through the CcListenerCount foreign key attribute. - * - * @param CcListenerCount $l CcListenerCount - * @return void - * @throws PropelException - */ - public function addCcListenerCount(CcListenerCount $l) - { - if ($this->collCcListenerCounts === null) { - $this->initCcListenerCounts(); - } - if (!$this->collCcListenerCounts->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcListenerCounts[]= $l; - $l->setCcTimestamp($this); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcTimestamp is new, it will return - * an empty collection; or if this CcTimestamp has previously - * been saved, it will retrieve related CcListenerCounts 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 CcTimestamp. - * - * @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 CcListenerCount[] List of CcListenerCount objects - */ - public function getCcListenerCountsJoinCcMountName($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcListenerCountQuery::create(null, $criteria); - $query->joinWith('CcMountName', $join_behavior); - - return $this->getCcListenerCounts($query, $con); - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->timestamp = 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 ($this->collCcListenerCounts) { - foreach ((array) $this->collCcListenerCounts as $o) { - $o->clearAllReferences($deep); - } - } - } // if ($deep) - - $this->collCcListenerCounts = 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); - } - -} // BaseCcTimestamp + /** + * Peer class name + */ + const PEER = 'Airtime\\CcTimestampPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcTimestampPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the timestamp field. + * @var string + */ + protected $timestamp; + + /** + * @var PropelObjectCollection|CcListenerCount[] Collection to store aggregation of CcListenerCount objects. + */ + protected $collCcListenerCounts; + protected $collCcListenerCountsPartial; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccListenerCountsScheduledForDeletion = null; + + /** + * Get the [id] column value. + * + * @return int + */ + public function getDbId() + { + + return $this->id; + } + + /** + * Get the [optionally formatted] temporal [timestamp] 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 getDbTimestamp($format = 'Y-m-d H:i:s') + { + if ($this->timestamp === null) { + return null; + } + + + try { + $dt = new DateTime($this->timestamp); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->timestamp, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcTimestamp The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcTimestampPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Sets the value of [timestamp] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return CcTimestamp The current object (for fluent API support) + */ + public function setDbTimestamp($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->timestamp !== null || $dt !== null) { + $currentDateAsString = ($this->timestamp !== null && $tmpDt = new DateTime($this->timestamp)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->timestamp = $newDateAsString; + $this->modifiedColumns[] = CcTimestampPeer::TIMESTAMP; + } + } // if either are not null + + + return $this; + } // setDbTimestamp() + + /** + * 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 resultset 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->timestamp = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 2; // 2 = CcTimestampPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcTimestamp 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(CcTimestampPeer::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 = CcTimestampPeer::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->collCcListenerCounts = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcTimestampQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcTimestampPeer::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); + CcTimestampPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->ccListenerCountsScheduledForDeletion !== null) { + if (!$this->ccListenerCountsScheduledForDeletion->isEmpty()) { + CcListenerCountQuery::create() + ->filterByPrimaryKeys($this->ccListenerCountsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccListenerCountsScheduledForDeletion = null; + } + } + + if ($this->collCcListenerCounts !== null) { + foreach ($this->collCcListenerCounts as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcTimestampPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcTimestampPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_timestamp_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcTimestampPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcTimestampPeer::TIMESTAMP)) { + $modifiedColumns[':p' . $index++] = '"timestamp"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_timestamp" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"timestamp"': + $stmt->bindValue($identifier, $this->timestamp, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcTimestampPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collCcListenerCounts !== null) { + foreach ($this->collCcListenerCounts 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcTimestampPeer::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->getDbTimestamp(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcTimestamp'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcTimestamp'][$this->getPrimaryKey()] = true; + $keys = CcTimestampPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbTimestamp(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->collCcListenerCounts) { + $result['CcListenerCounts'] = $this->collCcListenerCounts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcTimestampPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbTimestamp($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcTimestampPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbTimestamp($arr[$keys[1]]); + } + + /** + * 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(CcTimestampPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcTimestampPeer::ID)) $criteria->add(CcTimestampPeer::ID, $this->id); + if ($this->isColumnModified(CcTimestampPeer::TIMESTAMP)) $criteria->add(CcTimestampPeer::TIMESTAMP, $this->timestamp); + + 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(CcTimestampPeer::DATABASE_NAME); + $criteria->add(CcTimestampPeer::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 CcTimestamp (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbTimestamp($this->getDbTimestamp()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + foreach ($this->getCcListenerCounts() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcListenerCount($relObj->copy($deepCopy)); + } + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcTimestamp 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 CcTimestampPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcTimestampPeer(); + } + + return self::$peer; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('CcListenerCount' == $relationName) { + $this->initCcListenerCounts(); + } + } + + /** + * Clears out the collCcListenerCounts 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 CcTimestamp The current object (for fluent API support) + * @see addCcListenerCounts() + */ + public function clearCcListenerCounts() + { + $this->collCcListenerCounts = null; // important to set this to null since that means it is uninitialized + $this->collCcListenerCountsPartial = null; + + return $this; + } + + /** + * reset is the collCcListenerCounts collection loaded partially + * + * @return void + */ + public function resetPartialCcListenerCounts($v = true) + { + $this->collCcListenerCountsPartial = $v; + } + + /** + * Initializes the collCcListenerCounts collection. + * + * By default this just sets the collCcListenerCounts collection to an empty array (like clearcollCcListenerCounts()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcListenerCounts($overrideExisting = true) + { + if (null !== $this->collCcListenerCounts && !$overrideExisting) { + return; + } + $this->collCcListenerCounts = new PropelObjectCollection(); + $this->collCcListenerCounts->setModel('CcListenerCount'); + } + + /** + * Gets an array of CcListenerCount 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 CcTimestamp 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 PropelObjectCollection|CcListenerCount[] List of CcListenerCount objects + * @throws PropelException + */ + public function getCcListenerCounts($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcListenerCountsPartial && !$this->isNew(); + if (null === $this->collCcListenerCounts || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcListenerCounts) { + // return empty collection + $this->initCcListenerCounts(); + } else { + $collCcListenerCounts = CcListenerCountQuery::create(null, $criteria) + ->filterByCcTimestamp($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcListenerCountsPartial && count($collCcListenerCounts)) { + $this->initCcListenerCounts(false); + + foreach ($collCcListenerCounts as $obj) { + if (false == $this->collCcListenerCounts->contains($obj)) { + $this->collCcListenerCounts->append($obj); + } + } + + $this->collCcListenerCountsPartial = true; + } + + $collCcListenerCounts->getInternalIterator()->rewind(); + + return $collCcListenerCounts; + } + + if ($partial && $this->collCcListenerCounts) { + foreach ($this->collCcListenerCounts as $obj) { + if ($obj->isNew()) { + $collCcListenerCounts[] = $obj; + } + } + } + + $this->collCcListenerCounts = $collCcListenerCounts; + $this->collCcListenerCountsPartial = false; + } + } + + return $this->collCcListenerCounts; + } + + /** + * Sets a collection of CcListenerCount objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccListenerCounts A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcTimestamp The current object (for fluent API support) + */ + public function setCcListenerCounts(PropelCollection $ccListenerCounts, PropelPDO $con = null) + { + $ccListenerCountsToDelete = $this->getCcListenerCounts(new Criteria(), $con)->diff($ccListenerCounts); + + + $this->ccListenerCountsScheduledForDeletion = $ccListenerCountsToDelete; + + foreach ($ccListenerCountsToDelete as $ccListenerCountRemoved) { + $ccListenerCountRemoved->setCcTimestamp(null); + } + + $this->collCcListenerCounts = null; + foreach ($ccListenerCounts as $ccListenerCount) { + $this->addCcListenerCount($ccListenerCount); + } + + $this->collCcListenerCounts = $ccListenerCounts; + $this->collCcListenerCountsPartial = false; + + return $this; + } + + /** + * Returns the number of related CcListenerCount objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcListenerCount objects. + * @throws PropelException + */ + public function countCcListenerCounts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcListenerCountsPartial && !$this->isNew(); + if (null === $this->collCcListenerCounts || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcListenerCounts) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcListenerCounts()); + } + $query = CcListenerCountQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcTimestamp($this) + ->count($con); + } + + return count($this->collCcListenerCounts); + } + + /** + * Method called to associate a CcListenerCount object to this object + * through the CcListenerCount foreign key attribute. + * + * @param CcListenerCount $l CcListenerCount + * @return CcTimestamp The current object (for fluent API support) + */ + public function addCcListenerCount(CcListenerCount $l) + { + if ($this->collCcListenerCounts === null) { + $this->initCcListenerCounts(); + $this->collCcListenerCountsPartial = true; + } + + if (!in_array($l, $this->collCcListenerCounts->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcListenerCount($l); + + if ($this->ccListenerCountsScheduledForDeletion and $this->ccListenerCountsScheduledForDeletion->contains($l)) { + $this->ccListenerCountsScheduledForDeletion->remove($this->ccListenerCountsScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcListenerCount $ccListenerCount The ccListenerCount object to add. + */ + protected function doAddCcListenerCount($ccListenerCount) + { + $this->collCcListenerCounts[]= $ccListenerCount; + $ccListenerCount->setCcTimestamp($this); + } + + /** + * @param CcListenerCount $ccListenerCount The ccListenerCount object to remove. + * @return CcTimestamp The current object (for fluent API support) + */ + public function removeCcListenerCount($ccListenerCount) + { + if ($this->getCcListenerCounts()->contains($ccListenerCount)) { + $this->collCcListenerCounts->remove($this->collCcListenerCounts->search($ccListenerCount)); + if (null === $this->ccListenerCountsScheduledForDeletion) { + $this->ccListenerCountsScheduledForDeletion = clone $this->collCcListenerCounts; + $this->ccListenerCountsScheduledForDeletion->clear(); + } + $this->ccListenerCountsScheduledForDeletion[]= clone $ccListenerCount; + $ccListenerCount->setCcTimestamp(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcTimestamp is new, it will return + * an empty collection; or if this CcTimestamp has previously + * been saved, it will retrieve related CcListenerCounts 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 CcTimestamp. + * + * @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 PropelObjectCollection|CcListenerCount[] List of CcListenerCount objects + */ + public function getCcListenerCountsJoinCcMountName($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcListenerCountQuery::create(null, $criteria); + $query->joinWith('CcMountName', $join_behavior); + + return $this->getCcListenerCounts($query, $con); + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->timestamp = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->collCcListenerCounts) { + foreach ($this->collCcListenerCounts as $o) { + $o->clearAllReferences($deep); + } + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + if ($this->collCcListenerCounts instanceof PropelCollection) { + $this->collCcListenerCounts->clearIterator(); + } + $this->collCcListenerCounts = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcTimestampPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcTimestampPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcTimestampPeer.php index 3d3b7d6ae..1a1df0bef 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcTimestampPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcTimestampPeer.php @@ -1,738 +1,773 @@ array ('DbId', 'DbTimestamp', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbTimestamp', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::TIMESTAMP, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TIMESTAMP', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'timestamp', ), - BasePeer::TYPE_NUM => array (0, 1, ) - ); - - /** - * 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, 'DbTimestamp' => 1, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbTimestamp' => 1, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::TIMESTAMP => 1, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TIMESTAMP' => 1, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'timestamp' => 1, ), - BasePeer::TYPE_NUM => array (0, 1, ) - ); - - /** - * 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. CcTimestampPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcTimestampPeer::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(CcTimestampPeer::ID); - $criteria->addSelectColumn(CcTimestampPeer::TIMESTAMP); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.TIMESTAMP'); - } - } - - /** - * 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(CcTimestampPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcTimestampPeer::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(CcTimestampPeer::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 CcTimestamp - * @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 = CcTimestampPeer::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 CcTimestampPeer::populateObjects(CcTimestampPeer::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(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcTimestampPeer::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 CcTimestamp $value A CcTimestamp object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcTimestamp $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 CcTimestamp object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcTimestamp) { - $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 CcTimestamp 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 CcTimestamp 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_timestamp - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in CcListenerCountPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcListenerCountPeer::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 = CcTimestampPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcTimestampPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcTimestampPeer::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; - CcTimestampPeer::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 (CcTimestamp object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcTimestampPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcTimestampPeer::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 + CcTimestampPeer::NUM_COLUMNS; - } else { - $cls = CcTimestampPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcTimestampPeer::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(BaseCcTimestampPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcTimestampPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcTimestampTableMap()); - } - } - - /** - * 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 ? CcTimestampPeer::CLASS_DEFAULT : CcTimestampPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcTimestamp or Criteria object. - * - * @param mixed $values Criteria or CcTimestamp 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(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcTimestamp object - } - - if ($criteria->containsKey(CcTimestampPeer::ID) && $criteria->keyContainsValue(CcTimestampPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcTimestampPeer::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 CcTimestamp or Criteria object. - * - * @param mixed $values Criteria or CcTimestamp 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(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcTimestampPeer::ID); - $value = $criteria->remove(CcTimestampPeer::ID); - if ($value) { - $selectCriteria->add(CcTimestampPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcTimestampPeer::TABLE_NAME); - } - - } else { // $values is CcTimestamp 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_timestamp 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(CcTimestampPeer::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(CcTimestampPeer::TABLE_NAME, $con, CcTimestampPeer::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). - CcTimestampPeer::clearInstancePool(); - CcTimestampPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcTimestamp or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcTimestamp 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(CcTimestampPeer::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. - CcTimestampPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcTimestamp) { // it's a model object - // invalidate the cache for this single object - CcTimestampPeer::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(CcTimestampPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcTimestampPeer::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); - CcTimestampPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcTimestamp 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 CcTimestamp $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(CcTimestamp $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcTimestampPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcTimestampPeer::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(CcTimestampPeer::DATABASE_NAME, CcTimestampPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcTimestamp - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcTimestampPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcTimestampPeer::DATABASE_NAME); - $criteria->add(CcTimestampPeer::ID, $pk); - - $v = CcTimestampPeer::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(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcTimestampPeer::DATABASE_NAME); - $criteria->add(CcTimestampPeer::ID, $pks, Criteria::IN); - $objs = CcTimestampPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcTimestampPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_timestamp'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcTimestamp'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcTimestampTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 2; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 2; + + /** the column name for the id field */ + const ID = 'cc_timestamp.id'; + + /** the column name for the timestamp field */ + const TIMESTAMP = 'cc_timestamp.timestamp'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcTimestamp objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcTimestamp[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcTimestampPeer::$fieldNames[CcTimestampPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbTimestamp', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbTimestamp', ), + BasePeer::TYPE_COLNAME => array (CcTimestampPeer::ID, CcTimestampPeer::TIMESTAMP, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TIMESTAMP', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'timestamp', ), + BasePeer::TYPE_NUM => array (0, 1, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcTimestampPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbTimestamp' => 1, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbTimestamp' => 1, ), + BasePeer::TYPE_COLNAME => array (CcTimestampPeer::ID => 0, CcTimestampPeer::TIMESTAMP => 1, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TIMESTAMP' => 1, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'timestamp' => 1, ), + BasePeer::TYPE_NUM => array (0, 1, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcTimestampPeer::getFieldNames($toType); + $key = isset(CcTimestampPeer::$fieldKeys[$fromType][$name]) ? CcTimestampPeer::$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(CcTimestampPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcTimestampPeer::$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 CcTimestampPeer::$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. CcTimestampPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcTimestampPeer::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(CcTimestampPeer::ID); + $criteria->addSelectColumn(CcTimestampPeer::TIMESTAMP); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.timestamp'); + } + } + + /** + * 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(CcTimestampPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcTimestampPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcTimestampPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcTimestampPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcTimestamp + * @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 = CcTimestampPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcTimestampPeer::populateObjects(CcTimestampPeer::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 directly (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(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcTimestampPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcTimestampPeer::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 CcTimestamp $obj A CcTimestamp object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcTimestampPeer::$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 CcTimestamp object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcTimestamp) { + $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 CcTimestamp object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcTimestampPeer::$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 CcTimestamp 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(CcTimestampPeer::$instances[$key])) { + return CcTimestampPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcTimestampPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcTimestampPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_timestamp + * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in CcListenerCountPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcListenerCountPeer::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 = CcTimestampPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcTimestampPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcTimestampPeer::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; + CcTimestampPeer::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 (CcTimestamp object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcTimestampPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcTimestampPeer::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 + CcTimestampPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcTimestampPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcTimestampPeer::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(CcTimestampPeer::DATABASE_NAME)->getTable(CcTimestampPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcTimestampPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcTimestampPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcTimestampTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcTimestampPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcTimestamp or Criteria object. + * + * @param mixed $values Criteria or CcTimestamp 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(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcTimestamp object + } + + if ($criteria->containsKey(CcTimestampPeer::ID) && $criteria->keyContainsValue(CcTimestampPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcTimestampPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcTimestampPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcTimestamp or Criteria object. + * + * @param mixed $values Criteria or CcTimestamp 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(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcTimestampPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcTimestampPeer::ID); + $value = $criteria->remove(CcTimestampPeer::ID); + if ($value) { + $selectCriteria->add(CcTimestampPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcTimestampPeer::TABLE_NAME); + } + + } else { // $values is CcTimestamp object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcTimestampPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_timestamp table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcTimestampPeer::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(CcTimestampPeer::TABLE_NAME, $con, CcTimestampPeer::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). + CcTimestampPeer::clearInstancePool(); + CcTimestampPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcTimestamp or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcTimestamp 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(CcTimestampPeer::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. + CcTimestampPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcTimestamp) { // it's a model object + // invalidate the cache for this single object + CcTimestampPeer::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(CcTimestampPeer::DATABASE_NAME); + $criteria->add(CcTimestampPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcTimestampPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcTimestampPeer::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); + CcTimestampPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcTimestamp 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 CcTimestamp $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcTimestampPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcTimestampPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcTimestampPeer::DATABASE_NAME, CcTimestampPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcTimestamp + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcTimestampPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcTimestampPeer::DATABASE_NAME); + $criteria->add(CcTimestampPeer::ID, $pk); + + $v = CcTimestampPeer::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 + * @return CcTimestamp[] + * @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(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcTimestampPeer::DATABASE_NAME); + $criteria->add(CcTimestampPeer::ID, $pks, Criteria::IN); + $objs = CcTimestampPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcTimestampPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcTimestampQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcTimestampQuery.php index a3f383112..c3f104039 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcTimestampQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcTimestampQuery.php @@ -1,268 +1,417 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcTimestamp|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcTimestampPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcTimestamp|CcTimestamp[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcTimestampPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcTimestampQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcTimestampPeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcTimestamp A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcTimestampQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcTimestampPeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcTimestamp A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "timestamp" FROM "cc_timestamp" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcTimestamp(); + $obj->hydrate($row); + CcTimestampPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcTimestampQuery 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(CcTimestampPeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * Filter the query on the timestamp column - * - * @param string|array $dbTimestamp 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 CcTimestampQuery The current query, for fluid interface - */ - public function filterByDbTimestamp($dbTimestamp = null, $comparison = null) - { - if (is_array($dbTimestamp)) { - $useMinMax = false; - if (isset($dbTimestamp['min'])) { - $this->addUsingAlias(CcTimestampPeer::TIMESTAMP, $dbTimestamp['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbTimestamp['max'])) { - $this->addUsingAlias(CcTimestampPeer::TIMESTAMP, $dbTimestamp['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcTimestampPeer::TIMESTAMP, $dbTimestamp, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcTimestamp|CcTimestamp[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * Filter the query by a related CcListenerCount object - * - * @param CcListenerCount $ccListenerCount the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcTimestampQuery The current query, for fluid interface - */ - public function filterByCcListenerCount($ccListenerCount, $comparison = null) - { - return $this - ->addUsingAlias(CcTimestampPeer::ID, $ccListenerCount->getDbTimestampId(), $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Adds a JOIN clause to the query using the CcListenerCount relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcTimestampQuery The current query, for fluid interface - */ - public function joinCcListenerCount($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcListenerCount'); - - // 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, 'CcListenerCount'); - } - - return $this; - } + /** + * 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|CcTimestamp[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Use the CcListenerCount relation CcListenerCount 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 CcListenerCountQuery A secondary query class using the current class as primary query - */ - public function useCcListenerCountQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcListenerCount($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcListenerCount', 'CcListenerCountQuery'); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Exclude object from result - * - * @param CcTimestamp $ccTimestamp Object to remove from the list of results - * - * @return CcTimestampQuery The current query, for fluid interface - */ - public function prune($ccTimestamp = null) - { - if ($ccTimestamp) { - $this->addUsingAlias(CcTimestampPeer::ID, $ccTimestamp->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcTimestampQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { -} // BaseCcTimestampQuery + return $this->addUsingAlias(CcTimestampPeer::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 CcTimestampQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(CcTimestampPeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcTimestampQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcTimestampPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcTimestampPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcTimestampPeer::ID, $dbId, $comparison); + } + + /** + * Filter the query on the timestamp column + * + * Example usage: + * + * $query->filterByDbTimestamp('2011-03-14'); // WHERE timestamp = '2011-03-14' + * $query->filterByDbTimestamp('now'); // WHERE timestamp = '2011-03-14' + * $query->filterByDbTimestamp(array('max' => 'yesterday')); // WHERE timestamp < '2011-03-13' + * + * + * @param mixed $dbTimestamp The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcTimestampQuery The current query, for fluid interface + */ + public function filterByDbTimestamp($dbTimestamp = null, $comparison = null) + { + if (is_array($dbTimestamp)) { + $useMinMax = false; + if (isset($dbTimestamp['min'])) { + $this->addUsingAlias(CcTimestampPeer::TIMESTAMP, $dbTimestamp['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbTimestamp['max'])) { + $this->addUsingAlias(CcTimestampPeer::TIMESTAMP, $dbTimestamp['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcTimestampPeer::TIMESTAMP, $dbTimestamp, $comparison); + } + + /** + * Filter the query by a related CcListenerCount object + * + * @param CcListenerCount|PropelObjectCollection $ccListenerCount the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcTimestampQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcListenerCount($ccListenerCount, $comparison = null) + { + if ($ccListenerCount instanceof CcListenerCount) { + return $this + ->addUsingAlias(CcTimestampPeer::ID, $ccListenerCount->getDbTimestampId(), $comparison); + } elseif ($ccListenerCount instanceof PropelObjectCollection) { + return $this + ->useCcListenerCountQuery() + ->filterByPrimaryKeys($ccListenerCount->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcListenerCount() only accepts arguments of type CcListenerCount or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcListenerCount relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcTimestampQuery The current query, for fluid interface + */ + public function joinCcListenerCount($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcListenerCount'); + + // 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, 'CcListenerCount'); + } + + return $this; + } + + /** + * Use the CcListenerCount relation CcListenerCount 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 \Airtime\CcListenerCountQuery A secondary query class using the current class as primary query + */ + public function useCcListenerCountQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcListenerCount($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcListenerCount', '\Airtime\CcListenerCountQuery'); + } + + /** + * Exclude object from result + * + * @param CcTimestamp $ccTimestamp Object to remove from the list of results + * + * @return CcTimestampQuery The current query, for fluid interface + */ + public function prune($ccTimestamp = null) + { + if ($ccTimestamp) { + $this->addUsingAlias(CcTimestampPeer::ID, $ccTimestamp->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcTrans.php b/airtime_mvc/application/models/airtime/om/BaseCcTrans.php deleted file mode 100644 index 2ea4f7c20..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcTrans.php +++ /dev/null @@ -1,1903 +0,0 @@ -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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - 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/airtime_mvc/application/models/airtime/om/BaseCcTransPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcTransPeer.php deleted file mode 100644 index bac6b9ed8..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcTransPeer.php +++ /dev/null @@ -1,849 +0,0 @@ - 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/airtime_mvc/application/models/airtime/om/BaseCcTransQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcTransQuery.php deleted file mode 100644 index 0bbccae2f..000000000 --- a/airtime_mvc/application/models/airtime/om/BaseCcTransQuery.php +++ /dev/null @@ -1,826 +0,0 @@ -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/airtime_mvc/application/models/airtime/om/BaseCcWebstream.php b/airtime_mvc/application/models/airtime/om/BaseCcWebstream.php index 6f6e16e2b..066023913 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcWebstream.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcWebstream.php @@ -1,1485 +1,1764 @@ length = '00:00:00'; - } - - /** - * Initializes internal state of BaseCcWebstream 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 [description] column value. - * - * @return string - */ - public function getDbDescription() - { - return $this->description; - } - - /** - * Get the [url] column value. - * - * @return string - */ - public function getDbUrl() - { - return $this->url; - } - - /** - * Get the [length] column value. - * - * @return string - */ - public function getDbLength() - { - return $this->length; - } - - /** - * Get the [creator_id] column value. - * - * @return int - */ - public function getDbCreatorId() - { - return $this->creator_id; - } - - /** - * 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 [optionally formatted] temporal [utime] 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 getDbUtime($format = 'Y-m-d H:i:s') - { - if ($this->utime === null) { - return null; - } - - - - try { - $dt = new DateTime($this->utime); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->utime, 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 [lptime] 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 getDbLPtime($format = 'Y-m-d H:i:s') - { - if ($this->lptime === null) { - return null; - } - - - - try { - $dt = new DateTime($this->lptime); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->lptime, 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 [mime] column value. - * - * @return string - */ - public function getDbMime() - { - return $this->mime; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcWebstream 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[] = CcWebstreamPeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [name] column. - * - * @param string $v new value - * @return CcWebstream The current object (for fluent API support) - */ - public function setDbName($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->name !== $v) { - $this->name = $v; - $this->modifiedColumns[] = CcWebstreamPeer::NAME; - } - - return $this; - } // setDbName() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return CcWebstream 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[] = CcWebstreamPeer::DESCRIPTION; - } - - return $this; - } // setDbDescription() - - /** - * Set the value of [url] column. - * - * @param string $v new value - * @return CcWebstream The current object (for fluent API support) - */ - public function setDbUrl($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->url !== $v) { - $this->url = $v; - $this->modifiedColumns[] = CcWebstreamPeer::URL; - } - - return $this; - } // setDbUrl() - - /** - * Set the value of [length] column. - * - * @param string $v new value - * @return CcWebstream The current object (for fluent API support) - */ - public function setDbLength($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->length !== $v || $this->isNew()) { - $this->length = $v; - $this->modifiedColumns[] = CcWebstreamPeer::LENGTH; - } - - return $this; - } // setDbLength() - - /** - * Set the value of [creator_id] column. - * - * @param int $v new value - * @return CcWebstream The current object (for fluent API support) - */ - public function setDbCreatorId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->creator_id !== $v) { - $this->creator_id = $v; - $this->modifiedColumns[] = CcWebstreamPeer::CREATOR_ID; - } - - return $this; - } // setDbCreatorId() - - /** - * 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 CcWebstream 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[] = CcWebstreamPeer::MTIME; - } - } // if either are not null - - return $this; - } // setDbMtime() - - /** - * Sets the value of [utime] 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 CcWebstream The current object (for fluent API support) - */ - public function setDbUtime($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->utime !== null || $dt !== null ) { - // (nested ifs are a little easier to read in this case) - - $currNorm = ($this->utime !== null && $tmpDt = new DateTime($this->utime)) ? $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->utime = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); - $this->modifiedColumns[] = CcWebstreamPeer::UTIME; - } - } // if either are not null - - return $this; - } // setDbUtime() - - /** - * Sets the value of [lptime] 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 CcWebstream The current object (for fluent API support) - */ - public function setDbLPtime($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->lptime !== null || $dt !== null ) { - // (nested ifs are a little easier to read in this case) - - $currNorm = ($this->lptime !== null && $tmpDt = new DateTime($this->lptime)) ? $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->lptime = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); - $this->modifiedColumns[] = CcWebstreamPeer::LPTIME; - } - } // if either are not null - - return $this; - } // setDbLPtime() - - /** - * Set the value of [mime] column. - * - * @param string $v new value - * @return CcWebstream The current object (for fluent API support) - */ - public function setDbMime($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->mime !== $v) { - $this->mime = $v; - $this->modifiedColumns[] = CcWebstreamPeer::MIME; - } - - return $this; - } // setDbMime() - - /** - * 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->length !== '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->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->description = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->url = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->length = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->creator_id = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; - $this->mtime = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->utime = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->lptime = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; - $this->mime = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 10; // 10 = CcWebstreamPeer::NUM_COLUMNS - CcWebstreamPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcWebstream 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(CcWebstreamPeer::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 = CcWebstreamPeer::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->collCcSchedules = 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(CcWebstreamPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcWebstreamQuery::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(CcWebstreamPeer::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); - CcWebstreamPeer::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[] = CcWebstreamPeer::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(CcWebstreamPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcWebstreamPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows = 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows = CcWebstreamPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - if ($this->collCcSchedules !== null) { - foreach ($this->collCcSchedules 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 then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CcWebstreamPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collCcSchedules !== null) { - foreach ($this->collCcSchedules 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 = CcWebstreamPeer::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->getDbDescription(); - break; - case 3: - return $this->getDbUrl(); - break; - case 4: - return $this->getDbLength(); - break; - case 5: - return $this->getDbCreatorId(); - break; - case 6: - return $this->getDbMtime(); - break; - case 7: - return $this->getDbUtime(); - break; - case 8: - return $this->getDbLPtime(); - break; - case 9: - return $this->getDbMime(); - 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 = CcWebstreamPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbName(), - $keys[2] => $this->getDbDescription(), - $keys[3] => $this->getDbUrl(), - $keys[4] => $this->getDbLength(), - $keys[5] => $this->getDbCreatorId(), - $keys[6] => $this->getDbMtime(), - $keys[7] => $this->getDbUtime(), - $keys[8] => $this->getDbLPtime(), - $keys[9] => $this->getDbMime(), - ); - 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 = CcWebstreamPeer::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->setDbDescription($value); - break; - case 3: - $this->setDbUrl($value); - break; - case 4: - $this->setDbLength($value); - break; - case 5: - $this->setDbCreatorId($value); - break; - case 6: - $this->setDbMtime($value); - break; - case 7: - $this->setDbUtime($value); - break; - case 8: - $this->setDbLPtime($value); - break; - case 9: - $this->setDbMime($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 = CcWebstreamPeer::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->setDbDescription($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbUrl($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDbLength($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setDbCreatorId($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDbMtime($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setDbUtime($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setDbLPtime($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setDbMime($arr[$keys[9]]); - } - - /** - * 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(CcWebstreamPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcWebstreamPeer::ID)) $criteria->add(CcWebstreamPeer::ID, $this->id); - if ($this->isColumnModified(CcWebstreamPeer::NAME)) $criteria->add(CcWebstreamPeer::NAME, $this->name); - if ($this->isColumnModified(CcWebstreamPeer::DESCRIPTION)) $criteria->add(CcWebstreamPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(CcWebstreamPeer::URL)) $criteria->add(CcWebstreamPeer::URL, $this->url); - if ($this->isColumnModified(CcWebstreamPeer::LENGTH)) $criteria->add(CcWebstreamPeer::LENGTH, $this->length); - if ($this->isColumnModified(CcWebstreamPeer::CREATOR_ID)) $criteria->add(CcWebstreamPeer::CREATOR_ID, $this->creator_id); - if ($this->isColumnModified(CcWebstreamPeer::MTIME)) $criteria->add(CcWebstreamPeer::MTIME, $this->mtime); - if ($this->isColumnModified(CcWebstreamPeer::UTIME)) $criteria->add(CcWebstreamPeer::UTIME, $this->utime); - if ($this->isColumnModified(CcWebstreamPeer::LPTIME)) $criteria->add(CcWebstreamPeer::LPTIME, $this->lptime); - if ($this->isColumnModified(CcWebstreamPeer::MIME)) $criteria->add(CcWebstreamPeer::MIME, $this->mime); - - 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(CcWebstreamPeer::DATABASE_NAME); - $criteria->add(CcWebstreamPeer::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 CcWebstream (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->setDbDescription($this->description); - $copyObj->setDbUrl($this->url); - $copyObj->setDbLength($this->length); - $copyObj->setDbCreatorId($this->creator_id); - $copyObj->setDbMtime($this->mtime); - $copyObj->setDbUtime($this->utime); - $copyObj->setDbLPtime($this->lptime); - $copyObj->setDbMime($this->mime); - - 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->getCcSchedules() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCcSchedule($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 CcWebstream 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 CcWebstreamPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcWebstreamPeer(); - } - return self::$peer; - } - - /** - * Clears out the collCcSchedules 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 addCcSchedules() - */ - public function clearCcSchedules() - { - $this->collCcSchedules = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Initializes the collCcSchedules collection. - * - * By default this just sets the collCcSchedules collection to an empty array (like clearcollCcSchedules()); - * 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 initCcSchedules() - { - $this->collCcSchedules = new PropelObjectCollection(); - $this->collCcSchedules->setModel('CcSchedule'); - } - - /** - * Gets an array of CcSchedule 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 CcWebstream 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 CcSchedule[] List of CcSchedule objects - * @throws PropelException - */ - public function getCcSchedules($criteria = null, PropelPDO $con = null) - { - if(null === $this->collCcSchedules || null !== $criteria) { - if ($this->isNew() && null === $this->collCcSchedules) { - // return empty collection - $this->initCcSchedules(); - } else { - $collCcSchedules = CcScheduleQuery::create(null, $criteria) - ->filterByCcWebstream($this) - ->find($con); - if (null !== $criteria) { - return $collCcSchedules; - } - $this->collCcSchedules = $collCcSchedules; - } - } - return $this->collCcSchedules; - } - - /** - * Returns the number of related CcSchedule objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CcSchedule objects. - * @throws PropelException - */ - public function countCcSchedules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - if(null === $this->collCcSchedules || null !== $criteria) { - if ($this->isNew() && null === $this->collCcSchedules) { - return 0; - } else { - $query = CcScheduleQuery::create(null, $criteria); - if($distinct) { - $query->distinct(); - } - return $query - ->filterByCcWebstream($this) - ->count($con); - } - } else { - return count($this->collCcSchedules); - } - } - - /** - * Method called to associate a CcSchedule object to this object - * through the CcSchedule foreign key attribute. - * - * @param CcSchedule $l CcSchedule - * @return void - * @throws PropelException - */ - public function addCcSchedule(CcSchedule $l) - { - if ($this->collCcSchedules === null) { - $this->initCcSchedules(); - } - if (!$this->collCcSchedules->contains($l)) { // only add it if the **same** object is not already associated - $this->collCcSchedules[]= $l; - $l->setCcWebstream($this); - } - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcWebstream is new, it will return - * an empty collection; or if this CcWebstream has previously - * been saved, it will retrieve related CcSchedules 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 CcWebstream. - * - * @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 CcSchedule[] List of CcSchedule objects - */ - public function getCcSchedulesJoinCcShowInstances($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcScheduleQuery::create(null, $criteria); - $query->joinWith('CcShowInstances', $join_behavior); - - return $this->getCcSchedules($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CcWebstream is new, it will return - * an empty collection; or if this CcWebstream has previously - * been saved, it will retrieve related CcSchedules 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 CcWebstream. - * - * @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 CcSchedule[] List of CcSchedule objects - */ - public function getCcSchedulesJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = CcScheduleQuery::create(null, $criteria); - $query->joinWith('CcFiles', $join_behavior); - - return $this->getCcSchedules($query, $con); - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->name = null; - $this->description = null; - $this->url = null; - $this->length = null; - $this->creator_id = null; - $this->mtime = null; - $this->utime = null; - $this->lptime = null; - $this->mime = 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->collCcSchedules) { - foreach ((array) $this->collCcSchedules as $o) { - $o->clearAllReferences($deep); - } - } - } // if ($deep) - - $this->collCcSchedules = 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); - } - -} // BaseCcWebstream + /** + * Peer class name + */ + const PEER = 'Airtime\\CcWebstreamPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcWebstreamPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the name field. + * @var string + */ + protected $name; + + /** + * The value for the description field. + * @var string + */ + protected $description; + + /** + * The value for the url field. + * @var string + */ + protected $url; + + /** + * The value for the length field. + * Note: this column has a database default value of: '00:00:00' + * @var string + */ + protected $length; + + /** + * The value for the creator_id field. + * @var int + */ + protected $creator_id; + + /** + * The value for the mtime field. + * @var string + */ + protected $mtime; + + /** + * The value for the utime field. + * @var string + */ + protected $utime; + + /** + * The value for the lptime field. + * @var string + */ + protected $lptime; + + /** + * The value for the mime field. + * @var string + */ + protected $mime; + + /** + * @var PropelObjectCollection|CcSchedule[] Collection to store aggregation of CcSchedule objects. + */ + protected $collCcSchedules; + protected $collCcSchedulesPartial; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * An array of objects scheduled for deletion. + * @var PropelObjectCollection + */ + protected $ccSchedulesScheduledForDeletion = null; + + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->length = '00:00:00'; + } + + /** + * Initializes internal state of BaseCcWebstream 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 [description] column value. + * + * @return string + */ + public function getDbDescription() + { + + return $this->description; + } + + /** + * Get the [url] column value. + * + * @return string + */ + public function getDbUrl() + { + + return $this->url; + } + + /** + * Get the [length] column value. + * + * @return string + */ + public function getDbLength() + { + + return $this->length; + } + + /** + * Get the [creator_id] column value. + * + * @return int + */ + public function getDbCreatorId() + { + + return $this->creator_id; + } + + /** + * 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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [optionally formatted] temporal [utime] 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 getDbUtime($format = 'Y-m-d H:i:s') + { + if ($this->utime === null) { + return null; + } + + + try { + $dt = new DateTime($this->utime); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->utime, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [optionally formatted] temporal [lptime] 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 getDbLPtime($format = 'Y-m-d H:i:s') + { + if ($this->lptime === null) { + return null; + } + + + try { + $dt = new DateTime($this->lptime); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->lptime, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [mime] column value. + * + * @return string + */ + public function getDbMime() + { + + return $this->mime; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcWebstream The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcWebstreamPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return CcWebstream The current object (for fluent API support) + */ + public function setDbName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = CcWebstreamPeer::NAME; + } + + + return $this; + } // setDbName() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return CcWebstream The current object (for fluent API support) + */ + public function setDbDescription($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = CcWebstreamPeer::DESCRIPTION; + } + + + return $this; + } // setDbDescription() + + /** + * Set the value of [url] column. + * + * @param string $v new value + * @return CcWebstream The current object (for fluent API support) + */ + public function setDbUrl($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->url !== $v) { + $this->url = $v; + $this->modifiedColumns[] = CcWebstreamPeer::URL; + } + + + return $this; + } // setDbUrl() + + /** + * Set the value of [length] column. + * + * @param string $v new value + * @return CcWebstream The current object (for fluent API support) + */ + public function setDbLength($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->length !== $v) { + $this->length = $v; + $this->modifiedColumns[] = CcWebstreamPeer::LENGTH; + } + + + return $this; + } // setDbLength() + + /** + * Set the value of [creator_id] column. + * + * @param int $v new value + * @return CcWebstream The current object (for fluent API support) + */ + public function setDbCreatorId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->creator_id !== $v) { + $this->creator_id = $v; + $this->modifiedColumns[] = CcWebstreamPeer::CREATOR_ID; + } + + + return $this; + } // setDbCreatorId() + + /** + * 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 strings are treated as null. + * @return CcWebstream The current object (for fluent API support) + */ + public function setDbMtime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->mtime !== null || $dt !== null) { + $currentDateAsString = ($this->mtime !== null && $tmpDt = new DateTime($this->mtime)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->mtime = $newDateAsString; + $this->modifiedColumns[] = CcWebstreamPeer::MTIME; + } + } // if either are not null + + + return $this; + } // setDbMtime() + + /** + * Sets the value of [utime] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return CcWebstream The current object (for fluent API support) + */ + public function setDbUtime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->utime !== null || $dt !== null) { + $currentDateAsString = ($this->utime !== null && $tmpDt = new DateTime($this->utime)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->utime = $newDateAsString; + $this->modifiedColumns[] = CcWebstreamPeer::UTIME; + } + } // if either are not null + + + return $this; + } // setDbUtime() + + /** + * Sets the value of [lptime] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return CcWebstream The current object (for fluent API support) + */ + public function setDbLPtime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->lptime !== null || $dt !== null) { + $currentDateAsString = ($this->lptime !== null && $tmpDt = new DateTime($this->lptime)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->lptime = $newDateAsString; + $this->modifiedColumns[] = CcWebstreamPeer::LPTIME; + } + } // if either are not null + + + return $this; + } // setDbLPtime() + + /** + * Set the value of [mime] column. + * + * @param string $v new value + * @return CcWebstream The current object (for fluent API support) + */ + public function setDbMime($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->mime !== $v) { + $this->mime = $v; + $this->modifiedColumns[] = CcWebstreamPeer::MIME; + } + + + return $this; + } // setDbMime() + + /** + * 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->length !== '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 resultset 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->description = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->url = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->length = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->creator_id = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; + $this->mtime = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->utime = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; + $this->lptime = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->mime = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 10; // 10 = CcWebstreamPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcWebstream 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(CcWebstreamPeer::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 = CcWebstreamPeer::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->collCcSchedules = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(CcWebstreamPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcWebstreamQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcWebstreamPeer::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); + CcWebstreamPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->ccSchedulesScheduledForDeletion !== null) { + if (!$this->ccSchedulesScheduledForDeletion->isEmpty()) { + CcScheduleQuery::create() + ->filterByPrimaryKeys($this->ccSchedulesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ccSchedulesScheduledForDeletion = null; + } + } + + if ($this->collCcSchedules !== null) { + foreach ($this->collCcSchedules as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcWebstreamPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcWebstreamPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_webstream_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcWebstreamPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcWebstreamPeer::NAME)) { + $modifiedColumns[':p' . $index++] = '"name"'; + } + if ($this->isColumnModified(CcWebstreamPeer::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = '"description"'; + } + if ($this->isColumnModified(CcWebstreamPeer::URL)) { + $modifiedColumns[':p' . $index++] = '"url"'; + } + if ($this->isColumnModified(CcWebstreamPeer::LENGTH)) { + $modifiedColumns[':p' . $index++] = '"length"'; + } + if ($this->isColumnModified(CcWebstreamPeer::CREATOR_ID)) { + $modifiedColumns[':p' . $index++] = '"creator_id"'; + } + if ($this->isColumnModified(CcWebstreamPeer::MTIME)) { + $modifiedColumns[':p' . $index++] = '"mtime"'; + } + if ($this->isColumnModified(CcWebstreamPeer::UTIME)) { + $modifiedColumns[':p' . $index++] = '"utime"'; + } + if ($this->isColumnModified(CcWebstreamPeer::LPTIME)) { + $modifiedColumns[':p' . $index++] = '"lptime"'; + } + if ($this->isColumnModified(CcWebstreamPeer::MIME)) { + $modifiedColumns[':p' . $index++] = '"mime"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_webstream" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"name"': + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); + break; + case '"description"': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case '"url"': + $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR); + break; + case '"length"': + $stmt->bindValue($identifier, $this->length, PDO::PARAM_STR); + break; + case '"creator_id"': + $stmt->bindValue($identifier, $this->creator_id, PDO::PARAM_INT); + break; + case '"mtime"': + $stmt->bindValue($identifier, $this->mtime, PDO::PARAM_STR); + break; + case '"utime"': + $stmt->bindValue($identifier, $this->utime, PDO::PARAM_STR); + break; + case '"lptime"': + $stmt->bindValue($identifier, $this->lptime, PDO::PARAM_STR); + break; + case '"mime"': + $stmt->bindValue($identifier, $this->mime, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = CcWebstreamPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collCcSchedules !== null) { + foreach ($this->collCcSchedules 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcWebstreamPeer::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->getDbDescription(); + break; + case 3: + return $this->getDbUrl(); + break; + case 4: + return $this->getDbLength(); + break; + case 5: + return $this->getDbCreatorId(); + break; + case 6: + return $this->getDbMtime(); + break; + case 7: + return $this->getDbUtime(); + break; + case 8: + return $this->getDbLPtime(); + break; + case 9: + return $this->getDbMime(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcWebstream'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcWebstream'][$this->getPrimaryKey()] = true; + $keys = CcWebstreamPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbName(), + $keys[2] => $this->getDbDescription(), + $keys[3] => $this->getDbUrl(), + $keys[4] => $this->getDbLength(), + $keys[5] => $this->getDbCreatorId(), + $keys[6] => $this->getDbMtime(), + $keys[7] => $this->getDbUtime(), + $keys[8] => $this->getDbLPtime(), + $keys[9] => $this->getDbMime(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->collCcSchedules) { + $result['CcSchedules'] = $this->collCcSchedules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcWebstreamPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbDescription($value); + break; + case 3: + $this->setDbUrl($value); + break; + case 4: + $this->setDbLength($value); + break; + case 5: + $this->setDbCreatorId($value); + break; + case 6: + $this->setDbMtime($value); + break; + case 7: + $this->setDbUtime($value); + break; + case 8: + $this->setDbLPtime($value); + break; + case 9: + $this->setDbMime($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcWebstreamPeer::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->setDbDescription($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbUrl($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDbLength($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDbCreatorId($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDbMtime($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setDbUtime($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setDbLPtime($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDbMime($arr[$keys[9]]); + } + + /** + * 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(CcWebstreamPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcWebstreamPeer::ID)) $criteria->add(CcWebstreamPeer::ID, $this->id); + if ($this->isColumnModified(CcWebstreamPeer::NAME)) $criteria->add(CcWebstreamPeer::NAME, $this->name); + if ($this->isColumnModified(CcWebstreamPeer::DESCRIPTION)) $criteria->add(CcWebstreamPeer::DESCRIPTION, $this->description); + if ($this->isColumnModified(CcWebstreamPeer::URL)) $criteria->add(CcWebstreamPeer::URL, $this->url); + if ($this->isColumnModified(CcWebstreamPeer::LENGTH)) $criteria->add(CcWebstreamPeer::LENGTH, $this->length); + if ($this->isColumnModified(CcWebstreamPeer::CREATOR_ID)) $criteria->add(CcWebstreamPeer::CREATOR_ID, $this->creator_id); + if ($this->isColumnModified(CcWebstreamPeer::MTIME)) $criteria->add(CcWebstreamPeer::MTIME, $this->mtime); + if ($this->isColumnModified(CcWebstreamPeer::UTIME)) $criteria->add(CcWebstreamPeer::UTIME, $this->utime); + if ($this->isColumnModified(CcWebstreamPeer::LPTIME)) $criteria->add(CcWebstreamPeer::LPTIME, $this->lptime); + if ($this->isColumnModified(CcWebstreamPeer::MIME)) $criteria->add(CcWebstreamPeer::MIME, $this->mime); + + 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(CcWebstreamPeer::DATABASE_NAME); + $criteria->add(CcWebstreamPeer::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 CcWebstream (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbName($this->getDbName()); + $copyObj->setDbDescription($this->getDbDescription()); + $copyObj->setDbUrl($this->getDbUrl()); + $copyObj->setDbLength($this->getDbLength()); + $copyObj->setDbCreatorId($this->getDbCreatorId()); + $copyObj->setDbMtime($this->getDbMtime()); + $copyObj->setDbUtime($this->getDbUtime()); + $copyObj->setDbLPtime($this->getDbLPtime()); + $copyObj->setDbMime($this->getDbMime()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + foreach ($this->getCcSchedules() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCcSchedule($relObj->copy($deepCopy)); + } + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcWebstream 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 CcWebstreamPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcWebstreamPeer(); + } + + return self::$peer; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('CcSchedule' == $relationName) { + $this->initCcSchedules(); + } + } + + /** + * Clears out the collCcSchedules 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 CcWebstream The current object (for fluent API support) + * @see addCcSchedules() + */ + public function clearCcSchedules() + { + $this->collCcSchedules = null; // important to set this to null since that means it is uninitialized + $this->collCcSchedulesPartial = null; + + return $this; + } + + /** + * reset is the collCcSchedules collection loaded partially + * + * @return void + */ + public function resetPartialCcSchedules($v = true) + { + $this->collCcSchedulesPartial = $v; + } + + /** + * Initializes the collCcSchedules collection. + * + * By default this just sets the collCcSchedules collection to an empty array (like clearcollCcSchedules()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCcSchedules($overrideExisting = true) + { + if (null !== $this->collCcSchedules && !$overrideExisting) { + return; + } + $this->collCcSchedules = new PropelObjectCollection(); + $this->collCcSchedules->setModel('CcSchedule'); + } + + /** + * Gets an array of CcSchedule 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 CcWebstream 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 PropelObjectCollection|CcSchedule[] List of CcSchedule objects + * @throws PropelException + */ + public function getCcSchedules($criteria = null, PropelPDO $con = null) + { + $partial = $this->collCcSchedulesPartial && !$this->isNew(); + if (null === $this->collCcSchedules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcSchedules) { + // return empty collection + $this->initCcSchedules(); + } else { + $collCcSchedules = CcScheduleQuery::create(null, $criteria) + ->filterByCcWebstream($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collCcSchedulesPartial && count($collCcSchedules)) { + $this->initCcSchedules(false); + + foreach ($collCcSchedules as $obj) { + if (false == $this->collCcSchedules->contains($obj)) { + $this->collCcSchedules->append($obj); + } + } + + $this->collCcSchedulesPartial = true; + } + + $collCcSchedules->getInternalIterator()->rewind(); + + return $collCcSchedules; + } + + if ($partial && $this->collCcSchedules) { + foreach ($this->collCcSchedules as $obj) { + if ($obj->isNew()) { + $collCcSchedules[] = $obj; + } + } + } + + $this->collCcSchedules = $collCcSchedules; + $this->collCcSchedulesPartial = false; + } + } + + return $this->collCcSchedules; + } + + /** + * Sets a collection of CcSchedule objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $ccSchedules A Propel collection. + * @param PropelPDO $con Optional connection object + * @return CcWebstream The current object (for fluent API support) + */ + public function setCcSchedules(PropelCollection $ccSchedules, PropelPDO $con = null) + { + $ccSchedulesToDelete = $this->getCcSchedules(new Criteria(), $con)->diff($ccSchedules); + + + $this->ccSchedulesScheduledForDeletion = $ccSchedulesToDelete; + + foreach ($ccSchedulesToDelete as $ccScheduleRemoved) { + $ccScheduleRemoved->setCcWebstream(null); + } + + $this->collCcSchedules = null; + foreach ($ccSchedules as $ccSchedule) { + $this->addCcSchedule($ccSchedule); + } + + $this->collCcSchedules = $ccSchedules; + $this->collCcSchedulesPartial = false; + + return $this; + } + + /** + * Returns the number of related CcSchedule objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related CcSchedule objects. + * @throws PropelException + */ + public function countCcSchedules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collCcSchedulesPartial && !$this->isNew(); + if (null === $this->collCcSchedules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCcSchedules) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCcSchedules()); + } + $query = CcScheduleQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCcWebstream($this) + ->count($con); + } + + return count($this->collCcSchedules); + } + + /** + * Method called to associate a CcSchedule object to this object + * through the CcSchedule foreign key attribute. + * + * @param CcSchedule $l CcSchedule + * @return CcWebstream The current object (for fluent API support) + */ + public function addCcSchedule(CcSchedule $l) + { + if ($this->collCcSchedules === null) { + $this->initCcSchedules(); + $this->collCcSchedulesPartial = true; + } + + if (!in_array($l, $this->collCcSchedules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCcSchedule($l); + + if ($this->ccSchedulesScheduledForDeletion and $this->ccSchedulesScheduledForDeletion->contains($l)) { + $this->ccSchedulesScheduledForDeletion->remove($this->ccSchedulesScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param CcSchedule $ccSchedule The ccSchedule object to add. + */ + protected function doAddCcSchedule($ccSchedule) + { + $this->collCcSchedules[]= $ccSchedule; + $ccSchedule->setCcWebstream($this); + } + + /** + * @param CcSchedule $ccSchedule The ccSchedule object to remove. + * @return CcWebstream The current object (for fluent API support) + */ + public function removeCcSchedule($ccSchedule) + { + if ($this->getCcSchedules()->contains($ccSchedule)) { + $this->collCcSchedules->remove($this->collCcSchedules->search($ccSchedule)); + if (null === $this->ccSchedulesScheduledForDeletion) { + $this->ccSchedulesScheduledForDeletion = clone $this->collCcSchedules; + $this->ccSchedulesScheduledForDeletion->clear(); + } + $this->ccSchedulesScheduledForDeletion[]= $ccSchedule; + $ccSchedule->setCcWebstream(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcWebstream is new, it will return + * an empty collection; or if this CcWebstream has previously + * been saved, it will retrieve related CcSchedules 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 CcWebstream. + * + * @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 PropelObjectCollection|CcSchedule[] List of CcSchedule objects + */ + public function getCcSchedulesJoinCcShowInstances($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcScheduleQuery::create(null, $criteria); + $query->joinWith('CcShowInstances', $join_behavior); + + return $this->getCcSchedules($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CcWebstream is new, it will return + * an empty collection; or if this CcWebstream has previously + * been saved, it will retrieve related CcSchedules 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 CcWebstream. + * + * @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 PropelObjectCollection|CcSchedule[] List of CcSchedule objects + */ + public function getCcSchedulesJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + { + $query = CcScheduleQuery::create(null, $criteria); + $query->joinWith('CcFiles', $join_behavior); + + return $this->getCcSchedules($query, $con); + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->name = null; + $this->description = null; + $this->url = null; + $this->length = null; + $this->creator_id = null; + $this->mtime = null; + $this->utime = null; + $this->lptime = null; + $this->mime = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->collCcSchedules) { + foreach ($this->collCcSchedules as $o) { + $o->clearAllReferences($deep); + } + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + if ($this->collCcSchedules instanceof PropelCollection) { + $this->collCcSchedules->clearIterator(); + } + $this->collCcSchedules = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcWebstreamPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcWebstreamMetadata.php b/airtime_mvc/application/models/airtime/om/BaseCcWebstreamMetadata.php index f5730573c..8e5d68e53 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcWebstreamMetadata.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcWebstreamMetadata.php @@ -1,957 +1,1095 @@ id; - } - - /** - * Get the [instance_id] column value. - * - * @return int - */ - public function getDbInstanceId() - { - return $this->instance_id; - } - - /** - * 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 = 'Y-m-d H:i:s') - { - 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 [liquidsoap_data] column value. - * - * @return string - */ - public function getDbLiquidsoapData() - { - return $this->liquidsoap_data; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CcWebstreamMetadata 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[] = CcWebstreamMetadataPeer::ID; - } - - return $this; - } // setDbId() - - /** - * Set the value of [instance_id] column. - * - * @param int $v new value - * @return CcWebstreamMetadata The current object (for fluent API support) - */ - public function setDbInstanceId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->instance_id !== $v) { - $this->instance_id = $v; - $this->modifiedColumns[] = CcWebstreamMetadataPeer::INSTANCE_ID; - } - - if ($this->aCcSchedule !== null && $this->aCcSchedule->getDbId() !== $v) { - $this->aCcSchedule = null; - } - - return $this; - } // setDbInstanceId() - - /** - * 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 CcWebstreamMetadata 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('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_time = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null); - $this->modifiedColumns[] = CcWebstreamMetadataPeer::START_TIME; - } - } // if either are not null - - return $this; - } // setDbStartTime() - - /** - * Set the value of [liquidsoap_data] column. - * - * @param string $v new value - * @return CcWebstreamMetadata The current object (for fluent API support) - */ - public function setDbLiquidsoapData($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->liquidsoap_data !== $v) { - $this->liquidsoap_data = $v; - $this->modifiedColumns[] = CcWebstreamMetadataPeer::LIQUIDSOAP_DATA; - } - - return $this; - } // setDbLiquidsoapData() - - /** - * 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->instance_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->start_time = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->liquidsoap_data = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 4; // 4 = CcWebstreamMetadataPeer::NUM_COLUMNS - CcWebstreamMetadataPeer::NUM_LAZY_LOAD_COLUMNS). - - } catch (Exception $e) { - throw new PropelException("Error populating CcWebstreamMetadata 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->aCcSchedule !== null && $this->instance_id !== $this->aCcSchedule->getDbId()) { - $this->aCcSchedule = 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(CcWebstreamMetadataPeer::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 = CcWebstreamMetadataPeer::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->aCcSchedule = 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(CcWebstreamMetadataPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $ret = $this->preDelete($con); - if ($ret) { - CcWebstreamMetadataQuery::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(CcWebstreamMetadataPeer::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); - CcWebstreamMetadataPeer::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->aCcSchedule !== null) { - if ($this->aCcSchedule->isModified() || $this->aCcSchedule->isNew()) { - $affectedRows += $this->aCcSchedule->save($con); - } - $this->setCcSchedule($this->aCcSchedule); - } - - if ($this->isNew() ) { - $this->modifiedColumns[] = CcWebstreamMetadataPeer::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(CcWebstreamMetadataPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcWebstreamMetadataPeer::ID.')'); - } - - $pk = BasePeer::doInsert($criteria, $con); - $affectedRows += 1; - $this->setDbId($pk); //[IMV] update autoincrement primary key - $this->setNew(false); - } else { - $affectedRows += CcWebstreamMetadataPeer::doUpdate($this, $con); - } - - $this->resetModified(); // [HL] After being saved an object is no longer 'modified' - } - - $this->alreadyInSave = false; - - } - return $affectedRows; - } // doSave() - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - return true; - } else { - $this->validationFailures = $res; - return false; - } - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCcSchedule !== null) { - if (!$this->aCcSchedule->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCcSchedule->getValidationFailures()); - } - } - - - if (($retval = CcWebstreamMetadataPeer::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 = CcWebstreamMetadataPeer::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->getDbInstanceId(); - break; - case 2: - return $this->getDbStartTime(); - break; - case 3: - return $this->getDbLiquidsoapData(); - 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 = CcWebstreamMetadataPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getDbId(), - $keys[1] => $this->getDbInstanceId(), - $keys[2] => $this->getDbStartTime(), - $keys[3] => $this->getDbLiquidsoapData(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCcSchedule) { - $result['CcSchedule'] = $this->aCcSchedule->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 = CcWebstreamMetadataPeer::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->setDbInstanceId($value); - break; - case 2: - $this->setDbStartTime($value); - break; - case 3: - $this->setDbLiquidsoapData($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 = CcWebstreamMetadataPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setDbInstanceId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDbStartTime($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDbLiquidsoapData($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(CcWebstreamMetadataPeer::DATABASE_NAME); - - if ($this->isColumnModified(CcWebstreamMetadataPeer::ID)) $criteria->add(CcWebstreamMetadataPeer::ID, $this->id); - if ($this->isColumnModified(CcWebstreamMetadataPeer::INSTANCE_ID)) $criteria->add(CcWebstreamMetadataPeer::INSTANCE_ID, $this->instance_id); - if ($this->isColumnModified(CcWebstreamMetadataPeer::START_TIME)) $criteria->add(CcWebstreamMetadataPeer::START_TIME, $this->start_time); - if ($this->isColumnModified(CcWebstreamMetadataPeer::LIQUIDSOAP_DATA)) $criteria->add(CcWebstreamMetadataPeer::LIQUIDSOAP_DATA, $this->liquidsoap_data); - - 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(CcWebstreamMetadataPeer::DATABASE_NAME); - $criteria->add(CcWebstreamMetadataPeer::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 CcWebstreamMetadata (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->setDbInstanceId($this->instance_id); - $copyObj->setDbStartTime($this->start_time); - $copyObj->setDbLiquidsoapData($this->liquidsoap_data); - - $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 CcWebstreamMetadata 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 CcWebstreamMetadataPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CcWebstreamMetadataPeer(); - } - return self::$peer; - } - - /** - * Declares an association between this object and a CcSchedule object. - * - * @param CcSchedule $v - * @return CcWebstreamMetadata The current object (for fluent API support) - * @throws PropelException - */ - public function setCcSchedule(CcSchedule $v = null) - { - if ($v === null) { - $this->setDbInstanceId(NULL); - } else { - $this->setDbInstanceId($v->getDbId()); - } - - $this->aCcSchedule = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CcSchedule object, it will not be re-added. - if ($v !== null) { - $v->addCcWebstreamMetadata($this); - } - - return $this; - } - - - /** - * Get the associated CcSchedule object - * - * @param PropelPDO Optional Connection object. - * @return CcSchedule The associated CcSchedule object. - * @throws PropelException - */ - public function getCcSchedule(PropelPDO $con = null) - { - if ($this->aCcSchedule === null && ($this->instance_id !== null)) { - $this->aCcSchedule = CcScheduleQuery::create()->findPk($this->instance_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->aCcSchedule->addCcWebstreamMetadatas($this); - */ - } - return $this->aCcSchedule; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->instance_id = null; - $this->start_time = null; - $this->liquidsoap_data = 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->aCcSchedule = 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); - } - -} // BaseCcWebstreamMetadata + /** + * Peer class name + */ + const PEER = 'Airtime\\CcWebstreamMetadataPeer'; + + /** + * The Peer class. + * Instance provides a convenient way of calling static methods on a class + * that calling code may not be able to identify. + * @var CcWebstreamMetadataPeer + */ + protected static $peer; + + /** + * The flag var to prevent infinite loop in deep copy + * @var boolean + */ + protected $startCopy = false; + + /** + * The value for the id field. + * @var int + */ + protected $id; + + /** + * The value for the instance_id field. + * @var int + */ + protected $instance_id; + + /** + * The value for the start_time field. + * @var string + */ + protected $start_time; + + /** + * The value for the liquidsoap_data field. + * @var string + */ + protected $liquidsoap_data; + + /** + * @var CcSchedule + */ + protected $aCcSchedule; + + /** + * Flag to prevent endless save loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInSave = false; + + /** + * Flag to prevent endless validation loop, if this object is referenced + * by another object which falls in this transaction. + * @var boolean + */ + protected $alreadyInValidation = false; + + /** + * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced + * @var boolean + */ + protected $alreadyInClearAllReferencesDeep = false; + + /** + * Get the [id] column value. + * + * @return int + */ + public function getDbId() + { + + return $this->id; + } + + /** + * Get the [instance_id] column value. + * + * @return int + */ + public function getDbInstanceId() + { + + return $this->instance_id; + } + + /** + * 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 = 'Y-m-d H:i:s') + { + 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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [liquidsoap_data] column value. + * + * @return string + */ + public function getDbLiquidsoapData() + { + + return $this->liquidsoap_data; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return CcWebstreamMetadata The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CcWebstreamMetadataPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [instance_id] column. + * + * @param int $v new value + * @return CcWebstreamMetadata The current object (for fluent API support) + */ + public function setDbInstanceId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->instance_id !== $v) { + $this->instance_id = $v; + $this->modifiedColumns[] = CcWebstreamMetadataPeer::INSTANCE_ID; + } + + if ($this->aCcSchedule !== null && $this->aCcSchedule->getDbId() !== $v) { + $this->aCcSchedule = null; + } + + + return $this; + } // setDbInstanceId() + + /** + * 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 strings are treated as null. + * @return CcWebstreamMetadata The current object (for fluent API support) + */ + public function setDbStartTime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->start_time !== null || $dt !== null) { + $currentDateAsString = ($this->start_time !== null && $tmpDt = new DateTime($this->start_time)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->start_time = $newDateAsString; + $this->modifiedColumns[] = CcWebstreamMetadataPeer::START_TIME; + } + } // if either are not null + + + return $this; + } // setDbStartTime() + + /** + * Set the value of [liquidsoap_data] column. + * + * @param string $v new value + * @return CcWebstreamMetadata The current object (for fluent API support) + */ + public function setDbLiquidsoapData($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->liquidsoap_data !== $v) { + $this->liquidsoap_data = $v; + $this->modifiedColumns[] = CcWebstreamMetadataPeer::LIQUIDSOAP_DATA; + } + + + return $this; + } // setDbLiquidsoapData() + + /** + * 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 resultset 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->instance_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->start_time = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; + $this->liquidsoap_data = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 4; // 4 = CcWebstreamMetadataPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating CcWebstreamMetadata 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->aCcSchedule !== null && $this->instance_id !== $this->aCcSchedule->getDbId()) { + $this->aCcSchedule = 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(CcWebstreamMetadataPeer::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 = CcWebstreamMetadataPeer::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->aCcSchedule = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(CcWebstreamMetadataPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = CcWebstreamMetadataQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(CcWebstreamMetadataPeer::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); + CcWebstreamMetadataPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcSchedule !== null) { + if ($this->aCcSchedule->isModified() || $this->aCcSchedule->isNew()) { + $affectedRows += $this->aCcSchedule->save($con); + } + $this->setCcSchedule($this->aCcSchedule); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CcWebstreamMetadataPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcWebstreamMetadataPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('cc_webstream_metadata_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CcWebstreamMetadataPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(CcWebstreamMetadataPeer::INSTANCE_ID)) { + $modifiedColumns[':p' . $index++] = '"instance_id"'; + } + if ($this->isColumnModified(CcWebstreamMetadataPeer::START_TIME)) { + $modifiedColumns[':p' . $index++] = '"start_time"'; + } + if ($this->isColumnModified(CcWebstreamMetadataPeer::LIQUIDSOAP_DATA)) { + $modifiedColumns[':p' . $index++] = '"liquidsoap_data"'; + } + + $sql = sprintf( + 'INSERT INTO "cc_webstream_metadata" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"instance_id"': + $stmt->bindValue($identifier, $this->instance_id, PDO::PARAM_INT); + break; + case '"start_time"': + $stmt->bindValue($identifier, $this->start_time, PDO::PARAM_STR); + break; + case '"liquidsoap_data"': + $stmt->bindValue($identifier, $this->liquidsoap_data, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCcSchedule !== null) { + if (!$this->aCcSchedule->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcSchedule->getValidationFailures()); + } + } + + + if (($retval = CcWebstreamMetadataPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcWebstreamMetadataPeer::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->getDbInstanceId(); + break; + case 2: + return $this->getDbStartTime(); + break; + case 3: + return $this->getDbLiquidsoapData(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CcWebstreamMetadata'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CcWebstreamMetadata'][$this->getPrimaryKey()] = true; + $keys = CcWebstreamMetadataPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getDbInstanceId(), + $keys[2] => $this->getDbStartTime(), + $keys[3] => $this->getDbLiquidsoapData(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcSchedule) { + $result['CcSchedule'] = $this->aCcSchedule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = CcWebstreamMetadataPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setDbInstanceId($value); + break; + case 2: + $this->setDbStartTime($value); + break; + case 3: + $this->setDbLiquidsoapData($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 BasePeer::TYPE_PHPNAME + * + * @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 = CcWebstreamMetadataPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDbInstanceId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDbStartTime($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDbLiquidsoapData($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(CcWebstreamMetadataPeer::DATABASE_NAME); + + if ($this->isColumnModified(CcWebstreamMetadataPeer::ID)) $criteria->add(CcWebstreamMetadataPeer::ID, $this->id); + if ($this->isColumnModified(CcWebstreamMetadataPeer::INSTANCE_ID)) $criteria->add(CcWebstreamMetadataPeer::INSTANCE_ID, $this->instance_id); + if ($this->isColumnModified(CcWebstreamMetadataPeer::START_TIME)) $criteria->add(CcWebstreamMetadataPeer::START_TIME, $this->start_time); + if ($this->isColumnModified(CcWebstreamMetadataPeer::LIQUIDSOAP_DATA)) $criteria->add(CcWebstreamMetadataPeer::LIQUIDSOAP_DATA, $this->liquidsoap_data); + + 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(CcWebstreamMetadataPeer::DATABASE_NAME); + $criteria->add(CcWebstreamMetadataPeer::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 CcWebstreamMetadata (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDbInstanceId($this->getDbInstanceId()); + $copyObj->setDbStartTime($this->getDbStartTime()); + $copyObj->setDbLiquidsoapData($this->getDbLiquidsoapData()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 CcWebstreamMetadata 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 CcWebstreamMetadataPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new CcWebstreamMetadataPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a CcSchedule object. + * + * @param CcSchedule $v + * @return CcWebstreamMetadata The current object (for fluent API support) + * @throws PropelException + */ + public function setCcSchedule(CcSchedule $v = null) + { + if ($v === null) { + $this->setDbInstanceId(NULL); + } else { + $this->setDbInstanceId($v->getDbId()); + } + + $this->aCcSchedule = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the CcSchedule object, it will not be re-added. + if ($v !== null) { + $v->addCcWebstreamMetadata($this); + } + + + return $this; + } + + + /** + * Get the associated CcSchedule object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcSchedule The associated CcSchedule object. + * @throws PropelException + */ + public function getCcSchedule(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcSchedule === null && ($this->instance_id !== null) && $doQuery) { + $this->aCcSchedule = CcScheduleQuery::create()->findPk($this->instance_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->aCcSchedule->addCcWebstreamMetadatas($this); + */ + } + + return $this->aCcSchedule; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->instance_id = null; + $this->start_time = null; + $this->liquidsoap_data = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aCcSchedule instanceof Persistent) { + $this->aCcSchedule->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + $this->aCcSchedule = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CcWebstreamMetadataPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcWebstreamMetadataPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcWebstreamMetadataPeer.php index 445e9793c..4ac2a58ec 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcWebstreamMetadataPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcWebstreamMetadataPeer.php @@ -1,979 +1,1018 @@ array ('DbId', 'DbInstanceId', 'DbStartTime', 'DbLiquidsoapData', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbInstanceId', 'dbStartTime', 'dbLiquidsoapData', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::INSTANCE_ID, self::START_TIME, self::LIQUIDSOAP_DATA, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'INSTANCE_ID', 'START_TIME', 'LIQUIDSOAP_DATA', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'instance_id', 'start_time', 'liquidsoap_data', ), - 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 ('DbId' => 0, 'DbInstanceId' => 1, 'DbStartTime' => 2, 'DbLiquidsoapData' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbInstanceId' => 1, 'dbStartTime' => 2, 'dbLiquidsoapData' => 3, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::INSTANCE_ID => 1, self::START_TIME => 2, self::LIQUIDSOAP_DATA => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'INSTANCE_ID' => 1, 'START_TIME' => 2, 'LIQUIDSOAP_DATA' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'instance_id' => 1, 'start_time' => 2, 'liquidsoap_data' => 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. CcWebstreamMetadataPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcWebstreamMetadataPeer::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(CcWebstreamMetadataPeer::ID); - $criteria->addSelectColumn(CcWebstreamMetadataPeer::INSTANCE_ID); - $criteria->addSelectColumn(CcWebstreamMetadataPeer::START_TIME); - $criteria->addSelectColumn(CcWebstreamMetadataPeer::LIQUIDSOAP_DATA); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.INSTANCE_ID'); - $criteria->addSelectColumn($alias . '.START_TIME'); - $criteria->addSelectColumn($alias . '.LIQUIDSOAP_DATA'); - } - } - - /** - * 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(CcWebstreamMetadataPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcWebstreamMetadataPeer::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(CcWebstreamMetadataPeer::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 CcWebstreamMetadata - * @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 = CcWebstreamMetadataPeer::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 CcWebstreamMetadataPeer::populateObjects(CcWebstreamMetadataPeer::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(CcWebstreamMetadataPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcWebstreamMetadataPeer::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 CcWebstreamMetadata $value A CcWebstreamMetadata object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcWebstreamMetadata $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 CcWebstreamMetadata object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcWebstreamMetadata) { - $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 CcWebstreamMetadata 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 CcWebstreamMetadata 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_webstream_metadata - * 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 = CcWebstreamMetadataPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcWebstreamMetadataPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcWebstreamMetadataPeer::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; - CcWebstreamMetadataPeer::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 (CcWebstreamMetadata object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcWebstreamMetadataPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcWebstreamMetadataPeer::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 + CcWebstreamMetadataPeer::NUM_COLUMNS; - } else { - $cls = CcWebstreamMetadataPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcWebstreamMetadataPeer::addInstanceToPool($obj, $key); - } - return array($obj, $col); - } - - /** - * Returns the number of rows matching criteria, joining the related CcSchedule 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 doCountJoinCcSchedule(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(CcWebstreamMetadataPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcWebstreamMetadataPeer::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(CcWebstreamMetadataPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcWebstreamMetadataPeer::INSTANCE_ID, CcSchedulePeer::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 CcWebstreamMetadata objects pre-filled with their CcSchedule 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 CcWebstreamMetadata objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCcSchedule(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); - } - - CcWebstreamMetadataPeer::addSelectColumns($criteria); - $startcol = (CcWebstreamMetadataPeer::NUM_COLUMNS - CcWebstreamMetadataPeer::NUM_LAZY_LOAD_COLUMNS); - CcSchedulePeer::addSelectColumns($criteria); - - $criteria->addJoin(CcWebstreamMetadataPeer::INSTANCE_ID, CcSchedulePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcWebstreamMetadataPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcWebstreamMetadataPeer::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 = CcWebstreamMetadataPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcWebstreamMetadataPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CcSchedulePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcSchedulePeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CcSchedulePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CcWebstreamMetadata) to $obj2 (CcSchedule) - $obj2->addCcWebstreamMetadata($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(CcWebstreamMetadataPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcWebstreamMetadataPeer::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(CcWebstreamMetadataPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CcWebstreamMetadataPeer::INSTANCE_ID, CcSchedulePeer::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 CcWebstreamMetadata 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 CcWebstreamMetadata 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); - } - - CcWebstreamMetadataPeer::addSelectColumns($criteria); - $startcol2 = (CcWebstreamMetadataPeer::NUM_COLUMNS - CcWebstreamMetadataPeer::NUM_LAZY_LOAD_COLUMNS); - - CcSchedulePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + (CcSchedulePeer::NUM_COLUMNS - CcSchedulePeer::NUM_LAZY_LOAD_COLUMNS); - - $criteria->addJoin(CcWebstreamMetadataPeer::INSTANCE_ID, CcSchedulePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CcWebstreamMetadataPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CcWebstreamMetadataPeer::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 = CcWebstreamMetadataPeer::getOMClass(false); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CcWebstreamMetadataPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CcSchedule rows - - $key2 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CcSchedulePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CcSchedulePeer::getOMClass(false); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CcSchedulePeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (CcWebstreamMetadata) to the collection in $obj2 (CcSchedule) - $obj2->addCcWebstreamMetadata($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(BaseCcWebstreamMetadataPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcWebstreamMetadataPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcWebstreamMetadataTableMap()); - } - } - - /** - * 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 ? CcWebstreamMetadataPeer::CLASS_DEFAULT : CcWebstreamMetadataPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcWebstreamMetadata or Criteria object. - * - * @param mixed $values Criteria or CcWebstreamMetadata 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(CcWebstreamMetadataPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcWebstreamMetadata object - } - - if ($criteria->containsKey(CcWebstreamMetadataPeer::ID) && $criteria->keyContainsValue(CcWebstreamMetadataPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcWebstreamMetadataPeer::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 CcWebstreamMetadata or Criteria object. - * - * @param mixed $values Criteria or CcWebstreamMetadata 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(CcWebstreamMetadataPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcWebstreamMetadataPeer::ID); - $value = $criteria->remove(CcWebstreamMetadataPeer::ID); - if ($value) { - $selectCriteria->add(CcWebstreamMetadataPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcWebstreamMetadataPeer::TABLE_NAME); - } - - } else { // $values is CcWebstreamMetadata 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_webstream_metadata 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(CcWebstreamMetadataPeer::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(CcWebstreamMetadataPeer::TABLE_NAME, $con, CcWebstreamMetadataPeer::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). - CcWebstreamMetadataPeer::clearInstancePool(); - CcWebstreamMetadataPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcWebstreamMetadata or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcWebstreamMetadata 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(CcWebstreamMetadataPeer::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. - CcWebstreamMetadataPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcWebstreamMetadata) { // it's a model object - // invalidate the cache for this single object - CcWebstreamMetadataPeer::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(CcWebstreamMetadataPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcWebstreamMetadataPeer::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); - CcWebstreamMetadataPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcWebstreamMetadata 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 CcWebstreamMetadata $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(CcWebstreamMetadata $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcWebstreamMetadataPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcWebstreamMetadataPeer::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(CcWebstreamMetadataPeer::DATABASE_NAME, CcWebstreamMetadataPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcWebstreamMetadata - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcWebstreamMetadataPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcWebstreamMetadataPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcWebstreamMetadataPeer::DATABASE_NAME); - $criteria->add(CcWebstreamMetadataPeer::ID, $pk); - - $v = CcWebstreamMetadataPeer::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(CcWebstreamMetadataPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcWebstreamMetadataPeer::DATABASE_NAME); - $criteria->add(CcWebstreamMetadataPeer::ID, $pks, Criteria::IN); - $objs = CcWebstreamMetadataPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcWebstreamMetadataPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_webstream_metadata'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcWebstreamMetadata'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcWebstreamMetadataTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 4; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 4; + + /** the column name for the id field */ + const ID = 'cc_webstream_metadata.id'; + + /** the column name for the instance_id field */ + const INSTANCE_ID = 'cc_webstream_metadata.instance_id'; + + /** the column name for the start_time field */ + const START_TIME = 'cc_webstream_metadata.start_time'; + + /** the column name for the liquidsoap_data field */ + const LIQUIDSOAP_DATA = 'cc_webstream_metadata.liquidsoap_data'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcWebstreamMetadata objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcWebstreamMetadata[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcWebstreamMetadataPeer::$fieldNames[CcWebstreamMetadataPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbInstanceId', 'DbStartTime', 'DbLiquidsoapData', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbInstanceId', 'dbStartTime', 'dbLiquidsoapData', ), + BasePeer::TYPE_COLNAME => array (CcWebstreamMetadataPeer::ID, CcWebstreamMetadataPeer::INSTANCE_ID, CcWebstreamMetadataPeer::START_TIME, CcWebstreamMetadataPeer::LIQUIDSOAP_DATA, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'INSTANCE_ID', 'START_TIME', 'LIQUIDSOAP_DATA', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'instance_id', 'start_time', 'liquidsoap_data', ), + 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. CcWebstreamMetadataPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbInstanceId' => 1, 'DbStartTime' => 2, 'DbLiquidsoapData' => 3, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbInstanceId' => 1, 'dbStartTime' => 2, 'dbLiquidsoapData' => 3, ), + BasePeer::TYPE_COLNAME => array (CcWebstreamMetadataPeer::ID => 0, CcWebstreamMetadataPeer::INSTANCE_ID => 1, CcWebstreamMetadataPeer::START_TIME => 2, CcWebstreamMetadataPeer::LIQUIDSOAP_DATA => 3, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'INSTANCE_ID' => 1, 'START_TIME' => 2, 'LIQUIDSOAP_DATA' => 3, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'instance_id' => 1, 'start_time' => 2, 'liquidsoap_data' => 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcWebstreamMetadataPeer::getFieldNames($toType); + $key = isset(CcWebstreamMetadataPeer::$fieldKeys[$fromType][$name]) ? CcWebstreamMetadataPeer::$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(CcWebstreamMetadataPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcWebstreamMetadataPeer::$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 CcWebstreamMetadataPeer::$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. CcWebstreamMetadataPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcWebstreamMetadataPeer::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(CcWebstreamMetadataPeer::ID); + $criteria->addSelectColumn(CcWebstreamMetadataPeer::INSTANCE_ID); + $criteria->addSelectColumn(CcWebstreamMetadataPeer::START_TIME); + $criteria->addSelectColumn(CcWebstreamMetadataPeer::LIQUIDSOAP_DATA); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.instance_id'); + $criteria->addSelectColumn($alias . '.start_time'); + $criteria->addSelectColumn($alias . '.liquidsoap_data'); + } + } + + /** + * 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(CcWebstreamMetadataPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcWebstreamMetadataPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcWebstreamMetadataPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcWebstreamMetadataPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcWebstreamMetadata + * @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 = CcWebstreamMetadataPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcWebstreamMetadataPeer::populateObjects(CcWebstreamMetadataPeer::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 directly (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(CcWebstreamMetadataPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcWebstreamMetadataPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcWebstreamMetadataPeer::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 CcWebstreamMetadata $obj A CcWebstreamMetadata object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcWebstreamMetadataPeer::$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 CcWebstreamMetadata object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcWebstreamMetadata) { + $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 CcWebstreamMetadata object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcWebstreamMetadataPeer::$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 CcWebstreamMetadata 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(CcWebstreamMetadataPeer::$instances[$key])) { + return CcWebstreamMetadataPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcWebstreamMetadataPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcWebstreamMetadataPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_webstream_metadata + * 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 = CcWebstreamMetadataPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcWebstreamMetadataPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcWebstreamMetadataPeer::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; + CcWebstreamMetadataPeer::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 (CcWebstreamMetadata object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcWebstreamMetadataPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcWebstreamMetadataPeer::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 + CcWebstreamMetadataPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcWebstreamMetadataPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcWebstreamMetadataPeer::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + + /** + * Returns the number of rows matching criteria, joining the related CcSchedule 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 doCountJoinCcSchedule(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(CcWebstreamMetadataPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcWebstreamMetadataPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcWebstreamMetadataPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcWebstreamMetadataPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcWebstreamMetadataPeer::INSTANCE_ID, CcSchedulePeer::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 CcWebstreamMetadata objects pre-filled with their CcSchedule 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 CcWebstreamMetadata objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinCcSchedule(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(CcWebstreamMetadataPeer::DATABASE_NAME); + } + + CcWebstreamMetadataPeer::addSelectColumns($criteria); + $startcol = CcWebstreamMetadataPeer::NUM_HYDRATE_COLUMNS; + CcSchedulePeer::addSelectColumns($criteria); + + $criteria->addJoin(CcWebstreamMetadataPeer::INSTANCE_ID, CcSchedulePeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcWebstreamMetadataPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcWebstreamMetadataPeer::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 = CcWebstreamMetadataPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcWebstreamMetadataPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcSchedulePeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSchedulePeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcSchedulePeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (CcWebstreamMetadata) to $obj2 (CcSchedule) + $obj2->addCcWebstreamMetadata($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(CcWebstreamMetadataPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcWebstreamMetadataPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(CcWebstreamMetadataPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(CcWebstreamMetadataPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(CcWebstreamMetadataPeer::INSTANCE_ID, CcSchedulePeer::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 CcWebstreamMetadata 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 CcWebstreamMetadata 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(CcWebstreamMetadataPeer::DATABASE_NAME); + } + + CcWebstreamMetadataPeer::addSelectColumns($criteria); + $startcol2 = CcWebstreamMetadataPeer::NUM_HYDRATE_COLUMNS; + + CcSchedulePeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcSchedulePeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(CcWebstreamMetadataPeer::INSTANCE_ID, CcSchedulePeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = CcWebstreamMetadataPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = CcWebstreamMetadataPeer::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 = CcWebstreamMetadataPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + CcWebstreamMetadataPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined CcSchedule rows + + $key2 = CcSchedulePeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = CcSchedulePeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSchedulePeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcSchedulePeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (CcWebstreamMetadata) to the collection in $obj2 (CcSchedule) + $obj2->addCcWebstreamMetadata($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(CcWebstreamMetadataPeer::DATABASE_NAME)->getTable(CcWebstreamMetadataPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcWebstreamMetadataPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcWebstreamMetadataPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcWebstreamMetadataTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcWebstreamMetadataPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcWebstreamMetadata or Criteria object. + * + * @param mixed $values Criteria or CcWebstreamMetadata 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(CcWebstreamMetadataPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcWebstreamMetadata object + } + + if ($criteria->containsKey(CcWebstreamMetadataPeer::ID) && $criteria->keyContainsValue(CcWebstreamMetadataPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcWebstreamMetadataPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcWebstreamMetadataPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcWebstreamMetadata or Criteria object. + * + * @param mixed $values Criteria or CcWebstreamMetadata 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(CcWebstreamMetadataPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcWebstreamMetadataPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcWebstreamMetadataPeer::ID); + $value = $criteria->remove(CcWebstreamMetadataPeer::ID); + if ($value) { + $selectCriteria->add(CcWebstreamMetadataPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcWebstreamMetadataPeer::TABLE_NAME); + } + + } else { // $values is CcWebstreamMetadata object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcWebstreamMetadataPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_webstream_metadata table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcWebstreamMetadataPeer::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(CcWebstreamMetadataPeer::TABLE_NAME, $con, CcWebstreamMetadataPeer::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). + CcWebstreamMetadataPeer::clearInstancePool(); + CcWebstreamMetadataPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcWebstreamMetadata or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcWebstreamMetadata 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(CcWebstreamMetadataPeer::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. + CcWebstreamMetadataPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcWebstreamMetadata) { // it's a model object + // invalidate the cache for this single object + CcWebstreamMetadataPeer::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(CcWebstreamMetadataPeer::DATABASE_NAME); + $criteria->add(CcWebstreamMetadataPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcWebstreamMetadataPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcWebstreamMetadataPeer::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); + CcWebstreamMetadataPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcWebstreamMetadata 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 CcWebstreamMetadata $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcWebstreamMetadataPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcWebstreamMetadataPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcWebstreamMetadataPeer::DATABASE_NAME, CcWebstreamMetadataPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcWebstreamMetadata + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcWebstreamMetadataPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcWebstreamMetadataPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcWebstreamMetadataPeer::DATABASE_NAME); + $criteria->add(CcWebstreamMetadataPeer::ID, $pk); + + $v = CcWebstreamMetadataPeer::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 + * @return CcWebstreamMetadata[] + * @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(CcWebstreamMetadataPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcWebstreamMetadataPeer::DATABASE_NAME); + $criteria->add(CcWebstreamMetadataPeer::ID, $pks, Criteria::IN); + $objs = CcWebstreamMetadataPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcWebstreamMetadataPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcWebstreamMetadataQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcWebstreamMetadataQuery.php index ba5bfcb12..f72c1493d 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcWebstreamMetadataQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcWebstreamMetadataQuery.php @@ -1,329 +1,500 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcWebstreamMetadata|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcWebstreamMetadataPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcWebstreamMetadata|CcWebstreamMetadata[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcWebstreamMetadataPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcWebstreamMetadataPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcWebstreamMetadataQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcWebstreamMetadataPeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcWebstreamMetadata A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcWebstreamMetadataQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcWebstreamMetadataPeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcWebstreamMetadata A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "instance_id", "start_time", "liquidsoap_data" FROM "cc_webstream_metadata" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcWebstreamMetadata(); + $obj->hydrate($row); + CcWebstreamMetadataPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcWebstreamMetadataQuery 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(CcWebstreamMetadataPeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * Filter the query on the instance_id column - * - * @param int|array $dbInstanceId 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 CcWebstreamMetadataQuery The current query, for fluid interface - */ - public function filterByDbInstanceId($dbInstanceId = null, $comparison = null) - { - if (is_array($dbInstanceId)) { - $useMinMax = false; - if (isset($dbInstanceId['min'])) { - $this->addUsingAlias(CcWebstreamMetadataPeer::INSTANCE_ID, $dbInstanceId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbInstanceId['max'])) { - $this->addUsingAlias(CcWebstreamMetadataPeer::INSTANCE_ID, $dbInstanceId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcWebstreamMetadataPeer::INSTANCE_ID, $dbInstanceId, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcWebstreamMetadata|CcWebstreamMetadata[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * 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 CcWebstreamMetadataQuery 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(CcWebstreamMetadataPeer::START_TIME, $dbStartTime['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbStartTime['max'])) { - $this->addUsingAlias(CcWebstreamMetadataPeer::START_TIME, $dbStartTime['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcWebstreamMetadataPeer::START_TIME, $dbStartTime, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query on the liquidsoap_data column - * - * @param string $dbLiquidsoapData 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 CcWebstreamMetadataQuery The current query, for fluid interface - */ - public function filterByDbLiquidsoapData($dbLiquidsoapData = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbLiquidsoapData)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbLiquidsoapData)) { - $dbLiquidsoapData = str_replace('*', '%', $dbLiquidsoapData); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcWebstreamMetadataPeer::LIQUIDSOAP_DATA, $dbLiquidsoapData, $comparison); - } + /** + * 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|CcWebstreamMetadata[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query by a related CcSchedule object - * - * @param CcSchedule $ccSchedule the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcWebstreamMetadataQuery The current query, for fluid interface - */ - public function filterByCcSchedule($ccSchedule, $comparison = null) - { - return $this - ->addUsingAlias(CcWebstreamMetadataPeer::INSTANCE_ID, $ccSchedule->getDbId(), $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Adds a JOIN clause to the query using the CcSchedule relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcWebstreamMetadataQuery The current query, for fluid interface - */ - public function joinCcSchedule($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcSchedule'); - - // 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, 'CcSchedule'); - } - - return $this; - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcWebstreamMetadataQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { - /** - * Use the CcSchedule relation CcSchedule 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 CcScheduleQuery A secondary query class using the current class as primary query - */ - public function useCcScheduleQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCcSchedule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcSchedule', 'CcScheduleQuery'); - } + return $this->addUsingAlias(CcWebstreamMetadataPeer::ID, $key, Criteria::EQUAL); + } - /** - * Exclude object from result - * - * @param CcWebstreamMetadata $ccWebstreamMetadata Object to remove from the list of results - * - * @return CcWebstreamMetadataQuery The current query, for fluid interface - */ - public function prune($ccWebstreamMetadata = null) - { - if ($ccWebstreamMetadata) { - $this->addUsingAlias(CcWebstreamMetadataPeer::ID, $ccWebstreamMetadata->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return CcWebstreamMetadataQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { -} // BaseCcWebstreamMetadataQuery + return $this->addUsingAlias(CcWebstreamMetadataPeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcWebstreamMetadataQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcWebstreamMetadataPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcWebstreamMetadataPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcWebstreamMetadataPeer::ID, $dbId, $comparison); + } + + /** + * Filter the query on the instance_id column + * + * Example usage: + * + * $query->filterByDbInstanceId(1234); // WHERE instance_id = 1234 + * $query->filterByDbInstanceId(array(12, 34)); // WHERE instance_id IN (12, 34) + * $query->filterByDbInstanceId(array('min' => 12)); // WHERE instance_id >= 12 + * $query->filterByDbInstanceId(array('max' => 12)); // WHERE instance_id <= 12 + * + * + * @see filterByCcSchedule() + * + * @param mixed $dbInstanceId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcWebstreamMetadataQuery The current query, for fluid interface + */ + public function filterByDbInstanceId($dbInstanceId = null, $comparison = null) + { + if (is_array($dbInstanceId)) { + $useMinMax = false; + if (isset($dbInstanceId['min'])) { + $this->addUsingAlias(CcWebstreamMetadataPeer::INSTANCE_ID, $dbInstanceId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbInstanceId['max'])) { + $this->addUsingAlias(CcWebstreamMetadataPeer::INSTANCE_ID, $dbInstanceId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcWebstreamMetadataPeer::INSTANCE_ID, $dbInstanceId, $comparison); + } + + /** + * Filter the query on the start_time column + * + * Example usage: + * + * $query->filterByDbStartTime('2011-03-14'); // WHERE start_time = '2011-03-14' + * $query->filterByDbStartTime('now'); // WHERE start_time = '2011-03-14' + * $query->filterByDbStartTime(array('max' => 'yesterday')); // WHERE start_time < '2011-03-13' + * + * + * @param mixed $dbStartTime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcWebstreamMetadataQuery 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(CcWebstreamMetadataPeer::START_TIME, $dbStartTime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbStartTime['max'])) { + $this->addUsingAlias(CcWebstreamMetadataPeer::START_TIME, $dbStartTime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcWebstreamMetadataPeer::START_TIME, $dbStartTime, $comparison); + } + + /** + * Filter the query on the liquidsoap_data column + * + * Example usage: + * + * $query->filterByDbLiquidsoapData('fooValue'); // WHERE liquidsoap_data = 'fooValue' + * $query->filterByDbLiquidsoapData('%fooValue%'); // WHERE liquidsoap_data LIKE '%fooValue%' + * + * + * @param string $dbLiquidsoapData 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 CcWebstreamMetadataQuery The current query, for fluid interface + */ + public function filterByDbLiquidsoapData($dbLiquidsoapData = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLiquidsoapData)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLiquidsoapData)) { + $dbLiquidsoapData = str_replace('*', '%', $dbLiquidsoapData); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcWebstreamMetadataPeer::LIQUIDSOAP_DATA, $dbLiquidsoapData, $comparison); + } + + /** + * Filter the query by a related CcSchedule object + * + * @param CcSchedule|PropelObjectCollection $ccSchedule The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcWebstreamMetadataQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcSchedule($ccSchedule, $comparison = null) + { + if ($ccSchedule instanceof CcSchedule) { + return $this + ->addUsingAlias(CcWebstreamMetadataPeer::INSTANCE_ID, $ccSchedule->getDbId(), $comparison); + } elseif ($ccSchedule instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CcWebstreamMetadataPeer::INSTANCE_ID, $ccSchedule->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcSchedule() only accepts arguments of type CcSchedule or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcSchedule relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcWebstreamMetadataQuery The current query, for fluid interface + */ + public function joinCcSchedule($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcSchedule'); + + // 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, 'CcSchedule'); + } + + return $this; + } + + /** + * Use the CcSchedule relation CcSchedule 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 \Airtime\CcScheduleQuery A secondary query class using the current class as primary query + */ + public function useCcScheduleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCcSchedule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSchedule', '\Airtime\CcScheduleQuery'); + } + + /** + * Exclude object from result + * + * @param CcWebstreamMetadata $ccWebstreamMetadata Object to remove from the list of results + * + * @return CcWebstreamMetadataQuery The current query, for fluid interface + */ + public function prune($ccWebstreamMetadata = null) + { + if ($ccWebstreamMetadata) { + $this->addUsingAlias(CcWebstreamMetadataPeer::ID, $ccWebstreamMetadata->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseCcWebstreamPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcWebstreamPeer.php index c1b2f7221..3faaab287 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcWebstreamPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcWebstreamPeer.php @@ -1,778 +1,813 @@ array ('DbId', 'DbName', 'DbDescription', 'DbUrl', 'DbLength', 'DbCreatorId', 'DbMtime', 'DbUtime', 'DbLPtime', 'DbMime', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbDescription', 'dbUrl', 'dbLength', 'dbCreatorId', 'dbMtime', 'dbUtime', 'dbLPtime', 'dbMime', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::DESCRIPTION, self::URL, self::LENGTH, self::CREATOR_ID, self::MTIME, self::UTIME, self::LPTIME, self::MIME, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'DESCRIPTION', 'URL', 'LENGTH', 'CREATOR_ID', 'MTIME', 'UTIME', 'LPTIME', 'MIME', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'description', 'url', 'length', 'creator_id', 'mtime', 'utime', 'lptime', 'mime', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) - ); - - /** - * 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, 'DbDescription' => 2, 'DbUrl' => 3, 'DbLength' => 4, 'DbCreatorId' => 5, 'DbMtime' => 6, 'DbUtime' => 7, 'DbLPtime' => 8, 'DbMime' => 9, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbDescription' => 2, 'dbUrl' => 3, 'dbLength' => 4, 'dbCreatorId' => 5, 'dbMtime' => 6, 'dbUtime' => 7, 'dbLPtime' => 8, 'dbMime' => 9, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::DESCRIPTION => 2, self::URL => 3, self::LENGTH => 4, self::CREATOR_ID => 5, self::MTIME => 6, self::UTIME => 7, self::LPTIME => 8, self::MIME => 9, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'DESCRIPTION' => 2, 'URL' => 3, 'LENGTH' => 4, 'CREATOR_ID' => 5, 'MTIME' => 6, 'UTIME' => 7, 'LPTIME' => 8, 'MIME' => 9, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'description' => 2, 'url' => 3, 'length' => 4, 'creator_id' => 5, 'mtime' => 6, 'utime' => 7, 'lptime' => 8, 'mime' => 9, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) - ); - - /** - * 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. CcWebstreamPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CcWebstreamPeer::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(CcWebstreamPeer::ID); - $criteria->addSelectColumn(CcWebstreamPeer::NAME); - $criteria->addSelectColumn(CcWebstreamPeer::DESCRIPTION); - $criteria->addSelectColumn(CcWebstreamPeer::URL); - $criteria->addSelectColumn(CcWebstreamPeer::LENGTH); - $criteria->addSelectColumn(CcWebstreamPeer::CREATOR_ID); - $criteria->addSelectColumn(CcWebstreamPeer::MTIME); - $criteria->addSelectColumn(CcWebstreamPeer::UTIME); - $criteria->addSelectColumn(CcWebstreamPeer::LPTIME); - $criteria->addSelectColumn(CcWebstreamPeer::MIME); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.NAME'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.URL'); - $criteria->addSelectColumn($alias . '.LENGTH'); - $criteria->addSelectColumn($alias . '.CREATOR_ID'); - $criteria->addSelectColumn($alias . '.MTIME'); - $criteria->addSelectColumn($alias . '.UTIME'); - $criteria->addSelectColumn($alias . '.LPTIME'); - $criteria->addSelectColumn($alias . '.MIME'); - } - } - - /** - * 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(CcWebstreamPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CcWebstreamPeer::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(CcWebstreamPeer::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 CcWebstream - * @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 = CcWebstreamPeer::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 CcWebstreamPeer::populateObjects(CcWebstreamPeer::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(CcWebstreamPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CcWebstreamPeer::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 CcWebstream $value A CcWebstream object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool(CcWebstream $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 CcWebstream object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CcWebstream) { - $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 CcWebstream 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 CcWebstream 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_webstream - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in CcSchedulePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CcSchedulePeer::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 = CcWebstreamPeer::getOMClass(false); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CcWebstreamPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CcWebstreamPeer::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; - CcWebstreamPeer::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 (CcWebstream object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CcWebstreamPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CcWebstreamPeer::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 + CcWebstreamPeer::NUM_COLUMNS; - } else { - $cls = CcWebstreamPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CcWebstreamPeer::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(BaseCcWebstreamPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCcWebstreamPeer::TABLE_NAME)) - { - $dbMap->addTableObject(new CcWebstreamTableMap()); - } - } - - /** - * 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 ? CcWebstreamPeer::CLASS_DEFAULT : CcWebstreamPeer::OM_CLASS; - } - - /** - * Method perform an INSERT on the database, given a CcWebstream or Criteria object. - * - * @param mixed $values Criteria or CcWebstream 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(CcWebstreamPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CcWebstream object - } - - if ($criteria->containsKey(CcWebstreamPeer::ID) && $criteria->keyContainsValue(CcWebstreamPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcWebstreamPeer::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 CcWebstream or Criteria object. - * - * @param mixed $values Criteria or CcWebstream 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(CcWebstreamPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(self::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CcWebstreamPeer::ID); - $value = $criteria->remove(CcWebstreamPeer::ID); - if ($value) { - $selectCriteria->add(CcWebstreamPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CcWebstreamPeer::TABLE_NAME); - } - - } else { // $values is CcWebstream 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_webstream 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(CcWebstreamPeer::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(CcWebstreamPeer::TABLE_NAME, $con, CcWebstreamPeer::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). - CcWebstreamPeer::clearInstancePool(); - CcWebstreamPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Method perform a DELETE on the database, given a CcWebstream or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CcWebstream 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(CcWebstreamPeer::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. - CcWebstreamPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CcWebstream) { // it's a model object - // invalidate the cache for this single object - CcWebstreamPeer::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(CcWebstreamPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CcWebstreamPeer::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); - CcWebstreamPeer::clearRelatedInstancePool(); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CcWebstream 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 CcWebstream $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(CcWebstream $obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CcWebstreamPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CcWebstreamPeer::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(CcWebstreamPeer::DATABASE_NAME, CcWebstreamPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CcWebstream - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CcWebstreamPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CcWebstreamPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CcWebstreamPeer::DATABASE_NAME); - $criteria->add(CcWebstreamPeer::ID, $pk); - - $v = CcWebstreamPeer::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(CcWebstreamPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CcWebstreamPeer::DATABASE_NAME); - $criteria->add(CcWebstreamPeer::ID, $pks, Criteria::IN); - $objs = CcWebstreamPeer::doSelect($criteria, $con); - } - return $objs; - } +abstract class BaseCcWebstreamPeer +{ + + /** the default database name for this class */ + const DATABASE_NAME = 'airtime'; + + /** the table name for this class */ + const TABLE_NAME = 'cc_webstream'; + + /** the related Propel class for this table */ + const OM_CLASS = 'Airtime\\CcWebstream'; + + /** the related TableMap class for this table */ + const TM_CLASS = 'Airtime\\map\\CcWebstreamTableMap'; + + /** The total number of columns. */ + const NUM_COLUMNS = 10; + + /** The number of lazy-loaded columns. */ + const NUM_LAZY_LOAD_COLUMNS = 0; + + /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ + const NUM_HYDRATE_COLUMNS = 10; + + /** the column name for the id field */ + const ID = 'cc_webstream.id'; + + /** the column name for the name field */ + const NAME = 'cc_webstream.name'; + + /** the column name for the description field */ + const DESCRIPTION = 'cc_webstream.description'; + + /** the column name for the url field */ + const URL = 'cc_webstream.url'; + + /** the column name for the length field */ + const LENGTH = 'cc_webstream.length'; + + /** the column name for the creator_id field */ + const CREATOR_ID = 'cc_webstream.creator_id'; + + /** the column name for the mtime field */ + const MTIME = 'cc_webstream.mtime'; + + /** the column name for the utime field */ + const UTIME = 'cc_webstream.utime'; + + /** the column name for the lptime field */ + const LPTIME = 'cc_webstream.lptime'; + + /** the column name for the mime field */ + const MIME = 'cc_webstream.mime'; + + /** The default string format for model objects of the related table **/ + const DEFAULT_STRING_FORMAT = 'YAML'; + + /** + * An identity map to hold any loaded instances of CcWebstream objects. + * This must be public so that other peer classes can access this when hydrating from JOIN + * queries. + * @var array CcWebstream[] + */ + public static $instances = array(); + + + /** + * holds an array of fieldnames + * + * first dimension keys are the type constants + * e.g. CcWebstreamPeer::$fieldNames[CcWebstreamPeer::TYPE_PHPNAME][0] = 'Id' + */ + protected static $fieldNames = array ( + BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbDescription', 'DbUrl', 'DbLength', 'DbCreatorId', 'DbMtime', 'DbUtime', 'DbLPtime', 'DbMime', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbDescription', 'dbUrl', 'dbLength', 'dbCreatorId', 'dbMtime', 'dbUtime', 'dbLPtime', 'dbMime', ), + BasePeer::TYPE_COLNAME => array (CcWebstreamPeer::ID, CcWebstreamPeer::NAME, CcWebstreamPeer::DESCRIPTION, CcWebstreamPeer::URL, CcWebstreamPeer::LENGTH, CcWebstreamPeer::CREATOR_ID, CcWebstreamPeer::MTIME, CcWebstreamPeer::UTIME, CcWebstreamPeer::LPTIME, CcWebstreamPeer::MIME, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'DESCRIPTION', 'URL', 'LENGTH', 'CREATOR_ID', 'MTIME', 'UTIME', 'LPTIME', 'MIME', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'description', 'url', 'length', 'creator_id', 'mtime', 'utime', 'lptime', 'mime', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. CcWebstreamPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbDescription' => 2, 'DbUrl' => 3, 'DbLength' => 4, 'DbCreatorId' => 5, 'DbMtime' => 6, 'DbUtime' => 7, 'DbLPtime' => 8, 'DbMime' => 9, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbDescription' => 2, 'dbUrl' => 3, 'dbLength' => 4, 'dbCreatorId' => 5, 'dbMtime' => 6, 'dbUtime' => 7, 'dbLPtime' => 8, 'dbMime' => 9, ), + BasePeer::TYPE_COLNAME => array (CcWebstreamPeer::ID => 0, CcWebstreamPeer::NAME => 1, CcWebstreamPeer::DESCRIPTION => 2, CcWebstreamPeer::URL => 3, CcWebstreamPeer::LENGTH => 4, CcWebstreamPeer::CREATOR_ID => 5, CcWebstreamPeer::MTIME => 6, CcWebstreamPeer::UTIME => 7, CcWebstreamPeer::LPTIME => 8, CcWebstreamPeer::MIME => 9, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'DESCRIPTION' => 2, 'URL' => 3, 'LENGTH' => 4, 'CREATOR_ID' => 5, 'MTIME' => 6, 'UTIME' => 7, 'LPTIME' => 8, 'MIME' => 9, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'description' => 2, 'url' => 3, 'length' => 4, 'creator_id' => 5, 'mtime' => 6, 'utime' => 7, 'lptime' => 8, 'mime' => 9, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = CcWebstreamPeer::getFieldNames($toType); + $key = isset(CcWebstreamPeer::$fieldKeys[$fromType][$name]) ? CcWebstreamPeer::$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(CcWebstreamPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, CcWebstreamPeer::$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 CcWebstreamPeer::$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. CcWebstreamPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(CcWebstreamPeer::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(CcWebstreamPeer::ID); + $criteria->addSelectColumn(CcWebstreamPeer::NAME); + $criteria->addSelectColumn(CcWebstreamPeer::DESCRIPTION); + $criteria->addSelectColumn(CcWebstreamPeer::URL); + $criteria->addSelectColumn(CcWebstreamPeer::LENGTH); + $criteria->addSelectColumn(CcWebstreamPeer::CREATOR_ID); + $criteria->addSelectColumn(CcWebstreamPeer::MTIME); + $criteria->addSelectColumn(CcWebstreamPeer::UTIME); + $criteria->addSelectColumn(CcWebstreamPeer::LPTIME); + $criteria->addSelectColumn(CcWebstreamPeer::MIME); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.name'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.url'); + $criteria->addSelectColumn($alias . '.length'); + $criteria->addSelectColumn($alias . '.creator_id'); + $criteria->addSelectColumn($alias . '.mtime'); + $criteria->addSelectColumn($alias . '.utime'); + $criteria->addSelectColumn($alias . '.lptime'); + $criteria->addSelectColumn($alias . '.mime'); + } + } + + /** + * 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(CcWebstreamPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + CcWebstreamPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(CcWebstreamPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(CcWebstreamPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return CcWebstream + * @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 = CcWebstreamPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 CcWebstreamPeer::populateObjects(CcWebstreamPeer::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 directly (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(CcWebstreamPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + CcWebstreamPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(CcWebstreamPeer::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 CcWebstream $obj A CcWebstream object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + CcWebstreamPeer::$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 CcWebstream object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof CcWebstream) { + $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 CcWebstream object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(CcWebstreamPeer::$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 CcWebstream 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(CcWebstreamPeer::$instances[$key])) { + return CcWebstreamPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (CcWebstreamPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + CcWebstreamPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to cc_webstream + * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in CcSchedulePeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CcSchedulePeer::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 = CcWebstreamPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = CcWebstreamPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = CcWebstreamPeer::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; + CcWebstreamPeer::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 (CcWebstream object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = CcWebstreamPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = CcWebstreamPeer::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 + CcWebstreamPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = CcWebstreamPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + CcWebstreamPeer::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(CcWebstreamPeer::DATABASE_NAME)->getTable(CcWebstreamPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseCcWebstreamPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseCcWebstreamPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\CcWebstreamTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return CcWebstreamPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a CcWebstream or Criteria object. + * + * @param mixed $values Criteria or CcWebstream 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(CcWebstreamPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from CcWebstream object + } + + if ($criteria->containsKey(CcWebstreamPeer::ID) && $criteria->keyContainsValue(CcWebstreamPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcWebstreamPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(CcWebstreamPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a CcWebstream or Criteria object. + * + * @param mixed $values Criteria or CcWebstream 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(CcWebstreamPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(CcWebstreamPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(CcWebstreamPeer::ID); + $value = $criteria->remove(CcWebstreamPeer::ID); + if ($value) { + $selectCriteria->add(CcWebstreamPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(CcWebstreamPeer::TABLE_NAME); + } + + } else { // $values is CcWebstream object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(CcWebstreamPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the cc_webstream table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(CcWebstreamPeer::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(CcWebstreamPeer::TABLE_NAME, $con, CcWebstreamPeer::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). + CcWebstreamPeer::clearInstancePool(); + CcWebstreamPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a CcWebstream or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CcWebstream 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(CcWebstreamPeer::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. + CcWebstreamPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof CcWebstream) { // it's a model object + // invalidate the cache for this single object + CcWebstreamPeer::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(CcWebstreamPeer::DATABASE_NAME); + $criteria->add(CcWebstreamPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + CcWebstreamPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(CcWebstreamPeer::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); + CcWebstreamPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given CcWebstream 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 CcWebstream $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(CcWebstreamPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(CcWebstreamPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(CcWebstreamPeer::DATABASE_NAME, CcWebstreamPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return CcWebstream + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = CcWebstreamPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(CcWebstreamPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(CcWebstreamPeer::DATABASE_NAME); + $criteria->add(CcWebstreamPeer::ID, $pk); + + $v = CcWebstreamPeer::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 + * @return CcWebstream[] + * @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(CcWebstreamPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(CcWebstreamPeer::DATABASE_NAME); + $criteria->add(CcWebstreamPeer::ID, $pks, Criteria::IN); + $objs = CcWebstreamPeer::doSelect($criteria, $con); + } + + return $objs; + } } // BaseCcWebstreamPeer diff --git a/airtime_mvc/application/models/airtime/om/BaseCcWebstreamQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcWebstreamQuery.php index 6f5becfb6..67c828842 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcWebstreamQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcWebstreamQuery.php @@ -1,503 +1,722 @@ setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } - /** - * 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 CcWebstream|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ((null !== ($obj = CcWebstreamPeer::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); - } - } + return $query; + } - /** - * 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); - } + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return CcWebstream|CcWebstream[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CcWebstreamPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(CcWebstreamPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CcWebstreamQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - return $this->addUsingAlias(CcWebstreamPeer::ID, $key, Criteria::EQUAL); - } + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcWebstream A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CcWebstreamQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - return $this->addUsingAlias(CcWebstreamPeer::ID, $keys, Criteria::IN); - } + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcWebstream A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "name", "description", "url", "length", "creator_id", "mtime", "utime", "lptime", "mime" FROM "cc_webstream" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new CcWebstream(); + $obj->hydrate($row); + CcWebstreamPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); - /** - * 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 CcWebstreamQuery 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(CcWebstreamPeer::ID, $dbId, $comparison); - } + return $obj; + } - /** - * 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 CcWebstreamQuery 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(CcWebstreamPeer::NAME, $dbName, $comparison); - } + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return CcWebstream|CcWebstream[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); - /** - * 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 CcWebstreamQuery 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(CcWebstreamPeer::DESCRIPTION, $dbDescription, $comparison); - } + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } - /** - * Filter the query on the url column - * - * @param string $dbUrl 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 CcWebstreamQuery The current query, for fluid interface - */ - public function filterByDbUrl($dbUrl = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbUrl)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbUrl)) { - $dbUrl = str_replace('*', '%', $dbUrl); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcWebstreamPeer::URL, $dbUrl, $comparison); - } + /** + * 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|CcWebstream[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); - /** - * Filter the query on the length column - * - * @param string $dbLength 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 CcWebstreamQuery The current query, for fluid interface - */ - public function filterByDbLength($dbLength = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbLength)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbLength)) { - $dbLength = str_replace('*', '%', $dbLength); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcWebstreamPeer::LENGTH, $dbLength, $comparison); - } + return $criteria->getFormatter()->init($criteria)->format($stmt); + } - /** - * Filter the query on the creator_id column - * - * @param int|array $dbCreatorId 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 CcWebstreamQuery The current query, for fluid interface - */ - public function filterByDbCreatorId($dbCreatorId = null, $comparison = null) - { - if (is_array($dbCreatorId)) { - $useMinMax = false; - if (isset($dbCreatorId['min'])) { - $this->addUsingAlias(CcWebstreamPeer::CREATOR_ID, $dbCreatorId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbCreatorId['max'])) { - $this->addUsingAlias(CcWebstreamPeer::CREATOR_ID, $dbCreatorId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcWebstreamPeer::CREATOR_ID, $dbCreatorId, $comparison); - } + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return CcWebstreamQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { - /** - * 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 CcWebstreamQuery 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(CcWebstreamPeer::MTIME, $dbMtime['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbMtime['max'])) { - $this->addUsingAlias(CcWebstreamPeer::MTIME, $dbMtime['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcWebstreamPeer::MTIME, $dbMtime, $comparison); - } + return $this->addUsingAlias(CcWebstreamPeer::ID, $key, Criteria::EQUAL); + } - /** - * Filter the query on the utime column - * - * @param string|array $dbUtime 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 CcWebstreamQuery The current query, for fluid interface - */ - public function filterByDbUtime($dbUtime = null, $comparison = null) - { - if (is_array($dbUtime)) { - $useMinMax = false; - if (isset($dbUtime['min'])) { - $this->addUsingAlias(CcWebstreamPeer::UTIME, $dbUtime['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbUtime['max'])) { - $this->addUsingAlias(CcWebstreamPeer::UTIME, $dbUtime['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcWebstreamPeer::UTIME, $dbUtime, $comparison); - } + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return CcWebstreamQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { - /** - * Filter the query on the lptime column - * - * @param string|array $dbLPtime 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 CcWebstreamQuery The current query, for fluid interface - */ - public function filterByDbLPtime($dbLPtime = null, $comparison = null) - { - if (is_array($dbLPtime)) { - $useMinMax = false; - if (isset($dbLPtime['min'])) { - $this->addUsingAlias(CcWebstreamPeer::LPTIME, $dbLPtime['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dbLPtime['max'])) { - $this->addUsingAlias(CcWebstreamPeer::LPTIME, $dbLPtime['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - return $this->addUsingAlias(CcWebstreamPeer::LPTIME, $dbLPtime, $comparison); - } + return $this->addUsingAlias(CcWebstreamPeer::ID, $keys, Criteria::IN); + } - /** - * Filter the query on the mime column - * - * @param string $dbMime 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 CcWebstreamQuery The current query, for fluid interface - */ - public function filterByDbMime($dbMime = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($dbMime)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbMime)) { - $dbMime = str_replace('*', '%', $dbMime); - $comparison = Criteria::LIKE; - } - } - return $this->addUsingAlias(CcWebstreamPeer::MIME, $dbMime, $comparison); - } + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcWebstreamQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(CcWebstreamPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(CcWebstreamPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } - /** - * Filter the query by a related CcSchedule object - * - * @param CcSchedule $ccSchedule the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CcWebstreamQuery The current query, for fluid interface - */ - public function filterByCcSchedule($ccSchedule, $comparison = null) - { - return $this - ->addUsingAlias(CcWebstreamPeer::ID, $ccSchedule->getDbStreamId(), $comparison); - } + return $this->addUsingAlias(CcWebstreamPeer::ID, $dbId, $comparison); + } - /** - * Adds a JOIN clause to the query using the CcSchedule relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CcWebstreamQuery The current query, for fluid interface - */ - public function joinCcSchedule($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CcSchedule'); - - // 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, 'CcSchedule'); - } - - return $this; - } + /** + * Filter the query on the name column + * + * Example usage: + * + * $query->filterByDbName('fooValue'); // WHERE name = 'fooValue' + * $query->filterByDbName('%fooValue%'); // WHERE name LIKE '%fooValue%' + * + * + * @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 CcWebstreamQuery 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; + } + } - /** - * Use the CcSchedule relation CcSchedule 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 CcScheduleQuery A secondary query class using the current class as primary query - */ - public function useCcScheduleQuery($relationAlias = '', $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCcSchedule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CcSchedule', 'CcScheduleQuery'); - } + return $this->addUsingAlias(CcWebstreamPeer::NAME, $dbName, $comparison); + } - /** - * Exclude object from result - * - * @param CcWebstream $ccWebstream Object to remove from the list of results - * - * @return CcWebstreamQuery The current query, for fluid interface - */ - public function prune($ccWebstream = null) - { - if ($ccWebstream) { - $this->addUsingAlias(CcWebstreamPeer::ID, $ccWebstream->getDbId(), Criteria::NOT_EQUAL); - } - - return $this; - } + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDbDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDbDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @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 CcWebstreamQuery 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; + } + } -} // BaseCcWebstreamQuery + return $this->addUsingAlias(CcWebstreamPeer::DESCRIPTION, $dbDescription, $comparison); + } + + /** + * Filter the query on the url column + * + * Example usage: + * + * $query->filterByDbUrl('fooValue'); // WHERE url = 'fooValue' + * $query->filterByDbUrl('%fooValue%'); // WHERE url LIKE '%fooValue%' + * + * + * @param string $dbUrl 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 CcWebstreamQuery The current query, for fluid interface + */ + public function filterByDbUrl($dbUrl = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbUrl)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbUrl)) { + $dbUrl = str_replace('*', '%', $dbUrl); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcWebstreamPeer::URL, $dbUrl, $comparison); + } + + /** + * Filter the query on the length column + * + * Example usage: + * + * $query->filterByDbLength('fooValue'); // WHERE length = 'fooValue' + * $query->filterByDbLength('%fooValue%'); // WHERE length LIKE '%fooValue%' + * + * + * @param string $dbLength 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 CcWebstreamQuery The current query, for fluid interface + */ + public function filterByDbLength($dbLength = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbLength)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbLength)) { + $dbLength = str_replace('*', '%', $dbLength); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcWebstreamPeer::LENGTH, $dbLength, $comparison); + } + + /** + * Filter the query on the creator_id column + * + * Example usage: + * + * $query->filterByDbCreatorId(1234); // WHERE creator_id = 1234 + * $query->filterByDbCreatorId(array(12, 34)); // WHERE creator_id IN (12, 34) + * $query->filterByDbCreatorId(array('min' => 12)); // WHERE creator_id >= 12 + * $query->filterByDbCreatorId(array('max' => 12)); // WHERE creator_id <= 12 + * + * + * @param mixed $dbCreatorId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcWebstreamQuery The current query, for fluid interface + */ + public function filterByDbCreatorId($dbCreatorId = null, $comparison = null) + { + if (is_array($dbCreatorId)) { + $useMinMax = false; + if (isset($dbCreatorId['min'])) { + $this->addUsingAlias(CcWebstreamPeer::CREATOR_ID, $dbCreatorId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbCreatorId['max'])) { + $this->addUsingAlias(CcWebstreamPeer::CREATOR_ID, $dbCreatorId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcWebstreamPeer::CREATOR_ID, $dbCreatorId, $comparison); + } + + /** + * Filter the query on the mtime column + * + * Example usage: + * + * $query->filterByDbMtime('2011-03-14'); // WHERE mtime = '2011-03-14' + * $query->filterByDbMtime('now'); // WHERE mtime = '2011-03-14' + * $query->filterByDbMtime(array('max' => 'yesterday')); // WHERE mtime < '2011-03-13' + * + * + * @param mixed $dbMtime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcWebstreamQuery 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(CcWebstreamPeer::MTIME, $dbMtime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbMtime['max'])) { + $this->addUsingAlias(CcWebstreamPeer::MTIME, $dbMtime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcWebstreamPeer::MTIME, $dbMtime, $comparison); + } + + /** + * Filter the query on the utime column + * + * Example usage: + * + * $query->filterByDbUtime('2011-03-14'); // WHERE utime = '2011-03-14' + * $query->filterByDbUtime('now'); // WHERE utime = '2011-03-14' + * $query->filterByDbUtime(array('max' => 'yesterday')); // WHERE utime < '2011-03-13' + * + * + * @param mixed $dbUtime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcWebstreamQuery The current query, for fluid interface + */ + public function filterByDbUtime($dbUtime = null, $comparison = null) + { + if (is_array($dbUtime)) { + $useMinMax = false; + if (isset($dbUtime['min'])) { + $this->addUsingAlias(CcWebstreamPeer::UTIME, $dbUtime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbUtime['max'])) { + $this->addUsingAlias(CcWebstreamPeer::UTIME, $dbUtime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcWebstreamPeer::UTIME, $dbUtime, $comparison); + } + + /** + * Filter the query on the lptime column + * + * Example usage: + * + * $query->filterByDbLPtime('2011-03-14'); // WHERE lptime = '2011-03-14' + * $query->filterByDbLPtime('now'); // WHERE lptime = '2011-03-14' + * $query->filterByDbLPtime(array('max' => 'yesterday')); // WHERE lptime < '2011-03-13' + * + * + * @param mixed $dbLPtime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcWebstreamQuery The current query, for fluid interface + */ + public function filterByDbLPtime($dbLPtime = null, $comparison = null) + { + if (is_array($dbLPtime)) { + $useMinMax = false; + if (isset($dbLPtime['min'])) { + $this->addUsingAlias(CcWebstreamPeer::LPTIME, $dbLPtime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbLPtime['max'])) { + $this->addUsingAlias(CcWebstreamPeer::LPTIME, $dbLPtime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CcWebstreamPeer::LPTIME, $dbLPtime, $comparison); + } + + /** + * Filter the query on the mime column + * + * Example usage: + * + * $query->filterByDbMime('fooValue'); // WHERE mime = 'fooValue' + * $query->filterByDbMime('%fooValue%'); // WHERE mime LIKE '%fooValue%' + * + * + * @param string $dbMime 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 CcWebstreamQuery The current query, for fluid interface + */ + public function filterByDbMime($dbMime = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($dbMime)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $dbMime)) { + $dbMime = str_replace('*', '%', $dbMime); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CcWebstreamPeer::MIME, $dbMime, $comparison); + } + + /** + * Filter the query by a related CcSchedule object + * + * @param CcSchedule|PropelObjectCollection $ccSchedule the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcWebstreamQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcSchedule($ccSchedule, $comparison = null) + { + if ($ccSchedule instanceof CcSchedule) { + return $this + ->addUsingAlias(CcWebstreamPeer::ID, $ccSchedule->getDbStreamId(), $comparison); + } elseif ($ccSchedule instanceof PropelObjectCollection) { + return $this + ->useCcScheduleQuery() + ->filterByPrimaryKeys($ccSchedule->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCcSchedule() only accepts arguments of type CcSchedule or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the CcSchedule relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return CcWebstreamQuery The current query, for fluid interface + */ + public function joinCcSchedule($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CcSchedule'); + + // 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, 'CcSchedule'); + } + + return $this; + } + + /** + * Use the CcSchedule relation CcSchedule 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 \Airtime\CcScheduleQuery A secondary query class using the current class as primary query + */ + public function useCcScheduleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSchedule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSchedule', '\Airtime\CcScheduleQuery'); + } + + /** + * Exclude object from result + * + * @param CcWebstream $ccWebstream Object to remove from the list of results + * + * @return CcWebstreamQuery The current query, for fluid interface + */ + public function prune($ccWebstream = null) + { + if ($ccWebstream) { + $this->addUsingAlias(CcWebstreamPeer::ID, $ccWebstream->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseMediaContents.php b/airtime_mvc/application/models/airtime/om/BaseMediaContents.php new file mode 100644 index 000000000..019e52727 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseMediaContents.php @@ -0,0 +1,1462 @@ +trackoffset = 0; + $this->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 BaseMediaContents 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 [media_id] column value. + * + * @return int + */ + public function getMediaId() + { + + return $this->media_id; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [trackoffset] column value. + * + * @return double + */ + public function getTrackOffset() + { + + return $this->trackoffset; + } + + /** + * Get the [cliplength] column value. + * + * @return string + */ + public function getCliplength() + { + + return $this->cliplength; + } + + /** + * Get the [cuein] column value. + * + * @return string + */ + public function getCuein() + { + + return $this->cuein; + } + + /** + * Get the [cueout] column value. + * + * @return string + */ + public function getCueout() + { + + return $this->cueout; + } + + /** + * 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 getFadein($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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + 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 getFadeout($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; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return MediaContents The current object (for fluent API support) + */ + public function setDbId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = MediaContentsPeer::ID; + } + + + return $this; + } // setDbId() + + /** + * Set the value of [media_id] column. + * + * @param int $v new value + * @return MediaContents The current object (for fluent API support) + */ + public function setMediaId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->media_id !== $v) { + $this->media_id = $v; + $this->modifiedColumns[] = MediaContentsPeer::MEDIA_ID; + } + + if ($this->aMediaItem !== null && $this->aMediaItem->getId() !== $v) { + $this->aMediaItem = null; + } + + + return $this; + } // setMediaId() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return MediaContents The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = MediaContentsPeer::POSITION; + } + + + return $this; + } // setPosition() + + /** + * Set the value of [trackoffset] column. + * + * @param double $v new value + * @return MediaContents The current object (for fluent API support) + */ + public function setTrackOffset($v) + { + if ($v !== null && is_numeric($v)) { + $v = (double) $v; + } + + if ($this->trackoffset !== $v) { + $this->trackoffset = $v; + $this->modifiedColumns[] = MediaContentsPeer::TRACKOFFSET; + } + + + return $this; + } // setTrackOffset() + + /** + * Set the value of [cliplength] column. + * + * @param string $v new value + * @return MediaContents The current object (for fluent API support) + */ + public function setCliplength($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->cliplength !== $v) { + $this->cliplength = $v; + $this->modifiedColumns[] = MediaContentsPeer::CLIPLENGTH; + } + + + return $this; + } // setCliplength() + + /** + * Set the value of [cuein] column. + * + * @param string $v new value + * @return MediaContents The current object (for fluent API support) + */ + public function setCuein($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->cuein !== $v) { + $this->cuein = $v; + $this->modifiedColumns[] = MediaContentsPeer::CUEIN; + } + + + return $this; + } // setCuein() + + /** + * Set the value of [cueout] column. + * + * @param string $v new value + * @return MediaContents The current object (for fluent API support) + */ + public function setCueout($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->cueout !== $v) { + $this->cueout = $v; + $this->modifiedColumns[] = MediaContentsPeer::CUEOUT; + } + + + return $this; + } // setCueout() + + /** + * 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 strings are treated as null. + * @return MediaContents The current object (for fluent API support) + */ + public function setFadein($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->fadein !== null || $dt !== null) { + $currentDateAsString = ($this->fadein !== null && $tmpDt = new DateTime($this->fadein)) ? $tmpDt->format('H:i:s') : null; + $newDateAsString = $dt ? $dt->format('H:i:s') : null; + if ( ($currentDateAsString !== $newDateAsString) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) { + $this->fadein = $newDateAsString; + $this->modifiedColumns[] = MediaContentsPeer::FADEIN; + } + } // if either are not null + + + return $this; + } // setFadein() + + /** + * 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 strings are treated as null. + * @return MediaContents The current object (for fluent API support) + */ + public function setFadeout($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->fadeout !== null || $dt !== null) { + $currentDateAsString = ($this->fadeout !== null && $tmpDt = new DateTime($this->fadeout)) ? $tmpDt->format('H:i:s') : null; + $newDateAsString = $dt ? $dt->format('H:i:s') : null; + if ( ($currentDateAsString !== $newDateAsString) // normalized values don't match + || ($dt->format('H:i:s') === '00:00:00') // or the entered value matches the default + ) { + $this->fadeout = $newDateAsString; + $this->modifiedColumns[] = MediaContentsPeer::FADEOUT; + } + } // if either are not null + + + return $this; + } // setFadeout() + + /** + * 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->trackoffset !== 0) { + return false; + } + + 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 resultset 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->media_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; + $this->position = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; + $this->trackoffset = ($row[$startcol + 3] !== null) ? (double) $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(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 9; // 9 = MediaContentsPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating MediaContents 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->aMediaItem !== null && $this->media_id !== $this->aMediaItem->getId()) { + $this->aMediaItem = 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(MediaContentsPeer::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 = MediaContentsPeer::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->aMediaItem = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(MediaContentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = MediaContentsQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(MediaContentsPeer::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); + MediaContentsPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aMediaItem !== null) { + if ($this->aMediaItem->isModified() || $this->aMediaItem->isNew()) { + $affectedRows += $this->aMediaItem->save($con); + } + $this->setMediaItem($this->aMediaItem); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = MediaContentsPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . MediaContentsPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('media_contents_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(MediaContentsPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(MediaContentsPeer::MEDIA_ID)) { + $modifiedColumns[':p' . $index++] = '"media_id"'; + } + if ($this->isColumnModified(MediaContentsPeer::POSITION)) { + $modifiedColumns[':p' . $index++] = '"position"'; + } + if ($this->isColumnModified(MediaContentsPeer::TRACKOFFSET)) { + $modifiedColumns[':p' . $index++] = '"trackoffset"'; + } + if ($this->isColumnModified(MediaContentsPeer::CLIPLENGTH)) { + $modifiedColumns[':p' . $index++] = '"cliplength"'; + } + if ($this->isColumnModified(MediaContentsPeer::CUEIN)) { + $modifiedColumns[':p' . $index++] = '"cuein"'; + } + if ($this->isColumnModified(MediaContentsPeer::CUEOUT)) { + $modifiedColumns[':p' . $index++] = '"cueout"'; + } + if ($this->isColumnModified(MediaContentsPeer::FADEIN)) { + $modifiedColumns[':p' . $index++] = '"fadein"'; + } + if ($this->isColumnModified(MediaContentsPeer::FADEOUT)) { + $modifiedColumns[':p' . $index++] = '"fadeout"'; + } + + $sql = sprintf( + 'INSERT INTO "media_contents" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"media_id"': + $stmt->bindValue($identifier, $this->media_id, PDO::PARAM_INT); + break; + case '"position"': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case '"trackoffset"': + $stmt->bindValue($identifier, $this->trackoffset, PDO::PARAM_STR); + break; + case '"cliplength"': + $stmt->bindValue($identifier, $this->cliplength, PDO::PARAM_STR); + break; + case '"cuein"': + $stmt->bindValue($identifier, $this->cuein, PDO::PARAM_STR); + break; + case '"cueout"': + $stmt->bindValue($identifier, $this->cueout, PDO::PARAM_STR); + break; + case '"fadein"': + $stmt->bindValue($identifier, $this->fadein, PDO::PARAM_STR); + break; + case '"fadeout"': + $stmt->bindValue($identifier, $this->fadeout, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aMediaItem !== null) { + if (!$this->aMediaItem->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aMediaItem->getValidationFailures()); + } + } + + + if (($retval = MediaContentsPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MediaContentsPeer::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->getMediaId(); + break; + case 2: + return $this->getPosition(); + break; + case 3: + return $this->getTrackOffset(); + break; + case 4: + return $this->getCliplength(); + break; + case 5: + return $this->getCuein(); + break; + case 6: + return $this->getCueout(); + break; + case 7: + return $this->getFadein(); + break; + case 8: + return $this->getFadeout(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['MediaContents'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['MediaContents'][$this->getPrimaryKey()] = true; + $keys = MediaContentsPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getDbId(), + $keys[1] => $this->getMediaId(), + $keys[2] => $this->getPosition(), + $keys[3] => $this->getTrackOffset(), + $keys[4] => $this->getCliplength(), + $keys[5] => $this->getCuein(), + $keys[6] => $this->getCueout(), + $keys[7] => $this->getFadein(), + $keys[8] => $this->getFadeout(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aMediaItem) { + $result['MediaItem'] = $this->aMediaItem->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MediaContentsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setMediaId($value); + break; + case 2: + $this->setPosition($value); + break; + case 3: + $this->setTrackOffset($value); + break; + case 4: + $this->setCliplength($value); + break; + case 5: + $this->setCuein($value); + break; + case 6: + $this->setCueout($value); + break; + case 7: + $this->setFadein($value); + break; + case 8: + $this->setFadeout($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 BasePeer::TYPE_PHPNAME + * + * @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 = MediaContentsPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setMediaId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setTrackOffset($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCliplength($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setCuein($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setCueout($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]]); + } + + /** + * 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(MediaContentsPeer::DATABASE_NAME); + + if ($this->isColumnModified(MediaContentsPeer::ID)) $criteria->add(MediaContentsPeer::ID, $this->id); + if ($this->isColumnModified(MediaContentsPeer::MEDIA_ID)) $criteria->add(MediaContentsPeer::MEDIA_ID, $this->media_id); + if ($this->isColumnModified(MediaContentsPeer::POSITION)) $criteria->add(MediaContentsPeer::POSITION, $this->position); + if ($this->isColumnModified(MediaContentsPeer::TRACKOFFSET)) $criteria->add(MediaContentsPeer::TRACKOFFSET, $this->trackoffset); + if ($this->isColumnModified(MediaContentsPeer::CLIPLENGTH)) $criteria->add(MediaContentsPeer::CLIPLENGTH, $this->cliplength); + if ($this->isColumnModified(MediaContentsPeer::CUEIN)) $criteria->add(MediaContentsPeer::CUEIN, $this->cuein); + if ($this->isColumnModified(MediaContentsPeer::CUEOUT)) $criteria->add(MediaContentsPeer::CUEOUT, $this->cueout); + if ($this->isColumnModified(MediaContentsPeer::FADEIN)) $criteria->add(MediaContentsPeer::FADEIN, $this->fadein); + if ($this->isColumnModified(MediaContentsPeer::FADEOUT)) $criteria->add(MediaContentsPeer::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(MediaContentsPeer::DATABASE_NAME); + $criteria->add(MediaContentsPeer::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 MediaContents (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setMediaId($this->getMediaId()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setTrackOffset($this->getTrackOffset()); + $copyObj->setCliplength($this->getCliplength()); + $copyObj->setCuein($this->getCuein()); + $copyObj->setCueout($this->getCueout()); + $copyObj->setFadein($this->getFadein()); + $copyObj->setFadeout($this->getFadeout()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 MediaContents 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 MediaContentsPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new MediaContentsPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a MediaItem object. + * + * @param MediaItem $v + * @return MediaContents The current object (for fluent API support) + * @throws PropelException + */ + public function setMediaItem(MediaItem $v = null) + { + if ($v === null) { + $this->setMediaId(NULL); + } else { + $this->setMediaId($v->getId()); + } + + $this->aMediaItem = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the MediaItem object, it will not be re-added. + if ($v !== null) { + $v->addMediaContents($this); + } + + + return $this; + } + + + /** + * Get the associated MediaItem object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return MediaItem The associated MediaItem object. + * @throws PropelException + */ + public function getMediaItem(PropelPDO $con = null, $doQuery = true) + { + if ($this->aMediaItem === null && ($this->media_id !== null) && $doQuery) { + $this->aMediaItem = MediaItemQuery::create()->findPk($this->media_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->aMediaItem->addMediaContentss($this); + */ + } + + return $this->aMediaItem; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->media_id = null; + $this->position = null; + $this->trackoffset = null; + $this->cliplength = null; + $this->cuein = null; + $this->cueout = null; + $this->fadein = null; + $this->fadeout = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aMediaItem instanceof Persistent) { + $this->aMediaItem->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + $this->aMediaItem = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(MediaContentsPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseMediaContentsPeer.php b/airtime_mvc/application/models/airtime/om/BaseMediaContentsPeer.php new file mode 100644 index 000000000..8a7d191dd --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseMediaContentsPeer.php @@ -0,0 +1,1047 @@ + array ('DbId', 'MediaId', 'Position', 'TrackOffset', 'Cliplength', 'Cuein', 'Cueout', 'Fadein', 'Fadeout', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'mediaId', 'position', 'trackOffset', 'cliplength', 'cuein', 'cueout', 'fadein', 'fadeout', ), + BasePeer::TYPE_COLNAME => array (MediaContentsPeer::ID, MediaContentsPeer::MEDIA_ID, MediaContentsPeer::POSITION, MediaContentsPeer::TRACKOFFSET, MediaContentsPeer::CLIPLENGTH, MediaContentsPeer::CUEIN, MediaContentsPeer::CUEOUT, MediaContentsPeer::FADEIN, MediaContentsPeer::FADEOUT, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'MEDIA_ID', 'POSITION', 'TRACKOFFSET', 'CLIPLENGTH', 'CUEIN', 'CUEOUT', 'FADEIN', 'FADEOUT', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'media_id', 'position', 'trackoffset', '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. MediaContentsPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'MediaId' => 1, 'Position' => 2, 'TrackOffset' => 3, 'Cliplength' => 4, 'Cuein' => 5, 'Cueout' => 6, 'Fadein' => 7, 'Fadeout' => 8, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'mediaId' => 1, 'position' => 2, 'trackOffset' => 3, 'cliplength' => 4, 'cuein' => 5, 'cueout' => 6, 'fadein' => 7, 'fadeout' => 8, ), + BasePeer::TYPE_COLNAME => array (MediaContentsPeer::ID => 0, MediaContentsPeer::MEDIA_ID => 1, MediaContentsPeer::POSITION => 2, MediaContentsPeer::TRACKOFFSET => 3, MediaContentsPeer::CLIPLENGTH => 4, MediaContentsPeer::CUEIN => 5, MediaContentsPeer::CUEOUT => 6, MediaContentsPeer::FADEIN => 7, MediaContentsPeer::FADEOUT => 8, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'MEDIA_ID' => 1, 'POSITION' => 2, 'TRACKOFFSET' => 3, 'CLIPLENGTH' => 4, 'CUEIN' => 5, 'CUEOUT' => 6, 'FADEIN' => 7, 'FADEOUT' => 8, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'media_id' => 1, 'position' => 2, 'trackoffset' => 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = MediaContentsPeer::getFieldNames($toType); + $key = isset(MediaContentsPeer::$fieldKeys[$fromType][$name]) ? MediaContentsPeer::$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(MediaContentsPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, MediaContentsPeer::$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 MediaContentsPeer::$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. MediaContentsPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(MediaContentsPeer::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(MediaContentsPeer::ID); + $criteria->addSelectColumn(MediaContentsPeer::MEDIA_ID); + $criteria->addSelectColumn(MediaContentsPeer::POSITION); + $criteria->addSelectColumn(MediaContentsPeer::TRACKOFFSET); + $criteria->addSelectColumn(MediaContentsPeer::CLIPLENGTH); + $criteria->addSelectColumn(MediaContentsPeer::CUEIN); + $criteria->addSelectColumn(MediaContentsPeer::CUEOUT); + $criteria->addSelectColumn(MediaContentsPeer::FADEIN); + $criteria->addSelectColumn(MediaContentsPeer::FADEOUT); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.media_id'); + $criteria->addSelectColumn($alias . '.position'); + $criteria->addSelectColumn($alias . '.trackoffset'); + $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(MediaContentsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + MediaContentsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(MediaContentsPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(MediaContentsPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return MediaContents + * @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 = MediaContentsPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 MediaContentsPeer::populateObjects(MediaContentsPeer::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 directly (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(MediaContentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + MediaContentsPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(MediaContentsPeer::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 MediaContents $obj A MediaContents object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getDbId(); + } // if key === null + MediaContentsPeer::$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 MediaContents object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof MediaContents) { + $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 MediaContents object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(MediaContentsPeer::$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 MediaContents 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(MediaContentsPeer::$instances[$key])) { + return MediaContentsPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (MediaContentsPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + MediaContentsPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to media_contents + * 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 = MediaContentsPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = MediaContentsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = MediaContentsPeer::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; + MediaContentsPeer::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 (MediaContents object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = MediaContentsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = MediaContentsPeer::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 + MediaContentsPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = MediaContentsPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + MediaContentsPeer::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + + /** + * Returns the number of rows matching criteria, joining the related MediaItem 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 doCountJoinMediaItem(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(MediaContentsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + MediaContentsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(MediaContentsPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(MediaContentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(MediaContentsPeer::MEDIA_ID, MediaItemPeer::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 MediaContents objects pre-filled with their MediaItem 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 MediaContents objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinMediaItem(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(MediaContentsPeer::DATABASE_NAME); + } + + MediaContentsPeer::addSelectColumns($criteria); + $startcol = MediaContentsPeer::NUM_HYDRATE_COLUMNS; + MediaItemPeer::addSelectColumns($criteria); + + $criteria->addJoin(MediaContentsPeer::MEDIA_ID, MediaItemPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = MediaContentsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = MediaContentsPeer::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 = MediaContentsPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + MediaContentsPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = MediaItemPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = MediaItemPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = MediaItemPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + MediaItemPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (MediaContents) to $obj2 (MediaItem) + $obj2->addMediaContents($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(MediaContentsPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + MediaContentsPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(MediaContentsPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(MediaContentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(MediaContentsPeer::MEDIA_ID, MediaItemPeer::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 MediaContents 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 MediaContents 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(MediaContentsPeer::DATABASE_NAME); + } + + MediaContentsPeer::addSelectColumns($criteria); + $startcol2 = MediaContentsPeer::NUM_HYDRATE_COLUMNS; + + MediaItemPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + MediaItemPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(MediaContentsPeer::MEDIA_ID, MediaItemPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = MediaContentsPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = MediaContentsPeer::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 = MediaContentsPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + MediaContentsPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined MediaItem rows + + $key2 = MediaItemPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = MediaItemPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = MediaItemPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + MediaItemPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (MediaContents) to the collection in $obj2 (MediaItem) + $obj2->addMediaContents($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(MediaContentsPeer::DATABASE_NAME)->getTable(MediaContentsPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseMediaContentsPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseMediaContentsPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\MediaItem\map\MediaContentsTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return MediaContentsPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a MediaContents or Criteria object. + * + * @param mixed $values Criteria or MediaContents 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(MediaContentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from MediaContents object + } + + if ($criteria->containsKey(MediaContentsPeer::ID) && $criteria->keyContainsValue(MediaContentsPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.MediaContentsPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(MediaContentsPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a MediaContents or Criteria object. + * + * @param mixed $values Criteria or MediaContents 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(MediaContentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(MediaContentsPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(MediaContentsPeer::ID); + $value = $criteria->remove(MediaContentsPeer::ID); + if ($value) { + $selectCriteria->add(MediaContentsPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(MediaContentsPeer::TABLE_NAME); + } + + } else { // $values is MediaContents object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(MediaContentsPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the media_contents table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(MediaContentsPeer::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(MediaContentsPeer::TABLE_NAME, $con, MediaContentsPeer::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). + MediaContentsPeer::clearInstancePool(); + MediaContentsPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a MediaContents or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or MediaContents 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(MediaContentsPeer::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. + MediaContentsPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof MediaContents) { // it's a model object + // invalidate the cache for this single object + MediaContentsPeer::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(MediaContentsPeer::DATABASE_NAME); + $criteria->add(MediaContentsPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + MediaContentsPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(MediaContentsPeer::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); + MediaContentsPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given MediaContents 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 MediaContents $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(MediaContentsPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(MediaContentsPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(MediaContentsPeer::DATABASE_NAME, MediaContentsPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return MediaContents + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = MediaContentsPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(MediaContentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(MediaContentsPeer::DATABASE_NAME); + $criteria->add(MediaContentsPeer::ID, $pk); + + $v = MediaContentsPeer::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 + * @return MediaContents[] + * @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(MediaContentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(MediaContentsPeer::DATABASE_NAME); + $criteria->add(MediaContentsPeer::ID, $pks, Criteria::IN); + $objs = MediaContentsPeer::doSelect($criteria, $con); + } + + return $objs; + } + +} // BaseMediaContentsPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseMediaContentsPeer::buildTableMap(); + diff --git a/airtime_mvc/application/models/airtime/om/BaseMediaContentsQuery.php b/airtime_mvc/application/models/airtime/om/BaseMediaContentsQuery.php new file mode 100644 index 000000000..dfc2f619d --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseMediaContentsQuery.php @@ -0,0 +1,705 @@ +mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return MediaContents|MediaContents[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = MediaContentsPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(MediaContentsPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return MediaContents A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneByDbId($key, $con = null) + { + return $this->findPk($key, $con); + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return MediaContents A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "media_id", "position", "trackoffset", "cliplength", "cuein", "cueout", "fadein", "fadeout" FROM "media_contents" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new MediaContents(); + $obj->hydrate($row); + MediaContentsPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return MediaContents|MediaContents[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($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|MediaContents[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($stmt); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return MediaContentsQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(MediaContentsPeer::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 MediaContentsQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(MediaContentsPeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterByDbId(1234); // WHERE id = 1234 + * $query->filterByDbId(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterByDbId(array('min' => 12)); // WHERE id >= 12 + * $query->filterByDbId(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $dbId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaContentsQuery The current query, for fluid interface + */ + public function filterByDbId($dbId = null, $comparison = null) + { + if (is_array($dbId)) { + $useMinMax = false; + if (isset($dbId['min'])) { + $this->addUsingAlias(MediaContentsPeer::ID, $dbId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbId['max'])) { + $this->addUsingAlias(MediaContentsPeer::ID, $dbId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MediaContentsPeer::ID, $dbId, $comparison); + } + + /** + * Filter the query on the media_id column + * + * Example usage: + * + * $query->filterByMediaId(1234); // WHERE media_id = 1234 + * $query->filterByMediaId(array(12, 34)); // WHERE media_id IN (12, 34) + * $query->filterByMediaId(array('min' => 12)); // WHERE media_id >= 12 + * $query->filterByMediaId(array('max' => 12)); // WHERE media_id <= 12 + * + * + * @see filterByMediaItem() + * + * @param mixed $mediaId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaContentsQuery The current query, for fluid interface + */ + public function filterByMediaId($mediaId = null, $comparison = null) + { + if (is_array($mediaId)) { + $useMinMax = false; + if (isset($mediaId['min'])) { + $this->addUsingAlias(MediaContentsPeer::MEDIA_ID, $mediaId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($mediaId['max'])) { + $this->addUsingAlias(MediaContentsPeer::MEDIA_ID, $mediaId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MediaContentsPeer::MEDIA_ID, $mediaId, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 + * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaContentsQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(MediaContentsPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(MediaContentsPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MediaContentsPeer::POSITION, $position, $comparison); + } + + /** + * Filter the query on the trackoffset column + * + * Example usage: + * + * $query->filterByTrackOffset(1234); // WHERE trackoffset = 1234 + * $query->filterByTrackOffset(array(12, 34)); // WHERE trackoffset IN (12, 34) + * $query->filterByTrackOffset(array('min' => 12)); // WHERE trackoffset >= 12 + * $query->filterByTrackOffset(array('max' => 12)); // WHERE trackoffset <= 12 + * + * + * @param mixed $trackOffset The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaContentsQuery The current query, for fluid interface + */ + public function filterByTrackOffset($trackOffset = null, $comparison = null) + { + if (is_array($trackOffset)) { + $useMinMax = false; + if (isset($trackOffset['min'])) { + $this->addUsingAlias(MediaContentsPeer::TRACKOFFSET, $trackOffset['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($trackOffset['max'])) { + $this->addUsingAlias(MediaContentsPeer::TRACKOFFSET, $trackOffset['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MediaContentsPeer::TRACKOFFSET, $trackOffset, $comparison); + } + + /** + * Filter the query on the cliplength column + * + * Example usage: + * + * $query->filterByCliplength('fooValue'); // WHERE cliplength = 'fooValue' + * $query->filterByCliplength('%fooValue%'); // WHERE cliplength LIKE '%fooValue%' + * + * + * @param string $cliplength 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 MediaContentsQuery The current query, for fluid interface + */ + public function filterByCliplength($cliplength = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($cliplength)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $cliplength)) { + $cliplength = str_replace('*', '%', $cliplength); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(MediaContentsPeer::CLIPLENGTH, $cliplength, $comparison); + } + + /** + * Filter the query on the cuein column + * + * Example usage: + * + * $query->filterByCuein('fooValue'); // WHERE cuein = 'fooValue' + * $query->filterByCuein('%fooValue%'); // WHERE cuein LIKE '%fooValue%' + * + * + * @param string $cuein 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 MediaContentsQuery The current query, for fluid interface + */ + public function filterByCuein($cuein = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($cuein)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $cuein)) { + $cuein = str_replace('*', '%', $cuein); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(MediaContentsPeer::CUEIN, $cuein, $comparison); + } + + /** + * Filter the query on the cueout column + * + * Example usage: + * + * $query->filterByCueout('fooValue'); // WHERE cueout = 'fooValue' + * $query->filterByCueout('%fooValue%'); // WHERE cueout LIKE '%fooValue%' + * + * + * @param string $cueout 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 MediaContentsQuery The current query, for fluid interface + */ + public function filterByCueout($cueout = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($cueout)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $cueout)) { + $cueout = str_replace('*', '%', $cueout); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(MediaContentsPeer::CUEOUT, $cueout, $comparison); + } + + /** + * Filter the query on the fadein column + * + * Example usage: + * + * $query->filterByFadein('2011-03-14'); // WHERE fadein = '2011-03-14' + * $query->filterByFadein('now'); // WHERE fadein = '2011-03-14' + * $query->filterByFadein(array('max' => 'yesterday')); // WHERE fadein < '2011-03-13' + * + * + * @param mixed $fadein The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaContentsQuery 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(MediaContentsPeer::FADEIN, $fadein['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($fadein['max'])) { + $this->addUsingAlias(MediaContentsPeer::FADEIN, $fadein['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MediaContentsPeer::FADEIN, $fadein, $comparison); + } + + /** + * Filter the query on the fadeout column + * + * Example usage: + * + * $query->filterByFadeout('2011-03-14'); // WHERE fadeout = '2011-03-14' + * $query->filterByFadeout('now'); // WHERE fadeout = '2011-03-14' + * $query->filterByFadeout(array('max' => 'yesterday')); // WHERE fadeout < '2011-03-13' + * + * + * @param mixed $fadeout The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaContentsQuery 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(MediaContentsPeer::FADEOUT, $fadeout['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($fadeout['max'])) { + $this->addUsingAlias(MediaContentsPeer::FADEOUT, $fadeout['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MediaContentsPeer::FADEOUT, $fadeout, $comparison); + } + + /** + * Filter the query by a related MediaItem object + * + * @param MediaItem|PropelObjectCollection $mediaItem The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaContentsQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByMediaItem($mediaItem, $comparison = null) + { + if ($mediaItem instanceof MediaItem) { + return $this + ->addUsingAlias(MediaContentsPeer::MEDIA_ID, $mediaItem->getId(), $comparison); + } elseif ($mediaItem instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(MediaContentsPeer::MEDIA_ID, $mediaItem->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByMediaItem() only accepts arguments of type MediaItem or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the MediaItem relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return MediaContentsQuery The current query, for fluid interface + */ + public function joinMediaItem($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('MediaItem'); + + // 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, 'MediaItem'); + } + + return $this; + } + + /** + * Use the MediaItem relation MediaItem 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 \Airtime\MediaItemQuery A secondary query class using the current class as primary query + */ + public function useMediaItemQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinMediaItem($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'MediaItem', '\Airtime\MediaItemQuery'); + } + + /** + * Exclude object from result + * + * @param MediaContents $mediaContents Object to remove from the list of results + * + * @return MediaContentsQuery The current query, for fluid interface + */ + public function prune($mediaContents = null) + { + if ($mediaContents) { + $this->addUsingAlias(MediaContentsPeer::ID, $mediaContents->getDbId(), Criteria::NOT_EQUAL); + } + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseMediaItem.php b/airtime_mvc/application/models/airtime/om/BaseMediaItem.php new file mode 100644 index 000000000..39a22ec98 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseMediaItem.php @@ -0,0 +1,2160 @@ +play_count = 0; + $this->length = '00:00:00'; + } + + /** + * Initializes internal state of BaseMediaItem 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 [name] column value. + * + * @return string + */ + public function getName() + { + + return $this->name; + } + + /** + * Get the [owner_id] column value. + * + * @return int + */ + public function getOwnerId() + { + + return $this->owner_id; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [optionally formatted] temporal [last_played] 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 getLastPlayedTime($format = 'Y-m-d H:i:s') + { + if ($this->last_played === null) { + return null; + } + + + try { + $dt = new DateTime($this->last_played); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->last_played, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [play_count] column value. + * + * @return int + */ + public function getPlayCount() + { + + return $this->play_count; + } + + /** + * Get the [length] column value. + * + * @return string + */ + public function getLength() + { + + return $this->length; + } + + /** + * Get the [optionally formatted] temporal [created_at] 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 getCreatedAt($format = 'Y-m-d H:i:s') + { + if ($this->created_at === null) { + return null; + } + + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [optionally formatted] temporal [updated_at] 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 getUpdatedAt($format = 'Y-m-d H:i:s') + { + if ($this->updated_at === null) { + return null; + } + + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [descendant_class] column value. + * + * @return string + */ + public function getDescendantClass() + { + + return $this->descendant_class; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return MediaItem The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = MediaItemPeer::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return MediaItem The current object (for fluent API support) + */ + public function setName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = MediaItemPeer::NAME; + } + + + return $this; + } // setName() + + /** + * Set the value of [owner_id] column. + * + * @param int $v new value + * @return MediaItem The current object (for fluent API support) + */ + public function setOwnerId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->owner_id !== $v) { + $this->owner_id = $v; + $this->modifiedColumns[] = MediaItemPeer::OWNER_ID; + } + + if ($this->aCcSubjs !== null && $this->aCcSubjs->getDbId() !== $v) { + $this->aCcSubjs = null; + } + + + return $this; + } // setOwnerId() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return MediaItem The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = MediaItemPeer::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Sets the value of [last_played] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return MediaItem The current object (for fluent API support) + */ + public function setLastPlayedTime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->last_played !== null || $dt !== null) { + $currentDateAsString = ($this->last_played !== null && $tmpDt = new DateTime($this->last_played)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->last_played = $newDateAsString; + $this->modifiedColumns[] = MediaItemPeer::LAST_PLAYED; + } + } // if either are not null + + + return $this; + } // setLastPlayedTime() + + /** + * Set the value of [play_count] column. + * + * @param int $v new value + * @return MediaItem The current object (for fluent API support) + */ + public function setPlayCount($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->play_count !== $v) { + $this->play_count = $v; + $this->modifiedColumns[] = MediaItemPeer::PLAY_COUNT; + } + + + return $this; + } // setPlayCount() + + /** + * Set the value of [length] column. + * + * @param string $v new value + * @return MediaItem The current object (for fluent API support) + */ + public function setLength($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->length !== $v) { + $this->length = $v; + $this->modifiedColumns[] = MediaItemPeer::LENGTH; + } + + + return $this; + } // setLength() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return MediaItem The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->created_at !== null || $dt !== null) { + $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->created_at = $newDateAsString; + $this->modifiedColumns[] = MediaItemPeer::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return MediaItem The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->updated_at !== null || $dt !== null) { + $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->updated_at = $newDateAsString; + $this->modifiedColumns[] = MediaItemPeer::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Set the value of [descendant_class] column. + * + * @param string $v new value + * @return MediaItem The current object (for fluent API support) + */ + public function setDescendantClass($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->descendant_class !== $v) { + $this->descendant_class = $v; + $this->modifiedColumns[] = MediaItemPeer::DESCENDANT_CLASS; + } + + + return $this; + } // setDescendantClass() + + /** + * 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->play_count !== 0) { + return false; + } + + if ($this->length !== '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 resultset 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->owner_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; + $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->last_played = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->play_count = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; + $this->length = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; + $this->updated_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->descendant_class = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 10; // 10 = MediaItemPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating MediaItem 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_id !== $this->aCcSubjs->getDbId()) { + $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(MediaItemPeer::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 = MediaItemPeer::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->collMediaContentss = null; + + $this->singleAudioFile = null; + + $this->singleWebstream = null; + + $this->singlePlaylist = null; + + $this->singleBlock = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(MediaItemPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = MediaItemQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(MediaItemPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(MediaItemPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(MediaItemPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(MediaItemPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + MediaItemPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding 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->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->mediaContentssScheduledForDeletion !== null) { + if (!$this->mediaContentssScheduledForDeletion->isEmpty()) { + MediaContentsQuery::create() + ->filterByPrimaryKeys($this->mediaContentssScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->mediaContentssScheduledForDeletion = null; + } + } + + if ($this->collMediaContentss !== null) { + foreach ($this->collMediaContentss as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->singleAudioFile !== null) { + if (!$this->singleAudioFile->isDeleted() && ($this->singleAudioFile->isNew() || $this->singleAudioFile->isModified())) { + $affectedRows += $this->singleAudioFile->save($con); + } + } + + if ($this->singleWebstream !== null) { + if (!$this->singleWebstream->isDeleted() && ($this->singleWebstream->isNew() || $this->singleWebstream->isModified())) { + $affectedRows += $this->singleWebstream->save($con); + } + } + + if ($this->singlePlaylist !== null) { + if (!$this->singlePlaylist->isDeleted() && ($this->singlePlaylist->isNew() || $this->singlePlaylist->isModified())) { + $affectedRows += $this->singlePlaylist->save($con); + } + } + + if ($this->singleBlock !== null) { + if (!$this->singleBlock->isDeleted() && ($this->singleBlock->isNew() || $this->singleBlock->isModified())) { + $affectedRows += $this->singleBlock->save($con); + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = MediaItemPeer::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . MediaItemPeer::ID . ')'); + } + if (null === $this->id) { + try { + $stmt = $con->query("SELECT nextval('media_item_id_seq')"); + $row = $stmt->fetch(PDO::FETCH_NUM); + $this->id = $row[0]; + } catch (Exception $e) { + throw new PropelException('Unable to get sequence id.', $e); + } + } + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(MediaItemPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(MediaItemPeer::NAME)) { + $modifiedColumns[':p' . $index++] = '"name"'; + } + if ($this->isColumnModified(MediaItemPeer::OWNER_ID)) { + $modifiedColumns[':p' . $index++] = '"owner_id"'; + } + if ($this->isColumnModified(MediaItemPeer::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = '"description"'; + } + if ($this->isColumnModified(MediaItemPeer::LAST_PLAYED)) { + $modifiedColumns[':p' . $index++] = '"last_played"'; + } + if ($this->isColumnModified(MediaItemPeer::PLAY_COUNT)) { + $modifiedColumns[':p' . $index++] = '"play_count"'; + } + if ($this->isColumnModified(MediaItemPeer::LENGTH)) { + $modifiedColumns[':p' . $index++] = '"length"'; + } + if ($this->isColumnModified(MediaItemPeer::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = '"created_at"'; + } + if ($this->isColumnModified(MediaItemPeer::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = '"updated_at"'; + } + if ($this->isColumnModified(MediaItemPeer::DESCENDANT_CLASS)) { + $modifiedColumns[':p' . $index++] = '"descendant_class"'; + } + + $sql = sprintf( + 'INSERT INTO "media_item" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"name"': + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); + break; + case '"owner_id"': + $stmt->bindValue($identifier, $this->owner_id, PDO::PARAM_INT); + break; + case '"description"': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case '"last_played"': + $stmt->bindValue($identifier, $this->last_played, PDO::PARAM_STR); + break; + case '"play_count"': + $stmt->bindValue($identifier, $this->play_count, PDO::PARAM_INT); + break; + case '"length"': + $stmt->bindValue($identifier, $this->length, PDO::PARAM_STR); + break; + case '"created_at"': + $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + break; + case '"updated_at"': + $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + break; + case '"descendant_class"': + $stmt->bindValue($identifier, $this->descendant_class, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding 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 = MediaItemPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collMediaContentss !== null) { + foreach ($this->collMediaContentss as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->singleAudioFile !== null) { + if (!$this->singleAudioFile->validate($columns)) { + $failureMap = array_merge($failureMap, $this->singleAudioFile->getValidationFailures()); + } + } + + if ($this->singleWebstream !== null) { + if (!$this->singleWebstream->validate($columns)) { + $failureMap = array_merge($failureMap, $this->singleWebstream->getValidationFailures()); + } + } + + if ($this->singlePlaylist !== null) { + if (!$this->singlePlaylist->validate($columns)) { + $failureMap = array_merge($failureMap, $this->singlePlaylist->getValidationFailures()); + } + } + + if ($this->singleBlock !== null) { + if (!$this->singleBlock->validate($columns)) { + $failureMap = array_merge($failureMap, $this->singleBlock->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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MediaItemPeer::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->getName(); + break; + case 2: + return $this->getOwnerId(); + break; + case 3: + return $this->getDescription(); + break; + case 4: + return $this->getLastPlayedTime(); + break; + case 5: + return $this->getPlayCount(); + break; + case 6: + return $this->getLength(); + break; + case 7: + return $this->getCreatedAt(); + break; + case 8: + return $this->getUpdatedAt(); + break; + case 9: + return $this->getDescendantClass(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['MediaItem'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['MediaItem'][$this->getPrimaryKey()] = true; + $keys = MediaItemPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getName(), + $keys[2] => $this->getOwnerId(), + $keys[3] => $this->getDescription(), + $keys[4] => $this->getLastPlayedTime(), + $keys[5] => $this->getPlayCount(), + $keys[6] => $this->getLength(), + $keys[7] => $this->getCreatedAt(), + $keys[8] => $this->getUpdatedAt(), + $keys[9] => $this->getDescendantClass(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCcSubjs) { + $result['CcSubjs'] = $this->aCcSubjs->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collMediaContentss) { + $result['MediaContentss'] = $this->collMediaContentss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->singleAudioFile) { + $result['AudioFile'] = $this->singleAudioFile->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->singleWebstream) { + $result['Webstream'] = $this->singleWebstream->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->singlePlaylist) { + $result['Playlist'] = $this->singlePlaylist->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->singleBlock) { + $result['Block'] = $this->singleBlock->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MediaItemPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setName($value); + break; + case 2: + $this->setOwnerId($value); + break; + case 3: + $this->setDescription($value); + break; + case 4: + $this->setLastPlayedTime($value); + break; + case 5: + $this->setPlayCount($value); + break; + case 6: + $this->setLength($value); + break; + case 7: + $this->setCreatedAt($value); + break; + case 8: + $this->setUpdatedAt($value); + break; + case 9: + $this->setDescendantClass($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 BasePeer::TYPE_PHPNAME + * + * @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 = MediaItemPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setOwnerId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setLastPlayedTime($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setPlayCount($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setLength($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDescendantClass($arr[$keys[9]]); + } + + /** + * 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(MediaItemPeer::DATABASE_NAME); + + if ($this->isColumnModified(MediaItemPeer::ID)) $criteria->add(MediaItemPeer::ID, $this->id); + if ($this->isColumnModified(MediaItemPeer::NAME)) $criteria->add(MediaItemPeer::NAME, $this->name); + if ($this->isColumnModified(MediaItemPeer::OWNER_ID)) $criteria->add(MediaItemPeer::OWNER_ID, $this->owner_id); + if ($this->isColumnModified(MediaItemPeer::DESCRIPTION)) $criteria->add(MediaItemPeer::DESCRIPTION, $this->description); + if ($this->isColumnModified(MediaItemPeer::LAST_PLAYED)) $criteria->add(MediaItemPeer::LAST_PLAYED, $this->last_played); + if ($this->isColumnModified(MediaItemPeer::PLAY_COUNT)) $criteria->add(MediaItemPeer::PLAY_COUNT, $this->play_count); + if ($this->isColumnModified(MediaItemPeer::LENGTH)) $criteria->add(MediaItemPeer::LENGTH, $this->length); + if ($this->isColumnModified(MediaItemPeer::CREATED_AT)) $criteria->add(MediaItemPeer::CREATED_AT, $this->created_at); + if ($this->isColumnModified(MediaItemPeer::UPDATED_AT)) $criteria->add(MediaItemPeer::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(MediaItemPeer::DESCENDANT_CLASS)) $criteria->add(MediaItemPeer::DESCENDANT_CLASS, $this->descendant_class); + + 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(MediaItemPeer::DATABASE_NAME); + $criteria->add(MediaItemPeer::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 MediaItem (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setName($this->getName()); + $copyObj->setOwnerId($this->getOwnerId()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setLastPlayedTime($this->getLastPlayedTime()); + $copyObj->setPlayCount($this->getPlayCount()); + $copyObj->setLength($this->getLength()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + $copyObj->setDescendantClass($this->getDescendantClass()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + foreach ($this->getMediaContentss() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addMediaContents($relObj->copy($deepCopy)); + } + } + + $relObj = $this->getAudioFile(); + if ($relObj) { + $copyObj->setAudioFile($relObj->copy($deepCopy)); + } + + $relObj = $this->getWebstream(); + if ($relObj) { + $copyObj->setWebstream($relObj->copy($deepCopy)); + } + + $relObj = $this->getPlaylist(); + if ($relObj) { + $copyObj->setPlaylist($relObj->copy($deepCopy)); + } + + $relObj = $this->getBlock(); + if ($relObj) { + $copyObj->setBlock($relObj->copy($deepCopy)); + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 MediaItem 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 MediaItemPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new MediaItemPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a CcSubjs object. + * + * @param CcSubjs $v + * @return MediaItem The current object (for fluent API support) + * @throws PropelException + */ + public function setCcSubjs(CcSubjs $v = null) + { + if ($v === null) { + $this->setOwnerId(NULL); + } else { + $this->setOwnerId($v->getDbId()); + } + + $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->addMediaItem($this); + } + + + return $this; + } + + + /** + * Get the associated CcSubjs object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getCcSubjs(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcSubjs === null && ($this->owner_id !== null) && $doQuery) { + $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->owner_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->aCcSubjs->addMediaItems($this); + */ + } + + return $this->aCcSubjs; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('MediaContents' == $relationName) { + $this->initMediaContentss(); + } + } + + /** + * Clears out the collMediaContentss 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 MediaItem The current object (for fluent API support) + * @see addMediaContentss() + */ + public function clearMediaContentss() + { + $this->collMediaContentss = null; // important to set this to null since that means it is uninitialized + $this->collMediaContentssPartial = null; + + return $this; + } + + /** + * reset is the collMediaContentss collection loaded partially + * + * @return void + */ + public function resetPartialMediaContentss($v = true) + { + $this->collMediaContentssPartial = $v; + } + + /** + * Initializes the collMediaContentss collection. + * + * By default this just sets the collMediaContentss collection to an empty array (like clearcollMediaContentss()); + * 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. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initMediaContentss($overrideExisting = true) + { + if (null !== $this->collMediaContentss && !$overrideExisting) { + return; + } + $this->collMediaContentss = new PropelObjectCollection(); + $this->collMediaContentss->setModel('MediaContents'); + } + + /** + * Gets an array of MediaContents 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 MediaItem 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 PropelObjectCollection|MediaContents[] List of MediaContents objects + * @throws PropelException + */ + public function getMediaContentss($criteria = null, PropelPDO $con = null) + { + $partial = $this->collMediaContentssPartial && !$this->isNew(); + if (null === $this->collMediaContentss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collMediaContentss) { + // return empty collection + $this->initMediaContentss(); + } else { + $collMediaContentss = MediaContentsQuery::create(null, $criteria) + ->filterByMediaItem($this) + ->find($con); + if (null !== $criteria) { + if (false !== $this->collMediaContentssPartial && count($collMediaContentss)) { + $this->initMediaContentss(false); + + foreach ($collMediaContentss as $obj) { + if (false == $this->collMediaContentss->contains($obj)) { + $this->collMediaContentss->append($obj); + } + } + + $this->collMediaContentssPartial = true; + } + + $collMediaContentss->getInternalIterator()->rewind(); + + return $collMediaContentss; + } + + if ($partial && $this->collMediaContentss) { + foreach ($this->collMediaContentss as $obj) { + if ($obj->isNew()) { + $collMediaContentss[] = $obj; + } + } + } + + $this->collMediaContentss = $collMediaContentss; + $this->collMediaContentssPartial = false; + } + } + + return $this->collMediaContentss; + } + + /** + * Sets a collection of MediaContents objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param PropelCollection $mediaContentss A Propel collection. + * @param PropelPDO $con Optional connection object + * @return MediaItem The current object (for fluent API support) + */ + public function setMediaContentss(PropelCollection $mediaContentss, PropelPDO $con = null) + { + $mediaContentssToDelete = $this->getMediaContentss(new Criteria(), $con)->diff($mediaContentss); + + + $this->mediaContentssScheduledForDeletion = $mediaContentssToDelete; + + foreach ($mediaContentssToDelete as $mediaContentsRemoved) { + $mediaContentsRemoved->setMediaItem(null); + } + + $this->collMediaContentss = null; + foreach ($mediaContentss as $mediaContents) { + $this->addMediaContents($mediaContents); + } + + $this->collMediaContentss = $mediaContentss; + $this->collMediaContentssPartial = false; + + return $this; + } + + /** + * Returns the number of related MediaContents objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param PropelPDO $con + * @return int Count of related MediaContents objects. + * @throws PropelException + */ + public function countMediaContentss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + { + $partial = $this->collMediaContentssPartial && !$this->isNew(); + if (null === $this->collMediaContentss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collMediaContentss) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getMediaContentss()); + } + $query = MediaContentsQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByMediaItem($this) + ->count($con); + } + + return count($this->collMediaContentss); + } + + /** + * Method called to associate a MediaContents object to this object + * through the MediaContents foreign key attribute. + * + * @param MediaContents $l MediaContents + * @return MediaItem The current object (for fluent API support) + */ + public function addMediaContents(MediaContents $l) + { + if ($this->collMediaContentss === null) { + $this->initMediaContentss(); + $this->collMediaContentssPartial = true; + } + + if (!in_array($l, $this->collMediaContentss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddMediaContents($l); + + if ($this->mediaContentssScheduledForDeletion and $this->mediaContentssScheduledForDeletion->contains($l)) { + $this->mediaContentssScheduledForDeletion->remove($this->mediaContentssScheduledForDeletion->search($l)); + } + } + + return $this; + } + + /** + * @param MediaContents $mediaContents The mediaContents object to add. + */ + protected function doAddMediaContents($mediaContents) + { + $this->collMediaContentss[]= $mediaContents; + $mediaContents->setMediaItem($this); + } + + /** + * @param MediaContents $mediaContents The mediaContents object to remove. + * @return MediaItem The current object (for fluent API support) + */ + public function removeMediaContents($mediaContents) + { + if ($this->getMediaContentss()->contains($mediaContents)) { + $this->collMediaContentss->remove($this->collMediaContentss->search($mediaContents)); + if (null === $this->mediaContentssScheduledForDeletion) { + $this->mediaContentssScheduledForDeletion = clone $this->collMediaContentss; + $this->mediaContentssScheduledForDeletion->clear(); + } + $this->mediaContentssScheduledForDeletion[]= $mediaContents; + $mediaContents->setMediaItem(null); + } + + return $this; + } + + /** + * Gets a single AudioFile object, which is related to this object by a one-to-one relationship. + * + * @param PropelPDO $con optional connection object + * @return AudioFile + * @throws PropelException + */ + public function getAudioFile(PropelPDO $con = null) + { + + if ($this->singleAudioFile === null && !$this->isNew()) { + $this->singleAudioFile = AudioFileQuery::create()->findPk($this->getPrimaryKey(), $con); + } + + return $this->singleAudioFile; + } + + /** + * Sets a single AudioFile object as related to this object by a one-to-one relationship. + * + * @param AudioFile $v AudioFile + * @return MediaItem The current object (for fluent API support) + * @throws PropelException + */ + public function setAudioFile(AudioFile $v = null) + { + $this->singleAudioFile = $v; + + // Make sure that that the passed-in AudioFile isn't already associated with this object + if ($v !== null && $v->getMediaItem(null, false) === null) { + $v->setMediaItem($this); + } + + return $this; + } + + /** + * Gets a single Webstream object, which is related to this object by a one-to-one relationship. + * + * @param PropelPDO $con optional connection object + * @return Webstream + * @throws PropelException + */ + public function getWebstream(PropelPDO $con = null) + { + + if ($this->singleWebstream === null && !$this->isNew()) { + $this->singleWebstream = WebstreamQuery::create()->findPk($this->getPrimaryKey(), $con); + } + + return $this->singleWebstream; + } + + /** + * Sets a single Webstream object as related to this object by a one-to-one relationship. + * + * @param Webstream $v Webstream + * @return MediaItem The current object (for fluent API support) + * @throws PropelException + */ + public function setWebstream(Webstream $v = null) + { + $this->singleWebstream = $v; + + // Make sure that that the passed-in Webstream isn't already associated with this object + if ($v !== null && $v->getMediaItem(null, false) === null) { + $v->setMediaItem($this); + } + + return $this; + } + + /** + * Gets a single Playlist object, which is related to this object by a one-to-one relationship. + * + * @param PropelPDO $con optional connection object + * @return Playlist + * @throws PropelException + */ + public function getPlaylist(PropelPDO $con = null) + { + + if ($this->singlePlaylist === null && !$this->isNew()) { + $this->singlePlaylist = PlaylistQuery::create()->findPk($this->getPrimaryKey(), $con); + } + + return $this->singlePlaylist; + } + + /** + * Sets a single Playlist object as related to this object by a one-to-one relationship. + * + * @param Playlist $v Playlist + * @return MediaItem The current object (for fluent API support) + * @throws PropelException + */ + public function setPlaylist(Playlist $v = null) + { + $this->singlePlaylist = $v; + + // Make sure that that the passed-in Playlist isn't already associated with this object + if ($v !== null && $v->getMediaItem(null, false) === null) { + $v->setMediaItem($this); + } + + return $this; + } + + /** + * Gets a single Block object, which is related to this object by a one-to-one relationship. + * + * @param PropelPDO $con optional connection object + * @return Block + * @throws PropelException + */ + public function getBlock(PropelPDO $con = null) + { + + if ($this->singleBlock === null && !$this->isNew()) { + $this->singleBlock = BlockQuery::create()->findPk($this->getPrimaryKey(), $con); + } + + return $this->singleBlock; + } + + /** + * Sets a single Block object as related to this object by a one-to-one relationship. + * + * @param Block $v Block + * @return MediaItem The current object (for fluent API support) + * @throws PropelException + */ + public function setBlock(Block $v = null) + { + $this->singleBlock = $v; + + // Make sure that that the passed-in Block isn't already associated with this object + if ($v !== null && $v->getMediaItem(null, false) === null) { + $v->setMediaItem($this); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->name = null; + $this->owner_id = null; + $this->description = null; + $this->last_played = null; + $this->play_count = null; + $this->length = null; + $this->created_at = null; + $this->updated_at = null; + $this->descendant_class = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->collMediaContentss) { + foreach ($this->collMediaContentss as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->singleAudioFile) { + $this->singleAudioFile->clearAllReferences($deep); + } + if ($this->singleWebstream) { + $this->singleWebstream->clearAllReferences($deep); + } + if ($this->singlePlaylist) { + $this->singlePlaylist->clearAllReferences($deep); + } + if ($this->singleBlock) { + $this->singleBlock->clearAllReferences($deep); + } + if ($this->aCcSubjs instanceof Persistent) { + $this->aCcSubjs->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + if ($this->collMediaContentss instanceof PropelCollection) { + $this->collMediaContentss->clearIterator(); + } + $this->collMediaContentss = null; + if ($this->singleAudioFile instanceof PropelCollection) { + $this->singleAudioFile->clearIterator(); + } + $this->singleAudioFile = null; + if ($this->singleWebstream instanceof PropelCollection) { + $this->singleWebstream->clearIterator(); + } + $this->singleWebstream = null; + if ($this->singlePlaylist instanceof PropelCollection) { + $this->singlePlaylist->clearIterator(); + } + $this->singlePlaylist = null; + if ($this->singleBlock instanceof PropelCollection) { + $this->singleBlock->clearIterator(); + } + $this->singleBlock = null; + $this->aCcSubjs = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(MediaItemPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return MediaItem The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = MediaItemPeer::UPDATED_AT; + + return $this; + } + + // concrete_inheritance_parent behavior + + /** + * Whether or not this object is the parent of a child object + * + * @return bool + */ + public function hasChildObject() + { + return $this->getDescendantClass() !== null; + } + + /** + * Get the child object of this object + * + * @return mixed + */ + public function getChildObject() + { + if (!$this->hasChildObject()) { + return null; + } + $childObjectClass = $this->getDescendantClass(); + $childObject = PropelQuery::from($childObjectClass)->findPk($this->getPrimaryKey()); + + return $childObject->hasChildObject() ? $childObject->getChildObject() : $childObject; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseMediaItemPeer.php b/airtime_mvc/application/models/airtime/om/BaseMediaItemPeer.php new file mode 100644 index 000000000..33bee7319 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseMediaItemPeer.php @@ -0,0 +1,1074 @@ + array ('Id', 'Name', 'OwnerId', 'Description', 'LastPlayedTime', 'PlayCount', 'Length', 'CreatedAt', 'UpdatedAt', 'DescendantClass', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'name', 'ownerId', 'description', 'lastPlayedTime', 'playCount', 'length', 'createdAt', 'updatedAt', 'descendantClass', ), + BasePeer::TYPE_COLNAME => array (MediaItemPeer::ID, MediaItemPeer::NAME, MediaItemPeer::OWNER_ID, MediaItemPeer::DESCRIPTION, MediaItemPeer::LAST_PLAYED, MediaItemPeer::PLAY_COUNT, MediaItemPeer::LENGTH, MediaItemPeer::CREATED_AT, MediaItemPeer::UPDATED_AT, MediaItemPeer::DESCENDANT_CLASS, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'OWNER_ID', 'DESCRIPTION', 'LAST_PLAYED', 'PLAY_COUNT', 'LENGTH', 'CREATED_AT', 'UPDATED_AT', 'DESCENDANT_CLASS', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'owner_id', 'description', 'last_played', 'play_count', 'length', 'created_at', 'updated_at', 'descendant_class', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. MediaItemPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'OwnerId' => 2, 'Description' => 3, 'LastPlayedTime' => 4, 'PlayCount' => 5, 'Length' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, 'DescendantClass' => 9, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'name' => 1, 'ownerId' => 2, 'description' => 3, 'lastPlayedTime' => 4, 'playCount' => 5, 'length' => 6, 'createdAt' => 7, 'updatedAt' => 8, 'descendantClass' => 9, ), + BasePeer::TYPE_COLNAME => array (MediaItemPeer::ID => 0, MediaItemPeer::NAME => 1, MediaItemPeer::OWNER_ID => 2, MediaItemPeer::DESCRIPTION => 3, MediaItemPeer::LAST_PLAYED => 4, MediaItemPeer::PLAY_COUNT => 5, MediaItemPeer::LENGTH => 6, MediaItemPeer::CREATED_AT => 7, MediaItemPeer::UPDATED_AT => 8, MediaItemPeer::DESCENDANT_CLASS => 9, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'OWNER_ID' => 2, 'DESCRIPTION' => 3, 'LAST_PLAYED' => 4, 'PLAY_COUNT' => 5, 'LENGTH' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, 'DESCENDANT_CLASS' => 9, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'owner_id' => 2, 'description' => 3, 'last_played' => 4, 'play_count' => 5, 'length' => 6, 'created_at' => 7, 'updated_at' => 8, 'descendant_class' => 9, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = MediaItemPeer::getFieldNames($toType); + $key = isset(MediaItemPeer::$fieldKeys[$fromType][$name]) ? MediaItemPeer::$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(MediaItemPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, MediaItemPeer::$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 MediaItemPeer::$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. MediaItemPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(MediaItemPeer::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(MediaItemPeer::ID); + $criteria->addSelectColumn(MediaItemPeer::NAME); + $criteria->addSelectColumn(MediaItemPeer::OWNER_ID); + $criteria->addSelectColumn(MediaItemPeer::DESCRIPTION); + $criteria->addSelectColumn(MediaItemPeer::LAST_PLAYED); + $criteria->addSelectColumn(MediaItemPeer::PLAY_COUNT); + $criteria->addSelectColumn(MediaItemPeer::LENGTH); + $criteria->addSelectColumn(MediaItemPeer::CREATED_AT); + $criteria->addSelectColumn(MediaItemPeer::UPDATED_AT); + $criteria->addSelectColumn(MediaItemPeer::DESCENDANT_CLASS); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.name'); + $criteria->addSelectColumn($alias . '.owner_id'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.last_played'); + $criteria->addSelectColumn($alias . '.play_count'); + $criteria->addSelectColumn($alias . '.length'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); + $criteria->addSelectColumn($alias . '.descendant_class'); + } + } + + /** + * 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(MediaItemPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + MediaItemPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(MediaItemPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(MediaItemPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return MediaItem + * @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 = MediaItemPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 MediaItemPeer::populateObjects(MediaItemPeer::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 directly (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(MediaItemPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + MediaItemPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(MediaItemPeer::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 MediaItem $obj A MediaItem object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getId(); + } // if key === null + MediaItemPeer::$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 MediaItem object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof MediaItem) { + $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 MediaItem object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(MediaItemPeer::$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 MediaItem 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(MediaItemPeer::$instances[$key])) { + return MediaItemPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (MediaItemPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + MediaItemPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to media_item + * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in MediaContentsPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + MediaContentsPeer::clearInstancePool(); + // Invalidate objects in AudioFilePeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + AudioFilePeer::clearInstancePool(); + // Invalidate objects in WebstreamPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + WebstreamPeer::clearInstancePool(); + // Invalidate objects in PlaylistPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + PlaylistPeer::clearInstancePool(); + // Invalidate objects in BlockPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + BlockPeer::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 = MediaItemPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = MediaItemPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = MediaItemPeer::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; + MediaItemPeer::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 (MediaItem object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = MediaItemPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = MediaItemPeer::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 + MediaItemPeer::NUM_HYDRATE_COLUMNS; + } elseif (null == $key) { + // empty resultset, probably from a left join + // since this table is abstract, we can't hydrate an empty object + $obj = null; + $col = $startcol + MediaItemPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = MediaItemPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + MediaItemPeer::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(MediaItemPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + MediaItemPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(MediaItemPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(MediaItemPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(MediaItemPeer::OWNER_ID, 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 MediaItem 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 MediaItem 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(MediaItemPeer::DATABASE_NAME); + } + + MediaItemPeer::addSelectColumns($criteria); + $startcol = MediaItemPeer::NUM_HYDRATE_COLUMNS; + CcSubjsPeer::addSelectColumns($criteria); + + $criteria->addJoin(MediaItemPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = MediaItemPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = MediaItemPeer::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 = MediaItemPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + MediaItemPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (MediaItem) to $obj2 (CcSubjs) + $obj2->addMediaItem($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(MediaItemPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + MediaItemPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(MediaItemPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(MediaItemPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(MediaItemPeer::OWNER_ID, 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 MediaItem 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 MediaItem 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(MediaItemPeer::DATABASE_NAME); + } + + MediaItemPeer::addSelectColumns($criteria); + $startcol2 = MediaItemPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(MediaItemPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = MediaItemPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = MediaItemPeer::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 = MediaItemPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + MediaItemPeer::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(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (MediaItem) to the collection in $obj2 (CcSubjs) + $obj2->addMediaItem($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(MediaItemPeer::DATABASE_NAME)->getTable(MediaItemPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseMediaItemPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseMediaItemPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\map\MediaItemTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * This method must be overridden by the stub subclass, because + * MediaItem is declared abstract in the schema. + */ + abstract public static function getOMClass($row = 0, $colnum = 0); + + /** + * Performs an INSERT on the database, given a MediaItem or Criteria object. + * + * @param mixed $values Criteria or MediaItem 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(MediaItemPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from MediaItem object + } + + if ($criteria->containsKey(MediaItemPeer::ID) && $criteria->keyContainsValue(MediaItemPeer::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.MediaItemPeer::ID.')'); + } + + + // Set the correct dbName + $criteria->setDbName(MediaItemPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a MediaItem or Criteria object. + * + * @param mixed $values Criteria or MediaItem 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(MediaItemPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(MediaItemPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(MediaItemPeer::ID); + $value = $criteria->remove(MediaItemPeer::ID); + if ($value) { + $selectCriteria->add(MediaItemPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(MediaItemPeer::TABLE_NAME); + } + + } else { // $values is MediaItem object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(MediaItemPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the media_item table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(MediaItemPeer::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(MediaItemPeer::TABLE_NAME, $con, MediaItemPeer::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). + MediaItemPeer::clearInstancePool(); + MediaItemPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a MediaItem or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or MediaItem 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(MediaItemPeer::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. + MediaItemPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof MediaItem) { // it's a model object + // invalidate the cache for this single object + MediaItemPeer::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(MediaItemPeer::DATABASE_NAME); + $criteria->add(MediaItemPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + MediaItemPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(MediaItemPeer::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); + MediaItemPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given MediaItem 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 MediaItem $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(MediaItemPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(MediaItemPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(MediaItemPeer::DATABASE_NAME, MediaItemPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return MediaItem + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = MediaItemPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(MediaItemPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(MediaItemPeer::DATABASE_NAME); + $criteria->add(MediaItemPeer::ID, $pk); + + $v = MediaItemPeer::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 + * @return MediaItem[] + * @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(MediaItemPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(MediaItemPeer::DATABASE_NAME); + $criteria->add(MediaItemPeer::ID, $pks, Criteria::IN); + $objs = MediaItemPeer::doSelect($criteria, $con); + } + + return $objs; + } + +} // BaseMediaItemPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseMediaItemPeer::buildTableMap(); + diff --git a/airtime_mvc/application/models/airtime/om/BaseMediaItemQuery.php b/airtime_mvc/application/models/airtime/om/BaseMediaItemQuery.php new file mode 100644 index 000000000..d9f1dc410 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseMediaItemQuery.php @@ -0,0 +1,1199 @@ +mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return MediaItem|MediaItem[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = MediaItemPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(MediaItemPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return MediaItem A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return MediaItem A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "name", "owner_id", "description", "last_played", "play_count", "length", "created_at", "updated_at", "descendant_class" FROM "media_item" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new MediaItem(); + $obj->hydrate($row); + MediaItemPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return MediaItem|MediaItem[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($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|MediaItem[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($stmt); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(MediaItemPeer::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 MediaItemQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(MediaItemPeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(MediaItemPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(MediaItemPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MediaItemPeer::ID, $id, $comparison); + } + + /** + * Filter the query on the name column + * + * Example usage: + * + * $query->filterByName('fooValue'); // WHERE name = 'fooValue' + * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' + * + * + * @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 MediaItemQuery 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(MediaItemPeer::NAME, $name, $comparison); + } + + /** + * Filter the query on the owner_id column + * + * Example usage: + * + * $query->filterByOwnerId(1234); // WHERE owner_id = 1234 + * $query->filterByOwnerId(array(12, 34)); // WHERE owner_id IN (12, 34) + * $query->filterByOwnerId(array('min' => 12)); // WHERE owner_id >= 12 + * $query->filterByOwnerId(array('max' => 12)); // WHERE owner_id <= 12 + * + * + * @see filterByCcSubjs() + * + * @param mixed $ownerId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function filterByOwnerId($ownerId = null, $comparison = null) + { + if (is_array($ownerId)) { + $useMinMax = false; + if (isset($ownerId['min'])) { + $this->addUsingAlias(MediaItemPeer::OWNER_ID, $ownerId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($ownerId['max'])) { + $this->addUsingAlias(MediaItemPeer::OWNER_ID, $ownerId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MediaItemPeer::OWNER_ID, $ownerId, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description 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 MediaItemQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(MediaItemPeer::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the last_played column + * + * Example usage: + * + * $query->filterByLastPlayedTime('2011-03-14'); // WHERE last_played = '2011-03-14' + * $query->filterByLastPlayedTime('now'); // WHERE last_played = '2011-03-14' + * $query->filterByLastPlayedTime(array('max' => 'yesterday')); // WHERE last_played < '2011-03-13' + * + * + * @param mixed $lastPlayedTime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function filterByLastPlayedTime($lastPlayedTime = null, $comparison = null) + { + if (is_array($lastPlayedTime)) { + $useMinMax = false; + if (isset($lastPlayedTime['min'])) { + $this->addUsingAlias(MediaItemPeer::LAST_PLAYED, $lastPlayedTime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($lastPlayedTime['max'])) { + $this->addUsingAlias(MediaItemPeer::LAST_PLAYED, $lastPlayedTime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MediaItemPeer::LAST_PLAYED, $lastPlayedTime, $comparison); + } + + /** + * Filter the query on the play_count column + * + * Example usage: + * + * $query->filterByPlayCount(1234); // WHERE play_count = 1234 + * $query->filterByPlayCount(array(12, 34)); // WHERE play_count IN (12, 34) + * $query->filterByPlayCount(array('min' => 12)); // WHERE play_count >= 12 + * $query->filterByPlayCount(array('max' => 12)); // WHERE play_count <= 12 + * + * + * @param mixed $playCount The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function filterByPlayCount($playCount = null, $comparison = null) + { + if (is_array($playCount)) { + $useMinMax = false; + if (isset($playCount['min'])) { + $this->addUsingAlias(MediaItemPeer::PLAY_COUNT, $playCount['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($playCount['max'])) { + $this->addUsingAlias(MediaItemPeer::PLAY_COUNT, $playCount['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MediaItemPeer::PLAY_COUNT, $playCount, $comparison); + } + + /** + * Filter the query on the length column + * + * Example usage: + * + * $query->filterByLength('fooValue'); // WHERE length = 'fooValue' + * $query->filterByLength('%fooValue%'); // WHERE length LIKE '%fooValue%' + * + * + * @param string $length 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 MediaItemQuery The current query, for fluid interface + */ + public function filterByLength($length = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($length)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $length)) { + $length = str_replace('*', '%', $length); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(MediaItemPeer::LENGTH, $length, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at < '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(MediaItemPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(MediaItemPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MediaItemPeer::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at < '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(MediaItemPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(MediaItemPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MediaItemPeer::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query on the descendant_class column + * + * Example usage: + * + * $query->filterByDescendantClass('fooValue'); // WHERE descendant_class = 'fooValue' + * $query->filterByDescendantClass('%fooValue%'); // WHERE descendant_class LIKE '%fooValue%' + * + * + * @param string $descendantClass 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 MediaItemQuery The current query, for fluid interface + */ + public function filterByDescendantClass($descendantClass = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($descendantClass)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $descendantClass)) { + $descendantClass = str_replace('*', '%', $descendantClass); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(MediaItemPeer::DESCENDANT_CLASS, $descendantClass, $comparison); + } + + /** + * Filter the query by a related CcSubjs object + * + * @param CcSubjs|PropelObjectCollection $ccSubjs The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaItemQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcSubjs($ccSubjs, $comparison = null) + { + if ($ccSubjs instanceof CcSubjs) { + return $this + ->addUsingAlias(MediaItemPeer::OWNER_ID, $ccSubjs->getDbId(), $comparison); + } elseif ($ccSubjs instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(MediaItemPeer::OWNER_ID, $ccSubjs->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcSubjs() only accepts arguments of type CcSubjs or PropelCollection'); + } + } + + /** + * 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 MediaItemQuery The current query, for fluid interface + */ + public function joinCcSubjs($relationAlias = null, $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 \Airtime\CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSubjs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', '\Airtime\CcSubjsQuery'); + } + + /** + * Filter the query by a related MediaContents object + * + * @param MediaContents|PropelObjectCollection $mediaContents the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaItemQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByMediaContents($mediaContents, $comparison = null) + { + if ($mediaContents instanceof MediaContents) { + return $this + ->addUsingAlias(MediaItemPeer::ID, $mediaContents->getMediaId(), $comparison); + } elseif ($mediaContents instanceof PropelObjectCollection) { + return $this + ->useMediaContentsQuery() + ->filterByPrimaryKeys($mediaContents->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByMediaContents() only accepts arguments of type MediaContents or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the MediaContents relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function joinMediaContents($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('MediaContents'); + + // 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, 'MediaContents'); + } + + return $this; + } + + /** + * Use the MediaContents relation MediaContents 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 \Airtime\MediaItem\MediaContentsQuery A secondary query class using the current class as primary query + */ + public function useMediaContentsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinMediaContents($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'MediaContents', '\Airtime\MediaItem\MediaContentsQuery'); + } + + /** + * Filter the query by a related AudioFile object + * + * @param AudioFile|PropelObjectCollection $audioFile the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaItemQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByAudioFile($audioFile, $comparison = null) + { + if ($audioFile instanceof AudioFile) { + return $this + ->addUsingAlias(MediaItemPeer::ID, $audioFile->getId(), $comparison); + } elseif ($audioFile instanceof PropelObjectCollection) { + return $this + ->useAudioFileQuery() + ->filterByPrimaryKeys($audioFile->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByAudioFile() only accepts arguments of type AudioFile or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the AudioFile relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function joinAudioFile($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('AudioFile'); + + // 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, 'AudioFile'); + } + + return $this; + } + + /** + * Use the AudioFile relation AudioFile 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 \Airtime\MediaItem\AudioFileQuery A secondary query class using the current class as primary query + */ + public function useAudioFileQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinAudioFile($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'AudioFile', '\Airtime\MediaItem\AudioFileQuery'); + } + + /** + * Filter the query by a related Webstream object + * + * @param Webstream|PropelObjectCollection $webstream the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaItemQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByWebstream($webstream, $comparison = null) + { + if ($webstream instanceof Webstream) { + return $this + ->addUsingAlias(MediaItemPeer::ID, $webstream->getId(), $comparison); + } elseif ($webstream instanceof PropelObjectCollection) { + return $this + ->useWebstreamQuery() + ->filterByPrimaryKeys($webstream->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByWebstream() only accepts arguments of type Webstream or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the Webstream relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function joinWebstream($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Webstream'); + + // 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, 'Webstream'); + } + + return $this; + } + + /** + * Use the Webstream relation Webstream 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 \Airtime\MediaItem\WebstreamQuery A secondary query class using the current class as primary query + */ + public function useWebstreamQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinWebstream($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Webstream', '\Airtime\MediaItem\WebstreamQuery'); + } + + /** + * Filter the query by a related Playlist object + * + * @param Playlist|PropelObjectCollection $playlist the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaItemQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByPlaylist($playlist, $comparison = null) + { + if ($playlist instanceof Playlist) { + return $this + ->addUsingAlias(MediaItemPeer::ID, $playlist->getId(), $comparison); + } elseif ($playlist instanceof PropelObjectCollection) { + return $this + ->usePlaylistQuery() + ->filterByPrimaryKeys($playlist->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByPlaylist() only accepts arguments of type Playlist or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the Playlist relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function joinPlaylist($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Playlist'); + + // 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, 'Playlist'); + } + + return $this; + } + + /** + * Use the Playlist relation Playlist 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 \Airtime\MediaItem\PlaylistQuery A secondary query class using the current class as primary query + */ + public function usePlaylistQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinPlaylist($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Playlist', '\Airtime\MediaItem\PlaylistQuery'); + } + + /** + * Filter the query by a related Block object + * + * @param Block|PropelObjectCollection $block the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return MediaItemQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByBlock($block, $comparison = null) + { + if ($block instanceof Block) { + return $this + ->addUsingAlias(MediaItemPeer::ID, $block->getId(), $comparison); + } elseif ($block instanceof PropelObjectCollection) { + return $this + ->useBlockQuery() + ->filterByPrimaryKeys($block->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByBlock() only accepts arguments of type Block or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the Block relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function joinBlock($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Block'); + + // 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, 'Block'); + } + + return $this; + } + + /** + * Use the Block relation Block 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 \Airtime\MediaItem\BlockQuery A secondary query class using the current class as primary query + */ + public function useBlockQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinBlock($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Block', '\Airtime\MediaItem\BlockQuery'); + } + + /** + * Exclude object from result + * + * @param MediaItem $mediaItem Object to remove from the list of results + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function prune($mediaItem = null) + { + if ($mediaItem) { + $this->addUsingAlias(MediaItemPeer::ID, $mediaItem->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(MediaItemPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(MediaItemPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(MediaItemPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(MediaItemPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(MediaItemPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return MediaItemQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(MediaItemPeer::CREATED_AT); + } +} diff --git a/airtime_mvc/application/models/airtime/om/BasePlaylist.php b/airtime_mvc/application/models/airtime/om/BasePlaylist.php new file mode 100644 index 000000000..60133c5da --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BasePlaylist.php @@ -0,0 +1,1792 @@ +play_count = 0; + $this->length = '00:00:00'; + } + + /** + * Initializes internal state of BasePlaylist 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 [name] column value. + * + * @return string + */ + public function getName() + { + + return $this->name; + } + + /** + * Get the [owner_id] column value. + * + * @return int + */ + public function getOwnerId() + { + + return $this->owner_id; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [optionally formatted] temporal [last_played] 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 getLastPlayedTime($format = 'Y-m-d H:i:s') + { + if ($this->last_played === null) { + return null; + } + + + try { + $dt = new DateTime($this->last_played); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->last_played, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [play_count] column value. + * + * @return int + */ + public function getPlayCount() + { + + return $this->play_count; + } + + /** + * Get the [length] column value. + * + * @return string + */ + public function getLength() + { + + return $this->length; + } + + /** + * Get the [optionally formatted] temporal [created_at] 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 getCreatedAt($format = 'Y-m-d H:i:s') + { + if ($this->created_at === null) { + return null; + } + + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [optionally formatted] temporal [updated_at] 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 getUpdatedAt($format = 'Y-m-d H:i:s') + { + if ($this->updated_at === null) { + return null; + } + + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [descendant_class] column value. + * + * @return string + */ + public function getDescendantClass() + { + + return $this->descendant_class; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return Playlist The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = PlaylistPeer::ID; + } + + if ($this->aMediaItem !== null && $this->aMediaItem->getId() !== $v) { + $this->aMediaItem = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return Playlist The current object (for fluent API support) + */ + public function setName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = PlaylistPeer::NAME; + } + + + return $this; + } // setName() + + /** + * Set the value of [owner_id] column. + * + * @param int $v new value + * @return Playlist The current object (for fluent API support) + */ + public function setOwnerId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->owner_id !== $v) { + $this->owner_id = $v; + $this->modifiedColumns[] = PlaylistPeer::OWNER_ID; + } + + if ($this->aCcSubjs !== null && $this->aCcSubjs->getDbId() !== $v) { + $this->aCcSubjs = null; + } + + + return $this; + } // setOwnerId() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return Playlist The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = PlaylistPeer::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Sets the value of [last_played] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return Playlist The current object (for fluent API support) + */ + public function setLastPlayedTime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->last_played !== null || $dt !== null) { + $currentDateAsString = ($this->last_played !== null && $tmpDt = new DateTime($this->last_played)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->last_played = $newDateAsString; + $this->modifiedColumns[] = PlaylistPeer::LAST_PLAYED; + } + } // if either are not null + + + return $this; + } // setLastPlayedTime() + + /** + * Set the value of [play_count] column. + * + * @param int $v new value + * @return Playlist The current object (for fluent API support) + */ + public function setPlayCount($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->play_count !== $v) { + $this->play_count = $v; + $this->modifiedColumns[] = PlaylistPeer::PLAY_COUNT; + } + + + return $this; + } // setPlayCount() + + /** + * Set the value of [length] column. + * + * @param string $v new value + * @return Playlist The current object (for fluent API support) + */ + public function setLength($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->length !== $v) { + $this->length = $v; + $this->modifiedColumns[] = PlaylistPeer::LENGTH; + } + + + return $this; + } // setLength() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return Playlist The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->created_at !== null || $dt !== null) { + $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->created_at = $newDateAsString; + $this->modifiedColumns[] = PlaylistPeer::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return Playlist The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->updated_at !== null || $dt !== null) { + $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->updated_at = $newDateAsString; + $this->modifiedColumns[] = PlaylistPeer::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Set the value of [descendant_class] column. + * + * @param string $v new value + * @return Playlist The current object (for fluent API support) + */ + public function setDescendantClass($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->descendant_class !== $v) { + $this->descendant_class = $v; + $this->modifiedColumns[] = PlaylistPeer::DESCENDANT_CLASS; + } + + + return $this; + } // setDescendantClass() + + /** + * 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->play_count !== 0) { + return false; + } + + if ($this->length !== '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 resultset 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->owner_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; + $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->last_played = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; + $this->play_count = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; + $this->length = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; + $this->updated_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->descendant_class = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 10; // 10 = PlaylistPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating Playlist 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->aMediaItem !== null && $this->id !== $this->aMediaItem->getId()) { + $this->aMediaItem = null; + } + if ($this->aCcSubjs !== null && $this->owner_id !== $this->aCcSubjs->getDbId()) { + $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(PlaylistPeer::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 = PlaylistPeer::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->aMediaItem = null; + $this->aCcSubjs = null; + $this->singleBlock = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(PlaylistPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = PlaylistQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + // concrete_inheritance behavior + $this->getParentOrCreate($con)->delete($con); + + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(PlaylistPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + // concrete_inheritance behavior + $parent = $this->getSyncParent($con); + $parent->save($con); + $this->setPrimaryKey($parent->getPrimaryKey()); + + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(PlaylistPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(PlaylistPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(PlaylistPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + PlaylistPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aMediaItem !== null) { + if ($this->aMediaItem->isModified() || $this->aMediaItem->isNew()) { + $affectedRows += $this->aMediaItem->save($con); + } + $this->setMediaItem($this->aMediaItem); + } + + if ($this->aCcSubjs !== null) { + if ($this->aCcSubjs->isModified() || $this->aCcSubjs->isNew()) { + $affectedRows += $this->aCcSubjs->save($con); + } + $this->setCcSubjs($this->aCcSubjs); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->singleBlock !== null) { + if (!$this->singleBlock->isDeleted() && ($this->singleBlock->isNew() || $this->singleBlock->isModified())) { + $affectedRows += $this->singleBlock->save($con); + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(PlaylistPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(PlaylistPeer::NAME)) { + $modifiedColumns[':p' . $index++] = '"name"'; + } + if ($this->isColumnModified(PlaylistPeer::OWNER_ID)) { + $modifiedColumns[':p' . $index++] = '"owner_id"'; + } + if ($this->isColumnModified(PlaylistPeer::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = '"description"'; + } + if ($this->isColumnModified(PlaylistPeer::LAST_PLAYED)) { + $modifiedColumns[':p' . $index++] = '"last_played"'; + } + if ($this->isColumnModified(PlaylistPeer::PLAY_COUNT)) { + $modifiedColumns[':p' . $index++] = '"play_count"'; + } + if ($this->isColumnModified(PlaylistPeer::LENGTH)) { + $modifiedColumns[':p' . $index++] = '"length"'; + } + if ($this->isColumnModified(PlaylistPeer::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = '"created_at"'; + } + if ($this->isColumnModified(PlaylistPeer::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = '"updated_at"'; + } + if ($this->isColumnModified(PlaylistPeer::DESCENDANT_CLASS)) { + $modifiedColumns[':p' . $index++] = '"descendant_class"'; + } + + $sql = sprintf( + 'INSERT INTO "playlist" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"name"': + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); + break; + case '"owner_id"': + $stmt->bindValue($identifier, $this->owner_id, PDO::PARAM_INT); + break; + case '"description"': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case '"last_played"': + $stmt->bindValue($identifier, $this->last_played, PDO::PARAM_STR); + break; + case '"play_count"': + $stmt->bindValue($identifier, $this->play_count, PDO::PARAM_INT); + break; + case '"length"': + $stmt->bindValue($identifier, $this->length, PDO::PARAM_STR); + break; + case '"created_at"': + $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + break; + case '"updated_at"': + $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + break; + case '"descendant_class"': + $stmt->bindValue($identifier, $this->descendant_class, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aMediaItem !== null) { + if (!$this->aMediaItem->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aMediaItem->getValidationFailures()); + } + } + + if ($this->aCcSubjs !== null) { + if (!$this->aCcSubjs->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcSubjs->getValidationFailures()); + } + } + + + if (($retval = PlaylistPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->singleBlock !== null) { + if (!$this->singleBlock->validate($columns)) { + $failureMap = array_merge($failureMap, $this->singleBlock->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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = PlaylistPeer::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->getName(); + break; + case 2: + return $this->getOwnerId(); + break; + case 3: + return $this->getDescription(); + break; + case 4: + return $this->getLastPlayedTime(); + break; + case 5: + return $this->getPlayCount(); + break; + case 6: + return $this->getLength(); + break; + case 7: + return $this->getCreatedAt(); + break; + case 8: + return $this->getUpdatedAt(); + break; + case 9: + return $this->getDescendantClass(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['Playlist'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['Playlist'][$this->getPrimaryKey()] = true; + $keys = PlaylistPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getName(), + $keys[2] => $this->getOwnerId(), + $keys[3] => $this->getDescription(), + $keys[4] => $this->getLastPlayedTime(), + $keys[5] => $this->getPlayCount(), + $keys[6] => $this->getLength(), + $keys[7] => $this->getCreatedAt(), + $keys[8] => $this->getUpdatedAt(), + $keys[9] => $this->getDescendantClass(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aMediaItem) { + $result['MediaItem'] = $this->aMediaItem->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aCcSubjs) { + $result['CcSubjs'] = $this->aCcSubjs->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->singleBlock) { + $result['Block'] = $this->singleBlock->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = PlaylistPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setName($value); + break; + case 2: + $this->setOwnerId($value); + break; + case 3: + $this->setDescription($value); + break; + case 4: + $this->setLastPlayedTime($value); + break; + case 5: + $this->setPlayCount($value); + break; + case 6: + $this->setLength($value); + break; + case 7: + $this->setCreatedAt($value); + break; + case 8: + $this->setUpdatedAt($value); + break; + case 9: + $this->setDescendantClass($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 BasePeer::TYPE_PHPNAME + * + * @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 = PlaylistPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setOwnerId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setLastPlayedTime($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setPlayCount($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setLength($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDescendantClass($arr[$keys[9]]); + } + + /** + * 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(PlaylistPeer::DATABASE_NAME); + + if ($this->isColumnModified(PlaylistPeer::ID)) $criteria->add(PlaylistPeer::ID, $this->id); + if ($this->isColumnModified(PlaylistPeer::NAME)) $criteria->add(PlaylistPeer::NAME, $this->name); + if ($this->isColumnModified(PlaylistPeer::OWNER_ID)) $criteria->add(PlaylistPeer::OWNER_ID, $this->owner_id); + if ($this->isColumnModified(PlaylistPeer::DESCRIPTION)) $criteria->add(PlaylistPeer::DESCRIPTION, $this->description); + if ($this->isColumnModified(PlaylistPeer::LAST_PLAYED)) $criteria->add(PlaylistPeer::LAST_PLAYED, $this->last_played); + if ($this->isColumnModified(PlaylistPeer::PLAY_COUNT)) $criteria->add(PlaylistPeer::PLAY_COUNT, $this->play_count); + if ($this->isColumnModified(PlaylistPeer::LENGTH)) $criteria->add(PlaylistPeer::LENGTH, $this->length); + if ($this->isColumnModified(PlaylistPeer::CREATED_AT)) $criteria->add(PlaylistPeer::CREATED_AT, $this->created_at); + if ($this->isColumnModified(PlaylistPeer::UPDATED_AT)) $criteria->add(PlaylistPeer::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(PlaylistPeer::DESCENDANT_CLASS)) $criteria->add(PlaylistPeer::DESCENDANT_CLASS, $this->descendant_class); + + 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(PlaylistPeer::DATABASE_NAME); + $criteria->add(PlaylistPeer::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 Playlist (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setName($this->getName()); + $copyObj->setOwnerId($this->getOwnerId()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setLastPlayedTime($this->getLastPlayedTime()); + $copyObj->setPlayCount($this->getPlayCount()); + $copyObj->setLength($this->getLength()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + $copyObj->setDescendantClass($this->getDescendantClass()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + $relObj = $this->getBlock(); + if ($relObj) { + $copyObj->setBlock($relObj->copy($deepCopy)); + } + + $relObj = $this->getMediaItem(); + if ($relObj) { + $copyObj->setMediaItem($relObj->copy($deepCopy)); + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 Playlist 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 PlaylistPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new PlaylistPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a MediaItem object. + * + * @param MediaItem $v + * @return Playlist The current object (for fluent API support) + * @throws PropelException + */ + public function setMediaItem(MediaItem $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aMediaItem = $v; + + // Add binding for other direction of this 1:1 relationship. + if ($v !== null) { + $v->setPlaylist($this); + } + + + return $this; + } + + + /** + * Get the associated MediaItem object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return MediaItem The associated MediaItem object. + * @throws PropelException + */ + public function getMediaItem(PropelPDO $con = null, $doQuery = true) + { + if ($this->aMediaItem === null && ($this->id !== null) && $doQuery) { + $this->aMediaItem = MediaItemQuery::create()->findPk($this->id, $con); + // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association. + $this->aMediaItem->setPlaylist($this); + } + + return $this->aMediaItem; + } + + /** + * Declares an association between this object and a CcSubjs object. + * + * @param CcSubjs $v + * @return Playlist The current object (for fluent API support) + * @throws PropelException + */ + public function setCcSubjs(CcSubjs $v = null) + { + if ($v === null) { + $this->setOwnerId(NULL); + } else { + $this->setOwnerId($v->getDbId()); + } + + $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->addPlaylist($this); + } + + + return $this; + } + + + /** + * Get the associated CcSubjs object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getCcSubjs(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcSubjs === null && ($this->owner_id !== null) && $doQuery) { + $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->owner_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->aCcSubjs->addPlaylists($this); + */ + } + + return $this->aCcSubjs; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + } + + /** + * Gets a single Block object, which is related to this object by a one-to-one relationship. + * + * @param PropelPDO $con optional connection object + * @return Block + * @throws PropelException + */ + public function getBlock(PropelPDO $con = null) + { + + if ($this->singleBlock === null && !$this->isNew()) { + $this->singleBlock = BlockQuery::create()->findPk($this->getPrimaryKey(), $con); + } + + return $this->singleBlock; + } + + /** + * Sets a single Block object as related to this object by a one-to-one relationship. + * + * @param Block $v Block + * @return Playlist The current object (for fluent API support) + * @throws PropelException + */ + public function setBlock(Block $v = null) + { + $this->singleBlock = $v; + + // Make sure that that the passed-in Block isn't already associated with this object + if ($v !== null && $v->getPlaylist(null, false) === null) { + $v->setPlaylist($this); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->name = null; + $this->owner_id = null; + $this->description = null; + $this->last_played = null; + $this->play_count = null; + $this->length = null; + $this->created_at = null; + $this->updated_at = null; + $this->descendant_class = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->singleBlock) { + $this->singleBlock->clearAllReferences($deep); + } + if ($this->aMediaItem instanceof Persistent) { + $this->aMediaItem->clearAllReferences($deep); + } + if ($this->aCcSubjs instanceof Persistent) { + $this->aCcSubjs->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + if ($this->singleBlock instanceof PropelCollection) { + $this->singleBlock->clearIterator(); + } + $this->singleBlock = null; + $this->aMediaItem = null; + $this->aCcSubjs = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(PlaylistPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + + // concrete_inheritance behavior + + /** + * Get or Create the parent MediaItem object of the current object + * + * @return MediaItem The parent object + */ + public function getParentOrCreate($con = null) + { + if ($this->isNew()) { + if ($this->isPrimaryKeyNull()) { + //this prevent issue with deep copy & save parent object + if (null === ($parent = $this->getMediaItem($con))) { + $parent = new MediaItem(); + } + $parent->setDescendantClass('Airtime\MediaItem\Playlist'); + + return $parent; + } else { + $parent = MediaItemQuery::create()->findPk($this->getPrimaryKey(), $con); + if (null === $parent || null !== $parent->getDescendantClass()) { + $parent = new MediaItem(); + $parent->setPrimaryKey($this->getPrimaryKey()); + $parent->setDescendantClass('Airtime\MediaItem\Playlist'); + } + + return $parent; + } + } + + return MediaItemQuery::create()->findPk($this->getPrimaryKey(), $con); + } + + /** + * Create or Update the parent MediaItem object + * And return its primary key + * + * @return int The primary key of the parent object + */ + public function getSyncParent($con = null) + { + $parent = $this->getParentOrCreate($con); + $parent->setName($this->getName()); + $parent->setOwnerId($this->getOwnerId()); + $parent->setDescription($this->getDescription()); + $parent->setLastPlayedTime($this->getLastPlayedTime()); + $parent->setPlayCount($this->getPlayCount()); + $parent->setLength($this->getLength()); + $parent->setCreatedAt($this->getCreatedAt()); + $parent->setUpdatedAt($this->getUpdatedAt()); + if ($this->getCcSubjs() && $this->getCcSubjs()->isNew()) { + $parent->setCcSubjs($this->getCcSubjs()); + } + + return $parent; + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Playlist The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = PlaylistPeer::UPDATED_AT; + + return $this; + } + + // concrete_inheritance_parent behavior + + /** + * Whether or not this object is the parent of a child object + * + * @return bool + */ + public function hasChildObject() + { + return $this->getDescendantClass() !== null; + } + + /** + * Get the child object of this object + * + * @return mixed + */ + public function getChildObject() + { + if (!$this->hasChildObject()) { + return null; + } + $childObjectClass = $this->getDescendantClass(); + $childObject = PropelQuery::from($childObjectClass)->findPk($this->getPrimaryKey()); + + return $childObject->hasChildObject() ? $childObject->getChildObject() : $childObject; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BasePlaylistPeer.php b/airtime_mvc/application/models/airtime/om/BasePlaylistPeer.php new file mode 100644 index 000000000..5b11f1b83 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BasePlaylistPeer.php @@ -0,0 +1,1447 @@ + array ('Id', 'Name', 'OwnerId', 'Description', 'LastPlayedTime', 'PlayCount', 'Length', 'CreatedAt', 'UpdatedAt', 'DescendantClass', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'name', 'ownerId', 'description', 'lastPlayedTime', 'playCount', 'length', 'createdAt', 'updatedAt', 'descendantClass', ), + BasePeer::TYPE_COLNAME => array (PlaylistPeer::ID, PlaylistPeer::NAME, PlaylistPeer::OWNER_ID, PlaylistPeer::DESCRIPTION, PlaylistPeer::LAST_PLAYED, PlaylistPeer::PLAY_COUNT, PlaylistPeer::LENGTH, PlaylistPeer::CREATED_AT, PlaylistPeer::UPDATED_AT, PlaylistPeer::DESCENDANT_CLASS, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'OWNER_ID', 'DESCRIPTION', 'LAST_PLAYED', 'PLAY_COUNT', 'LENGTH', 'CREATED_AT', 'UPDATED_AT', 'DESCENDANT_CLASS', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'owner_id', 'description', 'last_played', 'play_count', 'length', 'created_at', 'updated_at', 'descendant_class', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. PlaylistPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'OwnerId' => 2, 'Description' => 3, 'LastPlayedTime' => 4, 'PlayCount' => 5, 'Length' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, 'DescendantClass' => 9, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'name' => 1, 'ownerId' => 2, 'description' => 3, 'lastPlayedTime' => 4, 'playCount' => 5, 'length' => 6, 'createdAt' => 7, 'updatedAt' => 8, 'descendantClass' => 9, ), + BasePeer::TYPE_COLNAME => array (PlaylistPeer::ID => 0, PlaylistPeer::NAME => 1, PlaylistPeer::OWNER_ID => 2, PlaylistPeer::DESCRIPTION => 3, PlaylistPeer::LAST_PLAYED => 4, PlaylistPeer::PLAY_COUNT => 5, PlaylistPeer::LENGTH => 6, PlaylistPeer::CREATED_AT => 7, PlaylistPeer::UPDATED_AT => 8, PlaylistPeer::DESCENDANT_CLASS => 9, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'OWNER_ID' => 2, 'DESCRIPTION' => 3, 'LAST_PLAYED' => 4, 'PLAY_COUNT' => 5, 'LENGTH' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, 'DESCENDANT_CLASS' => 9, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'owner_id' => 2, 'description' => 3, 'last_played' => 4, 'play_count' => 5, 'length' => 6, 'created_at' => 7, 'updated_at' => 8, 'descendant_class' => 9, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + ); + + /** + * 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = PlaylistPeer::getFieldNames($toType); + $key = isset(PlaylistPeer::$fieldKeys[$fromType][$name]) ? PlaylistPeer::$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(PlaylistPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, PlaylistPeer::$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 PlaylistPeer::$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. PlaylistPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(PlaylistPeer::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(PlaylistPeer::ID); + $criteria->addSelectColumn(PlaylistPeer::NAME); + $criteria->addSelectColumn(PlaylistPeer::OWNER_ID); + $criteria->addSelectColumn(PlaylistPeer::DESCRIPTION); + $criteria->addSelectColumn(PlaylistPeer::LAST_PLAYED); + $criteria->addSelectColumn(PlaylistPeer::PLAY_COUNT); + $criteria->addSelectColumn(PlaylistPeer::LENGTH); + $criteria->addSelectColumn(PlaylistPeer::CREATED_AT); + $criteria->addSelectColumn(PlaylistPeer::UPDATED_AT); + $criteria->addSelectColumn(PlaylistPeer::DESCENDANT_CLASS); + } else { + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.name'); + $criteria->addSelectColumn($alias . '.owner_id'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.last_played'); + $criteria->addSelectColumn($alias . '.play_count'); + $criteria->addSelectColumn($alias . '.length'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); + $criteria->addSelectColumn($alias . '.descendant_class'); + } + } + + /** + * 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(PlaylistPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + PlaylistPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(PlaylistPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(PlaylistPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return Playlist + * @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 = PlaylistPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 PlaylistPeer::populateObjects(PlaylistPeer::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 directly (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(PlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + PlaylistPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(PlaylistPeer::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 Playlist $obj A Playlist object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getId(); + } // if key === null + PlaylistPeer::$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 Playlist object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof Playlist) { + $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 Playlist object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(PlaylistPeer::$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 Playlist 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(PlaylistPeer::$instances[$key])) { + return PlaylistPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (PlaylistPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + PlaylistPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to playlist + * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in BlockPeer instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + BlockPeer::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 = PlaylistPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = PlaylistPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = PlaylistPeer::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; + PlaylistPeer::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 (Playlist object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = PlaylistPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = PlaylistPeer::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 + PlaylistPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = PlaylistPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + PlaylistPeer::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + + /** + * Returns the number of rows matching criteria, joining the related MediaItem 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 doCountJoinMediaItem(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(PlaylistPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + PlaylistPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(PlaylistPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(PlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(PlaylistPeer::ID, MediaItemPeer::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 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(PlaylistPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + PlaylistPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(PlaylistPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(PlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(PlaylistPeer::OWNER_ID, 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 Playlist objects pre-filled with their MediaItem 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 Playlist objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinMediaItem(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(PlaylistPeer::DATABASE_NAME); + } + + PlaylistPeer::addSelectColumns($criteria); + $startcol = PlaylistPeer::NUM_HYDRATE_COLUMNS; + MediaItemPeer::addSelectColumns($criteria); + + $criteria->addJoin(PlaylistPeer::ID, MediaItemPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = PlaylistPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = PlaylistPeer::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 = PlaylistPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + PlaylistPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = MediaItemPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = MediaItemPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = MediaItemPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + MediaItemPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (Playlist) to $obj2 (MediaItem) + // one to one relationship + $obj1->setMediaItem($obj2); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of Playlist 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 Playlist 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(PlaylistPeer::DATABASE_NAME); + } + + PlaylistPeer::addSelectColumns($criteria); + $startcol = PlaylistPeer::NUM_HYDRATE_COLUMNS; + CcSubjsPeer::addSelectColumns($criteria); + + $criteria->addJoin(PlaylistPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = PlaylistPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = PlaylistPeer::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 = PlaylistPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + PlaylistPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (Playlist) to $obj2 (CcSubjs) + $obj2->addPlaylist($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(PlaylistPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + PlaylistPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(PlaylistPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(PlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(PlaylistPeer::ID, MediaItemPeer::ID, $join_behavior); + + $criteria->addJoin(PlaylistPeer::OWNER_ID, 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 Playlist 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 Playlist 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(PlaylistPeer::DATABASE_NAME); + } + + PlaylistPeer::addSelectColumns($criteria); + $startcol2 = PlaylistPeer::NUM_HYDRATE_COLUMNS; + + MediaItemPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + MediaItemPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(PlaylistPeer::ID, MediaItemPeer::ID, $join_behavior); + + $criteria->addJoin(PlaylistPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = PlaylistPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = PlaylistPeer::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 = PlaylistPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + PlaylistPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined MediaItem rows + + $key2 = MediaItemPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = MediaItemPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = MediaItemPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + MediaItemPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (Playlist) to the collection in $obj2 (MediaItem) + $obj1->setMediaItem($obj2); + } // if joined row not null + + // Add objects for joined CcSubjs rows + + $key3 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcSubjsPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcSubjsPeer::addInstanceToPool($obj3, $key3); + } // if obj3 loaded + + // Add the $obj1 (Playlist) to the collection in $obj3 (CcSubjs) + $obj3->addPlaylist($obj1); + } // if joined row not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining the related MediaItem 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 doCountJoinAllExceptMediaItem(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(PlaylistPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + PlaylistPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(PlaylistPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(PlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(PlaylistPeer::OWNER_ID, 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; + } + + + /** + * 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 doCountJoinAllExceptCcSubjs(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(PlaylistPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + PlaylistPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(PlaylistPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(PlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(PlaylistPeer::ID, MediaItemPeer::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 Playlist objects pre-filled with all related objects except MediaItem. + * + * @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 Playlist objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptMediaItem(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(PlaylistPeer::DATABASE_NAME); + } + + PlaylistPeer::addSelectColumns($criteria); + $startcol2 = PlaylistPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(PlaylistPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = PlaylistPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = PlaylistPeer::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 = PlaylistPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + PlaylistPeer::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(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (Playlist) to the collection in $obj2 (CcSubjs) + $obj2->addPlaylist($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of Playlist objects pre-filled with all related objects except CcSubjs. + * + * @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 Playlist objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcSubjs(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(PlaylistPeer::DATABASE_NAME); + } + + PlaylistPeer::addSelectColumns($criteria); + $startcol2 = PlaylistPeer::NUM_HYDRATE_COLUMNS; + + MediaItemPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + MediaItemPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(PlaylistPeer::ID, MediaItemPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = PlaylistPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = PlaylistPeer::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 = PlaylistPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + PlaylistPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined MediaItem rows + + $key2 = MediaItemPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = MediaItemPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = MediaItemPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + MediaItemPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (Playlist) to the collection in $obj2 (MediaItem) + $obj1->setMediaItem($obj2); + + } // 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(PlaylistPeer::DATABASE_NAME)->getTable(PlaylistPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BasePlaylistPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BasePlaylistPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\MediaItem\map\PlaylistTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return PlaylistPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a Playlist or Criteria object. + * + * @param mixed $values Criteria or Playlist 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(PlaylistPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from Playlist object + } + + + // Set the correct dbName + $criteria->setDbName(PlaylistPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a Playlist or Criteria object. + * + * @param mixed $values Criteria or Playlist 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(PlaylistPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(PlaylistPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(PlaylistPeer::ID); + $value = $criteria->remove(PlaylistPeer::ID); + if ($value) { + $selectCriteria->add(PlaylistPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(PlaylistPeer::TABLE_NAME); + } + + } else { // $values is Playlist object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(PlaylistPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the playlist table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(PlaylistPeer::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(PlaylistPeer::TABLE_NAME, $con, PlaylistPeer::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). + PlaylistPeer::clearInstancePool(); + PlaylistPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a Playlist or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or Playlist 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(PlaylistPeer::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. + PlaylistPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof Playlist) { // it's a model object + // invalidate the cache for this single object + PlaylistPeer::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(PlaylistPeer::DATABASE_NAME); + $criteria->add(PlaylistPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + PlaylistPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(PlaylistPeer::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); + PlaylistPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given Playlist 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 Playlist $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(PlaylistPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(PlaylistPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(PlaylistPeer::DATABASE_NAME, PlaylistPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return Playlist + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = PlaylistPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(PlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(PlaylistPeer::DATABASE_NAME); + $criteria->add(PlaylistPeer::ID, $pk); + + $v = PlaylistPeer::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 + * @return Playlist[] + * @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(PlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(PlaylistPeer::DATABASE_NAME); + $criteria->add(PlaylistPeer::ID, $pks, Criteria::IN); + $objs = PlaylistPeer::doSelect($criteria, $con); + } + + return $objs; + } + +} // BasePlaylistPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BasePlaylistPeer::buildTableMap(); + diff --git a/airtime_mvc/application/models/airtime/om/BasePlaylistQuery.php b/airtime_mvc/application/models/airtime/om/BasePlaylistQuery.php new file mode 100644 index 000000000..bce1f75e7 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BasePlaylistQuery.php @@ -0,0 +1,966 @@ +mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return Playlist|Playlist[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = PlaylistPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(PlaylistPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Playlist A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Playlist A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "id", "name", "owner_id", "description", "last_played", "play_count", "length", "created_at", "updated_at", "descendant_class" FROM "playlist" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new Playlist(); + $obj->hydrate($row); + PlaylistPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Playlist|Playlist[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($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|Playlist[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($stmt); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return PlaylistQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(PlaylistPeer::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 PlaylistQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(PlaylistPeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 + * + * + * @see filterByMediaItem() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return PlaylistQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(PlaylistPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(PlaylistPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PlaylistPeer::ID, $id, $comparison); + } + + /** + * Filter the query on the name column + * + * Example usage: + * + * $query->filterByName('fooValue'); // WHERE name = 'fooValue' + * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' + * + * + * @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 PlaylistQuery 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(PlaylistPeer::NAME, $name, $comparison); + } + + /** + * Filter the query on the owner_id column + * + * Example usage: + * + * $query->filterByOwnerId(1234); // WHERE owner_id = 1234 + * $query->filterByOwnerId(array(12, 34)); // WHERE owner_id IN (12, 34) + * $query->filterByOwnerId(array('min' => 12)); // WHERE owner_id >= 12 + * $query->filterByOwnerId(array('max' => 12)); // WHERE owner_id <= 12 + * + * + * @see filterByCcSubjs() + * + * @param mixed $ownerId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return PlaylistQuery The current query, for fluid interface + */ + public function filterByOwnerId($ownerId = null, $comparison = null) + { + if (is_array($ownerId)) { + $useMinMax = false; + if (isset($ownerId['min'])) { + $this->addUsingAlias(PlaylistPeer::OWNER_ID, $ownerId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($ownerId['max'])) { + $this->addUsingAlias(PlaylistPeer::OWNER_ID, $ownerId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PlaylistPeer::OWNER_ID, $ownerId, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description 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 PlaylistQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(PlaylistPeer::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the last_played column + * + * Example usage: + * + * $query->filterByLastPlayedTime('2011-03-14'); // WHERE last_played = '2011-03-14' + * $query->filterByLastPlayedTime('now'); // WHERE last_played = '2011-03-14' + * $query->filterByLastPlayedTime(array('max' => 'yesterday')); // WHERE last_played < '2011-03-13' + * + * + * @param mixed $lastPlayedTime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return PlaylistQuery The current query, for fluid interface + */ + public function filterByLastPlayedTime($lastPlayedTime = null, $comparison = null) + { + if (is_array($lastPlayedTime)) { + $useMinMax = false; + if (isset($lastPlayedTime['min'])) { + $this->addUsingAlias(PlaylistPeer::LAST_PLAYED, $lastPlayedTime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($lastPlayedTime['max'])) { + $this->addUsingAlias(PlaylistPeer::LAST_PLAYED, $lastPlayedTime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PlaylistPeer::LAST_PLAYED, $lastPlayedTime, $comparison); + } + + /** + * Filter the query on the play_count column + * + * Example usage: + * + * $query->filterByPlayCount(1234); // WHERE play_count = 1234 + * $query->filterByPlayCount(array(12, 34)); // WHERE play_count IN (12, 34) + * $query->filterByPlayCount(array('min' => 12)); // WHERE play_count >= 12 + * $query->filterByPlayCount(array('max' => 12)); // WHERE play_count <= 12 + * + * + * @param mixed $playCount The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return PlaylistQuery The current query, for fluid interface + */ + public function filterByPlayCount($playCount = null, $comparison = null) + { + if (is_array($playCount)) { + $useMinMax = false; + if (isset($playCount['min'])) { + $this->addUsingAlias(PlaylistPeer::PLAY_COUNT, $playCount['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($playCount['max'])) { + $this->addUsingAlias(PlaylistPeer::PLAY_COUNT, $playCount['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PlaylistPeer::PLAY_COUNT, $playCount, $comparison); + } + + /** + * Filter the query on the length column + * + * Example usage: + * + * $query->filterByLength('fooValue'); // WHERE length = 'fooValue' + * $query->filterByLength('%fooValue%'); // WHERE length LIKE '%fooValue%' + * + * + * @param string $length 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 PlaylistQuery The current query, for fluid interface + */ + public function filterByLength($length = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($length)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $length)) { + $length = str_replace('*', '%', $length); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(PlaylistPeer::LENGTH, $length, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at < '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return PlaylistQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(PlaylistPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(PlaylistPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PlaylistPeer::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at < '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return PlaylistQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(PlaylistPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(PlaylistPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PlaylistPeer::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query on the descendant_class column + * + * Example usage: + * + * $query->filterByDescendantClass('fooValue'); // WHERE descendant_class = 'fooValue' + * $query->filterByDescendantClass('%fooValue%'); // WHERE descendant_class LIKE '%fooValue%' + * + * + * @param string $descendantClass 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 PlaylistQuery The current query, for fluid interface + */ + public function filterByDescendantClass($descendantClass = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($descendantClass)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $descendantClass)) { + $descendantClass = str_replace('*', '%', $descendantClass); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(PlaylistPeer::DESCENDANT_CLASS, $descendantClass, $comparison); + } + + /** + * Filter the query by a related MediaItem object + * + * @param MediaItem|PropelObjectCollection $mediaItem The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return PlaylistQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByMediaItem($mediaItem, $comparison = null) + { + if ($mediaItem instanceof MediaItem) { + return $this + ->addUsingAlias(PlaylistPeer::ID, $mediaItem->getId(), $comparison); + } elseif ($mediaItem instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(PlaylistPeer::ID, $mediaItem->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByMediaItem() only accepts arguments of type MediaItem or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the MediaItem relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return PlaylistQuery The current query, for fluid interface + */ + public function joinMediaItem($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('MediaItem'); + + // 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, 'MediaItem'); + } + + return $this; + } + + /** + * Use the MediaItem relation MediaItem 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 \Airtime\MediaItemQuery A secondary query class using the current class as primary query + */ + public function useMediaItemQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinMediaItem($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'MediaItem', '\Airtime\MediaItemQuery'); + } + + /** + * Filter the query by a related CcSubjs object + * + * @param CcSubjs|PropelObjectCollection $ccSubjs The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return PlaylistQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcSubjs($ccSubjs, $comparison = null) + { + if ($ccSubjs instanceof CcSubjs) { + return $this + ->addUsingAlias(PlaylistPeer::OWNER_ID, $ccSubjs->getDbId(), $comparison); + } elseif ($ccSubjs instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(PlaylistPeer::OWNER_ID, $ccSubjs->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcSubjs() only accepts arguments of type CcSubjs or PropelCollection'); + } + } + + /** + * 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 PlaylistQuery The current query, for fluid interface + */ + public function joinCcSubjs($relationAlias = null, $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 \Airtime\CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSubjs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', '\Airtime\CcSubjsQuery'); + } + + /** + * Filter the query by a related Block object + * + * @param Block|PropelObjectCollection $block the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return PlaylistQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByBlock($block, $comparison = null) + { + if ($block instanceof Block) { + return $this + ->addUsingAlias(PlaylistPeer::ID, $block->getId(), $comparison); + } elseif ($block instanceof PropelObjectCollection) { + return $this + ->useBlockQuery() + ->filterByPrimaryKeys($block->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByBlock() only accepts arguments of type Block or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the Block relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return PlaylistQuery The current query, for fluid interface + */ + public function joinBlock($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Block'); + + // 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, 'Block'); + } + + return $this; + } + + /** + * Use the Block relation Block 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 \Airtime\MediaItem\BlockQuery A secondary query class using the current class as primary query + */ + public function useBlockQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinBlock($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Block', '\Airtime\MediaItem\BlockQuery'); + } + + /** + * Exclude object from result + * + * @param Playlist $playlist Object to remove from the list of results + * + * @return PlaylistQuery The current query, for fluid interface + */ + public function prune($playlist = null) + { + if ($playlist) { + $this->addUsingAlias(PlaylistPeer::ID, $playlist->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return PlaylistQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(PlaylistPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return PlaylistQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(PlaylistPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return PlaylistQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(PlaylistPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return PlaylistQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(PlaylistPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return PlaylistQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(PlaylistPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return PlaylistQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(PlaylistPeer::CREATED_AT); + } +} diff --git a/airtime_mvc/application/models/airtime/om/BaseWebstream.php b/airtime_mvc/application/models/airtime/om/BaseWebstream.php new file mode 100644 index 000000000..4cdb69d93 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseWebstream.php @@ -0,0 +1,1733 @@ +play_count = 0; + $this->length = '00:00:00'; + } + + /** + * Initializes internal state of BaseWebstream object. + * @see applyDefaults() + */ + public function __construct() + { + parent::__construct(); + $this->applyDefaultValues(); + } + + /** + * Get the [mime] column value. + * + * @return string + */ + public function getMime() + { + + return $this->mime; + } + + /** + * Get the [url] column value. + * + * @return string + */ + public function getUrl() + { + + return $this->url; + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [name] column value. + * + * @return string + */ + public function getName() + { + + return $this->name; + } + + /** + * Get the [owner_id] column value. + * + * @return int + */ + public function getOwnerId() + { + + return $this->owner_id; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [optionally formatted] temporal [last_played] 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 getLastPlayedTime($format = 'Y-m-d H:i:s') + { + if ($this->last_played === null) { + return null; + } + + + try { + $dt = new DateTime($this->last_played); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->last_played, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [play_count] column value. + * + * @return int + */ + public function getPlayCount() + { + + return $this->play_count; + } + + /** + * Get the [length] column value. + * + * @return string + */ + public function getLength() + { + + return $this->length; + } + + /** + * Get the [optionally formatted] temporal [created_at] 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 getCreatedAt($format = 'Y-m-d H:i:s') + { + if ($this->created_at === null) { + return null; + } + + + try { + $dt = new DateTime($this->created_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Get the [optionally formatted] temporal [updated_at] 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 getUpdatedAt($format = 'Y-m-d H:i:s') + { + if ($this->updated_at === null) { + return null; + } + + + try { + $dt = new DateTime($this->updated_at); + } catch (Exception $x) { + throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x); + } + + if ($format === null) { + // Because propel.useDateTimeClass is true, we return a DateTime object. + return $dt; + } + + if (strpos($format, '%') !== false) { + return strftime($format, $dt->format('U')); + } + + return $dt->format($format); + + } + + /** + * Set the value of [mime] column. + * + * @param string $v new value + * @return Webstream The current object (for fluent API support) + */ + public function setMime($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->mime !== $v) { + $this->mime = $v; + $this->modifiedColumns[] = WebstreamPeer::MIME; + } + + + return $this; + } // setMime() + + /** + * Set the value of [url] column. + * + * @param string $v new value + * @return Webstream The current object (for fluent API support) + */ + public function setUrl($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->url !== $v) { + $this->url = $v; + $this->modifiedColumns[] = WebstreamPeer::URL; + } + + + return $this; + } // setUrl() + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return Webstream The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = WebstreamPeer::ID; + } + + if ($this->aMediaItem !== null && $this->aMediaItem->getId() !== $v) { + $this->aMediaItem = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return Webstream The current object (for fluent API support) + */ + public function setName($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = WebstreamPeer::NAME; + } + + + return $this; + } // setName() + + /** + * Set the value of [owner_id] column. + * + * @param int $v new value + * @return Webstream The current object (for fluent API support) + */ + public function setOwnerId($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->owner_id !== $v) { + $this->owner_id = $v; + $this->modifiedColumns[] = WebstreamPeer::OWNER_ID; + } + + if ($this->aCcSubjs !== null && $this->aCcSubjs->getDbId() !== $v) { + $this->aCcSubjs = null; + } + + + return $this; + } // setOwnerId() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return Webstream The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = WebstreamPeer::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Sets the value of [last_played] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return Webstream The current object (for fluent API support) + */ + public function setLastPlayedTime($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->last_played !== null || $dt !== null) { + $currentDateAsString = ($this->last_played !== null && $tmpDt = new DateTime($this->last_played)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->last_played = $newDateAsString; + $this->modifiedColumns[] = WebstreamPeer::LAST_PLAYED; + } + } // if either are not null + + + return $this; + } // setLastPlayedTime() + + /** + * Set the value of [play_count] column. + * + * @param int $v new value + * @return Webstream The current object (for fluent API support) + */ + public function setPlayCount($v) + { + if ($v !== null && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->play_count !== $v) { + $this->play_count = $v; + $this->modifiedColumns[] = WebstreamPeer::PLAY_COUNT; + } + + + return $this; + } // setPlayCount() + + /** + * Set the value of [length] column. + * + * @param string $v new value + * @return Webstream The current object (for fluent API support) + */ + public function setLength($v) + { + if ($v !== null && is_numeric($v)) { + $v = (string) $v; + } + + if ($this->length !== $v) { + $this->length = $v; + $this->modifiedColumns[] = WebstreamPeer::LENGTH; + } + + + return $this; + } // setLength() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return Webstream The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->created_at !== null || $dt !== null) { + $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->created_at = $newDateAsString; + $this->modifiedColumns[] = WebstreamPeer::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or DateTime value. + * Empty strings are treated as null. + * @return Webstream The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + if ($this->updated_at !== null || $dt !== null) { + $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; + $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; + if ($currentDateAsString !== $newDateAsString) { + $this->updated_at = $newDateAsString; + $this->modifiedColumns[] = WebstreamPeer::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * 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->play_count !== 0) { + return false; + } + + if ($this->length !== '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 resultset 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->mime = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null; + $this->url = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; + $this->id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; + $this->name = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; + $this->owner_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; + $this->description = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; + $this->last_played = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; + $this->play_count = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null; + $this->length = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; + $this->created_at = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; + $this->updated_at = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + $this->postHydrate($row, $startcol, $rehydrate); + + return $startcol + 11; // 11 = WebstreamPeer::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating Webstream 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->aMediaItem !== null && $this->id !== $this->aMediaItem->getId()) { + $this->aMediaItem = null; + } + if ($this->aCcSubjs !== null && $this->owner_id !== $this->aCcSubjs->getDbId()) { + $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(WebstreamPeer::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 = WebstreamPeer::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->aMediaItem = null; + $this->aCcSubjs = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param PropelPDO $con + * @return void + * @throws PropelException + * @throws Exception + * @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(WebstreamPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + try { + $deleteQuery = WebstreamQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + // concrete_inheritance behavior + $this->getParentOrCreate($con)->delete($con); + + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $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 + * @throws Exception + * @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(WebstreamPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + // concrete_inheritance behavior + $parent = $this->getSyncParent($con); + $parent->save($con); + $this->setPrimaryKey($parent->getPrimaryKey()); + + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(WebstreamPeer::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(WebstreamPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(WebstreamPeer::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + WebstreamPeer::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aMediaItem !== null) { + if ($this->aMediaItem->isModified() || $this->aMediaItem->isNew()) { + $affectedRows += $this->aMediaItem->save($con); + } + $this->setMediaItem($this->aMediaItem); + } + + if ($this->aCcSubjs !== null) { + if ($this->aCcSubjs->isModified() || $this->aCcSubjs->isNew()) { + $affectedRows += $this->aCcSubjs->save($con); + } + $this->setCcSubjs($this->aCcSubjs); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param PropelPDO $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(PropelPDO $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(WebstreamPeer::MIME)) { + $modifiedColumns[':p' . $index++] = '"mime"'; + } + if ($this->isColumnModified(WebstreamPeer::URL)) { + $modifiedColumns[':p' . $index++] = '"url"'; + } + if ($this->isColumnModified(WebstreamPeer::ID)) { + $modifiedColumns[':p' . $index++] = '"id"'; + } + if ($this->isColumnModified(WebstreamPeer::NAME)) { + $modifiedColumns[':p' . $index++] = '"name"'; + } + if ($this->isColumnModified(WebstreamPeer::OWNER_ID)) { + $modifiedColumns[':p' . $index++] = '"owner_id"'; + } + if ($this->isColumnModified(WebstreamPeer::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = '"description"'; + } + if ($this->isColumnModified(WebstreamPeer::LAST_PLAYED)) { + $modifiedColumns[':p' . $index++] = '"last_played"'; + } + if ($this->isColumnModified(WebstreamPeer::PLAY_COUNT)) { + $modifiedColumns[':p' . $index++] = '"play_count"'; + } + if ($this->isColumnModified(WebstreamPeer::LENGTH)) { + $modifiedColumns[':p' . $index++] = '"length"'; + } + if ($this->isColumnModified(WebstreamPeer::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = '"created_at"'; + } + if ($this->isColumnModified(WebstreamPeer::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = '"updated_at"'; + } + + $sql = sprintf( + 'INSERT INTO "webstream" (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case '"mime"': + $stmt->bindValue($identifier, $this->mime, PDO::PARAM_STR); + break; + case '"url"': + $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR); + break; + case '"id"': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case '"name"': + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); + break; + case '"owner_id"': + $stmt->bindValue($identifier, $this->owner_id, PDO::PARAM_INT); + break; + case '"description"': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case '"last_played"': + $stmt->bindValue($identifier, $this->last_played, PDO::PARAM_STR); + break; + case '"play_count"': + $stmt->bindValue($identifier, $this->play_count, PDO::PARAM_INT); + break; + case '"length"': + $stmt->bindValue($identifier, $this->length, PDO::PARAM_STR); + break; + case '"created_at"': + $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + break; + case '"updated_at"': + $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param PropelPDO $con + * + * @see doSave() + */ + protected function doUpdate(PropelPDO $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); + } + + /** + * 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; + } + + $this->validationFailures = $res; + + return false; + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggregated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; array of ValidationFailed objects 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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aMediaItem !== null) { + if (!$this->aMediaItem->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aMediaItem->getValidationFailures()); + } + } + + if ($this->aCcSubjs !== null) { + if (!$this->aCcSubjs->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aCcSubjs->getValidationFailures()); + } + } + + + if (($retval = WebstreamPeer::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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = WebstreamPeer::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->getMime(); + break; + case 1: + return $this->getUrl(); + break; + case 2: + return $this->getId(); + break; + case 3: + return $this->getName(); + break; + case 4: + return $this->getOwnerId(); + break; + case 5: + return $this->getDescription(); + break; + case 6: + return $this->getLastPlayedTime(); + break; + case 7: + return $this->getPlayCount(); + break; + case 8: + return $this->getLength(); + break; + case 9: + return $this->getCreatedAt(); + break; + case 10: + return $this->getUpdatedAt(); + 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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @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, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['Webstream'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['Webstream'][$this->getPrimaryKey()] = true; + $keys = WebstreamPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getMime(), + $keys[1] => $this->getUrl(), + $keys[2] => $this->getId(), + $keys[3] => $this->getName(), + $keys[4] => $this->getOwnerId(), + $keys[5] => $this->getDescription(), + $keys[6] => $this->getLastPlayedTime(), + $keys[7] => $this->getPlayCount(), + $keys[8] => $this->getLength(), + $keys[9] => $this->getCreatedAt(), + $keys[10] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aMediaItem) { + $result['MediaItem'] = $this->aMediaItem->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aCcSubjs) { + $result['CcSubjs'] = $this->aCcSubjs->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, 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. + * Defaults to BasePeer::TYPE_PHPNAME + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = WebstreamPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + + $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->setMime($value); + break; + case 1: + $this->setUrl($value); + break; + case 2: + $this->setId($value); + break; + case 3: + $this->setName($value); + break; + case 4: + $this->setOwnerId($value); + break; + case 5: + $this->setDescription($value); + break; + case 6: + $this->setLastPlayedTime($value); + break; + case 7: + $this->setPlayCount($value); + break; + case 8: + $this->setLength($value); + break; + case 9: + $this->setCreatedAt($value); + break; + case 10: + $this->setUpdatedAt($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 BasePeer::TYPE_PHPNAME + * + * @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 = WebstreamPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setMime($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setUrl($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setName($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setOwnerId($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setDescription($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setLastPlayedTime($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setPlayCount($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setLength($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setCreatedAt($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setUpdatedAt($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(WebstreamPeer::DATABASE_NAME); + + if ($this->isColumnModified(WebstreamPeer::MIME)) $criteria->add(WebstreamPeer::MIME, $this->mime); + if ($this->isColumnModified(WebstreamPeer::URL)) $criteria->add(WebstreamPeer::URL, $this->url); + if ($this->isColumnModified(WebstreamPeer::ID)) $criteria->add(WebstreamPeer::ID, $this->id); + if ($this->isColumnModified(WebstreamPeer::NAME)) $criteria->add(WebstreamPeer::NAME, $this->name); + if ($this->isColumnModified(WebstreamPeer::OWNER_ID)) $criteria->add(WebstreamPeer::OWNER_ID, $this->owner_id); + if ($this->isColumnModified(WebstreamPeer::DESCRIPTION)) $criteria->add(WebstreamPeer::DESCRIPTION, $this->description); + if ($this->isColumnModified(WebstreamPeer::LAST_PLAYED)) $criteria->add(WebstreamPeer::LAST_PLAYED, $this->last_played); + if ($this->isColumnModified(WebstreamPeer::PLAY_COUNT)) $criteria->add(WebstreamPeer::PLAY_COUNT, $this->play_count); + if ($this->isColumnModified(WebstreamPeer::LENGTH)) $criteria->add(WebstreamPeer::LENGTH, $this->length); + if ($this->isColumnModified(WebstreamPeer::CREATED_AT)) $criteria->add(WebstreamPeer::CREATED_AT, $this->created_at); + if ($this->isColumnModified(WebstreamPeer::UPDATED_AT)) $criteria->add(WebstreamPeer::UPDATED_AT, $this->updated_at); + + 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(WebstreamPeer::DATABASE_NAME); + $criteria->add(WebstreamPeer::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 Webstream (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setMime($this->getMime()); + $copyObj->setUrl($this->getUrl()); + $copyObj->setName($this->getName()); + $copyObj->setOwnerId($this->getOwnerId()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setLastPlayedTime($this->getLastPlayedTime()); + $copyObj->setPlayCount($this->getPlayCount()); + $copyObj->setLength($this->getLength()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy && !$this->startCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + // store object hash to prevent cycle + $this->startCopy = true; + + $relObj = $this->getMediaItem(); + if ($relObj) { + $copyObj->setMediaItem($relObj->copy($deepCopy)); + } + + //unflag object copy + $this->startCopy = false; + } // if ($deepCopy) + + if ($makeNew) { + $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 Webstream 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 WebstreamPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new WebstreamPeer(); + } + + return self::$peer; + } + + /** + * Declares an association between this object and a MediaItem object. + * + * @param MediaItem $v + * @return Webstream The current object (for fluent API support) + * @throws PropelException + */ + public function setMediaItem(MediaItem $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aMediaItem = $v; + + // Add binding for other direction of this 1:1 relationship. + if ($v !== null) { + $v->setWebstream($this); + } + + + return $this; + } + + + /** + * Get the associated MediaItem object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return MediaItem The associated MediaItem object. + * @throws PropelException + */ + public function getMediaItem(PropelPDO $con = null, $doQuery = true) + { + if ($this->aMediaItem === null && ($this->id !== null) && $doQuery) { + $this->aMediaItem = MediaItemQuery::create()->findPk($this->id, $con); + // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association. + $this->aMediaItem->setWebstream($this); + } + + return $this->aMediaItem; + } + + /** + * Declares an association between this object and a CcSubjs object. + * + * @param CcSubjs $v + * @return Webstream The current object (for fluent API support) + * @throws PropelException + */ + public function setCcSubjs(CcSubjs $v = null) + { + if ($v === null) { + $this->setOwnerId(NULL); + } else { + $this->setOwnerId($v->getDbId()); + } + + $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->addWebstream($this); + } + + + return $this; + } + + + /** + * Get the associated CcSubjs object + * + * @param PropelPDO $con Optional Connection object. + * @param $doQuery Executes a query to get the object if required + * @return CcSubjs The associated CcSubjs object. + * @throws PropelException + */ + public function getCcSubjs(PropelPDO $con = null, $doQuery = true) + { + if ($this->aCcSubjs === null && ($this->owner_id !== null) && $doQuery) { + $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->owner_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->aCcSubjs->addWebstreams($this); + */ + } + + return $this->aCcSubjs; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->mime = null; + $this->url = null; + $this->id = null; + $this->name = null; + $this->owner_id = null; + $this->description = null; + $this->last_played = null; + $this->play_count = null; + $this->length = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->alreadyInValidation = false; + $this->alreadyInClearAllReferencesDeep = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep && !$this->alreadyInClearAllReferencesDeep) { + $this->alreadyInClearAllReferencesDeep = true; + if ($this->aMediaItem instanceof Persistent) { + $this->aMediaItem->clearAllReferences($deep); + } + if ($this->aCcSubjs instanceof Persistent) { + $this->aCcSubjs->clearAllReferences($deep); + } + + $this->alreadyInClearAllReferencesDeep = false; + } // if ($deep) + + $this->aMediaItem = null; + $this->aCcSubjs = null; + } + + /** + * return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(WebstreamPeer::DEFAULT_STRING_FORMAT); + } + + /** + * return true is the object is in saving state + * + * @return boolean + */ + public function isAlreadyInSave() + { + return $this->alreadyInSave; + } + + // concrete_inheritance behavior + + /** + * Get or Create the parent MediaItem object of the current object + * + * @return MediaItem The parent object + */ + public function getParentOrCreate($con = null) + { + if ($this->isNew()) { + if ($this->isPrimaryKeyNull()) { + //this prevent issue with deep copy & save parent object + if (null === ($parent = $this->getMediaItem($con))) { + $parent = new MediaItem(); + } + $parent->setDescendantClass('Airtime\MediaItem\Webstream'); + + return $parent; + } else { + $parent = MediaItemQuery::create()->findPk($this->getPrimaryKey(), $con); + if (null === $parent || null !== $parent->getDescendantClass()) { + $parent = new MediaItem(); + $parent->setPrimaryKey($this->getPrimaryKey()); + $parent->setDescendantClass('Airtime\MediaItem\Webstream'); + } + + return $parent; + } + } + + return MediaItemQuery::create()->findPk($this->getPrimaryKey(), $con); + } + + /** + * Create or Update the parent MediaItem object + * And return its primary key + * + * @return int The primary key of the parent object + */ + public function getSyncParent($con = null) + { + $parent = $this->getParentOrCreate($con); + $parent->setName($this->getName()); + $parent->setOwnerId($this->getOwnerId()); + $parent->setDescription($this->getDescription()); + $parent->setLastPlayedTime($this->getLastPlayedTime()); + $parent->setPlayCount($this->getPlayCount()); + $parent->setLength($this->getLength()); + $parent->setCreatedAt($this->getCreatedAt()); + $parent->setUpdatedAt($this->getUpdatedAt()); + if ($this->getCcSubjs() && $this->getCcSubjs()->isNew()) { + $parent->setCcSubjs($this->getCcSubjs()); + } + + return $parent; + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return Webstream The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = WebstreamPeer::UPDATED_AT; + + return $this; + } + +} diff --git a/airtime_mvc/application/models/airtime/om/BaseWebstreamPeer.php b/airtime_mvc/application/models/airtime/om/BaseWebstreamPeer.php new file mode 100644 index 000000000..ba170cfb9 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseWebstreamPeer.php @@ -0,0 +1,1448 @@ + array ('Mime', 'Url', 'Id', 'Name', 'OwnerId', 'Description', 'LastPlayedTime', 'PlayCount', 'Length', 'CreatedAt', 'UpdatedAt', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('mime', 'url', 'id', 'name', 'ownerId', 'description', 'lastPlayedTime', 'playCount', 'length', 'createdAt', 'updatedAt', ), + BasePeer::TYPE_COLNAME => array (WebstreamPeer::MIME, WebstreamPeer::URL, WebstreamPeer::ID, WebstreamPeer::NAME, WebstreamPeer::OWNER_ID, WebstreamPeer::DESCRIPTION, WebstreamPeer::LAST_PLAYED, WebstreamPeer::PLAY_COUNT, WebstreamPeer::LENGTH, WebstreamPeer::CREATED_AT, WebstreamPeer::UPDATED_AT, ), + BasePeer::TYPE_RAW_COLNAME => array ('MIME', 'URL', 'ID', 'NAME', 'OWNER_ID', 'DESCRIPTION', 'LAST_PLAYED', 'PLAY_COUNT', 'LENGTH', 'CREATED_AT', 'UPDATED_AT', ), + BasePeer::TYPE_FIELDNAME => array ('mime', 'url', 'id', 'name', 'owner_id', 'description', 'last_played', 'play_count', 'length', 'created_at', 'updated_at', ), + 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. WebstreamPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('Mime' => 0, 'Url' => 1, 'Id' => 2, 'Name' => 3, 'OwnerId' => 4, 'Description' => 5, 'LastPlayedTime' => 6, 'PlayCount' => 7, 'Length' => 8, 'CreatedAt' => 9, 'UpdatedAt' => 10, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('mime' => 0, 'url' => 1, 'id' => 2, 'name' => 3, 'ownerId' => 4, 'description' => 5, 'lastPlayedTime' => 6, 'playCount' => 7, 'length' => 8, 'createdAt' => 9, 'updatedAt' => 10, ), + BasePeer::TYPE_COLNAME => array (WebstreamPeer::MIME => 0, WebstreamPeer::URL => 1, WebstreamPeer::ID => 2, WebstreamPeer::NAME => 3, WebstreamPeer::OWNER_ID => 4, WebstreamPeer::DESCRIPTION => 5, WebstreamPeer::LAST_PLAYED => 6, WebstreamPeer::PLAY_COUNT => 7, WebstreamPeer::LENGTH => 8, WebstreamPeer::CREATED_AT => 9, WebstreamPeer::UPDATED_AT => 10, ), + BasePeer::TYPE_RAW_COLNAME => array ('MIME' => 0, 'URL' => 1, 'ID' => 2, 'NAME' => 3, 'OWNER_ID' => 4, 'DESCRIPTION' => 5, 'LAST_PLAYED' => 6, 'PLAY_COUNT' => 7, 'LENGTH' => 8, 'CREATED_AT' => 9, 'UPDATED_AT' => 10, ), + BasePeer::TYPE_FIELDNAME => array ('mime' => 0, 'url' => 1, 'id' => 2, 'name' => 3, 'owner_id' => 4, 'description' => 5, 'last_played' => 6, 'play_count' => 7, 'length' => 8, 'created_at' => 9, 'updated_at' => 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. + */ + public static function translateFieldName($name, $fromType, $toType) + { + $toNames = WebstreamPeer::getFieldNames($toType); + $key = isset(WebstreamPeer::$fieldKeys[$fromType][$name]) ? WebstreamPeer::$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(WebstreamPeer::$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 + * @throws PropelException - if the type is not valid. + */ + public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, WebstreamPeer::$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 WebstreamPeer::$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. WebstreamPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(WebstreamPeer::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(WebstreamPeer::MIME); + $criteria->addSelectColumn(WebstreamPeer::URL); + $criteria->addSelectColumn(WebstreamPeer::ID); + $criteria->addSelectColumn(WebstreamPeer::NAME); + $criteria->addSelectColumn(WebstreamPeer::OWNER_ID); + $criteria->addSelectColumn(WebstreamPeer::DESCRIPTION); + $criteria->addSelectColumn(WebstreamPeer::LAST_PLAYED); + $criteria->addSelectColumn(WebstreamPeer::PLAY_COUNT); + $criteria->addSelectColumn(WebstreamPeer::LENGTH); + $criteria->addSelectColumn(WebstreamPeer::CREATED_AT); + $criteria->addSelectColumn(WebstreamPeer::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.mime'); + $criteria->addSelectColumn($alias . '.url'); + $criteria->addSelectColumn($alias . '.id'); + $criteria->addSelectColumn($alias . '.name'); + $criteria->addSelectColumn($alias . '.owner_id'); + $criteria->addSelectColumn($alias . '.description'); + $criteria->addSelectColumn($alias . '.last_played'); + $criteria->addSelectColumn($alias . '.play_count'); + $criteria->addSelectColumn($alias . '.length'); + $criteria->addSelectColumn($alias . '.created_at'); + $criteria->addSelectColumn($alias . '.updated_at'); + } + } + + /** + * 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(WebstreamPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + WebstreamPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + $criteria->setDbName(WebstreamPeer::DATABASE_NAME); // Set the correct dbName + + if ($con === null) { + $con = Propel::getConnection(WebstreamPeer::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; + } + /** + * Selects one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param PropelPDO $con + * @return Webstream + * @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 = WebstreamPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + + return null; + } + /** + * Selects several row from the DB. + * + * @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 WebstreamPeer::populateObjects(WebstreamPeer::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 directly (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(WebstreamPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + if (!$criteria->hasSelectClause()) { + $criteria = clone $criteria; + WebstreamPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(WebstreamPeer::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 Webstream $obj A Webstream object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if ($key === null) { + $key = (string) $obj->getId(); + } // if key === null + WebstreamPeer::$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 Webstream object or a primary key value. + * + * @return void + * @throws PropelException - if the value is invalid. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && $value !== null) { + if (is_object($value) && $value instanceof Webstream) { + $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 Webstream object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); + throw $e; + } + + unset(WebstreamPeer::$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 Webstream 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(WebstreamPeer::$instances[$key])) { + return WebstreamPeer::$instances[$key]; + } + } + + return null; // just to be explicit + } + + /** + * Clear the instance pool. + * + * @return void + */ + public static function clearInstancePool($and_clear_all_references = false) + { + if ($and_clear_all_references) { + foreach (WebstreamPeer::$instances as $instance) { + $instance->clearAllReferences(true); + } + } + WebstreamPeer::$instances = array(); + } + + /** + * Method to invalidate the instance pool of all tables related to webstream + * 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 + 2] === null) { + return null; + } + + return (string) $row[$startcol + 2]; + } + + /** + * 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 + 2]; + } + + /** + * 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 = WebstreamPeer::getOMClass(); + // populate the object(s) + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key = WebstreamPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj = WebstreamPeer::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; + WebstreamPeer::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 (Webstream object, last column rank) + */ + public static function populateObject($row, $startcol = 0) + { + $key = WebstreamPeer::getPrimaryKeyHashFromRow($row, $startcol); + if (null !== ($obj = WebstreamPeer::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 + WebstreamPeer::NUM_HYDRATE_COLUMNS; + } else { + $cls = WebstreamPeer::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $startcol); + WebstreamPeer::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + + /** + * Returns the number of rows matching criteria, joining the related MediaItem 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 doCountJoinMediaItem(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(WebstreamPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + WebstreamPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(WebstreamPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(WebstreamPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(WebstreamPeer::ID, MediaItemPeer::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 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(WebstreamPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + WebstreamPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(WebstreamPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(WebstreamPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(WebstreamPeer::OWNER_ID, 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 Webstream objects pre-filled with their MediaItem 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 Webstream objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinMediaItem(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(WebstreamPeer::DATABASE_NAME); + } + + WebstreamPeer::addSelectColumns($criteria); + $startcol = WebstreamPeer::NUM_HYDRATE_COLUMNS; + MediaItemPeer::addSelectColumns($criteria); + + $criteria->addJoin(WebstreamPeer::ID, MediaItemPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = WebstreamPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = WebstreamPeer::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 = WebstreamPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + WebstreamPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = MediaItemPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = MediaItemPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = MediaItemPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + MediaItemPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (Webstream) to $obj2 (MediaItem) + // one to one relationship + $obj1->setMediaItem($obj2); + + } // if joined row was not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of Webstream 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 Webstream 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(WebstreamPeer::DATABASE_NAME); + } + + WebstreamPeer::addSelectColumns($criteria); + $startcol = WebstreamPeer::NUM_HYDRATE_COLUMNS; + CcSubjsPeer::addSelectColumns($criteria); + + $criteria->addJoin(WebstreamPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = WebstreamPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = WebstreamPeer::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 = WebstreamPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + WebstreamPeer::addInstanceToPool($obj1, $key1); + } // if $obj1 already loaded + + $key2 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol); + if ($key2 !== null) { + $obj2 = CcSubjsPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if obj2 already loaded + + // Add the $obj1 (Webstream) to $obj2 (CcSubjs) + $obj2->addWebstream($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(WebstreamPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + WebstreamPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // Set the correct dbName + $criteria->setDbName(WebstreamPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(WebstreamPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(WebstreamPeer::ID, MediaItemPeer::ID, $join_behavior); + + $criteria->addJoin(WebstreamPeer::OWNER_ID, 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 Webstream 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 Webstream 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(WebstreamPeer::DATABASE_NAME); + } + + WebstreamPeer::addSelectColumns($criteria); + $startcol2 = WebstreamPeer::NUM_HYDRATE_COLUMNS; + + MediaItemPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + MediaItemPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol4 = $startcol3 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(WebstreamPeer::ID, MediaItemPeer::ID, $join_behavior); + + $criteria->addJoin(WebstreamPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = WebstreamPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = WebstreamPeer::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 = WebstreamPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + WebstreamPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined MediaItem rows + + $key2 = MediaItemPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = MediaItemPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = MediaItemPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + MediaItemPeer::addInstanceToPool($obj2, $key2); + } // if obj2 loaded + + // Add the $obj1 (Webstream) to the collection in $obj2 (MediaItem) + $obj1->setMediaItem($obj2); + } // if joined row not null + + // Add objects for joined CcSubjs rows + + $key3 = CcSubjsPeer::getPrimaryKeyHashFromRow($row, $startcol3); + if ($key3 !== null) { + $obj3 = CcSubjsPeer::getInstanceFromPool($key3); + if (!$obj3) { + + $cls = CcSubjsPeer::getOMClass(); + + $obj3 = new $cls(); + $obj3->hydrate($row, $startcol3); + CcSubjsPeer::addInstanceToPool($obj3, $key3); + } // if obj3 loaded + + // Add the $obj1 (Webstream) to the collection in $obj3 (CcSubjs) + $obj3->addWebstream($obj1); + } // if joined row not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Returns the number of rows matching criteria, joining the related MediaItem 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 doCountJoinAllExceptMediaItem(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(WebstreamPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + WebstreamPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(WebstreamPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(WebstreamPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(WebstreamPeer::OWNER_ID, 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; + } + + + /** + * 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 doCountJoinAllExceptCcSubjs(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(WebstreamPeer::TABLE_NAME); + + if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->setDistinct(); + } + + if (!$criteria->hasSelectClause()) { + WebstreamPeer::addSelectColumns($criteria); + } + + $criteria->clearOrderByColumns(); // ORDER BY should not affect count + + // Set the correct dbName + $criteria->setDbName(WebstreamPeer::DATABASE_NAME); + + if ($con === null) { + $con = Propel::getConnection(WebstreamPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria->addJoin(WebstreamPeer::ID, MediaItemPeer::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 Webstream objects pre-filled with all related objects except MediaItem. + * + * @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 Webstream objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptMediaItem(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(WebstreamPeer::DATABASE_NAME); + } + + WebstreamPeer::addSelectColumns($criteria); + $startcol2 = WebstreamPeer::NUM_HYDRATE_COLUMNS; + + CcSubjsPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + CcSubjsPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(WebstreamPeer::OWNER_ID, CcSubjsPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = WebstreamPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = WebstreamPeer::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 = WebstreamPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + WebstreamPeer::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(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + CcSubjsPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (Webstream) to the collection in $obj2 (CcSubjs) + $obj2->addWebstream($obj1); + + } // if joined row is not null + + $results[] = $obj1; + } + $stmt->closeCursor(); + + return $results; + } + + + /** + * Selects a collection of Webstream objects pre-filled with all related objects except CcSubjs. + * + * @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 Webstream objects. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectJoinAllExceptCcSubjs(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(WebstreamPeer::DATABASE_NAME); + } + + WebstreamPeer::addSelectColumns($criteria); + $startcol2 = WebstreamPeer::NUM_HYDRATE_COLUMNS; + + MediaItemPeer::addSelectColumns($criteria); + $startcol3 = $startcol2 + MediaItemPeer::NUM_HYDRATE_COLUMNS; + + $criteria->addJoin(WebstreamPeer::ID, MediaItemPeer::ID, $join_behavior); + + + $stmt = BasePeer::doSelect($criteria, $con); + $results = array(); + + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $key1 = WebstreamPeer::getPrimaryKeyHashFromRow($row, 0); + if (null !== ($obj1 = WebstreamPeer::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 = WebstreamPeer::getOMClass(); + + $obj1 = new $cls(); + $obj1->hydrate($row); + WebstreamPeer::addInstanceToPool($obj1, $key1); + } // if obj1 already loaded + + // Add objects for joined MediaItem rows + + $key2 = MediaItemPeer::getPrimaryKeyHashFromRow($row, $startcol2); + if ($key2 !== null) { + $obj2 = MediaItemPeer::getInstanceFromPool($key2); + if (!$obj2) { + + $cls = MediaItemPeer::getOMClass(); + + $obj2 = new $cls(); + $obj2->hydrate($row, $startcol2); + MediaItemPeer::addInstanceToPool($obj2, $key2); + } // if $obj2 already loaded + + // Add the $obj1 (Webstream) to the collection in $obj2 (MediaItem) + $obj1->setMediaItem($obj2); + + } // 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(WebstreamPeer::DATABASE_NAME)->getTable(WebstreamPeer::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this peer class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getDatabaseMap(BaseWebstreamPeer::DATABASE_NAME); + if (!$dbMap->hasTable(BaseWebstreamPeer::TABLE_NAME)) { + $dbMap->addTableObject(new \Airtime\MediaItem\map\WebstreamTableMap()); + } + } + + /** + * The class that the Peer will make instances of. + * + * + * @return string ClassName + */ + public static function getOMClass($row = 0, $colnum = 0) + { + return WebstreamPeer::OM_CLASS; + } + + /** + * Performs an INSERT on the database, given a Webstream or Criteria object. + * + * @param mixed $values Criteria or Webstream 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(WebstreamPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from Webstream object + } + + + // Set the correct dbName + $criteria->setDbName(WebstreamPeer::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 (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + + /** + * Performs an UPDATE on the database, given a Webstream or Criteria object. + * + * @param mixed $values Criteria or Webstream 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(WebstreamPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + } + + $selectCriteria = new Criteria(WebstreamPeer::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(WebstreamPeer::ID); + $value = $criteria->remove(WebstreamPeer::ID); + if ($value) { + $selectCriteria->add(WebstreamPeer::ID, $value, $comparison); + } else { + $selectCriteria->setPrimaryTableName(WebstreamPeer::TABLE_NAME); + } + + } else { // $values is Webstream object + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(WebstreamPeer::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Deletes all rows from the webstream table. + * + * @param PropelPDO $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException + */ + public static function doDeleteAll(PropelPDO $con = null) + { + if ($con === null) { + $con = Propel::getConnection(WebstreamPeer::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(WebstreamPeer::TABLE_NAME, $con, WebstreamPeer::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). + WebstreamPeer::clearInstancePool(); + WebstreamPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs a DELETE on the database, given a Webstream or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or Webstream 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(WebstreamPeer::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. + WebstreamPeer::clearInstancePool(); + // rename for clarity + $criteria = clone $values; + } elseif ($values instanceof Webstream) { // it's a model object + // invalidate the cache for this single object + WebstreamPeer::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(WebstreamPeer::DATABASE_NAME); + $criteria->add(WebstreamPeer::ID, (array) $values, Criteria::IN); + // invalidate the cache for this object(s) + foreach ((array) $values as $singleval) { + WebstreamPeer::removeInstanceFromPool($singleval); + } + } + + // Set the correct dbName + $criteria->setDbName(WebstreamPeer::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); + WebstreamPeer::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Validates all modified columns of given Webstream 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 Webstream $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($obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(WebstreamPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(WebstreamPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->hasColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(WebstreamPeer::DATABASE_NAME, WebstreamPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param int $pk the primary key. + * @param PropelPDO $con the connection to use + * @return Webstream + */ + public static function retrieveByPK($pk, PropelPDO $con = null) + { + + if (null !== ($obj = WebstreamPeer::getInstanceFromPool((string) $pk))) { + return $obj; + } + + if ($con === null) { + $con = Propel::getConnection(WebstreamPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $criteria = new Criteria(WebstreamPeer::DATABASE_NAME); + $criteria->add(WebstreamPeer::ID, $pk); + + $v = WebstreamPeer::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 + * @return Webstream[] + * @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(WebstreamPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(WebstreamPeer::DATABASE_NAME); + $criteria->add(WebstreamPeer::ID, $pks, Criteria::IN); + $objs = WebstreamPeer::doSelect($criteria, $con); + } + + return $objs; + } + +} // BaseWebstreamPeer + +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +BaseWebstreamPeer::buildTableMap(); + diff --git a/airtime_mvc/application/models/airtime/om/BaseWebstreamQuery.php b/airtime_mvc/application/models/airtime/om/BaseWebstreamQuery.php new file mode 100644 index 000000000..9c2903970 --- /dev/null +++ b/airtime_mvc/application/models/airtime/om/BaseWebstreamQuery.php @@ -0,0 +1,920 @@ +mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return Webstream|Webstream[]|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = WebstreamPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getConnection(WebstreamPeer::DATABASE_NAME, Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Alias of findPk to use instance pooling + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Webstream A model object, or null if the key is not found + * @throws PropelException + */ + public function findOneById($key, $con = null) + { + return $this->findPk($key, $con); + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Webstream A model object, or null if the key is not found + * @throws PropelException + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT "mime", "url", "id", "name", "owner_id", "description", "last_played", "play_count", "length", "created_at", "updated_at" FROM "webstream" WHERE "id" = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + $obj = null; + if ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $obj = new Webstream(); + $obj->hydrate($row); + WebstreamPeer::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con A connection object + * + * @return Webstream|Webstream[]|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKey($key) + ->doSelect($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|Webstream[]|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($stmt); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return WebstreamQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(WebstreamPeer::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 WebstreamQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(WebstreamPeer::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the mime column + * + * Example usage: + * + * $query->filterByMime('fooValue'); // WHERE mime = 'fooValue' + * $query->filterByMime('%fooValue%'); // WHERE mime LIKE '%fooValue%' + * + * + * @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 WebstreamQuery 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(WebstreamPeer::MIME, $mime, $comparison); + } + + /** + * Filter the query on the url column + * + * Example usage: + * + * $query->filterByUrl('fooValue'); // WHERE url = 'fooValue' + * $query->filterByUrl('%fooValue%'); // WHERE url LIKE '%fooValue%' + * + * + * @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 WebstreamQuery 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(WebstreamPeer::URL, $url, $comparison); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id >= 12 + * $query->filterById(array('max' => 12)); // WHERE id <= 12 + * + * + * @see filterByMediaItem() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return WebstreamQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(WebstreamPeer::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(WebstreamPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(WebstreamPeer::ID, $id, $comparison); + } + + /** + * Filter the query on the name column + * + * Example usage: + * + * $query->filterByName('fooValue'); // WHERE name = 'fooValue' + * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' + * + * + * @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 WebstreamQuery 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(WebstreamPeer::NAME, $name, $comparison); + } + + /** + * Filter the query on the owner_id column + * + * Example usage: + * + * $query->filterByOwnerId(1234); // WHERE owner_id = 1234 + * $query->filterByOwnerId(array(12, 34)); // WHERE owner_id IN (12, 34) + * $query->filterByOwnerId(array('min' => 12)); // WHERE owner_id >= 12 + * $query->filterByOwnerId(array('max' => 12)); // WHERE owner_id <= 12 + * + * + * @see filterByCcSubjs() + * + * @param mixed $ownerId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return WebstreamQuery The current query, for fluid interface + */ + public function filterByOwnerId($ownerId = null, $comparison = null) + { + if (is_array($ownerId)) { + $useMinMax = false; + if (isset($ownerId['min'])) { + $this->addUsingAlias(WebstreamPeer::OWNER_ID, $ownerId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($ownerId['max'])) { + $this->addUsingAlias(WebstreamPeer::OWNER_ID, $ownerId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(WebstreamPeer::OWNER_ID, $ownerId, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description 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 WebstreamQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(WebstreamPeer::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the last_played column + * + * Example usage: + * + * $query->filterByLastPlayedTime('2011-03-14'); // WHERE last_played = '2011-03-14' + * $query->filterByLastPlayedTime('now'); // WHERE last_played = '2011-03-14' + * $query->filterByLastPlayedTime(array('max' => 'yesterday')); // WHERE last_played < '2011-03-13' + * + * + * @param mixed $lastPlayedTime The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return WebstreamQuery The current query, for fluid interface + */ + public function filterByLastPlayedTime($lastPlayedTime = null, $comparison = null) + { + if (is_array($lastPlayedTime)) { + $useMinMax = false; + if (isset($lastPlayedTime['min'])) { + $this->addUsingAlias(WebstreamPeer::LAST_PLAYED, $lastPlayedTime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($lastPlayedTime['max'])) { + $this->addUsingAlias(WebstreamPeer::LAST_PLAYED, $lastPlayedTime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(WebstreamPeer::LAST_PLAYED, $lastPlayedTime, $comparison); + } + + /** + * Filter the query on the play_count column + * + * Example usage: + * + * $query->filterByPlayCount(1234); // WHERE play_count = 1234 + * $query->filterByPlayCount(array(12, 34)); // WHERE play_count IN (12, 34) + * $query->filterByPlayCount(array('min' => 12)); // WHERE play_count >= 12 + * $query->filterByPlayCount(array('max' => 12)); // WHERE play_count <= 12 + * + * + * @param mixed $playCount The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return WebstreamQuery The current query, for fluid interface + */ + public function filterByPlayCount($playCount = null, $comparison = null) + { + if (is_array($playCount)) { + $useMinMax = false; + if (isset($playCount['min'])) { + $this->addUsingAlias(WebstreamPeer::PLAY_COUNT, $playCount['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($playCount['max'])) { + $this->addUsingAlias(WebstreamPeer::PLAY_COUNT, $playCount['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(WebstreamPeer::PLAY_COUNT, $playCount, $comparison); + } + + /** + * Filter the query on the length column + * + * Example usage: + * + * $query->filterByLength('fooValue'); // WHERE length = 'fooValue' + * $query->filterByLength('%fooValue%'); // WHERE length LIKE '%fooValue%' + * + * + * @param string $length 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 WebstreamQuery The current query, for fluid interface + */ + public function filterByLength($length = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($length)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $length)) { + $length = str_replace('*', '%', $length); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(WebstreamPeer::LENGTH, $length, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at < '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return WebstreamQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(WebstreamPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(WebstreamPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(WebstreamPeer::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at < '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return WebstreamQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(WebstreamPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(WebstreamPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(WebstreamPeer::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related MediaItem object + * + * @param MediaItem|PropelObjectCollection $mediaItem The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return WebstreamQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByMediaItem($mediaItem, $comparison = null) + { + if ($mediaItem instanceof MediaItem) { + return $this + ->addUsingAlias(WebstreamPeer::ID, $mediaItem->getId(), $comparison); + } elseif ($mediaItem instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(WebstreamPeer::ID, $mediaItem->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByMediaItem() only accepts arguments of type MediaItem or PropelCollection'); + } + } + + /** + * Adds a JOIN clause to the query using the MediaItem relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return WebstreamQuery The current query, for fluid interface + */ + public function joinMediaItem($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('MediaItem'); + + // 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, 'MediaItem'); + } + + return $this; + } + + /** + * Use the MediaItem relation MediaItem 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 \Airtime\MediaItemQuery A secondary query class using the current class as primary query + */ + public function useMediaItemQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinMediaItem($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'MediaItem', '\Airtime\MediaItemQuery'); + } + + /** + * Filter the query by a related CcSubjs object + * + * @param CcSubjs|PropelObjectCollection $ccSubjs The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return WebstreamQuery The current query, for fluid interface + * @throws PropelException - if the provided filter is invalid. + */ + public function filterByCcSubjs($ccSubjs, $comparison = null) + { + if ($ccSubjs instanceof CcSubjs) { + return $this + ->addUsingAlias(WebstreamPeer::OWNER_ID, $ccSubjs->getDbId(), $comparison); + } elseif ($ccSubjs instanceof PropelObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(WebstreamPeer::OWNER_ID, $ccSubjs->toKeyValue('PrimaryKey', 'DbId'), $comparison); + } else { + throw new PropelException('filterByCcSubjs() only accepts arguments of type CcSubjs or PropelCollection'); + } + } + + /** + * 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 WebstreamQuery The current query, for fluid interface + */ + public function joinCcSubjs($relationAlias = null, $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 \Airtime\CcSubjsQuery A secondary query class using the current class as primary query + */ + public function useCcSubjsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinCcSubjs($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CcSubjs', '\Airtime\CcSubjsQuery'); + } + + /** + * Exclude object from result + * + * @param Webstream $webstream Object to remove from the list of results + * + * @return WebstreamQuery The current query, for fluid interface + */ + public function prune($webstream = null) + { + if ($webstream) { + $this->addUsingAlias(WebstreamPeer::ID, $webstream->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return WebstreamQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(WebstreamPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return WebstreamQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(WebstreamPeer::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return WebstreamQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(WebstreamPeer::UPDATED_AT); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return WebstreamQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(WebstreamPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by create date desc + * + * @return WebstreamQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(WebstreamPeer::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return WebstreamQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(WebstreamPeer::CREATED_AT); + } +} diff --git a/airtime_mvc/application/services/CalendarService.php b/airtime_mvc/application/services/CalendarService.php index 3c3a85b6c..be2d790d5 100644 --- a/airtime_mvc/application/services/CalendarService.php +++ b/airtime_mvc/application/services/CalendarService.php @@ -1,5 +1,7 @@ - + @@ -98,28 +98,7 @@
- - - - - - - - - - - - - - - - - - - - - -
+ @@ -350,31 +329,6 @@
- - - - - - - - - - - - - - -
- - - - - - - - - -
@@ -479,7 +433,7 @@
- +
@@ -492,7 +446,7 @@
- +
@@ -501,12 +455,12 @@
- +
- +
@@ -518,4 +472,100 @@
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ + + + + +
+ + + + + + +
+ + + + + + + + + + + + + + +
+ +
diff --git a/airtime_mvc/build/sql/schema.sql b/airtime_mvc/build/sql/schema.sql index 13d1654a5..8d5482640 100644 --- a/airtime_mvc/build/sql/schema.sql +++ b/airtime_mvc/build/sql/schema.sql @@ -1,901 +1,971 @@ ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_music_dirs ------------------------------------------------------------------------------ - -DROP TABLE "cc_music_dirs" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_music_dirs" CASCADE; CREATE TABLE "cc_music_dirs" ( - "id" serial NOT NULL, - "directory" TEXT, - "type" VARCHAR(255), - "exists" BOOLEAN default 't', - "watched" BOOLEAN default 't', - PRIMARY KEY ("id"), - CONSTRAINT "cc_music_dir_unique" UNIQUE ("directory") + "id" serial NOT NULL, + "directory" TEXT, + "type" VARCHAR(255), + "exists" BOOLEAN DEFAULT 't', + "watched" BOOLEAN DEFAULT 't', + PRIMARY KEY ("id"), + CONSTRAINT "cc_music_dir_unique" UNIQUE ("directory") ); -COMMENT ON TABLE "cc_music_dirs" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_files ------------------------------------------------------------------------------ - -DROP TABLE "cc_files" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_files" CASCADE; CREATE TABLE "cc_files" ( - "id" serial NOT NULL, - "name" VARCHAR(255) default '' NOT NULL, - "mime" VARCHAR(255) default '' NOT NULL, - "ftype" VARCHAR(128) default '' NOT NULL, - "directory" INTEGER, - "filepath" TEXT default '', - "state" VARCHAR(128) default 'empty' NOT NULL, - "currentlyaccessing" INTEGER default 0 NOT NULL, - "editedby" INTEGER, - "mtime" TIMESTAMP(6), - "utime" TIMESTAMP(6), - "lptime" TIMESTAMP(6), - "md5" CHAR(32), - "track_title" VARCHAR(512), - "artist_name" VARCHAR(512), - "bit_rate" INTEGER, - "sample_rate" INTEGER, - "format" VARCHAR(128), - "length" interval default '00:00:00', - "album_title" VARCHAR(512), - "genre" VARCHAR(64), - "comments" TEXT, - "year" VARCHAR(16), - "track_number" INTEGER, - "channels" INTEGER, - "url" VARCHAR(1024), - "bpm" INTEGER, - "rating" VARCHAR(8), - "encoded_by" VARCHAR(255), - "disc_number" VARCHAR(8), - "mood" VARCHAR(64), - "label" VARCHAR(512), - "composer" VARCHAR(512), - "encoder" VARCHAR(64), - "checksum" VARCHAR(256), - "lyrics" TEXT, - "orchestra" VARCHAR(512), - "conductor" VARCHAR(512), - "lyricist" VARCHAR(512), - "original_lyricist" VARCHAR(512), - "radio_station_name" VARCHAR(512), - "info_url" VARCHAR(512), - "artist_url" VARCHAR(512), - "audio_source_url" VARCHAR(512), - "radio_station_url" VARCHAR(512), - "buy_this_url" VARCHAR(512), - "isrc_number" VARCHAR(512), - "catalog_number" VARCHAR(512), - "original_artist" VARCHAR(512), - "copyright" VARCHAR(512), - "report_datetime" VARCHAR(32), - "report_location" VARCHAR(512), - "report_organization" VARCHAR(512), - "subject" VARCHAR(512), - "contributor" VARCHAR(512), - "language" VARCHAR(512), - "file_exists" BOOLEAN default 't', - "soundcloud_id" INTEGER, - "soundcloud_error_code" INTEGER, - "soundcloud_error_msg" VARCHAR(512), - "soundcloud_link_to_file" VARCHAR(4096), - "soundcloud_upload_time" TIMESTAMP(6), - "replay_gain" NUMERIC, - "owner_id" INTEGER, - "cuein" interval default '00:00:00', - "cueout" interval default '00:00:00', - "silan_check" BOOLEAN default 'f', - "hidden" BOOLEAN default 'f', - "is_scheduled" BOOLEAN default 'f', - "is_playlist" BOOLEAN default 'f', - PRIMARY KEY ("id") + "id" serial NOT NULL, + "name" VARCHAR(255) DEFAULT '' NOT NULL, + "mime" VARCHAR(255) DEFAULT '' NOT NULL, + "ftype" VARCHAR(128) DEFAULT '' NOT NULL, + "directory" INTEGER, + "filepath" TEXT DEFAULT '', + "state" VARCHAR(128) DEFAULT 'empty' NOT NULL, + "currentlyaccessing" INTEGER DEFAULT 0 NOT NULL, + "editedby" INTEGER, + "mtime" TIMESTAMP(6), + "utime" TIMESTAMP(6), + "lptime" TIMESTAMP(6), + "md5" CHAR(32), + "track_title" VARCHAR(512), + "artist_name" VARCHAR(512), + "bit_rate" INTEGER, + "sample_rate" INTEGER, + "format" VARCHAR(128), + "length" interval DEFAULT '00:00:00', + "album_title" VARCHAR(512), + "genre" VARCHAR(64), + "comments" TEXT, + "year" VARCHAR(16), + "track_number" INTEGER, + "channels" INTEGER, + "url" VARCHAR(1024), + "bpm" INTEGER, + "rating" VARCHAR(8), + "encoded_by" VARCHAR(255), + "disc_number" VARCHAR(8), + "mood" VARCHAR(64), + "label" VARCHAR(512), + "composer" VARCHAR(512), + "encoder" VARCHAR(64), + "checksum" VARCHAR(256), + "lyrics" TEXT, + "orchestra" VARCHAR(512), + "conductor" VARCHAR(512), + "lyricist" VARCHAR(512), + "original_lyricist" VARCHAR(512), + "radio_station_name" VARCHAR(512), + "info_url" VARCHAR(512), + "artist_url" VARCHAR(512), + "audio_source_url" VARCHAR(512), + "radio_station_url" VARCHAR(512), + "buy_this_url" VARCHAR(512), + "isrc_number" VARCHAR(512), + "catalog_number" VARCHAR(512), + "original_artist" VARCHAR(512), + "copyright" VARCHAR(512), + "report_datetime" VARCHAR(32), + "report_location" VARCHAR(512), + "report_organization" VARCHAR(512), + "subject" VARCHAR(512), + "contributor" VARCHAR(512), + "language" VARCHAR(512), + "file_exists" BOOLEAN DEFAULT 't', + "soundcloud_id" INTEGER, + "soundcloud_error_code" INTEGER, + "soundcloud_error_msg" VARCHAR(512), + "soundcloud_link_to_file" VARCHAR(4096), + "soundcloud_upload_time" TIMESTAMP(6), + "replay_gain" NUMERIC, + "owner_id" INTEGER, + "cuein" interval DEFAULT '00:00:00', + "cueout" interval DEFAULT '00:00:00', + "silan_check" BOOLEAN DEFAULT 'f', + "hidden" BOOLEAN DEFAULT 'f', + "is_scheduled" BOOLEAN DEFAULT 'f', + "is_playlist" BOOLEAN DEFAULT 'f', + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_files" IS ''; - - -SET search_path TO public; CREATE INDEX "cc_files_md5_idx" ON "cc_files" ("md5"); CREATE INDEX "cc_files_name_idx" ON "cc_files" ("name"); ------------------------------------------------------------------------------ --- cc_perms ------------------------------------------------------------------------------ - -DROP TABLE "cc_perms" CASCADE; - - -CREATE TABLE "cc_perms" -( - "permid" INTEGER NOT NULL, - "subj" INTEGER, - "action" VARCHAR(20), - "obj" INTEGER, - "type" CHAR(1), - PRIMARY KEY ("permid"), - CONSTRAINT "cc_perms_all_idx" UNIQUE ("subj","action","obj"), - CONSTRAINT "cc_perms_permid_idx" UNIQUE ("permid") -); - -COMMENT ON TABLE "cc_perms" IS ''; - - -SET search_path TO public; -CREATE INDEX "cc_perms_subj_obj_idx" ON "cc_perms" ("subj","obj"); - ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_show ------------------------------------------------------------------------------ - -DROP TABLE "cc_show" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_show" CASCADE; CREATE TABLE "cc_show" ( - "id" serial NOT NULL, - "name" VARCHAR(255) default '' NOT NULL, - "url" VARCHAR(255) default '', - "genre" VARCHAR(255) default '', - "description" VARCHAR(512), - "color" VARCHAR(6), - "background_color" VARCHAR(6), - "live_stream_using_airtime_auth" BOOLEAN default 'f', - "live_stream_using_custom_auth" BOOLEAN default 'f', - "live_stream_user" VARCHAR(255), - "live_stream_pass" VARCHAR(255), - "linked" BOOLEAN default 'f' NOT NULL, - "is_linkable" BOOLEAN default 't' NOT NULL, - PRIMARY KEY ("id") + "id" serial NOT NULL, + "name" VARCHAR(255) DEFAULT '' NOT NULL, + "url" VARCHAR(255) DEFAULT '', + "genre" VARCHAR(255) DEFAULT '', + "description" VARCHAR(512), + "color" VARCHAR(6), + "background_color" VARCHAR(6), + "live_stream_using_airtime_auth" BOOLEAN DEFAULT 'f', + "live_stream_using_custom_auth" BOOLEAN DEFAULT 'f', + "live_stream_user" VARCHAR(255), + "live_stream_pass" VARCHAR(255), + "linked" BOOLEAN DEFAULT 'f' NOT NULL, + "is_linkable" BOOLEAN DEFAULT 't' NOT NULL, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_show" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_show_instances ------------------------------------------------------------------------------ - -DROP TABLE "cc_show_instances" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_show_instances" CASCADE; CREATE TABLE "cc_show_instances" ( - "id" serial NOT NULL, - "starts" TIMESTAMP NOT NULL, - "ends" TIMESTAMP NOT NULL, - "show_id" INTEGER NOT NULL, - "record" INT2 default 0, - "rebroadcast" INT2 default 0, - "instance_id" INTEGER, - "file_id" INTEGER, - "time_filled" interval default '00:00:00', - "created" TIMESTAMP NOT NULL, - "last_scheduled" TIMESTAMP, - "modified_instance" BOOLEAN default 'f' NOT NULL, - PRIMARY KEY ("id") + "id" serial NOT NULL, + "starts" TIMESTAMP NOT NULL, + "ends" TIMESTAMP NOT NULL, + "show_id" INTEGER NOT NULL, + "record" INT2 DEFAULT 0, + "rebroadcast" INT2 DEFAULT 0, + "instance_id" INTEGER, + "file_id" INTEGER, + "time_filled" interval DEFAULT '00:00:00', + "created" TIMESTAMP NOT NULL, + "last_scheduled" TIMESTAMP, + "modified_instance" BOOLEAN DEFAULT 'f' NOT NULL, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_show_instances" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_show_days ------------------------------------------------------------------------------ - -DROP TABLE "cc_show_days" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_show_days" CASCADE; CREATE TABLE "cc_show_days" ( - "id" serial NOT NULL, - "first_show" DATE NOT NULL, - "last_show" DATE, - "start_time" TIME NOT NULL, - "timezone" VARCHAR(255) NOT NULL, - "duration" VARCHAR(255) NOT NULL, - "day" INT2, - "repeat_type" INT2 NOT NULL, - "next_pop_date" DATE, - "show_id" INTEGER NOT NULL, - "record" INT2 default 0, - PRIMARY KEY ("id") + "id" serial NOT NULL, + "first_show" DATE NOT NULL, + "last_show" DATE, + "start_time" TIME NOT NULL, + "timezone" VARCHAR NOT NULL, + "duration" VARCHAR NOT NULL, + "day" INT2, + "repeat_type" INT2 NOT NULL, + "next_pop_date" DATE, + "show_id" INTEGER NOT NULL, + "record" INT2 DEFAULT 0, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_show_days" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_show_rebroadcast ------------------------------------------------------------------------------ - -DROP TABLE "cc_show_rebroadcast" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_show_rebroadcast" CASCADE; CREATE TABLE "cc_show_rebroadcast" ( - "id" serial NOT NULL, - "day_offset" VARCHAR(255) NOT NULL, - "start_time" TIME NOT NULL, - "show_id" INTEGER NOT NULL, - PRIMARY KEY ("id") + "id" serial NOT NULL, + "day_offset" VARCHAR NOT NULL, + "start_time" TIME NOT NULL, + "show_id" INTEGER NOT NULL, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_show_rebroadcast" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_show_hosts ------------------------------------------------------------------------------ - -DROP TABLE "cc_show_hosts" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_show_hosts" CASCADE; CREATE TABLE "cc_show_hosts" ( - "id" serial NOT NULL, - "show_id" INTEGER NOT NULL, - "subjs_id" INTEGER NOT NULL, - PRIMARY KEY ("id") + "id" serial NOT NULL, + "show_id" INTEGER NOT NULL, + "subjs_id" INTEGER NOT NULL, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_show_hosts" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_playlist ------------------------------------------------------------------------------ - -DROP TABLE "cc_playlist" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_playlist" CASCADE; CREATE TABLE "cc_playlist" ( - "id" serial NOT NULL, - "name" VARCHAR(255) default '' NOT NULL, - "mtime" TIMESTAMP(6), - "utime" TIMESTAMP(6), - "creator_id" INTEGER, - "description" VARCHAR(512), - "length" interval default '00:00:00', - PRIMARY KEY ("id") + "id" serial NOT NULL, + "name" VARCHAR(255) DEFAULT '' NOT NULL, + "mtime" TIMESTAMP(6), + "utime" TIMESTAMP(6), + "creator_id" INTEGER, + "description" VARCHAR(512), + "length" interval DEFAULT '00:00:00', + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_playlist" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_playlistcontents ------------------------------------------------------------------------------ - -DROP TABLE "cc_playlistcontents" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_playlistcontents" CASCADE; CREATE TABLE "cc_playlistcontents" ( - "id" serial NOT NULL, - "playlist_id" INTEGER, - "file_id" INTEGER, - "block_id" INTEGER, - "stream_id" INTEGER, - "type" INT2 default 0 NOT NULL, - "position" INTEGER, - "trackoffset" FLOAT default 0 NOT NULL, - "cliplength" interval default '00:00:00', - "cuein" interval default '00:00:00', - "cueout" interval default '00:00:00', - "fadein" TIME default '00:00:00', - "fadeout" TIME default '00:00:00', - PRIMARY KEY ("id") + "id" serial NOT NULL, + "playlist_id" INTEGER, + "file_id" INTEGER, + "block_id" INTEGER, + "stream_id" INTEGER, + "type" INT2 DEFAULT 0 NOT NULL, + "position" INTEGER, + "trackoffset" FLOAT DEFAULT 0 NOT NULL, + "cliplength" interval DEFAULT '00:00:00', + "cuein" interval DEFAULT '00:00:00', + "cueout" interval DEFAULT '00:00:00', + "fadein" TIME DEFAULT '00:00:00', + "fadeout" TIME DEFAULT '00:00:00', + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_playlistcontents" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_block ------------------------------------------------------------------------------ - -DROP TABLE "cc_block" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_block" CASCADE; CREATE TABLE "cc_block" ( - "id" serial NOT NULL, - "name" VARCHAR(255) default '' NOT NULL, - "mtime" TIMESTAMP(6), - "utime" TIMESTAMP(6), - "creator_id" INTEGER, - "description" VARCHAR(512), - "length" interval default '00:00:00', - "type" VARCHAR(7) default 'static', - PRIMARY KEY ("id") + "id" serial NOT NULL, + "name" VARCHAR(255) DEFAULT '' NOT NULL, + "mtime" TIMESTAMP(6), + "utime" TIMESTAMP(6), + "creator_id" INTEGER, + "description" VARCHAR(512), + "length" interval DEFAULT '00:00:00', + "type" VARCHAR(7) DEFAULT 'static', + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_block" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_blockcontents ------------------------------------------------------------------------------ - -DROP TABLE "cc_blockcontents" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_blockcontents" CASCADE; CREATE TABLE "cc_blockcontents" ( - "id" serial NOT NULL, - "block_id" INTEGER, - "file_id" INTEGER, - "position" INTEGER, - "trackoffset" FLOAT default 0 NOT NULL, - "cliplength" interval default '00:00:00', - "cuein" interval default '00:00:00', - "cueout" interval default '00:00:00', - "fadein" TIME default '00:00:00', - "fadeout" TIME default '00:00:00', - PRIMARY KEY ("id") + "id" serial NOT NULL, + "block_id" INTEGER, + "file_id" INTEGER, + "position" INTEGER, + "trackoffset" FLOAT DEFAULT 0 NOT NULL, + "cliplength" interval DEFAULT '00:00:00', + "cuein" interval DEFAULT '00:00:00', + "cueout" interval DEFAULT '00:00:00', + "fadein" TIME DEFAULT '00:00:00', + "fadeout" TIME DEFAULT '00:00:00', + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_blockcontents" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_blockcriteria ------------------------------------------------------------------------------ - -DROP TABLE "cc_blockcriteria" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_blockcriteria" CASCADE; CREATE TABLE "cc_blockcriteria" ( - "id" serial NOT NULL, - "criteria" VARCHAR(32) NOT NULL, - "modifier" VARCHAR(16) NOT NULL, - "value" VARCHAR(512) NOT NULL, - "extra" VARCHAR(512), - "block_id" INTEGER NOT NULL, - PRIMARY KEY ("id") + "id" serial NOT NULL, + "criteria" VARCHAR(32) NOT NULL, + "modifier" VARCHAR(16) NOT NULL, + "value" VARCHAR(512) NOT NULL, + "extra" VARCHAR(512), + "block_id" INTEGER NOT NULL, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_blockcriteria" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_pref ------------------------------------------------------------------------------ - -DROP TABLE "cc_pref" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_pref" CASCADE; CREATE TABLE "cc_pref" ( - "id" serial NOT NULL, - "subjid" INTEGER, - "keystr" VARCHAR(255), - "valstr" TEXT, - PRIMARY KEY ("id"), - CONSTRAINT "cc_pref_id_idx" UNIQUE ("id"), - CONSTRAINT "cc_pref_subj_key_idx" UNIQUE ("subjid","keystr") + "id" serial NOT NULL, + "subjid" INTEGER, + "keystr" VARCHAR(255), + "valstr" TEXT, + PRIMARY KEY ("id"), + CONSTRAINT "cc_pref_id_idx" UNIQUE ("id"), + CONSTRAINT "cc_pref_subj_key_idx" UNIQUE ("subjid","keystr") ); -COMMENT ON TABLE "cc_pref" IS ''; - - -SET search_path TO public; CREATE INDEX "cc_pref_subjid_idx" ON "cc_pref" ("subjid"); ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_schedule ------------------------------------------------------------------------------ - -DROP TABLE "cc_schedule" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_schedule" CASCADE; CREATE TABLE "cc_schedule" ( - "id" serial NOT NULL, - "starts" TIMESTAMP NOT NULL, - "ends" TIMESTAMP NOT NULL, - "file_id" INTEGER, - "stream_id" INTEGER, - "clip_length" interval default '00:00:00', - "fade_in" TIME default '00:00:00', - "fade_out" TIME default '00:00:00', - "cue_in" interval NOT NULL, - "cue_out" interval NOT NULL, - "media_item_played" BOOLEAN default 'f', - "instance_id" INTEGER NOT NULL, - "playout_status" INT2 default 1 NOT NULL, - "broadcasted" INT2 default 0 NOT NULL, - "position" INTEGER default 0 NOT NULL, - PRIMARY KEY ("id") + "id" serial NOT NULL, + "starts" TIMESTAMP NOT NULL, + "ends" TIMESTAMP NOT NULL, + "file_id" INTEGER, + "stream_id" INTEGER, + "clip_length" interval DEFAULT '00:00:00', + "fade_in" TIME DEFAULT '00:00:00', + "fade_out" TIME DEFAULT '00:00:00', + "cue_in" interval NOT NULL, + "cue_out" interval NOT NULL, + "media_item_played" BOOLEAN DEFAULT 'f', + "instance_id" INTEGER NOT NULL, + "playout_status" INT2 DEFAULT 1 NOT NULL, + "broadcasted" INT2 DEFAULT 0 NOT NULL, + "position" INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_schedule" IS ''; - - -SET search_path TO public; CREATE INDEX "cc_schedule_instance_id_idx" ON "cc_schedule" ("instance_id"); ------------------------------------------------------------------------------ --- cc_sess ------------------------------------------------------------------------------ - -DROP TABLE "cc_sess" CASCADE; - - -CREATE TABLE "cc_sess" -( - "sessid" CHAR(32) NOT NULL, - "userid" INTEGER, - "login" VARCHAR(255), - "ts" TIMESTAMP, - PRIMARY KEY ("sessid") -); - -COMMENT ON TABLE "cc_sess" IS ''; - - -SET search_path TO public; -CREATE INDEX "cc_sess_login_idx" ON "cc_sess" ("login"); - -CREATE INDEX "cc_sess_userid_idx" ON "cc_sess" ("userid"); - ------------------------------------------------------------------------------ --- cc_smemb ------------------------------------------------------------------------------ - -DROP TABLE "cc_smemb" CASCADE; - - -CREATE TABLE "cc_smemb" -( - "id" INTEGER NOT NULL, - "uid" INTEGER default 0 NOT NULL, - "gid" INTEGER default 0 NOT NULL, - "level" INTEGER default 0 NOT NULL, - "mid" INTEGER, - PRIMARY KEY ("id"), - CONSTRAINT "cc_smemb_id_idx" UNIQUE ("id") -); - -COMMENT ON TABLE "cc_smemb" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_subjs ------------------------------------------------------------------------------ - -DROP TABLE "cc_subjs" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_subjs" CASCADE; CREATE TABLE "cc_subjs" ( - "id" serial NOT NULL, - "login" VARCHAR(255) default '' NOT NULL, - "pass" VARCHAR(255) default '' NOT NULL, - "type" CHAR(1) default 'U' NOT NULL, - "first_name" VARCHAR(255) default '' NOT NULL, - "last_name" VARCHAR(255) default '' NOT NULL, - "lastlogin" TIMESTAMP, - "lastfail" TIMESTAMP, - "skype_contact" VARCHAR(255), - "jabber_contact" VARCHAR(255), - "email" VARCHAR(255), - "cell_phone" VARCHAR(255), - "login_attempts" INTEGER default 0, - PRIMARY KEY ("id"), - CONSTRAINT "cc_subjs_id_idx" UNIQUE ("id"), - CONSTRAINT "cc_subjs_login_idx" UNIQUE ("login") + "id" serial NOT NULL, + "login" VARCHAR(255) DEFAULT '' NOT NULL, + "pass" VARCHAR(255) DEFAULT '' NOT NULL, + "type" CHAR(1) DEFAULT 'U' NOT NULL, + "first_name" VARCHAR(255) DEFAULT '' NOT NULL, + "last_name" VARCHAR(255) DEFAULT '' NOT NULL, + "lastlogin" TIMESTAMP, + "lastfail" TIMESTAMP, + "skype_contact" VARCHAR, + "jabber_contact" VARCHAR, + "email" VARCHAR, + "cell_phone" VARCHAR, + "login_attempts" INTEGER DEFAULT 0, + PRIMARY KEY ("id"), + CONSTRAINT "cc_subjs_id_idx" UNIQUE ("id"), + CONSTRAINT "cc_subjs_login_idx" UNIQUE ("login") ); -COMMENT ON TABLE "cc_subjs" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_subjs_token ------------------------------------------------------------------------------ - -DROP TABLE "cc_subjs_token" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_subjs_token" CASCADE; CREATE TABLE "cc_subjs_token" ( - "id" serial NOT NULL, - "user_id" INTEGER NOT NULL, - "action" VARCHAR(255) NOT NULL, - "token" VARCHAR(40) NOT NULL, - "created" TIMESTAMP NOT NULL, - PRIMARY KEY ("id"), - CONSTRAINT "cc_subjs_token_idx" UNIQUE ("token") + "id" serial NOT NULL, + "user_id" INTEGER NOT NULL, + "action" VARCHAR(255) NOT NULL, + "token" VARCHAR(40) NOT NULL, + "created" TIMESTAMP NOT NULL, + PRIMARY KEY ("id"), + CONSTRAINT "cc_subjs_token_idx" UNIQUE ("token") ); -COMMENT ON TABLE "cc_subjs_token" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_country ------------------------------------------------------------------------------ - -DROP TABLE "cc_country" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_country" CASCADE; CREATE TABLE "cc_country" ( - "isocode" CHAR(3) NOT NULL, - "name" VARCHAR(255) NOT NULL, - PRIMARY KEY ("isocode") + "isocode" CHAR(3) NOT NULL, + "name" VARCHAR(255) NOT NULL, + PRIMARY KEY ("isocode") ); -COMMENT ON TABLE "cc_country" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_stream_setting ------------------------------------------------------------------------------ - -DROP TABLE "cc_stream_setting" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_stream_setting" CASCADE; CREATE TABLE "cc_stream_setting" ( - "keyname" VARCHAR(64) NOT NULL, - "value" VARCHAR(255), - "type" VARCHAR(16) NOT NULL, - PRIMARY KEY ("keyname") + "keyname" VARCHAR(64) NOT NULL, + "value" VARCHAR(255), + "type" VARCHAR(16) NOT NULL, + PRIMARY KEY ("keyname") ); -COMMENT ON TABLE "cc_stream_setting" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_login_attempts ------------------------------------------------------------------------------ - -DROP TABLE "cc_login_attempts" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_login_attempts" CASCADE; CREATE TABLE "cc_login_attempts" ( - "ip" VARCHAR(32) NOT NULL, - "attempts" INTEGER default 0, - PRIMARY KEY ("ip") + "ip" VARCHAR(32) NOT NULL, + "attempts" INTEGER DEFAULT 0, + PRIMARY KEY ("ip") ); -COMMENT ON TABLE "cc_login_attempts" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_service_register ------------------------------------------------------------------------------ - -DROP TABLE "cc_service_register" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_service_register" CASCADE; CREATE TABLE "cc_service_register" ( - "name" VARCHAR(32) NOT NULL, - "ip" VARCHAR(18) NOT NULL, - PRIMARY KEY ("name") + "name" VARCHAR(32) NOT NULL, + "ip" VARCHAR(18) NOT NULL, + PRIMARY KEY ("name") ); -COMMENT ON TABLE "cc_service_register" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_live_log ------------------------------------------------------------------------------ - -DROP TABLE "cc_live_log" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_live_log" CASCADE; CREATE TABLE "cc_live_log" ( - "id" serial NOT NULL, - "state" VARCHAR(32) NOT NULL, - "start_time" TIMESTAMP NOT NULL, - "end_time" TIMESTAMP, - PRIMARY KEY ("id") + "id" serial NOT NULL, + "state" VARCHAR(32) NOT NULL, + "start_time" TIMESTAMP NOT NULL, + "end_time" TIMESTAMP, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_live_log" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_webstream ------------------------------------------------------------------------------ - -DROP TABLE "cc_webstream" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_webstream" CASCADE; CREATE TABLE "cc_webstream" ( - "id" serial NOT NULL, - "name" VARCHAR(255) NOT NULL, - "description" VARCHAR(255) NOT NULL, - "url" VARCHAR(512) NOT NULL, - "length" interval default '00:00:00' NOT NULL, - "creator_id" INTEGER NOT NULL, - "mtime" TIMESTAMP(6) NOT NULL, - "utime" TIMESTAMP(6) NOT NULL, - "lptime" TIMESTAMP(6), - "mime" VARCHAR(255), - PRIMARY KEY ("id") + "id" serial NOT NULL, + "name" VARCHAR(255) NOT NULL, + "description" VARCHAR(255) NOT NULL, + "url" VARCHAR(512) NOT NULL, + "length" interval DEFAULT '00:00:00' NOT NULL, + "creator_id" INTEGER NOT NULL, + "mtime" TIMESTAMP(6) NOT NULL, + "utime" TIMESTAMP(6) NOT NULL, + "lptime" TIMESTAMP(6), + "mime" VARCHAR, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_webstream" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_webstream_metadata ------------------------------------------------------------------------------ - -DROP TABLE "cc_webstream_metadata" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_webstream_metadata" CASCADE; CREATE TABLE "cc_webstream_metadata" ( - "id" serial NOT NULL, - "instance_id" INTEGER NOT NULL, - "start_time" TIMESTAMP NOT NULL, - "liquidsoap_data" VARCHAR(1024) NOT NULL, - PRIMARY KEY ("id") + "id" serial NOT NULL, + "instance_id" INTEGER NOT NULL, + "start_time" TIMESTAMP NOT NULL, + "liquidsoap_data" VARCHAR(1024) NOT NULL, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_webstream_metadata" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_mount_name ------------------------------------------------------------------------------ - -DROP TABLE "cc_mount_name" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_mount_name" CASCADE; CREATE TABLE "cc_mount_name" ( - "id" serial NOT NULL, - "mount_name" VARCHAR(255) NOT NULL, - PRIMARY KEY ("id") + "id" serial NOT NULL, + "mount_name" VARCHAR NOT NULL, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_mount_name" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_timestamp ------------------------------------------------------------------------------ - -DROP TABLE "cc_timestamp" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_timestamp" CASCADE; CREATE TABLE "cc_timestamp" ( - "id" serial NOT NULL, - "timestamp" TIMESTAMP NOT NULL, - PRIMARY KEY ("id") + "id" serial NOT NULL, + "timestamp" TIMESTAMP NOT NULL, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_timestamp" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_listener_count ------------------------------------------------------------------------------ - -DROP TABLE "cc_listener_count" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_listener_count" CASCADE; CREATE TABLE "cc_listener_count" ( - "id" serial NOT NULL, - "timestamp_id" INTEGER NOT NULL, - "mount_name_id" INTEGER NOT NULL, - "listener_count" INTEGER NOT NULL, - PRIMARY KEY ("id") + "id" serial NOT NULL, + "timestamp_id" INTEGER NOT NULL, + "mount_name_id" INTEGER NOT NULL, + "listener_count" INTEGER NOT NULL, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_listener_count" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_locale ------------------------------------------------------------------------------ - -DROP TABLE "cc_locale" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_locale" CASCADE; CREATE TABLE "cc_locale" ( - "id" serial NOT NULL, - "locale_code" VARCHAR(16) NOT NULL, - "locale_lang" VARCHAR(128) NOT NULL, - PRIMARY KEY ("id") + "id" serial NOT NULL, + "locale_code" VARCHAR(16) NOT NULL, + "locale_lang" VARCHAR(128) NOT NULL, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_locale" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_playout_history ------------------------------------------------------------------------------ - -DROP TABLE "cc_playout_history" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_playout_history" CASCADE; CREATE TABLE "cc_playout_history" ( - "id" serial NOT NULL, - "file_id" INTEGER, - "starts" TIMESTAMP NOT NULL, - "ends" TIMESTAMP, - "instance_id" INTEGER, - PRIMARY KEY ("id") + "id" serial NOT NULL, + "file_id" INTEGER, + "starts" TIMESTAMP NOT NULL, + "ends" TIMESTAMP, + "instance_id" INTEGER, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_playout_history" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_playout_history_metadata ------------------------------------------------------------------------------ - -DROP TABLE "cc_playout_history_metadata" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_playout_history_metadata" CASCADE; CREATE TABLE "cc_playout_history_metadata" ( - "id" serial NOT NULL, - "history_id" INTEGER NOT NULL, - "key" VARCHAR(128) NOT NULL, - "value" VARCHAR(128) NOT NULL, - PRIMARY KEY ("id") + "id" serial NOT NULL, + "history_id" INTEGER NOT NULL, + "key" VARCHAR(128) NOT NULL, + "value" VARCHAR(128) NOT NULL, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_playout_history_metadata" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_playout_history_template ------------------------------------------------------------------------------ - -DROP TABLE "cc_playout_history_template" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_playout_history_template" CASCADE; CREATE TABLE "cc_playout_history_template" ( - "id" serial NOT NULL, - "name" VARCHAR(128) NOT NULL, - "type" VARCHAR(35) NOT NULL, - PRIMARY KEY ("id") + "id" serial NOT NULL, + "name" VARCHAR(128) NOT NULL, + "type" VARCHAR(35) NOT NULL, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_playout_history_template" IS ''; - - -SET search_path TO public; ------------------------------------------------------------------------------ +----------------------------------------------------------------------- -- cc_playout_history_template_field ------------------------------------------------------------------------------ - -DROP TABLE "cc_playout_history_template_field" CASCADE; +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "cc_playout_history_template_field" CASCADE; CREATE TABLE "cc_playout_history_template_field" ( - "id" serial NOT NULL, - "template_id" INTEGER NOT NULL, - "name" VARCHAR(128) NOT NULL, - "label" VARCHAR(128) NOT NULL, - "type" VARCHAR(128) NOT NULL, - "is_file_md" BOOLEAN default 'f' NOT NULL, - "position" INTEGER NOT NULL, - PRIMARY KEY ("id") + "id" serial NOT NULL, + "template_id" INTEGER NOT NULL, + "name" VARCHAR(128) NOT NULL, + "label" VARCHAR(128) NOT NULL, + "type" VARCHAR(128) NOT NULL, + "is_file_md" BOOLEAN DEFAULT 'f' NOT NULL, + "position" INTEGER NOT NULL, + PRIMARY KEY ("id") ); -COMMENT ON TABLE "cc_playout_history_template_field" IS ''; +----------------------------------------------------------------------- +-- media_item +----------------------------------------------------------------------- +DROP TABLE IF EXISTS "media_item" CASCADE; -SET search_path TO public; -ALTER TABLE "cc_files" ADD CONSTRAINT "cc_files_owner_fkey" FOREIGN KEY ("owner_id") REFERENCES "cc_subjs" ("id"); +CREATE TABLE "media_item" +( + "id" serial NOT NULL, + "name" VARCHAR(128) NOT NULL, + "owner_id" INTEGER, + "description" VARCHAR(512), + "last_played" TIMESTAMP(6), + "play_count" INTEGER DEFAULT 0, + "length" interval DEFAULT '00:00:00', + "created_at" TIMESTAMP, + "updated_at" TIMESTAMP, + "descendant_class" VARCHAR(100), + PRIMARY KEY ("id") +); -ALTER TABLE "cc_files" ADD CONSTRAINT "cc_files_editedby_fkey" FOREIGN KEY ("editedby") REFERENCES "cc_subjs" ("id"); +----------------------------------------------------------------------- +-- audio_file +----------------------------------------------------------------------- -ALTER TABLE "cc_files" ADD CONSTRAINT "cc_music_dirs_folder_fkey" FOREIGN KEY ("directory") REFERENCES "cc_music_dirs" ("id"); +DROP TABLE IF EXISTS "audio_file" CASCADE; -ALTER TABLE "cc_perms" ADD CONSTRAINT "cc_perms_subj_fkey" FOREIGN KEY ("subj") REFERENCES "cc_subjs" ("id") ON DELETE CASCADE; +CREATE TABLE "audio_file" +( + "mime" VARCHAR, + "directory" INTEGER, + "filepath" TEXT DEFAULT '', + "md5" CHAR(32), + "track_title" VARCHAR(512), + "artist_name" VARCHAR(512), + "bit_rate" INTEGER, + "sample_rate" INTEGER, + "album_title" VARCHAR(512), + "genre" VARCHAR(64), + "comments" TEXT, + "year" VARCHAR(16), + "track_number" INTEGER, + "channels" INTEGER, + "url" VARCHAR(1024), + "bpm" INTEGER, + "encoded_by" VARCHAR(255), + "mood" VARCHAR(64), + "label" VARCHAR(512), + "composer" VARCHAR(512), + "copyright" VARCHAR(512), + "isrc_number" VARCHAR(512), + "info_url" VARCHAR(512), + "language" VARCHAR(512), + "replay_gain" NUMERIC, + "cuein" interval DEFAULT '00:00:00', + "cueout" interval DEFAULT '00:00:00', + "silan_check" BOOLEAN DEFAULT 'f', + "file_exists" BOOLEAN DEFAULT 't', + "hidden" BOOLEAN DEFAULT 'f', + "is_scheduled" BOOLEAN DEFAULT 'f', + "is_playlist" BOOLEAN DEFAULT 'f', + "id" INTEGER NOT NULL, + "name" VARCHAR(128) NOT NULL, + "owner_id" INTEGER, + "description" VARCHAR(512), + "last_played" TIMESTAMP(6), + "play_count" INTEGER DEFAULT 0, + "length" interval DEFAULT '00:00:00', + "created_at" TIMESTAMP, + "updated_at" TIMESTAMP, + PRIMARY KEY ("id") +); -ALTER TABLE "cc_show_instances" ADD CONSTRAINT "cc_show_fkey" FOREIGN KEY ("show_id") REFERENCES "cc_show" ("id") ON DELETE CASCADE; +CREATE INDEX "audio_file_md5_idx" ON "audio_file" ("md5"); -ALTER TABLE "cc_show_instances" ADD CONSTRAINT "cc_original_show_instance_fkey" FOREIGN KEY ("instance_id") REFERENCES "cc_show_instances" ("id") ON DELETE CASCADE; +----------------------------------------------------------------------- +-- webstream +----------------------------------------------------------------------- -ALTER TABLE "cc_show_instances" ADD CONSTRAINT "cc_recorded_file_fkey" FOREIGN KEY ("file_id") REFERENCES "cc_files" ("id") ON DELETE CASCADE; +DROP TABLE IF EXISTS "webstream" CASCADE; -ALTER TABLE "cc_show_days" ADD CONSTRAINT "cc_show_fkey" FOREIGN KEY ("show_id") REFERENCES "cc_show" ("id") ON DELETE CASCADE; +CREATE TABLE "webstream" +( + "mime" VARCHAR, + "url" VARCHAR(512) NOT NULL, + "id" INTEGER NOT NULL, + "name" VARCHAR(128) NOT NULL, + "owner_id" INTEGER, + "description" VARCHAR(512), + "last_played" TIMESTAMP(6), + "play_count" INTEGER DEFAULT 0, + "length" interval DEFAULT '00:00:00', + "created_at" TIMESTAMP, + "updated_at" TIMESTAMP, + PRIMARY KEY ("id") +); -ALTER TABLE "cc_show_rebroadcast" ADD CONSTRAINT "cc_show_fkey" FOREIGN KEY ("show_id") REFERENCES "cc_show" ("id") ON DELETE CASCADE; +----------------------------------------------------------------------- +-- playlist +----------------------------------------------------------------------- -ALTER TABLE "cc_show_hosts" ADD CONSTRAINT "cc_perm_show_fkey" FOREIGN KEY ("show_id") REFERENCES "cc_show" ("id") ON DELETE CASCADE; +DROP TABLE IF EXISTS "playlist" CASCADE; -ALTER TABLE "cc_show_hosts" ADD CONSTRAINT "cc_perm_host_fkey" FOREIGN KEY ("subjs_id") REFERENCES "cc_subjs" ("id") ON DELETE CASCADE; +CREATE TABLE "playlist" +( + "id" INTEGER NOT NULL, + "name" VARCHAR(128) NOT NULL, + "owner_id" INTEGER, + "description" VARCHAR(512), + "last_played" TIMESTAMP(6), + "play_count" INTEGER DEFAULT 0, + "length" interval DEFAULT '00:00:00', + "created_at" TIMESTAMP, + "updated_at" TIMESTAMP, + "descendant_class" VARCHAR(100), + PRIMARY KEY ("id") +); -ALTER TABLE "cc_playlist" ADD CONSTRAINT "cc_playlist_createdby_fkey" FOREIGN KEY ("creator_id") REFERENCES "cc_subjs" ("id") ON DELETE CASCADE; +----------------------------------------------------------------------- +-- block +----------------------------------------------------------------------- -ALTER TABLE "cc_playlistcontents" ADD CONSTRAINT "cc_playlistcontents_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "cc_files" ("id") ON DELETE CASCADE; +DROP TABLE IF EXISTS "block" CASCADE; -ALTER TABLE "cc_playlistcontents" ADD CONSTRAINT "cc_playlistcontents_block_id_fkey" FOREIGN KEY ("block_id") REFERENCES "cc_block" ("id") ON DELETE CASCADE; +CREATE TABLE "block" +( + "type" VARCHAR(7) DEFAULT 'static', + "id" INTEGER NOT NULL, + "name" VARCHAR(128) NOT NULL, + "owner_id" INTEGER, + "description" VARCHAR(512), + "last_played" TIMESTAMP(6), + "play_count" INTEGER DEFAULT 0, + "length" interval DEFAULT '00:00:00', + "created_at" TIMESTAMP, + "updated_at" TIMESTAMP, + PRIMARY KEY ("id") +); -ALTER TABLE "cc_playlistcontents" ADD CONSTRAINT "cc_playlistcontents_playlist_id_fkey" FOREIGN KEY ("playlist_id") REFERENCES "cc_playlist" ("id") ON DELETE CASCADE; +----------------------------------------------------------------------- +-- media_contents +----------------------------------------------------------------------- -ALTER TABLE "cc_block" ADD CONSTRAINT "cc_block_createdby_fkey" FOREIGN KEY ("creator_id") REFERENCES "cc_subjs" ("id") ON DELETE CASCADE; +DROP TABLE IF EXISTS "media_contents" CASCADE; -ALTER TABLE "cc_blockcontents" ADD CONSTRAINT "cc_blockcontents_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "cc_files" ("id") ON DELETE CASCADE; +CREATE TABLE "media_contents" +( + "id" serial NOT NULL, + "media_id" INTEGER, + "position" INTEGER, + "trackoffset" FLOAT DEFAULT 0 NOT NULL, + "cliplength" interval DEFAULT '00:00:00', + "cuein" interval DEFAULT '00:00:00', + "cueout" interval DEFAULT '00:00:00', + "fadein" TIME DEFAULT '00:00:00', + "fadeout" TIME DEFAULT '00:00:00', + PRIMARY KEY ("id") +); -ALTER TABLE "cc_blockcontents" ADD CONSTRAINT "cc_blockcontents_block_id_fkey" FOREIGN KEY ("block_id") REFERENCES "cc_block" ("id") ON DELETE CASCADE; +ALTER TABLE "cc_files" ADD CONSTRAINT "cc_files_owner_fkey" + FOREIGN KEY ("owner_id") + REFERENCES "cc_subjs" ("id"); -ALTER TABLE "cc_blockcriteria" ADD CONSTRAINT "cc_blockcontents_block_id_fkey" FOREIGN KEY ("block_id") REFERENCES "cc_block" ("id") ON DELETE CASCADE; +ALTER TABLE "cc_files" ADD CONSTRAINT "cc_files_editedby_fkey" + FOREIGN KEY ("editedby") + REFERENCES "cc_subjs" ("id"); -ALTER TABLE "cc_pref" ADD CONSTRAINT "cc_pref_subjid_fkey" FOREIGN KEY ("subjid") REFERENCES "cc_subjs" ("id") ON DELETE CASCADE; +ALTER TABLE "cc_files" ADD CONSTRAINT "cc_music_dirs_folder_fkey" + FOREIGN KEY ("directory") + REFERENCES "cc_music_dirs" ("id"); -ALTER TABLE "cc_schedule" ADD CONSTRAINT "cc_show_inst_fkey" FOREIGN KEY ("instance_id") REFERENCES "cc_show_instances" ("id") ON DELETE CASCADE; +ALTER TABLE "cc_show_instances" ADD CONSTRAINT "cc_show_fkey" + FOREIGN KEY ("show_id") + REFERENCES "cc_show" ("id") + ON DELETE CASCADE; -ALTER TABLE "cc_schedule" ADD CONSTRAINT "cc_show_file_fkey" FOREIGN KEY ("file_id") REFERENCES "cc_files" ("id") ON DELETE CASCADE; +ALTER TABLE "cc_show_instances" ADD CONSTRAINT "cc_original_show_instance_fkey" + FOREIGN KEY ("instance_id") + REFERENCES "cc_show_instances" ("id") + ON DELETE CASCADE; -ALTER TABLE "cc_schedule" ADD CONSTRAINT "cc_show_stream_fkey" FOREIGN KEY ("stream_id") REFERENCES "cc_webstream" ("id") ON DELETE CASCADE; +ALTER TABLE "cc_show_instances" ADD CONSTRAINT "cc_recorded_file_fkey" + FOREIGN KEY ("file_id") + REFERENCES "cc_files" ("id") + ON DELETE CASCADE; -ALTER TABLE "cc_sess" ADD CONSTRAINT "cc_sess_userid_fkey" FOREIGN KEY ("userid") REFERENCES "cc_subjs" ("id") ON DELETE CASCADE; +ALTER TABLE "cc_show_days" ADD CONSTRAINT "cc_show_fkey" + FOREIGN KEY ("show_id") + REFERENCES "cc_show" ("id") + ON DELETE CASCADE; -ALTER TABLE "cc_subjs_token" ADD CONSTRAINT "cc_subjs_token_userid_fkey" FOREIGN KEY ("user_id") REFERENCES "cc_subjs" ("id") ON DELETE CASCADE; +ALTER TABLE "cc_show_rebroadcast" ADD CONSTRAINT "cc_show_fkey" + FOREIGN KEY ("show_id") + REFERENCES "cc_show" ("id") + ON DELETE CASCADE; -ALTER TABLE "cc_webstream_metadata" ADD CONSTRAINT "cc_schedule_inst_fkey" FOREIGN KEY ("instance_id") REFERENCES "cc_schedule" ("id") ON DELETE CASCADE; +ALTER TABLE "cc_show_hosts" ADD CONSTRAINT "cc_perm_show_fkey" + FOREIGN KEY ("show_id") + REFERENCES "cc_show" ("id") + ON DELETE CASCADE; -ALTER TABLE "cc_listener_count" ADD CONSTRAINT "cc_timestamp_inst_fkey" FOREIGN KEY ("timestamp_id") REFERENCES "cc_timestamp" ("id") ON DELETE CASCADE; +ALTER TABLE "cc_show_hosts" ADD CONSTRAINT "cc_perm_host_fkey" + FOREIGN KEY ("subjs_id") + REFERENCES "cc_subjs" ("id") + ON DELETE CASCADE; -ALTER TABLE "cc_listener_count" ADD CONSTRAINT "cc_mount_name_inst_fkey" FOREIGN KEY ("mount_name_id") REFERENCES "cc_mount_name" ("id") ON DELETE CASCADE; +ALTER TABLE "cc_playlist" ADD CONSTRAINT "cc_playlist_createdby_fkey" + FOREIGN KEY ("creator_id") + REFERENCES "cc_subjs" ("id") + ON DELETE CASCADE; -ALTER TABLE "cc_playout_history" ADD CONSTRAINT "cc_playout_history_file_tag_fkey" FOREIGN KEY ("file_id") REFERENCES "cc_files" ("id") ON DELETE CASCADE; +ALTER TABLE "cc_playlistcontents" ADD CONSTRAINT "cc_playlistcontents_file_id_fkey" + FOREIGN KEY ("file_id") + REFERENCES "cc_files" ("id") + ON DELETE CASCADE; -ALTER TABLE "cc_playout_history" ADD CONSTRAINT "cc_his_item_inst_fkey" FOREIGN KEY ("instance_id") REFERENCES "cc_show_instances" ("id") ON DELETE SET NULL; +ALTER TABLE "cc_playlistcontents" ADD CONSTRAINT "cc_playlistcontents_block_id_fkey" + FOREIGN KEY ("block_id") + REFERENCES "cc_block" ("id") + ON DELETE CASCADE; -ALTER TABLE "cc_playout_history_metadata" ADD CONSTRAINT "cc_playout_history_metadata_entry_fkey" FOREIGN KEY ("history_id") REFERENCES "cc_playout_history" ("id") ON DELETE CASCADE; +ALTER TABLE "cc_playlistcontents" ADD CONSTRAINT "cc_playlistcontents_playlist_id_fkey" + FOREIGN KEY ("playlist_id") + REFERENCES "cc_playlist" ("id") + ON DELETE CASCADE; -ALTER TABLE "cc_playout_history_template_field" ADD CONSTRAINT "cc_playout_history_template_template_fkey" FOREIGN KEY ("template_id") REFERENCES "cc_playout_history_template" ("id") ON DELETE CASCADE; +ALTER TABLE "cc_block" ADD CONSTRAINT "cc_block_createdby_fkey" + FOREIGN KEY ("creator_id") + REFERENCES "cc_subjs" ("id") + ON DELETE CASCADE; + +ALTER TABLE "cc_blockcontents" ADD CONSTRAINT "cc_blockcontents_file_id_fkey" + FOREIGN KEY ("file_id") + REFERENCES "cc_files" ("id") + ON DELETE CASCADE; + +ALTER TABLE "cc_blockcontents" ADD CONSTRAINT "cc_blockcontents_block_id_fkey" + FOREIGN KEY ("block_id") + REFERENCES "cc_block" ("id") + ON DELETE CASCADE; + +ALTER TABLE "cc_blockcriteria" ADD CONSTRAINT "cc_blockcontents_block_id_fkey" + FOREIGN KEY ("block_id") + REFERENCES "cc_block" ("id") + ON DELETE CASCADE; + +ALTER TABLE "cc_pref" ADD CONSTRAINT "cc_pref_subjid_fkey" + FOREIGN KEY ("subjid") + REFERENCES "cc_subjs" ("id") + ON DELETE CASCADE; + +ALTER TABLE "cc_schedule" ADD CONSTRAINT "cc_show_inst_fkey" + FOREIGN KEY ("instance_id") + REFERENCES "cc_show_instances" ("id") + ON DELETE CASCADE; + +ALTER TABLE "cc_schedule" ADD CONSTRAINT "cc_show_file_fkey" + FOREIGN KEY ("file_id") + REFERENCES "cc_files" ("id") + ON DELETE CASCADE; + +ALTER TABLE "cc_schedule" ADD CONSTRAINT "cc_show_stream_fkey" + FOREIGN KEY ("stream_id") + REFERENCES "cc_webstream" ("id") + ON DELETE CASCADE; + +ALTER TABLE "cc_subjs_token" ADD CONSTRAINT "cc_subjs_token_userid_fkey" + FOREIGN KEY ("user_id") + REFERENCES "cc_subjs" ("id") + ON DELETE CASCADE; + +ALTER TABLE "cc_webstream_metadata" ADD CONSTRAINT "cc_schedule_inst_fkey" + FOREIGN KEY ("instance_id") + REFERENCES "cc_schedule" ("id") + ON DELETE CASCADE; + +ALTER TABLE "cc_listener_count" ADD CONSTRAINT "cc_timestamp_inst_fkey" + FOREIGN KEY ("timestamp_id") + REFERENCES "cc_timestamp" ("id") + ON DELETE CASCADE; + +ALTER TABLE "cc_listener_count" ADD CONSTRAINT "cc_mount_name_inst_fkey" + FOREIGN KEY ("mount_name_id") + REFERENCES "cc_mount_name" ("id") + ON DELETE CASCADE; + +ALTER TABLE "cc_playout_history" ADD CONSTRAINT "cc_playout_history_file_tag_fkey" + FOREIGN KEY ("file_id") + REFERENCES "cc_files" ("id") + ON DELETE CASCADE; + +ALTER TABLE "cc_playout_history" ADD CONSTRAINT "cc_his_item_inst_fkey" + FOREIGN KEY ("instance_id") + REFERENCES "cc_show_instances" ("id") + ON DELETE SET NULL; + +ALTER TABLE "cc_playout_history_metadata" ADD CONSTRAINT "cc_playout_history_metadata_entry_fkey" + FOREIGN KEY ("history_id") + REFERENCES "cc_playout_history" ("id") + ON DELETE CASCADE; + +ALTER TABLE "cc_playout_history_template_field" ADD CONSTRAINT "cc_playout_history_template_template_fkey" + FOREIGN KEY ("template_id") + REFERENCES "cc_playout_history_template" ("id") + ON DELETE CASCADE; + +ALTER TABLE "media_item" ADD CONSTRAINT "media_item_owner_fkey" + FOREIGN KEY ("owner_id") + REFERENCES "cc_subjs" ("id"); + +ALTER TABLE "audio_file" ADD CONSTRAINT "audio_file_music_dir_fkey" + FOREIGN KEY ("directory") + REFERENCES "cc_music_dirs" ("id"); + +ALTER TABLE "audio_file" ADD CONSTRAINT "audio_file_FK_2" + FOREIGN KEY ("id") + REFERENCES "media_item" ("id") + ON DELETE CASCADE; + +ALTER TABLE "audio_file" ADD CONSTRAINT "audio_file_FK_3" + FOREIGN KEY ("owner_id") + REFERENCES "cc_subjs" ("id"); + +ALTER TABLE "webstream" ADD CONSTRAINT "webstream_FK_1" + FOREIGN KEY ("id") + REFERENCES "media_item" ("id") + ON DELETE CASCADE; + +ALTER TABLE "webstream" ADD CONSTRAINT "webstream_FK_2" + FOREIGN KEY ("owner_id") + REFERENCES "cc_subjs" ("id"); + +ALTER TABLE "playlist" ADD CONSTRAINT "playlist_FK_1" + FOREIGN KEY ("id") + REFERENCES "media_item" ("id") + ON DELETE CASCADE; + +ALTER TABLE "playlist" ADD CONSTRAINT "playlist_FK_2" + FOREIGN KEY ("owner_id") + REFERENCES "cc_subjs" ("id"); + +ALTER TABLE "block" ADD CONSTRAINT "block_FK_1" + FOREIGN KEY ("id") + REFERENCES "playlist" ("id") + ON DELETE CASCADE; + +ALTER TABLE "block" ADD CONSTRAINT "block_FK_2" + FOREIGN KEY ("id") + REFERENCES "media_item" ("id") + ON DELETE CASCADE; + +ALTER TABLE "block" ADD CONSTRAINT "block_FK_3" + FOREIGN KEY ("owner_id") + REFERENCES "cc_subjs" ("id"); + +ALTER TABLE "media_contents" ADD CONSTRAINT "media_item_contents_fkey" + FOREIGN KEY ("media_id") + REFERENCES "media_item" ("id") + ON DELETE CASCADE; diff --git a/airtime_mvc/library/propel/CHANGELOG b/airtime_mvc/library/propel/CHANGELOG index fe4ff5fde..0c19ba531 100644 --- a/airtime_mvc/library/propel/CHANGELOG +++ b/airtime_mvc/library/propel/CHANGELOG @@ -1,107 +1,768 @@ -= Changelog Of The Propel 1.5 Branch = +# Changelog Of The Propel 1.x Branch # -== 2010-06-17: Version 1.5.2 == +## 2013-10-21: Version 1.7.0 ## - * [1810] Changed default table type keyword to ENGINE for MySQL (closes #969) - * [1809] Added a way to read virtual columns starting with a lowercase character (closes #993) - * [1808] Added connection object to the FK getter (closes #1018) - * [1807] Fixed namespace issue with `soft_delete` behavior (closes #1015) - * [1806] Fixed issue with instance pooling and soft_delete behavior (closes #1016) - * [1805] Added namespace declaration to model class interface (closes #1014) - * [1804] Improved generated class code when using namespaces (refs #683) - * [1803] Documented namespace.autoPackage build property (refs #1005) - * [1802] Added support for package autosetting based on namespace attribute (refs #1005) - * [1801] Fixed related instance pooling clear in case of an emulated on delete cascade / set null (refs #1012) - * [1800] Fixed onDelete cascade and setnull for self-referencing foreign keys (closes #1012) - * [1799] Fixed `ModelCriteria::find()` throws `Exception` instead of `PropelException` - * [1798] Fixed hard-to-debug unit test exception message - * [1797] Fixed cascade deletion emulation when `Criteria` is modified by `doSelect()` (closes #1008) - * [1796] Added `ModelCriteria::findOneOrCreate()` (closes #1009) - * [1795] Fixed `delete()` called in iterator breaks on demand formatter (closes #1006) - * [1794] Fixed double iteration on Propel collection (closes #1004) (patch from jeremyp) - * [1793] Documented namespaces (refs #683) - * [1792] Added support for namespaces in many-to-many relationships (refs #683) - * [1791] Added support for namespaces in single table inheritance (refs #683) - * [1790] Added mention of a common error code in runtime settings documentation - * [1789] Documented the simple templating system (refs #1002) - * [1788] Allowed namespace tests to run alongside normal tests (refs #683) - * [1787] Fixed `PropelObjectCollection::toArray()` when the collection is empty (closes #1001) - * [1786] Fixed runtime doc typo - * [1785] Refactored the `aggregate_column` behavior to take advantage of the buildtime simple templating engine (refs #1002, #995) - * [1784] Added simple templating engine for behaviors (refs #1002) - * [1783] Added a !HowTo on writing behaviors (should have been published in the blog, but Posterous is having troubles with code samples) - * [1782] Improved namespace support in generated `TableMap` classes (refs #683) - * [1781] Introducing Model Namespaces (PHP 5.3 only) (WIP) (refs #683) - * [1780] Fixed generated `filterByXXX()` for string columns when using custom comparison - * [1779] Added `aggregate_column` behavior (refs #995) - * [1778] Refactored `ForeignKey` class in generator - * [1777] [doc] Fixed typo in CRUD chapter - * [1776] Fixed generated relation names for tables with symmetrical foreign keys (closes #968) - * [1775] Fixed generated relation names for tables with more than one self-referencing foreign key (closes #972) - * [1774] Fixed copy of foreign keys with hardcoded refPhpName in concrete inheritance behavior (closes #988) - * [1773] Changing runtime autoload strategy (closes #974): - * Using absolute path in core autoloading - * introducing `PropelAutoloader` for models - * removing the need for include path change in installation docs - * [1772] Added failed SQL query to `BasePeer` exception messages (closes #979) - * [1771] Documented the schema autosuggest feature in supported IDEs - * [1770] Expanded the schema XSD annotations for easier schema autocompletion - * [1769] showcasing link to XSD file in schema to allow autocompletion on NetBeans - * [1768] Fixed typos in `ModelCriteria` doc (closes #978) (patch from Frosty) - * [1767] Fixed typo in install doc (closes #576) - * [1766] Fixed schema DTD does not validate schemas without behaviors (closes #973) - * [1765] Added the ability to comment the generated SQL query from a Criteria (closes #970) - * [1764] Fixed limitation in schema size when transformation or external schema is included (closes #971) - * [1763] Fixed limitation in schema size when no transformation nor external schema is included (closes #971) +067dad2 reworked approach for better handling of executed queries in DebugPDO +2bb6d2d fix DebugPDOStatement for usage with execute +041af74 Added unit test for modified table case +c15c239 Added type-hinting on doAdd crossFK generated functions +ceee8a9 fixed a getter function without '$con' +f30aa35 Fixed diff task combined with skipSql +57cde74 [README] Add packagist badge to show project popularity +9087851 Fix namespace support +83841e5 Get TableMap class name from Peer class +3b0b2cc Added test for version column case insensitivity +46b5a9c Added case-insensitive check for the version column +b9a8ad7 Fix small error in the QueryBuilder Doc for TemporalType +3ac9f0c Update SluggableBehavior.php +a2f4f92 unit test +2355979 slugable behavior - scope column overrides $getter +38742c4 Support for regexp on different platforms +148aeb2 [VersionableBehavior] Fix exception message got toVersion +a5226c9 fix bug when adding previously removed relations +115f6de add missing import for nested set +252da4c test added +52d8a76 fix for CASE expression in query with offset in ms sql +2b2c4da code style fix +f20f99b PropelObjectCollection::getIdenticalObject optimalization +0cfa3db Fix accidental type conversion in sluggable behavior. +e7ecc97 added Unit Test +c1fc85d Fixed issue with migrations and decimal or numeric table size +a6c3218 fix scheduledForDeletion for CrossFK w/ refPhpName +70c18d2 Undefined index fix +2193ba4 Fixed MigrationManager to use queries and charset settings +d37b4cd Fixed object builder toArray withColumn +7e173bc Fixed test assertion +20f66c0 Minor spelling corrections +2e50ea8 Failing testcase in toArray withColumn +4a5eba2 Fixed Sluggable behavior combining with symfony_i18n +c4b61cc Bugfix for PHP < 5.3.0 +f6031de Foreign Keys default behaviors managment (resolves issue #390) +130429f Fix some issues. Closes #684 +193f736 Fix a couple of mistakes +171211c Expected and actual values where in wrong order +52b072b Improved SQLParser performance +9687fe5 Tests for multiple character delimiters support +cfa8222 Added multiple character delimiters support +0272ba3 clone object in hashCode() function so the original object is not changed when calling hashCode provided test for the hasCode() function +3ea2f2d Issue #677: Set back reference when calling add Provided tests for testing if all references are set for crossreferences before saving +4495b9f fixed transaction leak when exception different from PropelException is thrown +3bf0689 fix deleting related objects +8fe41e5 Added multiple scope support in Sortable behavior. +8f75133 Fixed #651. Stupid typo. +5b7878a clean +f72c534 add an excluded_parent_behavior to concret_inheritance behavior +2606549 only generate findOneBySlug if required +cb913c3 Add test for ModelCriteria to prove it support IN operator in JOIN conditions +80179d6 Additional assertion to ensure binding params doesn't change actual result +a6a20bd Use Criterion always when possible Using Criterion allows to bind values in statements. You can't use Criterion only for strings because in this method you can't distinguish if it is a table name or value provided by user. +0ad1698 Add to Criteria support for IN and NOT IN operators in JOIN conditions e.g. JOIN x ON (x.id = y.x_id AND y.foo IN (42, 51)) +61f9368 removed duplicated assertion, refs #653 +54362ae fixed urls to trac tickets propel.phpdb.org/trac/ticket -> trac.propelorm.org/ticket +75a15f1 fix generated CS of SoftDelete in forceDelete() +27ea1df make ModelCriteria::create() changes more backward compatible +cd22e0b reduced ModelCriteria::clear() tests +937ff8b fix timing issues in TimestampableBehaviorTest +11c1841 add lcfirst function stub +aef6049 full list of changes below: +fbc1b3a fix some introspections, coding style +0379f34 add one-to-one handling to VersionableBehavior +5b3ad51 Update .travis.yml +38ec08d Revert bad CS fix (alternative CS behavior) +93c6a0f Fixes JOIN duplication issue when default join type equals given join type (issue #373) +dcace44 Bugfix for join equality when default join type is used +86760fe Make `testQuotingIdentifiers()` abstract and allow each `DBTest` to implement it +16926a5 Remove unnecessary .'' +fa98c50 Remove not valid anymore comment +07da31f Support for quoting aliases +3a91f81 add tests for issue #621 +5bab81d Update generator/lib/reverse/mysql/MysqlSchemaParser.php +577df2d Don't null size field when scale specified +644931d Fixed typos +c116afc add test for issue #622 +423f354 Merge branch 'master' of git://github.com/ciromattia/Propel into ciromattia-master +c1047df Merge branch '1.6' +5f503ea Correctly add map namespace when $phpName has no backslash (e.g. namespaces are not used) - fixes #614 +82aa016 allow withColumn() and select() again. fixes #608. +9798365 added failing testcase for issue #608 +622b9fe expect PropelException when cloning PropelOnDemandCollection's +0890783 separate tests for __clone() using objects and scalars +efb83ee fixed __clone() for PropelCollections containing scalar values +e1dbfa9 added tests for PropelCollection new __clone() magic method +f268cb0 removed unused properties from OnDemandCollection which were never set. +366e1df fixed test +48ebeb9 order by alias is not supported in mssql. fixes #596 by @chuck-jove +c85111f added test provided for issue 596 +288e91d Fixed #603 +866378d Removed the `extend ` in PHP5PeerBuilder since it's a bug. -== 2010-05-10: Version 1.5.1 == +## 2013-03-31: Version 1.6.9 ## - * [1759] Moved ModelWith runtime class to formatter directory - * [1758] Fixed warning with new StringReader - * [1757] Reduced console logging when building an up-to-date schema - * [1756] Parsing schemas as strings instead of files (closes #967) - * [1755] Reverting r1548 to allow inclusion of external schemas (refs #967) - * [1754] Documented custom defaultJoin type (refs #870) (closes #936) - * [1749] fix Criteria::addCond() example and php-doc (closes #964) - * [1748] fix Join::addCondition() php-doc (closes #963) - * [1747] Add getJoin() method to ModelCriteria (closes #961) - * [1745] Fixed auto_add_pk behavior when using separate schemas (closes #956) - * [1743] Refactored ModelCriteria::count() to allow query cache on counts - * [1742] Fixed propel-gen executable on windows (closes #942) - * [1741] disabled query cloning by default, you can enable it on a per query basis using keepQuery() (refs #953) - * [1740] Fixed shallow Criteria cloning (refs #953) - * [1739] Fixed overriding primary key in a new object (closes #960) - * [1738] Fixed generated joinXXX() methods used in secondary Criteria (closes #958) - * [1737] Fixed array hydration (refs #954, #959) - * [1736] Added unit test to demonstrate Array Hydration regression (refs #959) - * [1735] Fixed typo in MySQL DDL builder (closes #957) - * [1734] fixed doc typos (patch from Frosty) (closes #955) - * [1733] Refactored hydration schema - * removed circular dependency between Criteria and Formatter (refs #891) - * formatters now copy the necessary hydration data from the ModelCriteria - * Should improve memory handling in large resultsets - * removed PropelFormatter::setCriteria() and checkCriteria (refs #892) - * [1732] refactored on demand hydration (refs #954), removed ModelJoin storage in ModelWith - * [1731] Refactored Joined Array hydration (refs #954) - * [1730] Changed Propel::enableInstancePooling() return value - * [1729] Added a exception to explicit the limits of one-to-many joined hydration - * [1728] Refactored joined object hydration - * Now deals correctly with any join chain (refs #954) - * Faster for large resultsets and long join chains - * [1727] refactored BasePeer::doDelete() to handle table aliases and perform better (closes #949) - * [1726] Small Criteria optimization - * [1725] Fixed ModelCriteria::delete() fails when using true table alias (closes #949) - * [1724] Allowed Merging of Criteria objects to combien conditions with an OR (closes #951) - * [1723] Added the ability to reindex a collection (closes #851) - * [1722] Gave a public way to remove an alias (useful when merging Criterias) - * [1721] Added ModelCriteria::postUpdate() and ModelCriteria::postDelete() hooks (closes #945) - * [1720] Fixed issue with instance pooling and composite fkeys in peer classes (closes #924) - * [1719] Fixed E_STRICT warning in concrete table inheritance (closes #910) - * [1718] Added unit tests for PropelObjectCollection::toKeyValue(), and made it just a little smarter (closes #943) - * [1717] Fixed typo in Relationships doc closes #941) - * [1716] Fixed reverse task and validators (closes #928) - * [1715] Fixed phpDoc for Criteria::getCriterion() (closes #929) - * [1714] Fixed regression in orderBy() used in conjunction with ignoreCase (closes #946) - * [1712] Fixed concrete table inheritance with more than one level (closes #922) - * [1711] Fixed filterByXXX() when passed an explicit Criteria::EQUAL (closes #944) - * [1710] Fixed references to 1.4 pages in documentaton (closes #937) \ No newline at end of file +e9313d0 [Sluggable] fix issue with slug ending with 0XYZ +81815e6 [Sluggable] add test to prove issue with slug ending with 0XYZ +46ff6a2 Split the `testForeignKey` into several methods. Added some phpdoc so its cleaer +409850e Fixed #617. Proved the issue #617 and fixed it. + +## 2013-02-14: Version 1.6.8 ## + +01ea918 Fixed #601. +faaeec8 break on first validation error,... +53a270d conditionally check for the propel runtime version. This is required when runtime.xml based tasks will be run. +7006999 Pulled out assignment typo to clean up PR +2f751ce addHaving()'s parameters are the same as those of getCriterionForCondition +b2458cb Docblock fixes and one assignment typo +57bf351 Changed the signature of generated "getOMClass()" functions to a more generic form to be compatible with Concrete Inheritance Behaviour (as of: https://github.com/propelorm/Propel/issues/563#issuecomment-13036863). +85a92dd updated phing dependency to latest minor release, using tilde operator +799b71d MySQL throws an 'Incorrect table definition; there can be only one auto column and it must be defined as a key' if the primary key consists of multiple columns and if the first is not the autoIncrement one. So this push the autoIncrement column to the first position if its not already. +b9440ea In the Task `PropelSQLDiffTask` the `disableIdentifierQuoting` build property was not handled. +c09ef55 `setNegativeScope` does not return anything. +39ad25d Coding style, comments adjusted and removed unused variable. +4cbf8a8 Removed limitation where we can only move branches inside the same scope. +3a66896 fixed version constants to make unit tests pass +47392c1 added warning when build-time propel version and runtime-propel version do not match, refs propelorm/Propel#577 +d8c5c6d Removed tabs. +d6c11f1 Added `-` to the xsd simple type `file` comment. +f50d864 Fixed #566, #568. Since "package" is actually a file path, it should be able to contain dashes. Changed the xsd database>package data type to `file` and adapted simple type `file` to allow them to contain dashes. Added a test for it. +4868ae0 fix set descendant class +d3a27a8 Adjusted coding style and fixed a innodb vs. myIsam bug in nested set test resulting out of the new distinction between them. +23176c9 Fixed invalid regex for php_class data type +3a3a2d8 Removed constraint/foreign key statements if the table is MyISAM. +b94e4d8 Removed the enforced first non-backslash char in php_class data type. +070b042 Very small performance increment by breaking the loop if we found the index to be removed. +a3cb1b6 Fixed invalid generation of INDEX statements in Table::addExtraIndices() [only MySQL]. +bea81dd Fix 327 for incorrect filterById implementation. +f396437 Avoid escaping single quote in a string +6ffe886 fix serialization for all temporal type +a39c42c fixed key serialization +f159d77 fix test for dot generator +4538890 fix dot syntax generated by graphviz target +97bd6ab Fixes #345 +1d69cab Allow the QuickGenerator to use another Platform +73134d5 Change fallback order in getTableByPhpName(). Fixes #385 +62f0f79 Fix initialization of internal iterator for getRelCol. fix #460 +fb20853 teaching propel to clear UP and DOWN when calling clearAllReferences(true) we have infinite recursion prevention already covered also we add an optional param to clearInstancePool. if passes as true it will clearAllReferences(true) on every instance before clearing it. +075568c fix for many-to-many recursive save +28bd1f6 Fix cast in setters. Should fix #283 +ee5dd4f Fix inconsistency for BIGINT. Fixes #459 +b01565b Use model prefix in QueryInheritanceBuilder, fixes #542 +d298403 fix variable name on boolean filter methods +fa6bec5 Improved getValueSet() method, added ENUM getters for SQL value, set Query filter to use SQL getters +34f088f add 'add_cleanup' option to SluggableBehavior +aef0024 sqlType="enum(..)" now set the valueSet attribute it is not required to use Propel::ENUM as type +83b7036 fix slug pattern, add tests +100925e Too many queries for the makeSlugUnique method +b5660ec fix call to support php < 5.4 +b489a97 fix problems when relation object has a composite PK +6232333 changed \PDO to PDO +130f941 fix wrong order of result when using withColumn and select(), add tests to prove the issue +d8dbbe7 Fix: allow arrays as behavior parameters to be exported by the tablemap builder +0199fac reset version comment upon saving +39aaaa6 Fix missing use statement. Closes #515 +c702672 Fix strict standards error in Archivable & Concrete Inheritance +d557730 Removed unneeded else-blocks to simplify the code. +cb2da0b Fix absolute path test for Windows +6a42802 fix performance issue loading references on save +6be009c Added the missing default from patching +8e4348d Missed the param on the method when patching +35eb198 Fixed an issue with unnecessary queries for one-to-one related objects. +aaef084 Remove closure to ensure BC +8ba821f fix CS +a2ff295 Fix case sensitivity +394beb5 Better output in tests +269f088 Fix missing PropelException use declaration. +5cfdf7c Fix findOneOrCreate with single inheritance and namespace +21a1e03 sortable behavior: tests for FK scope column +f860b20 sortable behavior: fixed rank shifting on delete when there are no related objects +6966cd9 fix #500 update composer.json force phing 2.4.12 +22b7ef5 Fix a few typos +8bba368 Fix wrong escape of $con +d55ce56 Fix single inheritance class choice error when object is create by findOneOrCreate function +54df08d Fix test files (password introduced by error) +1bf96f2 Active identifier quoting by default, and fix it +1eb07b8 Enable identifier quoting +b9ce9a8 add more fluent FK api +624b87b Fix a descendant_class attribute issue when used with concrete_inheritance and namespaces (issue #480) +a9b91e5 fix duplicate use of parentClass from behaviors +04e6a7c migrations don't report equal FK behavior +3a93511 added unit test to prove the call order of combine and filterByXXX has influence on sql +2b575ab allow baseClass values with namespaces +e66636c Fix PropelCollection::toArray() +66d3740 Replace locale en_EN by en_US. The locale en_EN is not a standard locale. +28b61db Added postHydrate hook to PHP5OBjectBuilder and BaseObject +09760d7 Fix test suite (safe mode) +9ce1af4 Fix fixtures to avoid error (mysql safe mode) +ecf2bc4 Fix travis setup +2345aaa allow unsetting lazy load columns without loading +b692286 Remove accidentally added space +725518f Fix the 'Table "t1" declared twice' when same table name are declared on different schema fix #311 +ed54050 sortable behavior: removed getting $con in moveRelatedObjectsToNullScope() +4c369ba sortable behavior: changed moveRelatedObjectsToNullScope() to use already existing getMaxRank() method and fixed bug in shiftRank() +1e16f2c sortable behavior: changed moveRelatedObjectsToNullScope() method to use improved shiftRank() method +4c3cf04 sortable behavior: improved shiftRank() to not require $first node parameter +924839c sortable behavior: when scope column is a FK and onDelete="setnull", removing related object now moves all objects to the end of null scope +4ded2e5 skip findPk alias on "@method" generation in Query +740d8ff fixed combine overwrite exiting criterions. +3af6a72 sortable behavior: tests for new scope approach (includes fixed typo in SortableBehaviorObjectBuilderModifierWithScopeTest::testInsertAtRank()) +2efa390 sortable behavior: changed removeFromList() to work with new scope approach, little bugfix in preUpdate +f9a0906 Don't try to filter table names. +441f969 Update CHANGELOG +7e169b3 Applied fix #378 change for self::PEER +957b90a Readded blank line before return (accidentally removed while resolving merge conflicts) +5b06917 Fixed typo in method names: preDelete => preUpdate +737bb32 Make findOneById to be an alias of findPk +6e21f54 Ignore composer.phar +6eb19ea Fix #281 +7b30873 Fix #348 +e443b61 Fix #436 +754adbf Add new termination method: exists() +363fce3 Remove lcfirst() for BC purpose. Fixes #415 +da3288c Fix #424 +f9e3c77 Fix i18n behavior with table prefix. Fixes #423 +ddf5b70 Fix #433 +56c13d7 Fix typo in the database.xsd file +ebcdff1 Updated the Table class to not use the schema prefix as part of the phpName. Fixes issue #5. Changed DelegateBehaviorTest to not us +0f95b75 adds tests for i18n_pk_name option, checking columns names and fk building through table and i19n. +1c99e1d adds a test for i18n_pk_name schema option +fc153d0 add a new option for customizing the i18n table pk column name +6d31fa6 Fix QuickBuilder, QuickGenerator +c73221f Adjust fix for #425 +945efa3 Fix PropelObjectCollection to use the right approach during search()/contains() +54e559f Added optional condition to AggregateColumn behavior + +## 2012-07-30: Version 1.6.7 ## + +38cfc9e Update generator/build.properties-sample +f90dfa9 fix for issue 425 +74ee4e1 fix for issue 425 +88e21e6 Avoid blank line in object stub class +8709d3a Fix tests +cefc9ef More CS fixes +e1e1078 Fix doc blocks +29c9db3 Fix NULL => null +3c1717b Improve code generation to follow PSR recommendations +6bae0ca Changed FIXME to TODO +bfef0d7 Changed comments +5e9dfc1 PropelSQLParser with delimiter and fixed tests +39d7958 fix for issue 425 +9667675 SQL Parser Delimiter Tests +8cafbd6 Merge remote-tracking branch 'upstream/master' into delimiter-trigger-parser +5522fbf fix test to pass on platform with EOF != \n +cad1ac6 fix test 2 new relations added to book ;) for issue #421 +a9097da this fix issue #409 thank to toaotc for the patch +2ca7067 add test to prove issue #409 +e84c67c add chaining in PropelObjectCollection::toKeyValue +5dd5394 Revert "Fix platform loading" as it breaks multiple builds using the runtime config +55fef69 Fix regression that removed Persistent interfaces in base classes +d87e9a5 Add test that prove a regression +7c7a608 Fix composer config +c476e50 Add generator classes to the classmap +0d1515d Added column positioning ability to mysql migration +66e7a59 fixes translateFieldname and concrete inheritance +3c891ed add test to show the inheritance issue with php5.4 +66f91c9 Fix platform loading +2874edb fix call on a non object ;) +790b3e4 [aggregate_column behavior] computeCall call reduced from n+1 to 1 or 2 fix #403, add computeCall on main object save() add isAlreadyInSave(), +ddd028c add test to prove to much query on aggregate_column behavior +c36fc7f Add back previous include but change the order of the include path +c107e8e Issue #388: Fix propel-gen path issues Fixes an issue with the check for the propel-gen home-path in propel-gen script Fixes an issue with classes being redeclared because of custom include in phing.php (code is not there in the phing.php version from phing itself) +9731032 Fix collection cache overriding existing one when related object are fetched with criteria +f371602 Fix data loss where parent object won't save related objects when fetched with criteria +3a3ad2c Fixed Versionable Object Modifier not to reload object collection after populateFromVersion +dde4460 Fix joining related object +abc7fc8 Change ObjectBuilder to reload related objects when collection is partially loaded +05b7e1d Fixed possible bug +5d9517a Improved SQLParser to work with triggers in additional .sql files + +## 2012-07-02: Version 1.6.6 ## + +17edd0f Prepare 1.6.6 release +f15d36d Added defaultValue support for type ARRAY +3fc74cc Added tests for setIgnoreCase() method +b03569a Fixed package path if no parent package found +ec4ea3d [NestedSet] Fixed CS +b100492 Fixed small memory leak. Closes #358 +efb2b4a Added limit to phing version. It's now >= 2.4.12, but just for 2.4.* versions. +1f74be0 Better composer constraint, fixes #387 +da1e6ce Fixed bin scripts +b41b746 Cosmetic changes +62fd2bf fix regressions introduced in 841d477db7 +841d477 add @throws and @return where missing +94aae82 fix several generated phpDoc, missing declarations +66f9eda Fixed CS for sluggable behavior +e76f854 add sluggable scope schema +a0e7463 add test for sluggable with scope and alter make unique in behavior to include scope +ec0a762 added support for scope_column +3b34b07 add test for sluggable with scope and alter make unique in behavior to include scope +dd1ce76 tweak for proper php format +f32733f added support for scope_column +a051a60 Fixed CS +ca773b3 fix several phpDoc and type hints +0661d18 fix #378 change for self::PEER +70e572b add enforceVersioning +3b15493 Fixed propel-gen script +3849529 [Timestampable] Made 'updated_at' column optional using a parameter. Fixes #370 +ee711c7 Added bin-info in the composer Added bin-feature as described on http://getcomposer.org/doc/articles/vendor-bins.md +88b8b48 fix remove one-to-many, add test for one-to-many +a5d3096 fix rebase code duplication +a1f26b5 fix setter one-to-many schedule for deletion, fix remove many-to-many +b1f993a fix CS +d57ae1e fix-m2m-schedule-for-deletion +f511569 [Runtime] Avoided possibility issue +e074ecf [Runtime] Avoided BC break +f9ae6da [Runtime] Fixed PropelObjectFormatter for 1-N relations thanks to @fabeat +d636134 [Versionable] Added missing use statement +1c5c378 Fixed bad indentation +56025fa [Timestampable] Disabled update_at column if versionable is used on the same table. Closes #362 +afad075 Fixed CS according to PSR-1, and PSR-2 +afd35b4 [test] [generator] fixed test suite for XmlToAppData class. +1b3389c [test] [generator] fixed test suite according to last changes in previous commit. +ddde376 [generator] fixed the skipSql attribute value when exported to XML. +2710aa6 Fixed composer autoloading +9016436 [Archivable] Fixed file format (unix instead of dos), fixed issue with namespaces +8b9449a fix: Illegal offset type in /propel/runtime/lib/collection/PropelObjectCollection.php line 222 +84d4c66 fix a wrong var name => , close #350 +4f637d8 Adjusted last commit +c614915 Fix some typo (thanks to havvg and willdurand) +76e5eca Fixed ARRAY columns in hydrate() method +4db2d79 Add a little set of features in the README.md +c0af4bd Added new schema for setPk tests +da9bad3 line back. +5615f71 unit tests for pre-defined key type +f209122 new method `getDefaultKeyType` for PHP5ObjectBuilder provided. checks if `defaultKeyType` parameter provided. if not returns `TYPE_PHPNAME` by default. unit test for `getDefaultKeyType` +359cd80 added default key type for object builder. could be re-defined in project configuration. default key name is 'phpName' +f747823 Fixed Table::setInterface(), Table::getInterface() usages +1fd5b18 Added test to prove #318 +108a0b7 added cross ref table to schema and code to BookstoreTest to test patched cross ref setter +2097c08 Updates to PropelMigrationTask to better handle multiple datasources. +84b49eb patched addCrossFKSet: use cross FK related name and check if object in current collection +c3e9bbd Added test to prove #321 +e388798 Fixed SimpleArrayFormatter. Closes #338 +d15c389 Fixed problem when pk already exists on parent table +3d68575 [Generator] Added more methods to the GeneratorConfigInterface, allowed to load behaviors from a QuickGeneratorConfig instance +db47b84 Fixed setting PK on child objects of concrete-inheritance +d6506a5 Fixed propel-gen +bfa9f14 [Runtime] [ModelCriteria] Allowed insensitive case for column names +94d8c3f [Generator/Tests] Updated paths +ee23c82 [composer] Used phing/phing 2.4.12 +678676a Add: support for EXPLAIN queries in postgres +8280f6e Fixed license, added a README +21bdf18 [Tests] Fixed db settings +64a5f40 Added bootstrap.php file for phpunit +58c4861 Fixed travis-ci setup +44b6d26 [Tests] [Fixtures] Fixed default database settings +2b0d0a9 Updated gitignore +8927b97 Added travis-ci file +39d0a88 Added a way to autoload Phing classes using composer +ee007fa Added branch alias to composer.json +21ceeeb Updated the composer.json file +60b4c05 create version when deleting many-to-many refs +22fec05 cs corrections +eac4262 fix #320 reverse engineering : select tablename can returns quoted name on mssql + +## 2012-03-27: Version 1.6.5 ## + +cd69910 Preparing the 1.6.5 release +7b799e3 Fixed composer autoloading based on @grEvenX work +46c3f86 Merge pull request #317 from fzaninotto/fix_model_pager +14b9ac1 Merge pull request #319 from K-Phoen/feature-versionable-utility-methods +45e5c3e Merge pull request #315 from ddalmais/feat-explain-plan +4e72771 Merge pull request #324 from K-Phoen/fix-versioning-inheritance +9f80f8b Fix: versioning tables with inheritance +7769218 Add: some useful methods to Versionable objects +45f2924 Fix PropelModelPager::getLastPage() return type. +4cb3e5e Fix CS +4c8d9ac Use assertArrayHasKey instead of assertTrue +2e74a91 Fix indentation and useless blank line +aeeb66d Fix text formatting +929080d Add unit test on explain plan compute from text query +0469a2c Format DBMysql code +460b90f Make ExplainPlanTest independent from Adapter +377baf9 Add unit test on getExplainPlanQuery +2420c3e Add DBOracle doExplainPlan function +d54388a Remove forced database read connection Oracle must write explain plan in PLAN_TABLE +e4c3de1 Fix phpdoc function title +f62cba4 Enable to get the connection name in log +a8c55fd Enable doExplainPlan to take a bound query +00bcc96 Fix text in ExplainPlanTest +2f6a4fa Add explain plan unit test on mysql bookstore +9f16429 Add explain function use adapter specific doExplainPlan function +f0c8673 Add specific Mysql doExplainPlan function +03dda95 Add doExplainPlan on DBAdapter Return PropelException Used to return Exception in adapter without override of doExplainPlan function +b7669e3 Merge pull request #314 from K-Phoen/fix-is-versionning-necessary-fk +eb303e5 Fix: some isVersionningNecessary() calls can cause fatal errors +356947a Merge pull request #310 from akalyaev/master +38738e6 fixed code style (Refs #309) +3231a76 Fixed propel-gen. Closes #180 +8168f9d Added phpunit.xml.dist file +769dbf9 fixed ArchivableBehavior archived_at (Refs #309) +45f418b Marked PGSQL test skipped +43e4ae7 Fixed reset_tests.sh script +865511a [gh-152] Revert change that was made to postgres schema parsing that causes regressions and has no tests. Add tests for my case. I do not understand the case that the person who introduced the bug was trying to solve. +5ebefc3 Fix #282 versionable behavior FK in generated object classes Fix #282 by replacing foreign key references with PrimaryKey +14a1702 Merge pull request #298 from Langwhich/master +841448e Fix MySQL quote issue for table options. Closes #301 +2923a3b Merge pull request #291 from fzaninotto/remove_class_default +ea41817 Remove remaining BasePeer::CLASS_DEFAULT constant. +9d0251f Merge pull request #297 from vworldat/patch-1 +82894e7 Merge pull request #299 from havvg/master +292fc7a add test for multiple HAVING conditions +41f605a Fixes SQL diff command when there is a custom migration table name defined +f0ac2e9 `` tags inside behaviors are optional. The current schema fails when including a behavior like ``. +0eacc54 Merge pull request #295 from fzaninotto/versionable_namespace +1f46f36 Add missing namespace declarations in versionable behavior. +3d5dc3c Merge pull request #287 from fzaninotto/findoneorcreate_exception +f033016 Merge pull request #288 from fzaninotto/select_paginate +f2d1cce Merge pull request #289 from fzaninotto/archivable_namespace +e9051d4 Merge pull request #290 from fzaninotto/diff_with_migrations +e0c16e2 Remove BasePeer::CLASS_DEFAULT constant. +0b34a67 Update diff task to fail when uncommitted migrations are found. +34bd8d6 Add missing namespace declaration in archivable behavior. +f216a1a Add unit tests for paginate() used together with select() +891e332 Update the exception thrown by findOneOrCreate() when used with a join. +209e34d Merge pull request #279 from grandbora/fixSelectWithPeerConstant +2f9c987 fixed and tested +5850dce correct way of checking if a formatter was set +7afba56 code standard +b4727af fixing issue #248 allowing the use of custom PropelFormatter with select +49416d3 Fixed CS/trailing whitespaces +a8145ce Extended the clear method of the generated Active Record objects so that when dealing with object/array columns, the _unserialized fields will be cleared as well. +3ddd790 Fixed test showing a warning of undefined key offsets because numerically indexed arrays after cast to objects cannot be accessed by numeric property. +33acfaa Added failing tests for object and array type columns, caused by object reuse via the PropelOnDemandFormatter. +af6994e Merge pull request #276 from havvg/patch-1 +84df995 add test for class targets build +a9d972e make class targets selectable +e95a5d4 Merge pull request #268 from cedriclombardot/fix-count-with-select-from-select +ae7bdfc Merge pull request #270 from cedriclombardot/fix-issue-206 +e3f5081 Fix cs +46dffc8 Fix cs for testSubQueryCount() +8cc0cb3 Merge pull request #269 from jaugustin/patch-1 +f23575d Fix findPkSimple() uses wrong key for InstancePool (QueryBuilder) #206 +0383d9c Provide unit test for doCount with subqueries +bdb2e32 this fix an issue with the propelorm/propelbundle#62 +7025b10 Mark as complex queries look like SELECT * FROM (SELECT * FROM book) as b to fix bug in doCount() +8184e26 Bumped version to 1.6.5-dev + +## 2012-01-16: Version 1.6.4 ## + +[f8fdf43] Preparing the 1.6.4 release +[6984ed0] Merged PR #177. Fixes #90 +[1acaf0c] Fix #90 PropelOnDemandFormatter formatter broken when using single table inheritance +[aa7870b] [aggregate] Fix behavior when used with namespaces. +[843a7fb] [SchemaValidator] Schema validation fails for equal nest relations. +[65da18e] Added 'IF EXISTS' on 'DROP' clauses for PostgreSQL +[176242b] restoring the ability of reverse-engineering views +[2280ccb] add tests for Graphviz DOT generation +[3210ec9] mark FK with PK if both apply to column +[582d79b] Add unit test for 08e597835dd484e8b894f2ca1f56f053d3a4cfdb. +[08e5978] Add to phpName parameter to ArchivableBehavior. +[01994f2] Update test/testsuite/runtime/adapter/DBAdapterTest.php +[a6421e8] Correction to createSelectSqlPart at & after line 441 - it tries to look for a space between the rightmost '(' and the rightmost '.' after it. +[f93fff8] [Generator][I18nBehavior] fix setLocale when using custom locale_column fixes #223 +[4eb6602] Revert "Fixed Ymd format for PropelDateTime::newInstance" +[1b97344] Revert "fix isTimestamp." +[d0813bf] fix PropelQuickBuilder-dependent tests after SQLite DROP TABLE change +[87f30a6] use DROP TABLE IF EXISTS with SQLite +[0671d6b] Fixes #218, plus some typo fixes. +[9d8e12a] fixes #135 +[059df0a] empty test case +[6c8e974] typo fix (enterface -> interface) +[3d753de] add extensible ability to versionable +[18bc846] test typo fix +[5b0e107] Fixed missing typehint on crossFK methods +[c47f9fb] add raw sql capability to conditions +[cc29263] add namespace to check for duplicate table phpName +[68fe060] fixed versionnable infinite loop when no diff. +[47e9a2c] add tests to versionnable behavior whit foreign key +[047fa1e] [Generator] Fixed undefined variable. Fixes #202 +[5b6dda3] Updated phpDoc for populateFromVersion Initialized variable in function declaration instead of the beginning of the function +[6704737] Fixed so versionable behavior loads correct relations when populating from a an older version. See https://github.com/propelorm/Propel/issues/198 for more info about this issue. +[5ce2674] Allowed FQCN with namespaces in inheritance keys (working solution). Fixes #135 +[eab615f] Revert "Allowed FQCN with namespaces in inheritance keys. Fixes #135" +[9e279b6] Prevent notice error if no parameter found. Fixes #190 +[c43415c] Allowed FQCN with namespaces in inheritance keys. Fixes #135 +[af11116] [Generator] fix concrete inheritance deep copy, fix also one to one deep copy, fixes #192 +[7a80f9a] [Generator] fix first part #192, remove pk value when copy object with single PK not autoincremented +[12b2ddd] Updated composer file +[af5f683] Fixed a unit test in ModelCriteria +[0f3eee9] add BasePeer in declare classes, because when you use query_cache behavior with namespace, the BasePeer is not found +[8ba9370] Fix archivable behavior when used with unique index. +[16e3554] Fix bug that caused new I18n rows to not return a valid object causing a fatal error. +[d222741] Put `ModelCriteria` on par with `Criteria` for raw conditions. +[c89474c] Remove just added methods. +[1191479] Add the ability to create a raw Criterion to all Criteria methods +[0af997d] Introducing Criteria::RAW operator (WIP) +[f720e60] [Generator] [Builder] Fix abstract single table inheritance, refs #159 +[cb71e64] [behavior] [delegate] Fixed behavior with namespaces +[5423afb] [Generator] [QueryBuilder] fix single table inheritance findPk +[a8d80bd] Fix archivable behavior when archive table is in another database. There is a nasty bug causing the `archive()` method to use the wrong connection when called after `delete()` (this is because we want to enclose the two operations in a transaction when they operate on the same database) so we need to remove the connection parameter in case the user uses cross-databases archives. A unit test for this case is quite heavy to set up (two more DBs to create), but I have tested it locally and it is OK. +[f2e260e] Fix regression in 1.6.3, where exception is not caught on namespaced objects. Closes #165. +[7130d13] Fix BaseObject phpDoc. Closes #170. +[2b8accf] Do not specify -dev in composer.json +[2d66201] fix findByXXXAndYYY() when one of the parameters is a relation. Refs #158. Based on a patch by @maikg +[6cfab63] Fix sql_type regex to allow for values like enum('_self','_blank'). +[efa1c93] fixes #145 : isCrossRef attribute can now be set to false, with tests +[87c89c6] add test for isCrossRef attribute +[0204345] add isCrossRef attribute to the TableMap object, set the right value in the TableMapBuilder +[1b28424] Bumped version to 1.6.4-dev + +## 2011-10-13: Version 1.6.3 ## + +* [54b1941] [generator] Fix typos in new buildtime validation service +* [8663103] [generator] Introducing buildtime schema validation. All schema validation cannot be done in XSD. For more complex validations, some PHP processing is required. This patch moves validation logic into a simple and independent validation service. It processes the whole schema in order to output all error messages at once. Closes #3. Closes #96. +* [a20ad17] Added a unit test to cover changes in commit e47f63b8f224b0b85b91f86f414f223e023ff73c +* [275174c] Fix Behaviors adding a table when they are added as database behavior. Closes #136. +* [dbb0d4a] [enum type] Fix isModified() returns true when setting the existing value on a just hydrated object. Closes #139. +* [e47f63b] Fixed ModelCriteria::replaceNames() to handle namespaced model classes +* [83f8c5f] Properly define non-integer single PKs when using SQLite. +* [7a715cd] unit testing fo isTimestamp +* [4b330e8] fix isTimestamp. +* [31850e6] Bugfix: Syntaxerror if $archivedAtColumn==true +* [7b8f7b0] Fix indentation in generated Query classes. The QueryBuilder was using spaces instead of tabs to indent code. This is now fixed. +* [20fc5ac] Fix getId() in generated doInsert() for Postgresql +* [8c5d966] Fixed CS +* [cd0f9e2] Switched identifier escaping at buildtime to off by default. This harmonizes the buildtime and runtime settings, and removes the need to set disableidentifierquoting to true in build.properties for Postgresql. Make sure to rebuild your model and SQL after the update +* [59a8828] adjust AR generated code formatting +* [7a2a059] Fixed #118, #119 +* [faf7305] Fixed trailing whitespaces due to PR #116 +* [53a9ed2] [turbo] Add explicit comment to generated code +* [5ecdda8] [turbo] Final code formatting glitches +* [ed60055] [turbo] Fix doInsert for PKs using sequences +* [36c78f6] Implemented One-To-Many setters. +* [3dc5e3f] Fixed commit 5b1d911fee5ae0ef6321880bc7861dc5227cea45 +* [59a2abd] [turbo] Move logic for pk retrieval after insertion to buildtime +* [39e0456] Fix bug that would cause a transaction to leak if an Exception that isn't PropelException is thrown during preSave, preInsert, preUpdate, doSave, postInsert, postUpdate, postSave. +* [9732e08] Fixed builder (setter collection) +* [bd41e0d] [turbo] Align the syntax of recent additions to ObjectBuilder. Passing the script by reference is a bad habit, but not doing so for only a few methods is confusing. In the future, if a refactoring of the builders occurs, let us not reproduce that mistake +* [3437149] [turbo behavior] Move the doInsert() acceleration to the core. And now that there is nothing in the turbo behavior, it is removed. doInsert() acceleration is disabled on Mssql platforms, due to very exotic bindings in adapter classes +* [14bcdaf] [turbo behavior] Bugfix for namespaced classes and query_cache behavior +* [5bd66f6] [turbo behavior] Move the findPk() acceleration to the core. The behavior now only accelerates doInsert() (until we find a way to marge this into the core, too). +* [d231655] Revert "Fixed the name of generated SQL files if package contains slashes" +* [01b03f7] [turbo behavior] Use the correct binding code in accelerated findPk(). This is to accommodate cases where PK columns have special bindings (like timestamps... ot blobs, who knows). I took advantage of this to refactor the custom binding code in the adapters. +* [977dcd0] [turbo behavior] Refactor ModelCriteria::find(), findOne(), and findPk() to allow preSelect() hook to be called just like the other model hooks. This refactoring allows the turbo behavior to accelerate findPk() on every model, even those using a preSelect() hook. It also harmonizes the AR and Query apis: just like ActiveRecord::save() calls doInsert() or doUpdate(), ActiveQuery::find() calls doSelect(), and ActiveQuery::count() calls doCount(). +* [a9a2f0e] [turbo behavior] slightly better way to have binding type and value preparation depending on the platform +* [9b0690f] [turbo behavior] Change insert acceleration strategy to allow exotic bindings. This is necessary to let Oracle, for instance, use bindParam() instead of bindValue() for CLOBs. +* [2339b9d] Fixed commit 46d928f0a8f8e92484d9a031d986d0cc05c100a6 +* [e94b626] fix coding standard +* [25b86b1] [turbo behavior] Make each acceleration optional +* [46d928f] the semicolons are missing between sql request in $statementsToInsert +* [f38f6d0] [turbo behavior] Accelerate save() queries +* [489353b] [turbo behavior] refactored generated ActiveRecord::doSave() to make it easier to extend (end) +* [2ce3ef7] [turbo behavior] refactor generated ActiveRecord::doSave() to make it easier to extend (WIP) +* [970cf4a] Fixed logical error on save() for setter collections. +* [5b1d911] Fixed the behavior of 'disconnectedEscapeText()' for MySQL platform. Fixes #108 +* [77a166c] Added missing declared class. Refs #103. +* [d22d141] Removed useless function (setter collection) +* [b447f15] Added a new protected method 'doAdd*()' +* [9b44292] Fixed commit f267fdff5979a04b0a43466bc2dc89935831210d +* [abe38f2] [turbo behavior] Use correct binding for PK search. Backed by unit tests. +* [f72df02] Added more unit tests for the 'diff' method +* [f267fdf] Avoid too many deletes for scheduled for deletion objects (collection setter) +* [3e08824] Kept BC with PHP version under 5.3 (lcfirst() hack) +* [f442b35] Moved the diff logic to a better place (in PropelCollection) +* [fca956c] Added insert SQL ability to the PropelSqlManager +* [e4c37ca] Added more unit tests for the collection setter +* [9e6ad1d] Fixed setter signature +* [5eda115] Refactored collection setters thanks to fzaninotto +* [51729f7] Added more unit tests for the collection setter +* [594708e] Added auto save for related objects after using the collection setter (N-N) +* [9efdf58] Passed the connection to the setter +* [8e657e0] Added more tests for collection setter +* [c6db541] Added a workaround for collection setters +* [293a8b8] Added unit tests to bootstrap the work around collection setters +* [02f87a1] Fixed indentation +* [398c030] Added convenient methods to the Table class +* [6a7c4d1] [turbo behavior] Accelerate simple findPk() queries +* [9d9b246] Moved logic for the new build SQL task in a dedicated class. +* [31c5462] fix generate sql file when there is multiple schema.xml for the same connection +* [b5e5602] Make XSD validation for sqlType less restrictive. Fixes #97. +* [8dc4be5] Added a whitelist for charsets in MySQL adapter and PHP < 5.3.6. +* [5a40249] Fixed deprecated method since 5.3.0 +* [fd80913] Removed WHATS_NEW file +* [abd6c76] Fixed INSTALL +* [4ca8cd6] Fixed maintainer for PEAR package task +* [c1febde] Bumped version to 1.6.3-dev + +## 2011-09-14: Version 1.6.2 ## + +* [cb2009a] [delegate behavior] Fix incorrect handling of tablePrefix Refs #63. +* [9aef5f6] [i18n] Added few tests to prove there is no bug with relations. +* [4cf9dc7] Fixed #93 +* [65139a1] [PropelSQLTask] Fixed SQL filenames +* [b27fef5] Revert "Fixed possibility issue on SQL filenames based on package values" +* [0183944] fixed nested _if using a proxy +* [26fc546] removed underscore for private methods +* [4f6c495] fixed typo +* [c0ba5c5] fixed nested fluent condition +* [0202db4] [Tests] Preparing PHPUnit 3.6.0 release. +* [bffd323] Fixed failing unit tests complaining about an "Undefined index: datasources" when running some tests individually +* [6a0e030] Fixed version column needs to be required for mssql. The `versionable` behavior adds the version table by copying the main table, which already contains the version column. The problem is, as the version column becomes part of the PK of the version table, it must be required. Only MSSQL seems to complay about this, but it must be fixed anyway. +* [7c1d1b4] Fixed possibility issue on SQL filenames based on package values +* [d9adc1f] Fix issue with empty migration SQL generated when foreign key has skipSql +* [0e2463c] Added composer.json file +* [f46b54a] Fixed the name of generated SQL files if package contains slashes +* [6c2b8ef] Fix incorrectly generated migration SQL for pgsql if existing default value is removed from schema +* [672eb1f] Fixed commit 5c77b2a1e3efdab03e93 +* [5c77b2a] Allow configuration of usePrefix and includeLazyLoadColumns when exporting a PropelCollection +* [3bc2e78] Added usage of connection in PropelModelPager. Fixes #74 +* [ef1ef22] Updated license +* [691b648] Removed the docs/ directory as the documentation has its own repository +* [d4e9a51] should be `phpunit` +* [f581bae] fixed #70 : setByPosition method in enum +* [3269069] Fix test documentation +* [f6b6403] default sh shell is no more bash in debian. +* [d92e3a7] [archivable behavior] Added more tests to cover methods added in 9f7a0670184da5600d6abc4c79c82737f6fbad68 +* [eb4caf3] [archivable behavior] Fixed minor typos +* [4c10206] Allowed to use '/' in package values +* [c23b6cb] [archivable behavior] Fixed code formatting issues +* [5e58668] [archivable behavior] Refactored method generation to use templates +* [9f7a067] [archivable behavior] Further improved the ActiveRecord API +* [2de49d5] [archivable behavior] Fixed typos in the documentation +* [3a3c5f8] [archivable behavior] Added documentation and deprecated soft_delete +* [97d383c] [archivable behavior] Fixed the archiveOnDelete implementation when the addHooks build property is turned off +* [ca6f957] [archivable behavior] Made the preDelete hook play well with other preDelete hooks. Previous hooks or behaviors may interrupt the course of the delete() method. This behavior (and other behaviors implementing the preDelete hook) must only execute the code if the $ret value is true. +* [05633de] [archivable behavior] Refactored archiveOnDelete to avoid the need for static attributes +* [328a32b] [archivable behavior] Fixed generated ActiveRecord::delete() behaves differently when addHooks build property is disabled +* [2dc16dc] [archivable behavior] Refactored ActiveRecord and ActiveQuery APIs to harmonize them +* [a7e00af] [archivable behavior] Implemented archiving on `ActiveQuery::update()` and `::delete()` +* [3fd6823] [archivable behavior] Fixed a rare bug in `ModelCriteria::update()` causing "undefined index: datasources" error message +* [b818915] [archivable behavior] Added generated ActiveQuery::archive() method +* [f1a163d] [archivable behavior] split ArchivableBehavior class to make it more readable and ready for future additions +* [5d6e4b0] [archivable behavior] Added the ability to use a custom archive class. +* [5088e39] [archivable behavior] Added generated ActiveRecord::populateFromArchive() method +* [182af0c] [archivable behavior] Initial commit +* [ce59915] [Tests] More tests for MysqlSchemaParser +* [20d407a] Changed visibility to be less 'open'. Related commit: 381e378cb17b388765dfbb5a3241dacbff449323 +* [dd10eec] [Tests] fixed script to handle reverse fixtures +* [d64741a] Fixed the test file's syntax +* [9584188] Fixed unit test +* [8b20446] used 'SHOW FULL TABLES' instead of the previous one to handle multiple database +* [acccc26] Excluded read only tables from being counted +* [1cd82d6] handle views when using diff command +* [7f89e83] Added unit test for MySQL schema parser +* [8470dba] Added fixtures for MySQL reverse unit tests +* [f75334c] Changed prototype to use the interface instead of an implementation class +* [381e378] Changed visibility of simpleXmlToArray method in PropelConvertConfTask in order to use it in tests +* [54ce432] Removed stray testing stuff that got left behind +* [db4e041] FIX: Check that platform exists before using it +* [be563e8] Fixed false positive in PostgreSQL migrations where generator would generate varchar-fields without explicit size as VARCHAR(255) +* [7c84b79] Fixed postDelete hook in soft delete behavior +* [39e3709] [SoftDeleteBehavior] Fixed missing post hook call +* [8fc39e1] Added test to prove post hook is not fired on soft deleted objects. +* [c5c30e0] set sequence name configurable +* [082d27a] Added strict assertions +* [1ad20fb] added unit-test for Table::appendXml (namespace & package attributes) +* [3addf99] serialize namespace too +* [76a3841] store table`s package name in Xml +* [ff673c0] Added a tiny shell script to reset test fixtures +* [3d6d4bd] fixed naming and default values in unit test +* [67a77bf] Fixed bug in PhpNameGenerator. The default name convertor for table and column names is NameGenerator::CONV_METHOD_UNDERSCORE. This method has a slight bug resulting in an incorrect phpName for table using "_0" as a prefix: +* [04fe003] fix usage of undefined variable +* [ceb610f] `level` is reserved keywork in oracle +* [57a0f2c] pass vendor`s type to VendorInfo::__construct in XMLElement::getVendorInfoForType() +* [a3aaa76] detect autoincrement via sequences +* [7c84546] [delegate behavior] Documented the fact that, finally, delegate behavior can handle inheritance over several levels +* [8290ed5] [delegate behavior] Changed class table inheritance examples to show that the behavior is much more powerful than previously thought. Refs #40 +* [1f4ce85] Fixed MySQL type for a BOOLEAN +* [5e7d765] [delegate behavior] Fixed typo in behavior documentation +* [4ee22c0] [delegate behavior] Fixed coding standards +* [4b327c6] [delegate behavior] Fixed wrong file permissions (old samba config) +* [fe2ce45] [delegate behavior] Throwing exception at buildtime if the delegate table has a one-to-many relationship with the main table +* [87ed930] [delegate behavior] provided support for delegation by way of a many-to-one relationship +* [9583e6b] [delegate behavior] Refactoretests to leave less trace +* [197b533] documented the delegate behavior +* [ca09d1d] Introducing Delegate behavior, for class table inheritance fans +* [a78212c] Fixed bad formatting in generated query classes +* [184e63f] Removed __call() from generated ActiveRecord classes. +* [0e454c5] Avoid getClassname() to trigger registered autoloaders for nothing. +* [74cd5eb] Added the ability to define full qualified classnames in build properties. +* [e1662d0] Reverted change on the TINYINT default size (MysqlSchemaParser) +* [a2965d4] Fixed CS +* [9521482] Fixed TINYINT interpretation in MysqlSchemaParser. +* [e939c2e] Improved generated code for findOneOrCreate() method with ENUM and ARRAY types. +* [594d44e] Added missing link to the StandardEnglishPluralizer class +* [61deedb] Added more unit tests for the StandardEnglishPluralizer + Fixed special cases. +* [5288e48] Improved the StandardEnglishPluralizer. Fixed issue #4 +* [22159b2] Fixed double left-join & "with" issue when a third table is joined and "withed" +* [ec41624] Fixed phpdoc in parser/ +* [73a7d21] Fixed phpdoc in validator/ +* [10f5dd5] Added unit tests for issue #35 and PR #37 +* [9e62f3c] One-line fix for issue #35 (https://github.com/propelorm/Propel/issues/35) +* [e84f5fa] Set limit parameter to 0 (like initially done) if clear() is called +* [b377ebf] Added unit tests for Criteria methods: clear() and limit() +* [5ce8fa7] Remove unneeded @returns, Fix @param order +* [176c68f] Fix typo on docblock +* [425b0f2] Improve Behavior doc blocks +* [ffd8192] fixed unit test to check identity rather than equality +* [f5f9d9a] Made generated addRefFk method return the current AR object to allow fluent interface +* [13611a2] Fixed Typo in the doc mixing ModelCriteria::addSelectQuery() with ModelCriteria::getSelectQuery() +* [aaff75d] Removed trailing whitespace, unwanted tabs/spaces and so on... +* [698ce9b] Improved the patch for MySQL driver (possibly subject to sql injections) +* [54ef274] Added a new unit tests for DBMySQL class +* [cd547f2] MySQL Driver possibly subject to sql injections with PDO::quote() +* [cd99264] Fixed wrong peer name in soft_delete behaviour with classPrefix +* [2d0f101] Fixed Ymd format for PropelDateTime::newInstance +* [b006238] Fixed permissions for scripts +* [3e13b29] Fixed tests for PropelDateTime::newInstance +* [aa0393f] Add support for Ymd format for PropelDateTime::newInstance +* [35822d7] Fixed permissions for both directories and files. +* [76fb103] Fixed scandir warning if no valid directory given. +* [5ade9ff] added more generated files from tests to .gitignore +* [5c5816e] Added .gitignore to ignore generated files for unit tests +* [23270ef] Added a unit test for the previous commit +* [e86b3c3] Always sort columns when comparing composite foreign-keys +* [3dcd7b2] reproduced default isModified() logic for other mutators +* [e1ed026] Fix for ActiveRecord::isModified() in limit cases with default values +* [5f2ff4e] added missing validator in autoload map +* [7164161] Remove rewind on CLOB to fix warning +* [4eb059d] Fixed CS + restore BLOB insert + Add rewind before CLOB bindParam +* [e693f62] Fixed Error in logic of _if/_elseif/_else. Based on a patch by lvu, updated to Propel standards. Closes #12 +* [6f536c6] Fixed Oracle CLOB save by using PDO bindParam +* [ea8f4c8] [1.6] Fixed failing test after updating test schema (refs #1319) +* [258799f] [1.6] Fixed undefined method error when calling with() on a ModelCriteria having a relation with a special name (closes #1477) +* [9eac2ed] [1.6] Fixed logging of methods (refs #1468) +* [94193c6] [1.6] Removed old configuration test (refs #1468) +* [af7ac9c] [1.6] fixed regression in PropelConfiguration when setting an array value via setParameter (closes #1468) +* [ff2b8c1] [1.6] Fixed notice about undefined hydrationChain when using joinWith() twice and the middle entity is null (closes #1319) +* [0cee299] [1.6] Removed unused logging configuration setting (closes #1453) +* [a5ab232] [1.6] Fixed Conflict between concrete inheritance and namespaces (closes #1464) +* [eba3b40] [1.6] Fixed phpDoc for Criteria::addAscendingOrderByColumn() (patch by bertjan) (closes #1454) +* [c6b53c9] [1.6] Removed many false positive in migrations (closes #1451) +* [1d828e5] [1.6] Fixed issue with autoincrement pks when calling diff task in migrations (closes #1456) +* [942efab] [1.6] Switched to dev version number + +## 2011-06-14: Version 1.6.1 ## + +* [2318] Fixed handling of custom sqlType in migrations (closes #1348) +* [2317] fixed `PropelObjectCollection::populateRelation()` when using classPrefix or namespaces (based on a patch by mattleff) (closes #1402) +* [2316] Made `PropelObjectCollection::populateRelation()` initialize empty collections on entities having no related entity in a one-to-many relationship (closes #1182) +* [2315] Added all supported MySQL table options (closes #1447) +* [2314] Fixed phpDoc of generated ActiveRecord getter and setter methods for nested set models +* [2313] Fixed autoloading of namespaced models when using `useQuery()` (closes #1444) +* [2312] Fixed formatting issues in generated TableMap classes +* [2311] Fixed location of FKeys in PostgreSQL migrations (closes #1411) +* [2310] Fixed handling of empty string values on boolean columns for ActiveRecord mutator and ActiveQuery filter (closes #1437) +* [2309] fixed inconsistent EOL types in builder classes (closes #1436) +* [2308] fixed inconsistent EOL types in builder classes (closes #1436) +* [2307] Fixed "Nesting level too deep" error when similar schemas are used (patch from gepo) (closes #1426) +* [2306] Improved runtime/exception phpDoc formatting (patch by kupokomapa) (closes #1429) +* [2305] Improved runtime/logger phpDoc formatting (patch by kupokomapa) (closes #1428) +* [2304] Improved runtime/connection phpDoc blocks (based on a patch by kupokomapa) (closes #1425) +* [2303] Added `ModelCriteria::getSelect()` (closes #1412) +* [2302] Added `PropelOnDemandCollection::toArray()` (closes #1415) +* [2301] Fixed subquery bug with select (closes #1417) +* [2300] Added test to prove subquery bug with select (refs #1417) +* [2299] Fixed `PropelObjectCollection` and `PropelArrayCollection` would throw a fatal error when calling save() in conjunction with readOnly entities (closes #1422) +* [2298] Improved runtime/config phpDoc blocks (patch by kupokomapa) (closes #1424) +* [2297] Improved runtime/collections phpDoc blocks (based on a patch by kupokomapa) (closes #1423) +* [2296] Fixed coding standards in DBAdapter (closes #1421) +* [2295] Improved runtime/adapter phpDoc blocks (patch by kupokomapa) (refs #1421) +* [2294] Fixed soft delete via Peer class executes a wrong query (closes #1405) +* [2293] Fixed `forceDelete()` enables soft delete behavior even when disabled (closes #1404) +* [2292] Fixed tests under PHP 5.2 (closes #1388) +* [2291] Fixed minor formatting issue in generated Peer class +* [2290] Fixed generated column filters for enum columns when passed an array (closes #1381) +* [2289] Fixed strict standards error in soft delete behavior (closes #1398) +* [2288] Added missing `findRoots()` method to nested_set behavior with scope (closes #1397) +* [2287] Fixed bad binding with SQLSRV adapter (refs #1199) (closes #1400) +* [2286] Fixed DATE column with defaultValue of 0000-00-00 generates fatal (closes #1389) +* [2285] Fixed typo in README diff --git a/airtime_mvc/library/propel/INSTALL b/airtime_mvc/library/propel/INSTALL index cb7effd16..b685d9e99 100644 --- a/airtime_mvc/library/propel/INSTALL +++ b/airtime_mvc/library/propel/INSTALL @@ -1,4 +1,4 @@ I N S T A L L I N G P R O P E L ================================== -See docs/guide/01-Installation.txt for detailed installation instructions. \ No newline at end of file +See: http://www.propelorm.org/documentation/01-installation.html diff --git a/airtime_mvc/library/propel/LICENSE b/airtime_mvc/library/propel/LICENSE index 1b4925a27..cce8129dc 100644 --- a/airtime_mvc/library/propel/LICENSE +++ b/airtime_mvc/library/propel/LICENSE @@ -1,4 +1,5 @@ -Copyright (c) 2005-2010 Hans Lellelid, David Zuelke, Francois Zaninotto +Copyright (c) 2005-2013 Hans Lellelid, David Zuelke, Francois Zaninotto, William +Durand Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -16,4 +17,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. diff --git a/airtime_mvc/library/propel/README.md b/airtime_mvc/library/propel/README.md new file mode 100644 index 000000000..46e73bf34 --- /dev/null +++ b/airtime_mvc/library/propel/README.md @@ -0,0 +1,26 @@ +# Propel # + +Propel is an open-source Object-Relational Mapping (ORM) for PHP5. + +[![Build Status](https://secure.travis-ci.org/propelorm/Propel.png?branch=master)](http://travis-ci.org/propelorm/Propel) +[![Total Downloads](https://poser.pugx.org/propel/propel1/downloads.png)](https://packagist.org/packages/propel/propel1) +[![Latest Stable Version](https://poser.pugx.org/propel/propel1/v/stable.png)](https://packagist.org/packages/propel/propel1) + +## A quick tour of the features ## + +Propel has some nice features you should know about: + + - It's a fast and easy way to manage your database; + - It provides command line tools for generating code (well documented with an IDE-friendly syntax); + - It's very flexible: you can simply extend Propel; + - It uses PDO (PHP Data Objects) so it allows you to use the RDBMS of your choice (MySQL, SQLite, PostgreSQL, Oracle and MSSQL are supported); + - Propel is an open-source project which is [well documented](http://propelorm.org/documentation/). + +## Installation ## + +Read the [Propel documentation](http://www.propelorm.org/). + + +## License ## + +Propel is an open-source project released under the MIT license. See the `LICENSE` file for more information. diff --git a/airtime_mvc/library/propel/WHATS_NEW b/airtime_mvc/library/propel/WHATS_NEW deleted file mode 100644 index 9120f63ae..000000000 --- a/airtime_mvc/library/propel/WHATS_NEW +++ /dev/null @@ -1,807 +0,0 @@ -= What's new in Propel 1.5? = - -[[PageOutline]] - -First and foremost, don't be frightened by the long list of new features that follows. Propel 1.5 is completely backwards compatible with Propel 1.4 and 1.3, so there is no hidden cost to benefit from these features. If you didn't do it already, upgrade the propel libraries, rebuild your model, and you're done - your application can now use the Propel 1.5 features. - -== New Query API == - -This is the killer feature of Propel 1.5. It will transform the painful task of writing Criteria queries into a fun moment. - -=== Model Queries === - -Along Model and Peer classes, Propel 1.5 now generates one Query class for each table. These Query classes inherit from Criteria, but have additional abilities since the Propel generator has a deep knowledge of your schema. That means that Propel 1.5 advises that you use ModelQueries instead of raw Criteria. - -Model queries have smart filter methods for each column, and termination methods on their own. That means that instead of writing: - -{{{ -#!php -add(BookPeer::TITLE, 'War And Peace'); -$book = BookPeer::doSelectOne($c); -}}} - -You can write: - -{{{ -#!php -filterByTitle('War And Peace'); -$book = $q->findOne(); -}}} - -In addition, each Model Query class benefits from a factory method called `create()`, which returns a new instance of the query class. And the filter methods return the current query object. So it's even easier to write the previous query as follows: - -{{{ -#!php -filterByTitle('War And Peace'); - ->findOne(); -}}} - -The termination methods are `find()`, `findOne()`, `count()`, `paginate()`, `update()`, and `delete()`. They all accept a connection object as last parameter. - -Remember that a Model Query IS a Criteria. So your Propel 1.4 code snippets still work: - -{{{ -#!php -addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID); - ->add(AuthorPeer::LAST_NAME, 'Tolstoi') - ->addAscendingOrderByColumn(BookPeer::TITLE) - ->findOne(); -}}} - -But you will soon see that it's faster to use the generated methods of the Model Query classes: - -{{{ -#!php -useAuthorQuery(); - ->filterByLastName('Tolstoi') - ->endUse() - ->orderByTitle() - ->findOne(); -}}} - -That's right, you can embed a query into another; Propel guesses the join to apply from the foreign key declared in your schema. - -That makes it very easy to package your own custom model logic into reusable query methods. After a while, your code can easily look like the following: - -{{{ -#!php -filterByPublisher($publisher) - ->cheap() - ->recent() - ->useAuthorQuery(); - ->stillAlive() - ->famous() - ->endUse() - ->orderByTitle() - ->find(); -}}} - -The Model Queries can understand `findByXXX()` method calls, where `'XXX'` is the phpName of a column of the model. That answers one of the most common customization need: - -{{{ -#!php -findOneByTitle('War And Peace'); -}}} - -Eventually, these Query classes will replace the Peer classes; you should place all the code necessary to request or alter Model object in these classes. The Criteria/Peer way of doing queries still work exactly the same as in previous Propel versions, so your existing applications won't suffer from this update. - -'''Tip''': Incidentally, if you use an IDE with code completion, you will see that writing a query has never been so easy. - -=== Collections And On-Demand Hydration === - -The `find()` method of generated Model Query objects returns a `PropelCollection` object. You can use this object just like an array of model objects, iterate over it using `foreach`, access the objects by key, etc. - -{{{ -#!php -limit(5) - ->find(); // $books is a PropelCollection object -foreach ($books as $book) { - echo $book->getTitle(); -} -}}} - -Propel also returns a `PropelCollection` object instead of an array when you use a getter for a one-to-many relationship: - -{{{ -#!php -getBooks(); // $books is a PropelCollection object -}}} - -If your code relies on list of objects being arrays, you will need to update it a little. The `PropelCollection` object provides a method for most common array operations: - -{{{ -Array | Collection object ------------------------- | ----------------------------------------- -foreach($books as $book) | foreach($books as $book) -count($books) | count($books) or $books->count() -$books[]= $book | $books[]= $book or $books->append($book) -$books[0] | $books[0] or $books->getFirst() -$books[123] | $books[123] or $books->offsetGet(123) -unset($books[1]) | unset($books[1]) or $books->remove(1) -empty($books) | $books->isEmpty() -in_array($book, $books) | $books->contains($book) -array_pop($books) | $books->pop() -etc. -}}} - -'''Warning''': `empty($books)` always returns false when using a collection, even on a non-empty one. This is a PHP limitation. Prefer `$books->isEmpty()`, or `count($books)>0`. - -'''Tip''': If you can't afford updating your code to support collections instead of arrays, you can still ask Propel to generate 1.4-compatible model objects by overriding the `propel.builder.object.class` setting in your `build.properties`, as follows: - -{{{ -#!ini -propel.builder.object.class = builder.om.PHP5ObjectNoCollectionBuilder -}}} - -The `PropelCollection` class offers even more methods that you will soon use a lot: - -{{{ -#!php -getArrayCopy() // get the array inside the collection -$books->toArray() // turn all objects to associative arrays -$books->getPrimaryKeys() // get an array of the primary keys of all the objects in the collection -$books->getModel() // return the model of the collection, e.g. 'Book' -}}} - -Another advantage of using a collection instead of an array is that Propel can hydrate model objects on demand. Using this feature, you'll never fall short of memory again. Available through the `setFormatter()` method of Model Queries, on-demand hydration is very easy to trigger: - -{{{ -#!php -limit(50000) - ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND) // just add this line - ->find(); -foreach ($books as $book) { - echo $book->getTitle(); -} -}}} - -In this example, Propel will hydrate the `Book` objects row by row, after the `foreach` call, and reuse the memory between each iteration. The consequence is that the above code won't use more memory when the query returns 50,000 results than when it returns 5. - -`ModelCriteria::FORMAT_ON_DEMAND` is one of the many formatters provided by the new Query objects. You can also get a collection of associative arrays instead of objects, if you don't need any of the logic stored in your model object, by using `ModelCriteria::FORMAT_ARRAY`. - -The [wiki:Users/Documentation/1.5/ModelCriteria documentation] describes each formatter, and how to use it. - -=== Model Criteria === - -Generated Model Queries inherit from `ModelCriteria`, which extends your good old `Criteria`, and adds a few useful features. Basically, a `ModelCriteria` is a `Criteria` linked to a Model; by using the information stored in the generated TableMaps at runtime, `ModelCriteria` offers powerful methods to simplify the process of writing a query. - -For instance, `ModelCriteria::where()` provides similar functionality to `Criteria::add()`, except that its [http://www.php.net/manual/en/pdostatement.bindparam.php PDO-like syntax] removes the burden of Criteria constants for comparators. - -{{{ -#!php -where('Book.Title LIKE ?', 'War And P%') - ->findOne(); -}}} - -Propel analyzes the clause passed as first argument of `where()` to determine which escaping to use for the value passed as second argument. In the above example, the `Book::TITLE` column is declared as `VARCHAR` in the schema, so Propel will bind the title as a string. - -The `where()` method can also accept more complex clauses. You just need to explicit every column name as `'ModelClassName.ColumnPhpName'`, as follows: - -{{{ -#!php -where('UPPER(Book.Title) LIKE ?', 'WAR AND P%') - ->where('(Book.Price * 100) <= ?', 1500) - ->findOne(); -}}} - -Another great addition of `ModelCriteria` is the `join()` method, which just needs the name of a related model to build a JOIN clause: - -{{{ -#!php -join('Book.Author') - ->where('CONCAT(Author.FirstName, " ", Author.LastName) = ?', 'Leo Tolstoi') - ->find(); -}}} - -`ModelCriteria` has a built-in support for table aliases, which allows to setup a query using two joins on the same table, which was not possible with the `Criteria` object: - -{{{ -#!php -join('b.Author a') // use 'a' as an alias for 'Author' in the query - ->where('CONCAT(a.FirstName, " ", a.LastName) = ?', 'Leo Tolstoi') - ->find(); -}}} - -This syntax probably looks familiar, because it is very close to SQL. So you probably won't need long to figure out how to write a complex query with it. The documentation offers [wiki:Users/Documentation/1.5/ModelCriteria an entire chapter] dedicated to the new `ModelCriteria` class. Make sure you read it to see the power of this new query API. - -=== Criteria Enhancements === - -Generated queries and ModelQueries are not the only ones to have received a lot of attention in Propel 1.5. The Criteria object itself sees a few improvements, that will ease the writing of queries with complex logic. - -`Criteria::addOr()` operates the way you always expected it to. For instance, in Propel 1.4, `addOr()` resulted in a SQL `AND` if called on a column with no other condition: - -{{{ -#!php -add(BookPeer::TITLE, '%Leo%', Criteria::LIKE); -$c->addOr(BookPeer::TITLE, '%Tolstoi%', Criteria::LIKE); -// translates in SQL as -// WHERE (book.TITLE LIKE '%Leo%' OR book.TITLE LIKE '%Tolstoi%') - -// addOr() used to fail on a column with no existing condition -$c = new Criteria(); -$c->add(BookPeer::TITLE, '%Leo%', Criteria::LIKE); -$c->addOr(BookPeer::ISBN, '1234', Criteria::EQUAL); -// translates in SQL as -// WHERE book.TITLE LIKE '%Leo%' AND book.ISBN = '1234' -}}} - -This is fixed in Propel 1.5. This means that you don't need to call upon the `Criterion` object for a simple OR clause: - -{{{ -#!php -add(BookPeer::TITLE, '%Leo%', Criteria::LIKE); -$c->addOr(BookPeer::ISBN, '1234', Criteria::EQUAL); -// translates in SQL as -// WHERE (book.TITLE LIKE '%Leo%' OR book.ISBN = '1234') - -// and it's much faster to write than -$c = new Criteria(); -$c1 = $c->getNewCriterion(BookPeer::TITLE, '%Leo%', Criteria::LIKE); -$c2 = $c->getNewCriterion(BookPeer::ISBN, '1234', Criteria::EQUAL); -$c1->addOr($c2); -$c->add($c1); -}}} - -`add()` and `addOr()` only allow simple logical operations on a single condition. For more complex logic, Propel 1.4 forced you to use Criterions again. This is no longer the case in Propel 1.5, which provides a new `Criteria::combine()` method. It expects an array of named conditions to be combined, and an operator. Use `Criteria::addCond()` to create a condition, instead of the usual `add()`: - -{{{ -#!php -addCond('cond1', BookPeer::TITLE, 'Foo', Criteria::EQUAL); // creates a condition named 'cond1' -$c->addCond('cond2', BookPeer::TITLE, 'Bar', Criteria::EQUAL); // creates a condition named 'cond2' -$c->combine(array('cond1', 'cond2'), Criteria::LOGICAL_OR); // combine 'cond1' and 'cond2' with a logical OR -// translates in SQL as -// WHERE (book.TITLE = 'Foo' OR book.TITLE = 'Bar'); -}}} - -`combine()` accepts more than two conditions at a time: -{{{ -#!php -addCond('cond1', BookPeer::TITLE, 'Foo', Criteria::EQUAL); -$c->addCond('cond2', BookPeer::TITLE, 'Bar', Criteria::EQUAL); -$c->addCond('cond3', BookPeer::TITLE, 'FooBar', Criteria::EQUAL); -$c->combine(array('cond1', 'cond2', 'cond3'), Criteria::LOGICAL_OR); -// translates in SQL as -// WHERE ((book.TITLE = 'Foo' OR book.TITLE = 'Bar') OR book.TITLE = 'FooBar'); -}}} - -`combine()` itself can return a named condition to be combined later. So it allows for any level of logical complexity: - -{{{ -#!php -addCond('cond1', BookPeer::TITLE, 'Foo', Criteria::EQUAL); -$c->addCond('cond2', BookPeer::TITLE, 'Bar', Criteria::EQUAL); -$c->combine(array('cond1', 'cond2'), Criteria::LOGICAL_OR, 'cond12'); - -$c->addCond('cond3', BookPeer::ISBN, '1234', Criteria::EQUAL); -$c->addCond('cond4', BookPeer::ISBN, '4567', Criteria::EQUAL); -$c->combine(array('cond3', 'cond4'), Criteria::LOGICAL_OR, 'cond34'); - -$c->combine(array('cond12', 'cond34'), Criteria::LOGICAL_AND); - -// WHERE (book.TITLE = 'Foo' OR book.TITLE = 'Bar') -// AND (book.ISBN = '1234' OR book.ISBN = '4567'); -}}} - -The new `combine()` method makes it much easier to handle logically complex criterions. The good news is that if your application code already uses the old Criterion way, it will continue to work with Propel 1.5 as all these changes are backwards compatible. - -Of course, since Model Queries extend Criteria, this new feature is available for all your queries, with a slightly different syntax, in order to support column phpNames: - -{{{ -#!php -condition('cond1', 'Book.Title = ?', 'Foo') - ->condition('cond2', 'Book.Title = ?', 'Bar') - ->combine(array('cond1', 'cond2'), Criteria::LOGICAL_OR, 'cond12') - ->condition('cond3', 'Book.ISBN = ?', '1234') - ->condition('cond4', 'Book.ISBN = ?', '4567') - ->combine(array('cond3', 'cond4'), Criteria::LOGICAL_OR, 'cond34') - ->combine(array('cond12', 'cond34'), Criteria::LOGICAL_AND) - ->find(); -// WHERE (book.TITLE = 'Foo' OR book.TITLE = 'Bar') -// AND (book.ISBN = '1234' OR book.ISBN = '4567'); -}}} - -== Many-to-Many Relationships == - -At last, Propel generates the necessary methods to retrieve related objects in a many-to-many relationship. Since this feature is often needed, many developers already wrote these methods themselves. To avoid method collision, the generation of many-to-many getters is therefore optional. - -All you have to do is to add the `isCrossRef` attribute to the cross reference table, and rebuild your model. For instance, if a `User` has many `Groups`, and the `Group` has many `Users`, the many-to-many relationship is materialized by a `user_group` cross reference table: - -{{{ -#!xml - - - -
- - - - -
- - - - - - - - - - -
-}}} - -Then, both end of the relationship see the other end through a one-to-many relationship. That means that you can deal with related objects just like you normally do, without ever creating instances of the cross reference object: - -{{{ -#!php -setName('John Doe'); -$group = new Group(); -$group->setName('Anonymous'); -// relate $user and $group -$user->addGroup($group); -// save the $user object, the $group object, and a new instance of the UserGroup class -$user->save(); - -// retrieve objects as if they shared a one-to-many relationship -$groups = $user->getGroups(); - -// the model query also features a smart filter method for the relation -$groups = GroupPeer::create() - ->filterByUser($user) - ->find(); -}}} - -The syntax should be no surprise, since it's the same as the one for one-to-many relationships. Find more details about many-to-many relationships in the [wiki:Users/Documentation/1.5/Relationships relationships documentation]. - -== New Behaviors == - -The new behavior system, introduced in Propel 1.4, starts to unleash its true power with this release. Three new behaviors implement the most common customizations of object models: `nested_sets`, `sluggable`, and `sortable`. - -=== Nested Set Behavior === - -Using the `treeMode` attribute in a schema, you could turn a Propel model into a hierarchical data store starting with Propel 1.3. This method is now deprecated in favor of a new `nested_set` behavior, that does eactly the same thing, but in a more extensible and effective way. - -The main difference between the two implementations is performance. On the first levels of a large tree, the Propel 1.3 implementation of Nested sets used to consume a very large amount of memory and CPU to retrieve the siblings or the children of a given node. This is no longer true with the new behavior. - -This performance boost comes at a small price: you must add a new "level" column to your nested set models, and let the behavior update this column for the whole tree. - -For instance, if you used nested sets to keep a list of categories, the schema used to look like: - -{{{ -#!xml - - - - - -
-}}} - -The upgrade path is then pretty straightforward: - -1 - Update the schema, by removing the `treeMode` and `nestedSet` attributes and adding the `nested_set` behavior and the `tree_level` column: - -{{{ -#!xml - - - - - - - - - - - -
-}}} - -2 - Rebuild the model - -3 - Change the parent class of your model classes (object and peer) that used the nested set `treeMode`: - -{{{ -#!php - - - - - - - - -}}} - -Now, every time you save a new `Post` object, Propel will compose its slug according to the pattern defined in the behavior parameter and save it in an additional `slug` column: - -{{{ -#!php -setTitle('How Is Life On Earth?'); -$post1->setContent('Lorem Ipsum...'); -$post1->save(); -echo $post1->getSlug(); // '/posts/how-is-life-on-earth' -}}} - -Propel replaces every name enclosed between brackets in the slug pattern by the related column value. It also cleans up the string to make it URL-compatible, and ensures that it is unique. - -If you use this slug in URLs, you will need to retrieve a `Post` object based on it. This is just a one-liner: - -{{{ -#!php -findOneBySlug('/posts/how-is-life-on-earth'); -}}} - -There are many ways to customize the `sluggable` behavior to match the needs of your applications. Check the new [wiki:Users/Documentation/1.5/Behaviors/sluggable sluggable behavior documentation] for more details. - -=== Concrete Table Inheritance Behavior === - -Propel has offered [wiki:Users/Documentation/1.5/Inheritance#SingleTableInheritance Single Table Inheritance] for a long time. But for complex table inheritance needs, it is necessary to provide [http://martinfowler.com/eaaCatalog/concreteTableInheritance.html Concrete Table Inheritance]. Starting with Propel 1.5, this inheritance implementation is supported through the new `concrete_inheritance` behavior. - -In the following example, the `article` and `video` tables use this behavior to inherit the columns and foreign keys of their parent table, `content`: - -{{{ -#!xml - - - - - - - -
- - - -
- - - - - -
- - - - - -
-}}} - -The behavior copies the columns of the parent table to the child tables. That means that the generated `Article` and `Video` models have a `Title` property and a `Category` relationship: - -{{{ -#!php -setName('Movie'); -$cat->save(); -// create a new Article -$art = new Article(); -$art->setTitle('Avatar Makes Best Opening Weekend in the History'); -$art->setCategory($cat); -$art->setContent('With $232.2 million worldwide total, Avatar had one of the best-opening weekends in the history of cinema.'); -$art->save(); -// create a new Video -$vid = new Video(); -$vid->setTitle('Avatar Trailer'); -$vid->setCategory($cat); -$vid->setResourceLink('http://www.avatarmovie.com/index.html') -$vid->save(); -}}} - -If Propel stopped there, the `concrete_inheritance` behavior would only provide a shorcut to avoid repeating tags in the schema. But wait, there is more: the `Article` and `Video` classes actually extend the `Content` class: - -{{{ -#!php -getCategory()->getName(); - } -} -echo $art->getCategoryName(); // 'Movie' -echo $vid->getCategoryName(); // 'Movie' -}}} - -And the true power of Propel's Concrete Table Inheritance is that every time you save an `Article` or a `Video` object, Propel saves a copy of the `title` and `category_id` columns in a `Content` object. Consequently, retrieving objects regardless of their child type becomes very easy: - -{{{ -#!php -find(); -foreach ($conts as $content) { - echo $content->getTitle() . "(". $content->getCategoryName() ")/n"; -} -// Avatar Makes Best Opening Weekend in the History (Movie) -// Avatar Trailer (Movie) -}}} - -The resulting relational model is denormalized - in other terms, data is copied across tables - but the behavior takes care of everything for you. That allows for very effective read queries on complex inheritance structures. - -Check out the brand new [wiki:Users/Documentation/1.5/Inheritance#ConcreteTableInheritance Inheritance Documentation] for more details on using and customizing this behavior. - -=== Sortable Behavior === - -Have you ever enhanced a Propel Model to give it the ability to move up or down in an ordered list? The `sortable` behavior, new in Propel 1.5, offers exactly that... and even more. - -As usual for behaviors, activate `sortable` in your `schema.yml`: - -{{{ -#!xml - - - - - - - - - - - -
-}}} - -Then rebuild your model, and you're done. You have just created an ordered task list for users: - -{{{ -#!php -setTitle('Wash the dishes'); -$t1->setUser($paul); -$t1->save(); -echo $t1->getRank(); // 1 -$t2 = new Task(); -$t2->setTitle('Do the laundry'); -$t2->setUser($paul); -$t2->save(); -echo $t2->getRank(); // 2 -$t3 = new Task(); -$t3->setTitle('Rest a little'); -$t3->setUser($john); -$t3->save() -echo $t3->getRank(); // 1, because John has his own task list - -// retrieve the tasks -$allPaulsTasks = TaskPeer::retrieveList($scope = $paul->getId()); -$allJohnsTasks = TaskPeer::retrieveList($scope = $john->getId()); -$t1 = TaskPeer::retrieveByRank($rank = 1, $scope = $paul->getId()); -$t2 = $t1->getNext(); -$t2->moveUp(); -echo $t2->getRank(); // 1 -echo $t1->getRank(); // 2 -}}} - -This new behavior is fully unit tested and very customizable. Check out all you can do with `sortable` in the [wiki:Users/Documentation/1.5/Behaviors/sortable sortable behavior documentation]. - -=== Timestampable Behavior === - -This behavior is not new, since it was introduced in Propel 1.4. However, with the introduction of model queries, it gains specific query methods that will ease your work when retrieving objects based on their update date: - -{{{ -#!php -recentlyUpdated() // adds a minimum value for the update date - ->lastUpdatedFirst() // orders the results by descending update date - ->find(); -}}} - -== Better `toArray()` == - -When you call `toArray()` on a model object, you can now ask for the related objects: - -{{{ -#!php -toArray($keyType = BasePeer::TYPE_COLNAME, $includeLazyLoadColumns = true, $includeForeignObjects = true); -print_r($bookArray); - => array( - 'Id' => 123, - 'Title' => 'War And Peace', - 'ISBN' => '3245234535', - 'AuthorId' => 456, - 'PublisherId' => 567 - 'Author' => array( - 'Id' => 456, - 'FirstName' => 'Leo', - 'LastName' => 'Tolstoi' - ), - 'Publisher' => array( - 'Id' => 567, - 'Name' => 'Penguin' - ) - ) -}}} - -Only the related objects that were already hydrated appear in the result, so `toArray()` never issues additional queries. Together with the ability to return arrays instead of objects when using `PropelQuery`, this addition will help to debug and optimize model code. - -== Better Oracle Support == - -The Oracle adapter for the generator, the reverse engineering, and the runtime components have been greatly improved. This should provide an easier integration of Propel with an Oracle database. - -== Code Cleanup == - -=== Directory Structure Changes === - -The organization of the Propel runtime and generator code has been reworked, in order to make navigation across Propel classes easier for developers. End users should see no difference, apart if your `build.properties` references alternate builder classes in the Propel code. In that case, you will need to update your `build.properties` with the new paths. For instance, a reference to: - -{{{ -#!ini -propel.builder.peer.class = propel.engine.builder.om.php5.PHP5PeerBuilder -}}} - -Must be changed to: - -{{{ -#!ini -propel.builder.peer.class = builder.om.PHP5PeerBuilder -}}} - -Browse the Propel generator directory structure to find the classes you need. - -=== DebugPDO Refactoring === - -To allow custom connection handlers, the debug code that was written in the `DebugPDO` class has been moved to `PropelPDO`. The change is completely backwards compatible, but makes it easier to connect to a database without using PDO. - -During the change, the [wiki:Users/Documentation/1.5/07-Logging documentation about Propel logging and debugging features] was rewritten and should now be clearer. - -== propel-gen Script Modifications == - -The `propel-gen` script no longer requires a path to the project directory if you call it from a project directory. That means that calling `propel-gen` with a single argument defaults to expecting a task name: - -{{{ -> cd /path/to/my/project -> propel-gen reverse -}}} - -By default, the `propel-gen` command called without a task name defaults to the `main` task (and builds the model, the SQL, and the generation). - -Note: The behavior of the `propel-gen` script when called with one parameter differs from what it used to be in Propel 1.4, where the script expected a path in every situation. So the following syntax won't work anymore: - -{{{ -> propel-gen /path/to/my/project -}}} - -Instead, use either: - -{{{ -> cd /path/to/my/project -> propel-gen -}}} - -or: - -{{{ -> propel-gen /path/to/my/project main -}}} - -== License Change == - -Propel is more open-source than ever. To allow for an easier distribution, the open-source license of the Propel library changes from LGPL3 to MIT. This [http://en.wikipedia.org/wiki/MIT_License MIT License] is also known as the X11 License. - -This change removes a usage restriction enforced by the LGPL3: you no longer need to release any modifications to the core Propel source code under a LGPL compatible license. - -Of course, you still have the right to use, copy, modify, merge, publish, distribute, sublicense, and/or sell Propel. In other terms, you can do whatever you want with the Propel code, without worrying about the license, as long as you leave the LICENSE file within. - -== Miscellaneous == - - * Generated model classes now offer a `fromArray()` and a `toArray()` method by default. This feature existed before, but was disabled by default in the `build.properties`. The `addGenericAccessors` and `addGenericMutators` settings are therefore enabled by default in Propel 1.5. - * You can now prefix all the table names of a database schema by setting the `tablePrefix` attribute of the `` tag. - * The `addIncludes` build property introduced in Propel 1.4 is now set to `false` by default. That means that the runtime autoloading takes care of loading all classes at runtime, including generated Base classes. - * A bugfix in the name generator for related object getter in tables with two foreign keys related to the same table may have introduced problems in applications relying on old (wrong) names. Check your generated base model classes for the `getXXXrelatedByYYY()` and modify the application code relying on it if it exists. A good rule of thumb to avoid problems in such case is to name your relations by using the `phpName` and `refPhpName` attributes in the `` element in the schema. - * XSL transformation of your schemas is no longer enabled by default. Turn the `propel.schema.transform` setting to `true` in your `build.properties` to enable it again. This change removes the requirement on the libxslt extention for Propel. - * `ModelObject::addSelectColumns()` now accepts an additional parameter to allow the use of table aliases - * Added `ModelObject::clear()` to reinitialize a model object - * Added `ModelObject::isPrimaryKeyNull()` method to check of an object was hydrated with no values (in case of a left join) - * Added `Criteria::addSelectModifier($modifier)` to add more than one select modifier (e.g. 'SQL_CALC_FOUND_ROWS', 'HIGH_PRIORITY', etc.) - * Added `PeerClass::addGetPrimaryKeyFromRow()` to retrieve the Primary key from a result row - * Added a new set of constants in the generated Peer class to list column names without the table name (this is `BasePeer::TYPE_RAW_COLNAME`) - * Removed references to Creole in the code (Propel uses PDO instead of Creole since version 1.3) \ No newline at end of file diff --git a/airtime_mvc/library/propel/composer.json b/airtime_mvc/library/propel/composer.json new file mode 100644 index 000000000..0d9c39ac2 --- /dev/null +++ b/airtime_mvc/library/propel/composer.json @@ -0,0 +1,35 @@ +{ + "name": "propel/propel1", + "description": "Propel is an open-source Object-Relational Mapping (ORM) for PHP5.", + "keywords": ["orm", "active record", "mapping", "database", "persistence"], + "homepage": "http://www.propelorm.org/", + "license": "MIT", + "authors": [{ + "name": "William Durand", + "email": "william.durand1@gmail.com", + "homepage": "http://www.willdurand.fr" + }], + "autoload": { + "classmap": ["runtime/lib", "generator/lib"] + }, + "include-path": ["runtime/lib", "generator/lib"], + "require": { + "php": ">=5.2.4", + "phing/phing": "~2.4" + }, + "require-dev": { + "pear-pear.php.net/PEAR_PackageFileManager2": "@stable" + }, + "extra": { + "branch-alias": { + "dev-master": "1.7-dev" + } + }, + "repositories": [ + { + "type": "pear", + "url": "http://pear.php.net" + } + ], + "bin": ["generator/bin/propel-gen", "generator/bin/propel-gen.bat"] +} diff --git a/airtime_mvc/library/propel/contrib/dbd2propel/dbd2propel.xsl b/airtime_mvc/library/propel/contrib/dbd2propel/dbd2propel.xsl deleted file mode 100644 index 852af4ace..000000000 --- a/airtime_mvc/library/propel/contrib/dbd2propel/dbd2propel.xsl +++ /dev/null @@ -1,381 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - true - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TIMESTAMP - LONGVARCHAR - BOOLEAN - BLOB - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - restrict - cascade - setnull - restrict - - - -
diff --git a/airtime_mvc/library/propel/contrib/dbd2propel/transform.php b/airtime_mvc/library/propel/contrib/dbd2propel/transform.php deleted file mode 100644 index 129f19f85..000000000 --- a/airtime_mvc/library/propel/contrib/dbd2propel/transform.php +++ /dev/null @@ -1,21 +0,0 @@ -load('model.xml'); - -// load the transformation stylesheet -$xsl = new DOMDocument; -$xsl->load('dbd2propel.xsl'); - -$proc = new XSLTProcessor(); -// attach the xsl rules -$proc->importStyleSheet($xsl); - -$schema_xml = $proc->transformToXML($xml); - -file_put_contents('schema.xml', $schema_xml); diff --git a/airtime_mvc/library/propel/contrib/pat/patForms.php b/airtime_mvc/library/propel/contrib/pat/patForms.php deleted file mode 100644 index a1c66a135..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms.php +++ /dev/null @@ -1,2784 +0,0 @@ - - * @author gERD Schaufelberger - * @author Stephan Schmidt - * @copyright 2003-2004 PHP Application Tools - * @license LGPL - * @link http://www.php-tools.net - */ - -/** - * set the include path - */ -if ( !defined( 'PATFORMS_INCLUDE_PATH' ) ) { - define( 'PATFORMS_INCLUDE_PATH', dirname( __FILE__ ). '/patForms' ); -} - -/** - * needs helper methods of patForms_Element - */ -include_once PATFORMS_INCLUDE_PATH . "/Element.php"; - -/** - * error definition: renderer base class file (renderers/_base.php) could not - * be found. - * - * @see patForms::_createModule() - */ -define( "PATFORMS_ERROR_NO_MODULE_BASE_FILE", 1001 ); - -/** - * error definition: the specified renderer could not be found. - * - * @see patForms::_createModule() - */ -define( "PATFORMS_ERROR_MODULE_NOT_FOUND", 1002 ); - -/** - * error definition: the element added via the {@link patForms::addElement()} - * is not an object. Use the {@link patForms::createElement()} method to - * create an element object. - * - * @see patForms::addElement() - * @see patForms::createElement() - */ -define( "PATFORMS_ERROR_ELEMENT_IS_NO_OBJECT", 1003 ); - -/** - * error definition: generic unexpected error. - */ -define( "PATFORMS_ERROR_UNEXPECTED_ERROR", 1004 ); - -/** - * element does not exist - */ -define( "PATFORMS_ERROR_ELEMENT_NOT_FOUND", 1012 ); - -/** - * renderer object has not been set - if you want to render the form, you have to - * set a renderer object via the {@link patForms::setRenderer()} method. To create - * a renderer, use the {@link patForms::createRenderer()} method. - * - * @see patForms::setRenderer() - * @see patForms::createRenderer() - */ -define( "PATFORMS_ERROR_NO_RENDERER_SET", 1013 ); - -/** - * invalid renderer - * - * @see createRenderer() - */ -define( "PATFORMS_ERROR_INVALID_RENDERER", 1014 ); - -/** - * invalid method - * - * @see setMethod() - */ -define( "PATFORMS_ERROR_INVALID_METHOD", 1015 ); - -/** - * Given parameter is not a boolean value - */ -define( "PATFORMS_ERROR_PARAMETER_NO_BOOL", 1016 ); - -/** - * Given Static property does not exist - */ -define( "PATFORMS_ERROR_NO_STATIC_PROPERTY", 1017 ); - -/** - * Unknown event - */ -define( "PATFORMS_ERROR_UNKNOWN_EVENT", 1018 ); - -/** - * Invalid event handler - */ -define( "PATFORMS_ERROR_INVALID_HANDLER", 1019 ); - -/** - * Event exists - */ -define( 'PATFORMS_NOTICE_EVENT_ALREADY_REGISTERED', 1020 ); - -/** - * Invalid storage container - */ -define( 'PATFORMS_ERROR_INVALID_STORAGE', 1021 ); - -define( 'PATFORMS_NOTICE_ARRAY_EXPECTED', 1022 ); - -define( 'PATFORMS_NOTICE_ATTRIBUTE_NOT_SUPPORTED', 1023 ); - -define( 'PATFORMS_NOTICE_INVALID_OPTION', 1024 ); - -define( 'PATFORMS_ERROR_ATTRIBUTE_REQUIRED', 1025 ); - -define( 'PATFORMS_ERROR_CAN_NOT_VERIFY_FORMAT', 1026 ); - -define( 'PATFORMS_ERROR_METHOD_FOR_MODE_NOT_AVAILABLE', 1027 ); - - -/** - * errors apply on translating errors matching current locale settings - */ -define( 'PATFORMS_NOTICE_VALIDATOR_ERROR_LOCALE_UNDEFINED', 1028 ); -define( 'PATFORMS_WARNING_VALIDATOR_ERROR_UNDEFINED', 1029 ); - -/** - * apply the rule before the built-in validation - */ -define( 'PATFORMS_RULE_BEFORE_VALIDATION', 1 ); - -/** - * apply the rule after the built-in validation - */ -define( 'PATFORMS_RULE_AFTER_VALIDATION', 2 ); - -/** - * apply the rule before AND after the built-in validation - */ -define( 'PATFORMS_RULE_BOTH', 3 ); - -/** - * attach the observer to the elements - */ -define( 'PATFORMS_OBSERVER_ATTACH_TO_ELEMENTS', 1 ); - -/** - * attach the observer to the form - */ -define( 'PATFORMS_OBSERVER_ATTACH_TO_FORM', 2 ); - -/** - * attach the observer to the form and the elements - */ -define( 'PATFORMS_OBSERVER_ATTACH_TO_BOTH', 3 ); - -/** - * group values should stay nested - */ -define('PATFORMS_VALUES_NESTED', 0); - -/** - * group values should be flattened - */ -define('PATFORMS_VALUES_FLATTENED', 1); - -/** - * group values should be prefixed - */ -define('PATFORMS_VALUES_PREFIXED', 2); - -/** - * Static patForms properties - used to emulate pre-PHP5 static properties. - * - * @see setStaticProperty() - * @see getStaticProperty() - */ -$GLOBALS['_patForms'] = array( - 'format' => 'html', - 'locale' => 'C', - 'customLocales' => array(), - 'autoFinalize' => true, - 'defaultAttributes' => array(), -); - -/** - * patForms form manager class - serialize form elements into any given output format - * using element classes, and build the output via renderer classes. - * - * @package patForms - * @author Sebastian Mordziol - * @author gERD Schaufelberger - * @author Stephan Schmidt - * @copyright 2003-2004 PHP Application Tools - * @license LGPL - * @link http://www.php-tools.net - * @version 0.9.0alpha - * @todo check the clientside functionality, as that can lead to broken pages - */ -class patForms -{ - /** - * javascript that will displayed only once - * - * @access private - * @var array - */ - var $globalJavascript = array(); - - /** - * javascript that will be displayed once per instance - * - * @access private - * @var array - */ - var $instanceJavascript = array(); - - /** - * stores the mode for the form. It defaults to 'default', and is only overwritten if - * set specifically. It is passed on to any elements you create. - * - * @access private - * @see setMode() - */ - var $mode = 'default'; - - /** - * XML entities - * - * @access private - * @see toXML() - * @todo This is redundant to the Element's xmlEntities property - find a way to keep this in one place - */ - var $xmlEntities = array( - "<" => "<", - ">" => ">", - "&" => "&", - "'" => "'", - '"' => """ - ); - - /** - * stores the format for the element. It defaults to 'html', and is only overwritten if - * set specifically. It is passed on to any elements you create. - * - * @access private - * @see setFormat() - */ - var $format = 'html'; - - /** - * stores the flag telling the form whether it has been submitted - this is passed on to any - * elements you create. - * - * @access private - * @see setSubmitted() - */ - var $submitted = false; - - /** - * stores the element objects of this form. - * @access private - * @see addElement() - */ - var $elements = array(); - - /** - * stores the current element count for this form, used to generate the ids for each element - * @access private - * @see getElementId() - */ - var $elementCounter = 0; - - /** - * stores a renderer - * @access private - * @see setRenderer(), renderForm() - */ - var $renderer = null; - - /** - * stores the locale to use when adding validation errors for the whole form. - * - * @access private - * @var string $locale - * @see setLocale() - */ - var $locale = 'C'; - - /** - * stores custom locale - * - * @access private - * @var array - * @see setLocale() - */ - var $customLocales = array(); - - /** - * stores the element name - * @access private - * @see getElementName() - */ - var $elementName = 'Form'; - - /** - * flag to indicate, whether form should be validated automatically - * by renderForm() - * - * @access private - * @var string - * @see setAutoValidate(), renderForm() - */ - var $autoValidate = false; - - /** - * name of the variable that indicates, whether the form has - * been submitted. - * - * @access private - * @var string - * @see setAutoValidate() - */ - var $submitVar = null; - - /** - * event handlers - * - * @access private - * @var array - * @see registerEventHandler() - * @see registerEvent() - */ - var $_eventHandler = array(); - - /** - * events that can be triggered - * - * @access private - * @var array - * @see registerEventHandler() - * @see triggerEvent() - * @see registerEvent() - */ - var $_validEvents = array( 'onInit', 'onValidate', 'onSubmit', 'onError', 'onSuccess' ); - - /** - * Stores whether the current form has been validated - * - * @access private - */ - var $validated = false; - - /** - * Stores whether the current form is valid or not (after the - * validation process) - * - * @access private - */ - var $valid = null; - - /** - * Stores the names of all static properties that patForms will use as defaults - * for the properties with the same name on startup. - * - * @access private - */ - var $staticProperties = array( - 'format' => 'setFormat', - 'autoFinalize' => 'setAutoFinalize', - 'locale' => 'setLocale', - ); - - /** - * Stores the flag for the autoFinalize feature - * - * @access private - */ - var $autoFinalize = true; - - /** - * custom validation rules - * - * @access private - * @var array - */ - var $_rules = array(); - - /** - * define error codes an messages for the form - * - * Will be set by validation rules that have been - * added to the form. - * - * @access private - * @var array $validatorErrorCodes - */ - var $validatorErrorCodes = array(); - - /** - * stores any validation errors that can occurr during the - * form's validation process. - * - * @access private - * @var array $validationErrors - */ - var $validationErrors = array(); - - /** - * next error offset for rules - * @access private - * @var integer - */ - var $nextErrorOffset = 1000; - - /** - * Attributes of the form - needed to generate the form tag - * - * @access private - * @var array $attributes - * @see setAttribute() - */ - var $attributes = array(); - - /** - * Attribute definition for the form - defines which attribute the form - * itself supports. - * - * @access public - */ - var $attributeDefinition = array( - - 'id' => array( - 'required' => false, - 'format' => 'string', - 'outputFormats' => array( 'html' ), - ), - - 'name' => array( - 'required' => true, - 'format' => 'string', - 'outputFormats' => array( 'html' ), - ), - - 'method' => array( - 'required' => true, - 'format' => 'string', - 'default' => 'post', - 'outputFormats' => array( 'html' ), - ), - - 'action' => array( - 'required' => true, - 'format' => 'string', - 'outputFormats' => array( 'html' ), - ), - - 'accept' => array( - 'required' => false, - 'format' => 'string', - 'outputFormats' => array( 'html' ), - ), - - 'accept-charset' => array( - 'required' => false, - 'format' => 'string', - 'outputFormats' => array( 'html' ), - ), - - 'enctype' => array( - 'required' => false, - 'format' => 'string', - 'outputFormats' => array( 'html' ), - ), - - 'onreset' => array( - 'required' => false, - 'format' => 'string', - 'outputFormats' => array( 'html' ), - ), - - 'onsubmit' => array( - 'required' => false, - 'format' => 'string', - 'outputFormats' => array( 'html' ), - ), - - 'target' => array( - 'required' => false, - 'format' => 'string', - 'outputFormats' => array( 'html' ), - ), - ); - - /** - * Stores all available patForms options - these are inherited by all elements - * and their dependencies, like rules. - * - * Short option overview: - * - * - scripts: enable client script integration - * - * @access public - */ - var $options = array( - - 'scripts' => array( - 'enabled' => true, - 'params' => array(), - ), - - ); - - /** - * observers of the form - * - * @access private - * @var array - */ - var $observers = array(); - - /** - * Sets the default attributes that will be inherited by any elements you add to the form. - * - * Note: You have to call this method statically before creating a new form if you use - * patForm's automatic element creation feature via the {@link createForm()} method, as the - * default attributes cannot be set after an element has been created. - * - * @static - * @access public - * @param array $attributes The list of attributes to set with key => value pairs. - */ - function setDefaultAttributes( $attributes ) - { - patForms::setStaticProperty( 'defaultAttributes', $attributes ); - } - - /** - * sets the locale (language) to use for the validation error messages of all elements - * in the form. - * - * @access public - * @param string language code - * @param string optional language file - * @return bool True on success - */ - function setLocale( $locale, $languageFile = null ) - { - if (!is_null($languageFile)) { - $languageData = patForms::parseLocaleFile($languageFile); - - $customLocales = patForms::getStaticProperty('customLocales'); - $customLocales[$locale] = $languageData; - patForms::setStaticProperty('customLocales', $customLocales); - } - - if ( isset( $this ) && is_a( $this, 'patForms' ) ) { - $this->locale = $locale; - - if ( !empty( $this->elements ) ) { - $cnt = count( $this->elements ); - for ( $i=0; $i < $cnt; $i++ ) { - $this->elements[$i]->setLocale( $locale ); - } - } - } else { - patForms::setStaticProperty('locale', $locale); - } - - return true; - } - - /** - * checks, whether a locale is a custom locale - * - * @static - * @access public - * @param string locale name - * @return boolean - */ - function isCustomLocale($locale) - { - $customLocales = patForms::getStaticProperty('customLocales'); - if (isset($customLocales[$locale])) { - return true; - } - return false; - } - - /** - * get the custom locale for an element or a rule - * - * @static - * @access public - * @param string locale - * @param string key - * @return array - */ - function getCustomLocale($locale, $key) - { - $customLocales = patForms::getStaticProperty('customLocales'); - if (!isset($customLocales[$locale])) { - return false; - } - if (!isset($customLocales[$locale][$key])) { - return false; - } - return $customLocales[$locale][$key]; - } - - /** - * parses a locale file - * - * @access private - * @param string filename - * @return array locale information - * @todo add some file checks - */ - function parseLocaleFile($filename) - { - return parse_ini_file($filename, true); - } - - /** - * sets the format of the element - this will be passed on to any elements you create. If you - * have already added some elements when you call this method, it will be passed on to them too. - * - * @access public - * @param string $format The name of the format you have implemented in your element(s). - * @return bool $result True on success - * @see setMode() - * @see format - * @see serialize() - */ - function setFormat( $format ) - { - if ( isset( $this ) && is_a( $this, 'patForms' ) ) - { - $this->format = strtolower( $format ); - - if ( !empty( $this->elements ) ) - { - $cnt = count( $this->elements ); - for ( $i=0; $i < $cnt; $i++ ) - { - $this->elements[$i]->setFormat( $format ); - } - } - } - else - { - patForms::setStaticProperty( 'format', $format ); - } - - return true; - } - - /** - * sets the mode of the form - If you have already added some elements when you call this - * method, it will be passed on to them too. - * - * @access public - * @param string $mode The mode to set the form to: default|readonly or any other mode you have implemented in your element class(es). Default is 'default'. - * @see setMode() - * @see mode - * @see serialize() - */ - function setMode( $mode ) - { - $this->mode = strtolower( $mode ); - - if ( !empty( $this->elements ) ) - { - $cnt = count( $this->elements ); - for ( $i=0; $i < $cnt; $i++ ) - { - $this->elements[$i]->setMode( $mode ); - } - } - } - - /** - * sets the current submitted state of the form. Set this to true if you want the form - * to pick up its submitted data. It will pass on this information to all elements that - * have been added so far, and new ones inherit it too. - * - * @access public - * @param bool $state True if it has been submitted, false otherwise (default). - * @see isSubmitted() - * @see submitted - */ - function setSubmitted( $state ) - { - if ( $state == true ) - { - $eventState = $this->triggerEvent( 'Submit' ); - if ( $eventState === false ) - return false; - } - - $this->submitted = $state; - - if ( !empty( $this->elements ) ) - { - $cnt = count( $this->elements ); - for ( $i=0; $i < $cnt; $i++ ) - { - $this->elements[$i]->setSubmitted( $state ); - } - } - - return $state; - } - - /** - * sets the method for the request - * - * @access public - * @param string $method GET or POST - * @see method - * @uses setAttribute() - */ - function setMethod( $method ) - { - $method = strtolower( $method ); - - if ( $method != 'get' && $method != 'post' ) - { - return patErrorManager::raiseError( - PATFORMS_ERROR_INVALID_METHOD, - 'Unknown method "'.$method.'". Currently only GET and POST are supported as patForms methods.' - ); - } - $this->setAttribute( 'method', $method ); - return true; - } - - /** - * sets the action for the form - * - * This is a only a wrapper for setAttribute() - * - * @access public - * @param string $action - * @see setAttribute() - */ - function setAction( $action ) - { - return $this->setAttribute( 'action', $action ); - } - - /** - * Sets the AutoFinalize mode for the form. The AutoFinalize mode will tell patForms to - * finalize all elements after the form has been validated successfully. - * - * @access public - * @param boolean $mode Whether to activate the AutoFinalize mode (true) or not (false). - * @return boolean $success True if okay, a patError object otherwise. - * @see finalizeForm() - */ - function setAutoFinalize( $mode ) - { - if ( !is_bool( $mode ) ) - { - return patErrorManager::raiseError( - PATFORMS_ERROR_PARAMETER_NO_BOOL, - 'The setAutoFinalize() method requires a boolean value ( true or false ) as parameter.' - ); - } - - if ( isset( $this ) && is_a( $this, 'patForms' ) ) - { - $this->autoFinalize = $mode; - } - else - { - patForms::setStaticProperty( 'autoFinalize', $mode ); - } - - return true; - } - - /** - * Wrapper method that adds a filter to all elements - * of the form at once instead of having to do it for - * each element. - * - * @access public - * @param object &$filter The filter object to apply - * @see patForms_Element::applyFilter() - * @todo add error management and docs once the element's applyFilter method has too - */ - function applyFilter( &$filter ) - { - if ( empty( $this->elements ) ) - return true; - - $cnt = count( $this->elements ); - - for ( $i = 0; $i < $cnt; $i++ ) - { - $this->elements[$i]->applyFilter( $filter ); - } - } - - /** - * creates a new patForms object and returns it; this method is made to be called statically - * to be able to create a new patForms object from anywhere. - * - * @access public - * @param array $formDefinition Optional form definition for elements that will be added to the form - * @param array $attributes The attributes to set for the form itself - * @return object patForms $form The new patForms object. - * @todo it should be possible to pass Rule definitions, so they can be loaded and added automatically. - */ - function &createForm( $formDefinition = null, $attributes = null ) - { - $form = &new patForms(); - - if ( $attributes != null ) - { - $form->setAttributes( $attributes ); - } - - if ( $formDefinition === null ) - return $form; - - foreach ( $formDefinition as $name => $element ) - { - if ( !isset( $element["filters"] ) ) - { - $element["filters"] = null; - } - if ( !isset( $element["children"] ) ) - { - $element["children"] = null; - } - - $el = &$form->createElement( $name, $element["type"], $element["attributes"], $element["filters"], $element["children"] ); - - if ( isset( $element["renderer"] ) ) { - $el->setRenderer( $element["renderer"] ); - } - - $result = $form->addElement( $el ); - if (patErrorManager::isError( $result )) { - return $result; - } - } - return $form; - } - - /** - * add a custom validation rule - * - * @access public - * @param object patForms_Rule validation rule - * @param integer time to apply rule (before or after built-in validation) - * @param boolean apply the rule, even if the form is invalid - * @param boolean should form get revalidated (not implemented yet) - * @return boolean currently always true - */ - function addRule( &$rule, $time = PATFORMS_RULE_AFTER_VALIDATION, $invalid = false, $revalidate = false ) - { - $rule->prepareRule( $this ); - - $this->_rules[] = array( - 'rule' => &$rule, - 'time' => $time, - 'invalid' => $invalid, - 'revalidate' => $revalidate - ); - } - - /** - * patForms PHP5 constructor - processes some intitialization tasks like merging the currently - * set static properties with the internal properties. - * - * @access public - */ - function __construct() - { - foreach ( $this->staticProperties as $staticProperty => $setMethod ) - { - $propValue = patForms::getStaticProperty( $staticProperty ); - if ( patErrorManager::isError( $propValue ) ) - continue; - - $this->$setMethod( $propValue ); - } - - // initialize patForms internal attribute collection - $this->loadAttributeDefaults(); - } - - /** - * patForms pre-PHP5 constructor - does nothing for the moment except being a wrapper - * for the PHP5 contructor for older PHP versions support. - * - * @access public - */ - function patForms() - { - patForms::__construct(); - } - - /** - * sets a renderer object that will be used to render - * the form. - * - * @access public - * @param object &$renderer The renderer object - * @return mixed $success True on success, patError object otherwise. - * @see createRenderer() - * @see renderForm() - */ - function setRenderer( &$renderer, $args = array() ) - { - if ( !is_object( $renderer ) ) - { - return patErrorManager::raiseError( - PATFORMS_ERROR_INVALID_RENDERER, - 'You can only set a patForms_Renderer object with the setRenderer() method, "'.gettype( $renderer ).'" given.' - ); - } - - $this->renderer = &$renderer; - - if ( isset( $args['includeElements'] ) && $args['includeElements'] === true ) - { - // check all elements - there may be some that need - // renderers too, so we give them the same renderer if - // they don't already have one. - $cnt = count( $this->elements ); - for ( $i = 0; $i < $cnt; $i++ ) - { - if ( $this->elements[$i]->usesRenderer && !is_object( $this->elements[$i]->renderer ) ) - { - $this->elements[$i]->setRenderer( $renderer ); - } - } - } - - return true; - } - - /** - * sets a storage container object that will be used to store data - * - * @access public - * @param object patForms_Storage - * @see createStorage() - */ - function setStorage( &$storage ) - { - if ( !is_object( $storage ) ) - { - return patErrorManager::raiseError( - PATFORMS_ERROR_INVALID_STORAGE, - 'You can only set a patForms_Storage object with the setStorage() method, "'.gettype( $storage ).'" given.' - ); - } - - $this->registerEventHandlerObject( $storage, - array( - 'onInit' => 'loadEntry', - 'onValidate' => 'validateEntry', - 'onSuccess' => 'storeEntry' - ) - ); - } - - /** - * renders the form with the renderer that was set via the {@link setRenderer()} - * method. - * - * WARNING: This is still in alpha state! - * - * Should this method return a reference?? - * The return value could contain large blocks of HTML or large arrays! - * Do we want to copy these? - * - * @access public - * @param mixed $args arguments that will be passed to the renderer - * @return mixed $form The rendered form, or false if failed. - */ - function renderForm( $args = null ) - { - if ( $this->renderer === null ) - { - return patErrorManager::raiseError( - PATFORMS_ERROR_NO_RENDERER_SET, - 'Form cannot be rendered, you have to set a renderer first via the setRenderer() method.' - ); - } - - // form is not submitted, or auto-validation is disabled => render it - if ( !$this->isSubmitted() || $this->autoValidate !== true ) - { - $this->triggerEvent( 'Init' ); - return $this->renderer->render( $this, $args ); - } - - $this->validateForm(); - - return $this->renderer->render( $this, $args ); - } - - /** - * Validates all elements of the form. - * - * @access public - * @param boolean Flag to indicate, whether form should be validated again, if it already has been validated. - * @return boolean True if all elements could be validated, false otherwise. - * @see finishForm() - */ - function validateForm( $revalidate = false ) - { - if ( $this->validated && !$revalidate ) - return $this->valid; - - $valid = true; - - /** - * validate custom rules - */ - if ( !$this->_applyRules( PATFORMS_RULE_BEFORE_VALIDATION ) ) - { - $valid = false; - } - - /** - * validate elements - */ - if ( $valid === true ) - { - $cnt = count( $this->elements ); - for ( $i = 0; $i < $cnt; ++$i ) - { - if ( !$this->elements[$i]->validate() ) - { - $valid = false; - } - } - } - - if ($valid === true) { - $result = $this->triggerEvent('Validate'); - if ($result === false) { - $valid = false; - } - } - - /** - * validate custom rules - */ - if ( !$this->_applyRules( PATFORMS_RULE_AFTER_VALIDATION, $valid ) ) - { - $valid = false; - } - - if ( $valid === true && $this->autoFinalize === true ) - $this->finalizeForm(); - - $this->valid = $valid; - - $this->validated = true; - - if ( $valid === true ) - { - $this->_announce( 'status', 'validated' ); - $event = 'Success'; - } - else - { - $this->_announce( 'status', 'error' ); - $event = 'Error'; - } - - $this->triggerEvent( $event ); - - return $this->valid; - } - - /** - * apply rules - * - * @access private - * @param integer time of validation - * @param boolean form is valid - * @return boolean rules are valid or not - * @todo add documentation - */ - function _applyRules( $time, $isValid = true ) - { - $valid = true; - - $cnt = count( $this->_rules ); - for ($i = 0; $i < $cnt; $i++) { - - // wrong time - if (( $this->_rules[$i]['time'] & $time ) != $time) { - continue; - } - if (!$isValid && !$this->_rules[$i]['invalid']) { - continue; - } - - $result = $this->_rules[$i]['rule']->applyRule( $this, PATFORMS_RULE_AFTER_VALIDATION ); - if ( $result === false ) { - $valid = false; - } - } - return $valid; - } - - /** - * Finalizes the form by telling each fom element to finalize - finalizing means to - * process any tasks that need to be done after the form has been validated, like - * deleting any temporary files or whatever an element needs to do at that point. - * - * @access public - * @return bool $success Wether all elements could be finalized - * @see validateForm() - */ - function finalizeForm() - { - $success = true; - - $cnt = count( $this->elements ); - for ( $i = 0; $i < $cnt; ++$i ) - { - if ( !$this->elements[$i]->finalize() ) - { - patErrorManager::raiseWarning( - PATFORMS_ERROR_ELEMENT_NOT_FINALIZED, - 'Element "'.$this->elements[$i]->elementName.'" could not be finalized. See the element error messages for more details.' - ); - - $success = false; - } - } - - return $success; - } - - /** - * creates a new renderer from the patForms renderer collection and returns it. - * - * @access public - * @param string The name of the renderer to create - have a look at the Renderer/ subfolder for a list of available renderers. - * @return object patForms_Renderer The renderer object, or error object - */ - function &createRenderer( $name ) - { - return patForms::_createModule( 'Renderer', $name ); - } - - /** - * creates a new storage container and returns it. - * - * @access public - * @param string The name of the storage to create - have a look at the Storage/ subfolder for a list of available storage containers. - * @return object patForms_Storage The storage container, or error object - */ - function &createStorage( $name ) - { - return patForms::_createModule( 'Storage', $name ); - } - - /** - * Creates a new filter and returns it. - * - * You may pass an array as second parameter that contains - * parameters for the filter. patForms will check for setter methods - * for all keys and set the corresponding values. - * - * This eases the creating of simple filter objects. - * - * @access public - * @param string The name of the filter to create - have a look at the Filter/ subfolder for a list of available filters. - * @param array Optional parameters for the filter, if you provide a parameter, make sure the filter implements a set[Paramname]() method. - * This will be automated with interceptors in the PHP5 version of patForms - * @return object patForms_Filter The filter, or error object - */ - function &createFilter( $name, $params = null ) - { - $filter = &patForms::_createModule( 'Filter', $name ); - - if ( !is_array( $params ) ) - { - return $filter; - } - - foreach ( $params as $param => $value ) - { - $setter = 'set' . ucfirst( $param ); - if ( method_exists( $filter, $setter ) ) - { - $filter->$setter( $value ); - } - } - return $filter; - } - - /** - * creates a new rule from the patForms rule collection and returns it. - * - * If your rules are not located in patForms/Rule you have to load and - * instantiate them on your own. - * - * @access public - * @param string The name of the rule to create - have a look at the Rule/ subfolder for a list of available rules. - * @param string The id of the rule, needed if the rule uses client side actions. - * @return object patForms_Rule The rule object, or error object - */ - function &createRule( $name, $id = null ) - { - $rule = &patForms::_createModule( 'Rule', $name ); - if ( $id != null ) - { - $rule->setId( $id ); - } - return $rule; - } - - /** - * creates a new observer from the patForms observer collection and returns it. - * - * If your observers are not located in patForms/Observer you have to load and - * instantiate them on your own. - * - * @access public - * @param string The name of the observer to create - have a look at the Observer/ subfolder for a list of available observers. - * @return object patForms_Observer The observer object, or error object - */ - function &createObserver( $name ) - { - $observer = &patForms::_createModule( 'Observer', $name ); - - return $observer; - } - - /** - * creates a new module for patForms - * - * @access private - * @param string $type type of the module. Possible values are 'Renderer', 'Rule' - * @param string $name The name of the renderer to create - have a look at the renderers/ subfolder for a list of available renderers. - * @return object $module The module object, or an error object - */ - function &_createModule( $type, $name ) - { - $baseFile = PATFORMS_INCLUDE_PATH . '/'.$type.'.php'; - $baseClass = 'patForms_'.$type; - - // if there is an underscore in the module name, we want - // to load the module from a subfolder, so we transform - // all underscores to slashes. - $pathName = $name; - if ( strstr( $pathName, '_' ) ) - { - $pathName = str_replace( '_', '/', $name ); - } - - $moduleFile = PATFORMS_INCLUDE_PATH . '/'.$type.'/'.$pathName.'.php'; - $moduleClass = 'patForms_'.$type.'_'.$name; - - if ( !class_exists( $baseClass ) ) - { - if ( !file_exists( $baseFile ) ) - { - return patErrorManager::raiseError( - PATFORMS_ERROR_NO_MODULE_BASE_FILE, - $type .' base file could not be found', - 'Tried to load base file in path "'.$baseFile.'"' - ); - } - - include_once $baseFile; - } - - if ( !class_exists( $moduleClass ) ) - { - if ( !file_exists( $moduleFile ) ) - { - return patErrorManager::raiseError( - PATFORMS_ERROR_MODULE_NOT_FOUND, - $type.' "'.$name.'" file "'.$moduleFile. '" could not be found.' - ); - } - - include_once $moduleFile; - } - - $module = &new $moduleClass(); - - return $module; - } - - /** - * adds an element to the form - has to be a patForms_Element object. Use the {@link createElement()} - * method to create a new element object. Also takes care of passing on the form's configuration - * including the mode, format and submitted flags to the element. - * - * @access public - * @param object &$element The patForms_Element object to add to this form. - * @return bool $success True if everything went well, false otherwise. - * @see patForms_Element - * @see createElement() - */ - function addElement( &$element ) - { - if ( !is_object( $element ) ) - { - return patErrorManager::raiseError( - PATFORMS_ERROR_ELEMENT_IS_NO_OBJECT, - 'The addElement() method expects an element object, "'.gettype( $element ).'" given.' - ); - } - - if ( patErrorManager::isError( $element ) ) - { - return patErrorManager::raiseError( - PATFORMS_ERROR_UNEXPECTED_ERROR, - 'The element you are trying to add is a patError object, and not a patForms element object.' - ); - } - - if ( !$element->getId() ) { - $element->setId( $this->getElementId() ); - } - $element->setMode( $this->getMode() ); - $element->setFormat( $this->getFormat() ); - $element->setSubmitted( $this->isSubmitted() ); - $element->setLocale( $this->getLocale() ); - - $this->elements[] =& $element; - - return true; - } - - /** - * replaces an element in the form - * - * @access public - * @param object $element The patForms_Element object to be replaced - * @param object &$replace The element that will replace the old element - * @return bool $success True if everything went well, false otherwise. - * @see patForms_Element - * @see addElement() - */ - function replaceElement( $element, &$replace ) - { - if ( !is_object( $replace ) ) { - return patErrorManager::raiseError( - PATFORMS_ERROR_ELEMENT_IS_NO_OBJECT, - 'The addElement() method expects an element object, "'.gettype( $replace ).'" given.' - ); - } - - if ( patErrorManager::isError( $replace ) ) { - return patErrorManager::raiseError( - PATFORMS_ERROR_UNEXPECTED_ERROR, - 'The element you are trying to add is a patError object, and not a patForms element object.' - ); - } - - if (is_object($element)) { - $element = $element->getId(); - } - - $cnt = count($this->elements); - for ($i = 0; $i < $cnt; $i++) { - if ($this->elements[$i]->getId() === $element) { - - if ( !$replace->getId() ) { - $replace->setId( $this->getElementId() ); - } - $replace->setMode( $this->getMode() ); - $replace->setFormat( $this->getFormat() ); - $replace->setSubmitted( $this->isSubmitted() ); - $replace->setLocale( $this->getLocale() ); - - $this->elements[$i] = &$replace; - return true; - } - - // the current element is a container - if (method_exists($this->elements[$i], 'replaceElement')) { - $result = $this->elements[$i]->replaceElement($element, $replace); - if ($result === true) { - return $result; - } - } - } - - return false; - } - - /** - * Get an element by its name. - * - * @access public - * @param string $name name of the element - * @return object patForms element - * @deprecated please use patForms::getElementByName() instead - */ - function &getElement( $name ) - { - return $this->getElementByName( $name ); - } - - /** - * Get an element by its name. - * - * @access public - * @param string $name name of the element - * @return mixed either a patForms element or an array containing patForms elements - * @see getElementById() - */ - function &getElementByName( $name ) - { - if ( $name == '__form' ) { - return $this; - } - - $elements = array(); - $cnt = count( $this->elements ); - for ($i = 0; $i < $cnt; $i++) { - if ($this->elements[$i]->getName() == $name) { - $elements[] = &$this->elements[$i]; - continue; - } - if (method_exists($this->elements[$i], 'getElementById')) { - patErrorManager::pushExpect(PATFORMS_ERROR_ELEMENT_NOT_FOUND); - $result = &$this->elements[$i]->getElementByName($name); - patErrorManager::popExpect(); - if (!patErrorManager::isError($result)) { - if (is_array($result)) { - $cnt2 = count( $result ); - for ($j = 0; $j < $cnt2; $j++) { - $elements[] = &$result[$j]; - } - } else { - $elements[] = &$result; - } - } - } - } - - switch( count( $elements ) ) - { - case 0: - return patErrorManager::raiseError( - PATFORMS_ERROR_ELEMENT_NOT_FOUND, - 'Element '.$name.' could not be found.' - ); - break; - case 1: - return $elements[0]; - break; - default: - return $elements; - break; - } - } - - /** - * Get an element by its id. - * - * @access public - * @param string $id id of the element - * @return object patForms element - */ - function &getElementById( $id ) - { - $cnt = count( $this->elements ); - for ( $i = 0; $i < $cnt; $i++ ) - { - if ( $this->elements[$i]->getId() == $id ) { - return $this->elements[$i]; - } - if (method_exists($this->elements[$i], 'getElementById')) { - patErrorManager::pushExpect(PATFORMS_ERROR_ELEMENT_NOT_FOUND); - $result = &$this->elements[$i]->getElementById($id); - patErrorManager::popExpect(); - if (!patErrorManager::isError($result)) { - return $result; - } - } - } - return patErrorManager::raiseError( - PATFORMS_ERROR_ELEMENT_NOT_FOUND, - 'Element '.$name.' could not be found.' - ); - } - - /** - * Get all elements of the form - * - * @access public - * @return array all elements of the form - */ - function &getElements() - { - return $this->elements; - } - - /** - * Creates a new form element and returns a reference to it. - * - * The optional $filters array has to be in the following format: - * - *
-	* array(
-	*       array(
-	*              'filter' => 'Multiplier',
-	*              'params' => array( 'multiplier' => 6 )
-	*            )
-	*	   )
-	* 
- * - * @access public - * @param string $name The name of the element - * @param string $type The type of the element; for a list of possible elements, have a look at the elements/ subfolder of the patForms package. - * @param array $attributes Attributes for the element - * @param array $filters Optional filters that will be applied - * @return object patForms_Element $element The element object, or patError if failed. - */ - function &createElement( $name, $type, $attributes, $filters = null, $children = null ) - { - $element =& patForms::_createModule( 'Element', $type ); - if ( patErrorManager::isError( $element ) ) - { - return $element; - } - - $attributes['name'] = $name; - if ( !isset( $attributes['id'] ) ) { - $attributes['id'] = $this->getElementId(); - } - - // add default attributes - do this the 'silent' way be checking whether - // the element supports the given attribute, as the element throws a notice - // if it does not support it - this is not expected from default attributes. - foreach ( patForms::getStaticProperty( 'defaultAttributes' ) as $attributeName => $attributeValue ) - { - if ( !$element->hasAttribute( $attributeName ) ) - { - continue; - } - - $element->setAttribute( $attributeName, $attributeValue ); - } - - // set the given attributes normally - $success = $element->setAttributes( $attributes ); - if ( patErrorManager::isError( $success ) ) - { - return $success; - } - - if (is_array($children)) { - foreach ($children as $child) { - $childName = $child['attributes']['name']; - - $childEl = &patForms::createElement($childName, $child['type'], $child['attributes']); - if ( isset( $child["renderer"] ) ) { - $childEl->setRenderer( $child["renderer"] ); - } - - $element->addElement($childEl); - } - } - - $success = $element->_init(); - if ( patErrorManager::isError( $success ) ) { - return $success; - } - - // if we don't have any filters to add, we're done - if ( !is_array( $filters ) ) - { - return $element; - } - - $cnt = count( $filters ); - for ( $i = 0; $i < $cnt; $i++ ) - { - $params = isset( $filters[$i]['params'] ) ? $filters[$i]['params'] : null; - $filter = &patForms::createFilter( $filters[$i]['filter'], $params ); - if ( patErrorManager::isError( $filter ) ) - { - continue; - } - $element->applyFilter( $filter ); - } - - return $element; - } - - /** - * retrieves the validation errors from all elements in the form. Use this if the validateForm() - * method returned false. - * - * @access public - * q - * @return array $errors Array containing an array with validation errors for each element in the form. - * @todo replace __form with the name of the form, once attributes are implemented - */ - function getValidationErrors($withElements = true) - { - $found = false; - $errors = array(); - - if ( !empty( $this->validationErrors ) ) - { - $errors['__form'] = $this->validationErrors; - $found = true; - } - - if ($withElements === false) { - return $errors; - } - - $cnt = count( $this->elements ); - for ( $i = 0; $i < $cnt; ++$i ) - { - $name = $this->elements[$i]->getAttribute( 'name' ); - if ( $name === false ) - { - continue; - } - - $elementErrors = $this->elements[$i]->getValidationErrors(); - - if ( empty( $elementErrors ) ) - continue; - - $errors[$name] = $elementErrors; - $found = true; - } - - if ( $found ) - return $errors; - - return false; - } - - /** - * retrieves the values for all elements in the form. - * - * @access public - * @param array desired fields - * @param integer Mode that should be used to return values in groups - * @return array The values for all elements, as elementname => elementvalue. - * - * @todo remove the ugly Group check and replace with something better - * @todo implement something similar for getValidation errors - */ - function getValues( $fields = null, $type = PATFORMS_VALUES_NESTED ) - { - $values = array(); - - $cnt = count( $this->elements ); - for ( $i = 0; $i < $cnt; ++$i ) - { - $name = $this->elements[$i]->getAttribute( 'name' ); - if ( $name === false ) { - continue; - } - - if ( is_array( $fields ) && !in_array( $name, $fields ) ) { - continue; - } - - $tmpVal = $this->elements[$i]->getValue(); - if (!is_array($tmpVal) || $this->elements[$i]->elementName != 'Group') { - $values[$name] = $tmpVal; - continue; - } - - switch ($type) { - case PATFORMS_VALUES_FLATTENED: - $values = array_merge($values, $tmpVal); - break; - case PATFORMS_VALUES_PREFIXED: - foreach ($tmpVal as $key => $val) { - $values[$name.'_'.$key] = $val; - } - break; - case PATFORMS_VALUES_NESTED: - default: - $values[$name] = $tmpVal; - break; - - } - } - return $values; - } - - /** - * sets the values for all elements in the form. Use this to fill your form with external - * data, like a db query. Caution: if you do this and set the form to submitted, the values - * will be overwritten by any values present in the $_GET or $_POST variables. - * - * @access public - * @param array $values The values for all elements, as elementname => elementvalue. - */ - function setValues( $values, $overrideUserInput = false ) - { - patErrorManager::pushExpect(PATFORMS_ERROR_ELEMENT_NOT_FOUND); - foreach ($values as $elName => $value) { - $el = &$this->getElementByName($elName); - if (patErrorManager::isError($el)) { - continue; - } - if ($overrideUserInput === true) { - $el->setValue($value); - } else { - $el->setDefaultValue($value); - } - } - patErrorManager::popExpect(); - return true; - } - - /** - * retrieves the current mode of the form - * - * @access public - * @return string $mode The current form mode - * @see setMode() - * @see $mode - */ - function getMode() - { - return $this->mode; - } - - /** - * returns the locale that is currently set for the form. - * - * @access public - * @return string $locale The locale. - * @see setLocale() - * @see $locale - */ - function getLocale() - { - return $this->locale; - } - - /** - * retrieves the current format of the form - * - * @access public - * @return string $format The current form format - * @see setFormat() - * @see format - */ - function getFormat() - { - return $this->format; - } - - /** - * retrieves the current method of the form - * - * @access public - * @return string $method The request method - * @see setMethod() - */ - function getMethod() - { - return $this->getAttribute( 'method' ); - } - - /** - * retrieves the current action of the form - * - * @access public - * @return string $action Action of the form - * @see setAction() - */ - function getAction() - { - $action = $this->getAttribute( 'action' ); - if ( !empty( $action ) ) - return $action; - return $_SERVER['PHP_SELF']; - } - - /** - * adds an atribute to the form's attribute collection. If the attribute - * already exists, it is overwritten. - * - * @access public - * @param string $attributeName The name of the attribute to add - * @param string $atributeValue The value of the attribute - */ - function setAttribute( $attributeName, $attributeValue ) - { - if ( !isset( $this->attributeDefinition[$attributeName] ) ) - { - patErrorManager::raiseNotice( - PATFORMS_NOTICE_ATTRIBUTE_NOT_SUPPORTED, - "The attribute '".$attributeName."' is not supported by the form, skipped it. [".get_class( $this )."]" - ); - return true; - } - - $this->attributes[$attributeName] = $attributeValue; - - return true; - } - - /** - * adds several attributes at once to the form's attribute collection. - * Any existing attributes will be overwritten. - * - * @access public - * @param array $attributes The attributes to add - * @see setAttribute() - */ - function setAttributes( $attributes ) - { - if ( !is_array( $attributes ) ) - { - return patErrorManager::raiseError( - PATFORMS_NOTICE_ARRAY_EXPECTED, - "setAttributes: array expected" - ); - } - - foreach ( $attributes as $attributeName => $attributeValue ) - { - $this->setAttribute( $attributeName, $attributeValue ); - } - - return true; - } - - /** - * retrieves the value of a form attribute. - * - * @access public - * @param string $attribute The name of the attribute to retrieve - * @return mixed $attributeValue The value of the attribute, or false if it does not exist in the attributes collection. - * @see setAttribute() - */ - function getAttribute( $attribute ) - { - if ( !isset( $this->attributes[$attribute] ) ) - { - return false; - } - - return $this->attributes[$attribute]; - } - - /** - * retrieves all attributes of the form, or only the specified attributes. - * - * @access public - * @param array $attributes Optional: The names of the attributes to retrieve. Only the attributes that exist will be returned. - * @return array $result The attributes - * @see getAttribute() - */ - function getAttributes( $attributes = array() ) - { - if ( empty( $attributes ) ) - { - return $this->attributes; - } - - $result = array(); - foreach ( $attributes as $attribute ) - { - if ( $attributeValue = $this->getAttribute( $attribute ) ) - { - $result[$attribute] = $attributeValue; - } - } - - return $result; - } - - /** - * Loads the default attribute values into the attributes collection. Done directly - * on startup (in the consructor). - * - * The action defaults to the path of the current script, with session - * ID appended automatically, if SID has been defined. - * - * @access public - * @return bool $success Always returns true. - * @see $attributeDefaults - */ - function loadAttributeDefaults() - { - foreach ( $this->attributeDefinition as $attributeName => $attributeDef ) - { - if ( isset( $attributeDef['default'] ) ) - { - $this->attributes[$attributeName] = $attributeDef['default']; - } - - if ( $attributeName == 'action' ) - { - $this->attributes[$attributeName] = $_SERVER['PHP_SELF']; - /** - * session has been started, append session ID - */ - if ( defined( 'SID' ) ) - $this->attributes[$attributeName] .= '?' . SID; - } - } - - return true; - } - - /** - * retrieves the form's current submitted state. - * - * If autoValidate is used, it will check for the submitVar and - * set the submitted flag accordingly - * - * @access public - * @return bool $state True if it has been submitted, false otherwise. - * @see setSubmitted(), setAutoValidate() - * @see submitted - */ - function isSubmitted() - { - if ( $this->submitted === true ) - { - return true; - } - - if ( !isset( $this->submitVar ) ) - { - return false; - } - - if ( !$this->autoValidate ) - { - return false; - } - - if ( isset( $_GET[$this->submitVar] ) || isset( $_POST[$this->submitVar] ) ) - { - $this->setSubmitted( true ); - } - - return $this->submitted; - } - - /** - * Creates a new patForms_Creator object - * - * @static - * @access public - * @return object $creator The creator object, or a patError object on failure - */ - function createCreator( $type ) - { - return patForms::_createModule( 'Creator', $type ); - } - - /** - * get the element name of the form - * - * @access public - * @return string name of the form - */ - function getElementName() - { - return $this->elementName; - } - - /** - * get next error offset - * - * @access public - * @return integer - */ - function getErrorOffset( $requiredCodes = 100 ) - { - $offset = $this->nextErrorOffset; - $this->nextErrorOffset = $this->nextErrorOffset + $requiredCodes; - return $offset; - } - - /** - * add error codes and messages for validator method - * - * @access public - * @param array defintions - * @param integer offset for the error codes - */ - function addValidatorErrorCodes( $defs, $offset = 1000 ) - { - foreach ( $defs as $lang => $codes ) - { - if ( !isset( $this->validatorErrorCodes[$lang] ) ) - { - $this->validatorErrorCodes[$lang] = array(); - } - - foreach ( $codes as $code => $message ) - { - $this->validatorErrorCodes[$lang][($offset+$code)] = $message; - } - } - } - - /** - * add a validation error to the whole form - * - * This can be achieved by adding a validation rule to the form. - * - * @access public - * @param integer $code - * @param array $vars fill named placeholder with values - * @return boolean $result true on success - * @see addRule() - */ - function addValidationError( $code, $vars = array() ) - { - $error = false; - $lang = $this->locale; - $element = $this->getElementName(); - - // find error message for selected language - while ( true ) - { - // error message matches language code - if ( isset( $this->validatorErrorCodes[$lang][$code] ) ) - { - $error = array( "element" => $element, "code" => $code, "message" => $this->validatorErrorCodes[$lang][$code] ); - break; - } - // no message found and no fallback-langauage available - else if ( $lang == "C" ) - { - break; - } - - $lang_old = $lang; - - // look for other languages - if ( strlen( $lang ) > 5 ) - { - list( $lang, $trash ) = explode( ".", $lang ); - } - else if ( strlen( $lang ) > 2 ) - { - list( $lang, $trash ) = explode( "_", $lang ); - } - else - { - $lang = "C"; - } - - // inform developer about missing language - patErrorManager::raiseNotice( - PATFORMS_NOTICE_VALIDATOR_ERROR_LOCALE_UNDEFINED, - "Required Validation Error-Code for language: $lang_old not available. Now trying language: $lang", - "Add language definition in used element or choose other language" - ); - - } - - // get default Error! - if ( !$error ) - { - patErrorManager::raiseWarning( - PATFORMS_WARNING_VALIDATOR_ERROR_UNDEFINED, - "No Error Message for this validation Error was defined", - "Review the error-definition for validation-errors in your element '$element'." - ); - $error = array( "element" => $element, "code" => 0, "message" => "Unknown validation Error" ); - } - - // insert values to placeholders - if ( !empty( $vars ) ) - { - foreach ( $vars as $key => $value ) - { - $error["message"] = str_replace( "[". strtoupper( $key ) ."]", $value, $error["message"] ); - } - } - - array_push( $this->validationErrors, $error ); - $this->valid = false; - return true; - } - - /** - * retreives a new element id, used to give each added element a unique id for this - * form (id can be overwritten by setting the id attribute specifically). - * - * @access private - * @return int $elementId The new element id. - */ - function getElementId() - { - $this->elementCounter++; - return 'pfo'.$this->elementCounter; - } - - /** - * attach an observer - * - * @access public - * @param object patForms_Observer - * @see createObserver() - * @uses patForms_Element::createObserver() - */ - function attachObserver( &$observer, $where = PATFORMS_OBSERVER_ATTACH_TO_ELEMENTS ) - { - /** - * attach the observer to all elements - */ - if ( ( $where & PATFORMS_OBSERVER_ATTACH_TO_ELEMENTS ) == PATFORMS_OBSERVER_ATTACH_TO_ELEMENTS ) - { - $cnt = count( $this->elements ); - for ( $i = 0; $i < $cnt; ++$i ) - { - $this->elements[$i]->attachObserver( $observer ); - } - } - - /** - * attach the observer to the form - */ - if ( ( $where & PATFORMS_OBSERVER_ATTACH_TO_FORM ) == PATFORMS_OBSERVER_ATTACH_TO_FORM ) - { - $this->observers[] = &$observer; - } - return true; - } - - /** - * Retrieve the content for the start of the form, including any - * additional content, e.g. global scripts if the scripts option - * is enabled. - * - * @access public - * @return string $formStart The form start content - * @todo use format to build a dynamic method - */ - function serializeStart() - { - $methodName = "serializeStart".ucfirst( $this->getFormat() ).ucfirst( $this->getMode() ); - - if ( !method_exists( $this, $methodName ) ) - { - return patErrorManager::raiseError( - PATFORMS_ERROR_METHOD_FOR_MODE_NOT_AVAILABLE, - "Method for patForms mode '".$this->getMode()."' (".$methodName.") is not available." - ); - } - - return $this->$methodName(); - } - - /** - * Serializes the form's start element for html format, in default mode. - * - * @access private - * @return mixed $formStart The serialized start content, or a patError object. - */ - function serializeStartHtmlDefault() - { - $attributes = $this->getAttributesFor( $this->format ); - if ( patErrorManager::isError( $attributes ) ) - { - return $attributes; - } - - $content = patForms_Element::createTag( 'form', 'opening', $attributes ); - - if ( $this->optionEnabled( 'scripts' ) ) - { - $content .= $this->getScripts(); - } - - return $content; - } - - /** - * Serializes the form's start element for html format, in readonly mode. - * - * @access private - * @return mixed $formStart The serialized start content, or a patError object. - */ - function serializeStartHtmlReadonly() - { - $attributes = $this->getAttributesFor( $this->format ); - if ( patErrorManager::isError( $attributes ) ) - { - return $attributes; - } - - return patForms_Element::createTag( 'form', 'opening', $attributes ); - } - - /** - * Retrieve the content for the end of the form. - * - * @access public - * @return string $formEnd The form end content - */ - function serializeEnd() - { - $methodName = "serializeEnd".ucfirst( $this->getFormat() ).ucfirst( $this->getMode() ); - - if ( !method_exists( $this, $methodName ) ) - { - return patErrorManager::raiseError( - PATFORMS_ERROR_METHOD_FOR_MODE_NOT_AVAILABLE, - "Method for patForms mode '".$this->getMode()."' (".$methodName.") is not available." - ); - } - - return $this->$methodName(); - } - - /** - * Retrieves the content for the end of the form for html format, - * in default mode. - * - * @access private - * @return string $formEnd The form end content - */ - function serializeEndHtmlDefault() - { - return patForms_Element::createTag( 'form', 'closing' ); - } - - /** - * Retrieves the content for the end of the form for html format, - * in readonly mode. - * - * @access private - * @return string $formEnd The form end content - */ - function serializeEndHtmlReadonly() - { - return $this->serializeEndHtmlDefault(); - } - - /** - * validates the current attribute collection according to the attributes definition - * and the given output format, and returns the list of valid attributes. - * - * @access private - * @param string $format The output format to retrieve the attributes for. - * @return mixed $attributes The list of attributes, or false if failed. - */ - function getAttributesFor( $format ) - { - $attributes = array(); - - foreach ( $this->attributeDefinition as $attributeName => $attributeDef ) - { - if ( !isset( $this->attributes[$attributeName] ) ) - { - if ( $attributeDef["required"] ) - { - return patErrorManager::raiseError( - PATFORMS_ERROR_ATTRIBUTE_REQUIRED, - 'patForms needs the attribute "'.$attributeName.'" to be set.', - 'See the patForms attribute definition of patForms for a complete attribute reference.' - ); - } - - continue; - } - - $attributeValue = $this->attributes[$attributeName]; - - if ( !in_array( $format, $attributeDef["outputFormats"] ) ) - { - continue; - } - - if ( isset( $attributeDef["format"] ) ) - { - if ( !$this->_checkAttributeFormat( $attributeValue, $attributeDef["format"] ) ) - { - return patErrorManager::raiseError( - PATFORMS_ERROR_CAN_NOT_VERIFY_FORMAT, - "Format '".$attributeDef["format"]."' could not be verified for patForms attribute '".$attributeName."' => '".$attributeValue."'" - ); - } - } - - $attributes[$attributeName] = $attributeValue; - } - - return $attributes; - } - - /** - * checks the format of an attribute value according to the given format. - * - * @access private - * @param mixed $attributeValue The attribute value to check - * @param string $format The format to check the attribute value against - * @return bool $result True if format check succeeded, false otherwise. - * @see createAttributes() - * @todo Implement this method sometime - */ - function _checkAttributeFormat( $attributeValue, $format ) - { - return true; - } - - /** - * Enables a patForms option. - * - * See the {@link $options} property for an exhaustive list of available options. - * - * @access public - * @param string $option The option to enable - * @param array $params Optional parameters for the option - * @return mixed $result True on success, patError object otherwise. - * @see disableOption() - * @see optionEnabled() - * @see $options - */ - function enableOption( $option, $params = array() ) - { - if ( !in_array( $option, array_keys( $this->options ) ) ) - { - return patErrorManager::raiseNotice( - PATFORMS_NOTICE_INVALID_OPTION, - 'The option "'.$option.'" is not a valid patForms option.' - ); - } - - $this->options[$option]['enabled'] = true; - $this->options[$option]['params'] = $params; - - // now update all available elements too - $cnt = count( $this->elements ); - for ( $i=0; $i < $cnt; $i++ ) - { - $this->elements[$i]->enableOption( $option, $params ); - } - - return true; - } - - /** - * Disables a patForms option - * - * See the {@link $options} property for an exhaustive list of available options. - * - * @access public - * @param string $option The option to disable - * @return mixed $result True on success, patError object otherwise. - * @see enableOption() - * @see optionEnabled() - * @see $options - */ - function disableOption( $option ) - { - if ( !in_array( $option, array_keys( $this->options ) ) ) - { - return patErrorManager::raiseNotice( - PATFORMS_NOTICE_INVALID_OPTION, - 'The option "'.$option.'" is not a valid patForms option.' - ); - } - - $this->options[$option]['enabled'] = false; - - // now update all available elements too - $cnt = count( $this->elements ); - for ( $i=0; $i < $cnt; $i++ ) - { - $this->elements[$i]->disableOption( $option ); - } - - return true; - } - - /** - * Checks whether the given option is enabled. - * - * @access public - * @param string $option The option to check - * @return bool $enabled True if enabled, false otherwise. - * @see enableOption() - * @see disableOption() - * @see $options - */ - function optionEnabled( $option ) - { - if ( !isset( $this->options[$option] ) ) - return false; - - return $this->options[$option]['enabled']; - } - - /** - * Set the form to auto validate - * - * If you use this method, patForms will check the _GET and _POST variables - * for the variable you specified. If it is set, patForms assumes, that - * the form has been submitted. - * - * When creating a start tag for the form, the value will be inserted automatically. - * - * @access public - * @param string $submitVar - */ - function setAutoValidate( $submitVar ) - { - $this->autoValidate = true; - $this->submitVar = $submitVar; - } - - /** - * register a new event - * - * After registering an event, you may register one or more - * event handlers for this event an then trigger the event. - * - * This lets you extend the functionality of patForms. - * - * @access public - * @param string event name - * @return boolean true, if event could be registered - * @see registerEventHandler() - * @see triggerEvent() - */ - function registerEvent( $name ) - { - $event = 'on' . $name; - if ( in_array( $event, $this->_validEvents ) ) - { - return patErrorManager::raiseNotice( - PATFORMS_NOTICE_EVENT_ALREADY_REGISTERED, - 'Event "'.$event.'" already has been registered or is built-in event' - ); - } - array_push( $this->_validEvents, $event ); - return true; - } - - /** - * Register an event handler - * - * An event handler can be any valid PHP callback. You may pass - * one of the following values: - * - string functionname to call a globally declared function - * - array( string classname, string methodname) to call a static method - * - array( object obj, string methodname) to call a method of an object - * - * When the handler is called, two parameters will be passed: - * - object form : a patForms object - * - string event : the name of the event has should be handled. - * - * An event handler should always return true. If false is returned, - * the event will be cancelled. - * - * Currently handlers for the following events can be registered: - * - onSubmit - * - onSuccess - * - onError - * - * @access public - * @param string event name - * @param mixed event handler - * @return boolean true, if the handler could be registered - * @see triggerEvent() - * @see $_validEvents - */ - function registerEventHandler( $event, $handler ) - { - if ( !in_array( $event, $this->_validEvents ) ) - { - return patErrorManager::raiseError( - PATFORMS_ERROR_UNKNOWN_EVENT, - 'Cannot register event handler for unknown event "' . $event .'".' - ); - } - - if ( !is_callable( $handler ) ) - { - return patErrorManager::raiseError( - PATFORMS_ERROR_INVALID_HANDLER, - 'Event handler is not callable.' - ); - } - - if ( !isset( $this->_eventHandler[$event] ) ) - { - $this->_eventHandler[$event] = array(); - } - - $this->_eventHandler[$event][] = &$handler; - return true; - } - - /** - * set event handler object. - * - * An event handler object is used to handle all - * registered events. The object has to provide methods - * for all events it should handle, the names of the methods - * have to be the same as the names of the events. - * - * @access public - * @param object event handler object - * @param array method names, used to change the names of the methods - * @return boolean - */ - function registerEventHandlerObject( &$obj, $methods = array() ) - { - if ( empty( $methods ) ) - { - foreach ( $this->_validEvents as $event ) - { - if ( !method_exists( $obj, $event ) ) - continue; - - $methods[$event] = $event; - } - } - - foreach ( $methods as $event => $method ) - { - if ( !isset( $this->_eventHandler[$event] ) ) - { - $this->_eventHandler[$event] = array(); - } - - $this->_eventHandler[$event][] = array( &$obj, $method ); - } - - return true; - } - - /** - * Trigger an event - * - * In most cases there's no need to call this event - * from outside the class. The method is declared public - * to allow you to trigger custom events. - * - * @access public - * @param string Event name. The event name must not contain 'on', as this will be - * prefixed automatically. - */ - function triggerEvent( $event ) - { - $handlerName = 'on' . $event; - - if ( !isset( $this->_eventHandler[$handlerName] ) || empty( $this->_eventHandler[$handlerName] ) ) - { - return true; - } - - $cnt = count( $this->_eventHandler[$handlerName] ); - for ( $i = 0; $i < $cnt; $i++ ) - { - $result = call_user_func( $this->_eventHandler[$handlerName][$i], $this, $event ); - if ( $result == false ) - { - return $result; - } - } - return true; - } - - /** - * Serializes the entire form to XML, all elements included - * - * @access public - * @param string $namespace Optional namespace to use for the tags - * @return string $xml The XML representation of the form - * @see patForms_Element::toXML() - * @todo needs patForms_Element, maybe switch to PEAR::XML_Util - */ - function toXML( $namespace = null ) - { - $tagName = 'Form'; - - // prepend Namespace - if ( $namespace != null ) - { - $tagName = $namespace.':'.$tagName; - } - - // get all attributes - $attributes = $this->getAttributes(); - - // create valid XML attributes - foreach ( $attributes as $key => $value ) - { - $attributes[$key] = strtr( $value, $this->xmlEntities ); - } - - $elements = ''; - for ( $i = 0; $i < $this->elementCounter; $i++ ) - { - $elements .= $this->elements[$i]->toXML( $namespace ); - } - - return patForms_Element::createTag( $tagName, "full", $attributes, $elements ); - } - - /** - * Set a static property. - * - * Static properties are stored in an array in a global variable, - * until PHP5 is ready to use. - * - * @static - * @param string property name - * @param mixed property value - * @see getStaticProperty() - */ - function setStaticProperty( $property, &$value ) - { - $GLOBALS["_patForms"][$property] = &$value; - } - - /** - * Get a static property. - * - * Static properties are stored in an array in a global variable, - * until PHP5 is ready to use. - * - * @static - * @param string property name - * @return mixed property value - * @see setStaticProperty() - */ - function &getStaticProperty( $property ) - { - if ( isset( $GLOBALS["_patForms"][$property] ) ) - { - return $GLOBALS["_patForms"][$property]; - } - return patErrorManager::raiseWarning( - PATFORMS_ERROR_NO_STATIC_PROPERTY, - 'Static property "'.$property.'" could not be retreived, it does not exist.' - ); - } - - /** - * Retrieves the form's name - * - * If no name is set, it will use 'patForms' as name. - * - * @access public - * @return string $name The name of the form. - */ - function getName() - { - if ( isset( $this->attributes['name'] ) ) - return $this->attributes['name']; - return 'patForms'; - } - - /** - * get the javascript for the form - * - * This is still in alpha state. It will later - * allow client side validation if the element - * provides this feature. - * - * @access public - * @return string javascript needed by the form - * @todo make this dependent on the format - * @todo add changeable linebreaks - */ - function getScripts() - { - foreach ($this->elements as $element) { - $element->registerJavascripts($this); - } - - $globalJavascript = implode ("", $this->javascripts['global']); - $instances = implode ("", $this->javascripts['instance']); - - $script = ''; - - return $script; - - /* - $globalJavascript = ''; - $instances = ''; - - $displayedTypes = array(); - - $cnt = count( $this->elements ); - for ( $i = 0; $i < $cnt; ++$i ) - { - $instances .= $this->elements[$i]->getInstanceJavascript(); - - $type = $this->elements[$i]->getElementName(); - if ( in_array( $type, $displayedTypes ) ) - continue; - - array_push( $displayedTypes, $type ); - $globalJavascript .= $this->elements[$i]->getGlobalJavascript(); - } - - $cnt = count( $this->_rules ); - for ( $i = 0; $i < $cnt; ++$i ) - { - $instances .= $this->_rules[$i]['rule']->getInstanceJavascript(); - - - $type = $this->_rules[$i]['rule']->getRuleName(); - if ( in_array( $type, $displayedTypes ) ) - continue; - - array_push( $displayedTypes, $type ); - - $globalJavascript .= $this->_rules[$i]['rule']->getGlobalJavascript(); - } - - $script = ''; - - return $script; - */ - } - - private $javascripts = array( - 'global' => array(), - 'instance' => array() - ); - - function registerGlobalJavascript($type, $script) { - - $this->javascripts['global'][$type] = $script; - } - - function registerInstanceJavascript($script) { - - $this->javascripts['instance'][] = $script; - } - - /** - * anounce a change in the element to all observers - * - * @access private - * @param string property that changed - * @param mixed new value of the property - */ - function _announce( $property, $value ) - { - $cnt = count( $this->observers ); - for ( $i = 0; $i < $cnt; $i++ ) - { - $this->observers[$i]->notify( $this, $property, $value ); - } - return true; - } -} diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/Creator/Definition.php b/airtime_mvc/library/propel/contrib/pat/patForms/Creator/Definition.php deleted file mode 100644 index c2ecb4a96..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/Creator/Definition.php +++ /dev/null @@ -1,42 +0,0 @@ - $definition->name - )); - - foreach ($definition->elements as $el) { - $element = &$form->createElement($el['name'], $el['type'], null); - if (!empty($el['attributes']['datasource'])) { - $ds = $el['attributes']['datasource']; - unset($el['attributes']['datasource']); - $element->setDatasource(new $ds['name']($ds)); - } - // patForms will choke when we try to set attributes that - // don't exist for an element type. So we'll have to ask. - foreach ($el['attributes'] as $name => $value) { - if ($element->hasAttribute($name)) { - $element->setAttribute($name, $value); - } - } - if (isset($el['rules'])) { - foreach ($el['rules'] as $rule) { - $element->addRule(new $rule['type']($rule)); - } - } - $form->addElement($element); - } - if (!is_null($object)) { - $form->setValues($object->toArray()); - } - if ($definition->autoValidate) { - $form->setAutoValidate($definition->autoValidate); - } - - return $form; - } - -} diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/Creator/Propel.php b/airtime_mvc/library/propel/contrib/pat/patForms/Creator/Propel.php deleted file mode 100644 index 61876da98..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/Creator/Propel.php +++ /dev/null @@ -1,132 +0,0 @@ - - * @license LGPL, see license.txt for details - * @link http://www.php-tools.net - */ -class patForms_Creator_Propel extends patForms_Creator -{ - private static $creoleTypeMapping = array( - CreoleTypes::BOOLEAN =>'Radio', // BOOLEAN = 1; - CreoleTypes::BIGINT =>'String', // BIGINT = 2; - CreoleTypes::SMALLINT =>'String', // SMALLINT = 3; - CreoleTypes::TINYINT =>'String', // TINYINT = 4; - CreoleTypes::INTEGER =>'String', // INTEGER = 5; - CreoleTypes::CHAR =>'String', // CHAR = 6; - CreoleTypes::VARCHAR =>'String', // VARCHAR = 7; - CreoleTypes::FLOAT =>'String', // FLOAT = 8; - CreoleTypes::DOUBLE =>'String', // DOUBLE = 9; - CreoleTypes::DATE =>'Date', // DATE = 10; - CreoleTypes::TIME =>'String', // TIME = 11; - CreoleTypes::TIMESTAMP =>'Date', // TIMESTAMP = 12; - CreoleTypes::VARBINARY =>'String', // VARBINARY = 13; - CreoleTypes::NUMERIC =>'String', // NUMERIC = 14; - CreoleTypes::BLOB =>'String', // BLOB = 15; - CreoleTypes::CLOB =>'String', // CLOB = 16; - CreoleTypes::TEXT =>'Text', // TEXT = 17; - CreoleTypes::LONGVARCHAR =>'Text', // LONGVARCHAR = 17; - CreoleTypes::DECIMAL =>'String', // DECIMAL = 18; - CreoleTypes::REAL =>'String', // REAL = 19; - CreoleTypes::BINARY =>'String', // BINARY = 20; - CreoleTypes::LONGVARBINARY =>'String', // LONGVARBINARY = 21; - CreoleTypes::YEAR =>'String', // YEAR = 22; - CreoleTypes::ARR =>'String', - CreoleTypes::OTHER =>'String' - ); - - /** - * Create a form from a propel instance - * - * @access public - * @param mixed $object An instance of a Propel object - * @param array $options Any options the creator may need - * @return object $form The patForms object, or a patError object on failure. - */ - function &create( $object, $options = array() ) - { - // Propel stuff - $propel_peer = $object->getPeer(); - $propel_mapBuilder = $propel_peer->getMapBuilder(); // Not sure if we're gonna need this one - $propel_tablename = constant(get_class($propel_peer) . '::TABLE_NAME'); - $propel_tableMap = $propel_mapBuilder->getDatabaseMap()->getTable($propel_tablename); - - // The form - $form =& patForms::createForm( null, array( 'name' => 'patForms_Creator_Form' ) ); - - $propel_cols = $propel_tableMap->getColumns(); - foreach ($propel_cols as $propel_colname => $propel_col) { - - // phpName can be altered by editing the schema.xml, - // thus I think, we should lowercase()/ucfirst() this - $propel_colname = strtolower($propel_colname); - $el_displayname = ucFirst($propel_colname); - // this could be omitted of course, but I think, it's a - // convenient way to get more safe request properties - $el_name = $propel_tablename . '[' . $propel_colname . ']'; - - $el_attr = array( - 'edit' => 'yes', - 'title' => $el_displayname, - 'label' => $el_displayname, - 'name' => $el_name, - 'description' => $el_displayname - ); - - //// Obsolete ? - // Parse column info to element type info - //$type_info = $this->parseTypeInfoFromColumn($propel_col); - // Merge extra element attributes - //$el_attr = array_merge( $el_attr, $type_info['attributes'] ); - - // Is the element required ? Can we retrieve this info from the Column object ? - $el_attr['required'] = 'yes'; - // Value: for now we use default to set the value. Is there a better (more correct) way to do this ? - $el_attr['default'] = $object->{'get'.$propel_col->getPhpName()}(); - - if ($propel_col->isPrimaryKey()) { - $el_type = 'hidden'; - } else { - $el_type = self::$creoleTypeMapping[$propel_col->getCreoleType()]; - } - - $el = &$form->createElement($el_name, $el_type, null); - // patForms will choke when we try to set attributes - // that don't match the element type. So we'll ask. - foreach ($el_attr as $name => $value) { - if ($el->hasAttribute($name)) { - $el->setAttribute($name, $value); - } - } - $form->addElement($el); - } - - return $form; - } - - // Seems this function will become obsolete if we use the static $creoleTypeMapping - function parseTypeInfoFromColumn ( $column ) { - - return array( - 'type' => 'String', - 'attributes' => array() - ); - } -} diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/Creator/_propel_creator_test.php b/airtime_mvc/library/propel/contrib/pat/patForms/Creator/_propel_creator_test.php deleted file mode 100644 index 33f108ed7..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/Creator/_propel_creator_test.php +++ /dev/null @@ -1,201 +0,0 @@ - - * @license LGPL, see license.txt for details - * @link http://www.php-tools.net - */ - - /** - * Main examples prepend file, needed *only* for the examples framework! - */ - //include_once 'patExampleGen/prepend.php'; - //$exampleGen->displayHead( 'Example' ); - - include('include/common.php'); - - // EXAMPLE START ------------------------------------------------------ - - /** - * main patForms class - */ - require_once ('patForms.php'); - - /** - * patErrorManager class - */ - require_once ('patErrorManager.php'); - - - // create the creator :) - $creator = &patForms::createCreator( 'Propel' ); - - // create the form object from the given propel Object class instance - - require_once('model/general/UserProfile.php'); - $userProfile = UserProfilePeer::retrieveByPK(1); - $form =& $creator->create( $userProfile ); - - //$wikipage = WikipagePeer::retrieveByPK('wiki'); - //$form =& $creator->create($wikipage); - - // create the needed renderer - $renderer =& patForms::createRenderer( "Array" ); - - // set the renderer - $form->setRenderer( $renderer ); - - // use auto-validation - $form->setAutoValidate( 'save' ); - - // serialize the elements - $elements = $form->renderForm(); - - - // ERROR DISPLAY ------------------------------------------------------ - if ( $form->isSubmitted() ) - { - displayErrors( $form ); // see patExampleGen/customFunctions.php - } - - // DISPLAY FORM ------------------------------------------------------ - displayForm( $form, $elements ); // see patExampleGen/customFunctions.php - - /** - * Takes a patForms object, asks it if there are any validation - * errors and displays them if need be. - * - * NOTE: this is just a helper method for our examples collection, - * so that you may concentrate on the relevant parts of the examples. - * It does in no way represent the way it should be done :) - * - * @access public - * @param object &$form The patForms object to use - */ - function displayErrors( &$form ) - { - // get the errors from the form object - if there are none, - // this returns false so it is easy to check if there are any. - $errors = $form->getValidationErrors(); - - // if there are any errors, display them. - if ( $errors ) - { - echo '
'; - echo '
Validation failed
'; - echo '
'; - - // the errors collection is an associative array with the - // field names as keys, so we go through that. - foreach ( $errors as $elementName => $elementErrors ) - { - $element =& $form->getElementByName( $elementName ); - - // each element can have more than one error - this - // is rare, but can happen so this is an indexed array - // with one error in each row. - foreach ( $elementErrors as $row => $error ) - { - echo '
'; - echo ' '.$element->getAttribute( 'label' ).': '.$error['message'].'('.$error['element'].' element error #'.$error['code'].')
'; - echo '
'; - } - } - - echo '
'; - echo '
'; - } - // no errors, tell the world everything is fine - else - { - - echo '
Validation successful.
'; - } - } - - - /** - * Displays a standard form from the examples collection when the - * form is rendered via the array renderer. Does not work for any - * other examples. - * - * NOTE: this is just a helper method for our examples collection, - * so that you may concentrate on the relevant parts of the examples. - * It does in no way represent the way it should be done :) - * - * @access public - * @param object &$form The current form object - * @param array $elements The rendered elements from the - * @return - * @see - */ - function displayForm( &$form, $elements ) - { - // output the opening form tag - echo $form->serializeStart(); - - echo "\n"; - foreach ( $elements as $element ) { - } - echo "
\n"; - - // display all elements - foreach ( $elements as $element ) - { - if (!isset($element['description'])) { - // would choke a warning on hidden fields - // strange enough, we've no $element['type'] for hidden inputs - echo $element['element'] . "\n"; - continue; - } - - echo '
'; - echo $element['label']."
"; - echo "
".$element["element"]."
"; - echo "".$element["description"]."
"; - - echo '
'; - - //} else { - //echo "".$element['description']."".$element['element']."\n"; - //} - } - - // submit button, closing form tag - echo '

'; - echo $form->serializeEnd(); - - - // form submitted? display all form values - if ( $form->isSubmitted() ) { - $els =& $form->getElements(); - $cnt = count( $els ); - - echo '
'; - echo '
Submitted form values
'; - echo '
'; - echo ' '; - - for ( $i = 0; $i < $cnt; $i++ ) { - echo ''; - echo ' '; - echo ''; - } - - echo '
'.$els[$i]->getAttribute('label').' : '.$els[$i]->getValue().'
'; - echo '
'; - echo '
'; - } - } diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/Datasource/Propel.php b/airtime_mvc/library/propel/contrib/pat/patForms/Datasource/Propel.php deleted file mode 100644 index 08c059535..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/Datasource/Propel.php +++ /dev/null @@ -1,70 +0,0 @@ -peername = $conf['peername']; - $this->label = $conf['label']; - $this->value = $conf['value']; - } - - public function getValues() { - - $map = call_user_func(array($this->peername, 'getPhpNameMap')); - - $c = new Criteria(); - $c->clearSelectColumns(); - - foreach (array($this->label, $this->value) as $arr) { - foreach ($arr['members'] as $member) { - if (is_array($member)) { - foreach ($member as $member) { - $c->addSelectColumn(constant($this->peername . '::' . $map[$member])); - } - } else { - $c->addSelectColumn(constant($this->peername . '::' . $map[$member])); - } - } - } - - if (isset($this->label['initial']) OR isset($this->value['initial'])) { - $label = isset($this->label['initial']) ? $this->label['initial'] : ''; - $value = isset($this->value['initial']) ? $this->value['initial'] : ''; - $result[] = array( - 'value' => $value, - 'label' => $label - ); - } - - $rs = AuthorPeer::doSelectStmt($c); - $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); - while ($rs->next()) { - $row = $rs->getRow(); - foreach (array('label', 'value') as $key) { - $arr = $this->$key; - $params = array($arr['mask']); - foreach ($arr['members'] as $member) { - if (is_array($member)) { - foreach ($member as $member) { - $field_name = strtolower($map[$member]); // TODO is this always true? - $params[] = $row[$field_name]; - } - } else { - $field_name = strtolower($map[$member]); // TODO is this always true? - $params[] = $row[$field_name]; - } - } - $$key = call_user_func_array('sprintf', $params); - $tmp[$key] = $$key; - } - $result[] = $tmp; - } - - return $result; - } -} diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/Definition.php b/airtime_mvc/library/propel/contrib/pat/patForms/Definition.php deleted file mode 100644 index d02ab5b78..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/Definition.php +++ /dev/null @@ -1,122 +0,0 @@ -data['name'] = $name; - $this->data['mtime'] = time(); - if ($autoValidate) { - $this->data['autoValidate'] = $autoValidate; - } - } - - static public function create($conf) { - // TODO - } - - public function __get($name) { - - if (isset($this->data[$name])) { - return $this->data[$name]; - } - } - - // TODO change protocol to addElement(array $element) - public function addElement($name, $type, $attributes = array(), $rules = array()) { - - if (is_array($type)) { - extract($type); - } - - $this->data['elements'][$name]['name'] = $name; - $this->data['elements'][$name]['type'] = $type; - - foreach ($attributes as $key => $value) { - $value = $this->cast($value); - $this->data['elements'][$name]['attributes'][$key] = $value; - } - foreach ($rules as $key => $rule) { - $this->data['elements'][$name]['rules'][$key] = $rule; - } - } - - public function load($filename) { - - $data = $this->read($filename); - - foreach ($data as $key => $value) { - if ($key == 'elements') { - foreach ($value as $name => $element) { - $this->addElement($name, $element); - } - } else { - $this->data[$key] = $this->cast($value); - } - } - } - - public function save($filename) { - - $this->write($filename, $this->data); - } - - protected function read($filename) { - - $xml = file_get_contents($filename); - $unserializer = new XML_Unserializer(); - $unserializer->unserialize($xml); - return $unserializer->getUnserializedData(); - } - - protected function write($filename, $data) { - - $serializer = new XML_Serializer(array ( - 'addDecl' => true, - 'encoding' => 'ISO-8859-1', - 'indent' => ' ', - 'rootName' => 'form', - 'defaultTagName' => 'tag' - )); - $serializer->serialize($data); - $xml = $serializer->getSerializedData(); - - $fp = fopen($filename, 'w+'); - fputs($fp, $xml); - fclose($fp); - } - - protected function cast($value) { - - return $value; - - // seems as if patForms_Element(s) are broken here - // e.g. in patForms_Element_Text::serializeHtmlDefault() - // at line 245 if ( $this->attributes['display'] == 'no' ) - // will result to true if the display attribute is set - // to (php boolean) true - // so casting the 'true'/'false' and 'yes'/'no' values - // would break intended behaviour here - - if (is_array($value) OR is_bool($value)) { - return $value; - } - if ($value === 'true') { - return true; - } - if ($value === 'false') { - return false; - } - if (preg_match('/^[+-]?[0-9]+$/', $value)) { - settype($value, 'int'); - return $value; - } - if (preg_match('/^[+-]?[0-9]*\.[0-9]+$/', $value)) { - settype($value, 'double'); - return $value; - } - return $value; - } -} diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/Definition/Propel.php b/airtime_mvc/library/propel/contrib/pat/patForms/Definition/Propel.php deleted file mode 100644 index d2ecbe0a0..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/Definition/Propel.php +++ /dev/null @@ -1,165 +0,0 @@ - 'Switch', // BOOLEAN = 1; - CreoleTypes::BIGINT => 'String', // BIGINT = 2; - CreoleTypes::SMALLINT => 'String', // SMALLINT = 3; - CreoleTypes::TINYINT => 'String', // TINYINT = 4; - CreoleTypes::INTEGER => 'String', // INTEGER = 5; - CreoleTypes::CHAR => 'String', // CHAR = 6; - CreoleTypes::VARCHAR => 'String', // VARCHAR = 7; - CreoleTypes::FLOAT => 'String', // FLOAT = 8; - CreoleTypes::DOUBLE => 'String', // DOUBLE = 9; - CreoleTypes::DATE => 'String', // DATE = 10; - CreoleTypes::TIME => 'String', // TIME = 11; - CreoleTypes::TIMESTAMP => 'Date', // TIMESTAMP = 12; - CreoleTypes::VARBINARY => 'String', // VARBINARY = 13; - CreoleTypes::NUMERIC => 'String', // NUMERIC = 14; - CreoleTypes::BLOB => 'Text', // BLOB = 15; - CreoleTypes::CLOB => 'Text', // CLOB = 16; - CreoleTypes::TEXT => 'Text', // TEXT = 17; - CreoleTypes::LONGVARCHAR => 'Text', // LONGVARCHAR = 17; - CreoleTypes::DECIMAL => 'String', // DECIMAL = 18; - CreoleTypes::REAL => 'String', // REAL = 19; - CreoleTypes::BINARY => 'String', // BINARY = 20; - CreoleTypes::LONGVARBINARY => 'Text', // LONGVARBINARY = 21; - CreoleTypes::YEAR => 'String', // YEAR = 22; - CreoleTypes::ARR => 'String', - CreoleTypes::OTHER => 'String' - ); - - private static $validatorTypeMap = array( - 'unique' => null, - 'minLength' => 'patForms_Rule_MinLength', - 'maxLength' => 'patForms_Rule_MaxLength', - 'minValue' => 'patForms_Rule_MinValue', - 'maxValue' => 'patForms_Rule_MaxValue', - 'match' => 'patForms_Rule_Match', - 'notMatch' => 'patForms_Rule_NotMatch', - 'required' => null, // will be done by the elements "required" attribute - 'validValues' => 'patForms_Rule_ValidValues', - ); - - /** - * @param array $conf an assoc array of parameters. these are: - * - string name => $name of the propel object class - * - string filename => $filename of the form definition xml file - */ - - static public function create($conf) { - - extract($conf); - - $autoValidate = isset($autoValidate) ? $autoValidate : 'save'; - - $definition = new patForms_Definition_Propel($name, $autoValidate); - - if (0 AND file_exists($filename)) { - // load definition from xml file - $definition->load($filename); - } else { - // populate definition from table map and save it to xml file - $definition = self::populateFromTableMap($definition, $conf); - $definition->save($filename); - } - - return $definition; - } - - private function populateFromTableMap($definition, $conf) { - - extract($conf); - - $mapBuilder = call_user_func(array($name . 'Peer', 'getMapBuilder')); - $tablename = constant($name . 'Peer::TABLE_NAME'); - $tableMap = $mapBuilder->getDatabaseMap()->getTable($tablename); - $cols = $tableMap->getColumns(); - - foreach ($cols as $col) { - - $phpname = $col->getPhpName(); - // this would need a patched version of patForms in order - // to retrieve request vars after having submitted the form - // TODO - ask patForms developers to enable this - // $elementName = $tablename . '[' . $phpname . ']'; - $elementName = $phpname; - - $elementType = self::$creoleTypeMap[$col->getCreoleType()]; - - // TODO somehow retrieve element type specific default values? - $elementAttributes = array( - 'name' => $elementName, - 'title' => $phpname, - 'label' => $phpname, - 'description' => $phpname, - 'edit' => 'yes', - 'display' => $col->isPrimaryKey() ? 'no' : 'yes', - // Is the element required? - // TODO Can we retrieve this info from the Column object? - 'required' => true, - ); - - switch ($col->getCreoleType()) { - case CreoleTypes::BOOLEAN: { - $elementAttributes['value'] = 1; - break; - } - case CreoleTypes::DATE: { - // TODO doesn't seem to work for some reason - // $elementAttributes['format'] = 'date'; - // $elementAttributes['dateformat'] = 'Ymd'; - break; - } - } - - if ($col->isForeignKey()) { - - $relColname = $col->getRelatedColumnName(); - $relTablename = $col->getRelatedTableName(); - $relColPhpname = - Propel::getDatabaseMap(constant($relTablename . 'Peer::DATABASE_NAME'))-> - getTable($relTablename)->getColumn($relColname)->getPhpname(); - - $elementAttributes['datasource'] = array ( - 'name' => 'patForms_Datasource_Propel', - 'peername' => $relTablename . 'Peer', - 'label' => array( - 'initial' => 'Please select one ...', - 'members' => array($relColPhpname), - 'mask' => '%s', - ), - 'value' => array( - 'members' => array($relColPhpname), - 'mask' => '%s', - ), - ); - $elementType = 'Enum'; - } - - $rules = array(); - if ($col->hasValidators()) { - foreach ($col->getValidators() as $validator) { - $name = $validator->getName(); - $type = self::$validatorTypeMap[$name]; - if (!is_null($type)) { - $rules[$name] = array ( - 'table' => $col->getTablename(), - 'col' => $col->getColumnName(), - 'name' => $name, - 'type' => self::$validatorTypeMap[$name], - 'value' => $validator->getValue(), - 'class' => $validator->getClass(), - 'message' => $validator->getMessage(), - ); - } - } - } - - $definition->addElement($phpname, $elementType, $elementAttributes, $rules); - } - - return $definition; - } -} diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/Element.php b/airtime_mvc/library/propel/contrib/pat/patForms/Element.php deleted file mode 100644 index de1a6c9ef..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/Element.php +++ /dev/null @@ -1,1954 +0,0 @@ - - * @author gERD Schaufelberger - * @author Stephan Schmidt - */ - -/** - * error definition: the attribute that was set is not supported by this element (it is - * not listed in the attributeDefinition property set in the element class). - * @see patForms_Element::attributeDefinition - */ -define( "PATFORMS_ELEMENT_NOTICE_ATTRIBUTE_NOT_SUPPORTED", 1101 ); - -/** - * error definition: the setAttributes() method expects an array, - * but given value was not. - * @see patForms_Element::setAttributes() - */ -define( "PATFORMS_ELEMENT_ERROR_ARRAY_EXPECTED", 1102 ); - -/** - * error definition: the given attribute could not be set - */ -define( "PATFORMS_ELEMENT_ERROR_ADDING_ATTRIBUTE_FAILED", 1103 ); - -/** - * error definition: the element method to serialize the element in the given mode is - * not implemented. - * @see patForms_Element::serialize() - */ -define( "PATFORMS_ELEMENT_ERROR_METHOD_FOR_MODE_NOT_AVAILABLE", 1104 ); - -/** - * error definition: the element returned an error - */ -define( "PATFORMS_ELEMENT_ERROR_ERROR_RETURNED", 1105 ); - -/** - * error definition: the utility class {@link patForms_FormatChecker} could not be found, this is - * needed for the format validation of certain variable types. - * @see patForms_FormatChecker - * @see patForms_Element::validateFormat() - */ -define( "PATFORMS_ELEMENT_ERROR_FORMAT_CHECKER_NOT_FOUND", 1106 ); - -/** - * error definition: the modifier that was set for the element is not an array. - * @see patForms_Element::_applyModifiers() - */ -define( "PATFORMS_ELEMENT_ERROR_MODIFIER_NOT_AN_ARRAY", 1107 ); - -/** - * error definition: the method for the given modifier does not exist - * @see patForms_Element::_applyModifiers() - */ -define( "PATFORMS_ELEMENT_ERROR_METHOD_FOR_MODIFIER_NOT_FOUND", 1108 ); - -/** - * error definition: the modifier returned an error, modifications could not be made. - * @see patForms_Element::_applyModifiers() - */ -define( "PATFORMS_ELEMENT_ERROR_MODIFIER_RETURNED_ERROR", 1109 ); - -/** - * error definition: the given attribute is required for the specified output format. - * @see patForms_Element::getAttributesFor() - */ -define( "PATFORMS_ELEMENT_ERROR_ATTRIBUTE_REQUIRED", 1110 ); - -/** - * error definition: given modifier could not be applied to specified attribute - * @see patForms_Element::getAttributesFor() - */ -define( "PATFORMS_ELEMENT_ERROR_UNABLE_TO_APPLY_MODIFIER_TO_ATTRIBUTE", 1111 ); - -/** - * error definition: the given attribute is not available for output in the specified - * output format. - * @see patForms_Element::getAttributesFor() - */ -define( "PATFORMS_ELEMENT_ERROR_ATTRIBUTE_NOT_AVAILABLE_FOR_OUTPUT", 1112 ); - -/** - * error definition: format of the attribute could not be verified - * @see patForms_Element::getAttributesFor() - */ -define( "PATFORMS_ELEMENT_ERROR_CAN_NOT_VERIFY_FORMAT", 1113 ); - -/** - * error definition: the attribute collection of the element could not be validated. - * @see patForms_Element::toHtml() - */ -define( "PATFORMS_ELEMENT_ERROR_CAN_NOT_VALIDATE_ATTRIBUTE_COLLECTION", 1114 ); - -/** - * error definition: validator undefined - */ -define( "PATFORMS_ELEMENT_ERROR_VALIDATOR_ERROR_UNDEFINED", 1115 ); - -/** - * error definition: undefined locale for errors output - */ -define( "PATFORMS_ELEMENT_ERROR_VALIDATOR_ERROR_LOCALE_UNDEFINED", 1116 ); - -/** - * error definition: the html source for the element could not be generated. - */ -define( "PATFORMS_ELEMENT_ERROR_NO_HTML_CONTENT", 1221 ); - -/** - * error definition: not a valid renderer - */ -define( 'PATFORMS_ELEMENT_ERROR_INVALID_RENDERER', 1222 ); - -/** - * error definition: this element does not support the use of a renderer - */ -define( 'PATFORMS_ELEMENT_RENDERER_NOT_SUPPORTED', 1223 ); - -/** - * filter is located between patForms and browser - */ -define( 'PATFORMS_FILTER_TYPE_HTTP', 1 ); - -/** - * filter is located between patForms and the PHP script - */ -define( 'PATFORMS_FILTER_TYPE_PHP', 2 ); - -/** - * base patForms element class with all needed base functionality that each element - * should have. Extend this class to create your own elements. - * - * $Id: Element.php 1347 2009-12-03 21:06:36Z francois $ - * - * @abstract - * @package patForms - * @subpackage patForms_Element - * @access protected - * @version 0.1 - * @author Sebastian Mordziol - * @author gERD Schaufelberger - * @author Stephan Schmidt - * @license LGPL, see license.txt for details - * @link http://www.php-tools.net - */ -class patForms_Element -{ - /** - * the type of the element, set this in your element class! - * @access protected - */ - var $elementType = false; - - /** - * javascript that will be displayed only once - * - * @access private - * @var array - */ - var $globalJavascript = array(); - - /** - * javascript that will be displayed once per instance - * - * @access private - * @var array - */ - var $instanceJavascript = array(); - - /** - * the value of the element - * @access protected - */ - var $value = false; - - /** - * filters that have been applied - * @access private - */ - var $filters = array(); - - /** - * observers that have been attached - * - * @access private - * @var array - */ - var $observers = array(); - - /** - * The elementName for the serialized version of the element - * - * This is needed for the toXML() method and also by the patForms - * error management. If it is not set, the element name will be - * created by extracting everything after the last underscore in - * the classname. - * - * @access protected - * @see toXML() - */ - var $elementName = null; - - /** - * the attribute collection of the element - * @access private - * @see setAttribute() - * @see setAttributes() - * @see getAttribute() - * @see getAttributes() - */ - var $attributes = array(); - - /** - * the configuration for the attributes supported by the element. Overwrite this - * in your element class. - * - * @abstract - */ - var $attributeDefinition = array(); - - /** - * Stores the attribute defaults for the element, that will be used - * if the given attributes have not been set by the user. - * - * @abstract - * @access private - * @see getAttributeDefaults() - */ - var $attributeDefaults = array(); - - /** - * stores the mode for the element. It defaults to 'default', and is only overwritten if - * set specifically. - * - * @access protected - * @see setMode() - */ - var $mode = "default"; - - /** - * stores the format for the element. It defaults to 'html', and is only overwritten if - * set specifically. - * - * @access protected - * @see setFormat() - */ - var $format = "html"; - - /** - * stores the locale to use when adding validation errors. The specified locale has - * to be set in the validationErrorCodes element class property, otherwise the default - * 'C' (as in the programming language C => english) will be used. - * - * @access private - * @var string $locale - * @see setLocale() - */ - var $locale = "C"; - - /** - * stores the flag telling the element whether it has been submitted - this is used by the - * getValue() method to determine where to get the element's value from. - * @access protected - * @see getValue() - */ - var $submitted = false; - - /** - * stores the flag whether the element is valid - * @access protected - */ - var $valid = true; - - /** - * stores any validation errors that can occurr during the element's validation process. - * - * @access private - * @var array $validationErrors - */ - var $validationErrors = array(); - - /** - * define error codes an messages for each form element - * - * @access protected - * @var array $validatorErrorCodes - */ - var $validatorErrorCodes = array(); - - /** - * defines the starting character for the modifier placeholders that can be inserted - * in the attributes listed as having modifier support. - * - * @access private - * @var string $modifierStart - */ - var $modifierStart = "["; - - /** - * defines the starting character for the modifier placeholders that can be inserted - * in the attributes listed as having modifier support. - * - * @access private - * @var string $modifierStart - */ - var $modifierEnd = "]"; - - /** - * XML entities - * - * @access protected - * @see toXML() - */ - var $xmlEntities = array( - "<" => "<", - ">" => ">", - "&" => "&", - "'" => "'", - '"' => """ - ); - /** - * shortcur to the session variables - * If "false", no session will be used, otherwise it stores the session variables for this element - * - * @access private - * @var mixed $sessionVar - */ - var $sessionVar = false; - - /** - * custom validation rules - * - * @access private - * @var array - */ - var $_rules = array(); - - /** - * next error offset for rules - * @access private - * @var integer - */ - var $nextErrorOffset = 1000; - - /** - * stores whether the element uses a renderer to serialize its content - * @access private - * @var bool - */ - var $usesRenderer = false; - - /** - * Stores the renderer object that can be set via the setRenderer method - * @access private - * @var object - */ - var $renderer = false; - - /** - * Stores all element options - * @access private - */ - var $options = array(); - - /** - * constructor - extend this in your class if you need to do specific operations - * on startup. In that case, however, don't forget to call this constructor anyway - * so that the thing happening here don't get lost. - * - * That's easy to do... just add the following line in your constructor: - * parent::patForms_Element(); - * - * @access public - * @param mixed $mode Optional: the output format, e.g. 'html' - */ - function __construct( $format = false ) - { - if ( $format !== false ) - { - $this->format = $format; - } - - $this->loadAttributeDefaults(); - } - - /** - * patForms_Element constructor for php4 - * - * @access private - * @param integer $id - * @return boolean $result true on success - * @see __construct - */ - function patForms_Element( $format = false ) - { - $this->__construct( $format ); - } - - /** - * Add any initialization routines for your element in your element class, - * for everythig your element needs to do after it has been instantiated and - * the attribute collection has been created. - * - * @abstract - * @access private - * @return mixed $success True on success, a patError object otherwise - */ - function _init() - { - // your code here - return true; - } - - /** - * sets the format of the element - this defines which method will be called in your - * element class, along with the {@link mode} property. - * - * @access public - * @param string $format The name of the format you have implemented in your element(s). Default is 'html' - * @see setFormat() - * @see format - * @see serialize() - */ - function setFormat( $format ) - { - $this->format = strtolower( $format ); - } - - /** - * sets the mode of the element that defines which methods will be called in your - * element class, along with the {@link format} property. - * - * @access public - * @param string $mode The mode to set the element to: default|readonly or any other mode you have implemented in your element class(es). Default is 'default'. - * @see setFormat() - * @see mode - * @see serialize() - */ - function setMode( $mode ) - { - $this->mode = strtolower( $mode ); - } - - /** - * sets the locale (language) to use for the validation error messages of the form. - * - * @access public - * @param string $lang - * @return bool $result True on success - * @see $locale - */ - function setLocale( $lang ) - { - $this->locale = $lang; - - // check, whether this is a custom locale - if (patForms::isCustomLocale($lang)) { - $errorMessages = patForms::getCustomLocale($lang, 'Element::' . $this->elementName); - if (is_array($errorMessages)) { - $this->validatorErrorCodes[$lang] = $errorMessages; - } - } - - return true; - } - - /** - * sets the value of the element, which will be used to fill the element with. If none is - * set and the element needs a value, it will load it using the {@link resolveValue()} method. - * - * This will override user input. - * - * @access public - * @param mixed $value The value to set - * @see $value - * @see resolveValue() - * @see getValue() - */ - function setValue( $value ) - { - $value = $this->_applyFilters( $value, 'in', PATFORMS_FILTER_TYPE_PHP ); - $this->value = $value; - } - - /** - * sets the default value of the element, which will be used to fill the element with. - * - * @access public - * @param mixed $value The value to set - * @see $value - * @see resolveValue() - * @see setValue() - * @see getValue() - */ - function setDefaultValue( $value ) - { - $this->setAttribute('default', $value); - } - - /** - * sets the current submitted state of the element. Set this to true if you want the element - * to pick up its submitted data. - * - * @access public - * @param bool $state True if it has been submitted, false otherwise (default). - * @see getSubmitted() - * @see $submitted - */ - function setSubmitted( $state ) - { - $this->submitted = $state; - } - - /** - * sets the internal ID of the element - this is only used by the {@link patForms} class to - * give each element a unique ID that will be added as ID attribute to each element if the - * id attribute has not been defined. - * - * @access public - * @param string $id The id to set for the element - * @see getId() - */ - function setId( $id ) - { - $this->attributes['id'] = $id; - } - - /** - * gets the internal ID of the element - * - * @access public - * @return string $id The id to set for the element - * @see setId() - */ - function getId() - { - return $this->getAttribute( 'id' ); - } - - /** - * checks whether a given attribute is supported by this element. - * - * @access public - * @param string $attributeName The name of the attribute to check - * @return bool $hasAttribute True if it supports the attribute, false otherwise. - */ - function hasAttribute( $attributeName ) - { - if ( isset( $this->attributeDefinition[$attributeName] ) ) - { - return true; - } - - return false; - } - - /** - * adds an attribute to the element's attribut3 collection. If the attribute - * already exists, it is overwritten. - * - * @access public - * @param string $attributeName The name of the attribute to add - * @param string $attributeValue The value of the attribute - * @return mixed $success True on success, a patError object otherwise - */ - function setAttribute( $attributeName, $attributeValue ) - { - if ( !isset( $this->attributeDefinition[$attributeName] ) ) - { - return patErrorManager::raiseNotice( - PATFORMS_ELEMENT_NOTICE_ATTRIBUTE_NOT_SUPPORTED, - 'Unknown attribute ['.$attributeName.']', - 'Ignored the attribute as the ['.$this->elementName.'] element does not support it.' - ); - } - - $this->attributes[$attributeName] = $attributeValue; - - return true; - } - - /** - * adds several attribute at once to the element's attributes collection. - * Any existing attributes will be overwritten. - * - * @access public - * @param array $attributes The attributes to add - * @return mixed $success True on success, false otherwise - */ - function setAttributes( $attributes ) - { - if ( !is_array( $attributes ) ) - { - return patErrorManager::raiseError( - PATFORMS_ELEMENT_ERROR_ARRAY_EXPECTED, - "Not an array given (setAttributes)" - ); - } - - foreach ( $attributes as $attributeName => $attributeValue ) - { - $this->setAttribute( $attributeName, $attributeValue ); - } - - return true; - } - - /** - * sets a renderer object that will be used to render - * the element. Use the serialize() method to retrieve - * the rendered content of the element. - * - * Only enabled in elements that support renderers, like - * the radio element. - * - * @access public - * @param object &$renderer The renderer object - */ - function setRenderer( &$renderer ) - { - if ( !$this->usesRenderer ) - { - return patErrorManager::raiseWarning( - PATFORMS_ELEMENT_RENDERER_NOT_SUPPORTED, - 'The element \''.$this->elementName.'\' does not support the use of renderers - you do not have to set a renderer for this element.' - ); - } - - if ( !is_object( $renderer ) ) - { - return patErrorManager::raiseError( - PATFORMS_ELEMENT_ERROR_INVALID_RENDERER, - 'You can only set a patForms_Renderer object with the setRenderer() method, "'.gettype( $renderer ).'" given.' - ); - } - - $this->renderer = &$renderer; - } - - /** - * retrieves the value of an attribute. - * - * @access public - * @param string $attribute The name of the attribute to retrieve - * @return mixed $attributeValue The value of the attribute, or false if it does not exist in the attributes collection. - * @see setAttribute() - */ - function getAttribute( $attribute ) - { - if ( !isset( $this->attributes[$attribute] ) ) - { - return false; - } - - return $this->attributes[$attribute]; - } - - /** - * retrieves all attributes, or only the specified attributes. - * - * @access public - * @param array $attributes Optional: The names of the attributes to retrieve. Only the attributes that exist will be returned. - * @return array $result The attributes - * @see getAttribute() - */ - function getAttributes( $attributes = array() ) - { - if ( empty( $attributes ) ) - { - return $this->attributes; - } - - $result = array(); - foreach ( $attributes as $attribute ) - { - if ( $attributeValue = $this->getAttribute( $attribute ) ) - { - $result[$attribute] = $attributeValue; - } - } - - return $result; - } - - /** - * Loads the default attribute values into the attributes collection. Done directly - * on startup (in the consructor), so make sure you call this if your element needs - * this feature and you have implemented a custom constructor in your element. - * - * @access public - * @return bool $success Always returns true. - * @see $attributeDefaults - */ - function loadAttributeDefaults() - { - foreach ( $this->attributeDefinition as $attributeName => $attributeDef ) - { - if ( isset( $attributeDef['default'] ) ) - { - $this->attributes[$attributeName] = $attributeDef['default']; - } - } - - return true; - } - - /** - * retrieves the current value of the element. If none is set, will try to retrieve the - * value from submitted form data. - * - * @access public - * @param boolean Determines whether the method is used from an external script - * @return mixed The value, or an empty string if none found. - * @see setValue() - * @see value - * @see resolveValue() - */ - function getValue( $external = true ) - { - if ( $this->value === false ) - { - $this->resolveValue(); - - // could not be resolved - if ( $this->value === false ) - { - $value = ''; - } - else - { - $value = $this->value; - } - } - else - { - $value = $this->value; - } - - if ( $external === false ) - { - return $value; - } - - $value = $this->_applyFilters( $value, 'out', PATFORMS_FILTER_TYPE_PHP ); - - return $value; - } - - /** - * resolves the scope the value of the element may be stored in, and returns it. - * - * @access protected - * @see getValue() - * @see value - * @todo parse element name, if it uses the array syntax - */ - function resolveValue() - { - $varName = $this->attributes['name']; - - if ( $this->submitted && isset( $_POST[$varName] ) ) - { - $this->value = $_POST[$varName]; - if ( ini_get( 'magic_quotes_gpc' ) ) - $this->value = $this->rStripSlashes( $this->value ); - $this->value = $this->_applyFilters( $this->value, 'in', PATFORMS_FILTER_TYPE_HTTP ); - return true; - } - - if ( $this->submitted && isset( $_GET[$varName] ) ) - { - $this->value = $_GET[$varName]; - if ( ini_get( 'magic_quotes_gpc' ) ) - $this->value = $this->rStripSlashes( $this->value ); - $this->value = $this->_applyFilters( $this->value, 'in', PATFORMS_FILTER_TYPE_HTTP ); - return true; - } - - if ( isset( $this->attributes['default'] ) ) - { - $this->value = $this->attributes['default']; - $this->value = $this->_applyFilters( $this->value, 'in', PATFORMS_FILTER_TYPE_PHP ); - - return true; - } - - return true; - } - - /** - * recursively strip slashes - * - * This method is used to 'fix' magic_quotes_gpc. - * - * @access public - * @param mixed user input (get or post) - * @return mixed data with slashes stripped - */ - function rStripSlashes( $value ) - { - if ( is_scalar( $value ) ) - return stripslashes( $value ); - if ( is_array( $value ) ) - { - foreach ( $value as $key => $val ) - { - $value[$key] = $this->rStripSlashes( $val ); - } - } - return $value; - } - - /** - * apply filters to a value - * - * @access private - * @param mixed value - * @param string direction of the filter ('in' or 'out') - * @param integer type of filters to apply - * @return mixed filtered value - */ - function _applyFilters( $value, $dir = 'in', $type = PATFORMS_FILTER_TYPE_PHP ) - { - if ( empty( $this->filters ) ) - return $value; - - /** - * apply filters! - */ - $cnt = count( $this->filters ); - for ( $i = 0; $i < $cnt; $i++ ) - { - /** - * check, whether filter is located between php script and form - */ - if ( $this->filters[$i]->getType() != $type ) - { - continue; - } - - $value = $this->filters[$i]->$dir( $value ); - } - return $value; - } - - /** - * retrieves the current mode of the element - * - * @access public - * @return string $mode The current element mode - * @see setMode() - * @see mode - */ - function getMode() - { - return $this->mode; - } - - /** - * retrieves the current format of the element - * - * @access public - * @return string $format The current element format - * @see setFormat() - * @see format - */ - function getFormat() - { - return $this->format; - } - - /** - * retrieves the element's current submitted state. - * - * @access public - * @return bool $state True if it has been submitted, false otherwise. - * @see setSubmitted() - * @see submitted - */ - function getSubmitted() - { - return $this->submitted; - } - - /** - * retrieves the name of the element - * - * @access public - * @return string $name name of the element - * @uses getAttribute() - */ - function getName() - { - return $this->getAttribute( 'name' ); - } - - /** - * add a custom validation rule - * - * @access public - * @param object patForms_Rule validation rule - * @param integer time, when rule has to be applied, can be before or after validation. - * If set to null, it will use the default value as specified in the rule - * @return boolean currently always true - */ - function addRule( &$rule, $time = null ) - { - if ( is_null( $time ) ) - { - $time = $rule->getTime(); - } - - $rule->prepareRule( $this ); - - $this->_rules[] = array( - 'rule' => &$rule, - 'time' => $time, - ); - return true; - } - - /** - * adds an observer to the element - * - * @access public - * @param object patForms_Observer observer - * @return boolean currently always true - */ - function attachObserver( &$observer ) - { - $this->observers[] = &$observer; - return true; - } - - /** - * dispatches the serialization of the element in the format that was set to the - * corresponding method in the element class. These methods must be named in the - * folowing scheme: - * - * serialize[format][mode](), e.g. serializeHtmlDefault() - * - * @access public - * @return string $element The created element according to the specified mode. - * @see setFormat() - * @see setMode() - * @todo serialize*() methods should return a patError object instead of false!!!! - * Has to be changed asap! - */ - function serialize() - { - $methodName = "serialize".ucfirst( $this->getFormat() ).ucfirst( $this->getMode() ); - - if ( !method_exists( $this, $methodName ) ) - { - return patErrorManager::raiseError( - PATFORMS_ELEMENT_ERROR_METHOD_FOR_MODE_NOT_AVAILABLE, - "Element method for form mode '".$this->getMode()."' (".$methodName.") is not available." - ); - } - - /** - * get the value for internal use - * The PHP-filters will not be applied - */ - $value = $this->getValue( false ); - - $element = $this->$methodName( $value ); - if ( patErrorManager::isError( $element ) ) - { - return $element; - } - - return $element; - } - - /** - * Template method that applies rules and calls the elements - * validation method - * - * @final - * @access public - * @return bool $success True on success, false otherwise - */ - function validate() - { - // apply locale, if the current locale is a custom locale - if (patForms::isCustomLocale($this->locale)) { - $cnt = count( $this->_rules ); - for ( $i = 0; $i < $cnt; $i++ ) { - $this->_rules[$i]['rule']->setLocale($this->locale); - } - } - - /** - * validate custom rules - */ - if ( !$this->_applyRules( PATFORMS_RULE_BEFORE_VALIDATION ) ) - { - $this->_announce( 'status', 'error' ); - return false; - } - - /** - * the the unfiltered value - */ - $value = $this->getValue( false ); - - $valid = $this->validateElement( $value ); - if ( $valid === false ) - { - $this->_announce( 'status', 'error' ); - return false; - } - - /** - * validate custom rules - */ - if ( !$this->_applyRules( PATFORMS_RULE_AFTER_VALIDATION ) ) - { - $this->_announce( 'status', 'error' ); - return false; - } - - $this->_announce( 'status', 'validated' ); - return true; - } - - /** - * validates the given data with the element's validation routines - * and returns the data with any needed modifications. - * - * @abstract - * @access private - * @return bool $success True on success, false otherwise - */ - function validateElement() - { - // your code here - return true; - } - - /** - * apply rules - * - * @access private - * @param integer time of validation - * @return boolean rules are valid or not - * @todo add documentation - */ - function _applyRules( $time ) - { - $valid = true; - - $cnt = count( $this->_rules ); - for ( $i = 0; $i < $cnt; $i++ ) - { - if ( ( $this->_rules[$i]['time'] & $time ) != $time ) - continue; - - $result = $this->_rules[$i]['rule']->applyRule( $this, $time ); - if ( $result === false ) - { - $valid = false; - } - } - return $valid; - } - - /** - * finalize the element. - * - * Used as a template method. - * - * @final - * @access protected - * @return bool $success True on success, false otherwise - * @uses finalizeElement() to call the user code - */ - function finalize() - { - $value = $this->getValue( false ); - return $this->finalizeElement( $value ); - } - - /** - * finalize the element - * - * Offers the possibility to process any needed operations after the element - * has been validated. Implement any tasks that you need to do then here - a - * good example is the File element, where this method enables the moving of - * the uploaded file to the correct location. - * - * @abstract - * @access private - * @param mixed value of the element - * @return bool $success True on success, false otherwise - */ - function finalizeElement( $value ) - { - return true; - } - - /** - * Enables an element option. - * - * See the {@link patForms::$options} property for an exhaustive list of available options. - * - * @access public - * @param string $option The option to enable - * @param array $params Optional parameters for the option - * @see disableOption() - * @see $options - */ - function enableOption( $option, $params = array() ) - { - if ( !isset( $this->options[$option] ) ) - $this->options[$option] = array(); - - $this->options[$option]['enabled'] = true; - $this->options[$option]['params'] = $params; - } - - /** - * Disables an element option - * - * See the {@link patForms::$options} property for an exhaustive list of available options. - * - * @access public - * @param string $option The option to disable - * @see enableOption() - * @see $options - */ - function disableOption( $option ) - { - if ( !isset( $this->options[$option] ) ) - $this->options[$option] = array(); - - $this->options[$option]['enabled'] = false; - } - - /** - * [helper method] validates the given value according to the specified method. It first - * checks if there is a method to check the format in the {@link patForms_FormatChecker} - * class, then checks in the element class itself. - * - * @access public - * @param mixed $value The value to validate the format of - * @param string $format The format to validate the value with - * @return bool $isValid True if valid, false if invalid or no method exists to validate the format. - * @see patForms_FormatChecker - */ - function validateFormat( $value, $format ) - { - if ( !class_exists( "patForms_FormatChecker" ) ) - { - $checkerFile = dirname( __FILE__ )."/FormatChecker.php"; - if ( !file_exists( $checkerFile ) ) - { - $this->valid = false; - return patErrorManager::raiseError( - PATFORMS_ELEMENT_ERROR_FORMAT_CHECKER_NOT_FOUND, - "Type checker could not be found, aborting validation." - ); - } - - include_once( $checkerFile ); - } - - $format = strtolower( $format ); - - $methodName = "is_".$format; - $option = false; - - if ( method_exists( $this, $methodName ) ) - { - return $this->$methodName( $value ); - } - - if ( in_array( $methodName, get_class_methods( "patForms_FormatChecker" ) ) ) - { - return call_user_func( array( 'patForms_FormatChecker', $methodName ), $value ); - } - - return false; - } - - /** - * get next error offset - * - * @access public - * @return integer - */ - function getErrorOffset( $requiredCodes = 100 ) - { - $offset = $this->nextErrorOffset; - $this->nextErrorOffset = $this->nextErrorOffset + $requiredCodes; - return $offset; - } - - /** - * add error codes and messages for validator method - * - * @access public - * @param array defintions - * @param integer offset for the error codes - */ - function addValidatorErrorCodes( $defs, $offset = 1000 ) - { - foreach ( $defs as $lang => $codes ) - { - if ( !isset( $this->validatorErrorCodes[$lang] ) ) { - $this->validatorErrorCodes[$lang] = array(); - } - - foreach ( $codes as $code => $message ) { - $this->validatorErrorCodes[$lang][($offset+$code)] = $message; - } - } - } - - /** - * getValidationErrors - * - * @access public - * @return array errors that occured during the validation - */ - function getValidationErrors() - { - return $this->validationErrors; - } - - /** - * addValidationError - * - * - * @access public - * @param integer $code - * @param array $vars fill named placeholder with values - * @return boolean $result true on success - */ - function addValidationError( $code, $vars = array() ) - { - $error = false; - $lang = $this->locale; - $element = $this->getElementName(); - - // find error message for selected language - while ( true ) - { - // error message matches language code - if ( isset( $this->validatorErrorCodes[$lang][$code] ) ) - { - $error = array( "element" => $element, "code" => $code, "message" => $this->validatorErrorCodes[$lang][$code] ); - break; - } - // no message found and no fallback-langauage available - else if ( $lang == "C" ) - { - break; - } - - $lang_old = $lang; - - // look for other languages - if ( strlen( $lang ) > 5 ) - { - list( $lang, $trash ) = explode( ".", $lang ); - } - else if ( strlen( $lang ) > 2 ) - { - list( $lang, $trash ) = explode( "_", $lang ); - } - else - { - $lang = "C"; - } - - // inform developer about missing language - patErrorManager::raiseNotice( - PATFORMS_ELEMENT_ERROR_VALIDATOR_ERROR_LOCALE_UNDEFINED, - "Required Validation Error-Code for language: $lang_old not available. Now trying language: $lang", - "Add language definition in used element or choose other language" - ); - - } - - // get default Error! - if ( !$error ) - { - patErrorManager::raiseWarning( - PATFORMS_ELEMENT_ERROR_VALIDATOR_ERROR_UNDEFINED, - "No Error Message for this validation Error was defined", - "Review the error-definition for validation-errors in your element '$element'." - ); - $error = array( "element" => $element, "code" => 0, "message" => "Unknown validation Error" ); - } - - // insert values to placeholders - if ( !empty( $vars ) ) - { - foreach ( $vars as $key => $value ) - { - $error["message"] = str_replace( "[". strtoupper( $key ) ."]", $value, $error["message"] ); - } - } - - array_push( $this->validationErrors, $error ); - $this->valid = false; - return true; - } - - /** - * applies the specified modifiers to an attribute value, as set in the attribute definition. - * - * @access private - * @param mixed $attributeValue The value of the attribute to modify - * @param array $modifiers Array containing the list of modifiers and their options to apply. - * @return mixed $attributeValue The modified attribute value. - * @see createAttributes() - */ - function _applyModifiers( $attributeValue, $modifiers ) - { - if ( !is_array( $modifiers ) ) - { - return patErrorManager::raiseError( - PATFORMS_ELEMENT_ERROR_MODIFIER_NOT_AN_ARRAY, - "Modifiers are not an array" - ); - } - - foreach ( $modifiers as $modifier => $modifierOptions ) - { - // compute method name for this definition and check if it exists - $modifierMethod = "_modifier".ucfirst( $modifier ); - - if ( !method_exists( $this, $modifierMethod ) ) - { - return patErrorManager::raiseError( - PATFORMS_ELEMENT_ERROR_METHOD_FOR_MODIFIER_NOT_FOUND, - "Method not found for modifier '" . $modifier . "' (".$modifierMethod.") in class '" . get_class( $this ) . "'" - ); - } - - $modifiedValue = $this->$modifierMethod( $attributeValue ); - - if ( $modifiedValue === false ) - { - return patErrorManager::raiseError( - PATFORMS_ELEMENT_ERROR_MODIFIER_RETURNED_ERROR, - "Modifier '".$modifier."' returned an error." - ); - } - - $attributeValue = $modifiedValue; - } - - return $attributeValue; - } - - /** - * insertSpecials attribute value modifier - * - * you can use special placeholders to insert dynamic values into the attribute values. - * This method inserts the correct information for each placeholder in the given string. - * - * @access private - * @param string $string The string to insert the specials in - * @return string $string The string with all needed replacements - * @see _applyModifiers() - * @todo Maybe make this configurable - * @todo Add any other relevant information - */ - function _modifierInsertSpecials( $modifyValue, $options = array() ) - { - if ( is_array( $modifyValue ) || is_object( $modifyValue ) || is_array( $this->value ) ) - return $modifyValue; - - // go through each attribute in the attribute definition and replace the strings - // with the corresponding attribute values. - foreach ( $this->attributeDefinition as $attributeName => $attributeDef ) - { - // if attribute was not set, strip the variable by setting it to empty. - $attributeValue = ""; - - // retrieve real attribute value if it was set - if ( isset( $this->attributes[$attributeName] ) && is_string( $this->attributes[$attributeName] ) ) - { - $attributeValue = $this->attributes[$attributeName]; - } - - $search = $this->modifierStart."ELEMENT_".strtoupper( $attributeName ).$this->modifierEnd; - - // make the replacement - $modifyValue = str_replace( $search, $attributeValue, $modifyValue ); - } - - // the element's value is special... - $modifyValue = str_replace( $this->modifierStart."ELEMENT_VALUE".$this->modifierEnd, $this->value, $modifyValue ); - - return $modifyValue; - } - - /** - * checks the format of an attribute value according to the given format. - * - * @access private - * @param mixed $attributeValue The attribute value to check - * @param string $format The format to check the attribute value against - * @return bool $result True if format check succeeded, false otherwise. - * @see createAttributes() - * @todo Implement this method sometime - */ - function _checkAttributeFormat( $attributeValue, $format ) - { - return true; - } - - /** - * validates the current attribute collection according to the attributes definition - * and the given output format, and returns the list of valid attributes. - * - * @access private - * @param string $format The output format to retrieve the attributes for. - * @return mixed $attributes The list of attributes, or false if failed. - */ - function getAttributesFor( $format ) - { - $attributes = array(); - - foreach ( $this->attributeDefinition as $attributeName => $attributeDef ) - { - if ( !isset( $this->attributes[$attributeName] ) ) - { - if ( $attributeDef["required"] ) - { - return patErrorManager::raiseError( - PATFORMS_ELEMENT_ERROR_ATTRIBUTE_REQUIRED, - 'The element "'.$this->getElementName().'" needs the attribute "'.$attributeName.'" to be set.', - 'See the attribute definition of the element class "'.get_class( $this ).'"' - ); - } - - continue; - } - - $attributeValue = $this->attributes[$attributeName]; - - // special case disabled attribute: skip this if it is not set to yes - // to avoid generating a disabled field anyway (empty HTML attribute) - if ( $attributeName == 'disabled' && $attributeValue != 'yes' ) - { - continue; - } - - if ( isset( $attributeDef["modifiers"] ) && !empty( $attributeDef["modifiers"] ) ) - { - $modifiedValue = $this->_applyModifiers( $attributeValue, $attributeDef["modifiers"] ); - if ( $modifiedValue === false ) - { - return patErrorManager::raiseError( - PATFORMS_ELEMENT_ERROR_UNABLE_TO_APPLY_MODIFIER_TO_ATTRIBUTE, - "Could not apply modifier to attribute '".$attributeName."' (value:'".$attributeValue."')" - ); - } - - $attributeValue = $modifiedValue; - - // store this for later use too - $this->attributes[$attributeName] = $attributeValue; - } - - if ( !in_array( $format, $attributeDef["outputFormats"] ) ) - { - continue; - } - - if ( isset( $attributeDef["format"] ) ) - { - if ( !$this->_checkAttributeFormat( $attributeValue, $attributeDef["format"] ) ) - { - return patErrorManager::raiseError( - PATFORMS_ELEMENT_ERROR_CAN_NOT_VERIFY_FORMAT, - "Format '".$attributeDef["format"]."' could not be verified for attribute '".$attributeName."' => '".$attributeValue."'" - ); - } - } - - $attributes[$attributeName] = $attributeValue; - } - - return $attributes; - } - - /** - * [helper method] wrapper for the {@link createTag()} method which automates the tag - * creation by creating the tag from the current attribute collection and element type. - * - * @access protected - * @return mixed $result The created tag, or false if failed. - * @see elementType - * @see attributes - * @see createTag() - */ - function toHtml() - { - $attributes = $this->getAttributesFor( $this->getFormat() ); - if ( patErrorManager::isError( $attributes ) ) - { - return $attributes; - } - - return $this->createTag( $this->elementType[$this->getFormat()], "full", $attributes ); - } - - /** - * [helper method] create a hidden field with the given value. Retrieves all other needed - * attributes from the attributes collection. - * @access public - */ - function createHiddenTag( $value ) - { - $attribs = array( 'type' => 'hidden', - 'name' => $this->attributes['name'], - 'value' => $value, - 'id' => $this->attributes['id'], - ); - - return $this->createTag( "input", "full", $attribs ); - } - - /** - * [helper method] creates a hidden field with the given value. Used for the - * display=no attribute, and is the same as the createHiddenTag() method, only - * that the attributes collection is initialized to ensure that any variables - * in the element's attributes get replaced. - * - * @access private - * @param mixed $value The value of the element - * @return string $element The serialized hidden tag - * @see createHiddenTag() - */ - function createDisplaylessTag( $value ) - { - // call this to initialize all attributes. This is needed - // here to make sure that if there are - $this->getAttributesFor( $this->getFormat() ); - - return $this->createHiddenTag( $value ); - } - - /** - * [helper method] create an element HTML source from its attribute collection and - * returns it. - * - * @static - * @access protected - * @param string $tagname The name of the element / tag - * @param string $type Optional: the type of element to generate. Valid parameters are full|opening|closing|empty. Defaults to "full". - * @param mixed $value The value of the element - * @return string $element The HTML source of the element - */ - function createTag( $tagname, $type = "full", $attributes = array(), $value = false ) - { - switch( $type ) - { - case "closing": - return ""; - break; - - case "empty": - case "opening": - $tag = "<".$tagname; - - // create attribute collection - foreach ( $attributes as $attributeName => $attributeValue ) - { - $tag = $tag . " ".$attributeName."=\"".htmlentities( (string)$attributeValue )."\""; - } - - // empty tag? - if ( $type == "empty" ) - { - $tag = $tag . " />"; - return $tag; - } - - $tag = $tag . ">"; - return $tag; - - break; - - case "full": - if ( $value === false ) - { - return patForms_Element::createTag( $tagname, "empty", $attributes ); - } - - return patForms_Element::createTag( $tagname, "opening", $attributes ).htmlentities( $value ).patForms_Element::createTag( $tagname, "closing" ); - break; - } - } - - /** - * create XML representation of the element - * - * This can be used when you need to store the structure - * of your form in flat files or create form templates that can - * be read by patForms_Parser at a later point. - * - * @access public - * @param string namespace - * @uses getElementName() - * @see patForms_Parser - */ - function toXML( $namespace = null ) - { - $tagName = $this->getElementName(); - - // prepend Namespace - if ( $namespace != null ) - { - $tagName = $namespace.':'.$tagName; - } - - // get all attributes - $attributes = $this->getAttributes(); - - // create valid XML attributes - foreach ( $attributes as $key => $value ) - { - $attributes[$key] = strtr( $value, $this->xmlEntities ); - } - - $value = strtr( $this->getValue(), $this->xmlEntities ); - - if ( $value != false ) - { - return $this->createTag( $tagName, "full", $attributes, $value ); - } - return $this->createTag( $tagName, "empty", $attributes ); - } - - /** - * apply a filter - * - * This is still in alpha state! - * - * @access public - * @param object patForms_Filter - * @todo add error management and docs - * @todo allow filter to be an array containg two callbacks - * array( 'in' => 'myInFunc', 'out' => 'myOutFunc' ) ) - */ - function applyFilter( &$filter ) - { - $this->filters[] = &$filter; - return true; - } - - /** - * Get the name of the element, as stored in the elementName property. - * - * This is used when serializing an element to XML to - * create a now form template. - * - * This method checks for the $elementName property and if it - * is set to null, it will extract the element name from the class name - * - * @access public - * @return string tag name - */ - function getElementName() - { - if ( $this->elementName != null ) - { - return $this->elementName; - } - - $class = get_class( $this ); - $name = substr( strrchr( $class, "_" ), 1 ); - return ucfirst( $name ); - } - - /** - * checks wheter sessions are used or switch session usage on or of - * - * If switch argument is missing, this function just reports if sessions - * will be used or not - * - * @access protected - * @param string $switch switch sessions on ("yes") or off ("yes") - * @return boolean $result true if sessions will be used, false otherwise - * @see setSessionValue() - * @see getSessionValue() - * @see unsetSessionValue() - * @todo destroy session variables if sessions won't be usead any further - */ - function useSession( $switch = null ) - { - // switch sessions on or off - if ( $switch == "yes" ) - { - $this->attributes["usesession"] = "yes"; - } - else if ( $switch == "no" ) - { - $this->attributes["usesession"] = "no"; - return false; - } - - if ( isset( $this->attributes["usesession"] ) && $this->attributes["usesession"] == "yes" ) - { - if ( !$this->sessionVar ) - { - if ( !defined( "SID" ) ) - { - session_start(); - } - - $name = $this->attributes["name"]; - if ( !isset( $_SESSION["_patforms_element"][$name] ) ) - { - $_SESSION["_patforms_element"][$name] = array(); - } - - $this->sessionVar =& $_SESSION["_patforms_element"][$name]; - } - - return true; - } - return false; - } - - /** - * save a variable to the session - * - * @access protected - * @param string $name name to identify the variable - * @param mixed $value - * @return boolean $result true on success - * @see getSessionValue() - * @see unsetSessionValue() - */ - function setSessionValue( $name, $value ) - { - if ( !$this->useSession() ) - { - return false; - } - - $this->sessionVar[$name] = $value; - return true; - } - - /** - * get a variable from session - * - * @access protected - * @param string $name name to identify the variable - * @return mixed $result false if no sessions are used, null if variable is not set or the value of the variable - * @see getSessionValue() - * @see unsetSessionValue() - */ - function getSessionValue( $name ) - { - if ( !$this->useSession() ) - { - return false; - } - - if ( isset( $this->sessionVar[$name] ) ) - { - return $this->sessionVar[$name]; - } - return null; - } - - /** - * remove a variable from session - * - * @access protected - * @param string $name name to identify the variable - * @return mixed $result false if no sessions are used, null if variable is not set or the value of the variable - * @see getSessionValue() - * @see setSessionValue) - */ - function unsetSessionValue( $name ) - { - if ( !$this->useSession() ) - { - return false; - } - - $value = null; - if ( isset( $this->sessionVar[$name] ) ) - { - $value = $this->sessionVar[$name]; - unset( $this->sessionVar[$name] ); - } - return $value; - } - - /** - * get the global javascript of the element - * - * @access public - * @return string - */ - /* - function getGlobalJavascript() - { - if ( !isset( $this->globalJavascript[$this->format] ) ) - { - $script = ''; - } - else - { - $script = $this->globalJavascript[$this->format]; - } - - $cnt = count( $this->_rules ); - for ( $i = 0; $i < $cnt; $i++ ) - { - $tmp = $this->_rules[$i]['rule']->getGlobalJavascript(); - if ( $tmp === false ) - continue; - $script .= $tmp; - } - - return $script; - } - */ - - /** - * get the instance javascript of the element - * - * @access public - * @return string javascript for this instance - */ - /* - function getInstanceJavascript() - { - if ( !isset( $this->instanceJavascript[$this->format] ) ) - { - $script = ''; - } - else - { - $script = $this->instanceJavascript[$this->format]; - - $script = str_replace( '[ELEMENT::NAME]', $this->getName(), $script ); - $script = str_replace( '[ELEMENT::ID]', $this->getId(), $script ); - } - - $cnt = count( $this->_rules ); - for ( $i = 0; $i < $cnt; $i++ ) - { - $tmp = $this->_rules[$i]['rule']->getInstanceJavascript(); - if ( $tmp === false ) - continue; - $script .= $tmp; - } - - return $script; - } - */ - - function registerJavascripts(&$form) { - - if ($script = $this->getGlobalJavascript()) { - $form->registerGlobalJavascript($this->elementName, $script); - } - - if ($script = $this->getInstanceJavascript()) { - $form->registerInstanceJavascript($script); - } - - foreach ($this->_rules as $rule) { - $rule['rule']->registerJavascripts($form); - } - } - - function getGlobalJavascript() { - - if (isset($this->globalJavascript[$this->format])) { - return $this->globalJavascript[$this->format]; - } - } - - function getInstanceJavascript() { - - if (isset($this->instanceJavascript[$this->format])) { - $script = $this->instanceJavascript[$this->format]; - $script = str_replace('[ELEMENT::NAME]', $this->getName(), $script); - $script = str_replace('[ELEMENT::ID]', $this->getId(), $script); - return $script; - } - } - - /** - * retrieves the element's current submitted state. - * - * @access public - * @return bool $state True if it has been submitted, false otherwise. - * @see submitted - */ - function isSubmitted() - { - if ( $this->submitted === true ) { - return true; - } - return false; - } - - /** - * returns the locale that is currently set for the form. - * - * @access public - * @return string $locale The locale. - * @see setLocale() - * @see $locale - */ - function getLocale() - { - return $this->locale; - } - - /** - * anounce a change in the element to all observers - * - * @access private - * @param string property that changed - * @param mixed new value of the property - */ - function _announce( $property, $value ) - { - $cnt = count( $this->observers ); - for ( $i = 0; $i < $cnt; $i++ ) - { - $this->observers[$i]->notify( $this, $property, $value ); - } - return true; - } -} diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/Rule.php b/airtime_mvc/library/propel/contrib/pat/patForms/Rule.php deleted file mode 100644 index 911c0965e..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/Rule.php +++ /dev/null @@ -1,340 +0,0 @@ - - * @license LGPL, see license.txt for details - * @link http://www.php-tools.net - * @todo implement javascript helper methods (set a javascript property plus an - * array of keys that will be replaced by the properties of the rule) - */ -class patForms_Rule -{ - /** - * time when the rule should be applied - * - * Possible values are: - * -PATFORMS_RULE_BEFORE_VALIDATION - * -PATFORMS_RULE_AFTER_VALIDATION - * -PATFORMS_RULE_BOTH - * - * @access private - * @var integer - */ - var $_time = PATFORMS_RULE_AFTER_VALIDATION; - - /** - * script that will be displayed only once - * - * @access private - * @var array - */ - var $globalScript = array(); - - /** - * script that will be displayed once per instance - * - * @access private - * @var array - */ - var $instanceScript = array(); - - /** - * properties that have to be replaced in the instance script. - * - * @access private - * @var array - */ - var $scriptPlaceholders = array(); - - /** - * store the container of the rule - * - * @access private - * @var object - */ - var $container; - - /** - * define error codes an messages for each form element - * - * @abstract - * @access private - * @var array - */ - var $validatorErrorCodes = array(); - - /** - * error code offset for the rule - * - * @abstract - * @access private - */ - var $errorOffset; - - /** - * format of the rule - * - * @abstract - * @access private - */ - var $format = 'html'; - - /** - * name of the rule - * - * @abstract - * @access private - */ - var $ruleName = ''; - - /** - * Get the time when the rule should be applied. - * - * This has to be defined in the _time property of the rule. - * - * @access public - * @return integer - */ - function getTime() - { - return $this->_time; - } - - /** - * create a new rule object - * - * @access public - * @param string id - */ - function patForms_Rule( $id = null ) - { - if ( $id === null ) - { - $id = uniqid( '' ); - } - - $this->_id = $id; - } - - /** - * set the id for the rule - * - * @access public - * @param string id - */ - function setId( $id ) - { - $this->_id = $id; - } - - /** - * set the locale, this is needed to update the rule - * translations, that have been passed to the container - * element - * - * @access public - * @param string new locale - * @return boolean - */ - function setLocale( $locale ) - { - // rules do not store locale information - if (!patForms::isCustomLocale($locale)) { - return true; - } - - $errorMessages = patForms::getCustomLocale($locale, 'Rule::' . $this->getRuleName()); - - if (is_array($errorMessages)) { - $this->validatorErrorCodes[$locale] = $errorMessages; - } - - $this->container->addValidatorErrorCodes( $this->validatorErrorCodes, $this->errorOffset ); - - return true; - } - - /** - * prepare the rule - * - * This method is used to initialize the rule. - * By default it adds it validatorErrorCodes - * to the container and stores a reference to the - * container. - * - * You may extend it in your custom rules, but should always be calling - * this method using: - * - * - * patForms_Rule::prepareRule( $container ); - * - * - * @access public - * @param object Either a patForms or patForms_Element object - */ - function prepareRule( &$container ) - { - $this->format = $container->getFormat(); - - $this->container = &$container; - $this->errorOffset = $container->getErrorOffset(); - - $container->addValidatorErrorCodes( $this->validatorErrorCodes, $this->errorOffset ); - - return true; - } - - /** - * method called by patForms or any patForms_Element to validate the - * element or the form. - * - * @abstract - * @access public - * @param object Either a patForms or patForms_Element object - * @return boolean true, if rule has been applied succesfully, false otherwise - */ - function applyRule( &$container, $type = PATFORMS_RULE_BEFORE_VALIDATION ) - { - // your code - } - - /** - * addValidationError - * - * @access private - * @param integer $code - * @param array $vars fill named placeholder with values - * @return boolean $result true on success - */ - function addValidationError( $code, $vars = array() ) - { - $code= $this->errorOffset + $code; - return $this->container->addValidationError( $code, $vars ); - } - - /** - * get the name of the rule - * - * By default just return the classname, this is sufficient. - * - * @access public - * @return string - */ - function getRuleName() - { - if (!empty($this->ruleName)) { - return $this->ruleName; - } - return get_class( $this ); - } - - /** - * get the global javascript of the rule - * - * @access public - * @return string - * @todo Rules need to know the output format - */ - /* - function getGlobalJavascript() - { - if ( isset( $this->globalScript['html'] ) ) - { - return $this->globalScript['html']; - } - return ''; - } - */ - - /** - * get the instance javascript of the rule - * - * @access public - * @return string - */ - /* - function getInstanceJavascript() - { - if ( !isset( $this->instanceScript[$this->format] ) ) - { - return false; - } - // get the script for the current format - $script = $this->instanceScript[$this->format]; - - // always replace the id - $script = str_replace( '[RULE::ID]', $this->_id, $script ); - if ( method_exists( $this->container, 'getId' ) ) - { - $script = str_replace( '[CONTAINER::ID]', $this->container->getId(), $script ); - } - if ( method_exists( $this->container, 'getName' ) ) - { - $script = str_replace( '[CONTAINER::NAME]', $this->container->getName(), $script ); - } - - foreach ( $this->scriptPlaceholders as $placeholder => $property ) - { - if ( isset( $this->$property ) ) - $script = str_replace( '['.$placeholder.']', $this->$property, $script ); - else - $script = str_replace( '['.$placeholder.']', '', $script ); - } - return $script; - } - */ - - function registerJavascripts(&$form) { - - if ($script = $this->getGlobalJavascript()) { - $form->registerGlobalJavascript($this->getRuleName(), $script); - } - - if ($script = $this->getInstanceJavascript()) { - $form->registerInstanceJavascript($script); - } - } - - function getGlobalJavascript() { - - if (isset($this->globalScript[$this->format])) { - return $this->globalScript[$this->format]; - } - } - - function getInstanceJavascript(){ - - if (isset($this->instanceScript[$this->format])) { - $script = $this->instanceScript[$this->format]; - $script = str_replace('[RULE::ID]', $this->_id, $script); - if (method_exists($this->container, 'getId')) { - $script = str_replace('[CONTAINER::ID]', $this->container->getId(), $script); - } - if (method_exists($this->container, 'getName')) { - $script = str_replace('[CONTAINER::NAME]', $this->container->getName(), $script); - } - foreach ($this->scriptPlaceholders as $placeholder => $property) { - if (isset($this->$property)) { - $script = str_replace('['.$placeholder.']', $this->$property, $script); - } else { - $script = str_replace('['.$placeholder.']', '', $script); - } - } - return $script; - } - } -} diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/Rule/Match.php b/airtime_mvc/library/propel/contrib/pat/patForms/Rule/Match.php deleted file mode 100644 index 3d47185f2..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/Rule/Match.php +++ /dev/null @@ -1,163 +0,0 @@ - - * @license LGPL, see license.txt for details - * @link http://www.php-tools.net - */ -class patForms_Rule_Match extends patForms_Rule -{ - /** - * script that will be displayed only once - * - * @access private - * @var array - */ - - var $globalScript = array( - 'html' => "/* patForms::Rule::Match */ - -function pFRC_Match(field) { - this.field = eval('pfe_' + field); -} - -pFRC_Match.prototype.validate = function() { - value = this.field.getValue(); - if (!value.match(this.pattern)) { - alert('This is an invalid value.'); - } -} - -pFRC_Match.prototype.setValue = function(pattern) { - this.pattern = pattern; -} - -/* END: patForms::Rule::Match */ -" - ); - - /** - * javascript that will be displayed once per instance - * - * @access private - * @var array - */ - var $instanceScript = array( - 'html' => "var pfr_[RULE::ID] = new pFRC_Match('[CONTAINER::NAME]');\n" - ); - - /** - * properties that have to be replaced in the instance script. - * - * @access private - * @var array - */ - var $scriptPlaceholders = array( - 'RULE::SOURCE' => '_source', - ); - - /** - * name of the rule - * - * @abstract - * @access private - */ - var $ruleName = 'Match'; - - /** - * define error codes and messages for the rule - * - * @access private - * @var array $validatorErrorCodes - * @todo translate error messages - */ - var $validatorErrorCodes = array( - "C" => array( - 1 => "This is an invalid value.", - ), - "de" => array( - 1 => "Dies ist ein ungültiger Wert.", - ), - "fr" => array( - 1 => "This is an invalid value.", - ) - ); - - /** - * the regEx pattern - * @access private - * @var string - */ - var $_pattern; - - /** - * field id that is used - * @access private - * @var string - */ - var $_field; - - private $value = 10; - - public function __construct($params) { - - parent::__construct(); - - extract($params); - $this->_pattern = $value; - } - - /** - * prepare the rule - * - * @access public - * @param object patForms - */ - function prepareRule(&$container) { - - patForms_Rule::prepareRule($container); - - $onChange = $container->getAttribute('onchange'); - $newHandler = sprintf('pfr_%s.validate();', $this->_id); - $container->setAttribute('onchange', $newHandler . $onChange); - - return true; - } - - /** - * method called by patForms or any patForms_Element to validate the - * element or the form. - * - * @access public - * @param object patForms form object - */ - function applyRule(&$element, $type = PATFORMS_RULE_AFTER_VALIDATION) { - - if (preg_match($this->_pattern, $element->getValue()) != 0){ - return true; - } - - $this->addValidationError(1); - return false; - } - - /** - * - * - * @access public - */ - function registerJavascripts(&$form) { - - parent::registerJavascripts($form); - - $script = sprintf("pfr_%s.setValue(%s);\n", $this->_id, $this->_pattern); - $form->registerInstanceJavascript($script); - } -} diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/Rule/MaxLength.php b/airtime_mvc/library/propel/contrib/pat/patForms/Rule/MaxLength.php deleted file mode 100644 index d28c2f758..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/Rule/MaxLength.php +++ /dev/null @@ -1,161 +0,0 @@ - - * @license LGPL, see license.txt for details - * @link http://www.php-tools.net - */ -class patForms_Rule_MaxLength extends patForms_Rule -{ - /** - * script that will be displayed only once - * - * @access private - * @var array - */ - var $globalScript = array( - 'html' => "/* patForms::Rule::MaxLength */ - -function pFRC_MaxLength(field) { - this.field = eval('pfe_' + field); -} - -pFRC_MaxLength.prototype.validate = function() { - value = this.field.getValue(); - if (value.length > this.value) { - alert('Please enter a value that is max. ' + this.value + ' characters long.'); - } -} - -pFRC_MaxLength.prototype.setValue = function(value) { - this.value = value; -} - -/* END: patForms::Rule::MaxLength */ -" - ); - - /** - * javascript that will be displayed once per instance - * - * @access private - * @var array - */ - var $instanceScript = array( - 'html' => "var pfr_[RULE::ID] = new pFRC_MaxLength('[CONTAINER::NAME]');\n" - ); - - /** - * properties that have to be replaced in the instance script. - * - * @access private - * @var array - */ - var $scriptPlaceholders = array( - 'RULE::SOURCE' => '_source', - ); - - /** - * name of the rule - * - * @abstract - * @access private - */ - var $ruleName = 'MaxLength'; - - /** - * define error codes and messages for the rule - * - * @access private - * @var array $validatorErrorCodes - * @todo translate error messages - */ - var $validatorErrorCodes = array( - "C" => array( - 1 => "Please enter a value that is max. [VALUE] characters long.", - ), - "de" => array( - 1 => "Bitte geben Sie einen max. [VALUE] Zeichen langen Wert ein.", - ), - "fr" => array( - 1 => "Please enter a value that is max. [VALUE] characters long.", - ) - ); - - /** - * possible values - * @access private - * @var array - */ - var $_values; - - /** - * field id that is used - * @access private - * @var string - */ - var $_field; - - private $value = 10; - - public function __construct($params) { - - parent::__construct(); - - extract($params); - $this->value = $value; - } - - /** - * prepare the rule - * - * @access public - * @param object patForms - */ - function prepareRule(&$container) { - - patForms_Rule::prepareRule($container); - - $onChange = $container->getAttribute('onchange'); - $newHandler = sprintf('pfr_%s.validate();', $this->_id); - $container->setAttribute('onchange', $newHandler . $onChange); - - return true; - } - - /** - * method called by patForms or any patForms_Element to validate the - * element or the form. - * - * @access public - * @param object patForms form object - */ - function applyRule(&$element, $type = PATFORMS_RULE_AFTER_VALIDATION) { - - if (strlen($element->getValue()) <= $this->value) { - return true; - } - - $this->addValidationError(1, array('value' => $this->value)); - return false; - } - - /** - * - * - * @access public - */ - function registerJavascripts(&$form) { - - parent::registerJavascripts($form); - - $script = sprintf("pfr_%s.setValue(%s);\n", $this->_id, $this->value); - $form->registerInstanceJavascript($script); - } -} diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/Rule/MaxValue.php b/airtime_mvc/library/propel/contrib/pat/patForms/Rule/MaxValue.php deleted file mode 100644 index 6b25b8c84..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/Rule/MaxValue.php +++ /dev/null @@ -1,163 +0,0 @@ - - * @license LGPL, see license.txt for details - * @link http://www.php-tools.net - */ -class patForms_Rule_MaxValue extends patForms_Rule -{ - /** - * script that will be displayed only once - * - * @access private - * @var array - */ - - var $globalScript = array( - 'html' => "/* patForms::Rule::MaxValue */ - -function pFRC_MaxValue(field) { - this.field = eval('pfe_' + field); -} - -pFRC_MaxValue.prototype.validate = function() { - value = this.field.getValue(); - if (parseInt(value) != value) { - alert('Please enter a number that is less or equal to ' + this.value); - } - if (parseInt(value) > this.value) { - alert('Please enter a number that is less or equal to ' + this.value); - } -} - -pFRC_MaxValue.prototype.setMaxValue = function(value) { - this.value = value; -} - -/* END: patForms::Rule::MaxValue */ -" - ); - - /** - * javascript that will be displayed once per instance - * - * @access private - * @var array - */ - var $instanceScript = array( - 'html' => "var pfr_[RULE::ID] = new pFRC_MaxValue('[CONTAINER::NAME]');\n" - ); - - /** - * properties that have to be replaced in the instance script. - * - * @access private - * @var array - */ - var $scriptPlaceholders = array( - 'RULE::SOURCE' => '_source', - ); - - /** - * name of the rule - * - * @abstract - * @access private - */ - var $ruleName = 'MaxValue'; - - /** - * define error codes and messages for the rule - * - * @access private - * @var array $validatorErrorCodes - * @todo translate error messages - */ - var $validatorErrorCodes = array( - "C" => array( - 1 => "Please enter a number that is less or equal to [VALUE].", - ), - "de" => array( - 1 => "Bitte geben Sie eine Zahl kleiner oder gleich [VALUE] ein.", - ), - "fr" => array( - 1 => "Please enter a number that is less or equal to [VALUE].", - ) - ); - - /** - * the regEx pattern - * @access private - * @var string - */ - var $_value; - - /** - * field id that is used - * @access private - * @var string - */ - var $_field; - - public function __construct($params) { - - parent::__construct(); - - extract($params); - $this->_value = $value; - } - - /** - * prepare the rule - * - * @access public - * @param object patForms - */ - function prepareRule(&$container) { - - patForms_Rule::prepareRule($container); - - $onChange = $container->getAttribute('onchange'); - $newHandler = sprintf('pfr_%s.validate();', $this->_id); - $container->setAttribute('onchange', $newHandler . $onChange); - - return true; - } - - /** - * method called by patForms or any patForms_Element to validate the - * element or the form. - * - * @access public - * @param object patForms form object - */ - function applyRule(&$element, $type = PATFORMS_RULE_AFTER_VALIDATION) { - - if (intval($element->getValue()) <= intval($this->_value)){ - return true; - } - - $this->addValidationError(1, array('value' => $this->_value)); - return false; - } - - /** - * - * - * @access public - */ - function registerJavascripts(&$form) { - - parent::registerJavascripts($form); - - $script = sprintf("pfr_%s.setMaxValue(%s);\n", $this->_id, $this->_value); - $form->registerInstanceJavascript($script); - } -} diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/Rule/MinLength.php b/airtime_mvc/library/propel/contrib/pat/patForms/Rule/MinLength.php deleted file mode 100644 index 427600e49..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/Rule/MinLength.php +++ /dev/null @@ -1,161 +0,0 @@ - - * @license LGPL, see license.txt for details - * @link http://www.php-tools.net - */ -class patForms_Rule_MinLength extends patForms_Rule -{ - /** - * script that will be displayed only once - * - * @access private - * @var array - */ - var $globalScript = array( - 'html' => "/* patForms::Rule::MinLength */ - -function pFRC_MinLength(field) { - this.field = eval('pfe_' + field); -} - -pFRC_MinLength.prototype.validate = function() { - value = this.field.getValue(); - if (value.length < this.value) { - alert('Please enter a value that is at least ' + this.value + ' characters long.'); - } -} - -pFRC_MinLength.prototype.setValue = function(value) { - this.value = value; -} - -/* END: patForms::Rule::MinLength */ -" - ); - - /** - * javascript that will be displayed once per instance - * - * @access private - * @var array - */ - var $instanceScript = array( - 'html' => "var pfr_[RULE::ID] = new pFRC_MinLength('[CONTAINER::NAME]');\n" - ); - - /** - * properties that have to be replaced in the instance script. - * - * @access private - * @var array - */ - var $scriptPlaceholders = array( - 'RULE::SOURCE' => '_source', - ); - - /** - * name of the rule - * - * @abstract - * @access private - */ - var $ruleName = 'MinLength'; - - /** - * define error codes and messages for the rule - * - * @access private - * @var array $validatorErrorCodes - * @todo translate error messages - */ - var $validatorErrorCodes = array( - "C" => array( - 1 => "Please enter a value that is at least [VALUE] characters long.", - ), - "de" => array( - 1 => "Bitte geben Sie einen mindestens [VALUE] Zeichen langen Wert ein.", - ), - "fr" => array( - 1 => "Please enter a value that is at least [VALUE] characters long.", - ) - ); - - /** - * possible values - * @access private - * @var array - */ - var $_values; - - /** - * field id that is used - * @access private - * @var string - */ - var $_field; - - private $value = 10; - - public function __construct($params) { - - parent::__construct(); - - extract($params); - $this->value = $value; - } - - /** - * prepare the rule - * - * @access public - * @param object patForms - */ - function prepareRule(&$container) { - - patForms_Rule::prepareRule($container); - - $onChange = $container->getAttribute('onchange'); - $newHandler = sprintf('pfr_%s.validate();', $this->_id); - $container->setAttribute('onchange', $newHandler . $onChange); - - return true; - } - - /** - * method called by patForms or any patForms_Element to validate the - * element or the form. - * - * @access public - * @param object patForms form object - */ - function applyRule(&$element, $type = PATFORMS_RULE_AFTER_VALIDATION) { - - if (strlen($element->getValue()) >= $this->value) { - return true; - } - - $this->addValidationError(1, array('value' => $this->value)); - return false; - } - - /** - * - * - * @access public - */ - function registerJavascripts(&$form) { - - parent::registerJavascripts($form); - - $script = sprintf("pfr_%s.setValue(%s);\n", $this->_id, $this->value); - $form->registerInstanceJavascript($script); - } -} diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/Rule/MinValue.php b/airtime_mvc/library/propel/contrib/pat/patForms/Rule/MinValue.php deleted file mode 100644 index f31b107a4..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/Rule/MinValue.php +++ /dev/null @@ -1,165 +0,0 @@ - - * @license LGPL, see license.txt for details - * @link http://www.php-tools.net - */ -class patForms_Rule_MinValue extends patForms_Rule -{ - /** - * script that will be displayed only once - * - * @access private - * @var array - */ - - var $globalScript = array( - 'html' => "/* patForms::Rule::MinValue */ - -function pFRC_MinValue(field) { - this.field = eval('pfe_' + field); -} - -pFRC_MinValue.prototype.validate = function() { - value = this.field.getValue(); - if (parseInt(value) != value) { - alert('Please enter a number that is greater or equal to ' + this.value); - } - if (parseInt(value) < this.value) { - alert('Please enter a number that is greater or equal to ' + this.value); - } -} - -pFRC_MinValue.prototype.setMinValue = function(value) { - this.value = value; -} - -/* END: patForms::Rule::MinValue */ -" - ); - - /** - * javascript that will be displayed once per instance - * - * @access private - * @var array - */ - var $instanceScript = array( - 'html' => "var pfr_[RULE::ID] = new pFRC_MinValue('[CONTAINER::NAME]');\n" - ); - - /** - * properties that have to be replaced in the instance script. - * - * @access private - * @var array - */ - var $scriptPlaceholders = array( - 'RULE::SOURCE' => '_source', - ); - - /** - * name of the rule - * - * @abstract - * @access private - */ - var $ruleName = 'MinValue'; - - /** - * define error codes and messages for the rule - * - * @access private - * @var array $validatorErrorCodes - * @todo translate error messages - */ - var $validatorErrorCodes = array( - "C" => array( - 1 => "Please enter a number that is greater or equal to [VALUE].", - ), - "de" => array( - 1 => "Bitte geben Sie eine Zahl größer oder gleich [VALUE] ein.", - ), - "fr" => array( - 1 => "Please enter a number that is greater or equal to [VALUE].", - ) - ); - - /** - * the regEx pattern - * @access private - * @var string - */ - var $_value; - - /** - * field id that is used - * @access private - * @var string - */ - var $_field; - - private $value = 10; - - public function __construct($params) { - - parent::__construct(); - - extract($params); - $this->_value = $value; - } - - /** - * prepare the rule - * - * @access public - * @param object patForms - */ - function prepareRule(&$container) { - - patForms_Rule::prepareRule($container); - - $onChange = $container->getAttribute('onchange'); - $newHandler = sprintf('pfr_%s.validate();', $this->_id); - $container->setAttribute('onchange', $newHandler . $onChange); - - return true; - } - - /** - * method called by patForms or any patForms_Element to validate the - * element or the form. - * - * @access public - * @param object patForms form object - */ - function applyRule(&$element, $type = PATFORMS_RULE_AFTER_VALIDATION) { - - if (intval($element->getValue()) >= intval($this->_value)){ - return true; - } - - $this->addValidationError(1, array('value' => $this->_value)); - return false; - } - - /** - * - * - * @access public - */ - function registerJavascripts(&$form) { - - parent::registerJavascripts($form); - - $script = sprintf("pfr_%s.setMinValue(%s);\n", $this->_id, $this->_value); - $form->registerInstanceJavascript($script); - } -} diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/Rule/NotMatch.php b/airtime_mvc/library/propel/contrib/pat/patForms/Rule/NotMatch.php deleted file mode 100644 index c0ff7f365..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/Rule/NotMatch.php +++ /dev/null @@ -1,163 +0,0 @@ - - * @license LGPL, see license.txt for details - * @link http://www.php-tools.net - */ -class patForms_Rule_NotMatch extends patForms_Rule -{ - /** - * script that will be displayed only once - * - * @access private - * @var array - */ - - var $globalScript = array( - 'html' => "/* patForms::Rule::NotMatch */ - -function pFRC_NotMatch(field) { - this.field = eval('pfe_' + field); -} - -pFRC_NotMatch.prototype.validate = function() { - value = this.field.getValue(); - if (value.match(this.pattern)) { - alert('This is an invalid value.'); - } -} - -pFRC_NotMatch.prototype.setValue = function(pattern) { - this.pattern = pattern; -} - -/* END: patForms::Rule::NotMatch */ -" - ); - - /** - * javascript that will be displayed once per instance - * - * @access private - * @var array - */ - var $instanceScript = array( - 'html' => "var pfr_[RULE::ID] = new pFRC_NotMatch('[CONTAINER::NAME]');\n" - ); - - /** - * properties that have to be replaced in the instance script. - * - * @access private - * @var array - */ - var $scriptPlaceholders = array( - 'RULE::SOURCE' => '_source', - ); - - /** - * name of the rule - * - * @abstract - * @access private - */ - var $ruleName = 'NotMatch'; - - /** - * define error codes and messages for the rule - * - * @access private - * @var array $validatorErrorCodes - * @todo translate error messages - */ - var $validatorErrorCodes = array( - "C" => array( - 1 => "This is an invalid value.", - ), - "de" => array( - 1 => "Dies ist ein ungültiger Wert.", - ), - "fr" => array( - 1 => "This is an invalid value.", - ) - ); - - /** - * the regEx pattern - * @access private - * @var string - */ - var $_pattern; - - /** - * field id that is used - * @access private - * @var string - */ - var $_field; - - private $value = 10; - - public function __construct($params) { - - parent::__construct(); - - extract($params); - $this->_pattern = $value; - } - - /** - * prepare the rule - * - * @access public - * @param object patForms - */ - function prepareRule(&$container) { - - patForms_Rule::prepareRule($container); - - $onChange = $container->getAttribute('onchange'); - $newHandler = sprintf('pfr_%s.validate();', $this->_id); - $container->setAttribute('onchange', $newHandler . $onChange); - - return true; - } - - /** - * method called by patForms or any patForms_Element to validate the - * element or the form. - * - * @access public - * @param object patForms form object - */ - function applyRule(&$element, $type = PATFORMS_RULE_AFTER_VALIDATION) { - - if (preg_match($this->_pattern, $element->getValue()) == 0){ - return true; - } - - $this->addValidationError(1); - return false; - } - - /** - * - * - * @access public - */ - function registerJavascripts(&$form) { - - parent::registerJavascripts($form); - - $script = sprintf("pfr_%s.setValue(%s);\n", $this->_id, $this->_pattern); - $form->registerInstanceJavascript($script); - } -} diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/Rule/ValidValues.php b/airtime_mvc/library/propel/contrib/pat/patForms/Rule/ValidValues.php deleted file mode 100644 index 290ace0ed..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/Rule/ValidValues.php +++ /dev/null @@ -1,182 +0,0 @@ - - * @license LGPL, see license.txt for details - * @link http://www.php-tools.net - */ -class patForms_Rule_ValidValues extends patForms_Rule -{ - /** - * script that will be displayed only once - * - * @access private - * @var array - */ - var $globalScript = array( - 'html' => "/* patForms::Rule::ValidValues */ - -Array.prototype.inArray = function(value) { - var i; - for (i=0; i < this.length; i++) { - if (this[i] === value) { - return true; - } - } - return false; -}; - -function pFRC_ValidValue(field) { - this.field = eval('pfe_' + field); -} - -pFRC_ValidValue.prototype.validate = function() { - value = this.field.getValue(); - for (var i = 0; i < this.values.length; i++) { - if (this.values[i] === value) { - return true; - } - } - var msg = 'Please enter one of the following values: '; - for (var i = 0; i < this.values.length; i++) { - msg = msg + this.values[i]; - if (i < this.values.length - 1) { - msg = msg + ', '; - } - } - alert(msg); -} - -pFRC_ValidValue.prototype.setValues = function(values) { - this.values = values; -} - -/* END: patForms::Rule::ValidValue */ -" - ); - - /** - * javascript that will be displayed once per instance - * - * @access private - * @var array - */ - var $instanceScript = array( - 'html' => "var pfr_[RULE::ID] = new pFRC_ValidValue('[CONTAINER::NAME]');\n" - ); - - /** - * properties that have to be replaced in the instance script. - * - * @access private - * @var array - */ - var $scriptPlaceholders = array( - 'RULE::SOURCE' => '_source', - ); - - /** - * name of the rule - * - * @abstract - * @access private - */ - var $ruleName = 'ValidValue'; - - /** - * define error codes and messages for the rule - * - * @access private - * @var array $validatorErrorCodes - * @todo translate error messages - */ - var $validatorErrorCodes = array( - "C" => array( - 1 => "Please enter one of the following values: [VALUES].", - ), - "de" => array( - 1 => "Bitte geben Sie einen der folgenden Werte ein: [VALUES].", - ), - "fr" => array( - 1 => "Please enter one of the following values: [VALUES].", - ) - ); - - /** - * possible values - * @access private - * @var array - */ - var $_values; - - /** - * field id that is used - * @access private - * @var string - */ - var $_field; - - public function __construct($params) { - - parent::__construct(); - - extract($params); - $this->_values = explode('|', $value); - } - - /** - * prepare the rule - * - * @access public - * @param object patForms - */ - function prepareRule(&$container) { - - patForms_Rule::prepareRule($container); - - $onChange = $container->getAttribute('onchange'); - $newHandler = sprintf('pfr_%s.validate();', $this->_id); - $container->setAttribute('onchange', $newHandler . $onChange); - - return true; - } - - /** - * method called by patForms or any patForms_Element to validate the - * element or the form. - * - * @access public - * @param object patForms form object - */ - function applyRule(&$element, $type = PATFORMS_RULE_AFTER_VALIDATION) { - - if (in_array($element->getValue(), $this->_values)) { - return true; - } - - $this->addValidationError(1, array('values' => implode(', ', $this->_values))); - return false; - } - - /** - * - * - * @access public - */ - function registerJavascripts(&$form) { - - parent::registerJavascripts($form); - - foreach ($this->_values as $value) { - $values[] = "'$value'"; - } - $script = sprintf("pfr_%s.setValues(new Array(%s));\n", $this->_id, implode(', ', $values)); - $form->registerInstanceJavascript($script); - } -} diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/Storage/Propel.php b/airtime_mvc/library/propel/contrib/pat/patForms/Storage/Propel.php deleted file mode 100644 index f90c81dbb..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/Storage/Propel.php +++ /dev/null @@ -1,146 +0,0 @@ -peer = new $peername(); - $this->peername = $peername; - - $parts = explode('.', explode('.', $this->peer->getOMClass())); - $this->classname = array_pop($parts); - - $this->setPrimaryField('Id'); - } - - private function getCriteria($values) { - - $object = new $this->classname(); - //$object->populateFromArray($values); //TODO use a workaround until we'll get phpNamed keys in populateFromArray() - $object = $this->populateObjectFromArray($object, $values); - return $object->buildPkeyCriteria(); - } - - /** - * get an entry - * - * This tries to find an entry in the storage container - * that matches the current data that has been set in the - * form and populates the form with the data of this - * entry - * - * @access public - * @param object patForms patForms object that should be stored - * @return boolean true on success - */ - public function loadEntry(&$form) { - - if (!$object = $this->_entryExists($form->getValues())) { - // entry does not exists (why return an array here??) - return array(); - } - - $form->setValues($object->toArray()); - return true; - } - - public function validateEntry(&$form) { - - if (!$object = $this->_entryExists($form->getValues())) { - $object = new $this->classname(); - } - //$object->populateFromArray($form->getValues()); //TODO use a workaround until we'll get phpNamed keys in populateFromArray() - $object = $this->populateObjectFromArray($object, $form->getValues()); - $result = $object->validate(); - - if ($result !== true) { - $mapBuilder = $this->peer->getMapBuilder(); - $dbMap = $mapBuilder->getDatabaseMap(); - foreach ($result as $colname => $error) { - list($tablename, $colname) = explode('.', $colname); - $column = $dbMap->getTable($tablename)->getColumn($colname); - $element = $form->getElement($column->getPhpName()); - $element->addValidatorErrorCodes(array( - 'C' => array( - 1 => $error->getMessage() . ' (occured in Storage)', - ), - ), 1000); - $element->addValidationError(1001); - } - return false; - } - } - - /** - * adds an entry to the storage - * - * @param object patForms patForms object that should be stored - * @return boolean true on success - */ - public function _addEntry(&$form) { - - $object = new $this->classname(); - //$object->populateFromArray($form->getValues()); //TODO use a workaround until we'll get phpNamed keys in populateFromArray() - $object = $this->populateObjectFromArray($object, $form->getValues()); - $object->save(); - return true; - } - - /** - * updates an entry in the storage - * - * @param object patForms patForms object that should be stored - * @return boolean true on success - */ - public function _updateEntry(&$form, $primary) { - - $object = $this->_entryExists($form->getValues()); - //$object->populateFromArray($form->getValues()); //TODO use a workaround until we'll get phpNamed keys in populateFromArray() - $object = $this->populateObjectFromArray($object, $form->getValues()); - $object->save(); - return true; - } - - /** - * check, whether an entry exists - * - * @access private - * @param array - */ - public function _entryExists($values) { - - // This method gets called multiple times, e.g. when an existing - // object gets updated. We'll therefor cache results locally using - // a criteria string representation as hash. - - static $objects; - $criteria = $this->getCriteria($values); - $hash = $criteria->toString(); - - if (isset($objects[$hash])) { - return $objects[$hash]; - } - - $objects[$hash] = $this->peer->doSelectOne($criteria); - - if (empty($objects[$hash])) { - return false; - } - return $objects[$hash]; - } - - // this method is just a workaround - - private function populateObjectFromArray($object, $values) { - - foreach (array_keys($object->toArray()) as $key) { - if (array_key_exists($key, $values)) { - $object->{'set' . $key}($values[$key]); - } - } - return $object; - } -} diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/res/form.dynamic.tpl b/airtime_mvc/library/propel/contrib/pat/patForms/res/form.dynamic.tpl deleted file mode 100644 index 3935ea6c1..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/res/form.dynamic.tpl +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - {TITLE} - - - - - - - {START} - -
-

Validation failed

-

Sorry, your input could not be saved for the following reasons:

-
    - -
  • {FIELD}: {MESSAGE}
  • -
    -
-
-
- - - {ELEMENT} - - -
- -
{ELEMENT}
-
{DESCRIPTION}
-
-
-
-
- -
- {END} -
- - - -
\ No newline at end of file diff --git a/airtime_mvc/library/propel/contrib/pat/patForms/res/mysql-dump.bookstore.sql b/airtime_mvc/library/propel/contrib/pat/patForms/res/mysql-dump.bookstore.sql deleted file mode 100644 index 48c0ceeb1..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms/res/mysql-dump.bookstore.sql +++ /dev/null @@ -1,10 +0,0 @@ - -# This first example is tested with a Bookstore project on MySql -# (default setting Sqlite has not been tested) -# -# Additionally, you'll need some data in your tables. In case you -# don't have - here's a mini-dump to get the example running. - -INSERT INTO `author` VALUES (1, 'Martin', 'Heidegger'); -INSERT INTO `book` VALUES (1, 'Sein und Zeit', '3484701226', NULL, NULL); -INSERT INTO `publisher` VALUES (1, 'Max Niemeyer Verlag'); \ No newline at end of file diff --git a/airtime_mvc/library/propel/contrib/pat/patForms_Storage_Propel_test.php b/airtime_mvc/library/propel/contrib/pat/patForms_Storage_Propel_test.php deleted file mode 100644 index 04d3bdff1..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patForms_Storage_Propel_test.php +++ /dev/null @@ -1,97 +0,0 @@ - 2); - - -/** - * the rest should work out of the box if you don't have any unusal - * types in your database schema.xml (strings, int etc. should work) - */ - -require_once 'bookstore/' . $classname . '.php'; -Propel::init($propelConfFilename); - -// create a form definition - -$definition = patForms_Definition_Propel::create(array( - 'name' => $classname, - 'filename' => $path . '/form.' . $classname . '.xml', -)); - -// create a storage - -$storage = patForms::createStorage('Propel'); -$storage->setStorageLocation($classname . 'peer'); - -// create a form - -$form = &patForms::createCreator('Definition')->create($definition); -$form->setRenderer(patForms::createRenderer('Array')); -$form->setStorage($storage); -if (isset($pk)) { - $form->setValues($pk); -} - -// render it to a patTemplate (could be done by other template engines) - -$tpl = new patTemplate(); -$tpl->setRoot($path); -$tpl->readTemplatesFromInput('form.dynamic.tpl'); - -$tpl->addVar('page', 'title', 'Bookstore party'); -$tpl->addVar('form', 'start', $form->serializeStart()); -$tpl->addVar('form', 'end', $form->serializeEnd()); -$tpl->addRows('elements', $form->renderForm()); - -// this should be possible to be done in a more elegant way -if ($errors = $form->getValidationErrors()) { - foreach ($errors as $field => $error) { - $tpl->addVar('error', 'field', $field); - foreach ($error as $line) { - $tpl->addVar('error', 'message', $line['message']); - $tpl->addVar('error', 'code', $line['code']); - $tpl->parseTemplate('error', 'a'); - } - } - $tpl->setAttribute('errors', 'visibility', 'visible'); -} - -$tpl->displayParsedTemplate(); diff --git a/airtime_mvc/library/propel/contrib/pat/patTemplate.php b/airtime_mvc/library/propel/contrib/pat/patTemplate.php deleted file mode 100644 index 01347f63a..000000000 --- a/airtime_mvc/library/propel/contrib/pat/patTemplate.php +++ /dev/null @@ -1,2378 +0,0 @@ - - * @license LGPL - * @link http://www.php-tools.net - */ - -/** - * template already exists - */ -define( 'PATTEMPLATE_ERROR_TEMPLATE_EXISTS', 5010 ); - -/** - * template does not exist - */ -define ( 'PATTEMPLATE_WARNING_NO_TEMPLATE', 5011 ); - -/** - * unknown type - */ -define ( 'PATTEMPLATE_WARNING_UNKNOWN_TYPE', 5012 ); - -/** - * base class for module could not be found - */ -define( 'PATTEMPLATE_ERROR_BASECLASS_NOT_FOUND', 5050 ); - -/** - * module could not be found - */ -define( 'PATTEMPLATE_ERROR_MODULE_NOT_FOUND', 5051 ); - -/** - * array expected - */ -define( 'PATTEMPLATE_ERROR_EXPECTED_ARRAY', 5052 ); - -/** - * No input - */ -define( 'PATTEMPLATE_ERROR_NO_INPUT', 6000 ); - -/** - * patTemplate - * - * powerful templating engine - * - * @version 3.0.0 - * @package patTemplate - * @author Stephan Schmidt - * @license LGPL - * @link http://www.php-tools.net - */ -class patTemplate -{ - /** - * standard system vars that identify pat tools - * @var array - */ - var $_systemVars = array( - 'appName' => 'patTemplate', - 'appVersion' => '3.0.0', - 'author' => array( - 'Stephan Schmidt ' - ) - ); - - /** - * default attributes for new templates - * @access private - * @var array - */ - var $_defaultAttributes = array( - 'type' => 'standard', - 'visibility' => 'visible', - 'loop' => 1, - 'unusedvars' => 'strip', - 'whitespace' => 'keep', - 'autoclear' => 'off', - 'autoload' => 'on' - ); - - /** - * options for patTemplate - * - * Currently the following options are implemented: - * - maintainBc defines, whether patTemplate should be backwards compatible. - * This means, that you may use 'default' and 'empty' for subtemplates. - * - * @access private - * @var array - */ - var $_options = array( - 'startTag' => '{', - 'endTag' => '}', - 'root' => '.', - 'namespace' => 'patTemplate', - 'maintainBc' => true - ); - - /** - * start tag - * - * @access private - * @var string - */ - var $_startTag = '{'; - - /** - * end tag - * - * @access private - * @var string - */ - var $_endTag = '}'; - - /** - * loaded modules - * - * Modules are: - * - Readers - * - Caches - * - Variable modifiers - * - Filters - * - * @access private - * @var array - */ - var $_modules = array(); - - /** - * directories, where modules can be stored - * @access private - * @var array - */ - var $_moduleDirs = array(); - - /** - * stores all template names - * @access private - * @var array - */ - var $_templateList = array(); - - /** - * stores all template data - * @access private - * @var array - */ - var $_templates = array(); - - /** - * stores all global variables - * @access private - * @var array - */ - var $_globals = array(); - - /** - * stores all local variables - * @access private - * @var array - */ - var $_vars = array(); - - /** - * stores the name of the first template that has been - * found - * - * @access private - * @var string - */ - var $_root; - - /** - * output filters that should be used - * - * @access private - * @var array - */ - var $_outputFilters = array(); - - /** - * input filters that should be used - * - * @access private - * @var array - */ - var $_inputFilters = array(); - - /** - * template cache, that should be used - * - * @access private - * @var array - */ - var $_tmplCache = null; - - /** - * Create a new patTemplate instance. - * - * The constructor accepts the type of the templates as sole parameter. - * You may choose one of: - * - html (default) - * - tex - * - * The type influences the tags you are using in your templates. - * - * @access public - * @param string type (either html or tex) - */ - function patTemplate( $type = 'html' ) - { - if ( !defined( 'PATTEMPLATE_INCLUDE_PATH' ) ) - define( 'PATTEMPLATE_INCLUDE_PATH', dirname( __FILE__ ) . '/patTemplate' ); - - $this->setType( $type ); - } - - /** - * sets an option - * - * Currently, the following options are supported - * - maintainBc (true|false) - * - namespace (string) - * - * @access public - * @param string option to set - * @param string value of the option - */ - function setOption( $option, $value ) - { - $this->_options[$option] = $value; - } - - /** - * gets an option - * - * @access public - * @param string option to get - * @return mixed value of the option - */ - function getOption( $option ) - { - if ( !isset( $this->_options[$option] ) ) - return null; - return $this->_options[$option]; - } - - /** - * sets name of directory where templates are stored - * - * @access public - * @param string dir where templates are stored - * @deprecated please use patTemplate::setRoot() instead - */ - function setBasedir( $basedir ) - { - $this->_options['root'] = $basedir; - } - - /** - * sets root base for the template - * - * The parameter depends on the reader you are using. - * - * @access public - * @param string root base of the templates - */ - function setRoot( $root ) - { - $this->_options['root'] = $root; - } - - /** - * gets name of root base for the templates - * - * @access public - * @return mixed root base - */ - function getRoot() - { - return $this->_options['root']; - } - - /** - * sets namespace of patTemplate tags - * - * @access public - * @param string namespace - */ - function setNamespace( $ns ) - { - $this->_options['namespace'] = $ns; - } - - /** - * gets namespace of patTemplate tags - * - * @access public - * @return string namespace - */ - function getNamespace() - { - return $this->_options['namespace']; - } - - /** - * set default attribute - * - * @access public - * @param string attribute name - * @param mixed attribute value - */ - function setDefaultAttribute( $name, $value ) - { - $this->_defaultAttributes[$name] = $value; - } - - /** - * set default attributes - * - * @access public - * @param array attributes - */ - function setDefaultAttributes( $attributes ) - { - $this->_defaultAttributes = array_merge( $this->_defaultAttributes, $attributes ); - } - - /** - * get default attributes - * - * @access public - * @return return default attributes - */ - function getDefaultAttributes() - { - return $this->_defaultAttributes; - } - - /** - * set the type for the templates - * - * @access public - * @param string type (html or tex) - * @return boolean true on success - */ - function setType( $type ) - { - switch( strtolower( $type ) ) - { - case "tex": - $this->setTags( '<{', '}>' ); - break; - case "html": - $this->setTags( '{', '}' ); - break; - default: - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_UNKNOWN_TYPE, - "Unknown type '$type'. Please use 'html' or 'tex'." - ); - } - return true; - } - - /** - * set the start and end tag for variables - * - * @access public - * @param string start tag - * @param string end tag - * @return boolean true on success - */ - function setTags( $startTag, $endTag ) - { - $this->_options['startTag'] = $startTag; - $this->_options['endTag'] = $endTag; - - $this->_startTag = $startTag; - $this->_endTag = $endTag; - return true; - } - - /** - * get start tag for variables - * - * @access public - * @return string start tag - */ - function getStartTag() - { - return $this->_options['startTag']; - } - - /** - * get end tag for variables - * - * @access public - * @return string end tag - */ - function getEndTag() - { - return $this->_options['endTag']; - } - - /** - * add a directory where patTemplate should search for - * modules. - * - * You may either pass a string or an array of directories. - * - * patTemplate will be searching for a module in the same - * order you added them. If the module cannot be found in - * the custom folders, it will look in - * patTemplate/$moduleType. - * - * @access public - * @param string module type - * @param string|array directory or directories to search. - */ - function addModuleDir( $moduleType, $dir ) - { - if ( !isset( $this->_moduleDirs[$moduleType] ) ) - $this->_moduleDirs[$moduleType] = array(); - if ( is_array( $dir ) ) - $this->_moduleDirs[$moduleType] = array_merge( $this->_moduleDirs[$moduleType], $dir ); - else - array_push( $this->_moduleDirs[$moduleType], $dir ); - } - - /** - * Sets an attribute of a template - * - * supported attributes: visibilty, loop, parse, unusedvars - * - * @param string $template name of the template - * @param string $attribute name of the attribute - * @param mixed $value value of the attribute - * @access public - * @see setAttributes(),getAttribute(), clearAttribute() - */ - function setAttribute( $template, $attribute, $value ) - { - $template = strtolower( $template ); - if ( !isset( $this->_templates[$template] ) ) - { - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_NO_TEMPLATE, - "Template '$template' does not exist." - ); - } - - $attribute = strtolower( $attribute ); - $this->_templates[$template]['attributes'][$attribute] = $value; - return true; - } - - /** - * Sets several attribute of a template - * - * $attributes has to be a assotiative arrays containing attribute/value pairs - * supported attributes: visibilty, loop, parse, unusedvars - * - * @param string $template name of the template - * @param array $attributes attribute/value pairs - * @access public - * @see setAttribute(), getAttribute(), clearAttribute() - */ - function setAttributes( $template, $attributes ) - { - if ( !is_array( $attributes ) ) - { - return patErrorManager::raiseError( PATTEMPLATE_ERROR_EXPECTED_ARRAY, 'patTemplate::setAttributes: Expected array as second parameter, '.gettype( $attributes ).' given' ); - } - - $template = strtolower( $template ); - $attributes = array_change_key_case( $attributes ); - if ( !isset( $this->_templates[$template] ) ) - { - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_NO_TEMPLATE, - "Template '$template' does not exist." - ); - } - - $this->_templates[$template]['attributes'] = array_merge( $this->_templates[$template]['attributes'], $attributes ); - return true; - } - - /** - * Get all attributes of a template - * - * @param string name of the template - * @return array attributes - * @access public - */ - function getAttributes( $template ) - { - $template = strtolower( $template ); - if ( !isset( $this->_templates[$template] ) ) - { - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_NO_TEMPLATE, - "Template '$template' does not exist." - ); - } - return $this->_templates[$template]['attributes']; - } - - /** - * Gets an attribute of a template - * - * supported attributes: visibilty, loop, parse, unusedvars - * - * @param string $template name of the template - * @param string $attribute name of the attribute - * @return mixed value of the attribute - * @access public - * @see setAttribute(), setAttributes(), clearAttribute() - */ - function getAttribute( $template, $attribute ) - { - $template = strtolower( $template ); - $attribute = strtolower( $attribute ); - if ( !isset( $this->_templates[$template] ) ) - { - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_NO_TEMPLATE, - "Template '$template' does not exist." - ); - } - return $this->_templates[$template]['attributes'][$attribute]; - } - - /** - * Clears an attribute of a template - * - * supported attributes: visibilty, loop, parse, unusedvars - * - * @param string $template name of the template - * @param string $attribute name of the attribute - * @access public - * @see setAttribute(), setAttributes(), getAttribute() - */ - function clearAttribute( $template, $attribute ) - { - $template = strtolower( $template ); - $attribute = strtolower( $attribute ); - - if ( !isset( $this->_templates[$template] ) ) - { - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_NO_TEMPLATE, - "Template '$template' does not exist." - ); - } - $this->_templates[$template]['attributes'][$attribute] = '';; - return true; - } - - /** - * Prepare a template - * - * This can be used if you want to add variables to - * a template, that has not been loaded yet. - * - * @access public - * @param string template name - */ - function prepareTemplate( $name ) - { - $name = strtolower( $name ); - if ( !isset( $this->_vars[$name] ) ) - { - $this->_vars[$name] = array( - 'scalar' => array(), - 'rows' => array() - ); - } - } - - /** - * add a variable to a template - * - * A variable may also be an indexed array, but _not_ - * an associative array! - * - * @access public - * @param string $template name of the template - * @param string $varname name of the variable - * @param mixed $value value of the variable - */ - function addVar( $template, $varname, $value ) - { - $template = strtolower( $template ); - $varname = strtoupper( $varname ); - - if ( !is_array( $value ) ) - { - $this->_vars[$template]['scalar'][$varname] = $value; - return true; - } - - $cnt = count( $value ); - for ( $i = 0; $i < $cnt; $i++ ) - { - if ( !isset( $this->_vars[$template]['rows'][$i] ) ) - $this->_vars[$template]['rows'][$i] = array(); - - $this->_vars[$template]['rows'][$i][$varname] = $value[$i]; - } - - return true; - } - - /** - * get the value of a variable - * - * @access public - * @param string name of the template - * @param string name of the variable - * @return string value of the variable, null if the variable is not set - */ - function getVar( $template, $varname ) - { - $template = strtolower( $template ); - $varname = strtoupper( $varname ); - - if ( isset( $this->_vars[$template]['scalar'][$varname] ) ) - return $this->_vars[$template]['scalar'][$varname]; - - $value = array(); - - $cnt = count( $this->_vars[$template]['rows'] ); - for ( $i = 0; $i < $cnt; $i++ ) - { - if ( !isset( $this->_vars[$template]['rows'][$i][$varname] ) ) - continue; - array_push( $value, $this->_vars[$template]['rows'][$i][$varname] ); - } - if ( !empty( $value ) ) - return $value; - return null; - } - - /** - * Adds several variables to a template - * - * Each Template can have an unlimited amount of its own variables - * $variables has to be an assotiative array containing variable/value pairs - * - * @param string $template name of the template - * @param array $variables assotiative array of the variables - * @param string $prefix prefix for all variable names - * @access public - * @see addVar(), addRows(), addGlobalVar(), addGlobalVars() - */ - function addVars( $template, $variables, $prefix = '' ) - { - $template = strtolower( $template ); - $prefix = strtoupper( $prefix ); - $variables = array_change_key_case( $variables, CASE_UPPER ); - - foreach ( $variables as $varname => $value ) - { - $varname = $prefix.$varname; - - if ( !is_array( $value ) ) { - if (!is_scalar($value)) { - continue; - } - $this->_vars[$template]['scalar'][$varname] = $value; - continue; - } - - $cnt = count( $value ); - for ( $i = 0; $i < $cnt; $i++ ) - { - if ( !isset( $this->_vars[$template]['rows'][$i] ) ) - $this->_vars[$template]['rows'][$i] = array(); - - $this->_vars[$template]['rows'][$i][$varname] = $value[$i]; - } - } - } - - /** - * Adds several rows of variables to a template - * - * Each Template can have an unlimited amount of its own variables - * Can be used to add a database result as variables to a template - * - * @param string $template name of the template - * @param array $rows array containing assotiative arrays with variable/value pairs - * @param string $prefix prefix for all variable names - * @access public - * @see addVar(), addVars(), addGlobalVar(), addGlobalVars() - */ - function addRows( $template, $rows, $prefix = '' ) - { - $template = strtolower( $template ); - $prefix = strtoupper( $prefix ); - - $cnt = count( $rows ); - for ( $i = 0; $i < $cnt; $i++ ) - { - if ( !isset( $this->_vars[$template]['rows'][$i] ) ) - $this->_vars[$template]['rows'][$i] = array(); - - $rows[$i] = array_change_key_case( $rows[$i], CASE_UPPER ); - - foreach ( $rows[$i] as $varname => $value ) - { - $this->_vars[$template]['rows'][$i][$prefix.$varname] = $value; - } - } - } - - /** - * Adds an object to a template - * - * All properties of the object will be available as template variables. - * - * @param string name of the template - * @param object|array object or array of objects - * @param string prefix for all variable names - * @access public - * @see addVar(), addRows(), addGlobalVar(), addGlobalVars() - */ - function addObject( $template, $object, $prefix = '' ) - { - if ( is_array( $object ) ) - { - $rows = array(); - foreach ( $object as $o ) - array_push( $rows, get_object_vars( $o ) ); - - $this->addRows( $template, $rows, $prefix ); - return true; - } - elseif ( is_object( $object ) ) - { - $this->addVars( $template, get_object_vars( $object ), $prefix ); - return true; - } - return false; - } - - /** - * Adds a global variable - * - * Global variables are valid in all templates of this object. - * A global variable has to be scalar, it will be converted to a string. - * - * @access public - * @param string $varname name of the global variable - * @param string $value value of the variable - * @return boolean true on success - * @see addGlobalVars(), addVar(), addVars(), addRows() - */ - function addGlobalVar( $varname, $value ) - { - $this->_globals[strtoupper( $varname )] = ( string )$value; - return true; - } - - /** - * Adds several global variables - * - * Global variables are valid in all templates of this object. - * - * $variables is an associative array, containing name/value pairs of the variables. - * - * @access public - * @param array $variables array containing the variables - * @param string $prefix prefix for variable names - * @return boolean true on success - * @see addGlobalVar(), addVar(), addVars(), addRows() - */ - function addGlobalVars( $variables, $prefix = '' ) - { - $variables = array_change_key_case( $variables, CASE_UPPER ); - $prefix = strtoupper( $prefix ); - foreach ( $variables as $varname => $value ) - { - $this->_globals[$prefix.$varname] = ( string )$value; - } - return true; - } - - /** - * get all global variables - * - * @access public - * @return array global variables - */ - function getGlobalVars() - { - return $this->_globals; - } - - /** - * checks wether a template exists - * - * @access public - * @param string name of the template - * @return boolean true, if the template exists, false otherwise - */ - function exists( $name ) - { - return in_array( strtolower( $name ), $this->_templateList ); - } - - /** - * enable a template cache - * - * A template cache will improve performace, as the templates - * do not have to be read on each request. - * - * @access public - * @param string name of the template cache - * @param array parameters for the template cache - * @return boolean true on success, patError otherwise - */ - function useTemplateCache( $cache, $params = array() ) - { - if ( !is_object( $cache ) ) - { - $cache = &$this->loadModule( 'TemplateCache', $cache, $params ); - } - if ( patErrorManager::isError( $cache ) ) - return $cache; - - $this->_tmplCache = &$cache; - return true; - } - - /** - * enable an output filter - * - * Output filters are used to modify the template - * result before it is sent to the browser. - * - * They are applied, when displayParsedTemplate() is called. - * - * @access public - * @param string name of the output filter - * @param array parameters for the output filter - * @return boolean true on success, patError otherwise - */ - function applyOutputFilter( $filter, $params = array() ) - { - if ( !is_object( $filter ) ) - { - $filter = &$this->loadModule( 'OutputFilter', $filter, $params ); - } - if ( patErrorManager::isError( $filter ) ) - return $filter; - - $this->_outputFilters[] = &$filter; - return true; - } - - /** - * enable an input filter - * - * input filters are used to modify the template - * stream before it is split into smaller templates- - * - * @access public - * @param string name of the input filter - * @param array parameters for the input filter - * @return boolean true on success, patError otherwise - */ - function applyInputFilter( $filter, $params = array() ) - { - if ( !is_object( $filter ) ) - { - $filter = &$this->loadModule( 'InputFilter', $filter, $params ); - } - if ( patErrorManager::isError( $filter ) ) - return $filter; - - $this->_inputFilters[] = &$filter; - return true; - } - - /** - * open a file and parse for patTemplate tags - * - * @access public - * @param name of the file - * @return true, if the template could be parsed - * @deprecated Use patTemplate::readTemplatesFromInput() instead, as the method name is misleading - * @see readTemplatesFromInput() - */ - function readTemplatesFromFile( $filename ) - { - return $this->readTemplatesFromInput( $filename, 'File' ); - } - - /** - * open any input and parse for patTemplate tags - * - * @access public - * @param string name of the input (filename, shm segment, etc.) - * @param string driver that is used as reader, you may also pass a Reader object - * @param array additional options that will only be used for this template - * @param string name of the template that should be used as a container, should not be used by public - * calls. - * @return boolean true, if the template could be parsed, false otherwise - */ - function readTemplatesFromInput( $input, $reader = 'File', $options = null, $parseInto = null ) - { - if ($input === '') { - return patErrorManager::raiseError(PATTEMPLATE_ERROR_NO_INPUT, 'No input to read has been passed.'); - } - - if ( is_array( $options ) ) - $options = array_merge( $this->_options, $options ); - else - $options = $this->_options; - - if ( !is_null( $parseInto ) ) - $parseInto = strtolower( $parseInto ); - - $templates = false; - if ( $this->_tmplCache !== null ) - { - /** - * get the unique cache key - */ - $key = $this->_tmplCache->getKey( $input, $options ); - - $templates = $this->_loadTemplatesFromCache( $input, $reader, $options, $key ); - - /** - * check for error returned from cache - */ - if ( patErrorManager::isError( $templates ) ) - return $templates; - } - - /** - * templates have not been loaded from cache - */ - if ( $templates === false ) - { - if ( !is_object( $reader ) ) - { - $reader = &$this->loadModule( 'Reader', $reader ); - if ( patErrorManager::isError( $reader ) ) - return $reader; - } - $reader->setOptions( $options ); - - /** - * set the root attributes - */ - if ( !is_null( $parseInto ) ) - { - $attributes = $this->getAttributes( $parseInto ); - if ( !patErrorManager::isError( $attributes ) ) - { - $reader->setRootAttributes( $attributes ); - } - } - - $templates = $reader->readTemplates( $input ); - - /** - * check for error returned from reader - */ - if ( patErrorManager::isError( $templates ) ) - return $templates; - - /** - * store the - */ - if ( $this->_tmplCache !== null ) - { - $this->_tmplCache->write( $key, $templates ); - } - } - - /** - * traverse all templates - */ - foreach ( $templates as $name => $spec ) - { - /** - * root template - */ - if ( $name == '__ptroot' ) - { - if ( $parseInto === false ) - { - continue; - } - if ( !in_array( $parseInto, $this->_templateList ) ) - continue; - - $spec['loaded'] = true; - $spec['attributes'] = $this->_templates[$parseInto]['attributes']; - $name = $parseInto; - } - else - { - /** - * store the name - */ - array_push( $this->_templateList, $name ); - } - - /** - * if this is the first template that has been loaded - * set it as the root template - */ - if ( $this->_root === null && is_null( $parseInto ) && isset( $spec['isRoot'] ) && $spec['isRoot'] == true ) - { - $this->_root = $name; - } - - /** - * set some default values - */ - $spec['iteration'] = 0; - $spec['lastMode'] = 'w'; - $spec['result'] = ''; - $spec['modifyVars'] = array(); - $spec['copyVars'] = array(); - $spec['defaultVars'] = array(); - - /** - * store the template - */ - $this->_templates[$name] = $spec; - - $this->prepareTemplate( $name ); - - /** - * store the default values of the variables - */ - foreach ( $spec['varspecs'] as $varname => $varspec ) - { - if ( isset( $varspec['modifier'] ) ) - { - $this->_templates[$name]['modifyVars'][$varname] = $varspec['modifier']; - } - - if ( isset( $varspec['copyfrom'] ) ) - { - $this->_templates[$name]['copyVars'][$varname] = $varspec['copyfrom']; - } - - if ( !isset( $varspec['default'] ) ) - continue; - - $this->_templates[$name]['defaultVars'][$varname] = $varspec['default']; - - if ( !is_null( $this->getVar( $name, $varname ) ) ) - continue; - - $this->addVar( $name, $varname, $varspec['default'] ); - } - - unset($this->_templates[$name]['varspecs']); - - /** - * autoload the template - * - * Some error management is needed here... - */ - if ( isset( $this->_templates[$name]['attributes']['src'] ) && $this->_templates[$name]['attributes']['autoload'] == 'on' ) - { - if ( $this->_templates[$name]['loaded'] !== true ) - { - if ( $this->_templates[$name]['attributes']['parse'] == 'on' ) - { - $this->readTemplatesFromInput( $this->_templates[$name]['attributes']['src'], $this->_templates[$name]['attributes']['reader'], $options, $name ); - } - else - { - $this->loadTemplateFromInput( $this->_templates[$name]['attributes']['src'], $this->_templates[$name]['attributes']['reader'], null, $name ); - } - $this->_templates[$name]['loaded'] = true; - } - } - } - - return true; - } - - /** - * load from template cache - * - * @access private - * @param string name of the input (filename, shm segment, etc.) - * @param string driver that is used as reader, you may also pass a Reader object - * @param array options for the reader - * @param string cache key - * @return array|boolean either an array containing the templates, or false - */ - function _loadTemplatesFromCache( $input, &$reader, $options, $key ) - { - if ( is_object( $reader ) ) - $statName = $reader->getName(); - else - $statName = $reader; - - $stat = &$this->loadModule( 'Stat', $statName ); - $stat->setOptions( $options ); - - /** - * get modification time - */ - $modTime = $stat->getModificationTime( $input ); - $templates = $this->_tmplCache->load( $key, $modTime ); - - return $templates; - } - - /** - * open any input and load content into template - * - * @access public - * @param string name of the input (filename, shm segment, etc.) - * @param string driver that is used as reader - * @param string name of the template that should be used as a container, - * @return boolean true, if the template could be parsed, false otherwise - */ - function loadTemplateFromInput( $input, $reader = 'File', $options = null, $parseInto = false ) - { - if ( is_array( $options ) ) - $options = array_merge( $this->_options, $options ); - else - $options = $this->_options; - - if ( !is_null( $parseInto ) ) - $parseInto = strtolower( $parseInto ); - - $reader = &$this->loadModule( 'Reader', $reader ); - if ( patErrorManager::isError( $reader ) ) - { - return $reader; - } - $reader->setOptions($options); - - $result = $reader->loadTemplate( $input ); - - if ( patErrorManager::isError( $result ) ) - { - return $result; - } - - $this->_templates[$parseInto]['content'] .= $result; - $this->_templates[$parseInto]['loaded'] = true; - return true; - } - - /** - * load a template that had autoload="off" - * - * This is needed, if you change the source of a template and want to - * load it, after changing the attribute. - * - * @access public - * @param string template name - * @return boolean true, if template could be loaded - */ - function loadTemplate( $template ) - { - $template = strtolower( $template ); - if ( !isset( $this->_templates[$template] ) ) - { - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_NO_TEMPLATE, - "Template '$template' does not exist." - ); - } - - if ( $this->_templates[$template]['loaded'] === true ) - return true; - - if ( $this->_templates[$template]['attributes']['parse'] == 'on' ) - { - return $this->readTemplatesFromInput( $this->_templates[$template]['attributes']['src'], $this->_templates[$template]['attributes']['reader'], null, $template ); - } - else - { - return $this->loadTemplateFromInput( $this->_templates[$template]['attributes']['src'], $this->_templates[$template]['attributes']['reader'], null, $template ); - } - } - - /** - * loads a patTemplate module - * - * Modules are located in the patTemplate folder and include: - * - Readers - * - Caches - * - Variable Modifiers - * - Filters - * - Functions - * - Stats - * - * @access public - * @param string moduleType (Reader|TemplateCache|Modifier|OutputFilter|InputFilter) - * @param string moduleName - * @param array parameters for the module - * @return object - */ - function &loadModule( $moduleType, $moduleName, $params = array() ) - { - if ( !isset( $this->_modules[$moduleType] ) ) - $this->_modules[$moduleType] = array(); - - $sig = md5( $moduleName . serialize( $params ) ); - - if ( isset( $this->_modules[$moduleType][$sig] ) ) - return $this->_modules[$moduleType][$sig]; - - if ( !class_exists( 'patTemplate_Module' ) ) - { - $file = sprintf( "%s/Module.php", $this->getIncludePath() ); - if ( !@include_once $file ) - return patErrorManager::raiseError( PATTEMPLATE_ERROR_BASECLASS_NOT_FOUND, 'Could not load module base class.' ); - } - - $baseClass = 'patTemplate_' . $moduleType; - if ( !class_exists( $baseClass ) ) - { - $baseFile = sprintf( "%s/%s.php", $this->getIncludePath(), $moduleType ); - if ( !@include_once $baseFile ) - return patErrorManager::raiseError( PATTEMPLATE_ERROR_BASECLASS_NOT_FOUND, "Could not load base class for $moduleType ($baseFile)." ); - } - - $moduleClass = 'patTemplate_' . $moduleType . '_' .$moduleName; - if ( !class_exists( $moduleClass ) ) - { - if ( isset( $this->_moduleDirs[$moduleType] ) ) - $dirs = $this->_moduleDirs[$moduleType]; - else - $dirs = array(); - array_push( $dirs, $this->getIncludePath() .'/'. $moduleType ); - - foreach ( $dirs as $dir ) - { - $moduleFile = sprintf( "%s/%s.php", $dir, str_replace( '_', '/', $moduleName ) ); - if ( @include_once $moduleFile ) - break; - return patErrorManager::raiseError( PATTEMPLATE_ERROR_MODULE_NOT_FOUND, "Could not load module $moduleClass ($moduleFile)." ); - } - } - - if ( !class_exists( $moduleClass ) ) - { - return patErrorManager::raiseError( PATTEMPLATE_ERROR_MODULE_NOT_FOUND, "Module file $moduleFile does not contain class $moduleClass." ); - } - - $this->_modules[$moduleType][$sig] = &new $moduleClass; - if ( method_exists( $this->_modules[$moduleType][$sig], 'setTemplateReference' ) ) - { - $this->_modules[$moduleType][$sig]->setTemplateReference( $this ); - } - - $this->_modules[$moduleType][$sig]->setParams( $params ); - - return $this->_modules[$moduleType][$sig]; - } - - /** - * checks whether a module exists. - * - * Modules are located in the patTemplate folder and include: - * - Readers - * - Caches - * - Variable Modifiers - * - Filters - * - Functions - * - Stats - * - * @access public - * @param string moduleType (Reader|TemplateCache|Modifier|OutputFilter|InputFilter) - * @param string moduleName - * @return boolean - */ - function moduleExists( $moduleType, $moduleName ) - { - if ( isset( $this->_moduleDirs[$moduleType] ) ) - $dirs = $this->_moduleDirs[$moduleType]; - else - $dirs = array(); - array_push( $dirs, $this->getIncludePath() .'/'. $moduleType ); - - foreach ( $dirs as $dir ) - { - $moduleFile = sprintf( "%s/%s.php", $dir, str_replace( '_', '/', $moduleName ) ); - if ( !file_exists( $moduleFile ) ) - continue; - if ( !is_readable( $moduleFile ) ) - continue; - return true; - } - return false; - } - - /** - * parses a template - * - * Parses a template and stores the parsed content. - * mode can be "w" for write (delete already parsed content) or "a" for append (appends the - * new parsed content to the already parsed content) - * - * @access public - * @param string name of the template - * @param string mode for the parsing - */ - function parseTemplate( $template, $mode = 'w' ) - { - $template = strtolower( $template ); - - if ( !isset( $this->_templates[$template] ) ) - { - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_NO_TEMPLATE, - "Template '$template' does not exist." - ); - } - - /** - * template is not visible - */ - if ( $this->_templates[$template]['attributes']['visibility'] == 'hidden' ) - { - $this->_templates[$template]['result'] = ''; - $this->_templates[$template]['parsed'] = true; - return true; - } - - /** - * check, if the template has been loaded - * and load it if necessary. - */ - if ( $this->_templates[$template]['loaded'] !== true ) - { - if ( $this->_templates[$template]['attributes']['parse'] == 'on' ) - { - $result = $this->readTemplatesFromInput( $this->_templates[$template]['attributes']['src'], $this->_templates[$template]['attributes']['reader'], null, $template ); - } - else - { - $result = $this->loadTemplateFromInput( $this->_templates[$template]['attributes']['src'], $this->_templates[$template]['attributes']['reader'], null, $template ); - } - if ( patErrorManager::isError( $result ) ) - { - return $result; - } - } - - /** - * check for autoclear - */ - if ( - isset( $this->_templates[$template]['attributes']['autoclear'] ) && - $this->_templates[$template]['attributes']['autoclear'] == 'yes' && - $mode === 'w' && - $this->_templates[$template]['lastMode'] != 'a' - ) - { - $this->_templates[$template]['parsed'] = false; - } - - /** - * template has been parsed and mode is not 'append' - */ - if ( $this->_templates[$template]['parsed'] === true && $mode === 'w' ) - { - return true; - } - - $this->_templates[$template]['lastMode'] = $mode; - - $this->_initTemplate( $template ); - - if ( !isset( $this->_vars[$template]['rows'] ) ) - $this->_vars[$template]['rows'] = array(); - $loop = count( $this->_vars[$template]['rows'] ); - - /** - * loop at least one times - */ - if ( $loop < 1 ) - $loop = 1; - - if ( isset( $this->_templates[$template]['attributes']['maxloop'] ) ) - { - $loop = ceil( $loop / $this->_templates[$template]['attributes']['maxloop'] ) * $this->_templates[$template]['attributes']['maxloop']; - } - - $this->_templates[$template]['loop'] = max( $this->_templates[$template]['attributes']['loop'], $loop ); - - $start = 0; - if ( isset( $this->_templates[$template]['attributes']['limit'] ) ) - { - $p = strpos( $this->_templates[$template]['attributes']['limit'], ',' ); - if ( $p === false ) - { - $this->_templates[$template]['loop'] = min( $this->_templates[$template]['loop'], $this->_templates[$template]['attributes']['limit'] ); - $start = 0; - } - else - { - $start = substr( $this->_templates[$template]['attributes']['limit'], 0, $p ); - $end = substr( $this->_templates[$template]['attributes']['limit'], $p+1 )+$start; - - $this->_templates[$template]['loop'] = min( $this->_templates[$template]['loop'], $end ); - } - } - - /** - * template should be cleared before parsing - */ - if ( $mode == 'w' ) - { - $this->_templates[$template]['result'] = ''; - $this->_templates[$template]['iteration'] = $start; - } - - $loopCount = 0; - for ( $i = $start; $i < $this->_templates[$template]['loop']; $i++ ) - { - $finished = false; - - unset( $this->_templates[$template]['vars'] ); - - /** - * fetch the variables - */ - $this->_fetchVariables( $template ); - - /** - * fetch the template - */ - $result = $this->_fetchTemplate( $template ); - - if ( $result === false ) - { - $this->_templates[$template]['iteration']++; - continue; - } - - /** - * parse - */ - $this->_parseVariables( $template ); - $this->_parseDependencies( $template ); - - /** - * store result - */ - $this->_templates[$template]['result'] .= $this->_templates[$template]['work']; - - $this->_templates[$template]['iteration']++; - - ++$loopCount; - - /** - * check for maximum loops - */ - if ( isset( $this->_templates[$template]['attributes']['maxloop'] ) ) - { - if ( $loopCount == $this->_templates[$template]['attributes']['maxloop'] && $i < ( $loop-1 ) ) - { - $loopCount = 0; - $finished = true; - $this->_templates[$template]['parsed'] = true; - $this->parseTemplate( $this->_templates[$template]['attributes']['parent'], 'a' ); - $this->_templates[$template]['parsed'] = false; - $this->_templates[$template]['result'] = ''; - } - } - } - - if ( !$finished && isset( $this->_templates[$template]['attributes']['maxloop'] ) ) - { - $this->_templates[$template]['parsed'] = true; - $this->parseTemplate( $this->_templates[$template]['attributes']['parent'], 'a', false ); - $this->_templates[$template]['parsed'] = false; - $this->_templates[$template]['result'] = ''; - $this->_templates[$this->_templates[$template]['attributes']['parent']]['work'] = ''; - } - - $this->_parseGlobals($template); - - $this->_handleUnusedVars( $template ); - - $this->_templates[$template]['parsed'] = true; - - if ( isset( $this->_templates[$template]['attributes']['autoclear'] ) && $this->_templates[$template]['attributes']['autoclear'] == 'yes' ) - { - $this->_vars[$template] = array( - 'scalar' => array(), - 'rows' => array() - ); - } - - return true; - } - - /** - * Initialize a template - * - * This method checks the variable specifications and - * copys variables from other templates. - * - * @access private - * @param string name of the template - * @return boolean true on success - */ - function _initTemplate( $template ) - { - foreach ( $this->_templates[$template]['copyVars'] as $dest => $src ) - { - /** - * copy from the same template - */ - if ( !is_array( $src ) ) - { - $srcTemplate = $template; - $srcVar = $src; - } - else - { - $srcTemplate = $src[0]; - $srcVar = $src[1]; - } - - $copied = false; - - /** - * copy from another template - */ - if ( isset( $this->_vars[$srcTemplate] ) ) - { - if ( isset( $this->_vars[$srcTemplate]['scalar'][$srcVar] ) ) - { - $this->_vars[$template]['scalar'][$dest] = $this->_vars[$srcTemplate]['scalar'][$srcVar]; - continue; - } - - $rows = count( $this->_vars[$srcTemplate]['rows'] ); - - for ( $i = 0; $i < $rows; $i++ ) - { - if ( !isset( $this->_vars[$srcTemplate]['rows'][$i][$srcVar] ) ) - continue; - if ( !isset( $this->_vars[$template]['rows'][$i] ) ) - $this->_vars[$template]['rows'][$i] = array(); - $this->_vars[$template]['rows'][$i][$dest] = $this->_vars[$srcTemplate]['rows'][$i][$srcVar]; - $copied = true; - } - } - if ( !$copied && isset( $this->_globals[$srcVar] )) - { - $this->_vars[$template]['scalar'][$dest] = $this->_globals[$srcVar]; - } - - } - return true; - } - - /** - * parse all variables in a template - * - * @access private - * @param string - */ - function _parseVariables( $template ) - { - /** - * modify variables before parsing - */ - $this->_applyModifers($template, $this->_templates[$template]['vars']); - - foreach ( $this->_templates[$template]['vars'] as $key => $value ) - { - if ( is_array( $value ) ) - { - if ( count( $this->_templates[$template]['currentDependencies'] ) == 1 ) - { - $child = $this->_templates[$template]['currentDependencies'][0]; - } - else - { - if ( isset( $this->_templates[$template]['attributes']['child'] ) ) - $child = $this->_templates[$template]['attributes']['child']; - else - continue; - } - - $this->setAttribute( $child, 'autoclear', 'yes' ); - $this->addVar( $child, $key, $value ); - continue; - } - - $var = $this->_startTag.$key.$this->_endTag; - $this->_templates[$template]['work'] = @str_replace( $var, $value, $this->_templates[$template]['work'] ); - } - return true; - } - - /** - * parse global variables in the template - * - * @access private - * @param string name of the template - * @return boolean - */ - function _parseGlobals($template) - { - $globalVars = $this->_globals; - $this->_applyModifers($template, $globalVars); - - foreach ( $globalVars as $key => $value ) - { - if ( is_array( $value ) ) - { - continue; - } - - $var = $this->_startTag.$key.$this->_endTag; - $this->_templates[$template]['result'] = str_replace( $var, $value, $this->_templates[$template]['result'] ); - } - return true; - } - - /** - * apply variable modifiers - * - * The variables will be passed by reference. - * - * @access private - * @param string name of the template (use modifiers from this template) - * @param array variables to which the modifiers should be applied - * @return boolean - */ - function _applyModifers($template, &$vars) - { - foreach ( $this->_templates[$template]['modifyVars'] as $varname => $modifier ) - { - if ( !isset( $vars[$varname] ) ) - continue; - - if ( ( $modifier['type'] === 'php' || $modifier['type'] === 'auto' ) && is_callable( $modifier['mod'] ) ) - { - $vars[$varname] = call_user_func( $modifier['mod'], $vars[$varname] ); - continue; - } - - if ( $modifier['type'] === 'php' ) - continue; - - $mod = &$this->loadModule( 'Modifier', ucfirst( $modifier['mod'] ) ); - $vars[$varname] = $mod->modify( $vars[$varname], $modifier['params'] ); - } - return true; - } - - /** - * parse all dependencies in a template - * - * @access private - * @param string - */ - function _parseDependencies( $template ) - { - $countDep = count( $this->_templates[$template]['currentDependencies'] ); - for ( $i = 0; $i < $countDep; $i++ ) - { - $depTemplate = $this->_templates[$template]['currentDependencies'][$i]; - $this->parseTemplate( $depTemplate ); - $var = $this->_startTag.'TMPL:'.strtoupper( $depTemplate) .$this->_endTag; - $this->_templates[$template]['work'] = str_replace( $var, $this->_templates[$depTemplate]['result'], $this->_templates[$template]['work'] ); - } - return true; - } - - /** - * fetch plain template - * - * The template content will be stored in the template - * configuration so it can be used by other - * methods. - * - * @access private - * @param string template name - * @return boolean - */ - function _fetchTemplate( $template ) - { - switch( $this->_templates[$template]['attributes']['type'] ) - { - /** - * condition template - */ - case 'condition': - $value = $this->_getConditionValue( $template, $this->_templates[$template]['attributes']['conditionvar'] ); - if ( $value === false ) - { - $this->_templates[$template]['work'] = ''; - $this->_templates[$template]['currentDependencies'] = array(); - } - else - { - $this->_templates[$template]['work'] = $this->_templates[$template]['subtemplates'][$value]['data']; - $this->_templates[$template]['currentDependencies'] = $this->_templates[$template]['subtemplates'][$value]['dependencies']; - } - break; - - /** - * condition template - */ - case 'simplecondition': - foreach ( $this->_templates[$template]['attributes']['requiredvars'] as $var ) - { - if ( $var[0] !== $template ) - $this->_fetchVariables($var[0]); - - if ( isset( $this->_templates[$var[0]]['vars'][$var[1]] ) && strlen( $this->_templates[$var[0]]['vars'][$var[1]] ) > 0 ) - continue; - if (isset($this->_templates[$template]['attributes']['useglobals'])) - { - if (isset($this->_globals[$var[1]]) && strlen($this->_globals[$var[1]]) > 1) - continue; - } - - $this->_templates[$template]['work'] = ''; - $this->_templates[$template]['currentDependencies'] = array(); - break 2; - } - $this->_templates[$template]['work'] = $this->_templates[$template]['content']; - $this->_templates[$template]['currentDependencies'] = $this->_templates[$template]['dependencies']; - break; - - /** - * modulo template - */ - case 'modulo': - // check for empty template - if ($this->_hasVariables($template)) { - $value = ( $this->_templates[$template]['iteration'] + 1 ) % $this->_templates[$template]['attributes']['modulo']; - } else { - $value = '__empty'; - } - - $value = $this->_getConditionValue( $template, $value, false ); - if ( $value === false ) - { - $this->_templates[$template]['work'] = ''; - $this->_templates[$template]['currentDependencies'] = array(); - } - else - { - $this->_templates[$template]['work'] = $this->_templates[$template]['subtemplates'][$value]['data']; - $this->_templates[$template]['currentDependencies'] = $this->_templates[$template]['subtemplates'][$value]['dependencies']; - } - break; - - /** - * standard template - */ - default: - $this->_templates[$template]['work'] = $this->_templates[$template]['content']; - $this->_templates[$template]['currentDependencies'] = $this->_templates[$template]['dependencies']; - break; - } - return true; - } - - /** - * check, whether a template contains variables - * - * @access private - * @param string template name - * @return boolean - */ - function _hasVariables($template) - { - if (!empty($this->_vars[$template]['scalar'])) { - return true; - } - if (isset($this->_vars[$template]['rows'][$this->_templates[$template]['iteration']])) { - return true; - } - return false; - } - - /** - * fetch the value of a condition variable - * - * _fetchVariables() has to be called before this - * method is being called. - * - * @access private - * @param string template name - * @param string condition value - * @param boolean flag that indicates whether value is the name of the variable that should be resolved - * - * @todo split this method into smaller check methods that will be called according to - * a priority list - */ - function _getConditionValue( $template, $value, $isVar = true ) - { - if ( $isVar === true ) - { - if ( isset( $this->_templates[$template]['attributes']['conditiontmpl'] ) ) - { - $_template = $this->_templates[$template]['attributes']['conditiontmpl']; - $this->_fetchVariables( $_template ); - } - else - { - $_template = $template; - } - - /** - * get the value from the template variables - */ - if ( !isset( $this->_templates[$_template]['vars'][$value] ) || strlen( $this->_templates[$_template]['vars'][$value] ) === 0 ) - { - if ( $this->_templates[$template]['attributes']['useglobals'] == 'yes' || $this->_templates[$template]['attributes']['useglobals'] == 'useglobals' ) - { - if ( isset( $this->_globals[$value] ) && strlen( $this->_globals[$value] ) > 0 ) - { - $value = $this->_globals[$value]; - } - else - { - $value = '__empty'; - } - } - else - { - $value = '__empty'; - } - } - else - { - $value = $this->_templates[$_template]['vars'][$value]; - } - } - else - { - $_template = $template; - } - - /** - * is __first? - */ - if ( $this->_templates[$_template]['iteration'] == 0 ) - { - if ( isset( $this->_templates[$template]['subtemplates']['__first'] ) ) - { - return '__first'; - } - } - - /** - * is __last? - */ - $max = $this->_templates[$_template]['loop'] - 1; - if ( $this->_templates[$_template]['iteration'] == $max ) - { - if ( isset( $this->_templates[$template]['subtemplates']['__last'] ) ) - { - return '__last'; - } - } - - /** - * found an exact match - */ - if ( isset( $this->_templates[$template]['subtemplates'][$value] ) ) - { - return $value; - } - - /** - * is __default? - */ - if ( isset( $this->_templates[$template]['subtemplates']['__default'] ) ) - { - return '__default'; - } - - return false; - } - - /** - * fetch variables for a template - * - * The variables will be stored in the template - * configuration so they can be used by other - * methods. - * - * @access private - * @param string template name - * @return boolean - */ - function _fetchVariables( $template ) - { - /** - * variables already have been fetched - */ - if ( isset( $this->_templates[$template]['vars'] ) ) - { - return true; - } - - $iteration = $this->_templates[$template]['iteration']; - - if ( isset( $this->_templates[$template]['attributes']['varscope'] ) ) - { - $scopeTemplate = $this->_templates[$template]['attributes']['varscope']; - if ($this->exists($scopeTemplate)) { - $this->_fetchVariables( $scopeTemplate ); - $vars = $this->_templates[$scopeTemplate]['vars']; - } else { - patErrorManager::raiseWarning(PATTEMPLATE_WARNING_NO_TEMPLATE, 'Template \''.$scopeTemplate.'\' does not exist, referenced in varscope attribute of template \''.$template.'\''); - $vars = array(); - } - } - else - { - $vars = array(); - } - - /** - * get the scalar variables - */ - if ( isset( $this->_vars[$template] ) && isset( $this->_vars[$template]['scalar'] ) ) - { - $vars = array_merge( $vars, $this->_vars[$template]['scalar'] ); - } - - /** - * get the row variables - */ - if ( isset( $this->_vars[$template]['rows'][$iteration] ) ) - { - $vars = array_merge( $vars, $this->_vars[$template]['rows'][$iteration] ); - } - - /** - * add some system variables - */ - $currentRow = $iteration + 1; - $vars['PAT_ROW_VAR'] = $currentRow; - - if ( $this->_templates[$template]['attributes']['type'] == 'modulo' ) - { - $vars['PAT_MODULO_REP'] = ceil( $currentRow / $this->_templates[$template]['attributes']['modulo'] ); - $vars['PAT_MODULO'] = ( $this->_templates[$template]['iteration'] + 1 ) % $this->_templates[$template]['attributes']['modulo']; - } - - if ( $this->_templates[$template]['attributes']['addsystemvars'] !== false ) - { - $vars['PATTEMPLATE_VERSION'] = $this->_systemVars['appVersion']; - $vars['PAT_LOOPS'] = $this->_templates[$template]['loop']; - - switch ($this->_templates[$template]['attributes']['addsystemvars']) - { - case 'boolean': - $trueValue = 'true'; - $falseValue = 'false'; - break; - case 'integer': - $trueValue = '1'; - $falseValue = '0'; - break; - default: - $trueValue = $this->_templates[$template]['attributes']['addsystemvars']; - $falseValue = ''; - break; - } - - $vars['PAT_IS_ODD'] = ( $currentRow % 2 == 1 ) ? $trueValue : $falseValue; - $vars['PAT_IS_EVEN'] = ( $currentRow % 2 == 0 ) ? $trueValue : $falseValue; - $vars['PAT_IS_FIRST'] = ( $currentRow == 1 ) ? $trueValue : $falseValue; - $vars['PAT_IS_LAST'] = ( $currentRow == $this->_templates[$template]['loop'] ) ? $trueValue : $falseValue; - } - - $this->_templates[$template]['vars'] = $vars; - return true; - } - - /** - * handle all unused variables in a template - * - * This is influenced by the 'unusedvars' attribute of the - * template - * - * @access private - * @param string - */ - function _handleUnusedVars( $template ) - { - $regexp = '/('.$this->_startTag.'[^a-z]+'.$this->_endTag.')/U'; - - switch( $this->_templates[$template]['attributes']['unusedvars'] ) - { - case 'comment': - $this->_templates[$template]['result'] = preg_replace( $regexp, '', $this->_templates[$template]['result'] ); - break; - case 'strip': - $this->_templates[$template]['result'] = preg_replace( $regexp, '', $this->_templates[$template]['result'] ); - break; - case 'nbsp': - $this->_templates[$template]['result'] = preg_replace( $regexp, ' ', $this->_templates[$template]['result'] ); - break; - case 'ignore': - break; - default: - $this->_templates[$template]['result'] = preg_replace( $regexp, $this->_templates[$template]['attributes']['unusedvars'], $this->_templates[$template]['result'] ); - break; - } - return true; - } - - /** - * returns a parsed Template - * - * If the template already has been parsed, it just returns the parsed template. - * If the template has not been loaded, it will be loaded. - * - * @access public - * @param string name of the template - * @return string Content of the parsed template - * @see displayParsedTemplate() - */ - function getParsedTemplate( $name = null ) - { - if ( is_null( $name ) ) - $name = $this->_root; - - $name = strtolower( $name ); - - $result = $this->parseTemplate( $name ); - - if ( patErrorManager::isError( $result ) ) - return $result; - - return $this->_templates[$name]['result']; - } - - /** - * displays a parsed Template - * - * If the template has not been loaded, it will be loaded. - * - * @see getParsedTemplate() - * @param string name of the template - * @return boolean true on success - * @access public - */ - function displayParsedTemplate( $name = null ) - { - $result = $this->getParsedTemplate( $name ); - - /** - * error happened - */ - if ( patErrorManager::isError( $result ) ) - return $result; - - $cnt = count( $this->_outputFilters ); - for ( $i = 0; $i < $cnt; $i++ ) - { - $result = $this->_outputFilters[$i]->apply( $result ); - } - - echo $result; - return true; - } - - /** - * parse a template and push the result into a variable of any other - * template - * - * If the template already has been parsed, it will just be pushed into the variable. - * If the template has not been loaded, it will be loaded. - * - * @access public - * @param string name of the template - * @return string Content of the parsed template - * @param boolean if set to true, the value will be appended to the value already stored. - * @see getParsedTemplate() - * @see addVar() - */ - function parseIntoVar( $srcTmpl, $destTmpl, $var, $append = false ) - { - $srcTmpl = strtolower( $srcTmpl ); - $destTmpl = strtolower( $destTmpl ); - $var = strtoupper($var); - - $result = $this->parseTemplate( $srcTmpl ); - - if ( patErrorManager::isError( $result ) ) - return $result; - - if ( $append !== true || !isset( $this->_vars[$destTmpl]['scalar'][$var] ) ) - $this->_vars[$destTmpl]['scalar'][$var] = ''; - - $this->_vars[$destTmpl]['scalar'][$var] .= $this->_templates[$srcTmpl]['result']; - - return true; - } - - /** - * clears a parsed Template - * - * Parsed Content, variables and the loop attribute are cleared - * - * If you will not be using this template anymore, then you should - * call freeTemplate() - * - * @access public - * @param string name of the template - * @param boolean set this to true to clear all child templates, too - * @see clearAllTemplates() - * @see freeTemplate() - */ - function clearTemplate( $name, $recursive = false ) - { - $name = strtolower( $name ); - $this->_templates[$name]['parsed'] = false; - $this->_templates[$name]['work'] = ''; - $this->_templates[$name]['iteration'] = 0; - $this->_templates[$name]['result'] = ''; - $this->_vars[$name] = array( - 'scalar' => array(), - 'rows' => array() - ); - if (!empty($this->_templates[$name]['defaultVars'])) { - foreach ($this->_templates[$name]['defaultVars'] as $varname => $value) { - $this->addVar($name, $varname, $value); - } - } - - /** - * clear child templates as well - */ - if ( $recursive === true ) - { - $deps = $this->_getDependencies( $name ); - foreach ( $deps as $dep ) - { - $this->clearTemplate( $dep, true ); - } - } - return true; - } - - /** - * clears all templates - * - * @access public - * @uses clearTemplate() - */ - function clearAllTemplates() - { - $templates = array_keys( $this->_templates ); - $cnt = count( $templates ); - for ( $i = 0; $i < $cnt; $i++ ) - { - $this->clearTemplate( $templates[$i] ); - } - return true; - } - - /** - * frees a template - * - * All memory consumed by the template - * will be freed. - * - * @access public - * @param string name of the template - * @param boolean clear dependencies of the template - * @see freeAllTemplates() - */ - function freeTemplate( $name, $recursive = false ) - { - $name = strtolower( $name ); - $key = array_search( $name, $this->_templateList ); - if ( $key === false ) - { - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_NO_TEMPLATE, - "Template '$name' does not exist." - ); - } - - unset( $this->_templateList[$key] ); - $this->_templateList = array_values( $this->_templateList ); - - /** - * free child templates as well - */ - if ( $recursive === true ) - { - $deps = $this->_getDependencies( $name ); - foreach ( $deps as $dep ) - { - $this->freeTemplate( $dep, true ); - } - } - - unset( $this->_templates[$name] ); - unset( $this->_vars[$name] ); - - return true; - } - - /** - * frees all templates - * - * All memory consumed by the templates - * will be freed. - * - * @access public - * @see freeTemplate() - */ - function freeAllTemplates() - { - $this->_templates = array(); - $this->_vars = array(); - } - - /** - * get _all_ dependencies of a template, - * regardless of the subtemplates - * - * @access private - * @param string template name - * @return array list of all subtemplates - */ - function _getDependencies( $template ) - { - $deps = array(); - if ( isset( $this->_templates[$template]['dependencies'] ) ) - $deps = $this->_templates[$template]['dependencies']; - - if ( isset( $this->_templates[$template]['subtemplates'] ) ) - { - foreach ( $this->_templates[$template]['subtemplates'] as $sub ) - { - if ( isset( $sub['dependencies'] ) ) - $deps = array_merge( $deps, $sub['dependencies'] ); - } - } - $deps = array_unique( $deps ); - return $deps; - } - - /** - * Displays useful information about all or named templates - * - * This method breaks BC, as it now awaits an array instead of - * unlimited parameters. - * - * @param mixed array of templates that should be dumped, or null if you - * want all templates to be dumped - * @param string dumper - * @access public - */ - function dump( $restrict = null, $dumper = 'Html' ) - { - if ( is_string( $restrict ) ) - $restrict = array( $restrict ); - - $dumper = &$this->loadModule( 'Dump', $dumper ); - - if ( patErrorManager::isError( $dumper ) ) - { - return $dumper; - } - - if ( is_null( $restrict ) ) - { - $templates = $this->_templates; - $vars = $this->_vars; - } - else - { - $restrict = array_map( 'strtolower', $restrict ); - - $templates = array(); - $vars = array(); - - foreach ( $this->_templates as $name => $spec ) - { - if ( !in_array( $name, $restrict ) ) - continue; - $templates[$name] = $spec; - $vars[$name] = $this->_vars[$name]; - } - } - - $dumper->displayHeader(); - $dumper->dumpGlobals( $this->_globals ); - $dumper->dumpTemplates( $templates, $vars ); - $dumper->displayFooter(); - - return true; - } - - /** - * get the include path - * - * @access public - */ - function getIncludePath() - { - return PATTEMPLATE_INCLUDE_PATH; - } - - /** - * apply input filters that have been set - * - * This is being called by the readers. - * - * @access public - * @param string template - * @return string filtered templeta - */ - function applyInputFilters( $template ) - { - $cnt = count( $this->_inputFilters ); - for ( $i = 0; $i < $cnt; $i++ ) - { - $template = $this->_inputFilters[$i]->apply( $template ); - } - return $template; - } - - /** - * Convert the template to its string representation. - * - * This method allows you to just echo the patTemplate - * object in order to display the template. - * - * Requires PHP5 - * - * - * $tmpl = new patTemplate(); - * $tmpl->readTemplatesFromFile( 'myfile.tmpl' ); - * echo $tmpl; - * - * - * @access private - * @return string - */ - function __toString() - { - return $this->getParsedTemplate(); - } -} diff --git a/airtime_mvc/library/propel/contrib/pear/HTML_QuickForm_Propel/Propel.php b/airtime_mvc/library/propel/contrib/pear/HTML_QuickForm_Propel/Propel.php deleted file mode 100644 index 6a51e84fa..000000000 --- a/airtime_mvc/library/propel/contrib/pear/HTML_QuickForm_Propel/Propel.php +++ /dev/null @@ -1,909 +0,0 @@ -. - */ - -require_once 'HTML/QuickForm.php'; - -define('HTML_QUICKFORM_PROPEL_NO_COLUMNS', 2); -define('HTML_QUICKFORM_PROPEL_ALL_COLUMNS', 3); -define('HTML_QUICKFORM_PROPEL_COLUMN_MADE_VISIBLE', 4); -define('HTML_QUICKFORM_PROPEL_COLUMN_MADE_HIDDEN', 5); - -/* On large foreign table resultsets propel choked */ -# ini_set('memory_limit', '50M'); - -/** - * - * NOTE: HTML_QuickForm_Propel extends HTML_QuickForm, so all QuickForm functionality is available. - * - * A fictive example: - * - * $className = 'book'; - * $id = '7'; // existing item - * $id = null; // when no id is passed, it's assumed we are creating a new item - * - * $quickForm = new HTML_QuickForm_Propel($className, $id); // optionally pass it to the constructor - * $quickForm->setAction('/Bookstore/Form'); - * $quickForm->addElement('header', '', 'HTML_QuickForm_Propel'); - * $quickForm->setId($id); - * $quickForm->setClassName($className); - * $quickForm->setTarget('_self'); - * $quickForm->setMethod('post'); - * - * // use this to override the default behaviour for - * // foreign table select boxes, UserPeer::UNAME will be shown in the select list. - * // It defaults to the first string column in the foreign table. - * - * $quickForm->joinColumn(bookPeer::PUBLISHER_ID,UserPeer::UNAME); - * - * // default to all columns shown - * $quickForm->setColumnMode(HTML_QUICKFORM_PROPEL_ALL_COLUMNS); - * $quickForm->hideColumn('PASS'); - * - * // or default to no columns shown - * $quickForm->setColumnMode(HTML_QUICKFORM_PROPEL_NO_COLUMNS); - * $quickForm->showColumn('NAME'); // column name without table prefix. - * $quickForm->showColumn('UNAME'); - * $quickForm->showColumn('USER_INFO'); - * $quickForm->showColumn('EMAIL'); - * $quickForm->showColumn('FEMAIL'); - * $quickForm->showColumn('URL'); - * $quickForm->showColumn('PASS'); - * - * // generate the form - * $quickForm->build(); - * - * // after the form is build, it's possible to modify the generated elements - * $quickForm->getElement('NAME')->setSize(10); // manually tune this element - * - * if ($quickForm->validate()) { - * $quickForm->freeze(); - * - * // save the object we have editted - * $quickForm->save(); - * } else { - * $quickForm->toHtml(); // or any other QuickForm render option - * } - * - * TODO: map all creoleTypes to usefull formelements - * - * @author Rob Halff - * some improvements by Zoltan Nagy (sunshine@freemail.hu) - * @version $Rev: 1347 $ - * @copyright Copyright (c) 2005 Rob Halff: LGPL - See LICENCE - * @package propel.contrib - */ - -class HTML_QuickForm_Propel extends HTML_QuickForm { - - /** - * ID of the Propel Object. - * @var integer - * @access private - */ - private $id; - - /** - * Contains column visibility information. - * @var array - * @access private - */ - private $columnVisibility = array(); - - /** - * Contains titles of columns. - * @var array - * @access private - */ - private $columnTitle = array(); - - /** - * The Column visibility mode either. - * Possible values: - * - * HTML_QUICKFORM_PROPEL_ALL_COLUMNS - * HTML_QUICKFORM_PROPEL_NO_COLUMNS - * - * @var integer - * @access private - */ - private $columnMode; - - /** - * String containing the peerName. - * @var string - * @access private - */ - private $peerName; - - /** - * String containing the className of the propel Object. - * @var string - * @access private - */ - private $className; - - /** - * The Column objects. - * - * @var array - * @access private - */ - private $cols; - - /** - * The Object being operated on. - * @var object - * @access private - */ - private $obj; - - /** - * Seperator value. - * - * In case the option list will be build by multiple values - * This is the value these fields will be seperated with - * - * @var string - * @access private - */ - private $seperator = ' '; - - /** - * - * Not used yet. - * - * @var array - * @access private - */ - private $joinMap = array(); - - /** - * The default QuickForm rule type to use. - * Either server or client - * - * @var string - * @access private - */ - private $defaultRuleType = 'server'; - - - /** - * This is used in the QuickForm DateElement - * @var string - * @access private - */ - private $lang = 'en'; - - /** - * Rulemapping should cover all available propel rules - * - * @var array - * @access private - */ - private $ruleMapping = array( - 'mask'=>'regex', - 'maxLength'=>'maxlength', - 'minLength'=>'minlength', - 'maxValue'=>'maxvalue', - 'minValue'=>'minvalue', - 'required'=>'required', - 'validValues'=>'validvalues', - 'unique'=>'unique' - ); - - /** - * - * CreoleType to QuickForm element mapping - * - * @var array - * @access private - */ - private $typeMapping = array( - CreoleTypes::BOOLEAN =>'radio', - CreoleTypes::BIGINT =>'text', - CreoleTypes::SMALLINT =>'text', - CreoleTypes::TINYINT =>'text', - CreoleTypes::INTEGER =>'text', - CreoleTypes::NUMERIC =>'text', - CreoleTypes::DECIMAL =>'text', - CreoleTypes::REAL =>'text', - CreoleTypes::FLOAT =>'text', - CreoleTypes::DOUBLE =>'text', - CreoleTypes::CHAR =>'text', - CreoleTypes::VARCHAR =>'text', - CreoleTypes::LONGVARCHAR=>'textarea', - CreoleTypes::TEXT =>'textarea', - CreoleTypes::TIME =>'text', - CreoleTypes::TIMESTAMP =>'date', - CreoleTypes::DATE =>'date', - CreoleTypes::YEAR =>'text', - CreoleTypes::VARBINARY =>'text', - CreoleTypes::BLOB =>'text', - CreoleTypes::CLOB =>'text', - CreoleTypes::BINARY =>'text', - CreoleTypes::LONGVARBINARY=>'text', - CreoleTypes::ARR =>'text', - CreoleTypes::OTHER =>'text' - ); - - /** - * - * The Constructor - * - * Classname and id are specific to HTML_QuickForm_Propel - * - * The other parameters are needed to construct the parent QuickForm Class. - * - * @param string className - * @param string id - * @param string formName - * @param string method - * @param string action - * @param string target - * @param array attributes - * @param boolean trackSubmit - * - */ - public function __construct($className = null, $id = null, $formName='HTML_QuickForm_Propel', $method='post', $action='', $target='_self', $attributes=null, $trackSubmit = false) - { - $this->setClassName($className); - $this->setPeerName($className.'Peer'); // Is this always true ? - $this->setId($id); - parent::HTML_QuickForm($formName, $method, $action, $target, $attributes, $trackSubmit); - - // set the default column policy - $this->setColumnMode(HTML_QUICKFORM_PROPEL_ALL_COLUMNS); - } - - /** - * - * NOT IMPLEMENTED - * - * Allows for creating complex forms. - * Note that limit 1 will always be added to the criteria. - * Because we can only edit one record/row at a time. - * - * However we will be able to join tables in complex ways. - * - * @param Criteria - * - */ - public function setCriteria(Criteria $c) - { - $c->setLimit(1); - $this->criteria = $c; - } - - /** - * - * Set the action of this form - * - * @param string action - * - */ - public function setAction($action) - { - $attributes = array('action'=>$action); - $this->updateAttributes($attributes); - } - - /** - * - * Set method of this form, e.g. post or get - * - * @param string method - * - */ - public function setMethod($method) - { - $attributes = array('method'=>$method); - $this->updateAttributes($attributes); - } - - /** - * - * Set the target of this form - * - * @param string target - * - */ - public function setTarget($target) - { - $attributes = array('target'=>$target); - $this->updateAttributes($attributes); - } - - /** - * - * Set the id of the object we need to get - * - * @param string id - * - */ - public function setId($id) - { - $this->id = $id; - } - - /** - * - * Set the class - * - * @param string className - * - */ - public function setClassName($className) - { - $this->className = $className; - } - - /** - * - * Get the class name - * - * @return string className - * - */ - public function getClassName() - { - return $this->className; - } - - private function setPeerName($peerName) - { - $this->peerName = $peerName; - } - - /** - * - * Get the peer name - * - * @return string peerName - * - */ - public function getPeerName() - { - return $this->peerName; - } - - /** - * Build the form - * - * @return void - * - */ - public function build() - { - - if (!class_exists($this->peerName)) { - // some autoloading, dunno if it should belong here. - // or in the users autoload function - //$dbMap = call_user_func(array($this->peerName, 'getMapBuilder')); - // TODO: implement this. - } - - if (empty($this->id)) { - // create empty instance of this class - $this->obj = new $this->className(); - } else { - // find the object. - if (!$this->obj = call_user_func(array($this->peerName, 'retrieveByPK'), $this->id)) { - // for help me god.. what to do ? - throw new PropelException("HTML_QuickForm_Propel::build(): $this->peerName::retrieveByPK($this->id) failed."); - } - - } - - // note: getTableMap is protected by default. - // so do this handstand to get the tableMap - $mapBuilder = call_user_func(array($this->peerName, 'getMapBuilder')); - - // Note: $dbMap is re-used below to determine foreign table - $dbMap = $mapBuilder->getDatabaseMap(); - - // Get the column names for this table. - $this->cols = $dbMap->getTable(constant("$this->peerName::TABLE_NAME"))->getColumns(); - - // Do it the HTML_QuickForm way and use defaultValues - // instead of setValue() on every element. - // we have to first loop through the columns - foreach ($this->cols as $colName=>$col) { - - - $elementType = $this->typeMapping[$col->getCreoleType()]; - - if ($elementType == 'date') { - // null returns timestamp - $value = $this->obj->{'get'.$col->getPhpName()}(null); - } else { - - $value = $this->obj->{'get'.$col->getPhpName()}(); - - } - - $defaultValues[$colName] = $value; - } - - $this->setDefaults($defaultValues); - - foreach ($this->cols as $colName=>$col) { - - if ($this->isColumnHidden($colName)) { - continue; - } - - if ($col->isPrimaryKey()) { - // create a hidden field with primary key - if (!$this->checkColumn($colName, HTML_QUICKFORM_PROPEL_COLUMN_MADE_VISIBLE)) { - $this->addElement('hidden', $col->getColumnName(), $col->getColumnName()); - continue; - } - } - - // element's title - $colTitle = $this->getColumnTitle($colName); - - if ($col->isForeignKey()) { - - // TODO: check if user created an optional method for populating the select form - // this populating of the select box is just some way to show joined items in a form. - // it could also be checkboxes, radio buttons or whatever kind of widget. - - $relatedTable = $dbMap->getTable($col->getRelatedTableName()); - $relatedCols = $relatedTable->getColumns(); - $relatedPeer = $relatedTable->getPhpName().'Peer'; - - if (is_callable($relatedPeer, 'doSelect')) { - - - // TODO: allow set this criteria. - $c = new Criteria; - - $relatedList = call_user_func(array($relatedPeer,'doSelect'), $c); - - $colConstant = constant($this->peerName.'::'.$colName); - //$relatedColConstant = constant($relatedPeer.'::'.$relatedCol->getColumnName()); - $relatedGetter = 'getPrimaryKey'; - - - // TODO: this needs to be array based, to support multiple foreign columns - if (isset($this->joinMap[$colConstant])) { - // translate to getter - $relatedColConstant = $this->joinMap[$colConstant]; - if (!$relatedTable->containsColumn($relatedColConstant)) { - // throw exception, there is no such column - throw new PropelException('HTML_QuickForm_Propel::build(): there is no column named '.$relatedTable->normalizeColName($relatedConstant).'in '.$relatedTable->getTableName().' while trying to build the select list'); - } - $nameColumn = $relatedTable->getColumn($relatedColConstant); - $relatedGetter = 'get'.$nameColumn->getPhpName(); - } else { - //auto detection - // determine the first string column - foreach ($relatedCols as $relatedCol) { - if ($relatedCol->getType() == 'string') { - $relatedGetter = 'get'.$relatedCol->getPhpName(); - break; - } - } - } - - - $selectList = array(); - - // TODO: not hardcoded here. - $selectList[null] = _('Please selection an option'); - - foreach ($relatedList as $relObj) { - $key = $relObj->getPrimaryKey(); - - if (false OR $yesWannaUseEntireObjectsToUseItInTemplate) { - // TODO: IMPLEMENT THIS. - $selectList[$key] = $relObj; - } elseif (false OR $forceSomeKindOfColumnToBeDisplayed) { - // TODO: IMPLEMENT THIS. - } else { - $selectList[$key] = $relObj->{$relatedGetter}(); - } - } - - if (count($selectList) > 1) { // value of 1 depends on select message being set. - $select =& $this->addElement('select', $colName, $colTitle, $selectList); - } else { - // what to do if no records exists in the foreign table ? - $this->addElement('static', $colName, $colTitle, _('No Records')); - } - - } - - // do some recursion ? - - } else { - - //TODO: the mapping is not so generic anymore (to many exceptions) - $elementType = $this->typeMapping[$col->getCreoleType()]; - - if ($col->getCreoleType() == CreoleTypes::BOOLEAN) { - // TODO: describe how to override these options. - $radio = array(); - $radio[] = HTML_QuickForm::createElement('radio', null, null, 'Yes', true); - $radio[] = HTML_QuickForm::createElement('radio', null, null, 'No', false); - $el = $this->addGroup($radio, $colName, $colName); - - - } else { - - $el = $this->addElement( - $elementType, - $colName, - $colTitle); - - if ($elementType == 'text') { - $el->setMaxLength($col->getSize()); - } - - if ($col->getCreoleType() == CreoleTypes::TIMESTAMP) { - - /* Option Info: - var $_options = array( - 'language' => 'en', - 'format' => 'dMY', - 'minYear' => 2001, - 'maxYear' => 2010, - 'addEmptyOption' => false, - 'emptyOptionValue' => '', - 'emptyOptionText' => ' ', - 'optionIncrement' => array('i' => 1, 's' => 1) - ); - */ - - // hmm, don't like it but there seems to be no public method - // to set an option afterwards - $el->_options['language'] = $this->lang; - // TODO: is the format always the same in propel ? - $el->_options['format'] = 'Y-F-d H:i:s'; - - } - - } - // add an html id to the element - $this->addElementId($el, $colName); - - //$el->setValue($value); - - // required rule for NOT NULL columns - if ($col->isNotNull()) { - // TODO: What error message should we use? - $this->addRule($colName, - $this->getColumnTitle($colName) . ' is required', - 'required'); - } - - if ($col->hasValidators()) { - - foreach ($col->getValidators() as $validatorMap) { - - $this->addRule($colName, - $validatorMap->getMessage(), - $this->ruleMapping[$validatorMap->getName()], - $validatorMap->getValue(), - $this->defaultRuleType - ); - - } - } - - } - } - - // should HTML_QuickForm_Propel add this ? - $this->addElement('submit', 'submit', 'Submit'); - - // do this for the developer, can't think of any case where this is unwanted. - $this->applyFilter('__ALL__', 'trim'); - - } - - /** - * - * Use it to change the locale used for the Date element - * - * @param string locale - * @return void - * - */ - public function setLang($lang) - { - $this->lang = $lang; - } - - /** - * - * Save the form. - * - * @return void - * - */ - public function save() - { - $this->copyToObj(); - $this->obj->save(); - } - - /** - * - * Copy form values to Obj. - * - * @return void - * - */ - public function copyToObj() - { - // TODO: check what process does, if we leave out anything important. - - if (!isset($this->cols)) { - // throw some error, form cannot be saved before it is build. - throw new PropelException('HTML_QuickForm_Propel::save(): form cannot be saved before it is build.'); - } - - foreach ($this->cols as $colName=>$col) { - - // Has the form got this element? - if ($this->isColumnHidden($colName)) - { - continue; - } - - $value = $this->getElementValue($colName); - if ($value instanceof HTML_QuickForm_Error) - { - // TODO: What should we do if an error has occured? - continue; - } - $elementType = $this->typeMapping[$col->getCreoleType()]; - - // quickform doesn't seem to give back a timestamp, so calculate the date manually. - if ($elementType == 'date') { - - $date = array( - 'D' => null, - 'l' => null, - 'd' => null, - 'M' => null, - 'm' => null, - 'F' => null, - 'Y' => null, - 'y' => null, - 'h' => null, - 'H' => null, - 'i' => null, - 's' => null, - 'a' => null, - 'A' => null - ); - - foreach ($value as $key=>$val) { - $date[$key] = $val[0]; - - } - - $value = mktime($date['h'], $date['m'], $date['s'], $date['M'], $date['d'], $date['Y']); - } - - $this->obj->{'set'.$col->getPhpName()}($value); - } - } - - /** - * - * Get the object we are operating on. - * - * @return object a propel object - * - */ - public function getObj() - { - return $this->obj; - } - - /** - * What to do if a delete button is added - * and the user clicks on it, after the object has been delete in save() - */ - public function onDelete() - { - - - } - - public function createDeleteButton() - { - return $this->addElement('submit', 'delete', 'Delete'); - } - - public function isColumnHidden($column) - { - if ($this->checkColumn($column, HTML_QUICKFORM_PROPEL_COLUMN_MADE_HIDDEN) && $this->columnMode == HTML_QUICKFORM_PROPEL_ALL_COLUMNS) { - return true; - } - - if (!$this->checkColumn($column, HTML_QUICKFORM_PROPEL_COLUMN_MADE_VISIBLE) && $this->columnMode == HTML_QUICKFORM_PROPEL_NO_COLUMNS) { - return true; - } - - return false; - } - - private function checkColumn($column, $state) - { - if (isset($this->columnVisibility[$column])) { - return ($this->columnVisibility[$column] == $state); - } else { - return false; - } - } - - /** - * - * Sets the default visibility mode - * - * This must be either: - * HTML_QUICKFORM_PROPEL_NO_COLUMNS or - * HTML_QUICKFORM_PROPEL_ALL_COLUMNS - * - * @param string $column column name - * @return void - * - */ - public function setColumnMode($mode) - { - - if ($mode != HTML_QUICKFORM_PROPEL_NO_COLUMNS && $mode != HTML_QUICKFORM_PROPEL_ALL_COLUMNS) { - - throw new PropelException('HTML_QuickForm_Propel::setColumnMode(): invalid mode passed.'); - - } - - $this->columnMode = $mode; - } - - /** - * - * Tell HTML_QuickForm_Propel it should hide this column - * It is now passed like ID instead of somePeer::ID - * The latter is better, but the array_keys of the columns are in ID format and not somePeer::ID - * - * @param string $column column name - * @return void - * - */ - - public function hideColumn($column) - { - $this->columnVisibility[$column] = HTML_QUICKFORM_PROPEL_COLUMN_MADE_HIDDEN; - } - - /** - * - * Tell HTML_QuickForm_Propel it should show this column - * - * It is now passed like ID instead of somePeer::ID - * The latter is better, but the array_keys of the columns are in ID format and not somePeer::ID - * - * @param string $column column name - * @param string $title Title for the column, not required - * @return void - */ - public function showColumn($column, $title = NULL) - { - $this->columnVisibility[$column] = HTML_QUICKFORM_PROPEL_COLUMN_MADE_VISIBLE; - if ($title !== NULL) - { - $this->setColumnTitle($column, $title); - } - } - - /** - * - * assign a title to the column - * - * @param string $column - * @param string $title - * @return void - */ - public function setColumnTitle($column, $title) - { - $this->columnTitles[$column] = $title; - } - - /** - * - * returns column's title - * - * @param string $column - * @return void - */ - public function getColumnTitle($column) - { - // TODO: check if $column exists - return (array_key_exists($column, $this->columnTitles)) - ? $this->columnTitles[$column] - : $column; - } - - /** - * - * Try to automatically join all relatedTables. - * NOT IMPLEMENTED - * - * @param boolean $bool - * @return void - */ - public function autoJoin($bool) - { - $this->autoJoin = $bool; - } - - /** - * Override this if you don't like the (strtolower) default - * - * @param HTML_QuickForm_Element $el - * @param string $colName - * @return void - */ - protected function addElementId($el, $colName) - { - $el->updateAttributes(array('id'=>strtolower($colName))); - } - - /** - * - * Set the default rule typef - * @param string $type - * @return void - * - */ - public function setDefaultRuleType($type) - { - $this->defaultRuleType = $type; - } - - /** - * - * UNFINISHED - * - * Probably it would be nice to be able to add this to the schema xml - * - * TODO: further implement multiple columns for the select list - * - * @var colName constant - * @var foreignColName mixed (constant/array of columnName constants) - * @var $seperator string Only used if foreignColName is an array - */ - - public function joinColumn($colName, $foreignColName, $seperator = null) - { - if (isset($seperator)) { - $this->seperator = $seperator; - } - $this->joinMap[$colName] = $foreignColName; - } - -} diff --git a/airtime_mvc/library/propel/contrib/pear/Structures_DataGrid_Propel/Propel.php b/airtime_mvc/library/propel/contrib/pear/Structures_DataGrid_Propel/Propel.php deleted file mode 100644 index fcbf8afee..000000000 --- a/airtime_mvc/library/propel/contrib/pear/Structures_DataGrid_Propel/Propel.php +++ /dev/null @@ -1,352 +0,0 @@ -. - */ - -require_once 'Structures/DataGrid.php'; - -define('STRUCTURES_DATAGRID_PROPEL_NO_COLUMNS', 2); -define('STRUCTURES_DATAGRID_PROPEL_ALL_COLUMNS', 3); -define('STRUCTURES_DATAGRID_PROPEL_COLUMN_MADE_VISIBLE', 4); -define('STRUCTURES_DATAGRID_PROPEL_COLUMN_MADE_HIDDEN', 5); - -/** - * - * NOTE: Structures_DataGrid_Propel extends Structures_DataGrid, so all Datagrid functionality is available. - * - * A fictive example: - * // Propel and Propel project classes must be in the include_path - * - * // Propel Class name : Report - * $dg =& new Structures_DataGrid_Propel('Report'); - * - * // limit to 10 rows - * $c = new Criteria(); - * $c->setLimit(10); - * $dg->setCriteria($c); - * - * // choose what columns must be displayed - * $dg->setColumnMode(STRUCTURES_DATAGRID_PROPEL_NO_COLUMNS); - * $dg->showColumn('ACTIVE'); - * $dg->showColumn('TITLE'); - * $dg->showColumn('ID'); - * - * // generate the datagrid - * $dg->build(); - * - * // add two columns to edit the row and checkbox for further operations - * $dg->addColumn(new Structures_DataGrid_Column('', null, null, array('width' => '4%'), null, 'printEditLink()')); - * $dg->addColumn(new Structures_DataGrid_Column('', null, null, array('width' => '1%'), null, 'printCheckbox()')); - * - * // Display the datagrid - * $dg->render(); - * - * @author Marc - * @version $Rev: 1347 $ - * @copyright Copyright (c) 2005 Marc: LGPL - See LICENCE - * @package propel.contrib - */ - -class Structures_DataGrid_Propel extends Structures_DataGrid { - - /** - * Contains column visibility information. - * @var array - * @access private - */ - private $columnVisibility = array(); - - /** - * The Column visibility mode. - * Possible values: - * - * STRUCTURES_DATAGRID_PROPEL_ALL_COLUMNS - * STRUCTURES_DATAGRID_PROPEL_NO_COLUMNS - * - * @var integer - * @access private - */ - private $columnMode; - - /** - * String containing the peerName. - * @var string - * @access private - */ - private $peerName; - - /** - * String containing the className of the propel Object. - * @var string - * @access private - */ - private $className; - - /** - * Criteria of the Select query. - * @var criteria - * @access private - */ - private $criteria; - - /** - * List of primary keys - * @var array - * @access public - */ - public $primaryKeys; - - /** - * - * The Constructor - * - * Classname is specific to Structures_Datagrid_Propel - * - * The other parameters are needed to construct the parent Structures_DataGrid Class. - * - * @param string className - * @param string limit - * @param string render - * - */ - public function __construct($className = null, $limit = null, $render = DATAGRID_RENDER_HTML_TABLE) - { - - include_once $className.'.php'; - include_once $className.'Peer'.'.php'; - - $this->setClassName($className); - $this->setPeerName($className.'Peer'); // Is this always true ? - parent::Structures_DataGrid($limit,null,$render); - - // set the default column policy - $this->setColumnMode(STRUCTURES_DATAGRID_PROPEL_ALL_COLUMNS); - $this->criteria = new Criteria(); - } - - /** - * - * Set the criteria for select query - * - * @param Criteria c - * - */ - public function setCriteria(Criteria $c) - { - $this->criteria = $c; - } - - /** - * - * Set the class - * - * @param string className - * - */ - public function setClassName($className) - { - $this->className = $className; - } - - /** - * - * Get the class name - * - * @return string className - * - */ - public function getClassName() - { - return $this->className; - } - - private function setPeerName($peerName) - { - $this->peerName = $peerName; - } - - /** - * - * Get the peer name - * - * @return string peerName - * - */ - public function getPeerName() - { - return $this->peerName; - } - - /** - * - * Get the visibility of a column - * - * @return boolean true if column is set to hidden - * - */ - public function isColumnHidden($column) - { - if ($this->checkColumn($column, STRUCTURES_DATAGRID_PROPEL_COLUMN_MADE_HIDDEN) && $this->columnMode == STRUCTURES_DATAGRID_PROPEL_ALL_COLUMNS) { - return true; - } - - if (!$this->checkColumn($column, STRUCTURES_DATAGRID_PROPEL_COLUMN_MADE_VISIBLE) && $this->columnMode == STRUCTURES_DATAGRID_PROPEL_NO_COLUMNS) { - return true; - } - - return false; - } - - /** - * - * Check the state of a column - * - * @return boolean true if column is set to state - * - */ - private function checkColumn($column, $state) - { - if (isset($this->columnVisibility[$column])) { - return ($this->columnVisibility[$column] == $state); - } else { - return false; - } - } - - /** - * - * Sets the default visibility mode - * - * This must be either: - * STRUCTURES_DATAGRID_PROPEL_NO_COLUMNS or - * STRUCTURES_DATAGRID_PROPEL_ALL_COLUMNS - * - * @param string $column column name - * @return void - * - */ - public function setColumnMode($mode) - { - - if ($mode != STRUCTURES_DATAGRID_PROPEL_NO_COLUMNS && $mode != STRUCTURES_DATAGRID_PROPEL_ALL_COLUMNS) { - throw new PropelException('STRUCTURES_DATAGRID_PROPEL::setColumnMode(): invalid mode passed.'); - } - - $this->columnMode = $mode; - } - - /** - * - * Tell Structures_Datagrid_Propel it should hide this column - * It is now passed like ID instead of somePeer::ID - * The latter is better, but the array_keys of the columns are - * in ID format and not somePeer::ID - * - * @param string $column column name - * @return void - * - */ - public function hideColumn($column) - { - $this->columnVisibility[$column] = STRUCTURES_DATAGRID_PROPEL_COLUMN_MADE_HIDDEN; - } - - /** - * - * Tell Structures_Datagrid_Propel it should show this column - * - * It is now passed like ID instead of somePeer::ID - * The latter is better, but the array_keys of the columns are in ID format and not somePeer::ID - * - * @param string $column column name - * @return void - */ - public function showColumn($column) - { - $this->columnVisibility[$column] = STRUCTURES_DATAGRID_PROPEL_COLUMN_MADE_VISIBLE; - } - - /** - * - * Build the datagrid - * - * @return void - */ - public function build() - { - $mapBuilder = call_user_func(array($this->getPeerName(), 'getMapBuilder')); - $dbMap = $mapBuilder->getDatabaseMap(); - $cols = $dbMap->getTable(constant($this->getPeerName()."::TABLE_NAME"))->getColumns(); - $stmt = call_user_func(array( $this->getPeerName(), 'doSelectStmt'), $this->criteria); - - $dataset = array(); - $columns = array(); - $this->primaryKeys = array(); - $class = $this->getClassName(); - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { // use Creole ResultSet methods to iterate over resultset - $obj = new $class(); - $obj->hydrate($row); - - $row = array(); - foreach ($cols as $tmp_id => $col) - { - // save the PK in an array - if ($col->isPrimaryKey()) { - $this->primaryKeys[$col->getColumnName()] = $col->getColumnName(); - } - - $value = $obj->{'get'.$col->getPhpName()}(null); - // save the row value - - $row[$col->getColumnName()] = $value; - // save the list of propel header column name - $columns[$col->getColumnName()] = $col->getColumnName(); - - } - // add the row to dataset - $dataset[] = $row; - } - - $this->bind($dataset); - - if ($this->columnMode == STRUCTURES_DATAGRID_PROPEL_ALL_COLUMNS) { - foreach ($columns as $tmp_id => $column) { - - if (!$this->isColumnHidden($column)) { - - $this->addColumn(new Structures_DataGrid_Column($column, $column, $column, null)); - } - } - } else { - - foreach ($this->columnVisibility as $column => $visibility) { - - if (!$this->isColumnHidden($column)) { - $this->addColumn(new Structures_DataGrid_Column($column, $column, $column, null)); - } - } - } - - $this->renderer->setTableHeaderAttributes(array('class' => 'title')); - $this->renderer->setTableAttribute('class', 'list'); - $this->renderer->sortIconASC = '?'; - $this->renderer->sortIconDESC = '?'; - } - -} diff --git a/airtime_mvc/library/propel/docs/behavior/aggregate_column.txt b/airtime_mvc/library/propel/docs/behavior/aggregate_column.txt deleted file mode 100644 index e071425a7..000000000 --- a/airtime_mvc/library/propel/docs/behavior/aggregate_column.txt +++ /dev/null @@ -1,130 +0,0 @@ -= Aggregate Column Behavior = - -The `aggregate_column` behavior keeps a column updated using an aggregate function executed on a related table. - -== Basic Usage == - -In the `schema.xml`, use the `` tag to add the `aggregate_column` behavior to a table. You must provide parameters for the aggregate column `name`, the foreign table name, and the aggegate `expression`. For instance, to add an aggregate column keeping the comment count in a `post` table: - -{{{ -#!xml - - - - - - - - -
- - - - - - -
-}}} - -Rebuild your model, and insert the table creation sql again. The model now has an additional `nb_comments` column, of type `integer` by default. And each time an record from the foreign table is added, modified, or removed, the aggregate column is updated: - -{{{ -#!php -setTitle('How Is Life On Earth?'); -$post->save(); -echo $post->getNbComments(); // 0 -$comment1 = new Comment(); -$comment1->setPost($post); -$comment1->save(); -echo $post->getNbComments(); // 1 -$comment2 = new Comment(); -$comment2->setPost($post); -$comment2->save(); -echo $post->getNbComments(); // 2 -$comment2->delete(); -echo $post->getNbComments(); // 1 -}}} - -The aggregate column is also kept up to date when related records get modified through a Query object: - -{{{ -#!php -filterByPost($post) - ->delete(): -echo $post->getNbComments(); // 0 -}}} - -== Customizing The Aggregate Calculation == - -Any aggregate function can be used on any of the foreign columns. For instance, you can use the `aggregate_column` behavior to keep the latest update date of the related comments, or the total votes on the comments. You can even keep several aggregate columns in a single table: - -{{{ -#!xml - - - - - - - - - - - - - - - - - - -
- - - - - - - - -
-}}} - -The behavior adds a `computeXXX()` method to the `Post` class to compute the value of the aggregate function. This method, called each time records are modified in the related `comment` table, is the translation of the behavior settings into a SQL query: - -{{{ -#!php -prepare('SELECT COUNT(id) FROM `comment` WHERE comment.POST_ID = :p1'); - $stmt->bindValue(':p1', $this->getId()); - $stmt->execute(); - return $stmt->fetchColumn(); -} -}}} - -You can override this method in the model class to customize the aggregate column calculation. - -== Customizing The Aggregate Column == - -By default, the behavior adds one columns to the model. If this column is already described in the schema, the behavior detects it and doesn't add it a second time. This can be useful if you need to use a custom `type` or `phpName` for the aggregate column: - -{{{ -#!xml - - - - - - - - - -
-}}} diff --git a/airtime_mvc/library/propel/docs/behavior/alternative_coding_standards.txt b/airtime_mvc/library/propel/docs/behavior/alternative_coding_standards.txt deleted file mode 100644 index bc7462357..000000000 --- a/airtime_mvc/library/propel/docs/behavior/alternative_coding_standards.txt +++ /dev/null @@ -1,89 +0,0 @@ -= Alternative Coding Standards Behavior = - -The `alternative_coding_standards` behavior changes the coding standards of the model classes generated by Propel to match your own coding style. - -== Basic Usage == - -In the `schema.xml`, use the `` tag to add the `alternative_coding_standards` behavior to a table: -{{{ -#!xml - - - - -
-}}} - -Rebuild your model, and you're ready to go. The code of the model classes now uses an alternative set of coding standards: - -{{{ -#!php -title !== $v) - { - $this->title = $v; - $this->modifiedColumns[] = BookPeer::TITLE; - } - - return $this; - } - -// instead of - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return Table4 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[] = BookPeer::TITLE; - } - - return $this; - } // setTitle() -}}} - -The behavior replaces tabulations by whitespace (2 spaces by default), places opening brackets on newlines, removes closing brackets comments, and can even strip every comments in the generated classes if you wish. - -== Parameters == - -Each of the new coding style rules has corresponding parameter in the behavior description. Here is the default configuration: - -{{{ -#!xml - - - - - - - - - - -
-}}} - -You can change these settings to better match your own coding styles. diff --git a/airtime_mvc/library/propel/docs/behavior/auto_add_pk.txt b/airtime_mvc/library/propel/docs/behavior/auto_add_pk.txt deleted file mode 100644 index 214ddf020..000000000 --- a/airtime_mvc/library/propel/docs/behavior/auto_add_pk.txt +++ /dev/null @@ -1,73 +0,0 @@ -= AutoAddPk Behavior = - -The `auto_add_pk` behavior adds a primary key columns to the tables that don't have one. Using this behavior allows you to omit the declaration of primary keys in your tables. - -== Basic Usage == - -In the `schema.xml`, use the `` tag to add the `auto_add_pk` behavior to a table: -{{{ -#!xml - - - -
-}}} - -Rebuild your model, and insert the table creation sql. You will notice that the `book` table has two columns and not just one. The behavior added an `id` column, of type integer and autoincremented. This column can be used as any other column: - -{{{ -#!php -setTitle('War And Peace'); -$b->save(); -echo $b->getId(); // 1 -}}} - -This behavior is more powerful if you add it to the database instead of a table. That way, it will alter all tables not defining a primary key column - and leave the others unchanged. - -{{{ -#!xml - - - - -
-
-}}} - -You can even enable it for all your database by adding it to the default behaviors in your `build.properties` file: - -{{{ -#!ini -propel.behavior.default = auto_add_pk -}}} - -== Parameters == - -By default, the behavior adds a column named `id` to the table if the table has no primary key. You can customize all the attributes of the added column by setting corresponding parameters in the behavior definition: - -{{{ -#!xml - - - - - - - -
-
-}}} - -Once you regenerate your model, the column is now named differently: - -{{{ -#!php -setTitle('War And Peace'); -$b->setIdentifier(1); -$b->save(); -echo $b->getIdentifier(); // 1 -}}} diff --git a/airtime_mvc/library/propel/docs/behavior/nested_set.txt b/airtime_mvc/library/propel/docs/behavior/nested_set.txt deleted file mode 100644 index ad0f45077..000000000 --- a/airtime_mvc/library/propel/docs/behavior/nested_set.txt +++ /dev/null @@ -1,370 +0,0 @@ -= NestedSet Behavior = - -The `nested_set` behavior allows a model to become a tree structure, and provides numerous methods to traverse the tree in an efficient way. - -Many applications need to store hierarchical data in the model. For instance, a forum stores a tree of messages for each discussion. A CMS sees sections and subsections as a navigation tree. In a business organization chart, each person is a leaf of the organization tree. [http://en.wikipedia.org/wiki/Nested_set_model Nested sets] are the best way to store such hierachical data in a relational database and manipulate it. The name "nested sets" describes the algorithm used to store the position of a model in the tree ; it is also known as "modified preorder tree traversal". - -== Basic Usage == - -In the `schema.xml`, use the `` tag to add the `nested_set` behavior to a table: -{{{ -#!xml - - - - -
-}}} - -Rebuild your model, insert the table creation sql again, and you're ready to go. The model now has the ability to be inserted into a tree structure, as follows: - -{{{ -#!php -setTitle('Home'); -$s1->makeRoot(); // make this node the root of the tree -$s1->save(); -$s2 = new Section(); -$s2->setTitle('World'); -$s2->insertAsFirstChildOf($s1); // insert the node in the tree -$s2->save(); -$s3 = new Section(); -$s3->setTitle('Europe'); -$s3->insertAsFirstChildOf($s2); // insert the node in the tree -$s3->save() -$s4 = new Section(); -$s4->setTitle('Business'); -$s4->insertAsNextSiblingOf($s2); // insert the node in the tree -$s4->save(); -/* The sections are now stored in the database as a tree: - $s1:Home - | \ -$s2:World $s4:Business - | -$s3:Europe -*/ -}}} - -You can continue to insert new nodes as children or siblings of existing nodes, using any of the `insertAsFirstChildOf()`, `insertAsLastChildOf()`, `insertAsPrevSiblingOf()`, and `insertAsNextSiblingOf()` methods. - -Once you have built a tree, you can traverse it using any of the numerous methods the `nested_set` behavior adds to the query and model objects. For instance: - -{{{ -#!php -findRoot(); // $s1 -$worldNode = $rootNode->getFirstChild(); // $s2 -$businessNode = $worldNode->getNextSibling(); // $s4 -$firstLevelSections = $rootNode->getChildren(); // array($s2, $s4) -$allSections = $rootNode->getDescendants(); // array($s2, $s3, $s4) -// you can also chain the methods -$europeNode = $rootNode->getLastChild()->getPrevSibling()->getFirstChild(); // $s3 -$path = $europeNode->getAncestors(); // array($s1, $s2) -}}} - -The nodes returned by these methods are regular Propel model objects, with access to the properties and related models. The `nested_set` behavior also adds inspection methods to nodes: - -{{{ -#!php -isRoot(); // false -echo $s2->isLeaf(); // false -echo $s2->getLevel(); // 1 -echo $s2->hasChildren(); // true -echo $s2->countChildren(); // 1 -echo $s2->hasSiblings(); // true -}}} - -Each of the traversal and inspection methods result in a single database query, whatever the position of the node in the tree. This is because the information about the node position in the tree is stored in three columns of the model, named `tree_left`, `tree_left`, and `tree_level`. The value given to these columns is determined by the nested set algorithm, and it makes read queries much more effective than trees using a simple `parent_id` foreign key. - -== Manipulating Nodes == - -You can move a node - and its subtree - across the tree using any of the `moveToFirstChildOf()`, `moveToLastChildOf()`, `moveToPrevSiblingOf()`, and `moveToLastSiblingOf()` methods. These operations are immediate and don't require that you save the model afterwards: - -{{{ -#!php -moveToFirstChildOf($s4); -/* The tree is modified as follows: -$s1:Home - | -$s4:Business - | -$s2:World - | -$s3:Europe -*/ -// now move the "Europe" section directly under root, after "Business" -$s2->moveToFirstChildOf($s4); -/* The tree is modified as follows: - $s1:Home - | \ -$s4:Business $s3:Europe - | -$s2:World -*/ -}}} - -You can delete the descendants of a node using `deleteDescendants()`: - -{{{ -#!php -deleteDescendants($s4); -/* The tree is modified as follows: - $s1:Home - | \ -$s4:Business $s3:Europe -*/ -}}} - -If you `delete()` a node, all its descendants are deleted in cascade. To avoid accidental deletion of an entire tree, calling `delete()` on a root node throws an exception. Use the `delete()` Query method instead to delete an entire tree. - -== Filtering Results == - -The `nested_set` behavior adds numerous methods to the generated Query object. You can use these methods to build more complex queries. For instance, to get all the children of the root node ordered by title, build a Query as follows: - -{{{ -#!php -childrenOf($rootNode) - ->orderByTitle() - ->find(); -}}} - -Alternatively, if you already have an existing query method, you can pass it to the model object's methods to filter the results: - -{{{ -#!php -orderByTitle(); -$children = $rootNode->getChildren($orderQuery); -}}} - -== Multiple Trees == - -When you need to store several trees for a single model - for instance, several threads of posts in a forum - use a ''scope'' for each tree. This requires that you enable scope tree support in the behavior definition by setting the `use_scope` parameter to `true`: - -{{{ -#!xml - - - - - - - - - - -
-}}} - -Now, after rebuilding your model, you can have as many trees as required: - -{{{ -#!php -findPk(123); -$firstPost = PostQuery::create()->findRoot($thread->getId()); // first message of the discussion -$discussion = PostQuery::create()->findTree(thread->getId()); // all messages of the discussion -PostQuery::create()->inTree($thread->getId())->delete(); // delete an entire discussion -$firstPostOfEveryDiscussion = PostQuery::create()->findRoots(); -}}} - -== Using a RecursiveIterator == - -An alternative way to browse a tree structure extensively is to use a [http://php.net/RecursiveIterator RecursiveIterator]. The `nested_set` behavior provides an easy way to retrieve such an iterator from a node, and to parse the entire branch in a single iteration. - -For instance, to display an entire tree structure, you can use the following code: - -{{{ -#!php -findRoot(); -foreach ($root->getIterator() as $node) { - echo str_repeat(' ', $node->getLevel()) . $node->getTitle() . "\n"; -} -}}} - -The iterator parses the tree in a recursive way by retrieving the children of every node. This can be quite effective on very large trees, since the iterator hydrates only a few objects at a time. - -Beware, though, that the iterator executes many queries to parse a tree. On smaller trees, prefer the `getBranch()` method to execute only one query, and hydrate all records at once: - -{{{ -#!php -findRoot(); -foreach ($root->getBranch() as $node) { - echo str_repeat(' ', $node->getLevel()) . $node->getTitle() . "\n"; -} -}}} - -== Parameters == - -By default, the behavior adds three columns to the model - four if you use the scope feature. You can use custom names for the nested sets columns. The following schema illustrates a complete customization of the behavior: - -{{{ -#!xml - - - - - - - - - - - - - - - - - -
-}}} - -Whatever name you give to your columns, the `nested_sets` behavior always adds the following proxy methods, which are mapped to the correct column: - -{{{ -#!php -getLeftValue(); // returns $post->lft -$post->setLeftValue($left); -$post->getRightValue(); // returns $post->rgt -$post->setRightValue($right); -$post->getLevel(); // returns $post->lvl -$post->setLevel($level); -$post->getScopeValue(); // returns $post->thread_id -$post->setScopeValue($scope); -}}} - -If your application used the old nested sets builder from Propel 1.4, you can enable the `method_proxies` parameter so that the behavior generates method proxies for the methods that used a different name (e.g. `createRoot()` for `makeRoot()`, `retrieveFirstChild()` for `getFirstChild()`, etc. - -{{{ -#!xml - - - - - - -
-}}} - -== Complete API == - -Here is a list of the methods added by the behavior to the model objects: - -{{{ -#!php -` tag to add the `query_cache` behavior to a table: -{{{ -#!xml - - - - -
-}}} - -After you rebuild your model, all the queries on this object can now be cached. To trigger the query cache on a particular query, just give it a query key using the `setQueryKey()` method. The key is a unique identifier that you can choose, later used for cache lookups: - -{{{ -#!php -setQueryKey('search book by title') - ->filterByTitle($title) - ->findOne(); -}}} - -The first time Propel executes the termination method, it computes the SQL translation of the Query object and stores it into a cache backend (APC by default). Next time you run the same query, it executes faster, even with different parameters: - -{{{ -#!php -setQueryKey('search book by title') - ->filterByTitle($title) - ->findOne(); -}}} - -'''Tip''': The more complex the query, the greater the boost you get from the query cache behavior. - -== Parameters == - -You can change the cache backend and the cache lifetime (in seconds) by setting the `backend` and `lifetime` parameters: - -{{{ -#!xml - - - - - - - -
-}}} - -To implement a custom cache backend, just override the generated `cacheContains()`, `cacheFetch()` and `cacheStore()` methods in the Query object. For instance, to implement query cache using Zend_Cache and memcached, try the following: - -{{{ -#!php -getCacheBackend()->test($key); - } - - public function cacheFetch($key) - { - return $this->getCacheBackend()->load($key); - } - - public function cacheStore($key, $value) - { - return $this->getCacheBackend()->save($key, $value); - } - - protected function getCacheBackend() - { - if (self::$cacheBackend === null) { - $frontendOptions = array( - 'lifetime' => 7200, - 'automatic_serialization' => true - ); - $backendOptions = array( - 'servers' => array( - array( - 'host' => 'localhost', - 'port' => 11211, - 'persistent' => true - ) - ) - ); - self::$cacheBackend = Zend_Cache::factory('Core', 'Memcached', $frontendOptions, $backendOptions); - } - - return self::$cacheBackend; - } -} -}}} \ No newline at end of file diff --git a/airtime_mvc/library/propel/docs/behavior/sluggable.txt b/airtime_mvc/library/propel/docs/behavior/sluggable.txt deleted file mode 100644 index beb454a16..000000000 --- a/airtime_mvc/library/propel/docs/behavior/sluggable.txt +++ /dev/null @@ -1,135 +0,0 @@ -= Sluggable Behavior = - -The `sluggable` behavior allows a model to offer a human readable identifier that can be used for search engine friendly URLs. - -== Basic Usage == - -In the `schema.xml`, use the `` tag to add the `sluggable` behavior to a table: -{{{ -#!xml - - - - -
-}}} - -Rebuild your model, insert the table creation sql again, and you're ready to go. The model now has an additional getter for its slug, which is automatically set before the object is saved: - -{{{ -#!php -setTitle('Hello, World!'); -$p1->save(); -echo $p1->getSlug(); // 'hello-world' -}}} - -By default, the behavior uses the string representation of the object to build the slug. In the example above, the `title` column is defined as `primaryString`, so the slug uses this column as a base string. The string is then cleaned up in order to allow it to appear in a URL. In the process, blanks and special characters are replaced by a dash, and the string is lowercased. - -'''Tip''': The slug is unique by design. That means that if you create a new object and that the behavior calculates a slug that already exists, the string is modified to be unique: - -{{{ -#!php -setTitle('Hello, World!'); -$p2->save(); -echo $p2->getSlug(); // 'hello-world-1' -}}} - -The generated model query offers a `findOneBySlug()` method to easily retrieve a model object based on its slug: - -{{{ -#!php -findOneBySlug('hello-world'); -}}} - -== Parameters == - -By default, the behavior adds one columns to the model. If this column is already described in the schema, the behavior detects it and doesn't add it a second time. The behavior parameters allow you to use custom patterns for the slug composition. The following schema illustrates a complete customization of the behavior: - -{{{ -#!xml - - - - - - - - - - - - -
-}}} - -Whatever `slug_column` name you choose, the `sluggable` behavior always adds the following proxy methods, which are mapped to the correct column: - -{{{ -#!php -getSlug(); // returns $post->url -$post->setSlug($slug); // $post->url = $slug -}}} - -The `slug_pattern` parameter is the rule used to build the raw slug based on the object properties. Any substring enclosed between brackets '{}' is turned into a getter, so the `Post` class generates slugs as follows: - -{{{ -#!php -getTitle(); -} -}}} - -Incidentally, that means that you can use names that don't match a real column phpName, as long as your model provides a getter for it. - -The `replace_pattern` parameter is a regular expression that shows all the characters that will end up replaced by the `replacement` parameter. In the above example, special characters like '!' or ':' are replaced by '-', but not letters, digits, nor '/'. - -The `separator` parameter is the character that separates the slug from the incremental index added in case of non-unicity. Set as '/', it makes `Post` objects sharing the same title have the following slugs: - -{{{ -'posts/hello-world' -'posts/hello-world/1' -'posts/hello-world/2' -... -}}} - -A `permanent` slug is not automatically updated when the fields that constitute it change. This is useful when the slug serves as a permalink, that should work even when the model object properties change. Note that you can still manually change the slug in a model using the `permanent` setting by calling `setSlug()`; - -== Further Customization == - -The slug is generated by the object when it is saved, via the `createSlug()` method. This method does several operations on a simple string: - -{{{ -#!php -createRawSlug(); - // truncate the slug to accomodate the size of the slug column - $slug = $this->limitSlugSize($slug); - // add an incremental index to make sure the slug is unique - $slug = $this->makeSlugUnique($slug); - - return $slug; -} - -protected function createRawSlug() -{ - // here comes the string composition code, generated according to `slug_pattern` - $slug = 'posts/' . $this->cleanupSlugPart($this->getTitle()); - // cleanupSlugPart() cleans up the slug part - // based on the `replace_pattern` and `replacement` parameters - - return $slug; -} -}}} - -You can override any of these methods in your model class, in order to implement a custom slug logic. diff --git a/airtime_mvc/library/propel/docs/behavior/soft_delete.txt b/airtime_mvc/library/propel/docs/behavior/soft_delete.txt deleted file mode 100644 index 0105edbf1..000000000 --- a/airtime_mvc/library/propel/docs/behavior/soft_delete.txt +++ /dev/null @@ -1,116 +0,0 @@ -= SoftDelete Behavior = - -The `soft_delete` behavior overrides the deletion methods of a model object to make them 'hide' the deleted rows but keep them in the database. Deleted objects still don't show up on select queries, but they can be retrieved or undeleted when necessary. - -== Basic Usage == - -In the `schema.xml`, use the `` tag to add the `soft_delete` behavior to a table: -{{{ -#!xml - - - - -
-}}} - -Rebuild your model, insert the table creation sql again, and you're ready to go. The model now has one new column, `deleted_at`, that stores the deletion date. Select queries don't return the deleted objects: - -{{{ -#!php -setTitle('War And Peace'); -$b->save(); -$b->delete(); -echo $b->isDeleted(); // false -echo $b->getDeletedAt(); // 2009-10-02 18:14:23 -$books = BookQuery::create()->find(); // empty collection -}}} - -Behind the curtain, the behavior adds a condition to every SELECT query to return only records where the `deleted_at` column is null. That's why the deleted objects don't appear anymore upon selection. - -You can turn off the query alteration globally by calling the static method `disableSoftDelete()` on the related Query object: - -{{{ -#!php -find(); -$book = $books[0]; -echo $book->getTitle(); // 'War And Peace' -}}} - -Note that `find()` and other selection methods automatically re-enable the `soft_delete` filter. You can also enable it manually by calling the `enableSoftDelete()` method on Peer objects. - -If you want to recover a deleted object, use the `unDelete()` method: - -{{{ -#!php -unDelete(); -$books = BookQuery::create()->find(); -$book = $books[0]; -echo $book->getTitle(); // 'War And Peace' -}}} - -If you want to force the real deletion of an object, call the `forceDelete()` method: - -{{{ -#!php -forceDelete(); -echo $book->isDeleted(); // true -$books = BookQuery::create()->find(); // empty collection -}}} - -The query methods `delete()` and `deleteAll()` also perform a soft deletion, unless you disable the behavior on the peer class: - -{{{ -#!php -setTitle('War And Peace'); -$b->save(); - -BookQuery::create()->delete($b); -$books = BookQuery::create()->find(); // empty collection -// the rows look deleted, but they are still there -BookQuery::disableSoftDelete(); -$books = BookQuery::create()->find(); -$book = $books[0]; -echo $book->getTitle(); // 'War And Peace' - -// To perform a true deletion, disable the softDelete feature -BookQuery::disableSoftDelete(); -BookQuery::create()->delete(); -// Alternatively, use forceDelete() -BookQuery::create()->forceDelete(); -}}} - -== Parameters == - -You can change the name of the column added by the behavior by setting the `deleted_column` parameter: - -{{{ -#!xml - - - - - - - -
-}}} - -{{{ -#!php -setTitle('War And Peace'); -$b->save(); -$b->delete(); -echo $b->getMyDeletionDate(); // 2009-10-02 18:14:23 -$books = BookQuery::create()->find(); // empty collection -}}} diff --git a/airtime_mvc/library/propel/docs/behavior/sortable.txt b/airtime_mvc/library/propel/docs/behavior/sortable.txt deleted file mode 100644 index b45c12843..000000000 --- a/airtime_mvc/library/propel/docs/behavior/sortable.txt +++ /dev/null @@ -1,285 +0,0 @@ -= Sortable Behavior = - -The `sortable` behavior allows a model to become an ordered list, and provides numerous methods to traverse this list in an efficient way. - -== Basic Usage == - -In the `schema.xml`, use the `` tag to add the `sortable` behavior to a table: -{{{ -#!xml - - - - -
-}}} - -Rebuild your model, insert the table creation sql again, and you're ready to go. The model now has the ability to be inserted into an ordered list, as follows: - -{{{ -#!php -setTitle('Wash the dishes'); -$t1->save(); -echo $t1->getRank(); // 1, the first rank to be given (not 0) -$t2 = new Task(); -$t2->setTitle('Do the laundry'); -$t2->save(); -echo $t2->getRank(); // 2 -$t3 = new Task(); -$t3->setTitle('Rest a little'); -$t3->save() -echo $t3->getRank(); // 3 -}}} - -As long as you save new objects, Propel gives them the first available rank in the list. - -Once you have built an ordered list, you can traverse it using any of the methods added by the `sortable` behavior. For instance: - -{{{ -#!php -findOneByRank(1); // $t1 -$secondTask = $firstTask->getNext(); // $t2 -$lastTask = $secondTask->getNext(); // $t3 -$secondTask = $lastTask->getPrevious(); // $t2 - -$allTasks = TaskQuery::create()->findList(); -// => collection($t1, $t2, $t3) -$allTasksInReverseOrder = TaskQuery::create()->orderByRank('desc')->find(); -// => collection($t3, $t2, $t2) -}}} - -The results returned by these methods are regular Propel model objects, with access to the properties and related models. The `sortable` behavior also adds inspection methods to objects: - -{{{ -#!php -isFirst(); // false -echo $t2->isLast(); // false -echo $t2->getRank(); // 2 -}}} - -== Manipulating Objects In A List == - -You can move an object in the list using any of the `moveUp()`, `moveDown()`, `moveToTop()`, `moveToBottom()`, `moveToRank()`, and `swapWith()` methods. These operations are immediate and don't require that you save the model afterwards: - -{{{ -#!php -moveToTop(); -// The list is now 1 - Do the laundry, 2 - Wash the dishes, 3 - Rest a little -$t2->moveToBottom(); -// The list is now 1 - Wash the dishes, 2 - Rest a little, 3 - Do the laundry -$t2->moveUp(); -// The list is 1 - Wash the dishes, 2 - Do the laundry, 3 - Rest a little -$t2->swapWith($t1); -// The list is now 1 - Do the laundry, 2 - Wash the dishes, 3 - Rest a little -$t2->moveToRank(3); -// The list is now 1 - Wash the dishes, 2 - Rest a little, 3 - Do the laundry -$t2->moveToRank(2); -}}} - -By default, new objects are added at the bottom of the list. But you can also insert them at a specific position, using any of the `insertAtTop(), `insertAtBottom()`, and `insertAtRank()` methods. Note that the `insertAtXXX` methods don't save the object: - -{{{ -#!php -setTitle('Clean windows'); -$t4->insertAtRank(2); -$t4->save(); -// The list is now 1 - Wash the dishes, 2 - Clean Windows, 3 - Do the laundry, 4 - Rest a little -}}} - -Whenever you `delete()` an object, the ranks are rearranged to fill the gap: - -{{{ -#!php -delete(); -// The list is now 1 - Wash the dishes, 2 - Do the laundry, 3 - Rest a little -}}} - -'''Tip''': You can remove an object from the list without necessarily deleting it by calling `removeFromList()`. Don't forget to `save()` it afterwards so that the other objects in the lists are rearranged to fill the gap. - -== Multiple Lists == - -When you need to store several lists for a single model - for instance, one task list for each user - use a ''scope'' for each list. This requires that you enable scope support in the behavior definition by setting the `use_scope` parameter to `true`: - -{{{ -#!xml - - - - - - - - - - - -
-}}} - -Now, after rebuilding your model, you can have as many lists as required: - -{{{ -#!php -setTitle('Wash the dishes'); -$t1->setUser($paul); -$t1->save(); -echo $t1->getRank(); // 1 -$t2 = new Task(); -$t2->setTitle('Do the laundry'); -$t2->setUser($paul); -$t2->save(); -echo $t2->getRank(); // 2 -$t3 = new Task(); -$t3->setTitle('Rest a little'); -$t3->setUser($john); -$t3->save() -echo $t3->getRank(); // 1, because John has his own task list -}}} - -The generated methods now accept a `$scope` parameter to restrict the query to a given scope: - -{{{ -#!php -findOneByRank($rank = 1, $scope = $paul->getId()); // $t1 -$lastPaulTask = $firstTask->getNext(); // $t2 -$firstJohnTask = TaskPeer::create()->findOneByRank($rank = 1, $scope = $john->getId()); // $t1 -}}} - -Models using the sortable behavior with scope benefit from one additional Query methods named `inList()`: - -{{{ -#!php -inList($scope = $paul->getId())->find(); -}}} - -== Parameters == - -By default, the behavior adds one columns to the model - two if you use the scope feature. If these columns are already described in the schema, the behavior detects it and doesn't add them a second time. The behavior parameters allow you to use custom names for the sortable columns. The following schema illustrates a complete customization of the behavior: - -{{{ -#!xml - - - - - - - - - - - - - -
-}}} - -Whatever name you give to your columns, the `sortable` behavior always adds the following proxy methods, which are mapped to the correct column: - -{{{ -#!php -getRank(); // returns $task->my_rank_column -$task->setRank($rank); -$task->getScopeValue(); // returns $task->user_id -$task->setScopeValue($scope); -}}} - -The same happens for the generated Query object: - -{{{ -#!php -filterByRank(); // proxies to filterByMyRankColumn() -$query = TaskQuery::create()->orderByRank(); // proxies to orderByMyRankColumn() -$tasks = TaskQuery::create()->findOneByRank(); // proxies to findOneByMyRankColumn() -}}} - -'''Tip''': The behavior adds columns but no index. Depending on your table structure, you might want to add a column index by hand to speed up queries on sorted lists. - -== Complete API == - -Here is a list of the methods added by the behavior to the model objects: - -{{{ -#!php - $rank associative array -// only for behavior with use_scope -array inList($scope) -}}} - -The behavior also adds a few methods to the Peer classes: - -{{{ -#!php - $rank associative array -// only for behavior with use_scope -array retrieveList($scope) -int countList($scope) -int deleteList($scope) -}}} \ No newline at end of file diff --git a/airtime_mvc/library/propel/docs/behavior/timestampable.txt b/airtime_mvc/library/propel/docs/behavior/timestampable.txt deleted file mode 100644 index 146b694e9..000000000 --- a/airtime_mvc/library/propel/docs/behavior/timestampable.txt +++ /dev/null @@ -1,92 +0,0 @@ -= Timestampable Behavior = - -The `timestampable` behavior allows you to keep track of the date of creation and last update of your model objects. - -== Basic Usage == - -In the `schema.xml`, use the `` tag to add the `timestampable` behavior to a table: -{{{ -#!xml - - - - -
-}}} - -Rebuild your model, insert the table creation sql again, and you're ready to go. The model now has two new columns, `created_at` and `updated_at`, that store a timestamp automatically updated on save: - -{{{ -#!php -setTitle('War And Peace'); -$b->save(); -echo $b->getCreatedAt(); // 2009-10-02 18:14:23 -echo $b->getUpdatedAt(); // 2009-10-02 18:14:23 -$b->setTitle('Anna Karenina'); -$b->save(); -echo $b->getCreatedAt(); // 2009-10-02 18:14:23 -echo $b->getUpdatedAt(); // 2009-10-02 18:14:25 -}}} - -The object query also has specific methods to retrieve recent objects and order them according to their update date: - -{{{ -#!php -recentlyUpdated() // adds a minimum value for the update date - ->lastUpdatedFirst() // orders the results by descending update date - ->find(); -}}} - -You can use any of the following methods in the object query: - -{{{ -#!php - - - - - - - - - - -}}} - -{{{ -#!php -setTitle('War And Peace'); -$b->save(); -echo $b->getMyCreateDate(); // 2009-10-02 18:14:23 -echo $b->getMyUpdateDate(); // 2009-10-02 18:14:23 -$b->setTitle('Anna Karenina'); -$b->save(); -echo $b->getMyCreateDate(); // 2009-10-02 18:14:23 -echo $b->getMyUpdateDate(); // 2009-10-02 18:14:25 -}}} diff --git a/airtime_mvc/library/propel/docs/build.xml b/airtime_mvc/library/propel/docs/build.xml deleted file mode 100644 index cc876c4b4..000000000 --- a/airtime_mvc/library/propel/docs/build.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/airtime_mvc/library/propel/docs/cookbook/Add-Custom-SQL.txt b/airtime_mvc/library/propel/docs/cookbook/Add-Custom-SQL.txt deleted file mode 100644 index fd672f7ea..000000000 --- a/airtime_mvc/library/propel/docs/cookbook/Add-Custom-SQL.txt +++ /dev/null @@ -1,34 +0,0 @@ -= Adding Additional SQL Files = - -In many cases you may wish to have the ''insert-sql'' task perform additional SQL operations (e.g. add views, stored procedures, triggers, sample data, etc.). Rather than have to run additional SQL statements yourself every time you re-build your object model, you can have the Propel generator do this for you. - -== 1. Create the SQL DDL files == - -Create any additional SQL files that you want executed against the database (after the base ''schema.sql'' file is applied). - -For example, if we wanted to add a default value to a column that was unsupported in the schema (e.g. where value is a SQL function): - -{{{ -#!sql --- (for postgres) -ALTER TABLE my_table ALTER COLUMN my_column SET DEFAULT CURRENT_TIMESTAMP; -}}} - -Now we save that as '''my_column-default.sql''' in the same directory as the generated '''schema.sql''' file (usually in projectdir/build/sql/). - -== 2. Tell Propel Generator about the new file == - -In that same directory (where your '''schema.sql''' is located), there is a '''sqldb.map''' file which contains a mapping of SQL DDL files to the database that they should be executed against. After running the propel generator, you will probably have a single entry in that file that looks like: - -{{{ -schema.sql=your-db-name -}}} - -We want to simply add the new file we created to this file (future builds will preserve anything you add to this file). When we're done, the file will look like this: - -{{{ -schema.sql=your-db-name -my_column-default.sql=your-db-name -}}} - -Now when you execute the ''insert-sql'' Propel generator target, the '''my_column-default.sql''' file will be executed against the ''your-db-name'' database. \ No newline at end of file diff --git a/airtime_mvc/library/propel/docs/cookbook/Copying-Objects.txt b/airtime_mvc/library/propel/docs/cookbook/Copying-Objects.txt deleted file mode 100644 index 5a67eaa4f..000000000 --- a/airtime_mvc/library/propel/docs/cookbook/Copying-Objects.txt +++ /dev/null @@ -1,47 +0,0 @@ -= Copying Persisted Objects = - -Propel provides the {{{copy()}}} method to perform copies of mapped row in the database. Note that Propel does '''not''' override the {{{__clone()}}} method; this allows you to create local duplicates of objects that map to the same persisted database row (should you need to do this). - -The {{{copy()}}} method by default performs shallow copies, meaning that any foreign key references will remain the same. - -{{{ -#!php -setFirstName("Aldous"); -$a->setLastName("Huxley"); - -$p = new Publisher(); -$p->setName("Harper"); - -$b = new Book(); -$b->setTitle("Brave New World"); -$b->setPublisher($p); -$b->setAuthor($a); - -$b->save(); // so that auto-increment IDs are created - -$bcopy = $b->copy(); -var_export($bcopy->getId() == $b->getId()); // FALSE -var_export($bcopy->getAuthorId() == $b->getAuthorId()); // TRUE -var_export($bcopy->getAuthor() === $b->getAuthor()); // TRUE -?> -}}} - -== Deep Copies == - -By calling {{{copy()}}} with a {{{TRUE}}} parameter, Propel will create a deep copy of the object; this means that any related objects will also be copied. - -To continue with example from above: - -{{{ -#!php -copy(true); -var_export($bcopy->getId() == $b->getId()); // FALSE -var_export($bcopy->getAuthorId() == $b->getAuthorId()); // FALSE -var_export($bcopy->getAuthor() === $b->getAuthor()); // FALSE -?> -}}} \ No newline at end of file diff --git a/airtime_mvc/library/propel/docs/cookbook/Customizing-Build.txt b/airtime_mvc/library/propel/docs/cookbook/Customizing-Build.txt deleted file mode 100644 index acfe99406..000000000 --- a/airtime_mvc/library/propel/docs/cookbook/Customizing-Build.txt +++ /dev/null @@ -1,153 +0,0 @@ -= Customizing Build = -It is possible to customize the Propel build process by overriding values in your propel __build.properties__ file. For maximum flexibility, you can even create your own Phing __build.xml__ file. - -== Customizing the build.properties == -The easiest way to customize your Propel build is to simply specify build properties in your project's __build.properties__ file. - -=== Understanding Phing build properties === -''Properties'' are essentially variables. These variables can be specified on the commandline or in ''properties files''. - -For example, here's how a property might be specified on the commandline: -{{{ -$> phing -Dpropertyname=value -}}} - -More typically, properties are stored in files and loaded by Phing. For those not familiar with Java properties files, these files look like PHP INI files; the main difference is that values in properties files can be references to other properties (a feature that will probably exist in in INI files in PHP 5.1). - -'''Importantly:''' properties, once loaded, are not overridden by properties with the same name unless explicitly told to do so. In the Propel build process, the order of precedence for property values is as follows: - 1. Commandline properties - 1. Project __build.properties__ - 1. Top-level __build.properties__ - 1. Top-level __default.properties__ - -This means, for example, that values specified in the project's __build.properties__ files will override those in the top-level __build.properties__ and __default.properties__ files. - -=== Changing values === -To get an idea of what you can modify in Propel, simply look through the __build.properties__ and __default.properties__ files. - -''Note, however, that some of the current values exist for legacy reasons and will be cleaned up in Propel 1.1.'' - -==== New build output directories ==== -This can easily be customized on a project-by-project basis. For example, here is a __build.properties__ file for the ''bookstore ''project that puts the generated classes in __/var/www/bookstore/classes__ and puts the generated SQL in __/var/www/bookstore/db/sql__: -{{{ -propel.project = bookstore -propel.database = sqlite -propel.database.url = sqlite://localhost/./test/bookstore.db -propel.targetPackage = bookstore - -# directories -prope.output.dir = /var/www/bookstore -propel.php.dir = ${propel.output.dir}/classes -propel.phpconf.dir = ${propel.output.dir}/conf -propel.sql.dir = ${propel.output.dir}/db/sql -}}} - -The ''targetPackage'' property is also used in determining the path of the generated classes. In the example above, the __Book.php__ class will be located at __/var/www/bookstore/classes/bookstore/Book.php__. You can change this __bookstore__ subdir by altering the ''targetPackage'' property: -{{{ -propel.targetPackage = propelom -}}} - -Now the class will be located at __/var/www/bookstore/classes/propelom/Book.php__ - -''Note that you can override the targetPackage property by specifying a package="" attribute in the tag or even the tag of the schema.xml.'' - -== Creating a custom build.xml file == - -If you want to make more major changes to the way the build script works, you can setup your own Phing build script. This actually is not a very scary task, and once you've managed to create a Phing build script, you'll probably want to create build targets for other aspects of your project (e.g. running batch unit tests is now supported in Phing 2.1-CVS). - -To start with, I suggest taking a look at the __build-propel.xml__ script (the build.xml script is just a wrapper script). Note, however, that the __build-propel.xml__ script does a lot & has a lot of complexity that is designed to make it easy to configure using properties (so, don't be scared). - -Without going into too much detail about how Phing works, the important thing is that Phing build scripts XML and they are grouped into ''targets'' which are kinda like functions. The actual work of the scripts is performed by ''tasks'', which are PHP5 classes that extend the base Phing ''Task'' class and implement its abstract methods. Propel provides some Phing tasks that work with templates to create the object model. - -=== Step 1: register the needed tasks === - -The Propel tasks must be registered so that Phing can find them. This is done using the '''' tag. You can see this near the top of the __build-propel.xml__ file. - -For example, here is how we register the ''propel-om'' task, which is the task that creates the PHP classes for your object model: -{{{ - -}}} - -Simple enough. Phing will now associate the '''' tag with the ''PropelOMTask'' class, which it expects to find at __propel/phing/PropelOMTask.php__ (on your ''include_path''). If Propel generator classes are not on your ''include_path'', you can specify that path in your '''' tag: -{{{ - -}}} - -Or, for maximum re-usability, you can create a '''' object, and then reference it (this is the way __build-propel.xml__ does it): -{{{ - - - - - -}}} - -=== Step 2: invoking the new task === - -Now that the '''' task has been registered with Phing, it can be invoked in your build file. -{{{ - - - -}}} - -In the example above, it's worth pointing out that the '''' task can actually transform multiple __schema.xml__ files, which is why there is a '''' sub-element. Phing ''filesets'' are beyond the scope of this HOWTO, but hopefully the above example is obvious enough. - -=== Step 3: putting it together into a build.xml file === - -Now that we've seen the essential elements of our custom build file, it's time to look at how to assemble them into a working whole: -{{{ - - - - - - - - - - - - - - - - - - - - - - - -}}} - -If that build script was named __build.xml__ then it could be executed by simply running ''phing'' in the directory where it is located: -{{{ -$> phing om -}}} - -Actually, specifying the ''om'' target is not necessary since it is the default. - -Refer to the __build-propel.xml__ file for examples of how to use the other Propel Phing tasks -- e.g. '''' for generating the DDL SQL, '''' for inserting the SQL, etc. \ No newline at end of file diff --git a/airtime_mvc/library/propel/docs/cookbook/Existing-Database.txt b/airtime_mvc/library/propel/docs/cookbook/Existing-Database.txt deleted file mode 100644 index 3505c0f42..000000000 --- a/airtime_mvc/library/propel/docs/cookbook/Existing-Database.txt +++ /dev/null @@ -1,95 +0,0 @@ -= Working With Existing Databases = - -The following topics are targeted for developers who already have a working database solution in place, but would like to use Propel to work with the data. For this case, Propel provides a number of command-line utilities helping with migrations of data and data structures. - -== Working with Database Structures == - -Propel uses an abstract XML schema file to represent databases (the [wiki:Documentation/1.5/Schema schema]). Propel builds the SQL specific to a database based on this schema. Propel also provides a way to reverse-engineer the generic schema file based on database metadata. - -=== Creating an XML Schema from a DB Structure === - -To generate a schema file, create a new directory for your project & specify the connection information in your `build.properties` file for that project. For example, to create a new project, `legacyapp`, follow these steps: - - 1. Create the `legacyapp` project directory anywhere on your filesystem: -{{{ -> mkdir legacyapp -> cd legacyapp -}}} - 1. Create a `build.properties` file in `legacyapp/` directory with the DB connection parameters for your existing database, e.g.: -{{{ -propel.project = legacyapp - -# The Propel driver to use for generating SQL, etc. -propel.database = mysql - -# This must be a PDO DSN -propel.database.url = mysql:dbname=legacyapp -propel.database.user = root -# propel.database.password = -}}} - 1. Run the `reverse` task to generate the `schema.xml`: -{{{ -> propel-gen reverse -}}} - 1. Pay attention to any errors/warnings issued by Phing during the task execution and then examine the generated `schema.xml` file to make any corrections needed. - 1. '''You're done! ''' Now you have a `schema.xml` file in the `legacyapp/` project directory. You can now run the default Propel build to generate all the classes. - -The generated `schema.xml` file should be used as a guide, not a final answer. There are some datatypes that Propel may not be familiar with; also some datatypes are simply not supported by Propel (e.g. arrays in PostgreSQL). Unfamiliar datatypes will be reported as warnings and substituted with a default VARCHAR datatype. - -Tip: The reverse engineering classes may not be able to provide the same level of detail for all databases. In particular, metadata information for SQLite is often very basic since SQLite is a typeless database. - -=== Migrating Structure to a New RDBMS === - -Because Propel has both the ability to create XML schema files based on existing database structures and to create RDBMS-specific DDL SQL from the XML schema file, you can use Propel to convert one database into another. - -To do this you would simply: - 1. Follow the steps above to create the `schema.xml` file from existing db. - 1. Then you would change the target database type and specify connection URL for new database in the project's `build.properties` file: -{{{ -propel.database = pgsql -propel.database.url = pgsql://unix+localhost/newlegacyapp -}}} - 1. And then run the `sql` task to generate the new DDL: -{{{ -> propel-gen sql -}}} - 1. And (optionally) the `insert-sql` task to create the new database: -{{{ -> propel-gen insert-sql -}}} - -== Working with Database Data == - -Propel also provides several tasks to facilitate data import/export. The most important of these are `datadump` and `datasql`. The first dumps data to XML and the second converts the XML data dump to a ready-to-insert SQL file. - -Tip: Both of these tasks require that you already have generated the `schema.xml` for your database. - -=== Dumping Data to XML === - -Once you have created (or reverse-engineered) your `schema.xml` file, you can run the `datadump` task to dump data from the database into a `data.xml` file. - -{{{ -> propel-gen datadump -}}} - -The task transfers database records to XML using a simple format, where each row is an element, and each column is an attribute. So for instance, the XML representation of a row in a `publisher` table: - -||'''publisher_id'''||'''name'''|| -||1||William Morrow|| - -... is rendered in the `data.xml` as follows: -{{{ - - ... - - ... - -}}} - -=== Creating SQL from XML === - -To create the SQL files from the XML, run the `datasql` task: -{{{ -> propel-gen datasql -}}} -The generated SQL is placed in the `build/sql/` directory and will be inserted when you run the `insert-sql` task. \ No newline at end of file diff --git a/airtime_mvc/library/propel/docs/cookbook/LOB-Columns.txt b/airtime_mvc/library/propel/docs/cookbook/LOB-Columns.txt deleted file mode 100644 index d4b776d0b..000000000 --- a/airtime_mvc/library/propel/docs/cookbook/LOB-Columns.txt +++ /dev/null @@ -1,73 +0,0 @@ -= Working with LOB Columns = - -Propel uses PHP streams internally for storing ''Binary'' Locator Objects (BLOBs). This choice was made because PDO itself uses streams as a convention when returning LOB columns in a resultset and when binding values to prepared statements. Unfortunately, not all PDO drivers support this (see, for example, http://bugs.php.net/bug.php?id=40913); in those cases, Propel creates a {{{php://temp}}} stream to hold the LOB contents and thus provide a consistent API. - -Note that CLOB (''Character'' Locator Objects) are treated as strings in Propel, as there is no convention for them to be treated as streams by PDO. - -== Getting BLOB Values == - -BLOB values will be returned as PHP stream resources from the accessor methods. Alternatively, if the value is NULL in the database, then the accessors will return the PHP value NULL. - -{{{ -#!php -getCoverImage(); -if ($fp !== null) { - echo stream_get_contents($fp); -} -}}} - -== Setting BLOB Values == - -When setting a BLOB column, you can either pass in a stream or the blob contents. - -=== Setting using a stream === -{{{ -#!php -setCoverImage($fp); -}}} - -=== Setting using file contents === -{{{ -#!php -setCoverImage(file_get_contents("/path/to/file.ext")); -}}} - -Regardless of which setting method you choose, the BLOB will always be represented internally as a stream resource -- ''and subsequent calls to the accessor methods will return a stream.'' - -For example: -{{{ -#!php -setCoverImage(file_get_contents("/path/to/file.ext")); - -$fp = $media->getCoverImage(); -print gettype($fp); // "resource" -}}} - -=== Setting BLOB columns and isModified() === - -Note that because a stream contents may be externally modified, ''mutator methods for BLOB columns will always set the '''isModified()''' to report true'' -- even if the stream has the same identity as the stream that was returned. - -For example: -{{{ -#!php -getCoverImage(); -$media->setCoverImage($fp); - -var_export($media->isModified()); // TRUE -}}} \ No newline at end of file diff --git a/airtime_mvc/library/propel/docs/cookbook/Master-Slave.txt b/airtime_mvc/library/propel/docs/cookbook/Master-Slave.txt deleted file mode 100644 index 2e28f4903..000000000 --- a/airtime_mvc/library/propel/docs/cookbook/Master-Slave.txt +++ /dev/null @@ -1,94 +0,0 @@ -= Replication = - -Propel can be used in a master-slave replication environment. These environments are set up to improve the performance of web applications by dispatching the database-load to multiple database-servers. While a single master database is responsible for all write-queries, multiple slave-databases handle the read-queries. The slaves are synchronised with the master by a fast binary log (depending on the database). - -== Configuring Propel for Replication == - - * Set up a replication environment (see the Databases section below) - * Use the latest Propel-Version from SVN - * add a slaves-section to your {{{runtime-conf.xml}}} file - * verify the correct setup by checking the masters log file (should not contain "select ..." statements) - -You can configure Propel to support replication by adding a element with nested element(s) to your {{{runtime-conf.xml}}}. - -The section is at the same level as the master and contains multiple nested elements with the same information as the top-level (master) . It is recommended that they are numbered. The follwing example shows a slaves section with a several slave connections configured where "localhost" is the master and "slave-server1" and "slave-server2" are the slave-database connections. - -{{{ -#!xml - - - - propel-bookstore - console - 7 - - - - - sqlite - - mysql:host=localhost;dbname=bookstore - testuser - password - - - - mysql:host=slave-server1; dbname=bookstore - testuser - password - - - mysql:host=slave-server2; dbname=bookstore - testuser - password - - - - - - -}}} - -== Implementation == - -The replication functionality is implemented in the Propel connection configuration and initialization code and in the generated Peer and Object classes. - -=== Propel::getConnection() === - -When requesting a connection from Propel ('''Propel::getConnection()'''), you can either specify that you want a READ connection (slave) or WRITE connection (master). Methods that are designed to perform READ operations, like the '''doSelect*()''' methods of your generated Peer classes, will always request a READ connection like so: -{{{ -#!php -query('SELECT * FROM my'); -/* ... */ -}}} - -=== Propel::setForceMasterConnection() === - -You can force Propel to always return a WRITE (master) connection from '''Propel::getConnection()''' by calling '''Propel::setForceMasterConnection(true);'''. This can be useful if you must be sure that you are getting the most up-to-date data (i.e. if there is some latency possible between master and slaves). - -== Databases == - -=== MySql === - -http://dev.mysql.com/doc/refman/5.0/en/replication-howto.html - -== References == - - * Henderson Carl (2006): Building Scalable Web Sites. The Flickr Way. O'Reilly. ISBN-596-10235-6. - diff --git a/airtime_mvc/library/propel/docs/cookbook/Multi-Component.txt b/airtime_mvc/library/propel/docs/cookbook/Multi-Component.txt deleted file mode 100644 index f033ce70c..000000000 --- a/airtime_mvc/library/propel/docs/cookbook/Multi-Component.txt +++ /dev/null @@ -1,297 +0,0 @@ -= Multi-Component Data Model = - -Propel comes along with packaging capabilities that allow you to more easily integrate Propel into a packaged or modularized application. - -== Muliple Schemas == - -You can use as many `schema.xml` files as you want. Schema files have to be named `(*.)schema.xml`, so names like `schema.xml`, `package1.schema.xml`, `core.package1.schema.xml` are all acceptable. These files ''have'' to be located in your project directory. - -Each schema file has to contain a `` element with a `name` attribute. This name references the connection settings to be used for this database (and configured in the `runtime-conf.xml`), so separated schemas can share a common database name. - -Whenever you call a propel build taks, Propel will consider all these schema files and build the classes (or the SQL) for all the tables. - -== Understanding Packages == - -In Propel, a ''package'' represents a group of models. This is a convenient way to organize your code in a modularized way, since classes and SQL files of a given package are be grouped together and separated from the other packages. By carefully choosing the package of each model, applications end up in smaller, independent modules that are easier to manage. - -=== Package Cascade === - -The package is defined in a configuration cascade. You can set it up for the whole project, for all the tables of a schema, or for a single table. - -For the whole project, the main package is set in the `build.properties`: - -{{{ -#!ini -propel.targetPackage = my_project -}}} - -By default, all the tables of all the schemas in the project use this package. However, you can override the package for a given `` by setting its `package` attribute: - -{{{ -#!xml - - -
- -
-
- - - - - -
- - -
-
-}}} - -In this example, thanks to the `package` attribute, the tables are grouped into the following packages: - - * `my_project.author` package: `author` table - * `my_project.book` package: `book` and `review` tables - -'''Warning''': If you separate tables related by a foreign key into separate packages (like `book` and `author` in this example), you must enable the `packageObjectModel` build property to let Propel consider other packages for relations. - -You can also override the `package` attribute at the `` element level. - -{{{ -#!xml - - -
- -
-
- - - - - -
- - -
-
-}}} - -This ends up in the following package: - - * `my_project.author` package: `author` table - * `my_project.book` package: `book` table - * `my_project.review` package: `review` table - -Notice that tables can end up in separated packages even though they belong to the same schema file. - -'''Tip''': You can use dots in a package name to add more package levels. - -=== Packages and Generated Model Files === - -The `package` attribute of a table translates to the directory in which Propel generates the Model classes for this table. - -For instance, if no `package` attribute is defined at the database of table level, Propel places all classes according to the `propel.targetPackage` from the `build.properties`: - -{{{ -build/ - classes/ - my_project/ - om/ - map/ - Author.php - AuthorPeer.php - AuthorQuery.php - Book.php - BookPeer.php - BookQuery.php - Review.php - ReviewPeer.php - ReviewQuery.php -}}} - -You can further tweak the location where Propel puts the created files by changing the `propel.output.dir` build property. By default this property is set to: - -{{{ -#!ini -propel.output.dir = ${propel.project.dir}/build -}}} - -You can change it to use any other directory as your build directory. - -If you set up packages for `` elements, Propel splits up the generated model classes into subdirectories named after the package attribute: - -{{{ -build/ - classes/ - my_project/ - author/ - om/ - map/ - Author.php - AuthorPeer.php - AuthorQuery.php - book/ - om/ - map/ - Book.php - BookPeer.php - BookQuery.php - Review.php - ReviewPeer.php - ReviewQuery.php -}}} - -And of course, if you specialize the `package` attribute per table, you can have one table use its own package: - -{{{ -build/ - classes/ - my_project/ - author/ - om/ - map/ - Author.php - AuthorPeer.php - AuthorQuery.php - book/ - om/ - map/ - Book.php - BookPeer.php - BookQuery.php - review/ - om/ - map/ - Review.php - ReviewPeer.php - ReviewQuery.php -}}} - -=== Packages And SQL Files === - -Propel also considers packages for SQL generation. In practice, Propel generates one SQL file per package. Each file contains the CREATE TABLE SQL statements necessary to create all the tables of a given package. - -So by default, all the tables end up in a single SQL file: - -{{{ -build/ - sql/ - schema.sql -}}} - -If you specialize the `package` for each `` element, Propel uses it for SQL files: - -{{{ -build/ - sql/ - author.schema.sql // contains CREATE TABLE author - book.schema.sql // contains CREATE TABLE book and CREATE TABLE review -}}} - -And, as you probably expect it, a package overridden at the table level also accounts for an independent SQL file: - -{{{ -build/ - sql/ - author.schema.sql // contains CREATE TABLE author - book.schema.sql // contains CREATE TABLE book - review.schema.sql // contains CREATE TABLE review -}}} - -== Understanding The packageObjectModel Build Property == - -The `propel.packageObjectModel` build property enables the "packaged" build process. This modifies the build tasks behavior by joining `` elements of the same name - but keeping their packages separate. That allows to split a large schema into several files, regardless of foreign key dependencies, since Propel will join all schemas using the same database name. - -To switch this on, simply add the following line to the `build.properties` file in your project directory: -{{{ -propel.packageObjectModel = true -}}} - -== The Bookstore Packaged Example == - -In the bookstore-packaged example you'll find the following schema files: - - * author.schema.xml - * book.schema.xml - * club.schema.xml - * media.schema.xml - * publisher.schema.xml - * review.schema.xml - * log.schema.xml - -Each schema file has to contain a `` tag that has its `package` attribute set to the package name where ''all'' of the tables in this schema file/database belong to. - -For example, in the bookstore-packaged example the `author.schema.xml` contains the following `` tag: - -{{{ - -}}} - -That means, that the Author OM classes will be created in a subdirectory `core/author/` of the build output directory. - -You can have more than one schema file that belong to one package. For example, in the the bookstore-packaged example both the `book.schema.xml` and `media.schema.xml` belong to the same package "core.book". The generated OM classes for these schemas will therefore end up in the same `core/book/` subdirectory. - -=== The OM build === - -To run the packaged bookstore example build simply go to the `propel/test/fixtures/bookstore-packages/` directory and type: - -{{{ -../../../generator/bin/propel-gen om -}}} - -This should run without any complaints. When you have a look at the projects/bookstore-packaged/build/classes directory, the following directory tree should have been created: -{{{ -addon/ - club/ - BookClubList.php - BookClubListPeer.php - BookListRel.php - BookListRelPeer.php -core/ - author/ - Author.php - AuthorPeer.php - book/ - Book.php - BookPeer.php - - Media.php - MediaPeer.php - publisher/ - Publisher.php - PublisherPeer.php - review/ - Review.php - ReviewPeer.php -util/ - log/ - BookstoreLog.php - BookstoreLogPeer.php -}}} - -(The additional subdirectories map/ and om/ in each of these directories have been omitted for clarity.) - -== The SQL build == - -From the same schema files, run the SQL generation by calling: - -{{{ -../../../generator/bin/propel-gen sql -}}} - -Then, have a look at the `build/sql/` directory: you will see that for each package (that is specified as a package attribute in the schema file database tags), one sql file has been created: - - * addon.club.schema.sql - * core.author.schema.sql - * core.book.schema.sql - * core.publisher.schema.sql - * core.review.schema.sql - * util.log.schema.sql - -These files contain the CREATE TABLE SQL statements necessary for each package. - -When you now run the insert-sql task by typing: -{{{ -../../../generator/bin/propel-gen insert-sql -}}} -these SQL statements will be executed on a SQLite database located in the Propel/generator/test/ directory. \ No newline at end of file diff --git a/airtime_mvc/library/propel/docs/cookbook/Namespaces.txt b/airtime_mvc/library/propel/docs/cookbook/Namespaces.txt deleted file mode 100644 index 705d5ed68..000000000 --- a/airtime_mvc/library/propel/docs/cookbook/Namespaces.txt +++ /dev/null @@ -1,133 +0,0 @@ -= How to Use PHP 5.3 Namespaces = - -The generated model classes can use a namespace. It eases the management of large database models, and makes the Propel model classes integrate with PHP 5.3 applications in a clean way. - -== Namespace Declaration And Inheritance == - -To define a namespace for a model class, you just need to specify it in a `namespace` attribute of the `` element for a single table, or in the `` element to set the same namespace to all the tables. - -Here is an example schema using namespaces: - -{{{ -#!xml - - - -
- - - - - - - - - - - - -
- - - - - - -
- - - - -
- - - - - -
- -
-}}} - -The `` element defines a `namespace` attribute. The `book` and `author` tables inherit their namespace from the database, therefore the generated classes for these tables will be `\Bookstore\Book` and `\Bookstore\Author`. - -The `publisher` table defines a `namespace` attribute on ots own, which ''extends'' the database namespace. That means that the generated class will be `\Bookstore\Book\Publisher`. - -As for the `user` table, it defines an absolute namespace (starting with a backslash), which ''overrides'' the database namespace. The generated class for the `user` table will be `Admin\User`. - -'''Tip''': You can use subnamespaces (i.e. namespaces containing backslashes) in the `namespace` attribute. - -== Using Namespaced Models == - -Namespaced models benefit from the Propel runtime autoloading just like the other model classes. You just need to alias them, or to use their fully qualified name. - -{{{ -#!php -setAuthor($author); -$book->save(); -}}} - -The namespace is used for the ActiveRecord class, but also for the Query and Peer classes. Just remember that when you use relation names ina query, the namespace should not appear: - -{{{ -#!php -useBookQuery() - ->filterByPrice(array('max' => 10)) - ->endUse() - ->findOne(); -}}} - -Related tables can have different namespaces, it doesn't interfere with the functionality provided by the object model: - -{{{ -#!php -findOne(); -echo get_class($book->getPublisher()); -// \Bookstore\Book\Publisher -}}} - -'''Tip''': Using namespaces make generated model code incompatible with versions of PHP less than 5.3. Beware that you will not be able to use your model classes in an older PHP application. - -== Using Namespaces As A Directory Structure == - -In a schema, you can define a `package` attribute on a `` or a `` tag to generate model classes in a subdirectory (see [wiki:Documentation/1.5/Multi-Component]). If you use namespaces to autoload your classes based on a SplClassAutoloader (see http://groups.google.com/group/php-standards), then you may find yourself repeating the `namespace` data in the `package` attribute: - -{{{ -#!xml - -}}} - -To avoid such repetitions, just set the `propel.namespace.autoPackage` setting to `true` in your `build.properties`: - -{{{ -#!ini -propel.namespace.autoPackage = true -}}} - -Now Propel will automatically create a `package` attribute, and therefore distribute model classes in subdirectories, based on the `namespace` attribute, and you can omit the manual `package` attribute in the schema: - -{{{ -#!xml - -}}} \ No newline at end of file diff --git a/airtime_mvc/library/propel/docs/cookbook/Nested-Set.txt b/airtime_mvc/library/propel/docs/cookbook/Nested-Set.txt deleted file mode 100644 index 8cf7fed7e..000000000 --- a/airtime_mvc/library/propel/docs/cookbook/Nested-Set.txt +++ /dev/null @@ -1,183 +0,0 @@ -= !NestedSet support in Propel = - -'''Warning''': Since Propel 1.5, the support for nested sets was moved to the `nested_set` behavior. The method described here is deprecated.''' - -== Description == - -With !NestedSet implementation, trees are stored using different approach in databases: [http://www.sitepoint.com/article/hierarchical-data-database] - -Nested Set implementation requires three dedicated fields in table structure - - * left - * right - -Plus an optional fields for multi nested set support - * scope - -''NB: fields name are free and must be defined in schema.xml'' - -To enable !NestedSet support in table, schema.xml must define some specific attributes: -'''treeMode''' which must take the value '''!NestedSet''' - -{{{ -#!xml -
-}}} - -Then, left and right field must be defined that way '''nestedSetLeftKey''' as a boolean value as '''nestedSetRightKey''' - -{{{ -#!xml - - -}}} - -For multi nestedset support, an other column must be defined with boolean attribute '''treeScopeKey''' set to true -{{{ -#!xml - -}}} - -And then, let's the propel generator automagically create all the needed model and stub classes. - -== !NestedSet usage in Propel == - -''ex:'' -'''schema.xml''' extract -{{{ -#!xml -
- - - - - - - - - - - - - - - -
-}}} - -=== !NestedSet insertion === -{{{ -#!php -setText('Google'); -$root->setLink('http://www.google.com'); - -$root->makeRoot(); -$root->save(); - -$menu = new Menu(); -$menu->setText('Google Mail'); -$menu->setLink('http://mail.google.com'); -$menu->insertAsLastChildOf($root); -$menu->save(); - -$child = new Menu(); -$child->setText('Google Maps'); -$child->setLink('http://maps.google.com'); -$child->insertAsLastChildOf($root); -$child->save(); - -$sibling = new Menu(); -$sibling->setText('Yahoo!'); -$sibling->setLink('http://www.yahoo.com'); -$sibling->insertAsNextSiblingOf($root); -$sibling->save(); - -$child = new Menu(); -$child->setText('Yahoo! Mail'); -$child->setLink('http://mail.yahoo.com'); -$child->insertAsLastChildOf($sibling); -$child->save(); -}}} - -=== Multi !NestedSet insertion === -{{{ -#!php -setText('Google'); -$root->setLink('http://www.google.com'); - -$root->makeRoot(); -$root->setScopeIdValue(1); // Tree 1 -$root->save(); - -$menu = new Menu(); -$menu->setText('Google Mail'); -$menu->setLink('http://mail.google.com'); -$menu->insertAsLastChildOf($root); -$menu->save(); - -// Create secund root node -$root2 = new Menu(); -$root2->setText('Yahoo!'); -$root2->setLink('http://www.yahoo.com'); - -$root2->makeRoot(); -$root2->setScopeIdValue(2); // Tree 2 -$root2->save(); - -$menu = new Menu(); -$menu->setText('Yahoo! Mail'); -$menu->setLink('http://mail.yahoo.com'); -$menu->insertAsLastChildOf($root2); -$menu->save(); -}}} - -=== Tree retrieval === -{{{ -#!php -getDepth()); - } - - function endChildren() { - echo str_repeat("\t", $this->getDepth() - 1); - } -} - -$menu = MenuPeer::retrieveTree($scopeId); -$it = new myMenuOutput($menu); -foreach($it as $m) { - echo $m->getText(), '[', $m->getLeftValue(), '-', $m->getRightValue(), "]\n"; -} -}}} -=== Tree traversal === - -!NestetSet implementation use the [http://somabo.de/talks/200504_php_quebec_spl_for_the_masses.pdf SPL RecursiveIterator] as suggested by soenke - -== !NestedSet known broken behaviour == - -=== Issue description === -For every changes applied on the tree, several entries in the database can be involved. So all already loaded nodes have to be refreshed with their new left/right values. - -=== InstancePool enabled === -In order to refresh all loaded nodes, an automatic internal call is made after each tree change to retrieve all instance in InstancePool and update them. -And it works fine. - -=== InstancePool disabled === -When InstancePool is disabled, their is no way to retrieve references to all already loaded node and get them updated. -So in most case, all loaded nodes are not updated and it leads to an inconsistency state. -So, workaround is to do an explicit reload for any node you use after tree change. - - diff --git a/airtime_mvc/library/propel/docs/cookbook/Runtime-Introspection.txt b/airtime_mvc/library/propel/docs/cookbook/Runtime-Introspection.txt deleted file mode 100644 index dce769231..000000000 --- a/airtime_mvc/library/propel/docs/cookbook/Runtime-Introspection.txt +++ /dev/null @@ -1,164 +0,0 @@ -= Model Introspection At Runtime = - -In addition to the object and peer classes used to do C.R.U.D. operations, Propel generates an object mapping for your tables to allow runtime introspection. - -The intospection objects are instances of the map classes. Propel maps databases, tables, columns, validators, and relations into objects that you can easily use. - -== Retrieving a TableMap == - -The starting point for runtime introspection is usually a table map. This objects stores every possible property of a table, as defined in the `schema.xml`, but accessible at runtime. - -To retrieve a table map for a table, use the `getTableMap()` static method of the related peer class. For instance, to retrieve the table map for the `book` table, just call: - -{{{ -#!php -getName(); // 'table' -echo $bookTable->getPhpName(); // 'Table' -echo $bookTable->getPackage(); // 'bookstore' -echo $bookTable->isUseIdGenerator(); // true -}}} - -Tip: A TableMap object also references the `DatabaseMap` that contains it. From the database map, you can also retrieve other table maps using the table name or the table phpName: -{{{ -#!php -getDatabaseMap(); -$authorTable = $dbMap->getTable('author'); -$authorTable = $dbMap->getTablebyPhpName('Author'); -}}} - -To introspect the columns of a table, use any of the `getColumns()`, `getPrimaryKeys()`, and `getForeignKeys()` `TableMap` methods. They all return an array of `ColumnMap` objects. - -{{{ -#!php -getColumns(); -foreach ($bookColumns as $column) { - echo $column->getName(); -} -}}} - -Alternatively, if you know a column name, you can retrieve the corresponding ColumnMap directly using the of `getColumn($name)` method. - -{{{ -#!php -getColumn('title'); -}}} - -The `DatabaseMap` object offers a shortcut to every `ColumnMap` object if you know the fully qualified column name: -{{{ -#!php -getColumn('book.TITLE'); -}}} - -== ColumnMaps == - -A `ColumnMap` instance offers a lot of information about a table column. Check the following examples: - -{{{ -#!php -getTableName(); // 'book' -$bookTitleColumn->getTablePhpName(); // 'Book' -$bookTitleColumn->getType(); // 'VARCHAR' -$bookTitleColumn->getSize(); // 255 -$bookTitleColumn->getDefaultValue(); // null -$bookTitleColumn->isLob(); // false -$bookTitleColumn->isTemporal(); // false -$bookTitleColumn->isEpochTemporal(); // false -$bookTitleColumn->isNumeric(); // false -$bookTitleColumn->isText(); // true -$bookTitleColumn->isPrimaryKey(); // false -$bookTitleColumn->isForeignKey(); // false -$bookTitleColumn->hasValidators(); // false -}}} - -`ColumnMap` objects also keep a reference to their parent `TableMap` object: - -{{{ -#!php -getTable(); -}}} - -Foreign key columns give access to more information, including the related table and column: - -{{{ -#!php -getColumn('publisher_id'); -echo $bookPublisherIdColumn->isForeignKey(); // true -echo $bookPublisherIdColumn->getRelatedName(); // 'publisher.ID' -echo $bookPublisherIdColumn->getRelatedTableName(); // 'publisher' -echo $bookPublisherIdColumn->getRelatedColumnName(); // 'ID' -$publisherTable = $bookPublisherIdColumn->getRelatedTable(); -$publisherRelation = $bookPublisherIdColumn->getRelation(); -}}} - -== RelationMaps == - -To get an insight on all the relationships of a table, including the ones relying on a foreign key located in another table, you must use the `RelationMap` objects related to a table. - -If you know its name, you can retrieve a `RelationMap` object using `TableMap::getRelation($relationName)`. Note that the relation name is the phpName of the related table, unless the foreign key defines a phpName in the schema. For instance, the name of the `RelationMap` object related to the `book.PUBLISHER_ID` column is 'Publisher'. - -{{{ -#!php -getRelation('Publisher'); -}}} - -alternatively, you can access a `RelationMap` from a foreign key column using `ColumnMap::getRelation()`, as follows: - -{{{ -#!php -getColumn('publisher_id')->getRelation(); -}}} - -Once you have a `RelationMap` instance, inspect its properties using any of the following methods: - -{{{ -#!php -getType(); // RelationMap::MANY_TO_ONE -echo $publisherRelation->getOnDelete(); // 'SET NULL' -$bookTable = $publisherRelation->getLocalTable(); -$publisherTable = $publisherRelation->getForeignTable(); -print_r($publisherRelation->getColumnMappings()); - // array('book.PUBLISHER_ID' => 'publisher.ID') -print_r(publisherRelation->getLocalColumns()); - // array($bookPublisherIdColumn) -print_r(publisherRelation->getForeignColumns()); - // array($publisherBookIdColumn) -}}} - -This also works for relationships referencing the current table: - -{{{ -#!php -getRelation('Review'); -echo $reviewRelation->getType(); // RelationMap::ONE_TO_MANY -echo $reviewRelation->getOnDelete(); // 'CASCADE' -$reviewTable = $reviewRelation->getLocalTable(); -$bookTable = $reviewRelation->getForeignTable(); -print_r($reviewRelation->getColumnMappings()); - // array('review.BOOK_ID' => 'book.ID') -}}} - -To retrieve all the relations of a table, call `TableMap::getRelations()`. You can then iterate over an array of `RelationMap` objects. - -Tip: RelationMap objects are lazy-loaded, which means that the `TableMap` will not instanciate any relation object until you call `getRelations()`. This allows the `TableMap` to remain lightweight for when you don't use relationship introspection. diff --git a/airtime_mvc/library/propel/docs/cookbook/Writing-Behavior.txt b/airtime_mvc/library/propel/docs/cookbook/Writing-Behavior.txt deleted file mode 100644 index 33ceebc63..000000000 --- a/airtime_mvc/library/propel/docs/cookbook/Writing-Behavior.txt +++ /dev/null @@ -1,424 +0,0 @@ -= How to Write A Behavior = - -Behaviors are a good way to reuse code across models without requiring inheritance (a.k.a. horizontal reuse). This step-by-step tutorial explains how to port model code to a behavior, focusing on a simple example. - -In the tutorial "[http://propel.posterous.com/getting-to-know-propel-15-keeping-an-aggregat Keeping an Aggregate Column up-to-date]", posted in the [http://propel.posterous.com/ Propel blog], the `TotalNbVotes` property of a `PollQuestion` object was updated each time a related `PollAnswer` object was saved, edited, or deleted. This "aggregate column" behavior was implemented by hand using hooks in the model classes. To make it truly reusable, the custom model code needs to be refactored and moved to a Behavior class. - -== Boostrapping A Behavior == - -A behavior is a class that can alter the generated classes for a table of your model. It must only extend the [browser:branches/1.5/generator/lib/model/Behavior.php `Behavior`] class and implement special "hook" methods. Here is the class skeleton to start with for the `aggregate_column` behavior: - -{{{ -#!php - null, - ); -} -}}} - -Save this class in a file called `AggregateColumnBehavior.php`, and set the path for the class file in the project `build.properties` (just replace directory separators with dots). Remember that the `build.properties` paths are relative to the include path: - -{{{ -#!ini -propel.behavior.aggregate_column.class = path.to.AggregateColumnBehavior -}}} - -Test the behavior by adding it to a table of your model, for instance to a `poll_question` table: - -{{{ -#!xml - - - - - - - -
-
-}}} - -Rebuild your model, and check the generated `PollQuestionTableMap` class under the `map` subdirectory of your build class directory. This class carries the structure metadata for the `PollQuestion` ActiveRecord class at runtime. The class should feature a `getBehaviors()` method as follows, proving that the behavior was correctly applied: - -{{{ -#!php - array('name' => 'total_nb_votes', ), - ); - } // getBehaviors() -} -}}} - -== Adding A Column == - -The behavior works, but it still does nothing at all. Let's make it useful by allowing it to add a column. In the `AggregateColumnBehavior` class, just implement the `modifyTable()` method with the following code: - -{{{ -#!php -getTable(); - if (!$columnName = $this->getParameter('name')) { - throw new InvalidArgumentException(sprintf( - 'You must define a \'name\' parameter for the \'aggregate_column\' behavior in the \'%s\' table', - $table->getName() - )); - } - // add the aggregate column if not present - if(!$table->containsColumn($columnName)) { - $table->addColumn(array( - 'name' => $columnName, - 'type' => 'INTEGER', - )); - } - } -} -}}} - -This method shows that a behavior class has access to the `` defined for it in the `schema.xml` through the `getParameter()` command. Behaviors can also always access the `Table` object attached to them, by calling `getTable()`. A `Table` can check if a column exists and add a new one easily. The `Table` class is one of the numerous generator classes that serve to describe the object model at buildtime, together with `Column`, `ForeignKey`, `Index`, and a lot more classes. You can find all the buildtime model classes under the [browser:branches/1.5/generator/lib/model generator/lib/model] directory. - -'''Tip''': Don't mix up the ''runtime'' database model (`DatabaseMap`, `TableMap`, `ColumnMap`, `ValidatorMap`, `RelationMap`) with the ''buildtime'' database model (`Database`, `Table`, `Column`, `Validator`, etc.). The buildtime model is very detailed, in order to ease the work of the builders that write the ActiveRecord and Query classes. On the other hand, the runtime model is optimized for speed, and carries minimal information to allow correct hydration and binding at runtime. Behaviors use the buildtime object model, because they are run at buildtime, so they have access to the most powerful model. - -Now rebuild the model and the SQL, and sure enough, the new column is there. `BasePollQuestion` offers a `getTotalNbVotes()` and a `setTotalNbVotes()` method, and the table creation SQL now includes the additional `total_nb_votes` column: - -{{{ -#!sql -DROP TABLE IF EXISTS poll_question; -CREATE TABLE poll_question -( - id INTEGER NOT NULL AUTO_INCREMENT, - title VARCHAR(100), - total_nb_votes INTEGER, - PRIMARY KEY (id) -)Type=InnoDB; -}}} - -'''Tip''': The behavior only adds the column if it's not present (`!$table->containsColumn($columnName)`). So if a user needs to customize the column type, or any other attribute, he can include a `` tag in the table with the same name as defined in the behavior, and the `modifyTable()` will then skip the column addition. - -== Adding A Method To The ActiveRecord Class == - -In the previous post, a method of the ActiveRecord class was in charge of updating the `total_nb_votes` column. A behavior can easily add such methods by implementing the `objectMethods()` method: - -{{{ -#!php -addUpdateAggregateColumn(); - return $script; - } - - protected function addUpdateAggregateColumn() - { - $sql = sprintf('SELECT %s FROM %s WHERE %s = ?', - $this->getParameter('expression'), - $this->getParameter('foreign_table'), - $this->getParameter('foreign_column') - ); - $table = $this->getTable(); - $aggregateColumn = $table->getColumn($this->getParameter('name')); - $columnPhpName = $aggregateColumn->getPhpName(); - $localColumn = $table->getColumn($this->getParameter('local_column')); - return " -/** - * Updates the aggregate column {$aggregateColumn->getName()} - * - * @param PropelPDO \$con A connection object - */ -public function update{$columnPhpName}(PropelPDO \$con) -{ - \$sql = '{$sql}'; - \$stmt = \$con->prepare(\$sql); - \$stmt->execute(array(\$this->get{$localColumn->getPhpName()}())); - \$this->set{$columnPhpName}(\$stmt->fetchColumn()); - \$this->save(\$con); -} -"; - } -} -}}} - -The ActiveRecord class builder expects a string in return to the call to `Behavior::objectMethods()`, and appends this string to the generated code of the ActiveRecord class. Don't bother about indentation: builder classes know how to properly indent a string returned by a behavior. A good rule of thumb is to create one behavior method for each added method, to provide better readability. - -Of course, the schema must be modified to supply the necessary parameters to the behavior: - -{{{ -#!xml - - - - - - - - - - - -
- - - - - - - - -
-
-}}} - -Now if you rebuild the model, you will see the new `updateTotalNbVotes()` method in the generated `BasePollQuestion` class: - -{{{ -#!php -prepare($sql); - $stmt->execute(array($this->getId())); - $this->setTotalNbVotes($stmt->fetchColumn()); - $this->save($con); - } -} -}}} - -Behaviors offer similar hook methods to allow the addition of methods to the query classes (`queryMethods()`) and to the peer classes (`peerMethods()`). And if you need to add attributes, just implement one of the `objectAttributes()`, `queryAttributes()`, or `peerAttributes()` methods. - -== Using a Template For Generated Code == - -The behavior's `addUpdateAggregateColumn()` method is somehow hard to read, because of the large string containing the PHP code canvas for the added method. Propel behaviors can take advantage of Propel's simple templating system to use an external file as template for the code to insert. - -Let's refactor the `addUpdateAggregateColumn()` method to take advantage of this feature: - -{{{ -#!php -getParameter('expression'), - $this->getParameter('foreign_table'), - $this->getParameter('foreign_column') - ); - $table = $this->getTable(); - $aggregateColumn = $table->getColumn($this->getParameter('name')); - return $this->renderTemplate('objectUpdateAggregate', array( - 'aggregateColumn' => $aggregateColumn, - 'columnPhpName' => $aggregateColumn->getPhpName(), - 'localColumn' => $table->getColumn($this->getParameter('local_column')), - 'sql' => $sql, - )); - } -} -}}} - -The method no longer returns a string created by hand, but a ''rendered template''. Propel templates are simple PHP files executed in a sandbox - they have only access to the variables declared as second argument of the `renderTemplate()` call. - -Now create a `templates/` directory in the same directory as the `AggregateColumnBehavior` class file, and add in a `objectUpdateAggregate.php` file with the following code: - -{{{ -#!php -/** - * Updates the aggregate column getName() ?> - * - * @param PropelPDO $con A connection object - */ -public function update(PropelPDO $con) -{ - $sql = ''; - $stmt = $con->prepare($sql); - $stmt->execute(array($this->getgetPhpName() ?>())); - $this->set($stmt->fetchColumn()); - $this->save($con); -} -}}} - -No need to escape dollar signs anymore: this syntax allows for a cleaner separation, and is very convenient for large behaviors. - -== Adding Another Behavior From A Behavior == - -This is where it's getting tricky. In the [http://propel.posterous.com/getting-to-know-propel-15-keeping-an-aggregat blog post] describing the column aggregation technique, the calls to the `updateTotalNbVotes()` method come from the `postSave()` and `postDelete()` hooks of the `PollAnswer` class. But the current behavior is applied to the `poll_question` table, how can it modify the code of a class based on another table? - -The short answer is: it can't. To modify the classes built for the `poll_answer` table, a behavior must be registered on the `poll_answer` table. But a behavior is just like a column or a foreign key: it has an object counterpart in the buildtime database model. So the trick here is to modify the `AggregateColumnBehavior::modifyTable()` method to ''add a new behavior'' to the foreign table. This second behavior will be in charge of implementing the `postSave()` and `postDelete()` hooks of the `PollAnswer` class. - -{{{ -#!php -getDatabase()->getTable($this->getParameter('foreign_table')); - if (!$foreignTable->hasBehavior('concrete_inheritance_parent')) { - require_once 'AggregateColumnRelationBehavior.php'; - $relationBehavior = new AggregateColumnRelationBehavior(); - $relationBehavior->setName('aggregate_column_relation'); - $relationBehavior->addParameter(array( - 'name' => 'foreign_table', - 'value' => $table->getName() - )); - $relationBehavior->addParameter(array( - 'name' => 'foreign_column', - 'value' => $this->getParameter('name') - )); - $foreignTable->addBehavior($relationBehavior); - } - } -} -}}} - -In practice, everything now happens as if the `poll_answer` had its own behavior: - -{{{ -#!xml - - - - - - - - -
-
-}}} - -Adding a behavior to a `Table` instance, as well as adding a `Parameter` to a `Behavior` instance, is quite straightforward. And since the second behavior class file is required in the `modifyTable()` method, there is no need to add a path for it in the `build.properties`. - -== Adding Code For Model Hooks == - -The new `AggregateColumnRelationBehavior` is yet to write. It must implement a call to `PollQuestion::updateTotalNbVotes()` in the `postSave()` and `postDelete()` hooks. - -Adding code to hooks from a behavior is just like adding methods: add a method with the right hook name returning a code string, and the code will get appended at the right place. Unsurprisingly, the behavior hook methods for `postSave()` and `postDelete()` are called `postSave()` and `postDelete()`: - -{{{ -#!php - null, - 'foreignColumn' => null, - ); - - public function postSave() - { - $table = $this->getTable(); - $foreignTable = $table->getDatabase()->getTable($this->getParameter('foreign_table')); - $foreignColumn = $foreignTable->getColumn($this->getParameter('foreign_column')); - $foreignColumnPhpName = $foreignColumn->getPhpName(); - return "\$this->updateRelated{$foreignColumnPhpName}(\$con)"; - } - - public function postDelete() - { - return $this->postSave(); - } - - public function objectMethods() - { - $script = ''; - $script .= $this->addUpdateRelatedAggregateColumn(); - return $script; - } - - protected function addUpdateRelatedAggregateColumn() - { - $table = $this->getTable(); - $foreignTable = $table->getDatabase()->getTable($this->getParameter('foreign_table')); - $foreignTablePhpName = foreignTable->getPhpName(); - $foreignColumn = $foreignTable->getColumn($this->getParameter('foreign_column')); - $foreignColumnPhpName = $foreignColumn->getPhpName(); - return " -/** - * Updates an aggregate column in the foreign {$foreignTable->getName()} table - * - * @param PropelPDO \$con A connection object - */ -protected function updateRelated{$foreignColumnPhpName}(PropelPDO \$con) -{ - if (\$parent{$foreignTablePhpName} = \$this->get{$foreignTablePhpName}()) { - \$parent{$foreignTablePhpName}->update{$foreignColumnPhpName}(\$con); - } -} -"; - } -} -}}} - -The `postSave()` and `postDelete()` behavior hooks will not add code to the ActiveRecord `postSave()` and `postDelete()` methods - to allow users to further implement these methods - but instead it adds code directly to the `save()` and `delete()` methods, inside a transaction. Check the generated `BasePollAnswer` class for the added code in these methods: - -{{{ -#!php -updateRelatedTotalNbVotes($con); -}}} - -You will also see the new `updateRelatedTotalNbVotes()` method added by `AggregateColumnBehavior::objectMethods()`: - -{{{ -#!php -getPollQuestion()) { - $parentPollQuestion->updateTotalNbVotes($con); - } -} -}}} - -== What's Left == - -These are the basics of behavior writing: implement one of the methods documented in the [wiki:Documentation/1.5/Behaviors#WritingaBehavior behaviors chapter] of the Propel guide, and return strings containing the code to be added to the ActiveRecord, Query, and Peer classes. In addition to the behavior code, you should always write unit tests - all the behaviors bundled with Propel have full unit test coverage. And to make your behavior usable by others, documentation is highly recommended. Once again, Propel core behaviors are fully documented, to let users understand the behavior usage without having to peek into the code. - -As for the `AggregateColumnBehavior`, the job is not finished. The [http://propel.posterous.com/getting-to-know-propel-15-keeping-an-aggregat blog post] emphasized the need for hooks in the Query class, and these are not yet implemented in the above code. Besides, the post kept quiet about one use case that left the aggregate column not up to date (when a question is detached from a poll without deleting it). Lastly, the parameters required for this behavior are currently a bit verbose, especially concerning the need to define the foreign table and the foreign key - this could be simplified thanks to the knowledge of the object model that behaviors have. - -All this is left to the reader as an exercise. Fortunately, the final behavior is part of the Propel core behaviors, so the [browser:branches/1.5/generator/lib/behavior/aggregate_column code], [browser:branches/1.5/test/testsuite/generator/behavior/aggregate_column unit tests], and [wiki:Documentation/1.5/Behaviors/aggregate_column documentation] are all ready to help you to further understand the power of Propel's behavior system. \ No newline at end of file diff --git a/airtime_mvc/library/propel/docs/guide/01-Installation.txt b/airtime_mvc/library/propel/docs/guide/01-Installation.txt deleted file mode 100644 index f5ca02442..000000000 --- a/airtime_mvc/library/propel/docs/guide/01-Installation.txt +++ /dev/null @@ -1,164 +0,0 @@ -= Installing Propel = - -[[PageOutline]] - -Propel is available as a [http://pear.php.net/manual/en/installation.getting.php PEAR] package, as a "traditional" tgz or zip package, and as a checkout from a Subversion repository. Whatever installation method you may choose, getting Propel to work is pretty straightforward. - -== Prerequisites == - -Propel requirements are very light, allowing it to run on most PHP platforms: - - * [http://www.php.net/ PHP 5.2.4] or newer, with the DOM (libxml2) module enabled - * A supported database (MySQL, MS SQL Server, PostgreSQL, SQLite, Oracle) - -'''Tip''': Propel uses the PDO and SPL components, which are bundled and enabled by default in PHP5. - -== Propel Components == - -The Propel library is made of two components: a '''generator''', and a '''runtime library'''. These components are not co-dependent, and can be installed independently from each other. - -The generator is needed to build the object model, but is not required for running applications that use Propel. - -The runtime classes provide the shared functionality that is used by the Propel-generated object model classes. These are necessary to run applications that use Propel to access the database. - -Usually, both the generator and the runtime components are installed on development environments, while the actual test or production servers need only the runtime components installed. For your first contact with Propel, just install both. - -== Installing Propel == - -=== Installing Propel From PEAR === - -In order to install the Propel packages, you must add the `pear.propelorm.org` channel to your PEAR environment. Once the channel is discovered, you can install the generator package, or the runtime package, or both. Use the '-a' option to let PEAR download and install dependencies. - -{{{ -#!sh -> pear channel-discover pear.propelorm.org -> pear install -a propel/propel_generator -> pear install -a propel/propel_runtime -}}} - -Propel is now installed, and you can test it by following the instructions of the '''Testing Propel Installation''' section at the end of this page. - -Tip: If you want to install non-stable versions of Propel, change your `preferred_state` PEAR environment variable before installoing the Propel packages. Valid states include 'stable', 'beta', 'alpha', and 'devel': - -{{{ -#!sh -> pear config-set preferred_state beta -}}} - -=== Dependencies for Tarball and Subversion Versions === - -The Propel generator uses [http://phing.info/ Phing 2.3.3] to manage command line tasks; both the generator and the runtime classes use [http://pear.php.net/package/Log/ PEAR Log] to log events. - -If you choose to install Propel via PEAR, these components will be automatically installed as dependencies. If you choose to install Propel from a tarball or a Subversion checkout, you'll have to install them manually: - -{{{ -#!sh -> pear channel-discover pear.phing.info -> pear install phing/phing -> pear install Log -}}} - -Refer to their respective websites for alternative installation strategies for Phing and Log. - -=== Installing Propel From Subversion === - -Installing from SVN trunk ensures that you have the most up-to-date source code. - -{{{ -#!sh -> svn checkout http://svn.propelorm.org/branches/1.5 /usr/local/propel -}}} - -This will export both the generator and runtime components to your local `propel` directory. In addition, you'll also get Propel documentation and unit tests - that's why this method is the preferred installation method for Propel contributors. - -Once this is done, you'll need to setup your PHP environment to use this library - see the '''Setting Up PHP for Propel''' section below. - -Note: `branches/1.5` is currently more uptodate code than `trunk`; trunk is what will become 2.0, however it has had very little work done to it in a long time. - -=== Installing Propel From a Tarball === - -Download a tarball of each of the Propel components from the Propel website, and uncompress them into the location that best suits your need. For instance, in Linux: - -{{{ -#!sh -> cd /usr/local -> mkdir propel -> cd propel -> wget http://pear.propelorm.org/get/propel_generator-1.5.0.tgz -> tar zxvf propel_generator-1.5.0.tgz -> wget http://pear.propelorm.org/get/propel_runtime-1.5.0.tgz -> tar zxvf propel_runtime-1.5.0.tgz -}}} - -Once this is done, you'll need to setup your PHP environment to use this library. - -== Setting Up PHP for the Propel Generator == - -The following instructions are only required if you installed Propel from a tarball, or from Subversion. - -The Propel generator component bundles a `propel-gen` sh script (and a `propel-gen.bat` script for Windows). This script simplifies the commandline invocation of the Propel generator by hiding any references to Phing. - -You can call it directly from the command line: - -{{{ -#!sh -> /usr/local/propel/generator/bin/propel-gen -}}} - -In order to allow an easier execution the script, you can also: - - * add the propel generator's `bin/` directory to your PATH, - * or copy the `propel-gen` script to a location on your PAH, - * or (on Linux systems) create a symlink. For example: - -{{{ -#!sh -> cd /usr/local/bin -> ln -s /usr/local/propel/generator/bin/propel-gen propel-gen -}}} - -== Testing Propel Installation == - -You can test that the '''Propel generator''' component is properly installed by calling the `propel-gen` script from the CLI: - -{{{ -#!sh -> propel-gen -}}} - -The script should output a few lines before displaying a 'BUILD FAILED' message, which is normal - you haven't defined a database model yet. - -You can test that the '''Propel runtime''' component is properly installed by requiring the `Propel.php` script, as follows: - -{{{ -#!php -` tag: - -{{{ -#!xml - - - - -}}} - -The `name` attribute defines the name of the connection that Propel uses for the tables in this schema. It is not necessarily the name of the actual database. In fact, Propel uses a second file to link a connection name with real connection settings (like databae name, user and password). This `runtime-conf.xml` file will be explained later in this chapter. - -The `defaultIdMethod` attribute indicates that the tables in this schema use the database's "native" auto-increment/sequence features to handle id columns that are set to auto-increment. - -'''Tip''': You can define several schemas for a single project. Just make sure that each of the schema filenames end with `schema.xml`. - -=== Tables And Columns === - -Within the `` tag, Propel expects one `` tag for each table: - -{{{ -#!xml - - -
- -
- - -
- - -
-
-}}} - -This time, the `name` attributes are the real table names. The `phpName` is the name that Propel will use for the generated PHP class. By default, Propel uses a CamelCase version of the table name as its phpName - that means that you could omit the `phpName` attribute in the example above. - -Within each set of `` tags, define the columns that belong to that table: - -{{{ -#!xml - - -
- - - - - -
- - - - -
- - - -
-
-}}} - -Each column has a `name` (the one used by the database), and an optional `phpName` attribute. Once again, the Propel default behavior is to use a CamelCase version of the `name` as `phpName` when not specified. - -Each column also requires a `type`. The XML schema is database agnostic, so the column types and attributes are probably not exactly the same as the one you use in your own database. But Propel knows how to map the schema types with SQL types for many database vendors. Existing Propel column types are boolean, tinyint, smallint, integer, bigint, double, float, real, decimal, char, varchar, longvarchar, date, time, timestamp, blob, and clob. Some column types use a `size` (like `varchar` and `int`), some have unlimited size (`longvarchar`, `clob`, `blob`). - -As for the other column attributes, `required`, `primaryKey`, and `autoIncrement`, they mean exactly what their names suppose. - -'''Tip''': Propel supports namespaces (for PHP > 5.3). If you specify a `namespace` attribute in a `` element, the generated PHP classes for this table will use this namespace. - -=== Foreign Keys === - -A table can have several `` tags, describing foreign keys to foreign tables. Each `` tag consists of one or more mappings between a local column and a foreign column. - -{{{ -#!xml - - -
- - - - - - - - - - - -
- - - - -
- - - -
-
-}}} - -A foreign key represents a relationship. Just like a table or a column, a relationship has a `phpName`. By default, Propel uses the `phpName` of the foreign table as the `phpName` of the relation. The `refPhpName` defines the name of the relation as seen from the foreign table. - -There are many more attributes and elements available to describe a datamodel. Propel's documentation provides a complete [wiki:Documentation/1.5/Schema reference of the schema syntax], together with a [source:branches/1.5/generator/resources/dtd/database.dtd DTD] and a [source:branches/1.5/generator/resources/xsd/database.xsd XSD] schema for its validation. - -== Building The Model == - -=== Setting Up Build Configuration === - -The build process is highly customizable. Whether you need the generated classes to inherit one of your classes rather than Propel's base classes, or to enable/disable some methods in the generated classes, pretty much every customization is possible. Of course, Propel provides sensible defaults, so that you actually need to define only two settings for the build process to start: the RDBMS you are going to use, and a name for your project. - -Propel expects the build configuration to be stored in a file called `build.properties`, and stored at the same level as the `schema.xml`. Here is an example for a MySQL database: - -{{{ -#!ini -# Database driver -propel.database = mysql - -# Project name -propel.project = bookstore -}}} - -Use your own database vendor driver, chosen among pgsql, mysql, sqlite, mssql, and oracle. - -You can learn more about the available build settings and their possible values in the [wiki:Documentation/1.5/BuildConfiguration build configuration reference]. - -=== Using the `propel-gen` Script To Build The Model === - -The Propel generator uses the `propel-gen` script, as seen in the previous chapter. This executable expects a command name as its argument. - -Open a terminal and browse to the `bookstore/` directory, where you saved the two previous files (`schema.xml`, and `build.properties`). Then use the `propel-gen` script to call the "Object Model generator" command using its shortcut - "om": - -{{{ -> cd /path/to/bookstore -> propel-gen om -}}} - -You should normally see a some colored lines appear in the terminal, logging all the class generation, and ending with "BUILD FINISHED". If not, look for red lines in the log and follow the directions in the error messages. - -=== Generated Object Model === - -The "om" command added a new directory in the `bookstore/` project, called `build/`. The generated model classes are located under the `classes/bookstore/` subdirectory: - -{{{ -> cd /path/to/bookstore -> cd build/classes/bookstore/ -> ls - om/ - map/ - Author.php - AuthorPeer.php - AuthorQuery.php - Book.php - BookPeer.php - BookQuery.php - Publisher.php - PublisherPeer.php - PublisherQuery.php -}}} - -For every table in the database, Propel creates 3 PHP classes: - - * a ''model'' class (e.g. `Book`), which represents a row in the database; - * a ''peer'' class (e.g. `BookPeer`), offering static constants and methods mostly for compatibility with previous Propel versions; - * a ''query'' class (e.g. `BookQuery`), used to operate on a table to retrieve and update rows - -Propel uses the `phpName` attribute of each table as the base for the PHP class names. - -All these classes are empty, but they inherit from `Base` classes that you will find under the `om/` directory: - -{{{ -#!php - cd /path/to/bookstore -> propel-gen sql -}}} - -The generated SQL definition can be found in the `build/sql/schema.sql` file. The code is optimized for the database driver defined in the `build.properties`. - -=== Using The SQL File === - -Create the database and setup the access permissions using your favorite database client. For instance, to create the `my_db_name` database with MySQL, type: - -{{{ -> mysqladmin -u root -p create my_db_name -}}} - -Now you can use the generated code directly: - -{{{ -> mysql -u root -p my_db_name < build/sql/schema.sql -}}} - -'''Tip''': The `schema.sql` file will DROP any existing table before creating them, which will effectively erase your database. - -Depending on which RDBMS you are using, it may be normal to see some errors (e.g. "unable to DROP...") when you first run this command. This is because some databases have no way of checking to see whether a database object exists before attempting to DROP it (MySQL is a notable exception). It is safe to disregard these errors, and you can always run the script a second time to make sure that the errors are no longer present. - -=== Inserting SQL With `propel-gen` === - -As an alternative to using the generated sql code directly, you can ask Propel to insert it directly into your database. Start by defining the database connection settings in the `build.properties`, as follows: - -{{{ -# Connection parameters -propel.database.url = mysql:host=localhost;dbname=my_db_name -propel.database.user = my_db_user -propel.database.password = my_db_password - -# Other examples: -# propel.database.url = sqlite:/path/to/bookstore.db -# propel.database.url = pgsql:host=localhost dbname=my_db_name user=my_db_user password=my_db_password -}}} - -The `propel.database.url` setting should be a PDO DSN (see the [http://www.php.net/pdo PDO documentation] for more information about vendor-specific DSN). The `user` and `password` are only necessary for the `mysql` and `oracle` drivers. - -Then use the `propel-gen` script with the "insert-sql" command to connect to the database and inject the generated SQL code: - -{{{ -> cd /path/to/bookstore -> propel-gen insert-sql -}}} - -== Runtime Connection Settings == - -The database and PHP classes are now ready to be used. But they don't know yet how to communicate with each other at runtime. You must add a configuration file so that the generated object model classes and the shared Propel runtime classes can connect to the database, and log the Propel activity. - -=== Writing The XML Runtime Configuration === - -Create a file called `runtime-conf.xml` at the root of the `bookstore` project, using the following content: -{{{ -#!xml - - - - - - - mysql - - mysql:host=localhost;dbname=my_db_name - my_db_user - my_db_password - - - - - -}}} - -Notice how the `id` attribute of the `` tag matches the connection name defined in the `` tag of the `schema.xml`. This is how Propel maps a database description to a connection. - -Replace the `` and the `` settings wit hthe ones of your database. - -See the [wiki:Documentation/1.5/RuntimeConfiguration runtime configuration reference] for a more detailed explanation of this file. - -'''Tip''': If you uncomment the `` section, Propel will attempt to instantiate the `Log` class (from the [http://pear.php.net/package/Log/ PEAR Log] package) with the specified parameters and use that to log queries. Propel's statement logging happens at the DEBUG level (7); errors and warnings are logged at the appropriate (non-debug) level. - -=== Building the Runtime Configuration === - -For performance reasons, Propel prefers to use a PHP version of the connection settings rather than the XML file you just defined. So you must use the `propel-gen` script one last time to build the PHP version of the `runtime-conf.xml` configuration: - -{{{ -> cd /path/to/bookstore -> propel-gen convert-conf -}}} - -The resulting file can be found under `build/conf/bookstore-conf.php`, where "bookstore" is the name of the project you defined in `build.properties`. - -'''Tip''': As you saw, a Propel project setup requires that you call three commands with the `propel-gen` script: `om`, `sql`, and `convert-conf`. This is so usual that if you call the `propel-gen` script with no parameter, it will execute these three commands in a row: - -{{{ -> cd /path/to/bookstore -> propel-gen -}}} - -== Setting Up Propel == - -This is the final step: initialize Propel in your PHP script. You may wish to do this step in an init or setup script that is included at the beginning of your PHP scripts. - -Here is a sample initialization file: - -{{{ -#!php -setFirstName('Jane'); -$author->setLastName('austen'); -$author->save(); -}}} - -The column names used in the `setXXX()` methods correspond to the `phpName` attribute of the `` tag in your schema, or to a CamelCase version of the column name if the `phpName` is not set. - -In the background, the call to `save()` results in the following SQL being executed on the database: -{{{ -#!sql -INSERT INTO author (first_name, last_name) VALUES ('Jane', 'Austen'); -}}} - -== Reading Object Properties == - -Propel maps the columns of a table into properties of the generated objects. For each property, you can use a generated getter to access it. - -{{{ -#!php -getId(); // 1 -echo $author->getFirstName(); // 'Jane' -echo $author->getLastName(); // 'austen' -}}} - -The `id` column was set automatically by the database, since the `schema.xml` defines it as an `autoIncrement` column. The value is very easy to retrieve once the object is saved: just call the getter on the column phpName. - -These calls don't issue a database query, since the `Author` object is already loaded in memory. - -== Retrieving Rows == - -Retrieving objects from the database, also referred to as ''hydrating'' objects, is essentially the process of executing a SELECT query against the database and populating a new instance of the appropriate object with the contents of each returned row. - -In Propel, you use the generated Query objects to select existing rows from the database. - -=== Retrieving by Primary Key === - -The simplest way to retrieve a row from the database, is to use the generated `findPK()` method. It simply expects the value of the primary key of the row to be retrieved. - -{{{ -#!php -findPK(1); -// now $firstBook is an Author object, or NULL if no match was found. -}}} - -This issues a simple SELECT SQL query. For instance, for MySQL: - -{{{ -#!sql -SELECT author.id, author.first_name, author.last_name -FROM `author` -WHERE author.id = 1 -LIMIT 1; -}}} - -When the primary key consists of more than one column, `findPK()` accepts multiple parameters, one for each primary key column. - -'''Tip''': Every generated Query objects offers a factory method called `create()`. This methods creates a new instance of the query, and allows you to write queries in a single line: - -{{{ -#!php -findPK(1); -}}} - -You can also select multiple objects based on their primary keys, by calling the generated `findPKs()` method. It takes an array of primary keys as a parameter: - -{{{ -#!php -findPKs(array(1,2,3,4,5,6,7)); -// $selectedAuthors is a collection of Author objects -}}} - -=== Querying the Database === - -To retrieve rows other than by the primary key, use the Query's `find()` method. - -An empty Query object carries no condition, and returns all the rows of the table -{{{ -#!php -find(); -// $authors contains a collection of Author objects -// one object for every row of the author table -foreach($authors as $author) { - echo $author->getFirstName(); -} -}}} - -To add a simple condition on a given column, use one of the generated `filterByXXX()` methods of the Query object, where `XXX` is a column phpName. Since `filterByXXX()` methods return the current query object, you can continue to add conditions or end the query with the result of the method call. For instance, to filter by first name: - -{{{ -#!php -filterByFirstName('Jane') - ->find(); -}}} - -When you pass a value to a `filterByXXX()` method, Propel uses the column type to escape this value in PDO. This protects you from SQL injection risks. - -You can also easily limit and order the results on a query. Once again, the Query methods return the current Query object, so you can easily chain them: - -{{{ -#!php -orderByLastName() - ->limit(10) - ->find(); -}}} - -`find()` always returns a collection of objects, even if there is only one result. If you know that you need a single result, use `findOne()` instead of `find()`. It will add the limit and return a single object instead of an array: - -{{{ -#!php -filterByFirstName('Jane') - ->findOne(); -}}} - -'''Tip''': Propel provides magic methods for this simple use case. So you can write the above query as: - -{{{ -#!php -findOneByFirstName('Jane'); -}}} - -The Propel Query API is very powerful. The next chapter will teach you to use it to add conditions on related objects. If you can't wait, jump to the [wiki:Documentation/1.5/ModelCriteria Query API reference]. - -=== Using Custom SQL === - -The `Query` class provides a relatively simple approach to constructing a query. Its database neutrality and logical simplicity make it a good choice for expressing many common queries. However, for a very complex query, it may prove more effective (and less painful) to simply use a custom SQL query to hydrate your Propel objects. - -As Propel uses PDO to query the underlying database, you can always write custom queries using the PDO syntax. For instance, if you have to use a sub-select: - -{{{ -#!php -prepare($sql); -$stmt->execute(array(':name' => 'Tolstoy'); -}}} - -With only a little bit more work, you can also populate `Book` objects from the resulting statement. Create a new `PropelObjectCollection` for the `Book` model, and call the `format()` method using the statement: - -{{{ -#!php -setModelName('Book'); -$books = $coll->format($stmt); -// $books contains a collection of Book objects -}}} - -There are a few important things to remember when using custom SQL to populate Propel: - * The resultset columns must be numerically indexed - * The resultset must contain all columns in the object - * The resultset must have columns ''in the same order'' as they are defined in the `schema.xml` file - -== Updating Objects == - -Updating database rows basically involves retrieving objects, modifying the contents, and then saving them. In practice, for Propel, this is a combination of what you've already seen in the previous sections: - -{{{ -#!php -findOneByFirstName('Jane'); -$author->setLastName('Austen'); -$author->save(); -}}} - -Alternatively, you can update several rows based on a Query using the query object's `update()` method: - -{{{ -#!php -filterByFirstName('Jane') - ->update(array('LastName' => 'Austen')); -}}} - -This last method is better for updating several rows at once, or if you didn't retrieve the objects before. - -== Deleting Objects == - -Deleting objects works the same as updating them. You can either delete an existing object: - -{{{ -#!php -findOneByFirstName('Jane'); -$author->delete(); -}}} - -Or use the `delete()` method in the query: - -{{{ -#!php -filterByFirstName('Jane') - ->delete(); -}}} - -'''Tip''': A deleted object still lives in the PHP code. It is marked as deleted and cannot be saved anymore, but you can still read its properties: - -{{{ -#!php -isDeleted(); // true -echo $author->getFirstName(); // 'Jane' -}}} - -== Termination Methods == - -The Query methods that don't return the current query object are called "Termination Methods". You've alread seen come of them: `find()`, `findOne()`, `update()`, `delete()`. There are two more termination methods that you should know about: - -{{{ -#!php -count(); -// You could also count the number of results from a find(), but that would be less effective, -// since it implies hydrating objects just to count them - -// paginate() returns a paginated list of results -$authorPager = AuthorQuery::create()->paginate($page = 1, $maxPerPage = 10); -// This method will compute an offset and a limit -// based on the number of the page and the max number of results per page. -// The result is a PropelModelPager object, over which you can iterate: -foreach ($authorPager as $author) { - echo $author->getFirstName(); -} -// a pager object gives more information -echo $pager->getNbResults(); // total number of results if not paginated -echo $pager->haveToPaginate(); // return true if the total number of results exceeds the maximum per page -echo $pager->getFirstIndex(); // index of the first result in the page -echo $pager->getLastIndex(); // index of the last result in the page -$links = $pager->getLinks(5); // array of page numbers around the current page; useful to display pagination controls -}}} - -== Collections And On-Demand Hydration == - -The `find()` method of generated Model Query objects returns a `PropelCollection` object. You can use this object just like an array of model objects, iterate over it using `foreach`, access the objects by key, etc. - -{{{ -#!php -limit(5) - ->find(); -foreach ($authors as $author) { - echo $authors->getFirstName(); -} -}}} - -The advantage of using a collection instead of an array is that Propel can hydrate model objects on demand. Using this feature, you'll never fall short of memory when retrieving a large number of results. Available through the `setFormatter()` method of Model Queries, on-demand hydration is very easy to trigger: - -{{{ -#!php -limit(50000) - ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND) // just add this line - ->find(); -foreach ($authors as $author) { - echo $author->getFirstName(); -} -}}} - -In this example, Propel will hydrate the `Author` objects row by row, after the `foreach` call, and reuse the memory between each iteration. The consequence is that the above code won't use more memory when the query returns 50,000 results than when it returns 5. - -`ModelCriteria::FORMAT_ON_DEMAND` is one of the many formatters provided by the Query objects. You can also get a collection of associative arrays instead of objects, if you don't need any of the logic stored in your model object, by using `ModelCriteria::FORMAT_ARRAY`. - -The [wiki:Documentation/1.5/ModelCriteria Query API reference] describes each formatter, and how to use it. - -== Propel Instance Pool == - -Propel keeps a list of the objects that you already retrieved in memory to avoid calling the same request twice in a PHP script. This list is called the instance pool, and is automatically populated from your past requests: - -{{{ -#!php -findPk(1); -// Issues a SELECT query -... -// second call -$author2 = AuthorQuery::create()->findPk(1); -// Skips the SQL query and returns the existing $author1 object -}}} diff --git a/airtime_mvc/library/propel/docs/guide/04-Relationships.txt b/airtime_mvc/library/propel/docs/guide/04-Relationships.txt deleted file mode 100644 index 6e5de3c68..000000000 --- a/airtime_mvc/library/propel/docs/guide/04-Relationships.txt +++ /dev/null @@ -1,386 +0,0 @@ -= Basic Relationships = - -[[PageOutline]] - -The definition of foreign keys in your schema allows Propel to add smart methods to the generated model and query objects. In practice, these generated methods mean that you will never actually have to deal with primary and foreign keys yourself. It makes the task of dealing with relations extremely straightforward. - -== Inserting A Related Row == - -Propel creates setters for related objects that simplify the foreign key handling. You don't actually have to define a foreign key value. Instead, just set a related object, as follows: - -{{{ -#!php -setFirstName("Leo"); -$author->setLastName("Tolstoy"); -$author->save(); - -$book = new Book(); -$book->setTitle("War & Peace"); -// associate the $author object with the current $book -$book->setAuthor($author); -$book->save(); -}}} - -Propel generates the `setAuthor()` method based on the `phpName` attribute of the `` element in the schema. When the attribute is not set, Propel uses the `phpName` of the related table instead. - -Internally, the call to `Book::setAuthor($author)` translates into `Book::setAuthorId($author->getId())`. But you don't actually have to save a Propel object before associating it to another. In fact, Propel automatically "cascades" INSERT statements when a new object has other related objects added to it. - -For one-to-many relationships - meaning, from the other side of a many-to-one relationship - the process is a little different. In the previous example, one `Book` has one `Author`, but one `Author` has many `Books`. From the `Author` point of view, a one-to-many relationships relates it to `Book`. So Propel doesn't generate an `Author::setBook()`, but rather an `Author::addBook()`: - -{{{ -#!php -setTitle("War & Peace"); -// associate the $author object with the current $book -$book->save(); - -$author = new Author(); -$author->setFirstName("Leo"); -$author->setLastName("Tolstoy"); -$author->addBook($book); -$author->save(); -}}} - -The result is the same in the database - the `author_id` column of the `book` row is correctly set to the `id` of the `author` row. - -== Save Cascade == - -As a matter of fact, you don't need to `save()` an object before relating it. Propel knows which objects are related to each other, and is capable of saving all the unsaved objects if they are related to each other. - -The following example shows how to create new `Author` and `Publisher` objects, which are then added to a new `Book` object; all 3 objects are saved when the `Book::save()` method is eventually invoked. - -{{{ -#!php -setFirstName("Leo"); -$author->setLastName("Tolstoy"); -// no need to save the author yet - -$publisher = new Publisher(); -$publisher->setName("Viking Press"); -// no need to the publisher yet - -$book = new Book(); -$book->setTitle("War & Peace"); -$book->setIsbn("0140444173"); -$book->setPublisher($publisher); -$book->setAuthor($author); -$book->save(); // saves all 3 objects! -}}} - -In practice, Propel '''cascades''' the `save()` action to the related objects. - -== Reading Related Object Properties == - -Just like the related object setters, Propel generates a getter for every relation: - -{{{ -#!php -findPk(1); -$author = $book->getAuthor(); -echo $author->getFirstName(); // 'Leo' -}}} - -Since a relationship can also be seen from the other end, Propel allows the foreign table to retrieve the related objects as well: - -{{{ -#!php -findPk(1); -$books = $author->getBooks(); -foreach ($books as $book) { - echo $book->getTitle(); -} -}}} - -Notice that Propel generated a `getBooks()` method returning an array of `Book` objects, rather than a `getBook()` method. This is because the definition of a foreign key defines a many-to-one relationship, seen from the other end as a one-to-many relationship. - -'''Tip''': Propel also generates a `countBooks()` methods to get the number of related objects without hydrating all the `Book` objects. for performance reasons, you should prefer this method to `count($author->getBooks())`. - -Getters for one-to-many relationship accept an optional query object. This allows you to hydrate related objects, or retrieve only a subset of the related objects, or to reorder the list of results: - -{{{ -#!php -orderByTitle() - ->joinWith('Book.Publisher'); -$books = $author->getBooks($query); -}}} - -== Using Relationships In A Query == - -=== Finding Records Related To Another One === - -If you need to find objects related to a model object that you already have, you can take advantage of the generated `filterByXXX()` methods in the query objects, where `XXX` is a relation name: - -{{{ -#!php -findPk(1); -$books = BookQuery::create() - ->filterByAuthor($author) - ->orderByTitle() - ->find(); -}}} - -You don't need to specify that the `author_id` column of the `Book` object should match the `id` column of the `Author` object. Since you already defined the foreign key mapping in your schema, Propel knows enough to figure it out. - -=== Embedding Queries === - -In SQL queries, relationships often translate to a JOIN statement. Propel abstracts this relational logic in the query objects, by allowing you to ''embed'' a related query into another. - -In practice, Propel generates one `useXXXQuery()` method for every relation in the Query objects. So the `BookQuery` class offers a `useAuthorQuery()` and a `usePublisherQuery()` method. These methods return a new Query instance of the related query class, that you can eventually merge into the main query by calling `endUse()`. - -To illustrate this, let's see how to write the following SQL query with the Propel Query API: - -{{{ -#!sql -SELECT book.* -FROM book INNER JOIN author ON book.AUTHOR_ID = author.ID -WHERE book.ISBN = '0140444173' AND author.FIRST_NAME = 'Leo' -ORDER BY book.TITLE ASC -LIMIT 10; -}}} - -That would simply give: - -{{{ -#!php -filterByISBN('0140444173') - ->useAuthorQuery() // returns a new AuthorQuery instance - ->filterByFirstName('Leo') // this is an AuthorQuery method - ->endUse() // merges the Authorquery in the main Bookquery and returns the BookQuery - ->orderByTitle() - ->limit(10) - ->find(); -}}} - -Propel knows the columns to use in the `ON` clause from the definition of foreign keys in the schema. The ability to use methods of a related Query object allows you to keep your model logic where it belongs. - -Of course, you can embed several queries to issue a query of any complexity level: - -{{{ -#!php -useBookQuery() - ->usePublisherQuery() - ->filterByName('Viking Press') - ->endUse() - ->endUse() - ->find(); -}}} - -You can see how the indentation of the method calls provide a clear explanation of the embedding logic. That's why it is a good practice to format your Propel queries with a single method call per line, and to add indentation every time a `useXXXQuery()` method is used. - -== Many-to-Many Relationships == - -Databases typically use a cross-reference table, or junction table, to materialize the relationship. For instance, if the `user` and `group` tables are related by a many-to-many relationship, this happens through the rows of a `user_group` table. To inform Propel about the many-to-many relationship, set the `isCrossRef` attribute of the cross reference table to true: - -{{{ -#!xml - - - -
- - - - -
- - - - - - - - - - -
-}}} - -Once you rebuild your model, the relationship is seen as a one-to-many relationship from both the `User` and the `Group` models. That means that you can deal with adding and reading relationships the same way as you usually do: - -{{{ -#!php -setName('John Doe'); -$group = new Group(); -$group->setName('Anonymous'); -// relate $user and $group -$user->addGroup($group); -// save the $user object, the $group object, and a new instance of the UserGroup class -$user->save(); -}}} - -The same happens for reading related objects ; Both ends see the relationship as a one-to-many relationship: - -{{{ -#!php -getUsers(); -$nbUsers = $group->countUsers(); -$groups = $user->getGroups(); -$nbGroups = $user->countGroups(); -}}} - -Just like regular related object getters, these generated methods accept an optional query object, to further filter the results. - -To facilitate queries, Propel also adds new methods to the `UserQuery` and `GroupQuery` classes: - -{{{ -#!php -filterByGroup($group) - ->find(); -$groups = GroupQuery::create() - ->filterByUser($user) - ->find(); -}}} - -== One-to-One Relationships == - -Propel supports the special case of one-to-one relationships. These relationships are defined when the primary key is also a foreign key. For example : - -{{{ -#!xml - - - -
- - - - - - - - -
-}}} - -Because the primary key of the `bookstore_employee_account` is also a foreign key to the `bookstore_employee` table, Propel interprets this as a one-to-one relationship and will generate singular methods for both sides of the relationship (`BookstoreEmployee::getBookstoreEmployeeAccount()`, and `BookstoreEmployeeAccount::getBookstoreEmployee()`). - -== On-Update and On-Delete Triggers = - -Propel also supports the ''ON UPDATE'' and ''ON DELETE'' aspect of foreign keys. These properties can be specified in the `` tag using the `onUpdate` and `onDelete` attributes. Propel supports values of `CASCADE`, `SETNULL`, and `RESTRICT` for these attributes. For databases that have native foreign key support, these trigger events will be specified at the datbase level when the foreign keys are created. For databases that do not support foreign keys, this functionality will be emulated by Propel. - -{{{ -#!xml - - - - - - - -
-}}} - -In the example above, the `review` rows will be automatically removed if the related `book` row is deleted. - -== Minimizing Queries == - -Even if you use a foreign query, Propel will issue new queries when you fetch related objects: - -{{{ -#!php -useAuthorQuery() - ->filterByFirstName('Leo') - ->endUse() - ->findOne(); -$author = $book->getAuthor(); // Needs another database query -}}} - -Propel allows you to retrieve the main object together with related objects in a single query. You just the `with()` method to specify which objects the main object should be hydrated with. - -{{{ -#!php -useAuthorQuery() - ->filterByFirstName('Leo') - ->endUse() - ->with('Author') - ->findOne(); -$author = $book->getAuthor(); // Same result, with no supplementary query -}}} - -Since the call to `with()` adds the columns of the related object to the SELECT part of the query, and uses these columns to populate the related object, that means that a query using `with()` is slower and consumes more memory. So use it only when you actually need the related objects afterwards. - -If you don't want to add a filter on a related object but still need to hydrate it, calling `useXXXQuery()`, `endUse()`, and then `with()` can be a little cumbersome. For this case, Propel provides a proxy method called `joinWith()`. It expects a string made of the initial query name and the foreign query name. For instance: - -{{{ -#!php -joinWith('Book.Author') - ->findOne(); -$author = $book->getAuthor(); // Same result, with no supplementary query -}}} - -`with()` and `joinWith()` are not limited to immediate relationships. As a matter of fact, just like you can nest `use()` calls, you can call `with()` several times to populate a chain of objects: - -{{{ -#!php -joinWith('Review.Book') - ->joinWith('Book.Author') - ->joinWith('Book.Publisher') - ->findOne(); -$book = $review->getBook() // No additional query needed -$author = $book->getAuthor(); // No additional query needed -$publisher = $book->getPublisher(); // No additional query needed -}}} - -So `with()` is very useful to minimize the number of database queries. As soon as you see that the number of queries necessary to perform an action is proportional to the number of results, adding a `with()` call is the trick to get down to a more reasonnable query count. - -'''Tip''': `with()` also works for left joins on one-to-many relationships, but you musn't use a `limit()` in the query in this case. This is because Propel has no way to determine the actual number of rows of the main object in such a case. - -{{{ -#!php -leftJoinWith('Author.Book') - ->find(); -// this does not work -$authors = AuthorQuery::create() - ->leftJoinWith('Author.Book') - ->limit(5) - ->find(); -}}} - -However, it is quite easy to achieve hydration of related objects with only one additional query: - -{{{ - #!php -find(); -$authors->populateRelation('Book'); -// now you can iterate over each author's book without further queries -foreach ($authors as $author) { - foreach ($authors->getBooks() as $book) { // no database query, the author already has a Books collection - // do stuff with $book and $author - } -} -}}} \ No newline at end of file diff --git a/airtime_mvc/library/propel/docs/guide/05-Validators.txt b/airtime_mvc/library/propel/docs/guide/05-Validators.txt deleted file mode 100644 index 352ea6e1d..000000000 --- a/airtime_mvc/library/propel/docs/guide/05-Validators.txt +++ /dev/null @@ -1,253 +0,0 @@ -= Validators = - -[[PageOutline]] - -Validators help you to validate an input before perstisting it to the database. In Propel, validators are rules describing what type of data a column accepts. Validators are referenced in the `schema.xml` file, using `` tags. - -Validators are applied at the PHP level, they are not created as constraints on the database itself. That means that if you also use another language to work with the database, the validator rules will not be enforced. -You can also apply multiple rule entries per validator entry in the schema.xml file. - -== Overview == - -In the following example, the `username` column is defined to have a minimum length of 4 characters: - -{{{ -#!xml - - - - - - -
-}}} - -Every column rule is represented by a `` tag. A `` is a set of `` tags bound to a column. - -At runtime, you can validate an instance of the model by calling the `validate()` method: - -{{{ -#!php -setUsername("foo"); // only 3 in length, which is too short... -if ($objUser->validate()) { - // no validation errors, so the data can be persisted - $user->save(); -} else { - // Something went wrong. - // Use the validationFailures to check what - $failures = $objUser->getValidationFailures(); - foreach($failures as $failure) { - echo $objValidationFailure->getMessage() . "
\n"; - } -} -}}} - -`validate()` returns a boolean. If the validation failed, you can access the array `ValidationFailed` objects by way of the `getValidationFailures()` method. Each `ValidationFailed` instance gives access to the column, the messagen and the validator that caused the failure. - -== Core Validators == - -Propel bundles a set of validatorts that should help you deal with the most common cases. - -=== !MatchValidator === - -The `MatchValidator` is used to run a regular expression of choice against the column. Note that this is a `preg`, not `ereg` (check [http://www.php.net/preg_match the preg_match documentation] for more information about regexps). - -{{{ -#!xml - - - - -}}} - -=== !NotMatchValidator === - -Opposite of `MatchValidator, this validator returns false if the regex returns true - -{{{ -#!xml - - - - - -}}} - -=== !MaxLengthValidator === - -When you want to limit the size of the string to be inserted in a column, use the `MaxLengthValidator`. Internally, it uses `strlen()` to get the length of the string. For instance, some database completely ignore the lentgh of `LONGVARCHAR` columns; you can enforce it using a validator: - -{{{ -#!xml - - - - -}}} - -'''Tip''': If you have specified the `size` attribute in the `` tag, you don't have to specify the `value` attribute in the validator rule again, as this is done automatically. - -=== !MinLengthValidator === - -{{{ -#!xml - - - - -}}} - -=== !MaxValueValidator === - -To limit the value of an integer column, use the `MaxValueValidator`. Note that this validator uses a non-strict comparison ('less than or equal'): - -{{{ -#!xml - - - - -}}} - -=== !MinValueValidator === - -{{{ -#!xml - - - - -}}} - -'''Tip''': You can run multiple validators against a single column. - -{{{ -#!xml - - - - - -}}} - -=== !RequiredValidator === - -This validtor checks the same rule as a `required=true` on the column at the database level. However it will not give you a clean error to work with. - -{{{ -#!xml - - - - -}}} - -=== !UniqueValidator === - -To check whether the value already exists in the table, use the `UniqueValidator`: - -{{{ -#!xml - - - - -}}} - -=== !ValidValuesValidator === - -This rule restricts the valid values to a list delimited by a pipe ('|'). - -{{{ -#!xml - - - - -}}} - -=== !TypeValidator === - -Restrict values to a certain PHP type using the `TypeValidator`: - -{{{ -#!xml - - - - -}}} - -== Adding A Custom Validator == - -You can easily add a custom validator. A validator is a class extending `BasicValidator` providing a public `isValid()` method. For instance: - -{{{ -#!php -` tag. So `$map->getValue()` returns the `value` attribute. - -'''Tip''': Make sure that `isValid()` returns a boolean, so really true or false. Propel is very strict about this. Returning a mixed value just won't do. - -To enable the new validator on a column, add a corresponding `` in your schema and use 'class' as the rule `name`. - -{{{ -#!xml - - - -}}} - -The `class` attribute of the `` tag should contain a path to the validator class accessible from the include_path, where the directory separator is replaced by a dot. \ No newline at end of file diff --git a/airtime_mvc/library/propel/docs/guide/06-Transactions.txt b/airtime_mvc/library/propel/docs/guide/06-Transactions.txt deleted file mode 100644 index 55a9240cc..000000000 --- a/airtime_mvc/library/propel/docs/guide/06-Transactions.txt +++ /dev/null @@ -1,291 +0,0 @@ -= Transactions = - -[[PageOutline]] - -Database transactions are the key to assure the data integrity and the performance of database queries. Propel uses transactions internally, and provides a simple API to use them in your own code. - -'''Tip''': If the [http://en.wikipedia.org/wiki/ACID ACID] acronym doesn't ring a bell, you should probably learn some [http://en.wikipedia.org/wiki/Database_transaction fundamentals about database transactions] before reading further. - -== Wrapping Queries Inside a Transaction == - -Propel uses PDO as database abstraction layer, and therefore uses [http://www.php.net/manual/en/pdo.transactions.php PDO's built-in support for database transactions]. The syntax is the same, as you can see in the classical "money transfer" example: - -{{{ -#!php -beginTransaction(); - - try { - // remove the amount from $fromAccount - $fromAccount->setValue($fromAccount->getValue() - $amount); - $fromAccount->save($con); - // add the amount to $toAccount - $toAccount->setValue($toAccount->getValue() + $amount); - $toAccount->save($con); - - $con->commit(); - } catch (Exception $e) { - $con->rollback(); - throw $e; - } -} -}}} - -The transaction statements are `beginTransaction()`, `commit()` and `rollback()`, which are methods of the PDO connection object. Transaction methods are typically used inside a `try/catch` block. The exception is rethrown after rolling back the transaction: That ensures that the user knows that something wrong happenned. - -In this example, if something wrong happens while saving either one of the two accounts, an `Exception` is thrown, and the whole operation is rolled back. That means that the transfer is cancelled, with an insurance that the money hasn't vanished (that's the A in ACID, which stands for "Atomicity"). If both account modifications work as expected, the whole transaction is committed, meaning that the data changes enclosed in the transaction are persisted in the database. - -Tip: In order to build a transaction, you need a connection object. The connection object for a Propel model is always available through `Propel::getConnection([ModelName]Peer::DATABASE_NAME)`. - -== Denormalization And Transactions == - -Another example of the use of transactions is for [http://en.wikipedia.org/wiki/Denormalization denormalized schemas]. - -For instance, suppose that you have an `Author` model with a one to many relationship to a `Book` model. every time you need to display the number of books written by an author, you call `countBooks()` on the author object, which issues a new query to the database: - -{{{ -#!php -
    - -
  • getName() ?> (countBooks() ?> books)
  • - -
-}}} - -If you have a large number of authors and books, this simple code snippet can be a real performance blow to your application. The usual way to optimize it is to ''denormalize'' your schema by storing the number of books by each author in a new `nb_books` column, in the `author` table. - -{{{ -#!xml - - - - -
-}}} - -You must update this new column every time you save or delete a `Book` object; this will make write queries a little slower, but read queries much faster. Fortunately, Propel model objects support pre- and post- hooks for the `save()` and `delete()` methods, so this is quite easy to implement: - -{{{ -#!php -updateNbBooks($con); - } - - public function postDelete(PropelPDO $con) - { - $this->updateNbBooks($con); - } - - public function updateNbBooks(PropelPDO $con) - { - $author = $this->getAuthor(); - $nbBooks = $author->countBooks($con); - $author->setNbBooks($nbBooks); - $author->save($con); - } -} -}}} - -The `BaseBook::save()` method wraps the actual database INSERT/UPDATE query inside a transaction, together with any other query registered in a pre- or post- save hook. That means that when you save a book, the `postSave()` code is executed in the same transaction as the actual `$book->save()` method. Everything happens as is the code was the following: - -{{{ -#!php -beginTransaction(); - - try { - // insert/update query for the current object - $this->doSave($con); - - // postSave hook - $author = $this->getAuthor(); - $nbBooks = $author->countBooks($con); - $author->setNbBooks($nbBooks); - $author->save($con); - - $con->commit(); - } catch (Exception $e) { - $con->rollback(); - throw $e; - } - } -} -}}} - -In this example, the `nb_books` column of the `author` table will always we synchronized with the number of books. If anything happens during the transaction, the saving of the book is rolled back, as well as the `nb_books` column update. The transaction serves to preserve data consistency in a denormalized schema ("Consistency" stands for the C in ACID). - -'''Tip''': Check the [wiki:Documentation/1.5/Behaviors behaviors documentation] for details about the pre- and post- hooks in Propel model objects. - -== Nested Transactions == - -Some RDBMS offer the ability to nest transactions, to allow partial rollback of a set of transactions. PDO does not provide this ability at the PHP level; nevertheless, Propel emulates nested transactions for all supported database engines: - -{{{ -#!php -beginTransaction(); - try { - $c = new Criteria(); - $c->add(BookPeer::PRICE, null, Criteria::ISNULL); - BookPeer::doDelete($c, $con); - $con->commit(); - } catch (Exception $e) { - $con->rollback(); - throw $e; - } -} - -function deleteAuthorsWithNoEmail(PropelPDO $con) -{ - $con->beginTransaction(); - try { - $c = new Criteria(); - $c->add(AuthorPeer::EMAIL, null, Criteria::ISNULL); - AuthorPeer::doDelete($c, $con); - $con->commit(); - } catch (Exception $e) { - $con->rollback(); - throw $e; - } -} - -function cleanup(PropelPDO $con) -{ - $con->beginTransaction(); - try { - deleteBooksWithNoPrice($con); - deleteAuthorsWithNoEmail($con); - $con->commit(); - } catch (Exception $e) { - $con->rollback(); - throw $e; - } -} -}}} - -All three functions alter data in a transaction, ensuring data integrity for each. In addition, the `cleanup()` function actually executes two nested transactions inside one main transaction. - -Propel deals with this case by seeing only the outermost transaction, and ignoring the `beginTransaction()`, `commit()` and `rollback()` statements of nested transactions. If nothing wrong happens, then the last `commit()` call (after both `deleteBooksWithNoPrice()` and `deleteAuthorsWithNoEmail()` end) triggers the actual database commit. However, if an exception is thrown in either one of these nested transactions, it is escalated to the main `catch` statement in `cleanup()` so that the entire transaction (starting at the main `beginTransaction()`) is rolled back. - -So you can use transactions everywhere it's necessary in your code, without worrying about nesting them. Propel will always commit or rollback everything altogether, whether the RDBMS supports nested transactions or not. - -'''Tip''': This allows you to wrap all your application code inside one big transaction for a better integrity. - -== Using Transactions To Boost Performance == - -A database transaction has a cost in terms of performance. In fact, for simple data manipulation, the cost of the transaction is more important than the cost of the query itself. Take the following example: - -{{{ -#!php -setTitle($i . ': A Space Odyssey'); - $book->save($con); -} -}}} - -As explained earlier, Propel wraps every save operation inside a transaction. In terms of execution time, this is very expensive. Here is how the above code would translate to MySQL in an InnodDB table: - -{{{ -#!sql -BEGIN; -INSERT INTO book (`ID`,`TITLE`) VALUES (NULL,'0: A Space Odyssey'); -COMMIT; -BEGIN; -INSERT INTO book (`ID`,`TITLE`) VALUES (NULL,'1: A Space Odyssey'); -COMMIT; -BEGIN; -INSERT INTO book (`ID`,`TITLE`) VALUES (NULL,'2: A Space Odyssey'); -COMMIT; -... -}}} - -You can take advantage of Propel's nested transaction capabilities to encapsulate the whole loop inside one single transaction. This will reduce the execution time drastically: - -{{{ -#!php -beginTransaction(); -for ($i=0; $i<2002; $i++) -{ - $book = new Book(); - $book->setTitle($i . ': A Space Odyssey'); - $book->save($con); -} -$con->commit(); -}}} - -The transactions inside each `save()` will become nested, and therefore not translated into actual database transactions. Only the outmost transaction will become a database transaction. So this will translate to MySQL as: - -{{{ -#!sql -BEGIN; -INSERT INTO book (`ID`,`TITLE`) VALUES (NULL,'0: A Space Odyssey'); -INSERT INTO book (`ID`,`TITLE`) VALUES (NULL,'1: A Space Odyssey'); -INSERT INTO book (`ID`,`TITLE`) VALUES (NULL,'2: A Space Odyssey'); -... -COMMIT; -}}} - -In practice, encapsulating a large amount of simple queries inside a single transaction significantly improves performance. - -Tip: Until the final `commit()` is called, most database engines lock updated rows, or even tables, to prevent any query outside the transaction from seeing the partially committed data (this is how transactions preserve Isolation, which is the I in ACID). That means that large transactions will queue every other queries for potentially a long time. Consequently, use large transactions only when concurrency is not a requirement. - -== Why Is The Connection Always Passed As Parameter? == - -All the code examples in this chapter show the connection object passed a a parameter to Propel methods that trigger a database query: - -{{{ -#!php -setValue($fromAccount->getValue() - $amount); -$fromAccount->save($con); -}}} - -The same code works without explicitely passing the connection object, because Propel knows how to get the right connection from a Model: - -{{{ -#!php -setValue($fromAccount->getValue() - $amount); -$fromAccount->save(); -}}} - -However, it's a good practice to pass the connection explicitely, and for three reasons: - - * Propel doesn't need to look for a connection object, and this results in a tiny boost in performance. - * You can use a specific connection, which is required in distributed (master/slave) environments, in order to distinguish read and write operations. - * Most importantly, transactions are tied to a single connection. You can't enclose two queries using different connections in a single transaction. So it's very useful to identify the connection you want to use for every query, as Propel will throw an exception if you use the wrong connection. - -== Limitations == - - * Currently there is no support for row locking (e.g. `SELECT blah FOR UPDATE`). - * You must rethrow the exception caught in the `catch` statement of nested transactions, otherwise there is a risk that the global rollback doesn't occur. - * True nested transactions, with partial rollback, are only possible in MSSQL, and can be emulated in other RDBMS through savepoints. This feature may be added to Propel in the future, but for the moment, only the outermost PHP transaction triggers a database transaction. - * If you rollback a partially executed transaction and ignore the exception thrown, there are good chances that some of your objects are out of sync with the database. The good practice is to always let a transaction exception escalate until it stops the script execution. - diff --git a/airtime_mvc/library/propel/docs/guide/07-Behaviors.txt b/airtime_mvc/library/propel/docs/guide/07-Behaviors.txt deleted file mode 100644 index fe0025ec1..000000000 --- a/airtime_mvc/library/propel/docs/guide/07-Behaviors.txt +++ /dev/null @@ -1,280 +0,0 @@ -= Behaviors = - -[[PageOutline]] - -Behaviors are a great way to package model extensions for reusability. They are the powerful, versatile, fast, and help you organize your code in a better way. - -== Pre and Post Hooks For `save()` And `delete()` Methods == - -The `save()` and `delete()` methods of your generated objects are easy to override. In fact, Propel looks for one of the following methods in your objects and executes them when needed: - -{{{ -#!php - - ... - - -}}} - -Then, you can force the update of the `created_at` column before every insertion as follows: - -{{{ -#!php -setCreatedAt(time()); - return true; - } -} -}}} - -Whenever you call `save()` on a new object, Propel now executes the `preInsert()` method on this objects and therefore update the `created_at` column: - -{{{ -#!php -setTitle('War And Peace'); -$b->save(); -echo $b->getCreatedAt(); // 2009-10-02 18:14:23 -}}} - -If you implement `preInsert()`, `preUpdate()`, `preSave()` or `preDelete()`, these methods must return a boolean value. This determines whether the action (save or delete) may proceed. - -'''Tip''': Since this feature adds a small overhead to write operations, you can deactivate it completely in your build properties by setting `propel.addHooks` to `false`. - -{{{ -#!ini -# ------------------- -# TEMPLATE VARIABLES -# ------------------- -propel.addHooks = false -}}} - -== Introducing Behaviors == - -When several of your custom model classes end up with similar methods added, it is time to refactor the common code. - -For example, you may want to add the same ability you gave to `Book` to all the other objects in your model. Let's call this the "Timestampable behavior", because then all of your rows have a timestamp marking their creation. In order to achieve this behavior, you have to repeat the same operations on every table. First, add a `created_at` column to the other tables: - -{{{ -#!xml - - ... - -
- - ... - -
-}}} - -Then, add a `preInsert()` hook to the object stub classes: - -{{{ -#!php -setCreatedAt(time()); - } -} - -class Author extends BaseAuthor -{ - public function preInsert() - { - $this->setCreatedAt(time()); - } -} -}}} - -Even if the code of this example is very simple, the repetition of code is already too much. Just imagine a more complex behavior, and you will understand that using the copy-and-paste technique soon leads to a maintenance nightmare. - -Propel offers three ways to achieve the refactoring of the common behavior. The first one is to use a custom builder during the build process. This can work if all of your models share one single behavior. The second way is to use table inheritance. The inherited methods then offer limited capabilities. And the third way is to use Propel behaviors. This is the right way to refactor common model logic. - -Behaviors are special objects that use events called during the build process to enhance the generated model classes. Behaviors can add attributes and methods to both the Peer and model classes, they can modify the course of some of the generated methods, and they can even modify the structure of a database by adding columns or tables. - -For instance, Propel bundles a behavior called `timestampable`, which does exatcly the same thing as described above. But instead of adding columns and methods by hand, all you have to do is to declare it in a `` tag in your `schema.xml`, as follows: - -{{{ -#!xml - - ... - -
- - ... - -
-}}} - -Then rebuild your model, and there you go: two columns, `created_at` and `updated_at`, were automatically added to both the `book` and `author` tables. Besides, the generated `BaseBook` and `BaseAuthor` classes already contain the code necessary to auto-set the current time on creation and on insertion. - -== Bundled Behaviors == - -Propel currently bundles several behaviors. Check the behavior documentation for details on usage: - - * [wiki:Documentation/1.5/Behaviors/aggregate_column aggregate_column] - * [wiki:Documentation/1.5/Behaviors/alternative_coding_standards alternative_coding_standards] - * [wiki:Documentation/1.5/Behaviors/auto_add_pk auto_add_pk] - * [wiki:Documentation/1.5/Behaviors/timestampable timestampable] - * [wiki:Documentation/1.5/Behaviors/sluggable sluggable] - * [wiki:Documentation/1.5/Behaviors/soft_delete soft_delete] - * [wiki:Documentation/1.5/Behaviors/sortable sortable] - * [wiki:Documentation/1.5/Behaviors/nested_set nested_set] - * [wiki:Documentation/1.5/Behaviors/query_cache query_cache] - * And [wiki:Documentation/1.5/Inheritance#ConcreteTableInheritance concrete_inheritance], documented in the Inheritance Chapter even if it's a behavior - -Behaviors bundled with Propel require no further installation and work out of the box. - -== Customizing Behaviors == - -Behaviors often offer some parameters to tweak their effect. For instance, the `timestampable` behavior allows you to customize the names of the columns added to store the creation date and the update date. The behavior customization occurs in the `schema.xml`, inside `` tags nested in the `` tag. So let's set the behavior to use `created_on` instead of `created_at` for the creation date column name (and same for the update date column): - -{{{ -#!xml - - ... - - - - -
-}}} - -If the columns already exist in your schema, a behavior is smart enough not to add them one more time. - -{{{ -#!xml - - ... - - - - - - -
-}}} - -== Using Third-Party Behaviors == - -As a Propel behavior can be packaged into a single class, behaviors are quite easy to reuse and distribute across several projects. All you need to do is to copy the behavior file into your project, and declare it in `build.properties`, as follows: - -{{{ -#!ini -# ---------------------------------- -# B E H A V I O R S E T T I N G S -# ---------------------------------- - -propel.behavior.timestampable.class = propel.engine.behavior.timestampable.TimestampableBehavior -# Add your custom behavior pathes here -propel.behavior.formidable.class = path.to.FormidableBehavior -}}} - -Propel will then find the `FormidableBehavior` class whenever you use the `formidable` behavior in your schema: - -{{{ -#!xml - - ... - - -
-}}} - -'''Tip''': If you use autoloading during the build process, and if the behavior classes benefit from the autoloading, then you don't even need to declare the path to the behavior class. - -== Applying a Behavior To All Tables == - -You can add a `` tag directly under the `` tag. That way, the behavior will be applied to all the tables of the database. - -{{{ -#!xml - - - - ... -
- - ... -
-
-}}} - -In this example, both the `book` and `author` table benefit from the `timestampable` behavior, and therefore automatically update their `created_at` and `updated_at` columns upon saving. - -Going one step further, you can even apply a behavior to all the databases of your project, provided the behavior doesn't need parameters - or can use default parameters. To add a behavior to all databases, simply declare it in the project's `build.properties` under the `propel.behavior.default` key, as follows: - -{{{ -#!ini -propel.behavior.default = soft_delete, timestampable -}}} - -== Writing a Behavior == - -Behaviors can modify their table, and even add another table, by implementing the `modifyTable` method. In this method, use `$this->getTable()` to retrieve the table buildtime model and manipulate it. - -Behaviors can add code to the generated model object by implementing one of the following methods: - -{{{ -objectAttributes() // add attributes to the object -objectMethods() // add methods to the object -preInsert() // add code to be executed before insertion of a new object -postInsert() // add code to be executed after insertion of a new object -preUpdate() // add code to be executed before update of an existing object -postUpdate() // add code to be executed after update of an existing object -preSave() // add code to be executed before saving an object (new or existing) -postSave() // add code to be executed after saving an object (new or existing) -preDelete() // add code to be executed before deleting an object -postDelete() // add code to be executed after deleting an object -objectCall() // add code to be executed inside the object's __call() -objectFilter(&$script) // do whatever you want with the generated code, passed as reference -}}} - -Behaviors can also add code to the generated query objects by implementing one of the following methods: - -{{{ -queryAttributes() // add attributes to the query class -queryMethods() // add methods to the query class -preSelectQuery() // add code to be executed before selection of a existing objects -preUpdateQuery() // add code to be executed before update of a existing objects -postUpdateQuery() // add code to be executed after update of a existing objects -preDeleteQuery() // add code to be executed before deletion of a existing objects -postDeleteQuery() // add code to be executed after deletion of a existing objects -queryFilter(&$script) // do whatever you want with the generated code, passed as reference -}}} - -Behaviors can also add code to the generated peer objects by implementing one of the following methods: - -{{{ -staticAttributes() // add static attributes to the peer class -staticMethods() // add static methods to the peer class -preSelect() // adds code before every select query -peerFilter(&$script) // do whatever you want with the generated code, passed as reference -}}} - -Check the behaviors bundled with Propel to see how to implement your own behavior. diff --git a/airtime_mvc/library/propel/docs/guide/08-Logging.txt b/airtime_mvc/library/propel/docs/guide/08-Logging.txt deleted file mode 100644 index 80445f17d..000000000 --- a/airtime_mvc/library/propel/docs/guide/08-Logging.txt +++ /dev/null @@ -1,448 +0,0 @@ -= Logging And Debugging = - -[[PageOutline]] - -Propel provides tools to monitor and debug your model. Whether you need to check the SQL code of slow queries, or to look for error messages previously thrown, Propel is your best friend for finding and fixing problems. - -== Propel Logs == - -Propel uses the logging facility configured in `runtime-conf.xml` to record errors, warnings, and debug information. - -By default Propel will attempt to use the Log framework that is distributed with PEAR. If you are not familiar with it, check its [http://www.indelible.org/php/Log/guide.html online documentation]. It is also easy to configure Propel to use your own logging framework -- or none at all. - -=== Logger Configuration === - -The Propel log handler is configured in the `` section of your project's `runtime-conf.xml` file. Here is the accepted format for this section with the default values that Propel uses: - -{{{ -#!xml - - - - file - ./propel.log - propel - 7 - - - - ... - - -}}} - -Using these parameters, Propel creates a ''file'' Log handler in the background, and keeps it for later use: - -{{{ -#!php -` nested elements may vary, depending on which log handler you are using. Refer to the [http://www.indelible.org/php/Log/guide.html#standard-log-handlers PEAR::Log] documentation for more details on log handlers configuration and options. - -Note that the `` tag needs to correspond to the integer represented by one of the `PEAR_LOG_*` constants: - -||'''Constant'''||'''Value'''||'''Description''' -||PEAR_LOG_EMERG||0||System is unusable|| -||PEAR_LOG_ALERT||1||Immediate action required|| -||PEAR_LOG_CRIT||2||Critical conditions|| -||PEAR_LOG_ERR||3||Error conditions|| -||PEAR_LOG_WARNING||4||Warning conditions|| -||PEAR_LOG_NOTICE||5||Normal but significant|| -||PEAR_LOG_INFO||6||Informational|| -||PEAR_LOG_DEBUG||7||Debug-level messages|| - -=== Logging Messages === - -Use the static `Propel::log()` method to log a message using the configured log handler: - -{{{ -#!php -setName('foo'); -Propel::log('uh-oh, something went wrong with ' . $myObj->getName(), Propel::LOG_ERROR); -}}} - -You can log your own messages from the generated model objects by using their `log()` method, inherited from `BaseObject`: - -{{{ -#!php -log('uh-oh, something went wrong', Propel::LOG_ERROR); -}}} - -The log messages will show up in the log handler defined in `runtime-conf.xml` (`propel.log` file by default) as follows: - -{{{ -Oct 04 00:00:18 [error] uh-oh, something went wrong with foo -Oct 04 00:00:18 [error] MyObj: uh-oh, something went wrong -}}} - -Tip: All serious errors coming from the Propel core do not only issue a log message, they are also thrown as `PropelException`. - -=== Using An Alternative PEAR Log Handler === - -In many cases you may wish to integrate Propel's logging facility with the rest of your web application. In `runtime-conf.xml`, you can customize a different PEAR logger. Here are a few examples: - -'''Example 1:''' Using 'display' container (for output to HTML) -{{{ -#!xml - - display - 6 - -}}} - -'''Example 2:''' Using 'syslog' container -{{{ -#!xml - - syslog - 8 - propel - 6 - -}}} - -=== Using A Custom Logger === - -If you omit the `` section of your `runtime-conf.xml`, then Propel will not setup ''any'' logging for you. In this case, you can set a custom logging facility and pass it to Propel at runtime. - -Here's an example of how you could configure your own logger and then set Propel to use it: - -{{{ -#!php -log($m, Propel::LOG_EMERG); - } - public function alert($m) - { - $this->log($m, Propel::LOG_ALERT); - } - public function crit($m) - { - $this->log($m, Propel::LOG_CRIT); - } - public function err($m) - { - $this->log($m, Propel::LOG_ERR); - } - public function warning($m) - { - $this->log($m, Propel::LOG_WARNING); - } - public function notice($m) - { - $this->log($m, Propel::LOG_NOTICE); - } - public function info($m) - { - $this->log($m, Propel::LOG_INFO); - } - public function debug($m) - { - $this->log($m, Propel::LOG_DEBUG); - } - - public function log($message, $priority) - { - $color = $this->priorityToColor($priority); - echo '

$message

'; - } - - private function priorityToColor($priority) - { - switch($priority) { - case Propel::LOG_EMERG: - case Propel::LOG_ALERT: - case Propel::LOG_CRIT: - case Propel::LOG_ERR: - return 'red'; - break; - case Propel::LOG_WARNING: - return 'orange'; - break; - case Propel::LOG_NOTICE: - return 'green'; - break; - case Propel::LOG_INFO: - return 'blue'; - break; - case Propel::LOG_DEBUG: - return 'grey'; - break; - } - } -} -}}} - -Tip: There is also a bundled `MojaviLogAdapter` class which allows you to use a Mojavi logger with Propel. - -== Debugging Database Activity == - -By default, Propel uses `PropelPDO` for database connections. This class, which extends PHP's `PDO`, offers a debug mode to keep track of all the database activity, including all the executed queries. - -=== Enabling The Debug Mode === - -The debug mode is disabled by default, but you can enable it at runtime as follows: - -{{{ -#!php -useDebug(true); -}}} - -You can also disable the debug mode at runtime, by calling `PropelPDO::useDebug(false)`. Using this method, you can choose to enable the debug mode for only one particular query, or for all queries. - -Alternatively, you can ask Propel to always enable the debug mode for a particular connection by using the `DebugPDO` class instead of the default `PropelPDO` class. This is accomplished in the `runtime-conf.xml` file, in the `` tag of a given datasource connection (see the [wiki:Documentation/1.5/RuntimeConfiguration runtime configuration reference] for more details). - -{{{ -#!xml - - - - - - sqlite - - - DebugPDO -}}} - -'''Tip''': You can use your own connection class there, but make sure that it extends `PropelPDO` and not only `PDO`. Propel requires certain fixes to PDO API that are provided by `PropelPDO`. - -=== Counting Queries === - -In debug mode, `PropelPDO` keeps track of the number of queries that are executed. Use `PropelPDO::getQueryCount()` to retrieve this number: - -{{{ -#!php -getQueryCount(); // 1 -}}} - -Tip: You cannot use persistent connections if you want the query count to work. Actually, the debug mode in general requires that you don't use persistent connections in order for it to correctly log bound values and count executed statements. - -=== Retrieving The Latest Executed Query === - -For debugging purposes, you may need the SQL code of the latest executed query. It is available at runtime in debug mode using `PropelPDO::getLastExecutedQuery()`, as follows: - -{{{ -#!php -getLastExecutedQuery(); // 'SELECT * FROM my_obj'; -}}} - -Tip: You can also get a decent SQL representation of the criteria being used in a SELECT query by using the `Criteria->toString()` method. - -Propel also keeps track of the queries executed directly on the connection object, and displays the bound values correctly. - -{{{ -#!php -prepare('SELECT * FROM my_obj WHERE name = :p1'); -$stmt->bindValue(':p1', 'foo'); -$stmt->execute(); -echo $con->getLastExecutedQuery(); // 'SELECT * FROM my_obj where name = "foo"'; -}}} - -'''Tip''': The debug mode is intended for development use only. Do not use it in production environment, it logs too much information for a production server, and adds a small overhead to the database queries. - -== Full Query Logging == - -The combination of the debug mode and a logging facility provides a powerful debugging tool named ''full query logging''. If you have properly configured a log handler, enabling the debug mode (or using `DebugPDO`) automatically logs the executed queries into Propel's default log file: - -{{{ -Oct 04 00:00:18 propel-bookstore [debug] INSERT INTO publisher (`ID`,`NAME`) VALUES (NULL,'William Morrow') -Oct 04 00:00:18 propel-bookstore [debug] INSERT INTO author (`ID`,`FIRST_NAME`,`LAST_NAME`) VALUES (NULL,'J.K.','Rowling') -Oct 04 00:00:18 propel-bookstore [debug] INSERT INTO book (`ID`,`TITLE`,`ISBN`,`PRICE`,`PUBLISHER_ID`,`AUTHOR_ID`) VALUES (NULL,'Harry Potter and the Order of the Phoenix','043935806X',10.99,53,58) -Oct 04 00:00:18 propel-bookstore [debug] INSERT INTO review (`ID`,`REVIEWED_BY`,`REVIEW_DATE`,`RECOMMENDED`,`BOOK_ID`) VALUES (NULL,'Washington Post','2009-10-04',1,52) -... -Oct 04 00:00:18 propel-bookstore [debug] SELECT bookstore_employee_account.EMPLOYEE_ID, bookstore_employee_account.LOGIN FROM `bookstore_employee_account` WHERE bookstore_employee_account.EMPLOYEE_ID=25 -}}} - -By default, Propel logs all SQL queries, together with the date of the query and the name of the connection. - -=== Setting The Data To Log === - -The full query logging feature can be configured either in the `runtime-conf.xml` configuration file, or using the runtime configuration API. - -In `runtime-conf.xml`, tweak the feature by adding a `` tag under ``: - -{{{ -#!xml - - - - ... - - - - ... - - - -
- - true - - - - true - -
-
-
-
-
-}}} - -To accomplish the same configuration as above at runtime, change the settings in your main include file, after `Propel::init()`, as follows: - -{{{ -#!php -setParameter('debugpdo.logging.details.method.enabled', true); -$config->setParameter('debugpdo.logging.details.time.enabled', true); -$config->setParameter('debugpdo.logging.details.mem.enabled', true); -}}} - -Let's see a few of the provided parameters. - -=== Logging More Connection Messages === - -`PropelPDO` can log queries, but also connection events (open and close), and transaction events (begin, commit and rollback). Since Propel can emulate nested transactions, you may need to know when an actual `COMMIT` or `ROLLBACK` is issued. - -To extend which methods of `PropelPDO` do log messages in debug mode, customize the `'debugpdo.logging.methods'` parameter, as follows: - -{{{ -#!php -setParameter('debugpdo.logging.methods', $allMethods); -}}} - -By default, only the messages coming from `PropelPDO::exec`, `PropelPDO::query`, and `DebugPDOStatement::execute` are logged. - -=== Logging Execution Time And Memory === - -In debug mode, Propel counts the time and memory necessary for each database query. This very valuable data can be added to the log messages on demand, by adding the following configuration: - -{{{ -#!php -setParameter('debugpdo.logging.details.time.enabled', true); -$config->setParameter('debugpdo.logging.details.mem.enabled', true); -}}} - -Enabling the options shown above, you get log output along the lines of: - -{{{ -Feb 23 16:41:04 Propel [debug] time: 0.000 sec | mem: 1.4 MB | SET NAMES 'utf8' -Feb 23 16:41:04 Propel [debug] time: 0.002 sec | mem: 1.6 MB | SELECT COUNT(tags.NAME) FROM tags WHERE tags.IMAGEID = 12 -Feb 23 16:41:04 Propel [debug] time: 0.012 sec | mem: 2.4 MB | SELECT tags.NAME, image.FILENAME FROM tags LEFT JOIN image ON tags.IMAGEID = image.ID WHERE image.ID = 12 -}}} - -The order in which the logging details are enabled is significant, since it determines the order in which they will appear in the log file. - -=== Complete List Of Logging Options === - -The following settings can be customized at runtime or in the configuration file: - -||'''Parameter'''||'''Default'''||'''Meaning'''|| -||`debugpdo.logging.enabled`||`true`||Should any logging take place|| -||`debugpdo.logging.innerglue`||`": "`||String to use for combining the title of a detail and its value|| -||`debugpdo.logging.outerglue`||`" | "`||String to use for combining details together on a log line|| -||`debugpdo.logging.realmemoryusage`||`false`||Parameter to [http://www.php.net/manual/en/function.memory-get-usage.php memory_get_usage()] and [http://www.php.net/manual/en/function.memory-get-peak-usage.php memory_get_peak_usage()] calls|| -||`debugpdo.logging.methods`||[http://propel.propelorm.org/browser/branches/1.5/runtime/classes/propel/util/DebugPDO.php#L151 array(...)]||An array of method names `Class::method`) to be included in method call logging|| -||`debugpdo.logging.details.slow.enabled`||`false`||Enables flagging of slow method calls|| -||`debugpdo.logging.details.slow.threshold`||`0.1`||Method calls taking more seconds than this threshold are considered slow|| -||`debugpdo.logging.details.time.enabled`||`false`||Enables logging of method execution times|| -||`debugpdo.logging.details.time.precision`||`3`||Determines the precision of the execution time logging|| -||`debugpdo.logging.details.time.pad`||`10`||How much horizontal space to reserve for the execution time on a log line|| -||`debugpdo.logging.details.mem.enabled`||`false`||Enables logging of the instantaneous PHP memory consumption|| -||`debugpdo.logging.details.mem.precision`||`1`||Determines the precision of the memory consumption logging|| -||`debugpdo.logging.details.mem.pad`||`9`||How much horizontal space to reserve for the memory consumption on a log line|| -||`debugpdo.logging.details.memdelta.enabled`||`false`||Enables logging differences in memory consumption before and after the method call|| -||`debugpdo.logging.details.memdelta.precision`||`1`||Determines the precision of the memory difference logging|| -||`debugpdo.logging.details.memdelta.pad`||`10`||How much horizontal space to reserve for the memory difference on a log line|| -||`debugpdo.logging.details.mempeak.enabled`||`false`||Enables logging the peak memory consumption thus far by the currently executing PHP script|| -||`debugpdo.logging.details.mempeak.precision`||`1`||Determines the precision of the memory peak logging|| -||`debugpdo.logging.details.mempeak.pad`||`9`||How much horizontal space to reserve for the memory peak on a log line|| -||`debugpdo.logging.details.querycount.enabled`||`false`||Enables logging of the number of queries performed by the DebugPDO instance thus far|| -||`debugpdo.logging.details.querycount.pad`||`2`||How much horizontal space to reserve for the query count on a log line|| -||`debugpdo.logging.details.method.enabled`||`false`||Enables logging of the name of the method call|| -||`debugpdo.logging.details.method.pad`||`28`||How much horizontal space to reserve for the method name on a log line|| - -=== Changing the Log Level === - -By default the connection log messages are logged at the `Propel::LOG_DEBUG` level. This can be changed by calling the `setLogLevel()` method on the connection object: - -{{{ -#!php -setLogLevel(Propel::LOG_INFO); -}}} - -Now all queries and bind param values will be logged at the INFO level. - -=== Configuring a Different Full Query Logger === - -By default the `PropelPDO` connection logs queries and binds param values using the `Propel::log()` static method. As explained above, this method uses the log storage configured by the `` tag in the `runtime-conf.xml` file. - -If you would like the queries to be logged using a different logger (e.g. to a different file, or with different ident, etc.), you can set a logger explicitly on the connection at runtime, using `Propel::setLogger()`: - -{{{ -#!php -setLogger($logger); -} -}}} - -This will not affect the general Propel logging, but only the full query logging. That way you can log the Propel error and warnings in one file, and the SQL queries in another file. diff --git a/airtime_mvc/library/propel/docs/guide/09-Inheritance.txt b/airtime_mvc/library/propel/docs/guide/09-Inheritance.txt deleted file mode 100644 index 25e03b8e1..000000000 --- a/airtime_mvc/library/propel/docs/guide/09-Inheritance.txt +++ /dev/null @@ -1,329 +0,0 @@ -= Inheritance = - -[[PageOutline]] - -Developers often need one model table to extend another model table. Inheritance being an object-oriented notion, it doesn't have a true equivalent in the database world, so this is something an ORM must emulate. Propel offers two types of table inheritance: [http://www.martinfowler.com/eaaCatalog/singleTableInheritance.html Single Table Inheritance], which is the most efficient implementations from a SQL and query performance perspective, but is limited to a small number of inherited fields ; and [http://www.martinfowler.com/eaaCatalog/concreteTableInheritance.html Concrete Table Inheritance], which provides the most features but adds a small overhead on write queries. - -== Single Table Inheritance == - -In this implementation, one table is used for all subclasses. This has the implication that your table must have all columns needed by the main class and subclasses. Propel will create stub subclasses. - -Let's illustrate this idea with an example. Consider an object model with three classes, `Book`, `Essay`, and `Comic` - the first class being parent of the other two. With single table inheritance, the data of all three classes is stored in one table, named `book`. - -=== Schema Definition === - -A table using Single Table Inheritance requires a column to identify which class should be used to represent the ''table'' row. Classically, this column is named `class_key` - but you can choose whatever name fits your taste. The column needs the `inheritance="single"` attribute to make Propel understand that it's the class key column. Note that this 'key' column must be a real column in the table. - -{{{ -#!xml - - - - - - - - -
-}}} - -Once you rebuild your model, Propel generated all three model classes (`Book`, `Essay`, and `Comic`) and three query classes (`BookQuery`, `EssayQuery`, and `ComicQuery`). The `Essay` and `Comic` classes extend the `Book` class, the `EssayQuery` and `ComicQuery` classes extend `BookQuery`. - -'''Tip''': An inherited class can extend another inherited class. That mean that you can add a `Manga` kind of book that extends `Comic` instead of `Book`. - -=== Using Inherited Objects === - -Use inherited objects just like you use regular Propel model objects: - -{{{ -#!php -setTitle('War And Peace'); -$book->save(); -$essay = new Essay(); -$essay->setTitle('On the Duty of Civil Disobedience'); -$essay->save(); -$comic = new Comic(); -$comic->setTitle('Little Nemo In Slumberland'); -$comic->save(); -}}} - -Inherited objects share the same properties and methods by default, but you can add your own logic to each of the generated classes. - -Behind the curtain, Propel sets the `class_key` column based on the model class. So the previous code stores the following rows in the database: - -{{{ -id | title | class_key ----|-----------------------------------|---------- -1 | War And Peace | Book -2 | On the Duty of Civil Disobedience | Essay -3 | Little Nemo In Slumberland | Comic -}}} - -Incidentally, that means that you can add new classes manually, even if they are not defined as `` tags in the `schema.xml`: - -{{{ -#!php -setClassKey('Novel'); - } -} -$novel = new Novel(); -$novel->setTitle('Harry Potter'); -$novel->save(); -}}} - -=== Retrieving Inherited objects === - -In order to retrieve books, use the Query object of the main class, as you would usually do. Propel will hydrate children objects instead of the parent object when necessary: - -{{{ -#!php -find(); -foreach ($books as $book) { - echo get_class($book) . ': ' . $book->getTitle() . "\n"; -} -// Book: War And Peace -// Essay: On the Duty of Civil Disobedience -// Comic: Little Nemo In Slumberland -// Novel: Harry Potter -}}} - -If you want to retrieve only objects of a certain class, use the inherited query classes: - -{{{ -#!php -findOne(); -echo get_class($comic) . ': ' . $comic->getTitle() . "\n"; -// Comic: Little Nemo In Slumberland -}}} - -'''Tip''': You can override the base peer's `getOMClass()` to return the classname to use based on more complex logic (or query). - -=== Abstract Entities === - -If you wish to enforce using subclasses of an entity, you may declare a table "abstract" in your XML data model: - -{{{ -#!xml - - ... -}}} - -That way users will only be able to instanciate `Essay` or `Comic` books, but not `Book`. - -== Concrete Table Inheritance == - -Concrete Table Inheritance uses one table for each class in the hierarchy. Each table contains columns for the class and all its ancestors, so any fields in a superclass are duplicated across the tables of the subclasses. - -Propel implements Concrete Table Inheritance through a behavior. - -=== Schema Definition === - -Once again, this is easier to understand through an example. In a Content Management System, content types are often organized in a hierarchy, each subclass adding more fields to the superclass. So let's consider the following schema, where the `article` and `video` tables use the same fields as the main `content` tables, plus additional fields: - -{{{ -#!xml -
- - - - - - -
- - - -
- - - - - - - - -
- - - - - - - - -
-}}} - -Since the columns of the main table are copied to the child tables, this schema is a simple implementation of Concrete Table Inheritance. This is something that you can write by hand, but the repetition makes it tedious. Instead, you should let the `concrete_inheritance` behavior do it for you: - -{{{ -#!xml - - - - - - - -
- - - -
- - - - - -
- - - - - -
-}}} - -'''Tip''': The `concrete_inheritance` behavior copies columns, foreign keys, indices and validators. - -=== Using Inherited Model Classes === - -For each of the tables in the schema above, Propel generates a Model class: - -{{{ -#!php -setName('Movie'); -$cat->save(); -// create a new Article -$art = new Article(); -$art->setTitle('Avatar Makes Best Opening Weekend in the History'); -$art->setCategory($cat); -$art->setContent('With $232.2 million worldwide total, Avatar had one of the best-opening weekends in the history of cinema.'); -$art->save(); -// create a new Video -$vid = new Video(); -$vid->setTitle('Avatar Trailer'); -$vid->setCategory($cat); -$vid->setResourceLink('http://www.avatarmovie.com/index.html') -$vid->save(); -}}} - -And since the `concrete_inheritance` behavior tag defines a parent table, the `Article` and `Video` classes extend the `Content` class (same for the generated Query classes): - -{{{ -#!php -getCategory()->getName(); - } -} -echo $art->getCategoryName(); // 'Movie' -echo $vid->getCategoryName(); // 'Movie' - -// methods of the parent query are accessible to the child query -class ContentQuery extends BaseContentQuery -{ - public function filterByCategoryName($name) - { - return $this - ->useCategoryQuery() - ->filterByName($name) - ->endUse(); - } -} -$articles = ArticleQuery::create() - ->filterByCategoryName('Movie') - ->find(); -}}} - -That makes of Concrete Table Inheritance a powerful way to organize your model logic and to avoid repetition, both in the schema and in the model code. - -=== Data Replication === - -By default, every time you save an `Article` or a `Video` object, Propel saves a copy of the `title` and `category_id` columns in a `Content` object. Consequently, retrieving objects regardless of their child type becomes very easy: - -{{{ -#!php -find(); -foreach ($conts as $content) { - echo $content->getTitle() . "(". $content->getCategoryName() ")/n"; -} -// Avatar Makes Best Opening Weekend in the History (Movie) -// Avatar Trailer (Movie) -}}} - -Propel also creates a one-to-one relationship between a object and its parent copy. That's why the schema definition above doesn't define any primary key for the `article` and `video` tables: the `concrete_inheritance` behavior creates the `id` primary key which is also a foreign key to the parent `id` column. So once you have a parent object, getting the child object is just one method call away: - -{{{ -#!php -getContent(); - } -} -class Movie extends BaseMovie -{ - public function getPreview() - { - return $this->getResourceLink(); - } -} -$conts = ContentQuery::create()->find(); -foreach ($conts as $content) { - echo $content->getTitle() . "(". $content->getCategoryName() ")/n" - if ($content->hasChildObject()) { - echo ' ' . $content->getChildObject()->getPreview(), "\n"; -} -// Avatar Makes Best Opening Weekend in the History (Movie) -// With $232.2 million worldwide total, Avatar had one of the best-opening -// weekends in the history of cinema. -// Avatar Trailer (Movie) -// http://www.avatarmovie.com/index.html -}}} - -The `hasChildObject()` and `getChildObject()` methods are automatically added by the behavior to the parent class. Behind the curtain, the saved `content` row has an additional `descendant_column` field allowing it to use the right model for the job. - -'''Tip''' You can disable the data replication by setting the `copy_data_to_parent` parameter to "false". In that case, the `concrete_inheritance` behavior simply modifies the table at buildtime and does nothing at runtime. Also, with `copy_data_to_parent` disabled, any primary key copied from the parent table is not turned into a foreign key: - -{{{ -#!xml - - - - - - -
-// results in - - - - - - - - -
-}}} \ No newline at end of file diff --git a/airtime_mvc/library/propel/docs/reference/Buildtime-Configuration.txt b/airtime_mvc/library/propel/docs/reference/Buildtime-Configuration.txt deleted file mode 100644 index 36fbe642b..000000000 --- a/airtime_mvc/library/propel/docs/reference/Buildtime-Configuration.txt +++ /dev/null @@ -1,312 +0,0 @@ -= Build Properties Reference = - -[[PageOutline]] - -Here is a list of properties that can be set to affect how Propel builds database files. For a complete list, see the {{{default.properties}}} file that is bundled with your version of Propel generator (this will be in PEAR's data directory if you are using a PEAR-installed version of Propel). - -First, some conventions: - - * Text surrounded by a '''/''' is text that you would provide and is not defined in the language. (i.e. a table name is a good example of this.) - * Items where you have an alternative choice have a '''|''' character between them (i.e. true|false) - * Alternative choices may be delimited by '''{''' and '''}''' to indicate that this is the default option, if not overridden elsewhere. - -== Where to Specify Properties == - -=== In the Project build.properties File === - -The most natural place to specify properties for a file are in the project's {{{build.properties}}} file. This file is expected to be found in the project directory. - -=== In a global build.properties file === - -You can also create a {{{global build.properties}}} file in the same directory as Propel's {{{default.properties}}} file. For users who have installed Propel using PEAR, this will be in PEAR data directory structure. - -=== On the Command Line === - -You can also specify properties on the commandline when you invoke Propel: - -{{{ -$ propel-gen /path/to/project -Dpropel.someOtherProperty=value -}}} - -''Note that there is '''no space''' between the -D and the property name.'' - -== The Properties == - -=== General Build Settings === - -{{{ -propel.project = Your-Project-Name -}}} - -The name of your project. This affects names of generated files, etc. - -{{{ -propel.targetPackage = {propel.project} -}}} - -The package to use for the generated classes. This affects the value of the @package phpdoc tag, and it also affects the directory that the classes are placed in. By default this will be the same as the project. Note that the target package (and thus the target directory for generated classes) can be overridden in each `` and `` element in the XML schema. - -{{{ -propel.packageObjectModel = true|{false} -}}} - -Whether to join schemas using the same database name into a single schema. This allows splitting schemas in packages, and referencing tables in another schema (but in the same database) in a foreign key. Beware that database behaviors will also be joined when this parameter is set to true. - -{{{ -propel.schema.validate = {true}|false -}}} - -Whether to validate the schema using the XSD file. The default XSD file is located under `generator/resources/xsd/database.xsd`, and you can use a custom XSD file by changing the `propel.schema.xsd.file` property. - -{{{ -propel.schema.transform = true|{false} -}}} - -Whether to transform the schema using the XSL file. This was used in previous Propel versions to clean up the schema, but tended to hide problems in the schema. It is disabled by default since Propel 1.5. The default XSL file is located under `generator/resources/xsd/database.xsl`, and you can use a custom XSL file by changing the `propel.schema.xsl.file` property. - -=== Database Settings === - -{{{ -propel.database = pgsql|mysql|sqlite|mssql|oracle -}}} - -The Propel platform that will be used to determine how to build the SQL DDL, etc. - - -{{{ -propel.database.url = /PDO database connection string/ -propel.database.user = -propel.database.password = -}}} - -Propel will use this information as the default to connect to your database. Note that for PDO some drivers (e.g. mysql, oracle) require that you specify the username and password separately from the DSN, which is why they are available as options. - - -{{{ -propel.database.buildUrl = /PDO database connection string, defaults to use ${propel.database.url}/ -}}} - -This property is used by Propel to connect to a database to reverse engineer or data dump. The default is to use the database connection defined by the ''propel.database.url'' property. - - -{{{ -propel.database.createUrl = /PDO database connection string, defaults to use ${propel.database.url}/ -}}} - -This property is used by Propel for creating a database. Of course, Propel is unable to create many databases because they do not provide a SQL method for creation; therefore, it is usually recommended that you actually create your database by hand. - -{{{ -propel.database.schema = /schema-name/ -}}} - -Where supported by the RDBMS, you can specify a schema name for Propel to use. - -{{{ -propel.database.encoding = -}}} -The encoding to use for the database. This can affect things such as transforming charsets when exporting to XML, etc. - -{{{ -propel.tablePrefix = {empty}|string -}}} - -Add a prefix to all the table names in the database. This does not affect the tables phpName. This setting can be overridden on a per-database basis in the schema. - -=== Reverse-Engineering Settings === - -{{{ -propel.samePhpName = true|{false} -}}} -Whether to specify PHP names that are the same as the column names. - -{{{ -propel.addVendorInfo = true|{false} -}}} -Whether to add the vendor info. This is currently only used for MySQL, but does provide additional information (such as full-text indexes) which can affect the generation of the DDL from the schema. - -{{{ -propel.addValidators = {none}|maxvalue|type|required|unique|all -}}} -Which Propel validators to add to the generated schema (based on the db constraints). - -=== Customizing Generated Object Model === - -{{{ -propel.addGenericAccessors = true|{false} -propel.addGenericMutators = true|{false} -}}} -Whether to add generic getter/setter methods -- e.g. '''getByName()''', '''setByName()'''. - -{{{ -propel.addTimeStamp = true|{false} -}}} -Whether to add a timestamp to the phpdoc header of generated OM classes. - -{{{ -propel.addValidateMethod = {true}|false -}}} -Whether to add `validate()` method to your classes. Set to false if you don't use Propel validation. - -{{{ -propel.addIncludes = {true}|false -}}} -Whether to add `require` statements on the generated stub classes. Set to false if you autoload every classe at runtime. - -{{{ -propel.addHooks = {true}|false -}}} -Whether to support pre- and post- hooks on `save()` and `delete()` methods. Set to false if you never use these hooks for a small speed boost. - -{{{ -propel.basePrefix = {Base}|/YourPrefix/ -}}} -The prefix to use for the base (super) classes that are generated. - -{{{ -propel.classPrefix = {empty}|string; -}}} -Some sort of "namespacing": All Propel classes with get the Prefix "My_ORM_Prefix_" just like "My_ORM_Prefix_BookPeer". - -{{{ -propel.disableIdentifierQuoting = true|{false} -}}} -Identifier quoting is only implemented at the DDL layer at this point. Since this may result in undesired behavior (especially in Postgres), it can be disabled by setting this property to true. - -{{{ -propel.useLeftJoinsInDoJoinMethods = {true}|false -}}} -Set whether the '''doSelectJoin*()''' methods use LEFT JOIN or INNER JOIN (see ticket:491 and ticket:588 to understand more about why this might be important). - -=== MySQL-specific Settings === - -{{{ -propel.mysqlTableType = /DefaultTableEngine/ -}}} -Default table engine - defaults to MyISAM. You can override this setting if you wish to default to another engine for all tables (for instance InnoDB, or HEAP). This setting can also be overridden on a per-table basis using the `` element in the schema (see [wiki:Documentation/1.5/Schema#AddingVendorInfo]). - -{{{ -propel.mysqlTableEngineKeyword = /EngineKeyword/ -}}} -Keyword used to specify the table engine in the CREATE SQL statement. Defaults to 'ENGINE', users of MYSQL < 5 should use 'TYPE' instead. - -=== Date/Time Settings === - -{{{ -propel.useDateTimeClass = true|{false} -}}} -This is how you enable full use of the new DateTime class in Propel. Setting this to true means that getter methods for date/time/timestamp columns will return a DateTime object ''when the default format is empty''. Note that the current default of ''false'' is only for backwards compatibility; in the future ''true'' will be the only option here. - -{{{ -propel.dateTimeClass = {DateTime}|string -}}} -Specify a custom DateTime subclass that you wish to have Propel use for temporal values. - -{{{ -propel.defaultTimeStampFormat = {Y-m-d H:i:s}|string -propel.defaultTimeFormat = {%X}|string -propel.defaultDateFormat = {%x}|string -}}} -These are the default formats that will be used when fetching values from temporal columns in Propel. You can always specify these when calling the methods directly, but for methods like getByName() it is nice to change the defaults. - -To have these methods return DateTime objects instead, you should set these to empty values, for example: -{{{ -propel.defaultTimeStampFormat = -}}} - -=== Directories === - -{{{ -propel.project.dir = default-depends-on-installation-type -}}} - -''This is not necessarily a property you can change.'' The project directory is the directory where you project files (build.properties, schema.xml, runtime-conf.xml, etc.) are located. For example, if you use the {{{propel-gen}}} script, this value will get overridden to the path you pass to {{{propel-gen}}}. - -{{{ -propel.output.dir = ${propel.project.dir}/build -}}} -The default top-level directory for output of classes, sql, config, etc. - -{{{ -propel.schema.dir = ${propel.project.dir} -}}} -The directory where Propel expects to find your schema.xml file. - -{{{ -propel.conf.dir = ${propel.project.dir} -}}} -The directory where Propel expects to find your {{{runtime-conf.xml}}} file. - -{{{ -propel.php.dir = ${propel.output.dir}/classes -}}} -The directory where Propel will create generated object model classes. - -{{{ -propel.phpconf.dir = ${propel.output.dir}/conf -}}} -The directory where Propel will place the php-ified version of your {{{runtime-conf.xml}}}. - -{{{ -propel.sql.dir = ${propel.output.dir}/sql -}}} -The directory where Propel will place generated DDL (or data insert statements, etc.) - - -=== Overriding Builder Classes === - -{{{ -# Object Model builders -propel.builder.peer.class = propel.engine.builder.om.php5.PHP5ComplexPeerBuilder -propel.builder.object.class = propel.engine.builder.om.php5.PHP5ComplexObjectBuilder -propel.builder.objectstub.class = propel.engine.builder.om.php5.PHP5ExtensionObjectBuilder -propel.builder.peerstub.class = propel.engine.builder.om.php5.PHP5ExtensionPeerBuilder - -propel.builder.objectmultiextend.class = propel.engine.builder.om.php5.PHP5MultiExtendObjectBuilder - -propel.builder.tablemap.class = propel.engine.builder.om.php5.PHP5TableMapBuilder - -propel.builder.interface.class = propel.engine.builder.om.php5.PHP5InterfaceBuilder - -propel.builder.node.class = propel.engine.builder.om.php5.PHP5NodeBuilder -propel.builder.nodepeer.class = propel.engine.builder.om.php5.PHP5NodePeerBuilder -propel.builder.nodestub.class = propel.engine.builder.om.php5.PHP5ExtensionNodeBuilder -propel.builder.nodepeerstub.class = propel.engine.builder.om.php5.PHP5ExtensionNodePeerBuilder - -propel.builder.nestedset.class = propel.engine.builder.om.php5.PHP5NestedSetBuilder -propel.builder.nestedsetpeer.class = propel.engine.builder.om.php5.PHP5NestedSetPeerBuilder - -# SQL builders - -propel.builder.ddl.class = propel.engine.builder.sql.${propel.database}.${propel.database}DDLBuilder -propel.builder.datasql.class = propel.engine.builder.sql.${propel.database}.${propel.database}DataSQLBuilder - -# Platform classes - -propel.platform.class = propel.engine.platform.${propel.database}Platform - -# Pluralizer class (used to generate plural forms) - -propel.builder.pluralizer.class = propel.engine.builder.util.DefaultEnglishPluralizer -}}} - -As you can see, you can specify your own builder and platform classes if you want to extend & override behavior in the default classes - -=== Adding Behaviors === - -{{{ -propel.behavior.timestampable.class = propel.engine.behavior.TimestampableBehavior -}}} - -Define the path to the class to be used for the `timestampable` behavior. This behavior is bundled wit hPropel, but if you want to override it, you can specify a different path. - -If you want to add more behaviors, write their path following the same model: - -{{{ -propel.behavior.my_behavior.class = my.custom.path.to.MyBehaviorClass -}}} - -Behaviors are enabled on a per-table basis in the `schema.xml`. However, you can add behaviors for all your schemas, provided that you define them in the `propel.behavior.default` setting: - -{{{ -propel.behavior.default = soft_delete,my_behavior -}}} \ No newline at end of file diff --git a/airtime_mvc/library/propel/docs/reference/ModelCriteria.txt b/airtime_mvc/library/propel/docs/reference/ModelCriteria.txt deleted file mode 100644 index d5c4042d3..000000000 --- a/airtime_mvc/library/propel/docs/reference/ModelCriteria.txt +++ /dev/null @@ -1,1025 +0,0 @@ -= Propel Query Reference = - -[[PageOutline]] - -Propel's Query classes make it easy to write queries of any level of complexity in a simple and reusable way. - -== Overview == - -Propel proposes an object-oriented API for writing database queries. That means that you don't need to write any SQL code to interact with the database. Object orientation also facilitates code reuse and readability. Here is how to query the database for records in the `book` table ordered by the `title` column and published in the last month: - -{{{ -#!php -filterByPublishedAt(array('min' => time() - 30 * 24 * 60 * 60)) - ->orderByTitle() - ->find(); -}}} - -The first thing to notice here is the fluid interface. Propel queries are made of method calls that return the current query object - `filterByPublishedAt()` and `orderByTitle()` return the current query augmented with conditions. `find()`, on the other hand, is a ''termination method'' that doesn't return the query, but its result - in this case, a collection of `Book` objects. - -Propel generates one `filterByXXX()` method for every column in the table. The column name used in the PHP method is not the actual column name in the database ('`published_at`'), but rather a CamelCase version of it ('`PublishedAt`'), called the column ''phpName''. Remember to always use the phpName in the PHP code ; the actual SQL name only appears in the SQL code. - -When a termination method like `find()` is called, Propel builds the SQL code and executes it. The previous example generates the following code when `find()` is called: - -{{{ -#!php -= :p1 -ORDER BY book.TITLE ASC'; -}}} - -Propel uses the column name in conjunction with the schema to determine the column type. In this case, `published_at` is defined in the schema as a `TIMESTAMP`. Then, Propel ''binds'' the value to the condition using the column type. This prevents SQL injection attacks that often plague web applications. Behind the curtain, Propel uses PDO to achieve this binding: - -{{{ -#!php -prepare($query); -$stmt->bind(':p1', time() - 30 * 24 * 60 * 60, PDO::PARAM_INT); -$res = $stmt->execute(); -}}} - -The final `find()` doesn't just execute the SQL query above, it also instanciates `Book` objects and populates them with the results of the query. Eventually, it returns a `PropelCollection` object with these `Book` objects inside. For the sake of clarity, you can consider this collection object as an array. In fact, you can use it as if it were a true PHP array and iterate over the result list the usual way: - -{{{ -#!php -getTitle(); -} -}}} - -So Propel queries are a very powerful tool to write your queries in an object-oriented fashion. They are also very natural - if you know how to write an SQL query, chances are that you will write Propel queries in minutes. - -== Generated Query Methods == - -For each object, Propel creates a few methods in the generated query object. - -=== Column Filter Methods === - -`filterByXXX()`, generated for each column, provides a different feature and a different functionality depending on the column type: - - * For all columns, `filterByXXX()` translates to a simple SQL `WHERE` condition by default: - -{{{ -#!php -filterByTitle('War And Peace') - ->find(); -// example Query generated for a MySQL database -$query = 'SELECT book.* from `book` -WHERE book.TITLE = :p1'; // :p1 => 'War And Peace' -}}} - - * For string columns, `filterByXXX()` translates to a SQL `WHERE ... LIKE` if the value contains wildcards: - -{{{ -#!php -filterByTitle('War%') - ->find(); -// example Query generated for a MySQL database -$query = 'SELECT book.* from `book` -WHERE book.TITLE LIKE :p1'; // :p1 => 'War%' -}}} - - * For integer columns, `filterByXXX()` translates into a SQL `WHERE ... IN` if the value is an array: - -{{{ -#!php -filterByAuthorId(array(123, 456)) - ->find(); -// example Query generated for a MySQL database -$query = 'SELECT book.* from `book` -WHERE book.AUTHOR_ID IN (:p1, :p2)'; // :p1 => 123, :p2 => 456 -}}} - - * For Boolean columns, `filterByXXX()` translates the value to a boolean using smart casting: - -{{{ -#!php -filterByIsPublished('yes') - ->filterByIsSoldOut('no') - ->find(); -// example Query generated for a MySQL database -$query = 'SELECT book.* from `book` -WHERE book.IS_PUBLISHED = :p1 - AND book.IS_SOLD_OUT = :p2'; // :p1 => true, :p2 => false -}}} - -=== Relation Filter Methods === - -Propel also generates a `filterByXXX()` method for every foreign key. The filter expects an object of the related class as parameter: - -{{{ -#!php -findPk(123); -$books = BookQuery::create() - ->filterByAuthor($author) - ->find(); -// example Query generated for a MySQL database -$query = 'SELECT book.* from `book` -WHERE book.AUTHOR_ID = :p1'; // :p1 => 123 -}}} - -Check the generated BaseQuery classes for a complete view of the generated query methods. Every generated method comes with a detailed phpDoc comment, making code completion very easy on supported IDEs. - -=== Embedding a Related Query === - -In order to add conditions on related tables, a propel query can ''embed'' the query of the related table. The generated `useXXXQuery()` serve that purpose. For instance, here is how to query the database for books written by 'Leo Tolstoi': - -{{{ -#!php -useAuthorQuery() - ->filterByName('Leo Tolstoi') - ->endUse() - ->find(); -}}} - -`useAuthorQuery()` returns a new instance of `AuthorQuery` already joined with the current `BookQuery` instance. The next method is therefore called on a different object - that's why the `filterByName()` call is further indented in the code example. Finally, `endUse()` merges the conditions applied on the `AuthorQuery` to the `BookQuery`, and returns the original `BookQuery` object. - -Propel knows how to join the `Book` model to the `Author` model, since you already defined a foreign key between the two tables in the `schema.xml`. Propel takes advantage of this knowledge of your model relationships to help you write faster queries and omit the most obvious data. - -{{{ -#!php - 'Leo Tolstoi' -}}} - -You can customize the related table alias and the join type by passing arguments to the `useXXXQuery()` method: - -{{{ -#!php -useAuthorQuery('a', 'left join') - ->filterByName('Leo Tolstoi') - ->endUse() - ->find(); -// example Query generated for a MySQL database -$query = 'SELECT book.* from book -LEFT JOIN author a ON book.AUTHOR_ID = a.ID -WHERE a.NAME = :p1'; // :p1 => 'Leo Tolstoi' -}}} - -The `useXXXQuery()` methods allow for very complex queries. You can mix them, nest them, and reopen them to add more conditions. - -== Inherited Methods == - -The generated Query classes extend a core Propel class named `ModelCriteria`, which provides even more methods for building your queries. - -=== Finding An Object From Its Primary Key === - -{{{ -#!php -findPk(123); -// Finding the books having primary keys 123 and 456 -$books = BookQuery::create()->findPks(array(123, 456)); -// Also works for objects with composite primary keys -$bookOpinion = BookOpinionQuery::create()->findPk(array($bookId, $userId)); -}}} - -=== Finding Objects === - -{{{ -#!php -find(); -// Finding 3 Books -$articles = BookQuery::create() - ->limit(3) - ->find(); -// Finding a single Book -$article = BookQuery::create() - ->findOne(); -}}} - -=== Using Magic Query Methods === - -{{{ -#!php -findOneByTitle('War And Peace'); -// same as -$book = BookQuery::create() - ->filterByTitle('War And Peace') - ->findOne(); - -$books = BookQuery::create()->findByTitle('War And Peace'); -// same as -$books = BookQuery::create() - ->filterByTitle('War And Peace') - ->find(); - -// You can even combine several column conditions in a method name, if you separate them with 'And' -$book = BookQuery::create()->findOneByTitleAndAuthorId('War And Peace', 123); -// same as -$book = BookQuery::create() - ->filterByTitle('War And Peace') - ->filterById(123) - ->findOne(); -}}} - -=== Ordering Results === - -{{{ -#!php -orderByPublishedAt() - ->find(); -// Finding all Books ordered by published_at desc -$books = BookQuery::create() - ->orderByPublishedAt('desc') - ->find(); -}}} - -=== Specifying A Connection === - -{{{ -#!php -findOne($con); -}}} - -'''Tip''': In debug mode, the connection object provides a way to check the latest executed query, by calling `$con->getLastExecutedQuery()`. See the [wiki:Documentation/1.5/07-Logging Logging documentation] for more details. - -=== Counting Objects === - -{{{ -#!php -count($con); -// This is much faster than counting the results of a find() -// since count() doesn't populate Model objects -}}} - -=== Deleting Objects === - -{{{ -#!php -deleteAll($con); -// Deleting a selection of Books -$nbDeletedBooks = BookQuery::create() - ->filterByTitle('Pride And Prejudice') - ->delete($con); -}}} - -=== Updating Objects === - -{{{ -#!php -setName('Jane Austen'); -$author1->save(); -$author2 = new Author(); -$author2->setName('Leo Tolstoy'); -$author2->save(); - -// update() issues an UPDATE ... SET query based on an associative array column => value -$nbUpdatedRows = AuthorQuery::create() - ->filterByName('Leo Tolstoy') - ->update(array('Name' => 'Leo Tolstoi'), $con); - -// update() returns the number of modified columns -echo $nbUpdatedRows; // 1 - -// Beware that update() updates all records found in a single row -// And bypasses any behavior registered on the save() hooks -// You can force a one-by-one update by setting the third parameter of update() to true -$nbUpdatedRows = AuthorQuery::create() - ->filterByName('Leo Tolstoy') - ->update(array('Name' => 'Leo Tolstoi'), $con, true); -// Beware that it may take a long time -}}} - -=== Creating An Object Based on a Query === - -You may often create a new object based on values used in conditions if a query returns no result. This happens a lot when dealing with cross-reference tables in many-to-many relationships. To avoid repeating yourself, use `findOneOrCreate()` instead of `findOne()` in such cases: - -{{{ -#!php -filterByBook($book) - ->filterByTag('crime') - ->findOne(); -if (!$bookTag) { - $bookTag = new BookTag(); - $bookTag->setBook($book); - $bookTag->setTag('crime'); -} -// The short way -$bookTag = BookTagQuery::create() - ->filterByBook($book) - ->filterByTag('crime') - ->findOneOrCreate(); -}}} - -=== Reusing A Query === - -By default, termination methods like `findOne()`, `find()`, `count()`, `paginate()`, or `delete()` alter the original query. That means that if you need to reuse a query after a termination method, you must call the `keepQuery()` method first: - -{{{ -#!php -filterByIsPublished(true); -$book = $q->findOneByTitle('War And Peace'); -// findOneByXXX() adds a limit() to the query -// so further reuses of the query may show side effects -echo $q->count(); // 1 - -// to allos query reuse, call keepQuery() before the termination method -$q = BookQuery::create()->filterByIsPublished(true)->keepQuery(); -$book = $q->findOneByTitle('War And Peace'); -echo $q->count(); // 34 -}}} - -== Relational API == - -For more complex queries, you can use an alternative set of methods, closer to the relational logic of SQL, to make sure that Propel issues exactly the SQL query you need. - -This alternative API uses methods like `where()`, `join()` and `orderBy()` that translate directly to their SQL equivalent - `WHERE`, `JOIN`, etc. Here is an example: - -{{{ -#!php -join('Book.Author') - ->where('Author.Name = ?', 'Leo Tolstoi') - ->orderBy('Book.Title', 'asc') - ->find(); - -}}} - -The names passed as parameters in these methods, like 'Book.Author', 'Author.Name', and 'Book.Title', are ''explicit column names''. These names are composed of the phpName of the model, and the phpName of the column, separated by a dot (e.g. 'Author.Name'). Manipulating object model names allows you to be detached from the actual data storage, and alter the database names without necessarily updating the PHP code. It also makes the use of table aliases much easier - more on that matter later. - -Propel knows how to map the explicit column names to database column names in order to translate the Propel query into an actual database query: - -{{{ -#!php -where('Book.Title = ?', 'War And Peace') - ->find(); -// Finding all Books where title is like 'War%' -$books = BookQuery::create() - ->where('Book.Title LIKE ?', 'War%') - ->find(); -// Finding all Books published after $date -$books = BookQuery::create() - ->where('Book.PublishedAt > ?', $date) - ->find(); -// Finding all Books with no author -$books = BookQuery::create() - ->where('Book.AuthorId IS NULL') - ->find(); -// Finding all books from a list of authors -$books = BookQuery::create() - ->where('Book.AuthorId IN ?', array(123, 542, 563)) - ->find(); -// You can even use SQL functions inside conditions -$books = BookQuery::create() - ->where('UPPER(Book.Title) = ?', 'WAR AND PEACE') - ->find(); -}}} - -=== Combining Several Conditions === - -For speed reasons, `where()` only accepts simple conditions, with a single interrogation point for the value replacement. When you need to apply more than one condition, and combine them with a logical operator, you have to call `where()` multiple times. - -{{{ -#!php -where('Book.Title = ?', 'War And Peace') - ->where('Book.PublishedAt > ?', $date) - ->find(); -// For conditions chained with OR, use orWhere() instead of where() -$books = BookQuery::create() - ->where('Book.Title = ?', 'War And Peace') - ->orWhere('Book.Title LIKE ?', 'War%') - ->find(); -}}} - -The use of `where()` and `orWhere()` doesn't allow logically complex conditions, that you would write in SQL with parenthesis. For such cases, create named conditions with `condition()`, and then combine them in an array that you can pass to `where()` instead of a single condition, as follows: - -{{{ -#!php -condition('cond1', 'Book.Title = ?', 'War And Peace') // create a condition named 'cond1' - ->condition('cond2', 'Book.Title LIKE ?', 'War%') // create a condition named 'cond2' - ->where(array('cond1', 'cond2'), 'or')-> // combine 'cond1' and 'cond2' with a logical OR - ->find(); - // SELECT book.* from book WHERE (book.TITLE = 'War And Peace' OR book.TITLE LIKE 'War%'); - -// You can create a named condition from the combination of other named conditions by using `combine()` -// That allows for any level of complexity -$books = BookQuery::create() - ->condition('cond1', 'Book.Title = ?', 'War And Peace') // create a condition named 'cond1' - ->condition('cond2', 'Book.Title LIKE ?', 'War%') // create a condition named 'cond2' - ->combine(array('cond1', 'cond2'), 'or', 'cond12') // create a condition named 'cond12' from 'cond1' and 'cond2' - ->condition('cond3', 'Book.PublishedAt <= ?', $end) // create a condition named 'cond3' - ->condition('cond4', 'Book.PublishedAt >= ?', $begin) // create a condition named 'cond4' - ->combine(array('cond3', 'cond4'), 'and', 'cond34') // create a condition named 'cond34' from 'cond3' and 'cond4' - ->where(array('cond12', 'cond34'), 'and') // combine the two conditions in a where - ->find(); - // SELECT book.* FROM book WHERE ( - // (book.TITLE = 'War And Peace' OR book.TITLE LIKE 'War%') - // AND - // (book.PUBLISHED_AT <= $end AND book.PUBLISHED_AT >= $begin) - // ); -}}} - -=== Joining Tables === - -{{{ -#!php -setName('Jane Austen'); -$author1->save(); -$book1 = new Book(); -$book1->setTitle('Pride And Prejudice'); -$book1->setAuthor($author1); -$book1->save(); - -// Add a join statement -// No need to tell the query which columns to use for the join, just the related Class -// After all, the columns of the FK are already defined in the schema. -$book = BookQuery::create() - ->join('Book.Author') - ->where('Author.Name = ?', 'Jane Austen') - ->findOne(); - // SELECT book.* FROM book - // INNER JOIN author ON book.AUTHOR_ID = author.ID - // WHERE author.NAME = 'Jane Austin' - // LIMIT 1; - -// The default join() call results in a SQL INNER JOIN clause -// For LEFT JOIN or RIGHT JOIN clauses, use leftJoin() or rightJoin() instead of join() -$book = BookQuery::create() - ->leftJoin('Book.Author') - ->where('Author.Name = ?', 'Jane Austen') - ->findOne(); - -// You can chain joins if you want to make more complex queries -$review = new Review(); -$review->setBook($book1); -$review->setRecommended(true); -$review->save(); - -$author = BookQuery::create() - ->join('Author.Book') - ->join('Book.Review') - ->where('Review.Recommended = ?', true) - ->findOne(); - -// Alternatively, you can use the generated joinXXX() methods -// Which are a bit faster than join(), but limited to the current model's relationships -$book = BookQuery::create() - ->joinAuthor() - ->where('Author.Name = ?', 'Jane Austen') - ->findOne(); -// The join type depends on the required attribute of the foreign key column -// If the column is required, then the default join type is an INNER JOIN -// Otherwise, the default join type is a LEFT JOIN -// You can override the default join type for a given relationship -// By setting the joinType attribute of the foreign key element in the schema.xml -}}} - -=== Table Aliases === - -{{{ -#!php -where('b.Title = ?', 'Pride And Prejudice') - ->find(); - -// join(), leftJoin() and rightJoin() also allow table aliases -$author = AuthorQuery::create('a') - ->join('a.Book b') - ->join('b.Review r') - ->where('r.Recommended = ?', true) - ->findOne(); - -// Table aliases can be used in all query methods (where, groupBy, orderBy, etc.) -$books = BookQuery::create('b') - ->where('b.Title = ?', 'Pride And Prejudice') - ->orderBy('b.Title') - ->find(); - -// Table aliases are mostly useful to join the current table, -// or to handle multiple foreign keys on the same column -$employee = EmployeeQuery::create('e') - ->innerJoin('e.Supervisor s') - ->where('s.Name = ?', 'John') - ->find(); -}}} - -=== Minimizing Queries === - -Even if you do a join, Propel will issue new queries when you fetch related objects: - -{{{ -#!php -join('Book.Author') - ->where('Author.Name = ?', 'Jane Austen') - ->findOne(); -$author = $book->getAuthor(); // Needs another database query -}}} - -Propel allows you to retrieve the main object together with related objects in a single query. You just have to call the `with()` method to specify which objects the main object should be hydrated with. - -{{{ -#!php -join('Book.Author') - ->with('Author') - ->where('Author.Name = ?', 'Jane Austen') - ->findOne(); -$author = $book->getAuthor(); // Same result, with no supplementary query -}}} - -`with()` expects a relation name, as declared previously by `join()`. In practice, that means that `with()` and `join()` should always come one after the other. To avoid repetition, use `joinWith()` to both add a `join()` and a `with()` on a relation. So the shorter way to write the previous query is: - -{{{ -#!php -joinWith('Book.Author') - ->where('Author.Name = ?', 'Jane Austen') - ->findOne(); -$author = $book->getAuthor(); // Same result, with no supplementary query -}}} - -Since the call to `with()` adds the columns of the related object to the SELECT part of the query, and uses these columns to populate the related object, that means that `joinWith()` is slower and consumes more memory that `join()`. So use it only when you actually need the related objects afterwards. - -`with()` and `joinWith()` are not limited to immediate relationships. As a matter of fact, just like you can chain `join()` calls, you can chain `joinWith()` calls to populate a chain of objects: - -{{{ -#!php -joinWith('Review.Book') - ->joinWith('Book.Author') - ->joinWith('Book.Publisher') - ->findOne(); -$book = $review->getBook() // No additional query needed -$author = $book->getAuthor(); // No additional query needed -$publisher = $book->getPublisher(); // No additional query needed -}}} - -So `joinWith()` is very useful to minimize the number of database queries. As soon as you see that the number of queries necessary to perform an action is proportional to the number of results, adding `With` after `join()` calls is the trick to get down to a more reasonnable query count. - -=== Adding Columns === - -Sometimes you don't need to hydrate a full object in addition to the main object. If you only need one additional column, the `withColumn()` method is a good alternative to `joinWith()`, and it speeds up the query: - -{{{ -#!php -join('Book.Author') - ->withColumn('Author.Name', 'AuthorName') - ->findOne(); -$authorName = $book->getAuthorName(); -}}} - -Propel adds the 'with' column to the SELECT clause of the query, and uses the second argument of the `withColumn()` call as a column alias. This additional column is later available as a 'virtual' column, i.e. using a getter that does not correspond to a real column. You don't actually need to write the `getAuthorName()` method ; Propel uses the magic `__call()` method of the generated `Book` class to catch the call to a virtual column. - -`withColumn()` is also of great use to add calculated columns: - -{{{ -#!php -join('Author.Book') - ->withColumn('COUNT(Book.Id)', 'NbBooks') - ->groupBy('Author.Id') - ->find(); -foreach ($authors as $author) { - echo $author->getName() . ': ' . $author->getNbBooks() . " books\n"; -} -}}} - -With a single SQL query, you can have both a list of objects and an additional column for each object. That makes of `withColumn()` a great query saver. - -'''Tip''': You can call `withColumn()` multiple times to add more than one virtual column to the resulting objects. - -=== Adding A Comment === - -{{{ -#!php -setComment('Author Deletion') - ->filterByName('Leo Tolstoy') - ->delete($con); -// The comment ends up in the generated SQL query -// DELETE /* Author Deletion */ FROM `author` WHERE author.NAME = 'Leo Tolstoy' -}}} - -=== Using Methods From Another Query Class === - -After writing custom methods to query objects, developers often meet the need to use the method from another query. For instance, in order to select the authors of the most recent books, you may want to write: - -{{{ -#!php -join('Author.Book') - ->recent() - ->find(); -}}} - -The problem is that `recent()` is a method of `BookQuery`, not of the `AuthorQuery` class that the `create()` factory returns. - -Does that mean that you must repeat the `BookQuery::recent()` code into a new `AuthorQuery::recentBooks()` method? That would imply repeating the same code in two classes, which is not a good practice. Instead, use the `useQuery()` and `endUse()` combination to use the methods of `BookQuery` inside `AuthorQuery`: - -{{{ -#!php -join('Author.Book') - ->useQuery('Book') - ->recent() - ->endUse() - ->find(); -}}} - -This is excatly whath the generated `useBookQuery()` does, except that you have more control over the join type and alias when you use the relational API. Behind the scene, `useQuery('Book')` creates a `BookQuery` instance and returns it. So the `recent()` call is actually called on `BookQuery`, not on `ArticleQuery`. Upon calling `endUse()`, the `BookQuery` merges into the original `ArticleQuery` and returns it. So the final `find()` is indeed called on the `AuthorQuery` instance. - -You can nest queries in as many levels as you like, in order to avoid the repetition of code in your model. - -'''Tip''': If you define an alias for the relation in `join()`, you must pass this alias instead of the model name in `useQuery()`. - -{{{ -#!php -join('a.Book b') - ->useQuery('b') - ->recent() - ->endUse() - ->find(); -}}} - -=== Fluid Conditions === - -Thanks to the query factories and the fluid interface, developers can query the database without creating a variable for the Query object. This helps a lot to reduce the amount of code necessary to write a query, and it also makes the code more readable. - -But when you need to call a method on a Query object only if a certain condition is satisfied, it becomes compulsory to use a variable for the Query object: - -{{{ -#!php -isEditor()) { - $query->where('Book.IsPublished = ?', true); -} -$books = $query - ->orderByTitle() - ->find(); -}}} - -The `ModelCriteria` class offers a neat way to keep your code to a minimum in such occasions. It provides `_if()` and `_endif()` methods allowing for inline conditions. Using thses methods, the previous query can be written as follows: - -{{{ -#!php -_if(!$user->isEditor()) - ->where('Book.IsPublished = ?', true) - ->_endif() - ->orderByTitle() - ->find(); -}}} - -The method calls enclosed between `_if($cond)` and `_endif()` will only be executed if the condition is true. To complete the list of tools available for fluid conditions, you can also use `_else()` and `_elseif($cond)`. - -=== More Complex Queries === - -The Propel Query objects have even more methods that allow you to write queries of any level of complexity. Check the API documentation for the `ModelCriteria` class to see all methods. - -{{{ -#!php -find(); // $books behaves like an array -?> -There are books: -
    - -
  • - getTitle() ?> -
  • - -
- -find(); // $books is an object -?> - -isEmpty()): ?> -There are no books. - -There are count() ?> books: -
    - -
  • - getTitle() ?> -
  • - isLast()): ?> -
  • Do you want more books?
  • - - -
- -}}} - -Here is the list of methods you can call on a PropelCollection: - -{{{ -#!php -setFormatter('PropelArrayFormatter') - ->findOne(); -print_r($book); - => array('Id' => 123, 'Title' => 'War And Peace', 'ISBN' => '3245234535', 'AuthorId' => 456, 'PublisherId' => 567) -}}} - -Of course, the formatters take the calls to `with()` into account, so you can end up with a precise array representation of a model object: - -{{{ -#!php -setFormatter('PropelArrayFormatter') - ->with('Book.Author') - ->with('Book.Publisher') - ->findOne(); -print_r($book); - => array( - 'Id' => 123, - 'Title' => 'War And Peace', - 'ISBN' => '3245234535', - 'AuthorId' => 456, - 'PublisherId' => 567 - 'Author' => array( - 'Id' => 456, - 'FirstName' => 'Leo', - 'LastName' => 'Tolstoi' - ), - 'Publisher' => array( - 'Id' => 567, - 'Name' => 'Penguin' - ) - ) -}}} - -Propel provides four formatters: - * `PropelObjectFormatter`: The default formatter, returning a model object for `findOne()`, and a `PropelObjectCollection` of model objects for `find()` - * `PropelOnDemandFormatter`: To save memory for large resultsets, prefer this formatter ; it hydrates rows one by one as they are iterated on, and doesn't create a new Propel Model object at each row. Note that this formatter doesn't use the Instance Pool. - * `PropelArrayFormatter`: The array formatter, returning an associative array for `findOne()`, and a `PropelArrayCollection` of arrays for `find()` - * `PropelStatementFormatter`: The 'raw' formatter, returning a `PDOStatement` in any case. - -You can easily write your own formatter to format the resultas the way you want. A formatter is basically a subclass of `PropelFormatter` providing a `format()` and a `formatOne()` method expecting a PDO statement. - -== Writing Your Own business Logic Into A Query == - -=== Custom Filters === - -You can add custom methods to the query objects to make your queries smarter, more reusable, and more readable. Don't forget to return the current object (`$this`) in the new methods. - -{{{ -#!php -filterByPublishedAt(array('min' => time() - $nbDays * 24 * 60 * 60)); - } - - public function mostRecentFirst() - { - return $this->orderByPublishedAt('desc'); - } -} - -// You can now use your custom query and its methods together with the usual ones -$books = BookQuery::create() - ->recent() - ->mostRecentFirst() - ->find(); -}}} - -=== Custom Hooks === - -The query objects also allow you to add code to be executed before each query, by implementing one of the following methods: `preSelect()`, `preUpdate()`, and `preDelete()`. It makes the implementation of a 'soft delete' behavior very straightforward: - -{{{ -#!php -filterByDeletedAt(null); - } - - public function preDelete($con) - { - // mark the records as deleted instead of deleting them - return $this->update(array('DeletedAt' => time())); - } -} -}}} - -'''Tip''': You can create several custom queries for a given model, in order to separate the methods into logical classes. - -{{{ -#!php -where($this->getModelAliasOrName() . '.PublishedAt IS NOT NULL'); - } -} -// Use 'frontendBook' instead of 'Book' in the frontend to retrieve only published articles -$q = new frontendBookQuery(); -$books = $q->find(); -}}} - -'''Tip''': Due to late static binding issues in PHP 5.2, you cannot use the `create()` factory on an inherited query - unless you override it yoursel in the descendant class. Alternatively, Propel offers a global query factory named `PropelQuery`: - -{{{ -#!php -find(); -}}} \ No newline at end of file diff --git a/airtime_mvc/library/propel/docs/reference/Runtime-Configuration.txt b/airtime_mvc/library/propel/docs/reference/Runtime-Configuration.txt deleted file mode 100644 index 256c0a45e..000000000 --- a/airtime_mvc/library/propel/docs/reference/Runtime-Configuration.txt +++ /dev/null @@ -1,318 +0,0 @@ -= Runtime Configuration File = - -[[PageOutline]] - -== Example {{{runtime-conf.xml}}} File == - -Here is a the sample runtime configuration file. - -{{{ -#!xml - - - - propel-bookstore - console - 7 - - - - - sqlite - - DebugPDO - mysql:host=localhost;dbname=bookstore - testuser - password - - - - - - - - utf8 - - set search_path myschema, public - INSERT INTO BAR ('hey', 'there') - - - - - - mysql:host=slave-server1; dbname=bookstore - - - mysql:host=slave-server2; dbname=bookstore - - - - - - -
- - true - - - - true - 1 - -
-
-
-
-
-}}} - -== Explanation of Configuration Sections == - -Below you will find an explanation of the primary elements in the configuration. - -=== === - -If the '''''' element is present, Propel will use the specified information to instantiate a [http://pear.php.net/Log PEAR Log] logger. - -{{{ -#!xml - - - file - /path/to/logger.log - my-app - 7 - -}}} - -The nested elements correspond to the configuration options for the logger (options that would otherwise be passed to '''Log::factory()''' method). - -||'''Element'''||'''Default'''||'''Description'''|| -||''''''||file||The logger type.|| -||''''''||./propel.log||Name of log, meaning is dependent on type specified. (For ''file'' type this is the filename).|| -||''''''||propel||The identifier tag for the log.|| -||''''''||7 (PEAR_LOG_DEBUG)||The logging level.|| - -This log configuring API is designed to provide a simple way to get log output from Propel; however, if your application already has a logging mechanism, we recommend instead that you use your existing logger (writing a simple log adapter, if you are using an unsupported logger). See the [wiki:Documentation/1.5/07-Logging Logging documentation] for more info. - -=== === - -This is the top-level tag for Propel datasources configuration. - -{{{ -#!xml - - - -}}} - -=== === - -{{{ -#!xml - - - - -}}} -A specific datasource being configured. - * The @id must match the @name attribute from your {{{schema.xml}}}. - -=== === - -The adapter to use for Propel. Currently supported adapters: sqlite, pgsql, mysql, oracle, mssql. Note that it is possible that your adapter could be different from your connection driver (e.g. if using ODBC to connect to MSSQL database, you would use an ODBC PDO driver, but MSSQL Propel adapter). - -{{{ -#!xml - - - - - sqlite -}}} - -=== === - -The PDO database connection for the specified datasource. - -Nested elements define the DSN, connection options, other PDO attributes, and finally some Propel-specific initialization settings. - -{{{ -#!xml - - - - - -}}} - -==== ==== - -A custom PDO class (must be a PropelPDO subclass) that you would like to use for the PDO connection. - -{{{ -#!xml - - - - - - DebugPDO -}}} - -This can be used to specify the alternative '''DebugPDO''' class bundled with Propel, or your own subclass. ''Your class must extend PropelPDO, because Propel requires the ability to nest transactions (without having exceptions being thrown by PDO).'' - -==== ==== - -The PDO DSN that Propel will use to connect to the database for this datasource. - -{{{ -#!xml - - - - - - mysql:host=localhost;dbname=bookstore -}}} - -See the PHP documentation for specific format: - * [http://www.php.net/manual/en/ref.pdo-mysql.connection.php MySQL DSN] - * [http://www.php.net/manual/en/ref.pdo-pgsql.connection.php PostgreSQL DSN] - * [http://www.php.net/manual/en/ref.pdo-sqlite.connection.php SQLite DSN] - * [http://www.php.net/manual/en/ref.pdo-oci.connection.php Oracle DSN] - * [http://www.php.net/manual/en/ref.pdo-dblib.connection.php MSSQL DSN] - -Note that some database (e.g. PostgreSQL) specify username and password as part of the DSN while the others specify user and password separately. - -==== and ==== - -Specifies credentials for databases that specify username and password separately (e.g. MySQL, Oracle). - -{{{ -#!xml - - - - - - mysql:host=localhost;dbname=bookstore - test - testpass -}}} - -==== ==== - -Specify any options which ''must'' be specified when the PDO connection is created. For example, the ATTR_PERSISTENT option must be specified at object creation time. - -See the [http://www.php.net/pdo PDO documentation] for more details. - -{{{ -#!xml - - - - - - - - - -}}} - -==== ==== - -`` are similar to ``; the difference is that options specified in `` are set after the PDO object has been created. These are set using the [http://us.php.net/PDO-setAttribute PDO->setAttribute()] method. - -In addition to the standard attributes that can be set on the PDO object, there are also the following Propel-specific attributes that change the behavior of the PropelPDO connection: - -|| '''Attribute constant''' || '''Valid Values (Default)''' || '''Description''' || -|| PropelPDO::PROPEL_ATTR_CACHE_PREPARES || true/false (false) || Whether to have the PropelPDO connection cache the PDOStatement prepared statements. This will improve performance if you are executing the same query multiple times by your script (within a single request / script run). || - -''Note that attributes in the XML can be specified with or without the PDO:: (or PropelPDO::) constant prefix.'' - -{{{ -#!xml - - - - - - - - - - - -}}} - -'''Tip''': If you are using MySQL and get the following error : "SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active", you can try adding the following attribute: - -{{{ - -}}} - -==== ==== - -Settings are Propel-specific options used to further configure the connection -- or perform other user-defined initialization tasks. - -Currently supported settings are: - * charset - * queries - -===== charset ===== - -Specifies the character set to use. Currently you must specify the charset in the way that is understood by your RDBMS. Also note that not all database systems support specifying charset (e.g. SQLite must be compiled with specific charset support). Specifying this option will likely result in an exception if your database doesn't support the specified charset. - -{{{ -#!xml - - - - - - - - utf8 - -}}} - -===== queries ===== - -Specifies any SQL statements to run when the database connection is initialized. This can be used for any environment setup or db initialization you would like to perform. These statements will be executed with every Propel initialization (e.g. every PHP script load). - -{{{ -#!xml - - - - - - - - - set search_path myschema, public - INSERT INTO BAR ('hey', 'there') - - -}}} - -=== === - -{{{ -#!xml - - - - - -}}} - -The `` tag groups slave `` elements which provide support for configuring slave db servers -- when using Propel in a master-slave replication environment. See the [wiki:Documentation/1.5/Master-Slave Master-Slave documentation] for more information. The nested `` elements are configured the same way as the top-level `` element is configured. - -=== === - -The optional `` element may be provided to pass additional logging configuration options to DebugPDO. Note that these settings have no effect unless DebugPDO has been selected in [1.5/RuntimeConfiguration#debugpdo `runtime-conf.xml`] as the PDO connection class. See the [wiki:Documentation/1.5/07-Logging Logging documentation] for more information on configuring DebugPDO. \ No newline at end of file diff --git a/airtime_mvc/library/propel/docs/reference/Schema.txt b/airtime_mvc/library/propel/docs/reference/Schema.txt deleted file mode 100644 index b130c03fb..000000000 --- a/airtime_mvc/library/propel/docs/reference/Schema.txt +++ /dev/null @@ -1,398 +0,0 @@ -= Database Schema = - -[[PageOutline]] - -The schema for `schema.xml` contains a small number of elements with required and optional attributes. The Propel generator contains a [source:branches/1.5/generator/resources/dtd/database.dtd DTD] that can be used to validate your `schema.xml` document. Also, when you build your SQL and OM, the Propel generator will automatically validate your `schema.xml` file using a highly-detailed [source:branches/1.5/generator/resources/xsd/database.xsd XSD]. - -== At-a-Glance == - -The hierarchical tree relationship for the elements is: - -{{{ -#!xml - - -
- - - - - - - - - - - - - -
-
-}}} - -**Tip**: If you use an IDE supporting autocompletion in XML documents, you can take advantage of the XSD describing the `schema.xml` syntax to suggest elements and attributes as you type. To enable it, add a `xmlns:xsi` and a `xsi:noNamespaceSchemaLocation` attribute to the leading `` tag: - -{{{ -#!xml - -}}} - -== Detailed Reference == - -This page provides an alternate rendering of the Appendix B - Schema Reference from the user's guide. -It spells out in specific detail, just where each attribute or element belongs. - -First, some conventions: - - * Text surrounded by a '''/''' is text that you would provide and is not defined in the language. (i.e. a table name is a good example of this.) - * Optional items are surrounded by '''[''' and ''']''' characters. - * Items where you have an alternative choice have a '''|''' character between them (i.e. true|false) - * Alternative choices may be delimited by '''{''' and '''}''' to indicate that this is the default option, if not overridden elsewhere. - * '''...''' means repeat the previous item. - -=== element === - -Starting with the {{{}}} element. The ''attributes'' and ''elements'' available are: - -{{{ -#!xml - - - - ... - -}}} - -The `package`, `baseClass`, `basePeer`, `defaultPhpNamingMethod`, and `heavyIndexing` attributes are generally optional. -A Database element may include an `` element, or multiple `
` elements. - - * `defaultIdMethod` sets the default id method to use for auto-increment columns. - * `package` specifies the "package" for the generated classes. Classes are created in subdirectories according to the `package` value. - * `namespace` specifies the default namespace that generated model classes will use (PHP 5.3 only). This attribute can be completed or overridden at the table level. - * `baseClass` allows you to specify a default base class that all generated Propel objects should extend (in place of `propel.om.BaseObject`). - * `basePeer` instructs Propel to use a different SQL-generating `BasePeer` class (or sub-class of `BasePeer`) for all generated objects. - * `defaultPhpNamingMethod` the default naming method to use for tables of this database. Defaults to `underscore`, which transforms table names into CamelCase phpNames. - * `heavyIndexing` adds indexes for each component of the primary key (when using composite primary keys). - * `tablePrefix` adds a prefix to all the SQL table names. - -=== element === - -The `` element is pretty simple. It just includes a schema file from somewhere on the file systems. The format is: - -{{{ -#!xml - -}}} - -===
element === - -The `
` element is the most complicated of the usable elements. Its definition looks like this: - -{{{ -#!xml -
- - - ... - - ... - - ... - - ... - - ... -
-}}} - -According to the schema, `name` is the only required attribute. Also, the `idMethod`, `package`, `namespace`, `phpNamingMethod`, `baseClass`, `basePeer`, and `heavyIndexing` attributes all default to what is specified by the `` element. - -==== Description of Attributes ==== - - * `idMethod` sets the id method to use for auto-increment columns. - * `phpName` specifies object model class name. By default, Propel uses a CamelCase version of the table name as phpName. - * `package` specifies the "package" (or subdirectory) in which model classes get generated. - * `namespace` specifies the namespace that the generated model classes will use (PHP 5.3 only). If the table namespace starts with a `\`, it overrides the namespace defined in the `` tag; otherwise, the actual table namespace is the concatenation of the database namespace and the table namespace. - * `skipSql` instructs Propel not to generate DDL SQL for the specified table. This can be used together with `readOnly` for supperting VIEWS in Propel. - * `abstract` Whether the generated ''stub'' class will be abstract (e.g. if you're using inheritance) - * `phpNamingMethod` the naming method to use. Defaults to `underscore`, which transforms the table name into a CamelCase phpName. - * `baseClass` allows you to specify a class that the generated Propel objects should extend ({{{in place of propel.om.BaseObject}}}). - * `basePeer` instructs Propel to use a different SQL-generating `BasePeer` class (or sub-class of `BasePeer`). - * `heavyIndexing` adds indexes for each component of the primary key (when using composite primary keys). - * `readOnly` suppresses the mutator/setter methods, save() and delete() methods. - * `treeMode` is used to indicate that this table is part of a node tree. Currently the only supported values are "!NestedSet" (see [wiki:Documentation/1.5/Behaviors/nested_set]) and "!MaterializedPath" (deprecated). - * `reloadOnInsert` is used to indicate that the object should be reloaded from the database when an INSERT is performed. This is useful if you have triggers (or other server-side functionality like column default expressions) that alters the database row on INSERT. - * `reloadOnUpdate` is used to indicate that the object should be reloaded from the database when an UPDATE is performed. This is useful if you have triggers (or other server-side functionality like column default expressions) that alters the database row on UPDATE. - * `allowPkInsert` can be used if you want to define the primary key of a new object being inserted. By default if idMethod is "native", Propel would throw an exception. However, in some cases this feature is useful, for example if you do some replication of data in an master-master environment. It defaults to false. - -=== element === - -{{{ -#!xml - - [] - -}}} - -==== Description of Attributes ==== - - * {{{defaultValue}}} The default value that the object will have for this column in the PHP instance after creating a "new Object". This value is always interpreted as a string. - * {{{defaultExpr}}} The default value for this column as expressed in SQL. This value is used solely for the "sql" target which builds your database from the schema.xml file. The defaultExpr is the SQL expression used as the "default" for the column. - * {{{primaryString}}} A column defined as primary string serves as default value for a `__toString()` method in the generated Propel object. - -=== element === - -To link a column to another table use the following syntax: - -{{{ -#!xml - - - -}}} - -==== Description of Attributes ==== - - * {{{defaultJoin}}} This affects the default join type used in the generated `joinXXX()` methods in the model query class. Propel uses an INNER JOIN for foreign keys attached to a required column, and a LEFT JOIN for foreign keys attached to a non-required column, but you can override this in the foreign key element. - -=== element === - -To create an index on one or more columns, use the following syntax: - -{{{ -#!xml - - - ... - -}}} - -In some cases your RDBMS may require you to specify an index size. - -=== element === - -To create a unique index on one or more columns, use the following syntax: - -{{{ -#!xml - - - ... - -}}} - -In some cases your RDBMS may require you to specify an index size for unique indexes. - -=== element === - -If you are using a database that uses sequences for auto-increment columns (e.g. PostgreSQL or Oracle), you can customize the name of the sequence using the tag: - -{{{ -#!xml - -}}} - -== Column Types == - -Here are the Propel column types with some example mappings to native database and PHP types. There are also several ways to customize the mapping between these types. - -=== Text Types === - -||'''Propel Type'''||'''Desc'''||'''Example Default DB Type (MySQL)'''||'''Default PHP Native Type'''|| -||CHAR||Fixed-lenght character data||CHAR||string|| -||VARCHAR||Variable-lenght character data||VARCHAR||string|| -||LONGVARCHAR||Long variable-length character data||TEXT||string|| -||CLOB||Character LOB (locator object)||LONGTEXT||string|| - -=== Numeric Types === - -||'''Propel Type'''||'''Desc'''||'''Example Default DB Type (MySQL)'''||'''Default PHP Native Type'''|| -||NUMERIC||Numeric data||DECIMAL||string (PHP int is limited)|| -||DECIMAL||Decimal data||DECIMAL||string (PHP int is limited)|| -||TINYINT||Tiny integer ||TINYINT||int|| -||SMALLINT||Small integer ||SMALLINT||int|| -||INTEGER||Integer||INTEGER||int|| -||BIGINT||Large integer||BIGINT||string (PHP int is limited)|| -||REAL||Real number||REAL||double|| -||FLOAT||Floating point number||FLOAT||double|| -||DOUBLE||Floating point number||DOUBLE||double|| - -=== Binary Types === - -||'''Propel Type'''||'''Desc'''||'''Example Default DB Type (MySQL)'''||'''Default PHP Native Type'''|| -||BINARY||Fixed-length binary data||BLOB||double|| -||VARBINARY||Variable-length binary data||MEDIUMBLOB||double|| -||LONGVARBINARY||Long variable-length binary data||LONGBLOB||double|| -||BLOB||Binary LOB (locator object)||LONGBLOB||string|| - -=== Temporal (Date/Time) Types === - - -||'''Propel Type'''||'''Desc'''||'''Example Default DB Type (MySQL)'''||'''Default PHP Native Type'''|| -||DATE||Date (e.g. YYYY-MM-DD)||DATE||DateTime object|| -||TIME||Time (e.g. HH:MM:SS)||TIME||DateTime object|| -||TIMESTAMP||Date + time (e.g. YYYY-MM-DD HH:MM:SS)||TIMESTAMP||DateTime object|| - -==== Legacy Temporal Types ==== - -The following Propel 1.2 types are still supported, but are no longer needed with Propel 1.3. - -||'''Propel Type'''||'''Desc'''||'''Example Default DB Type (MySQL)'''||'''Default PHP Native Type'''|| -||BU_DATE||Pre-/post-epoch date (e.g. 1201-03-02)||DATE||DateTime object|| -||BU_TIMESTAMP||Pre-/post-epoch Date + time (e.g. 1201-03-02 12:33:00)||TIMESTAMP||DateTime object|| - -== Customizing Mappings == - -=== Specify Column Attributes === - -You can change the way that Propel maps its own types to native SQL types or to PHP types by overriding the values for a specific column. - -For example: - -(Overriding PHP type) -{{{ -#!xml - -}}} - -(Overriding SQL type) -{{{ -#!xml - -}}} - -=== Adding Vendor Info === - -Propel supports database-specific elements in the schema (currently only for MySQL). This "vendor" parameters affect the generated SQL. To add vendor data, add a `` tag with a `type` attribute specifying the target database vendor. In the `` tag, add `` tags with a `name` and a `value` attribue. For instance: - -{{{ -#!xml - - - - - -
-}}} - -This will change the generated SQL table creation to look like: - -{{{ -#!sql -CREATE TABLE book - () - ENGINE = InnoDB - DEFAULT CHARACTER SET utf8; -}}} - -Propel supports the following vendor parameters for MySQL: - -{{{ -Name | Example values ------------------|--------------- -// in element -Engine | MYISAM (default), BDB, HEAP, ISAM, InnoDB, MERGE, MRG_MYISAM -Charset | utf8, latin1, etc. -Collate | utf8_unicode_ci, latin1_german1_ci, etc. -Checksum | 0, 1 -Pack_Keys | 0, 1, DEFAULT -Delay_key_write | 0, 1 -// in element -Charset | utf8, latin1, etc. -Collate | utf8_unicode_ci, latin1_german1_ci, etc. -// in element -Index_type | FULLTEXT -}}} - -=== Using Custom Platform === - -For overriding the mapping between Propel types and native SQL types, you can create your own Platform class and override the mapping. - -For example: - -{{{ -#!php -setSchemaDomainMapping(new Domain(PropelTypes::NUMERIC, "DECIMAL")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, "TEXT")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::BINARY, "BLOB")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::VARBINARY, "MEDIUMBLOB")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARBINARY, "LONGBLOB")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::BLOB, "LONGBLOB")); - $this->setSchemaDomainMapping(new Domain(PropelTypes::CLOB, "LONGTEXT")); - } -} -}}} - -You must then specify that mapping in the {{{build.properties}}} for your project: - -{{{ -propel.platform.class = propel.engine.platform.${propel.database}Platform -}}} diff --git a/airtime_mvc/library/propel/generator/bin/phing.php b/airtime_mvc/library/propel/generator/bin/phing.php new file mode 100755 index 000000000..c6a4223fc --- /dev/null +++ b/airtime_mvc/library/propel/generator/bin/phing.php @@ -0,0 +1,65 @@ +#!/usr/bin/env php + \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" + # try to find Propel + if [ -d /opt/propel/generator ] ; then + PROPEL_GEN_HOME=/opt/propel/generator fi - done - cd "$saveddir" - - PROPEL_GEN_HOME=`dirname "$PRG"`/.. + if [ -d "${HOME}/opt/propel/generator" ] ; then + PROPEL_GEN_HOME="${HOME}/opt/propel/generator" + fi - # make it fully qualified - PROPEL_GEN_HOME=`cd "$PROPEL_GEN_HOME" && pwd` - - # make it available in PHP via getenv("PROPEL_GEN_HOME") - export PROPEL_GEN_HOME - + if [ -d "/usr/local/propel/generator" ] ; then + PROPEL_GEN_HOME="/usr/local/propel/generator" + fi + + if [ -d "${HOME}/usr/propel/generator" ] ; then + PROPEL_GEN_HOME="${HOME}/usr/propel/generator" + fi + + ## resolve links - the script name may be a link to phing's home + SOURCE="${BASH_SOURCE[0]}" + PRG="$( dirname "$SOURCE" )" + while [ -h "$SOURCE" ] + do + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$PRG/$SOURCE" + PRG="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + done + PRG="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + + if [ -d "`dirname $PRG`" ] ; then + PROPEL_GEN_HOME="`dirname $PRG`" + fi + + export PROPEL_GEN_HOME +fi + +if [ -f "$PROPEL_GEN_HOME/bin/phing.php" ] ; then + export PHING_COMMAND="$PROPEL_GEN_HOME/bin/phing.php" fi if [ -z "$PHING_COMMAND" ] ; then - # echo "WARNING: PHING_COMMAND environment not set. (Assuming phing on PATH)" - export PHING_COMMAND="phing" + export PHING_COMMAND="phing" fi if [ $# = 1 ] ; then - $PHING_COMMAND -f $PROPEL_GEN_HOME/build.xml -Dusing.propel-gen=true -Dproject.dir=$saveddir $* + "$PHING_COMMAND" -f "$PROPEL_GEN_HOME/build.xml" -Dusing.propel-gen=true -Dproject.dir=$saveddir $* else - $PHING_COMMAND -f $PROPEL_GEN_HOME/build.xml -Dusing.propel-gen=true -Dproject.dir=$* + "$PHING_COMMAND" -f "$PROPEL_GEN_HOME/build.xml" -Dusing.propel-gen=true -Dproject.dir=$* fi diff --git a/airtime_mvc/library/propel/generator/bin/propel-gen.bat b/airtime_mvc/library/propel/generator/bin/propel-gen.bat new file mode 100755 index 000000000..b6607f6b1 --- /dev/null +++ b/airtime_mvc/library/propel/generator/bin/propel-gen.bat @@ -0,0 +1,32 @@ +@echo off + +rem ********************************************************************* +rem ** The Propel generator convenience script for Windows based systems +rem ** $Id$ +rem ********************************************************************* + +rem This script will do the following: +rem - check for PHING_COMMAND env, if found, use it. +rem - if not found detect php, if found use it, otherwise err and terminate +rem - check for PROPEL_GEN_HOME env, if found use it +rem - if not found error and leave + +if "%OS%"=="Windows_NT" @setlocal + +rem %~dp0 is expanded pathname of the current script under NT +set DEFAULT_PROPEL_GEN_HOME=%~dp0.. + +if "%PROPEL_GEN_HOME%" == "" set PROPEL_GEN_HOME=%DEFAULT_PROPEL_GEN_HOME% +set DEFAULT_PROPEL_GEN_HOME= + +if "%PHING_COMMAND%" == "" set PHING_COMMAND=phing.bat + +set nbArgs=0 +for %%x in (%*) do Set /A nbArgs+=1 +if %nbArgs% leq 1 ( + %PHING_COMMAND% -f "%PROPEL_GEN_HOME%\build.xml" -Dusing.propel-gen=true -Dproject.dir="%CD%" %* +) else ( + %PHING_COMMAND% -f "%PROPEL_GEN_HOME%\build.xml" -Dusing.propel-gen=true -Dproject.dir=%* +) + +if "%OS%"=="Windows_NT" @endlocal diff --git a/airtime_mvc/library/propel/generator/build-propel.xml b/airtime_mvc/library/propel/generator/build-propel.xml index 036544248..1026b25ab 100644 --- a/airtime_mvc/library/propel/generator/build-propel.xml +++ b/airtime_mvc/library/propel/generator/build-propel.xml @@ -1,513 +1,645 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ATTENTION: It appears you are using PostgreSQL and you have identifier-quoting turned on. - It is suggested that you disable identifier quoting when using PostgreSQL -- especially if you - have case-sensitive columns in your database. - - To disable identifier quoting, add the following property to your build.properties (or specify - it using -D on commandline): - - propel.disableIdentifierQuoting=true - - You can ignore this warning if you understand the issues related to case-sensitivity and Propel's - DDL-only implementation of identifier quoting. - - - - - - - - - - - - ATTENTION: It appears you are using the mysqli driver. - - This driver is no longer supported by Propel because Propel now uses PDO for database connections. - Please use mysqli driver instead. - Use 'mysql' instead of 'mysqli' for your propel.database property. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - + - - - - - - + + + + + + + + - + + - - - - - + - + + + + - + + + + + + + + + + + + + + + + + + + + + - - - + - + + + + - - - - - + + + + + + - - - - - + + + + + - - - + + + + + + + - + + + + + - - - - - + + + + + + + + + ATTENTION: It appears you are using PostgreSQL and you have identifier-quoting turned on. + It is suggested that you disable identifier quoting when using PostgreSQL -- especially if you + + have case-sensitive columns in your database. + + To disable identifier quoting, add the following property to your build.properties (or specify + + it using -D on commandline): + + propel.disableIdentifierQuoting=true + + You can ignore this warning if you understand the issues related to case-sensitivity and + Propel's + + DDL-only implementation of identifier quoting. + + + - - - - - + + + + + + + + ATTENTION: It appears you are using the mysqli driver. + + This driver is no longer supported by Propel because Propel now uses PDO for database + connections. + + Please use mysqli driver instead. + Use 'mysql' instead of 'mysqli' for your propel.database property. + + + - - - - - + - + + + + + - - - - - + - - - - - - + - - - - - - + + + + + + - - - - - + + + + + + - + + + + + - - - - - - + - - - + - - - - - + - - + + --> + - + + + - - - - - - - - Output file: ${propel.runtime.phpconf.file} - XMLFile: ${propel.conf.dir}/${propel.runtime.conf.file} + - - - + + - + + + - + - - - - - - + + + + + - - - - - + + - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/airtime_mvc/library/propel/generator/build.properties-sample b/airtime_mvc/library/propel/generator/build.properties-sample index e94312a21..a6955476a 100644 --- a/airtime_mvc/library/propel/generator/build.properties-sample +++ b/airtime_mvc/library/propel/generator/build.properties-sample @@ -5,8 +5,8 @@ # ------------------------------------------------------------------- # This file contains some example properties. Ideally properties # should be specified in the project-specific build.properties file; -# however, this file can be used to specify non-default properties -# that you would like to use accross all of your Propel projects. +# however, this file can be used to specify non-default properties +# that you would like to use across all of your Propel projects. # ------------------------------------------------------------------- # @@ -19,15 +19,15 @@ propel.home = . # ------------------------------------------------------------------- # This is the name of your Propel project. The name of your Propel # project is used (by default) to determine where the generator will -# find needed configuration files and will place resuilting build -# files. E.g. if your project is named 'killerapp', Propel will +# find needed configuration files and will place resulting build +# files. E.g. if your project is named 'killerapp', Propel will # look here for schema.xml and runtime-conf.xml files: -# +# # projects/killerapp/ # # ------------------------------------------------------------------- -# You can set this here, but it's preferrable to set this in a +# You can set this here, but it's preferable to set this in a # project-specific build.properties file. # # propel.project = bookstore @@ -43,7 +43,7 @@ propel.home = . # mssql, mysql, oracle, pgsql, sqlite # ------------------------------------------------------------------- -# You can set this here, but it's preferrable to set this in a +# You can set this here, but it's preferable to set this in a # project-specific build.properties file. # # propel.database = mysql @@ -72,19 +72,19 @@ propel.home = . # A string to pre-pend to the file names of base data and peer objects. # # complexObjectModel -# If true, Propel generates data objects with collection support and -# methods to easily retreive foreign key relationships. +# If true, Propel generates data objects with collection support and +# methods to easily retrieve foreign key relationships. # # targetPackage -# Sets the PHP "package" the om files will generated to, e.g. +# Sets the PHP "package" the om files will generated to, e.g. # "com.company.project.om". # # targetPlatform -# Sets whether Propel is building classes for php5 (default) +# Sets whether Propel is building classes for php5 (default) # or php4 (experimental). # # packageObjectModel -# Sets whether Propel is packaging ObjectModel fro several +# Sets whether Propel is packaging ObjectModel for several # [package].schema.xml files. The # attribute has to be set then. (warning: this is experimental!) # @@ -111,10 +111,10 @@ propel.packageObjectModel = false # # ------------------------------------------------------------------- # PDO connection settings. These connection settings are used by -# build tagets that perform database operations (e.g. 'insert-sql', +# build targets that perform database operations (e.g. 'insert-sql', # 'reverse'). # -# You can set them here, but it's preferrable to set these properties +# You can set them here, but it's preferable to set these properties # in a project-specific build.properties file. # @@ -124,19 +124,19 @@ propel.packageObjectModel = false # propel.database.driver = creole.drivers.sqlite.SQLiteConnection # Note that if you do not wish to specify the database (e.g. if you -# are using multiple databses) you can use the @DB@ token which +# are using multiple databases) you can use the @DB@ token which # will be replaced with a database at runtime. # # propel.database.url = mysql:host=$host;dbname=$database -# For MySQL or Oracle, you also need to specify username & password +# For MySQL or Oracle, you also need to specify username & password # propel.database.user = [db username] # propel.database.password = [db password] # Use the URL below to specify a DSN to used to create the database. # Note that this URL should not contain the database name, as you will # get an error if the database does not exist. -# (This does not apply to SQLite since the databse is automatically created +# (This does not apply to SQLite since the database is automatically created # when the connection is made -- if it does not already exist.) # # propel.database.createUrl = mysql:host=$host;dbname=$database @@ -148,29 +148,28 @@ propel.packageObjectModel = false # # ------------------------------------------------------------------- # -# samePhpName -# If true, the reverse task will set the phpName attribute for the +# samePhpName +# If true, the reverse task will set the phpName attribute for the # tables and columns to be the same as SQL name. # -# addVendorInfo -# If true, the reverse task will add vendor specific information -# to the database schema +# addVendorInfo +# If true, the reverse task will add all vendor specific information +# to the database schema. Under `mysql` the `Engine` vendor information +# is always added. # -# addValidators -# Bitfield like option to turn on/off addition of Validator and -# Rule tags to the schema. Uses a boolean syntax like in php.ini. -# Allowed tokens are: -# none add no validators) -# all add all validators) -# maxlength add maxlengths for string type columns) -# maxvalue add maxvalue for numeric columns) -# type add notmatch validators for numeric columns) -# required add required validators for required columns) -# unique add unique validators for unique indexes) -# Allowed operators are: -# & bitwise AND -# | bitwise OR -# ~ bitwise NOT +# addValidators +# List of Validators that the reverse task may add to the schema +# based on database constraints. +# Allowed tokens are: +# none add no validators +# all add all validators +# maxlength add maxlengths for string type columns +# maxvalue add maxvalue for numeric columns +# type add notmatch validators for numeric columns +# required add required validators for required columns +# unique add unique validators for unique indexes +# You can cherry-pick allowed validators by using a comma-separated value, e.g +# maxvalue,type,required # # ------------------------------------------------------------------- @@ -185,7 +184,7 @@ propel.packageObjectModel = false # # ------------------------------------------------------------------- # Some databases provide some configuration options that can be set -# in this script. +# in this script. # # === MySQL # propel.mysql.tableType diff --git a/airtime_mvc/library/propel/generator/build.xml b/airtime_mvc/library/propel/generator/build.xml index 5005dae11..90a8929c0 100644 --- a/airtime_mvc/library/propel/generator/build.xml +++ b/airtime_mvc/library/propel/generator/build.xml @@ -1,184 +1,244 @@ - - + + - - + + - - - - - - + + - - - - - - - - - - - + + + - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - Project name - - + + + + + + + + - - No project.dir was specified, using default path: ./projects/${project} - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - Processing additional properties file: ${additional.properties} - - - - - - - + + + + + + + + + + + + + + + + Project name + + - + + No project.dir was specified, using default path: ./projects/${project} + + - - - + + + + + Processing additional properties file: ${additional.properties} + + + + + + + - + - - - + - - - + - - - + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/airtime_mvc/library/propel/generator/build.xml-local b/airtime_mvc/library/propel/generator/build.xml-local index ff57c3b2b..2113d5a09 100644 --- a/airtime_mvc/library/propel/generator/build.xml-local +++ b/airtime_mvc/library/propel/generator/build.xml-local @@ -1,30 +1,30 @@ - + - + @@ -51,21 +51,21 @@ - + - + - - + - + - + - - - + + + - - - + + + - - - - + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - - - - - - Propel version for package + + + + + + + + + + Propel version for package - - + + - + - - - ----------------------------- - | Creating directory layout | - ----------------------------- + + + ----------------------------- + | Creating directory layout | + ----------------------------- - - + + - - - - + + + + - - - - - - - + + + - - - - - - - - + + + - + + + + + + - - + - ----------------------------- - | Creating PEAR package.xml | - ----------------------------- - + - + + - - - + ----------------------------- + | Creating PEAR package.xml | + ----------------------------- + - + - + + + - - - ----------------------------- - | Creating tar.gz package | - ----------------------------- - - - - + - \ No newline at end of file + + + + + ----------------------------- + | Creating tar.gz package | + ----------------------------- + + + + + + diff --git a/airtime_mvc/library/propel/generator/pear/build.properties b/airtime_mvc/library/propel/generator/pear/build.properties index 0f6c76b90..79a2e5bf5 100644 --- a/airtime_mvc/library/propel/generator/pear/build.properties +++ b/airtime_mvc/library/propel/generator/pear/build.properties @@ -1,5 +1,2 @@ # In this file you can define any properties taht you want to affect # all projects built using the propel-gen script on this system -# -# See http://www.propelorm.org/wiki/Documentation/1.5/BuildConfiguration -# for a list of available properties. diff --git a/airtime_mvc/library/propel/generator/pear/pear-build.xml b/airtime_mvc/library/propel/generator/pear/pear-build.xml index dbc84eebd..f989f3763 100644 --- a/airtime_mvc/library/propel/generator/pear/pear-build.xml +++ b/airtime_mvc/library/propel/generator/pear/pear-build.xml @@ -1,121 +1,168 @@ - - + + - + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - Processing additional properties file: ${additional.properties} - - - - - - - + + + + + Processing additional properties file: ${additional.properties} + + + + + + + - + - - - - + + + + - + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/airtime_mvc/library/propel/generator/pear/pear-propel-gen b/airtime_mvc/library/propel/generator/pear/pear-propel-gen old mode 100755 new mode 100644 diff --git a/airtime_mvc/library/propel/generator/pear/pear-propel-gen.bat b/airtime_mvc/library/propel/generator/pear/pear-propel-gen.bat index 754ea5911..17c704d9f 100644 --- a/airtime_mvc/library/propel/generator/pear/pear-propel-gen.bat +++ b/airtime_mvc/library/propel/generator/pear/pear-propel-gen.bat @@ -8,7 +8,7 @@ ::---------------------------------------------------------------------------------- :: Please set following to the "phing" script. By default this is expected to be :: on your path. (You don't need to modify this file if that is the case.) - + SET phingScript=phing ::--------------------------------------------------------------------------------- diff --git a/airtime_mvc/library/propel/generator/resources/dtd/database.dtd b/airtime_mvc/library/propel/generator/resources/dtd/database.dtd index 1de399e8b..91d813b69 100644 --- a/airtime_mvc/library/propel/generator/resources/dtd/database.dtd +++ b/airtime_mvc/library/propel/generator/resources/dtd/database.dtd @@ -6,175 +6,183 @@ some differences do exist. --> - + nochange - indicates not change is performed. + underscore - Underscores are removed, First letter is + capitalized, first letter after an underscore + is capitalized, the rest of the letters are + converted to lowercase. + phpname - same as underscore, but no letters are converted + to lowercase. + --> - - + + - - + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + diff --git a/airtime_mvc/library/propel/generator/resources/xsd/custom_datatypes.xsd b/airtime_mvc/library/propel/generator/resources/xsd/custom_datatypes.xsd index 12e8327cb..348878df7 100644 --- a/airtime_mvc/library/propel/generator/resources/xsd/custom_datatypes.xsd +++ b/airtime_mvc/library/propel/generator/resources/xsd/custom_datatypes.xsd @@ -1,8 +1,8 @@ - - - - - \ No newline at end of file + + + + + diff --git a/airtime_mvc/library/propel/generator/resources/xsd/database.xsd b/airtime_mvc/library/propel/generator/resources/xsd/database.xsd index a54046efa..fc3815b30 100644 --- a/airtime_mvc/library/propel/generator/resources/xsd/database.xsd +++ b/airtime_mvc/library/propel/generator/resources/xsd/database.xsd @@ -1,862 +1,976 @@ - + also included. --> - + - + - + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - + + + + + + - - - - - - - + + + + + + + - - - + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - + + + + + - - - - - - - - + + + + + - - - - - - + + + + + + + - - - - - - + + + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - + + + + + + - - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - - + + + + - - - - + + + + + + + - - - - - - - + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + - - - - - - - + + + + + + + - - - - - - + + + + + + + - - - - + + + + + + + - - - - - - + + + + + + + - - - - - - - - - The name of the column as it appears in the database. - - - - - - - Name used in PHP code to reference this column (in getters, setters, etc.). Defaults to the name transformed by the phpNamingMethod, which defaults to a CamelCase converter. So by default, a column named 'author_id' receives 'AuthorId' as phpName. - - - - - - - Name used for the class constant corresponding to this column in PHP code. Defaults to the uppercase name, so a column named 'author_id' receives 'AUTHOR_ID' as peerName. - - - - - - - - Visibility for the column accessor method. 'public' by default, also accepts 'protected' and 'private'. - - - - - - - Visibility for the column mutator method. 'public' by default, also accepts 'protected' and 'private'. - - - - - - - Set to true to add a primary key on this column. - - - - - - - Set to true to forbid NULL values. - - - - - - - Any of the Propel supported data types. These types are database-agnostic, and converted to the native database type according to the connection. - - - - - - - Native database column type. - - - - - - - PHP type for te column in PHP code. This column's setter uses type casting with the set php_type; besides, generated phpDoc in the model classes use this attribute for code completion. - - - - - - - Numeric length of the column. - - - - - - - Digits after decimal place - - - - - - - Synonym for defaultValue - - - - - - - The default value that the object will have for this column in the PHP instance after creating a "new Object". This value is always interpreted as a string. See defaultExpr for setting an SQL function as a default value. - - - - - - - The default value for this column as expressed in SQL. This value is used solely for the "sql" target which builds your database from the schema.xml file. The defaultExpr is the SQL expression used as the "default" for the column. - - - - - - - - - - Name of the method used to transform the column name into a phpName. Defaults to 'clean', which Removes any character that is not a letter or a number and capitilizes the first letter of the name, the first letter of each alphanumeric block, and converts the rest of the letters to lowercase. Possible values: any of the PhpNameGenerator CONV_METHOD_XXX constants (clean, underscore, phpName, nochange). - - - - - - - A text description of the column. It gets added to the SQL CREATE table as a comment, and appears in the phpDoc bloc of the related getter and setter methods in the ActiveRecord class. - - - - - - - Set to true to skip this column by default during hydration. That means that this column will be hydrated on demand, using a supplementary query. Mostly useful for LOB columns. - - - - - - - (DEPRECATED) For use with treeMode table attribute. - - - - - - - (DEPRECATED) For use with treeMode table attribute. - - - - - - - (DEPRECATED) For use with treeMode table attribute. - - - - - - - (DEPRECATED) For use with treeMode table attribute. - - - - - - - (DEPRECATED) For use with treeMode table attribute. - - - - - - - A column defined as primary string serves as default value for a `__toString()` method in the generated Propel object. - - - - + + + + + + - - - - - - A reference between a local and a foreign column. Composite foreign keys can have several references. - - - - - - - - - The other table name - - - - - - - Name for this foreign key - - - - - - - Name for the foreign object in methods generated in this class. - - - - - - - Name for this object in methods generated in the foreign class - - - - - - - This affects the default join type used in the generated `joinXXX()` methods in the model query class. Propel uses an INNER JOIN for foreign keys attached to a required column, and a LEFT JOIN for foreign keys attached to a non-required column, but you can override this in the foreign key element. - - - - - - + + + + - - - - - The (absolute or relative to this schema dir name) path to the external schema file. - - - - + + + + + + - + + + + + + + + + The name of the column as it appears in the database. + + + + + + + Name used in PHP code to reference this column (in getters, setters, etc.). Defaults to the name + transformed by the phpNamingMethod, which defaults to a CamelCase converter. So by default, a column + named 'author_id' receives 'AuthorId' as phpName. + + + + + + + Name used for the class constant corresponding to this column in PHP code. Defaults to the uppercase + name, so a column named 'author_id' receives 'AUTHOR_ID' as peerName. + + + + + + + + Visibility for the column accessor method. 'public' by default, also accepts 'protected' and + 'private'. + + + + + + + Visibility for the column mutator method. 'public' by default, also accepts 'protected' and + 'private'. + + + + + + + Set to true to add a primary key on this column. + + + + + + + Set to true to forbid NULL values. + + + + + + + Any of the Propel supported data types. These types are database-agnostic, and converted to the + native database type according to the connection. + + + + + + + Native database column type. + + + + + + + PHP type for the column in PHP code. This column's setter uses type casting with the set php_type; + besides, generated phpDoc in the model classes use this attribute for code completion. + + + + + + + Numeric length of the column. + + + + + + + Digits after decimal place + + + + + + + Synonym for defaultValue + + + + + + + The default value that the object will have for this column in the PHP instance after creating a + "new Object". This value is always interpreted as a string. See defaultExpr for setting an SQL + function as a default value. + + + + + + + The default value for this column as expressed in SQL. This value is used solely for the "sql" + target which builds your database from the schema.xml file. The defaultExpr is the SQL expression + used as the "default" for the column. + + + + + + + + + Name of the method used to transform the column name into a phpName. Defaults to 'clean', which + Removes any character that is not a letter or a number and capitalizes the first letter of the name, + the first letter of each alphanumeric block, and converts the rest of the letters to lowercase. + Possible values: any of the PhpNameGenerator CONV_METHOD_XXX constants (clean, underscore, phpName, + nochange). + + + + + + + A text description of the column. It gets added to the SQL CREATE table as a comment, and appears in + the phpDoc bloc of the related getter and setter methods in the ActiveRecord class. + + + + + + + Set to true to skip this column by default during hydration. That means that this column will be + hydrated on demand, using a supplementary query. Mostly useful for LOB columns. + + + + + + + (DEPRECATED) For use with treeMode table attribute. + + + + + + + (DEPRECATED) For use with treeMode table attribute. + + + + + + + (DEPRECATED) For use with treeMode table attribute. + + + + + + + (DEPRECATED) For use with treeMode table attribute. + + + + + + + (DEPRECATED) For use with treeMode table attribute. + + + + + + + A column defined as primary string serves as default value for a `__toString()` method in the + generated Propel object. + + + + + + + The list of values for an ENUM column, separated by commas + + + + - - - - - - A column of the table - - - - - - - - A foreign key on one or several columns in this table, referencing a foreign table - - - - - - - - An index on one or several columns of the current table - - - - - - - - A unique index on one or several columns of the current table - - - - - - - - If you are using a database that uses sequences for auto-increment columns (e.g. PostgreSQL or Oracle), you can customize the name of the sequence using this tag - - - - - - - - A validator to be executed on a given column at runtime - - - - - - - - A behavior to be added to the current table. Can modify the table structure, as well as modify the runtime code of the generated Model objects linked to this table. Bundled behaviors include alternative_coding_standards, auto_add_pk, timestampable, sluggable, soft_delete, sortable, nested_set, query_cache, and concrete_inheritance. - - - - - - - - table attributes specific to a database vendor. Only supports MySQL specific table attributes for now (Charset, Collate, Checksum, Pack_keys, Delay_key_write). - - - - - - - - - The name of the table as it appears in the database. - - - - - - - The name of the ActiveRecord class generated for this table. Defaults to the name transformed by the phpNamingMethod, which defaults to a CamelCase converter. So by default, a table named 'foo_author' receives 'FooAuthor' as phpName. - - - - - - - The PHP 5.3 namespace to use for the generated model classes. - - - - - - - - Default visibility for column accessor methods. 'public' by default, also accepts 'protected' and 'private'. - - - - - - - Default visibility for column mutator methods. 'public' by default, also accepts 'protected' and 'private'. - - - - - - - Id method to use for auto-increment columns. - - - - - - - Can be used if you want to define the primary key of a new object being inserted. By default if idMethod is "native", Propel would throw an exception. However, in some cases this feature is useful, for example if you do some replication of data in an master-master environment. - - - - - - - Instructs Propel not to generate DDL SQL for the specified table. This can be used together with readOnly for supperting VIEWS in Propel - - - - - - - Suppresses the mutator/setter methods, save() and delete() methods. - - - - - - - Whether the generated stub class will be abstract (e.g. if you're using inheritance) - - - - - - - Allows you to specify a class that the generated Propel objects should extend (in place of propel.om.BaseObject) - - - - - - - Instructs Propel to use a different SQL-generating BasePeer class (or sub-class of BasePeer). - - - - - - - - Specifies the "package" for the generated classes. Classes are created in subdirectories according to the package attribute value. - - - - - - - - Name of the method used to transform the table name into a phpName. Defaults to 'clean', which Removes any character that is not a letter or a number and capitilizes the first letter of the name, the first letter of each alphanumeric block, and converts the rest of the letters to lowercase. Possible values: any of the PhpNameGenerator CONV_METHOD_XXX constants (clean, underscore, phpName, nochange). - - - - - - - Adds indexes for each component of the primary key (when using composite primary keys) - - - - - - - A text description of the table. It gets added to the SQL CREATE table as a comment, and appears in the phpDoc bloc of the related ActiveRecord class. - - - - - - - Used to indicate that this table is part of a node tree. Currently the only supported values are "NestedSet" and "MaterializedPath" (DEPRECATED: use nested_set behavior instead). - - - - - - - Indicate that the object should be reloaded from the database when an INSERT is performed. This is useful if you have triggers (or other server-side functionality like column default expressions) that alters the database row on INSERT. - - - - - - - Indicate that the object should be reloaded from the database when an UPDATE is performed. This is useful if you have triggers (or other server-side functionality like column default expressions) that alters the database row on UPDATE. - - - - - - - Set to true if the current table is a cross-reference table in a many-to-many relationship to allow generation of getter and setter in each of the tables of the relationship. - - - - + + + + + + A reference between a local and a foreign column. Composite foreign keys can have several + references. + + + + + + + + + The other table name + + + + + + + The other schema name + + + + + + + Name for this foreign key + + + + + + + Name for the foreign object in methods generated in this class. + + + + + + + Name for this object in methods generated in the foreign class + + + + + + + This affects the default join type used in the generated `joinXXX()` methods in the model query + class. Propel uses an INNER JOIN for foreign keys attached to a required column, and a LEFT JOIN for + foreign keys attached to a non-required column, but you can override this in the foreign key + element. + + + + + + + + + Instructs Propel not to generate DDL SQL for the specified foreign key. This can be used to support + relationships in the model without an actual foreign key. + + + + - - - - - - Embed an external schema file into the current schema. Accepts absolute and relative schema file paths. - - - - - - - A table using the database connection. - - - - - - - Behavior to be applied to all the database tables - - - - - - - - The name of the table in the database. Propel advocates the use of singular table names. - - - - - - - Default id method to use for auto-increment columns - - - - - - - - Default visibility for column accessor methods. 'public' by default, also accepts 'protected' and 'private'. - - - - - - - Default visibility for column mutator methods. 'public' by default, also accepts 'protected' and 'private'. - - - - - - - Specifies the "package" for the generated classes. Classes are created in subdirectories according to the package attribute value. - - - - - - - The PHP 5.3 namespace to use for the generated model classes of the database. Can be overridden on a per-table basis. - - - - - - - Allows to specify a default base class that all generated Propel objects should extend (in place of propel.om.BaseObject) - - - - - - - Instructs Propel to use a different SQL-generating BasePeer class (or sub-class of BasePeer) for all generated objects - - - - - - - The default naming method to use in this database. - - - - - - - Adds indexes for each component of the primary key (when using composite primary keys) - - - - - - - Adds a prefix to all the SQL table names - - - - + + + + + The (absolute or relative to this schema dir name) path to the external schema file. + + + + + + + + + + + + + A column of the table + + + + + + + + A foreign key on one or several columns in this table, referencing a foreign table + + + + + + + + An index on one or several columns of the current table + + + + + + + + A unique index on one or several columns of the current table + + + + + + + + If you are using a database that uses sequences for auto-increment columns (e.g. PostgreSQL or + Oracle), you can customize the name of the sequence using this tag + + + + + + + + A validator to be executed on a given column at runtime + + + + + + + + A behavior to be added to the current table. Can modify the table structure, as well as modify + the runtime code of the generated Model objects linked to this table. Bundled behaviors include + alternative_coding_standards, auto_add_pk, timestampable, sluggable, soft_delete, sortable, + nested_set, query_cache, and concrete_inheritance. + + + + + + + + table attributes specific to a database vendor. Only supports MySQL specific table attributes + for now (Charset, Collate, Checksum, Pack_keys, Delay_key_write). + + + + + + + + + The name of the table as it appears in the database. + + + + + + + The table's schema for RDBMs supporting multiple schemas per database. + + + + + + + The name of the ActiveRecord class generated for this table. Defaults to the name transformed by the + phpNamingMethod, which defaults to a CamelCase converter. So by default, a table named 'foo_author' + receives 'FooAuthor' as phpName. + + + + + + + The PHP 5.3 namespace to use for the generated model classes. + + + + + + + + Default visibility for column accessor methods. 'public' by default, also accepts 'protected' and + 'private'. + + + + + + + Default visibility for column mutator methods. 'public' by default, also accepts 'protected' and + 'private'. + + + + + + + Id method to use for auto-increment columns. + + + + + + + Can be used if you want to define the primary key of a new object being inserted. By default if + idMethod is "native", Propel would throw an exception. However, in some cases this feature is + useful, for example if you do some replication of data in an master-master environment. + + + + + + + Instructs Propel not to generate DDL SQL for the specified table. This can be used together with + readOnly for supporting VIEWS in Propel + + + + + + + Suppresses the mutator/setter methods, save() and delete() methods. + + + + + + + Whether the generated stub class will be abstract (e.g. if you're using inheritance) + + + + + + + Allows you to specify a class that the generated Propel objects should extend (in place of + propel.om.BaseObject) + + + + + + + Instructs Propel to use a different SQL-generating BasePeer class (or sub-class of BasePeer). + + + + + + + + Specifies the "package" for the generated classes. Classes are created in subdirectories according + to the package attribute value. + + + + + + + + Name of the method used to transform the table name into a phpName. Defaults to 'clean', which + Removes any character that is not a letter or a number and capitalizes the first letter of the name, + the first letter of each alphanumeric block, and converts the rest of the letters to lowercase. + Possible values: any of the PhpNameGenerator CONV_METHOD_XXX constants (clean, underscore, phpName, + nochange). + + + + + + + Adds indexes for each component of the primary key (when using composite primary keys) + + + + + + + A text description of the table. It gets added to the SQL CREATE table as a comment, and appears in + the phpDoc bloc of the related ActiveRecord class. + + + + + + + Used to indicate that this table is part of a node tree. Currently the only supported values are + "NestedSet" and "MaterializedPath" (DEPRECATED: use nested_set behavior instead). + + + + + + + Indicate that the object should be reloaded from the database when an INSERT is performed. This is + useful if you have triggers (or other server-side functionality like column default expressions) + that alters the database row on INSERT. + + + + + + + Indicate that the object should be reloaded from the database when an UPDATE is performed. This is + useful if you have triggers (or other server-side functionality like column default expressions) + that alters the database row on UPDATE. + + + + + + + Set to true if the current table is a cross-reference table in a many-to-many relationship to allow + generation of getter and setter in each of the tables of the relationship. + + + + + + + The default format used to convert objects based on this table to strings. Propel supports by + default the 'XML', 'YAML', 'JSON', and 'CSV' formats, but custom formats are also possible. + + + + + + + + + + + Embed an external schema file into the current schema. Accepts absolute and relative schema file + paths. + + + + + + + A table using the database connection. + + + + + + + Behavior to be applied to all the database tables + + + + + + + + The name of the table in the database. Propel advocates the use of singular table names. + + + + + + + Default id method to use for auto-increment columns + + + + + + + + Default visibility for column accessor methods. 'public' by default, also accepts 'protected' and + 'private'. + + + + + + + Default visibility for column mutator methods. 'public' by default, also accepts 'protected' and + 'private'. + + + + + + + Specifies the "package" for the generated classes. Classes are created in subdirectories according + to the package attribute value. + + + + + + + The PHP 5.3 namespace to use for the generated model classes of the database. Can be overridden on a + per-table basis. + + + + + + + Specify a schema for the tables in this database. Useful for RDBMs which support multiple schemas + per database. + + + + + + + Allows to specify a default base class that all generated Propel objects should extend (in place of + propel.om.BaseObject) + + + + + + + Instructs Propel to use a different SQL-generating BasePeer class (or sub-class of BasePeer) for all + generated objects + + + + + + + The default naming method to use in this database. + + + + + + + Adds indexes for each component of the primary key (when using composite primary keys) + + + + + + + Adds a prefix to all the SQL table names + + + + + + + The default format used to convert objects based on this database to strings. Propel supports by + default the 'XML', 'YAML', 'JSON', and 'CSV' formats, but custom formats are also possible. + + + + diff --git a/airtime_mvc/library/propel/generator/resources/xsl/database.xsl b/airtime_mvc/library/propel/generator/resources/xsl/database.xsl index 81d8217ad..7183d4003 100644 --- a/airtime_mvc/library/propel/generator/resources/xsl/database.xsl +++ b/airtime_mvc/library/propel/generator/resources/xsl/database.xsl @@ -3,290 +3,298 @@ ]> - + - - + + - - - - - native - - - underscore - - - false - - - - - - - + Starts the normalization process + --> + + + + native + + + underscore + + + false + + + + + + + - - - - + + + + + + - - - - - none - - - - - - + + + + + none + + + + + + + + - - - - + + + + - - - - - none - - - - - - + + + + + none + + + + + + + + - - - - + + + + - - - - + + + + + + - - - - + + + + - - -
- - false - - - false - - - - - - - - - - -
- + + + + + false + + + false + + + + + + + + + + +
+
- - - - - none - - - none - - - - - - + + + + + none + + + none + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - default - - - - + + + + + default + + + + - - - - - - - + + + + + + + - - - - - class - - - - + + + + + class + + + + - - - - - - + + + + + + - - - - - - - + + + + + + + - - - - - - + + + + + + - - - - - false - - - false - - - VARCHAR - - - false - - - false - - - 255 - - - - - - + + + + + false + + + false + + + VARCHAR + + + false + + + false + + + 255 + + + + + + - - - - - - + + + + + + diff --git a/airtime_mvc/library/propel/generator/resources/xsl/dbd2propel.xsl b/airtime_mvc/library/propel/generator/resources/xsl/dbd2propel.xsl new file mode 100644 index 000000000..2e67fd2af --- /dev/null +++ b/airtime_mvc/library/propel/generator/resources/xsl/dbd2propel.xsl @@ -0,0 +1,406 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + true + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TIMESTAMP + LONGVARCHAR + BOOLEAN + BLOB + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + restrict + cascade + setnull + restrict + + + +
diff --git a/airtime_mvc/library/propel/generator/stubs/functions.php b/airtime_mvc/library/propel/generator/stubs/functions.php new file mode 100644 index 000000000..2c44363a2 --- /dev/null +++ b/airtime_mvc/library/propel/generator/stubs/functions.php @@ -0,0 +1,10 @@ + + + + + + + ./test/testsuite/ + + + + + + ./runtime/lib/ + ./generator/lib/ + + + diff --git a/airtime_mvc/library/propel/runtime/lib/Propel.php b/airtime_mvc/library/propel/runtime/lib/Propel.php index 6171408e1..b761baf65 100644 --- a/airtime_mvc/library/propel/runtime/lib/Propel.php +++ b/airtime_mvc/library/propel/runtime/lib/Propel.php @@ -22,895 +22,927 @@ * @author Martin Poeschl (Torque) * @author Henning P. Schmiedehausen (Torque) * @author Kurt Schrader (Torque) - * @version $Revision: 1811 $ + * @version $Revision$ * @package propel.runtime */ class Propel { - /** - * The Propel version. - */ - const VERSION = '1.5.2'; - - /** - * A constant for default. - */ - const DEFAULT_NAME = "default"; - - /** - * A constant defining 'System is unusuable' logging level - */ - const LOG_EMERG = 0; - - /** - * A constant defining 'Immediate action required' logging level - */ - const LOG_ALERT = 1; - - /** - * A constant defining 'Critical conditions' logging level - */ - const LOG_CRIT = 2; - - /** - * A constant defining 'Error conditions' logging level - */ - const LOG_ERR = 3; - - /** - * A constant defining 'Warning conditions' logging level - */ - const LOG_WARNING = 4; - - /** - * A constant defining 'Normal but significant' logging level - */ - const LOG_NOTICE = 5; - - /** - * A constant defining 'Informational' logging level - */ - const LOG_INFO = 6; - - /** - * A constant defining 'Debug-level messages' logging level - */ - const LOG_DEBUG = 7; - - /** - * The class name for a PDO object. - */ - const CLASS_PDO = 'PDO'; - - /** - * The class name for a PropelPDO object. - */ - const CLASS_PROPEL_PDO = 'PropelPDO'; - - /** - * The class name for a DebugPDO object. - */ - const CLASS_DEBUG_PDO = 'DebugPDO'; - - /** - * Constant used to request a READ connection (applies to replication). - */ - const CONNECTION_READ = 'read'; - - /** - * Constant used to request a WRITE connection (applies to replication). - */ - const CONNECTION_WRITE = 'write'; - - /** - * @var string The db name that is specified as the default in the property file - */ - private static $defaultDBName; - - /** - * @var array The global cache of database maps - */ - private static $dbMaps = array(); - - /** - * @var array The cache of DB adapter keys - */ - private static $adapterMap = array(); - - /** - * @var array Cache of established connections (to eliminate overhead). - */ - private static $connectionMap = array(); - - /** - * @var PropelConfiguration Propel-specific configuration. - */ - private static $configuration; - - /** - * @var bool flag to set to true once this class has been initialized - */ - private static $isInit = false; - - /** - * @var Log optional logger - */ - private static $logger = null; - - /** - * @var string The name of the database mapper class - */ - private static $databaseMapClass = 'DatabaseMap'; - - /** - * @var bool Whether the object instance pooling is enabled - */ - private static $instancePoolingEnabled = true; - - /** - * @var bool For replication, whether to force the use of master connection. - */ - private static $forceMasterConnection = false; - - /** - * @var string Base directory to use for autoloading. Initialized in self::initBaseDir() - */ - protected static $baseDir; - - /** - * @var array A map of class names and their file paths for autoloading - */ - protected static $autoloadMap = array( - - 'DBAdapter' => 'adapter/DBAdapter.php', - 'DBMSSQL' => 'adapter/DBMSSQL.php', - 'MssqlPropelPDO' => 'adapter/MSSQL/MssqlPropelPDO.php', - 'MssqlDebugPDO' => 'adapter/MSSQL/MssqlDebugPDO.php', - 'MssqlDateTime' => 'adapter/MSSQL/MssqlDateTime.class.php', - 'DBMySQL' => 'adapter/DBMySQL.php', - 'DBMySQLi' => 'adapter/DBMySQLi.php', - 'DBNone' => 'adapter/DBNone.php', - 'DBOracle' => 'adapter/DBOracle.php', - 'DBPostgres' => 'adapter/DBPostgres.php', - 'DBSQLite' => 'adapter/DBSQLite.php', - 'DBSybase' => 'adapter/DBSybase.php', - - 'PropelArrayCollection' => 'collection/PropelArrayCollection.php', - 'PropelCollection' => 'collection/PropelCollection.php', - 'PropelObjectCollection' => 'collection/PropelObjectCollection.php', - 'PropelOnDemandCollection' => 'collection/PropelOnDemandCollection.php', - 'PropelOnDemandIterator' => 'collection/PropelOnDemandIterator.php', - - 'PropelConfiguration' => 'config/PropelConfiguration.php', - 'PropelConfigurationIterator' => 'config/PropelConfigurationIterator.php', - - 'PropelPDO' => 'connection/PropelPDO.php', - 'DebugPDO' => 'connection/DebugPDO.php', - 'DebugPDOStatement' => 'connection/DebugPDOStatement.php', - - 'PropelException' => 'exception/PropelException.php', - - 'ModelWith' => 'formatter/ModelWith.php', - 'PropelArrayFormatter' => 'formatter/PropelArrayFormatter.php', - 'PropelFormatter' => 'formatter/PropelFormatter.php', - 'PropelObjectFormatter' => 'formatter/PropelObjectFormatter.php', - 'PropelOnDemandFormatter' => 'formatter/PropelOnDemandFormatter.php', - 'PropelStatementFormatter' => 'formatter/PropelStatementFormatter.php', - - 'BasicLogger' => 'logger/BasicLogger.php', - 'MojaviLogAdapter' => 'logger/MojaviLogAdapter.php', - - 'ColumnMap' => 'map/ColumnMap.php', - 'DatabaseMap' => 'map/DatabaseMap.php', - 'TableMap' => 'map/TableMap.php', - 'RelationMap' => 'map/RelationMap.php', - 'ValidatorMap' => 'map/ValidatorMap.php', - - 'BaseObject' => 'om/BaseObject.php', - 'NodeObject' => 'om/NodeObject.php', - 'Persistent' => 'om/Persistent.php', - 'PreOrderNodeIterator' => 'om/PreOrderNodeIterator.php', - 'NestedSetPreOrderNodeIterator' => 'om/NestedSetPreOrderNodeIterator.php', - 'NestedSetRecursiveIterator' => 'om/NestedSetRecursiveIterator.php', - - 'Criteria' => 'query/Criteria.php', - 'Criterion' => 'query/Criterion.php', - 'CriterionIterator' => 'query/CriterionIterator.php', - 'Join' => 'query/Join.php', - 'ModelCriteria' => 'query/ModelCriteria.php', - 'ModelCriterion' => 'query/ModelCriterion.php', - 'ModelJoin' => 'query/ModelJoin.php', - 'PropelQuery' => 'query/PropelQuery.php', - - 'BasePeer' => 'util/BasePeer.php', - 'NodePeer' => 'util/NodePeer.php', - 'PeerInfo' => 'util/PeerInfo.php', - 'PropelAutoloader' => 'util/PropelAutoloader.php', - 'PropelColumnTypes' => 'util/PropelColumnTypes.php', - 'PropelConditionalProxy' => 'util/PropelConditionalProxy.php', - 'PropelModelPager' => 'util/PropelModelPager.php', - 'PropelPager' => 'util/PropelPager.php', - 'PropelDateTime' => 'util/PropelDateTime.php', - - 'BasicValidator' => 'validator/BasicValidator.php', - 'MatchValidator' => 'validator/MatchValidator.php', - 'MaxLengthValidator' => 'validator/MaxLengthValidator.php', - 'MaxValueValidator' => 'validator/MaxValueValidator.php', - 'MinLengthValidator' => 'validator/MinLengthValidator.php', - 'MinValueValidator' => 'validator/MinValueValidator.php', - 'NotMatchValidator' => 'validator/NotMatchValidator.php', - 'RequiredValidator' => 'validator/RequiredValidator.php', - 'UniqueValidator' => 'validator/UniqueValidator.php', - 'ValidValuesValidator' => 'validator/ValidValuesValidator.php', - 'ValidationFailed' => 'validator/ValidationFailed.php', - ); - - /** - * Initializes Propel - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function initialize() - { - if (self::$configuration === null) { - throw new PropelException("Propel cannot be initialized without a valid configuration. Please check the log files for further details."); - } - - self::configureLogging(); - - // reset the connection map (this should enable runtime changes of connection params) - self::$connectionMap = array(); - - if (isset(self::$configuration['classmap']) && is_array(self::$configuration['classmap'])) { - PropelAutoloader::getInstance()->addClassPaths(self::$configuration['classmap']); - PropelAutoloader::getInstance()->register(); - } - - self::$isInit = true; - } - - /** - * Configure Propel a PHP (array) config file. - * - * @param string Path (absolute or relative to include_path) to config file. - * - * @throws PropelException If configuration file cannot be opened. - * (E_WARNING probably will also be raised by PHP) - */ - public static function configure($configFile) - { - $configuration = include($configFile); - if ($configuration === false) { - throw new PropelException("Unable to open configuration file: " . var_export($configFile, true)); - } - self::setConfiguration($configuration); - } - - /** - * Configure the logging system, if config is specified in the runtime configuration. - */ - protected static function configureLogging() - { - if (self::$logger === null) { - if (isset(self::$configuration['log']) && is_array(self::$configuration['log']) && count(self::$configuration['log'])) { - include_once 'Log.php'; // PEAR Log class - $c = self::$configuration['log']; - $type = isset($c['type']) ? $c['type'] : 'file'; - $name = isset($c['name']) ? $c['name'] : './propel.log'; - $ident = isset($c['ident']) ? $c['ident'] : 'propel'; - $conf = isset($c['conf']) ? $c['conf'] : array(); - $level = isset($c['level']) ? $c['level'] : PEAR_LOG_DEBUG; - self::$logger = Log::singleton($type, $name, $ident, $conf, $level); - } // if isset() - } - } - - /** - * Initialization of Propel a PHP (array) configuration file. - * - * @param string $c The Propel configuration file path. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function init($c) - { - self::configure($c); - self::initialize(); - } - - /** - * Determine whether Propel has already been initialized. - * - * @return bool True if Propel is already initialized. - */ - public static function isInit() - { - return self::$isInit; - } - - /** - * Sets the configuration for Propel and all dependencies. - * - * @param mixed The Configuration (array or PropelConfiguration) - */ - public static function setConfiguration($c) - { - if (is_array($c)) { - if (isset($c['propel']) && is_array($c['propel'])) { - $c = $c['propel']; - } - $c = new PropelConfiguration($c); - } - self::$configuration = $c; - } - - /** - * Get the configuration for this component. - * - * @param int - PropelConfiguration::TYPE_ARRAY: return the configuration as an array - * (for backward compatibility this is the default) - * - PropelConfiguration::TYPE_ARRAY_FLAT: return the configuration as a flat array - * ($config['name.space.item']) - * - PropelConfiguration::TYPE_OBJECT: return the configuration as a PropelConfiguration instance - * @return mixed The Configuration (array or PropelConfiguration) - */ - public static function getConfiguration($type = PropelConfiguration::TYPE_ARRAY) - { - return self::$configuration->getParameters($type); - } - - /** - * Override the configured logger. - * - * This is primarily for things like unit tests / debugging where - * you want to change the logger without altering the configuration file. - * - * You can use any logger class that implements the propel.logger.BasicLogger - * interface. This interface is based on PEAR::Log, so you can also simply pass - * a PEAR::Log object to this method. - * - * @param object The new logger to use. ([PEAR] Log or BasicLogger) - */ - public static function setLogger($logger) - { - self::$logger = $logger; - } - - /** - * Returns true if a logger, for example PEAR::Log, has been configured, - * otherwise false. - * - * @return bool True if Propel uses logging - */ - public static function hasLogger() - { - return (self::$logger !== null); - } - - /** - * Get the configured logger. - * - * @return object Configured log class ([PEAR] Log or BasicLogger). - */ - public static function logger() - { - return self::$logger; - } - - /** - * Logs a message - * If a logger has been configured, the logger will be used, otherwrise the - * logging message will be discarded without any further action - * - * @param string The message that will be logged. - * @param string The logging level. - * - * @return bool True if the message was logged successfully or no logger was used. - */ - public static function log($message, $level = self::LOG_DEBUG) - { - if (self::hasLogger()) { - $logger = self::logger(); - switch ($level) { - case self::LOG_EMERG: - return $logger->log($message, $level); - case self::LOG_ALERT: - return $logger->alert($message); - case self::LOG_CRIT: - return $logger->crit($message); - case self::LOG_ERR: - return $logger->err($message); - case self::LOG_WARNING: - return $logger->warning($message); - case self::LOG_NOTICE: - return $logger->notice($message); - case self::LOG_INFO: - return $logger->info($message); - default: - return $logger->debug($message); - } - } - return true; - } - - /** - * Returns the database map information. Name relates to the name - * of the connection pool to associate with the map. - * - * The database maps are "registered" by the generated map builder classes. - * - * @param string The name of the database corresponding to the DatabaseMap to retrieve. - * - * @return DatabaseMap The named DatabaseMap. - * - * @throws PropelException - if database map is null or propel was not initialized properly. - */ - public static function getDatabaseMap($name = null) - { - if ($name === null) { - $name = self::getDefaultDB(); - if ($name === null) { - throw new PropelException("DatabaseMap name is null!"); - } - } - - if (!isset(self::$dbMaps[$name])) { - $clazz = self::$databaseMapClass; - self::$dbMaps[$name] = new $clazz($name); - } - - return self::$dbMaps[$name]; - } - - /** - * Sets the database map object to use for specified datasource. - * - * @param string $name The datasource name. - * @param DatabaseMap $map The database map object to use for specified datasource. - */ - public static function setDatabaseMap($name, DatabaseMap $map) - { - if ($name === null) { - $name = self::getDefaultDB(); - } - self::$dbMaps[$name] = $map; - } - - /** - * For replication, set whether to always force the use of a master connection. - * - * @param boolean $bit True or False - */ - public static function setForceMasterConnection($bit) - { - self::$forceMasterConnection = (bool) $bit; - } - - /** - * For replication, whether to always force the use of a master connection. - * - * @return boolean - */ - public static function getForceMasterConnection() - { - return self::$forceMasterConnection; - } - - /** - * Sets a Connection for specified datasource name. - * - * @param string $name The datasource name for the connection being set. - * @param PropelPDO $con The PDO connection. - * @param string $mode Whether this is a READ or WRITE connection (Propel::CONNECTION_READ, Propel::CONNECTION_WRITE) - */ - public static function setConnection($name, PropelPDO $con, $mode = Propel::CONNECTION_WRITE) - { - if ($name === null) { - $name = self::getDefaultDB(); - } - if ($mode == Propel::CONNECTION_READ) { - self::$connectionMap[$name]['slave'] = $con; - } else { - self::$connectionMap[$name]['master'] = $con; - } - } - - /** - * Gets an already-opened PDO connection or opens a new one for passed-in db name. - * - * @param string $name The datasource name that is used to look up the DSN from the runtime configuation file. - * @param string $mode The connection mode (this applies to replication systems). - * - * @return PDO A database connection - * - * @throws PropelException - if connection cannot be configured or initialized. - */ - public static function getConnection($name = null, $mode = Propel::CONNECTION_WRITE) - { - if ($name === null) { - $name = self::getDefaultDB(); - } - - // IF a WRITE-mode connection was requested - // or Propel is configured to always use the master connection - // THEN return the master connection. - if ($mode != Propel::CONNECTION_READ || self::$forceMasterConnection) { - return self::getMasterConnection($name); - } else { - return self::getSlaveConnection($name); - } - - } - - /** - * Gets an already-opened write PDO connection or opens a new one for passed-in db name. - * - * @param string $name The datasource name that is used to look up the DSN - * from the runtime configuation file. Empty name not allowed. - * - * @return PDO A database connection - * - * @throws PropelException - if connection cannot be configured or initialized. - */ - public static function getMasterConnection($name) - { - if (!isset(self::$connectionMap[$name]['master'])) { - // load connection parameter for master connection - $conparams = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : null; - if (empty($conparams)) { - throw new PropelException('No connection information in your runtime configuration file for datasource ['.$name.']'); - } - // initialize master connection - $con = Propel::initConnection($conparams, $name); - self::$connectionMap[$name]['master'] = $con; - } - - return self::$connectionMap[$name]['master']; - } - - /** - * Gets an already-opened read PDO connection or opens a new one for passed-in db name. - * - * @param string $name The datasource name that is used to look up the DSN - * from the runtime configuation file. Empty name not allowed. - * - * @return PDO A database connection - * - * @throws PropelException - if connection cannot be configured or initialized. - */ - public static function getSlaveConnection($name) - { - if (!isset(self::$connectionMap[$name]['slave'])) { - - $slaveconfigs = isset(self::$configuration['datasources'][$name]['slaves']) ? self::$configuration['datasources'][$name]['slaves'] : null; - - if (empty($slaveconfigs)) { - // no slaves configured for this datasource - // fallback to the master connection - self::$connectionMap[$name]['slave'] = self::getMasterConnection($name); - } else { - // Initialize a new slave - if (isset($slaveconfigs['connection']['dsn'])) { - // only one slave connection configured - $conparams = $slaveconfigs['connection']; - } else { - // more than one sleve connection configured - // pickup a random one - $randkey = array_rand($slaveconfigs['connection']); - $conparams = $slaveconfigs['connection'][$randkey]; - if (empty($conparams)) { - throw new PropelException('No connection information in your runtime configuration file for SLAVE ['.$randkey.'] to datasource ['.$name.']'); - } - } - - // initialize slave connection - $con = Propel::initConnection($conparams, $name); - self::$connectionMap[$name]['slave'] = $con; - } - - } // if datasource slave not set - - return self::$connectionMap[$name]['slave']; - } - - /** - * Opens a new PDO connection for passed-in db name. - * - * @param array $conparams Connection paramters. - * @param string $name Datasource name. - * @param string $defaultClass The PDO subclass to instantiate if there is no explicit classname - * specified in the connection params (default is Propel::CLASS_PROPEL_PDO) - * - * @return PDO A database connection of the given class (PDO, PropelPDO, SlavePDO or user-defined) - * - * @throws PropelException - if lower-level exception caught when trying to connect. - */ - public static function initConnection($conparams, $name, $defaultClass = Propel::CLASS_PROPEL_PDO) - { - - $dsn = $conparams['dsn']; - if ($dsn === null) { - throw new PropelException('No dsn specified in your connection parameters for datasource ['.$name.']'); - } - - if (isset($conparams['classname']) && !empty($conparams['classname'])) { - $classname = $conparams['classname']; - if (!class_exists($classname)) { - throw new PropelException('Unable to load specified PDO subclass: ' . $classname); - } - } else { - $classname = $defaultClass; - } - - $user = isset($conparams['user']) ? $conparams['user'] : null; - $password = isset($conparams['password']) ? $conparams['password'] : null; - - // load any driver options from the config file - // driver options are those PDO settings that have to be passed during the connection construction - $driver_options = array(); - if ( isset($conparams['options']) && is_array($conparams['options']) ) { - try { - self::processDriverOptions( $conparams['options'], $driver_options ); - } catch (PropelException $e) { - throw new PropelException('Error processing driver options for datasource ['.$name.']', $e); - } - } - - try { - $con = new $classname($dsn, $user, $password, $driver_options); - $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - if (Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT)->getParameter('debugpdo.logging.enabled', false)) { - $con->useLogging(true); - } - } catch (PDOException $e) { - throw new PropelException("Unable to open PDO connection", $e); - } - - // load any connection options from the config file - // connection attributes are those PDO flags that have to be set on the initialized connection - if (isset($conparams['attributes']) && is_array($conparams['attributes'])) { - $attributes = array(); - try { - self::processDriverOptions( $conparams['attributes'], $attributes ); - } catch (PropelException $e) { - throw new PropelException('Error processing connection attributes for datasource ['.$name.']', $e); - } - foreach ($attributes as $key => $value) { - $con->setAttribute($key, $value); - } - } - - // initialize the connection using the settings provided in the config file. this could be a "SET NAMES " query for MySQL, for instance - $adapter = self::getDB($name); - $adapter->initConnection($con, isset($conparams['settings']) && is_array($conparams['settings']) ? $conparams['settings'] : array()); - - return $con; - } - - /** - * Internal function to handle driver options or conneciton attributes in PDO. - * - * Process the INI file flags to be passed to each connection. - * - * @param array Where to find the list of constant flags and their new setting. - * @param array Put the data into here - * - * @throws PropelException If invalid options were specified. - */ - private static function processDriverOptions($source, &$write_to) - { - foreach ($source as $option => $optiondata) { - if (is_string($option) && strpos($option, '::') !== false) { - $key = $option; - } elseif (is_string($option)) { - $key = 'PropelPDO::' . $option; - } - if (!defined($key)) { - throw new PropelException("Invalid PDO option/attribute name specified: ".$key); - } - $key = constant($key); - - $value = $optiondata['value']; - if (is_string($value) && strpos($value, '::') !== false) { - if (!defined($value)) { - throw new PropelException("Invalid PDO option/attribute value specified: ".$value); - } - $value = constant($value); - } - - $write_to[$key] = $value; - } - } - - /** - * Returns database adapter for a specific datasource. - * - * @param string The datasource name. - * - * @return DBAdapter The corresponding database adapter. - * - * @throws PropelException If unable to find DBdapter for specified db. - */ - public static function getDB($name = null) - { - if ($name === null) { - $name = self::getDefaultDB(); - } - - if (!isset(self::$adapterMap[$name])) { - if (!isset(self::$configuration['datasources'][$name]['adapter'])) { - throw new PropelException("Unable to find adapter for datasource [" . $name . "]."); - } - $db = DBAdapter::factory(self::$configuration['datasources'][$name]['adapter']); - // register the adapter for this name - self::$adapterMap[$name] = $db; - } - - return self::$adapterMap[$name]; - } - - /** - * Sets a database adapter for specified datasource. - * - * @param string $name The datasource name. - * @param DBAdapter $adapter The DBAdapter implementation to use. - */ - public static function setDB($name, DBAdapter $adapter) - { - if ($name === null) { - $name = self::getDefaultDB(); - } - self::$adapterMap[$name] = $adapter; - } - - /** - * Returns the name of the default database. - * - * @return string Name of the default DB - */ - public static function getDefaultDB() - { - if (self::$defaultDBName === null) { - // Determine default database name. - self::$defaultDBName = isset(self::$configuration['datasources']['default']) ? self::$configuration['datasources']['default'] : self::DEFAULT_NAME; - } - return self::$defaultDBName; - } - - /** - * Closes any associated resource handles. - * - * This method frees any database connection handles that have been - * opened by the getConnection() method. - */ - public static function close() - { - foreach (self::$connectionMap as $idx => $cons) { - // Propel::log("Closing connections for " . $idx, Propel::LOG_DEBUG); - unset(self::$connectionMap[$idx]); - } - } - - /** - * Autoload function for loading propel dependencies. - * - * @param string The class name needing loading. - * - * @return boolean TRUE if the class was loaded, false otherwise. - */ - public static function autoload($className) - { - if (isset(self::$autoloadMap[$className])) { - require self::$baseDir . self::$autoloadMap[$className]; - return true; - } - return false; - } - - /** - * Initialize the base directory for the autoloader. - * Avoids a call to dirname(__FILE__) each time self::autoload() is called. - * FIXME put in the constructor if the Propel class ever becomes a singleton - */ - public static function initBaseDir() - { - self::$baseDir = dirname(__FILE__) . '/'; - } - - /** - * Include once a file specified in DOT notation and return unqualified classname. - * - * Typically, Propel uses autoload is used to load classes and expects that all classes - * referenced within Propel are included in Propel's autoload map. This method is only - * called when a specific non-Propel classname was specified -- for example, the - * classname of a validator in the schema.xml. This method will attempt to include that - * class via autoload and then relative to a location on the include_path. - * - * @param string $class dot-path to clas (e.g. path.to.my.ClassName). - * @return string unqualified classname - */ - public static function importClass($path) { - - // extract classname - if (($pos = strrpos($path, '.')) === false) { - $class = $path; - } else { - $class = substr($path, $pos + 1); - } - - // check if class exists, using autoloader to attempt to load it. - if (class_exists($class, $useAutoload=true)) { - return $class; - } - - // turn to filesystem path - $path = strtr($path, '.', DIRECTORY_SEPARATOR) . '.php'; - - // include class - $ret = include_once($path); - if ($ret === false) { - throw new PropelException("Unable to import class: " . $class . " from " . $path); - } - - // return qualified name - return $class; - } - - /** - * Set your own class-name for Database-Mapping. Then - * you can change the whole TableMap-Model, but keep its - * functionality for Criteria. - * - * @param string The name of the class. - */ - public static function setDatabaseMapClass($name) - { - self::$databaseMapClass = $name; - } - - /** - * Disable instance pooling. - * - * @return boolean true if the method changed the instance pooling state, - * false if it was already disabled - */ - public static function disableInstancePooling() - { - if (!self::$instancePoolingEnabled) { - return false; - } - self::$instancePoolingEnabled = false; - return true; - } - - /** - * Enable instance pooling (enabled by default). - * - * @return boolean true if the method changed the instance pooling state, - * false if it was already enabled - */ - public static function enableInstancePooling() - { - if (self::$instancePoolingEnabled) { - return false; - } - self::$instancePoolingEnabled = true; - return true; - } - - /** - * the instance pooling behaviour. True by default. - * - * @return boolean Whether the pooling is enabled or not. - */ - public static function isInstancePoolingEnabled() - { - return self::$instancePoolingEnabled; - } + /** + * The Propel version. + */ + const VERSION = '1.7.0'; + + /** + * A constant for default. + */ + const DEFAULT_NAME = "default"; + + /** + * A constant defining 'System is unusuable' logging level + */ + const LOG_EMERG = 0; + + /** + * A constant defining 'Immediate action required' logging level + */ + const LOG_ALERT = 1; + + /** + * A constant defining 'Critical conditions' logging level + */ + const LOG_CRIT = 2; + + /** + * A constant defining 'Error conditions' logging level + */ + const LOG_ERR = 3; + + /** + * A constant defining 'Warning conditions' logging level + */ + const LOG_WARNING = 4; + + /** + * A constant defining 'Normal but significant' logging level + */ + const LOG_NOTICE = 5; + + /** + * A constant defining 'Informational' logging level + */ + const LOG_INFO = 6; + + /** + * A constant defining 'Debug-level messages' logging level + */ + const LOG_DEBUG = 7; + + /** + * The class name for a PDO object. + */ + const CLASS_PDO = 'PDO'; + + /** + * The class name for a PropelPDO object. + */ + const CLASS_PROPEL_PDO = 'PropelPDO'; + + /** + * The class name for a DebugPDO object. + */ + const CLASS_DEBUG_PDO = 'DebugPDO'; + + /** + * Constant used to request a READ connection (applies to replication). + */ + const CONNECTION_READ = 'read'; + + /** + * Constant used to request a WRITE connection (applies to replication). + */ + const CONNECTION_WRITE = 'write'; + + /** + * @var string The db name that is specified as the default in the property file + */ + private static $defaultDBName; + + /** + * @var array The global cache of database maps + */ + private static $dbMaps = array(); + + /** + * @var array The cache of DB adapter keys + */ + private static $adapterMap = array(); + + /** + * @var array Cache of established connections (to eliminate overhead). + */ + private static $connectionMap = array(); + + /** + * @var PropelConfiguration Propel-specific configuration. + */ + private static $configuration; + + /** + * @var bool flag to set to true once this class has been initialized + */ + private static $isInit = false; + + /** + * @var Log optional logger + */ + private static $logger = null; + + /** + * @var string The name of the database mapper class + */ + private static $databaseMapClass = 'DatabaseMap'; + + /** + * @var bool Whether the object instance pooling is enabled + */ + private static $instancePoolingEnabled = true; + + /** + * @var bool For replication, whether to force the use of master connection. + */ + private static $forceMasterConnection = false; + + /** + * @var string Base directory to use for autoloading. Initialized in self::initBaseDir() + */ + protected static $baseDir; + + /** + * @var array A map of class names and their file paths for autoloading + */ + protected static $autoloadMap = array( + + 'DBAdapter' => 'adapter/DBAdapter.php', + 'DBMSSQL' => 'adapter/DBMSSQL.php', + 'MssqlPropelPDO' => 'adapter/MSSQL/MssqlPropelPDO.php', + 'MssqlDebugPDO' => 'adapter/MSSQL/MssqlDebugPDO.php', + 'MssqlDateTime' => 'adapter/MSSQL/MssqlDateTime.class.php', + 'DBMySQL' => 'adapter/DBMySQL.php', + 'DBMySQLi' => 'adapter/DBMySQLi.php', + 'DBNone' => 'adapter/DBNone.php', + 'DBOracle' => 'adapter/DBOracle.php', + 'DBPostgres' => 'adapter/DBPostgres.php', + 'DBSQLite' => 'adapter/DBSQLite.php', + 'DBSybase' => 'adapter/DBSybase.php', + 'DBSQLSRV' => 'adapter/DBSQLSRV.php', + + 'PropelArrayCollection' => 'collection/PropelArrayCollection.php', + 'PropelCollection' => 'collection/PropelCollection.php', + 'PropelObjectCollection' => 'collection/PropelObjectCollection.php', + 'PropelOnDemandCollection' => 'collection/PropelOnDemandCollection.php', + 'PropelOnDemandIterator' => 'collection/PropelOnDemandIterator.php', + + 'PropelConfiguration' => 'config/PropelConfiguration.php', + 'PropelConfigurationIterator' => 'config/PropelConfigurationIterator.php', + + 'PropelPDO' => 'connection/PropelPDO.php', + 'DebugPDO' => 'connection/DebugPDO.php', + 'DebugPDOStatement' => 'connection/DebugPDOStatement.php', + + 'PropelException' => 'exception/PropelException.php', + + 'ModelWith' => 'formatter/ModelWith.php', + 'PropelArrayFormatter' => 'formatter/PropelArrayFormatter.php', + 'PropelFormatter' => 'formatter/PropelFormatter.php', + 'PropelObjectFormatter' => 'formatter/PropelObjectFormatter.php', + 'PropelOnDemandFormatter' => 'formatter/PropelOnDemandFormatter.php', + 'PropelStatementFormatter' => 'formatter/PropelStatementFormatter.php', + 'PropelSimpleArrayFormatter' => 'formatter/PropelSimpleArrayFormatter.php', + + 'BasicLogger' => 'logger/BasicLogger.php', + 'MojaviLogAdapter' => 'logger/MojaviLogAdapter.php', + + 'ColumnMap' => 'map/ColumnMap.php', + 'DatabaseMap' => 'map/DatabaseMap.php', + 'TableMap' => 'map/TableMap.php', + 'RelationMap' => 'map/RelationMap.php', + 'ValidatorMap' => 'map/ValidatorMap.php', + + 'BaseObject' => 'om/BaseObject.php', + 'NodeObject' => 'om/NodeObject.php', + 'Persistent' => 'om/Persistent.php', + 'PreOrderNodeIterator' => 'om/PreOrderNodeIterator.php', + 'NestedSetPreOrderNodeIterator' => 'om/NestedSetPreOrderNodeIterator.php', + 'NestedSetRecursiveIterator' => 'om/NestedSetRecursiveIterator.php', + + 'PropelCSVParser' => 'parser/PropelCSVParser.php', + 'PropelJSONParser' => 'parser/PropelJSONParser.php', + 'PropelParser' => 'parser/PropelParser.php', + 'PropelXMLParser' => 'parser/PropelXMLParser.php', + 'PropelYAMLParser' => 'parser/PropelYAMLParser.php', + + 'Criteria' => 'query/Criteria.php', + 'Criterion' => 'query/Criterion.php', + 'CriterionIterator' => 'query/CriterionIterator.php', + 'Join' => 'query/Join.php', + 'ModelCriteria' => 'query/ModelCriteria.php', + 'ModelCriterion' => 'query/ModelCriterion.php', + 'ModelJoin' => 'query/ModelJoin.php', + 'PropelQuery' => 'query/PropelQuery.php', + + 'BasePeer' => 'util/BasePeer.php', + 'NodePeer' => 'util/NodePeer.php', + 'PeerInfo' => 'util/PeerInfo.php', + 'PropelAutoloader' => 'util/PropelAutoloader.php', + 'PropelColumnTypes' => 'util/PropelColumnTypes.php', + 'PropelConditionalProxy' => 'util/PropelConditionalProxy.php', + 'PropelModelPager' => 'util/PropelModelPager.php', + 'PropelPager' => 'util/PropelPager.php', + 'PropelDateTime' => 'util/PropelDateTime.php', + + 'BasicValidator' => 'validator/BasicValidator.php', + 'MatchValidator' => 'validator/MatchValidator.php', + 'MaxLengthValidator' => 'validator/MaxLengthValidator.php', + 'MaxValueValidator' => 'validator/MaxValueValidator.php', + 'MinLengthValidator' => 'validator/MinLengthValidator.php', + 'MinValueValidator' => 'validator/MinValueValidator.php', + 'NotMatchValidator' => 'validator/NotMatchValidator.php', + 'RequiredValidator' => 'validator/RequiredValidator.php', + 'TypeValidator' => 'validator/TypeValidator.php', + 'UniqueValidator' => 'validator/UniqueValidator.php', + 'ValidValuesValidator' => 'validator/ValidValuesValidator.php', + 'ValidationFailed' => 'validator/ValidationFailed.php', + ); + + /** + * Initializes Propel + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function initialize() + { + if (self::$configuration === null) { + throw new PropelException("Propel cannot be initialized without a valid configuration. Please check the log files for further details."); + } + + self::configureLogging(); + + // check whether the generated model has the same version as the runtime, see gh-#577 + // we need to check for existance first, because tasks which rely on the runtime.xml conf will not provide a generator_version + if (isset(self::$configuration['generator_version']) && self::$configuration['generator_version'] != self::VERSION) { + $warning = "Version mismatch: The generated model was build using propel '" . self::$configuration['generator_version'] . "' while the current runtime is at version '" . self::VERSION . "'"; + if (self::$logger) { + self::$logger->warning($warning); + } else { + trigger_error($warning, E_USER_WARNING); + } + } + + // reset the connection map (this should enable runtime changes of connection params) + self::$connectionMap = array(); + + if (isset(self::$configuration['classmap']) && is_array(self::$configuration['classmap'])) { + PropelAutoloader::getInstance()->addClassPaths(self::$configuration['classmap']); + PropelAutoloader::getInstance()->register(); + } + + self::$isInit = true; + } + + /** + * Configure Propel a PHP (array) config file. + * + * @param string Path (absolute or relative to include_path) to config file. + * + * @throws PropelException If configuration file cannot be opened. + * (E_WARNING probably will also be raised by PHP) + */ + public static function configure($configFile) + { + $configuration = include($configFile); + if ($configuration === false) { + throw new PropelException("Unable to open configuration file: " . var_export($configFile, true)); + } + self::setConfiguration($configuration); + } + + /** + * Configure the logging system, if config is specified in the runtime configuration. + */ + protected static function configureLogging() + { + if (self::$logger === null) { + if (isset(self::$configuration['log']) && is_array(self::$configuration['log']) && count(self::$configuration['log'])) { + include_once 'Log.php'; // PEAR Log class + $c = self::$configuration['log']; + $type = isset($c['type']) ? $c['type'] : 'file'; + $name = isset($c['name']) ? $c['name'] : './propel.log'; + $ident = isset($c['ident']) ? $c['ident'] : 'propel'; + $conf = isset($c['conf']) ? $c['conf'] : array(); + $level = isset($c['level']) ? $c['level'] : PEAR_LOG_DEBUG; + self::$logger = Log::singleton($type, $name, $ident, $conf, $level); + } // if isset() + } + } + + /** + * Initialization of Propel a PHP (array) configuration file. + * + * @param string $c The Propel configuration file path. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function init($c) + { + self::configure($c); + self::initialize(); + } + + /** + * Determine whether Propel has already been initialized. + * + * @return bool True if Propel is already initialized. + */ + public static function isInit() + { + return self::$isInit; + } + + /** + * Sets the configuration for Propel and all dependencies. + * + * @param mixed The Configuration (array or PropelConfiguration) + */ + public static function setConfiguration($c) + { + if (is_array($c)) { + if (isset($c['propel']) && is_array($c['propel'])) { + $c = $c['propel']; + } + $c = new PropelConfiguration($c); + } + self::$configuration = $c; + } + + /** + * Get the configuration for this component. + * + * @param int - PropelConfiguration::TYPE_ARRAY: return the configuration as an array + * (for backward compatibility this is the default) + * - PropelConfiguration::TYPE_ARRAY_FLAT: return the configuration as a flat array + * ($config['name.space.item']) + * - PropelConfiguration::TYPE_OBJECT: return the configuration as a PropelConfiguration instance + * + * @return mixed The Configuration (array or PropelConfiguration) + */ + public static function getConfiguration($type = PropelConfiguration::TYPE_ARRAY) + { + return self::$configuration->getParameters($type); + } + + /** + * Override the configured logger. + * + * This is primarily for things like unit tests / debugging where + * you want to change the logger without altering the configuration file. + * + * You can use any logger class that implements the propel.logger.BasicLogger + * interface. This interface is based on PEAR::Log, so you can also simply pass + * a PEAR::Log object to this method. + * + * @param object The new logger to use. ([PEAR] Log or BasicLogger) + */ + public static function setLogger($logger) + { + self::$logger = $logger; + } + + /** + * Returns true if a logger, for example PEAR::Log, has been configured, + * otherwise false. + * + * @return bool True if Propel uses logging + */ + public static function hasLogger() + { + return (self::$logger !== null); + } + + /** + * Get the configured logger. + * + * @return object Configured log class ([PEAR] Log or BasicLogger). + */ + public static function logger() + { + return self::$logger; + } + + /** + * Logs a message + * If a logger has been configured, the logger will be used, otherwrise the + * logging message will be discarded without any further action + * + * @param string The message that will be logged. + * @param string The logging level. + * + * @return bool True if the message was logged successfully or no logger was used. + */ + public static function log($message, $level = self::LOG_DEBUG) + { + if (self::hasLogger()) { + $logger = self::logger(); + switch ($level) { + case self::LOG_EMERG: + return $logger->log($message, $level); + case self::LOG_ALERT: + return $logger->alert($message); + case self::LOG_CRIT: + return $logger->crit($message); + case self::LOG_ERR: + return $logger->err($message); + case self::LOG_WARNING: + return $logger->warning($message); + case self::LOG_NOTICE: + return $logger->notice($message); + case self::LOG_INFO: + return $logger->info($message); + default: + return $logger->debug($message); + } + } + + return true; + } + + /** + * Returns the database map information. Name relates to the name + * of the connection pool to associate with the map. + * + * The database maps are "registered" by the generated map builder classes. + * + * @param string The name of the database corresponding to the DatabaseMap to retrieve. + * + * @return DatabaseMap The named DatabaseMap. + * + * @throws PropelException - if database map is null or propel was not initialized properly. + */ + public static function getDatabaseMap($name = null) + { + if ($name === null) { + $name = self::getDefaultDB(); + if ($name === null) { + throw new PropelException("DatabaseMap name is null!"); + } + } + + if (!isset(self::$dbMaps[$name])) { + $clazz = self::$databaseMapClass; + self::$dbMaps[$name] = new $clazz($name); + } + + return self::$dbMaps[$name]; + } + + /** + * Sets the database map object to use for specified datasource. + * + * @param string $name The datasource name. + * @param DatabaseMap $map The database map object to use for specified datasource. + */ + public static function setDatabaseMap($name, DatabaseMap $map) + { + if ($name === null) { + $name = self::getDefaultDB(); + } + self::$dbMaps[$name] = $map; + } + + /** + * For replication, set whether to always force the use of a master connection. + * + * @param boolean $bit True or False + */ + public static function setForceMasterConnection($bit) + { + self::$forceMasterConnection = (bool) $bit; + } + + /** + * For replication, whether to always force the use of a master connection. + * + * @return boolean + */ + public static function getForceMasterConnection() + { + return self::$forceMasterConnection; + } + + /** + * Sets a Connection for specified datasource name. + * + * @param string $name The datasource name for the connection being set. + * @param PropelPDO $con The PDO connection. + * @param string $mode Whether this is a READ or WRITE connection (Propel::CONNECTION_READ, Propel::CONNECTION_WRITE) + */ + public static function setConnection($name, PropelPDO $con, $mode = Propel::CONNECTION_WRITE) + { + if ($name === null) { + $name = self::getDefaultDB(); + } + if ($mode == Propel::CONNECTION_READ) { + self::$connectionMap[$name]['slave'] = $con; + } else { + self::$connectionMap[$name]['master'] = $con; + } + } + + /** + * Gets an already-opened PDO connection or opens a new one for passed-in db name. + * + * @param string $name The datasource name that is used to look up the DSN from the runtime configuration file. + * @param string $mode The connection mode (this applies to replication systems). + * + * @return PDO A database connection + * + * @throws PropelException - if connection cannot be configured or initialized. + */ + public static function getConnection($name = null, $mode = Propel::CONNECTION_WRITE) + { + if ($name === null) { + $name = self::getDefaultDB(); + } + + // IF a WRITE-mode connection was requested + // or Propel is configured to always use the master connection + // THEN return the master connection. + if ($mode != Propel::CONNECTION_READ || self::$forceMasterConnection) { + return self::getMasterConnection($name); + } else { + return self::getSlaveConnection($name); + } + } + + /** + * Gets an already-opened write PDO connection or opens a new one for passed-in db name. + * + * @param string $name The datasource name that is used to look up the DSN + * from the runtime configuation file. Empty name not allowed. + * + * @return PDO A database connection + * + * @throws PropelException - if connection cannot be configured or initialized. + */ + public static function getMasterConnection($name) + { + if (!isset(self::$connectionMap[$name]['master'])) { + // load connection parameter for master connection + $conparams = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : null; + if (empty($conparams)) { + throw new PropelException('No connection information in your runtime configuration file for datasource [' . $name . ']'); + } + // initialize master connection + $con = Propel::initConnection($conparams, $name); + self::$connectionMap[$name]['master'] = $con; + } + + return self::$connectionMap[$name]['master']; + } + + /** + * Gets an already-opened read PDO connection or opens a new one for passed-in db name. + * + * @param string $name The datasource name that is used to look up the DSN + * from the runtime configuation file. Empty name not allowed. + * + * @return PDO A database connection + * + * @throws PropelException - if connection cannot be configured or initialized. + */ + public static function getSlaveConnection($name) + { + if (!isset(self::$connectionMap[$name]['slave'])) { + + $slaveconfigs = isset(self::$configuration['datasources'][$name]['slaves']) ? self::$configuration['datasources'][$name]['slaves'] : null; + + if (empty($slaveconfigs)) { + // no slaves configured for this datasource + // fallback to the master connection + self::$connectionMap[$name]['slave'] = self::getMasterConnection($name); + } else { + // Initialize a new slave + if (isset($slaveconfigs['connection']['dsn'])) { + // only one slave connection configured + $conparams = $slaveconfigs['connection']; + } else { + // more than one sleve connection configured + // pickup a random one + $randkey = array_rand($slaveconfigs['connection']); + $conparams = $slaveconfigs['connection'][$randkey]; + if (empty($conparams)) { + throw new PropelException('No connection information in your runtime configuration file for SLAVE [' . $randkey . '] to datasource [' . $name . ']'); + } + } + + // initialize slave connection + $con = Propel::initConnection($conparams, $name); + self::$connectionMap[$name]['slave'] = $con; + } + } // if datasource slave not set + + return self::$connectionMap[$name]['slave']; + } + + /** + * Opens a new PDO connection for passed-in db name. + * + * @param array $conparams Connection paramters. + * @param string $name Datasource name. + * @param string $defaultClass The PDO subclass to instantiate if there is no explicit classname + * specified in the connection params (default is Propel::CLASS_PROPEL_PDO) + * + * @return PDO A database connection of the given class (PDO, PropelPDO, SlavePDO or user-defined) + * + * @throws PropelException - if lower-level exception caught when trying to connect. + */ + public static function initConnection($conparams, $name, $defaultClass = Propel::CLASS_PROPEL_PDO) + { + $adapter = self::getDB($name); + + if (null === $conparams['dsn']) { + throw new PropelException('No dsn specified in your connection parameters for datasource [' . $name . ']'); + } + + $conparams = $adapter->prepareParams($conparams); + + if (isset($conparams['classname']) && !empty($conparams['classname'])) { + $classname = $conparams['classname']; + if (!class_exists($classname)) { + throw new PropelException('Unable to load specified PDO subclass: ' . $classname); + } + } else { + $classname = $defaultClass; + } + + $dsn = $conparams['dsn']; + $user = isset($conparams['user']) ? $conparams['user'] : null; + $password = isset($conparams['password']) ? $conparams['password'] : null; + + // load any driver options from the config file + // driver options are those PDO settings that have to be passed during the connection construction + $driver_options = array(); + if (isset($conparams['options']) && is_array($conparams['options'])) { + try { + self::processDriverOptions($conparams['options'], $driver_options); + } catch (PropelException $e) { + throw new PropelException('Error processing driver options for datasource [' . $name . ']', $e); + } + } + + try { + $con = new $classname($dsn, $user, $password, $driver_options); + $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $con->setAttribute(PropelPDO::PROPEL_ATTR_CONNECTION_NAME, $name); + } catch (PDOException $e) { + throw new PropelException("Unable to open PDO connection", $e); + } + + // load any connection options from the config file + // connection attributes are those PDO flags that have to be set on the initialized connection + if (isset($conparams['attributes']) && is_array($conparams['attributes'])) { + $attributes = array(); + try { + self::processDriverOptions($conparams['attributes'], $attributes); + } catch (PropelException $e) { + throw new PropelException('Error processing connection attributes for datasource [' . $name . ']', $e); + } + foreach ($attributes as $key => $value) { + $con->setAttribute($key, $value); + } + } + + // initialize the connection using the settings provided in the config file. this could be a "SET NAMES " query for MySQL, for instance + $adapter->initConnection($con, isset($conparams['settings']) && is_array($conparams['settings']) ? $conparams['settings'] : array()); + + return $con; + } + + /** + * Internal function to handle driver options or conneciton attributes in PDO. + * + * Process the INI file flags to be passed to each connection. + * + * @param array Where to find the list of constant flags and their new setting. + * @param array Put the data into here + * + * @throws PropelException If invalid options were specified. + */ + private static function processDriverOptions($source, &$write_to) + { + foreach ($source as $option => $optiondata) { + if (is_string($option) && strpos($option, '::') !== false) { + $key = $option; + } elseif (is_string($option)) { + $key = 'PropelPDO::' . $option; + } + if (!defined($key)) { + throw new PropelException("Invalid PDO option/attribute name specified: " . $key); + } + $key = constant($key); + + $value = $optiondata['value']; + if (is_string($value) && strpos($value, '::') !== false) { + if (!defined($value)) { + throw new PropelException("Invalid PDO option/attribute value specified: " . $value); + } + $value = constant($value); + } + + $write_to[$key] = $value; + } + } + + /** + * Returns database adapter for a specific datasource. + * + * @param string The datasource name. + * + * @return DBAdapter The corresponding database adapter. + * + * @throws PropelException If unable to find DBdapter for specified db. + */ + public static function getDB($name = null) + { + if ($name === null) { + $name = self::getDefaultDB(); + } + + if (!isset(self::$adapterMap[$name])) { + if (!isset(self::$configuration['datasources'][$name]['adapter'])) { + throw new PropelException("Unable to find adapter for datasource [" . $name . "]."); + } + $db = DBAdapter::factory(self::$configuration['datasources'][$name]['adapter']); + // register the adapter for this name + self::$adapterMap[$name] = $db; + } + + return self::$adapterMap[$name]; + } + + /** + * Sets a database adapter for specified datasource. + * + * @param string $name The datasource name. + * @param DBAdapter $adapter The DBAdapter implementation to use. + */ + public static function setDB($name, DBAdapter $adapter) + { + if ($name === null) { + $name = self::getDefaultDB(); + } + self::$adapterMap[$name] = $adapter; + } + + /** + * Returns the name of the default database. + * + * @return string Name of the default DB + */ + public static function getDefaultDB() + { + if (self::$defaultDBName === null) { + // Determine default database name. + self::$defaultDBName = isset(self::$configuration['datasources']['default']) && is_scalar(self::$configuration['datasources']['default']) ? self::$configuration['datasources']['default'] : self::DEFAULT_NAME; + } + + return self::$defaultDBName; + } + + /** + * Closes any associated resource handles. + * + * This method frees any database connection handles that have been + * opened by the getConnection() method. + */ + public static function close() + { + foreach (self::$connectionMap as $idx => $cons) { + // Propel::log("Closing connections for " . $idx, Propel::LOG_DEBUG); + unset(self::$connectionMap[$idx]); + } + } + + /** + * Autoload function for loading propel dependencies. + * + * @param string The class name needing loading. + * + * @return boolean TRUE if the class was loaded, false otherwise. + */ + public static function autoload($className) + { + if (isset(self::$autoloadMap[$className])) { + require self::$baseDir . self::$autoloadMap[$className]; + + return true; + } + + return false; + } + + /** + * Initialize the base directory for the autoloader. + * Avoids a call to dirname(__FILE__) each time self::autoload() is called. + * FIXME put in the constructor if the Propel class ever becomes a singleton + */ + public static function initBaseDir() + { + self::$baseDir = dirname(__FILE__) . '/'; + } + + /** + * Include once a file specified in DOT notation and return unqualified classname. + * + * Typically, Propel uses autoload is used to load classes and expects that all classes + * referenced within Propel are included in Propel's autoload map. This method is only + * called when a specific non-Propel classname was specified -- for example, the + * classname of a validator in the schema.xml. This method will attempt to include that + * class via autoload and then relative to a location on the include_path. + * + * @param string $class dot-path to clas (e.g. path.to.my.ClassName). + * + * @return string unqualified classname + * + * @throws PropelException + */ + public static function importClass($path) + { + // extract classname + if (($pos = strrpos($path, '.')) === false) { + $class = $path; + } else { + $class = substr($path, $pos + 1); + } + + // check if class exists, using autoloader to attempt to load it. + if (class_exists($class, $useAutoload = true)) { + return $class; + } + + // turn to filesystem path + $path = strtr($path, '.', DIRECTORY_SEPARATOR) . '.php'; + + // include class + $ret = include_once($path); + if ($ret === false) { + throw new PropelException("Unable to import class: " . $class . " from " . $path); + } + + // return qualified name + return $class; + } + + /** + * Set your own class-name for Database-Mapping. Then + * you can change the whole TableMap-Model, but keep its + * functionality for Criteria. + * + * @param string The name of the class. + */ + public static function setDatabaseMapClass($name) + { + self::$databaseMapClass = $name; + } + + /** + * Disable instance pooling. + * + * @return boolean true if the method changed the instance pooling state, + * false if it was already disabled + */ + public static function disableInstancePooling() + { + if (!self::$instancePoolingEnabled) { + return false; + } + self::$instancePoolingEnabled = false; + + return true; + } + + /** + * Enable instance pooling (enabled by default). + * + * @return boolean true if the method changed the instance pooling state, + * false if it was already enabled + */ + public static function enableInstancePooling() + { + if (self::$instancePoolingEnabled) { + return false; + } + self::$instancePoolingEnabled = true; + + return true; + } + + /** + * the instance pooling behaviour. True by default. + * + * @return boolean Whether the pooling is enabled or not. + */ + public static function isInstancePoolingEnabled() + { + return self::$instancePoolingEnabled; + } } // Since the Propel class is not a true singleton, this code cannot go into the __construct() Propel::initBaseDir(); spl_autoload_register(array('Propel', 'autoload')); + +if (version_compare(PHP_VERSION, '5.3.0', '<')) { + require_once dirname(__FILE__) . '/../stubs/functions.php'; +} diff --git a/airtime_mvc/library/propel/runtime/lib/adapter/DBAdapter.php b/airtime_mvc/library/propel/runtime/lib/adapter/DBAdapter.php index 4da98dc38..7fa0d8a37 100644 --- a/airtime_mvc/library/propel/runtime/lib/adapter/DBAdapter.php +++ b/airtime_mvc/library/propel/runtime/lib/adapter/DBAdapter.php @@ -27,271 +27,585 @@ * @author Jon S. Stevens (Torque) * @author Brett McLaughlin (Torque) * @author Daniel Rall (Torque) - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.adapter */ abstract class DBAdapter { + const ID_METHOD_NONE = 0; + const ID_METHOD_AUTOINCREMENT = 1; + const ID_METHOD_SEQUENCE = 2; - const ID_METHOD_NONE = 0; - const ID_METHOD_AUTOINCREMENT = 1; - const ID_METHOD_SEQUENCE = 2; + /** + * Propel driver to Propel adapter map. + * + * @var array + */ + private static $adapters = array( + 'mysql' => 'DBMySQL', + 'mysqli' => 'DBMySQLi', + 'mssql' => 'DBMSSQL', + 'sqlsrv' => 'DBSQLSRV', + 'oracle' => 'DBOracle', + 'oci' => 'DBOracle', + 'pgsql' => 'DBPostgres', + 'sqlite' => 'DBSQLite', + '' => 'DBNone', + ); - /** - * Propel driver to Propel adapter map. - * @var array - */ - private static $adapters = array( - 'mysql' => 'DBMySQL', - 'mysqli' => 'DBMySQLi', - 'mssql' => 'DBMSSQL', - 'dblib' => 'DBMSSQL', - 'sybase' => 'DBSybase', - 'oracle' => 'DBOracle', - 'oci' => 'DBOracle', - 'pgsql' => 'DBPostgres', - 'sqlite' => 'DBSQLite', - '' => 'DBNone', - ); + /** + * Creates a new instance of the database adapter associated + * with the specified Propel driver. + * + * @param string $driver The name of the Propel driver to create a new adapter instance + * for or a shorter form adapter key. + * + * @throws PropelException If the adapter could not be instantiated. + * @return DBAdapter An instance of a Propel database adapter. + */ + public static function factory($driver) + { + $adapterClass = isset(self::$adapters[$driver]) ? self::$adapters[$driver] : null; + if ($adapterClass !== null) { + $a = new $adapterClass(); - /** - * Creates a new instance of the database adapter associated - * with the specified Propel driver. - * - * @param string $driver The name of the Propel driver to - * create a new adapter instance for or a shorter form adapter key. - * @return DBAdapter An instance of a Propel database adapter. - * @throws PropelException if the adapter could not be instantiated. - */ - public static function factory($driver) { - $adapterClass = isset(self::$adapters[$driver]) ? self::$adapters[$driver] : null; - if ($adapterClass !== null) { - $a = new $adapterClass(); - return $a; - } else { - throw new PropelException("Unsupported Propel driver: " . $driver . ": Check your configuration file"); - } - } + return $a; + } else { + throw new PropelException("Unsupported Propel driver: " . $driver . ": Check your configuration file"); + } + } - /** - * This method is called after a connection was created to run necessary - * post-initialization queries or code. - * - * If a charset was specified, this will be set before any other queries - * are executed. - * - * This base method runs queries specified using the "query" setting. - * - * @param PDO A PDO connection instance. - * @param array An array of settings. - * @see setCharset() - */ - public function initConnection(PDO $con, array $settings) - { - if (isset($settings['charset']['value'])) { - $this->setCharset($con, $settings['charset']['value']); - } - if (isset($settings['queries']) && is_array($settings['queries'])) { - foreach ($settings['queries'] as $queries) { - foreach ((array)$queries as $query) { - $con->exec($query); - } - } - } - } + /** + * Prepare connection parameters. + * + * @param array $settings + * + * @return array + */ + public function prepareParams($settings) + { + return $settings; + } - /** - * Sets the character encoding using SQL standard SET NAMES statement. - * - * This method is invoked from the default initConnection() method and must - * be overridden for an RDMBS which does _not_ support this SQL standard. - * - * @param PDO A PDO connection instance. - * @param string The charset encoding. - * @see initConnection() - */ - public function setCharset(PDO $con, $charset) - { - $con->exec("SET NAMES '" . $charset . "'"); - } + /** + * This method is called after a connection was created to run necessary + * post-initialization queries or code. + * + * If a charset was specified, this will be set before any other queries + * are executed. + * + * This base method runs queries specified using the "query" setting. + * + * @see setCharset() + * + * @param PDO $con A PDO connection instance. + * @param array $settings An array of settings. + */ + public function initConnection(PDO $con, array $settings) + { + if (isset($settings['charset']['value'])) { + $this->setCharset($con, $settings['charset']['value']); + } + if (isset($settings['queries']) && is_array($settings['queries'])) { + foreach ($settings['queries'] as $queries) { + foreach ((array) $queries as $query) { + $con->exec($query); + } + } + } + } - /** - * This method is used to ignore case. - * - * @param string The string to transform to upper case. - * @return string The upper case string. - */ - public abstract function toUpperCase($in); + /** + * Sets the character encoding using SQL standard SET NAMES statement. + * + * This method is invoked from the default initConnection() method and must + * be overridden for an RDMBS which does _not_ support this SQL standard. + * + * @see initConnection() + * + * @param PDO $con A $PDO PDO connection instance. + * @param string $charset The $string charset encoding. + */ + public function setCharset(PDO $con, $charset) + { + $con->exec("SET NAMES '" . $charset . "'"); + } - /** - * Returns the character used to indicate the beginning and end of - * a piece of text used in a SQL statement (generally a single - * quote). - * - * @return string The text delimeter. - */ - public function getStringDelimiter() - { - return '\''; - } + /** + * This method is used to ignore case. + * + * @param string $in The string to transform to upper case. + * + * @return string The upper case string. + */ + abstract public function toUpperCase($in); - /** - * This method is used to ignore case. - * - * @param string $in The string whose case to ignore. - * @return string The string in a case that can be ignored. - */ - public abstract function ignoreCase($in); + /** + * Returns the character used to indicate the beginning and end of + * a piece of text used in a SQL statement (generally a single + * quote). + * + * @return string The text delimiter. + */ + public function getStringDelimiter() + { + return '\''; + } - /** - * This method is used to ignore case in an ORDER BY clause. - * Usually it is the same as ignoreCase, but some databases - * (Interbase for example) does not use the same SQL in ORDER BY - * and other clauses. - * - * @param string $in The string whose case to ignore. - * @return string The string in a case that can be ignored. - */ - public function ignoreCaseInOrderBy($in) - { - return $this->ignoreCase($in); - } + /** + * This method is used to ignore case. + * + * @param string $in The string whose case to ignore. + * + * @return string The string in a case that can be ignored. + */ + abstract public function ignoreCase($in); - /** - * Returns SQL which concatenates the second string to the first. - * - * @param string String to concatenate. - * @param string String to append. - * @return string - */ - public abstract function concatString($s1, $s2); + /** + * This method is used to ignore case in an ORDER BY clause. + * Usually it is the same as ignoreCase, but some databases + * (Interbase for example) does not use the same SQL in ORDER BY + * and other clauses. + * + * @param string $in The string whose case to ignore. + * + * @return string The string in a case that can be ignored. + */ + public function ignoreCaseInOrderBy($in) + { + return $this->ignoreCase($in); + } - /** - * Returns SQL which extracts a substring. - * - * @param string String to extract from. - * @param int Offset to start from. - * @param int Number of characters to extract. - * @return string - */ - public abstract function subString($s, $pos, $len); + /** + * Returns SQL which concatenates the second string to the first. + * + * @param string $s1 String to concatenate. + * @param string $s2 String to append. + * + * @return string + */ + abstract public function concatString($s1, $s2); - /** - * Returns SQL which calculates the length (in chars) of a string. - * - * @param string String to calculate length of. - * @return string - */ - public abstract function strLength($s); + /** + * Returns SQL which extracts a substring. + * + * @param string $s String to extract from. + * @param integer $pos Offset to start from. + * @param integer $len Number of characters to extract. + * + * @return string + */ + abstract public function subString($s, $pos, $len); + /** + * Returns SQL which calculates the length (in chars) of a string. + * + * @param string $s String to calculate length of. + * + * @return string + */ + abstract public function strLength($s); - /** - * Quotes database objec identifiers (table names, col names, sequences, etc.). - * @param string $text The identifier to quote. - * @return string The quoted identifier. - */ - public function quoteIdentifier($text) - { - return '"' . $text . '"'; - } + /** + * Quotes database objec identifiers (table names, col names, sequences, etc.). + * + * @param string $text The identifier to quote. + * + * @return string The quoted identifier. + */ + public function quoteIdentifier($text) + { + return '"' . $text . '"'; + } - /** - * Quotes a database table which could have space seperating it from an alias, both should be identified seperately - * @param string $table The table name to quo - * @return string The quoted table name - **/ - public function quoteIdentifierTable($table) { - return implode(" ", array_map(array($this, "quoteIdentifier"), explode(" ", $table) ) ); - } + /** + * Quotes a database table which could have space separating it from an alias, both should be identified separately + * This doesn't take care of dots which separate schema names from table names. Adapters for RDBMs which support + * schemas have to implement that in the platform-specific way. + * + * @param string $table The table name to quo + * + * @return string The quoted table name + **/ + public function quoteIdentifierTable($table) + { + return implode(" ", array_map(array($this, "quoteIdentifier"), explode(" ", $table))); + } - /** - * Returns the native ID method for this RDBMS. - * @return int one of DBAdapter:ID_METHOD_SEQUENCE, DBAdapter::ID_METHOD_AUTOINCREMENT. - */ - protected function getIdMethod() - { - return DBAdapter::ID_METHOD_AUTOINCREMENT; - } + /** + * Returns the native ID method for this RDBMS. + * + * @return integer One of DBAdapter:ID_METHOD_SEQUENCE, DBAdapter::ID_METHOD_AUTOINCREMENT. + */ + protected function getIdMethod() + { + return DBAdapter::ID_METHOD_AUTOINCREMENT; + } - /** - * Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT. - * @return boolean - */ - public function isGetIdBeforeInsert() - { - return ($this->getIdMethod() === DBAdapter::ID_METHOD_SEQUENCE); - } + /** + * Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT. + * + * @return boolean + */ + public function isGetIdBeforeInsert() + { + return ($this->getIdMethod() === DBAdapter::ID_METHOD_SEQUENCE); + } - /** - * Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT. - * @return boolean - */ - public function isGetIdAfterInsert() - { - return ($this->getIdMethod() === DBAdapter::ID_METHOD_AUTOINCREMENT); - } + /** + * Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT. + * + * @return boolean + */ + public function isGetIdAfterInsert() + { + return ($this->getIdMethod() === DBAdapter::ID_METHOD_AUTOINCREMENT); + } - /** - * Gets the generated ID (either last ID for autoincrement or next sequence ID). - * @return mixed - */ - public function getId(PDO $con, $name = null) - { - return $con->lastInsertId($name); - } + /** + * Gets the generated ID (either last ID for autoincrement or next sequence ID). + * Warning: duplicates logic from DefaultPlatform::getIdentifierPhp(). + * Any code modification here must be ported there. + * + * @param PDO $con + * @param string $name + * + * @return mixed + */ + public function getId(PDO $con, $name = null) + { + return $con->lastInsertId($name); + } - /** - * Returns timestamp formatter string for use in date() function. - * @return string - */ - public function getTimestampFormatter() - { - return "Y-m-d H:i:s"; - } + /** + * Formats a temporal value before binding, given a ColumnMap object. + * + * @param mixed $value The temporal value + * @param mixed $type PropelColumnTypes constant, or ColumnMap object + * + * @return string The formatted temporal value + */ + public function formatTemporalValue($value, $type) + { + /** @var $dt PropelDateTime */ + if ($dt = PropelDateTime::newInstance($value)) { + if ($type instanceof ColumnMap) { + $type = $type->getType(); + } + switch ($type) { + case PropelColumnTypes::TIMESTAMP: + case PropelColumnTypes::BU_TIMESTAMP: + $value = $dt->format($this->getTimestampFormatter()); + break; + case PropelColumnTypes::DATE: + case PropelColumnTypes::BU_DATE: + $value = $dt->format($this->getDateFormatter()); + break; + case PropelColumnTypes::TIME: + $value = $dt->format($this->getTimeFormatter()); + break; + } + } - /** - * Returns date formatter string for use in date() function. - * @return string - */ - public function getDateFormatter() - { - return "Y-m-d"; - } + return $value; + } - /** - * Returns time formatter string for use in date() function. - * @return string - */ - public function getTimeFormatter() - { - return "H:i:s"; - } + /** + * Returns timestamp formatter string for use in date() function. + * + * @return string + */ + public function getTimestampFormatter() + { + return 'Y-m-d H:i:s'; + } - /** - * Should Column-Names get identifiers for inserts or updates. - * By default false is returned -> backwards compability. - * - * it`s a workaround...!!! - * - * @todo should be abstract - * @return boolean - * @deprecated - */ - public function useQuoteIdentifier() - { - return false; - } + /** + * Returns date formatter string for use in date() function. + * + * @return string + */ + public function getDateFormatter() + { + return "Y-m-d"; + } - /** - * Modifies the passed-in SQL to add LIMIT and/or OFFSET. - */ - public abstract function applyLimit(&$sql, $offset, $limit); + /** + * Returns time formatter string for use in date() function. + * + * @return string + */ + public function getTimeFormatter() + { + return "H:i:s"; + } - /** - * Gets the SQL string that this adapter uses for getting a random number. - * - * @param mixed $seed (optional) seed value for databases that support this - */ - public abstract function random($seed = null); + /** + * Should Column-Names get identifiers for inserts or updates. + * By default false is returned -> backwards compability. + * + * it`s a workaround...!!! + * + * @todo should be abstract + * @deprecated + * + * @return boolean + */ + public function useQuoteIdentifier() + { + return false; + } + /** + * Allows manipulation of the query string before PDOStatement is instantiated. + * + * @param string $sql The sql statement + * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) + * @param Criteria $values + * @param DatabaseMap $dbMap + */ + public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap) + { + } + + /** + * Modifies the passed-in SQL to add LIMIT and/or OFFSET. + * + * @param string $sql + * @param integer $offset + * @param integer $limit + */ + abstract public function applyLimit(&$sql, $offset, $limit); + + /** + * Gets the SQL string that this adapter uses for getting a random number. + * + * @param mixed $seed (optional) seed value for databases that support this + */ + abstract public function random($seed = null); + + /** + * Returns the "DELETE FROM [AS ]" part of DELETE query. + * + * @param Criteria $criteria + * @param string $tableName + * + * @return string + */ + public function getDeleteFromClause($criteria, $tableName) + { + $sql = 'DELETE '; + if ($queryComment = $criteria->getComment()) { + $sql .= '/* ' . $queryComment . ' */ '; + } + if ($realTableName = $criteria->getTableForAlias($tableName)) { + if ($this->useQuoteIdentifier()) { + $realTableName = $this->quoteIdentifierTable($realTableName); + } + $sql .= $tableName . ' FROM ' . $realTableName . ' AS ' . $tableName; + } else { + if ($this->useQuoteIdentifier()) { + $tableName = $this->quoteIdentifierTable($tableName); + } + $sql .= 'FROM ' . $tableName; + } + + return $sql; + } + + /** + * Builds the SELECT part of a SQL statement based on a Criteria + * taking into account select columns and 'as' columns (i.e. columns aliases) + * Move from BasePeer to DBAdapter and turn from static to non static + * + * @param Criteria $criteria + * @param array $fromClause + * @param boolean $aliasAll + * + * @return string + */ + public function createSelectSqlPart(Criteria $criteria, &$fromClause, $aliasAll = false) + { + $selectClause = array(); + + if ($aliasAll) { + $this->turnSelectColumnsToAliases($criteria); + // no select columns after that, they are all aliases + } else { + foreach ($criteria->getSelectColumns() as $columnName) { + + // expect every column to be of "table.column" formation + // it could be a function: e.g. MAX(books.price) + + $tableName = null; + + $selectClause[] = $columnName; // the full column name: e.g. MAX(books.price) + + $parenPos = strrpos($columnName, '('); + $dotPos = strrpos($columnName, '.', ($parenPos !== false ? $parenPos : 0)); + + if ($dotPos !== false) { + if ($parenPos === false) { // table.column + $tableName = substr($columnName, 0, $dotPos); + } else { // FUNC(table.column) + // functions may contain qualifiers so only take the last + // word as the table name. + // COUNT(DISTINCT books.price) + $tableName = substr($columnName, $parenPos + 1, $dotPos - ($parenPos + 1)); + $lastSpace = strrpos($tableName, ' '); + if ($lastSpace !== false) { // COUNT(DISTINCT books.price) + $tableName = substr($tableName, $lastSpace + 1); + } + } + // is it a table alias? + $tableName2 = $criteria->getTableForAlias($tableName); + if ($tableName2 !== null) { + $fromClause[] = $tableName2 . ' ' . $tableName; + } else { + $fromClause[] = $tableName; + } + } // if $dotPost !== false + } + } + + // set the aliases + foreach ($criteria->getAsColumns() as $alias => $col) { + $selectClause[] = $col . ' AS ' . $this->quoteIdentifier($alias); + } + + $selectModifiers = $criteria->getSelectModifiers(); + $queryComment = $criteria->getComment(); + + // Build the SQL from the arrays we compiled + $sql = "SELECT " + . ($queryComment ? '/* ' . $queryComment . ' */ ' : '') + . ($selectModifiers ? (implode(' ', $selectModifiers) . ' ') : '') + . implode(", ", $selectClause); + + return $sql; + } + + /** + * Ensures uniqueness of select column names by turning them all into aliases + * This is necessary for queries on more than one table when the tables share a column name + * Moved from BasePeer to DBAdapter and turned from static to non static + * + * @see http://propel.phpdb.org/trac/ticket/795 + * + * @param Criteria $criteria + * + * @return Criteria The input, with Select columns replaced by aliases + */ + public function turnSelectColumnsToAliases(Criteria $criteria) + { + $selectColumns = $criteria->getSelectColumns(); + // clearSelectColumns also clears the aliases, so get them too + $asColumns = $criteria->getAsColumns(); + $criteria->clearSelectColumns(); + $columnAliases = $asColumns; + // add the select columns back + foreach ($selectColumns as $clause) { + // Generate a unique alias + $baseAlias = preg_replace('/\W/', '_', $clause); + $alias = $baseAlias; + // If it already exists, add a unique suffix + $i = 0; + while (isset($columnAliases[$alias])) { + $i++; + $alias = $baseAlias . '_' . $i; + } + // Add it as an alias + $criteria->addAsColumn($alias, $clause); + $columnAliases[$alias] = $clause; + } + // Add the aliases back, don't modify them + foreach ($asColumns as $name => $clause) { + $criteria->addAsColumn($name, $clause); + } + + return $criteria; + } + + /** + * Binds values in a prepared statement. + * + * This method is designed to work with the BasePeer::createSelectSql() method, which creates + * both the SELECT SQL statement and populates a passed-in array of parameter + * values that should be substituted. + * + * + * $db = Propel::getDB($criteria->getDbName()); + * $sql = BasePeer::createSelectSql($criteria, $params); + * $stmt = $con->prepare($sql); + * $params = array(); + * $db->populateStmtValues($stmt, $params, Propel::getDatabaseMap($critera->getDbName())); + * $stmt->execute(); + * + * + * @param PDOStatement $stmt + * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) + * @param DatabaseMap $dbMap + */ + public function bindValues(PDOStatement $stmt, array $params, DatabaseMap $dbMap) + { + $position = 0; + foreach ($params as $param) { + $position++; + $parameter = ':p' . $position; + $value = $param['value']; + if (null === $value) { + $stmt->bindValue($parameter, null, PDO::PARAM_NULL); + continue; + } + $tableName = $param['table']; + if (null === $tableName) { + $type = isset($param['type']) ? $param['type'] : PDO::PARAM_STR; + $stmt->bindValue($parameter, $value, $type); + continue; + } + $cMap = $dbMap->getTable($tableName)->getColumn($param['column']); + $this->bindValue($stmt, $parameter, $value, $cMap, $position); + } + } + + /** + * Binds a value to a positioned parameted in a statement, + * given a ColumnMap object to infer the binding type. + * Warning: duplicates logic from DefaultPlatform::getColumnBindingPHP(). + * Any code modification here must be ported there. + * + * @param PDOStatement $stmt The statement to bind + * @param string $parameter Parameter identifier + * @param mixed $value The value to bind + * @param ColumnMap $cMap The ColumnMap of the column to bind + * @param null|integer $position The position of the parameter to bind + * + * @return boolean + */ + public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + { + if ($cMap->isTemporal()) { + $value = $this->formatTemporalValue($value, $cMap); + } elseif (is_resource($value) && $cMap->isLob()) { + // we always need to make sure that the stream is rewound, otherwise nothing will + // get written to database. + rewind($value); + } + + return $stmt->bindValue($parameter, $value, $cMap->getPdoType()); + } + + /** + * Do Explain Plan for query object or query string + * + * @param PropelPDO $con propel connection + * @param ModelCriteria|string $query query the criteria or the query string + * + * @throws PropelException if explain plan is not implemented for adapter + * @return PDOStatement A PDO statement executed using the connection, ready to be fetched + */ + public function doExplainPlan(PropelPDO $con, $query) + { + throw new PropelException("Explain plan is not implemented for this adapter"); + } } diff --git a/airtime_mvc/library/propel/runtime/lib/adapter/DBMSSQL.php b/airtime_mvc/library/propel/runtime/lib/adapter/DBMSSQL.php index f98fa7dfc..7692549ee 100644 --- a/airtime_mvc/library/propel/runtime/lib/adapter/DBMSSQL.php +++ b/airtime_mvc/library/propel/runtime/lib/adapter/DBMSSQL.php @@ -12,204 +12,322 @@ * This is used to connect to a MSSQL database. * * @author Hans Lellelid (Propel) - * @version $Revision: 1700 $ + * @version $Revision$ * @package propel.runtime.adapter */ class DBMSSQL extends DBAdapter { + /** + * MS SQL Server does not support SET NAMES + * + * @see DBAdapter::setCharset() + * + * @param PDO $con + * @param string $charset + */ + public function setCharset(PDO $con, $charset) + { + } - /** - * This method is used to ignore case. - * - * @param in The string to transform to upper case. - * @return The upper case string. - */ - public function toUpperCase($in) - { - return $this->ignoreCase($in); - } + /** + * This method is used to ignore case. + * + * @param string $in The string to transform to upper case. + * + * @return string The upper case string. + */ + public function toUpperCase($in) + { + return $this->ignoreCase($in); + } - /** - * This method is used to ignore case. - * - * @param in The string whose case to ignore. - * @return The string in a case that can be ignored. - */ - public function ignoreCase($in) - { - return 'UPPER(' . $in . ')'; - } + /** + * This method is used to ignore case. + * + * @param string $in The string whose case to ignore. + * + * @return string The string in a case that can be ignored. + */ + public function ignoreCase($in) + { + return 'UPPER(' . $in . ')'; + } - /** - * Returns SQL which concatenates the second string to the first. - * - * @param string String to concatenate. - * @param string String to append. - * @return string - */ - public function concatString($s1, $s2) - { - return '(' . $s1 . ' + ' . $s2 . ')'; - } + /** + * Returns SQL which concatenates the second string to the first. + * + * @param string $s1 String to concatenate. + * @param string $s2 String to append. + * + * @return string + */ + public function concatString($s1, $s2) + { + return '(' . $s1 . ' + ' . $s2 . ')'; + } - /** - * Returns SQL which extracts a substring. - * - * @param string String to extract from. - * @param int Offset to start from. - * @param int Number of characters to extract. - * @return string - */ - public function subString($s, $pos, $len) - { - return 'SUBSTRING(' . $s . ', ' . $pos . ', ' . $len . ')'; - } + /** + * Returns SQL which extracts a substring. + * + * @param string $s String to extract from. + * @param integer $pos Offset to start from. + * @param integer $len Number of characters to extract. + * + * @return string + */ + public function subString($s, $pos, $len) + { + return 'SUBSTRING(' . $s . ', ' . $pos . ', ' . $len . ')'; + } - /** - * Returns SQL which calculates the length (in chars) of a string. - * - * @param string String to calculate length of. - * @return string - */ - public function strLength($s) - { - return 'LEN(' . $s . ')'; - } + /** + * Returns SQL which calculates the length (in chars) of a string. + * + * @param string $s String to calculate length of. + * + * @return string + */ + public function strLength($s) + { + return 'LEN(' . $s . ')'; + } - /** - * @see DBAdapter::quoteIdentifier() - */ - public function quoteIdentifier($text) - { - return '[' . $text . ']'; - } + /** + * @see DBAdapter::quoteIdentifier() + * + * @param string $text + * + * @return string + */ + public function quoteIdentifier($text) + { + return '[' . $text . ']'; + } - /** - * @see DBAdapter::random() - */ - public function random($seed = null) - { - return 'RAND(' . ((int)$seed) . ')'; - } + /** + * @see DBAdapter::quoteIdentifierTable() + * + * @param string $table + * + * @return string + */ + public function quoteIdentifierTable($table) + { + // e.g. 'database.table alias' should be escaped as '[database].[table] [alias]' + return '[' . strtr($table, array('.' => '].[', ' ' => '] [')) . ']'; + } - /** - * Simulated Limit/Offset - * This rewrites the $sql query to apply the offset and limit. - * some of the ORDER BY logic borrowed from Doctrine MsSqlPlatform - * @see DBAdapter::applyLimit() - * @author Benjamin Runnels - */ - public function applyLimit(&$sql, $offset, $limit) - { - // make sure offset and limit are numeric - if(! is_numeric($offset) || ! is_numeric($limit)) - { - throw new PropelException('DBMSSQL::applyLimit() expects a number for argument 2 and 3'); - } + /** + * @see DBAdapter::random() + * + * @param string $seed + * + * @return string + */ + public function random($seed = null) + { + return 'RAND(' . ((int) $seed) . ')'; + } - //split the select and from clauses out of the original query - $selectSegment = array(); + /** + * Simulated Limit/Offset + * + * This rewrites the $sql query to apply the offset and limit. + * some of the ORDER BY logic borrowed from Doctrine MsSqlPlatform + * + * @see DBAdapter::applyLimit() + * @author Benjamin Runnels + * + * @param string $sql + * @param integer $offset + * @param integer $limit + * + * @return void + * + * @throws PropelException + * @throws Exception + */ + public function applyLimit(&$sql, $offset, $limit) + { + // make sure offset and limit are numeric + if (!is_numeric($offset) || !is_numeric($limit)) { + throw new PropelException('DBMSSQL::applyLimit() expects a number for argument 2 and 3'); + } - $selectText = 'SELECT '; + //split the select and from clauses out of the original query + $selectSegment = array(); - if (preg_match('/\Aselect(\s+)distinct/i', $sql)) { - $selectText .= 'DISTINCT '; - } + $selectText = 'SELECT '; - preg_match('/\Aselect(.*)from(.*)/si', $sql, $selectSegment); - if(count($selectSegment) == 3) { - $selectStatement = trim($selectSegment[1]); - $fromStatement = trim($selectSegment[2]); - } else { - throw new Exception('DBMSSQL::applyLimit() could not locate the select statement at the start of the query.'); - } + preg_match('/\Aselect(.*)from(.*)/si', $sql, $selectSegment); + if (count($selectSegment) == 3) { + $selectStatement = trim($selectSegment[1]); + $fromStatement = trim($selectSegment[2]); + } else { + throw new Exception('DBMSSQL::applyLimit() could not locate the select statement at the start of the query.'); + } - // if we're starting at offset 0 then theres no need to simulate limit, - // just grab the top $limit number of rows - if($offset == 0) { - $sql = $selectText . 'TOP ' . $limit . ' ' . $selectStatement . ' FROM ' . $fromStatement; - return; - } + if (preg_match('/\Aselect(\s+)distinct/i', $sql)) { + $selectText .= 'DISTINCT '; + $selectStatement = str_ireplace('distinct ', '', $selectStatement); + } - //get the ORDER BY clause if present - $orderStatement = stristr($fromStatement, 'ORDER BY'); - $orders = ''; + // if we're starting at offset 0 then theres no need to simulate LIMIT, + // just grab the top $limit number of rows + if ($offset == 0) { + $sql = $selectText . 'TOP ' . $limit . ' ' . $selectStatement . ' FROM ' . $fromStatement; - if($orderStatement !== false) { - //remove order statement from the from statement - $fromStatement = trim(str_replace($orderStatement, '', $fromStatement)); + return; + } - $order = str_ireplace('ORDER BY', '', $orderStatement); - $orders = explode(',', $order); + //get the ORDER BY clause if present + $orderStatement = stristr($fromStatement, 'ORDER BY'); + $orders = ''; - for($i = 0; $i < count($orders); $i ++) { - $orderArr[trim(preg_replace('/\s+(ASC|DESC)$/i', '', $orders[$i]))] = array( - 'sort' => (stripos($orders[$i], ' DESC') !== false) ? 'DESC' : 'ASC', - 'key' => $i - ); - } - } + if ($orderStatement !== false) { + //remove order statement from the FROM statement + $fromStatement = trim(str_replace($orderStatement, '', $fromStatement)); - //setup inner and outer select selects - $innerSelect = ''; - $outerSelect = ''; - foreach(explode(', ', $selectStatement) as $selCol) { - $selColArr = explode(' ', $selCol); - $selColCount = count($selColArr) - 1; + $order = str_ireplace('ORDER BY', '', $orderStatement); + $orders = array_map('trim', explode(',', $order)); - //make sure the current column isn't * or an aggregate - if($selColArr[0] != '*' && ! strstr($selColArr[0], '(')) { - if(isset($orderArr[$selColArr[0]])) { - $orders[$orderArr[$selColArr[0]]['key']] = $selColArr[0] . ' ' . $orderArr[$selColArr[0]]['sort']; - } + for ($i = 0; $i < count($orders); $i++) { + $orderArr[trim(preg_replace('/\s+(ASC|DESC)$/i', '', $orders[$i]))] = array( + 'sort' => (stripos($orders[$i], ' DESC') !== false) ? 'DESC' : 'ASC', + 'key' => $i + ); + } + } - //use the alias if one was present otherwise use the column name - $alias = (! stristr($selCol, ' AS ')) ? $this->quoteIdentifier($selColArr[0]) : $this->quoteIdentifier($selColArr[$selColCount]); + //setup inner and outer select selects + $innerSelect = ''; + $outerSelect = ''; + foreach (explode(', ', $selectStatement) as $selCol) { + $selColArr = explode(' ', $selCol); + $selColCount = count($selColArr) - 1; - //save the first non-aggregate column for use in ROW_NUMBER() if required - if(! isset($firstColumnOrderStatement)) { - $firstColumnOrderStatement = 'ORDER BY ' . $selColArr[0]; - } + //make sure the current column isn't * or an aggregate + if ($selColArr[0] != '*' && !strstr($selColArr[0], '(') && strtoupper($selColArr[0]) !== 'CASE') { - //add an alias to the inner select so all columns will be unique - $innerSelect .= $selColArr[0] . ' AS ' . $alias . ', '; - $outerSelect .= $alias . ', '; - } else { - //agregate columns must always have an alias clause - if(! stristr($selCol, ' AS ')) { - throw new Exception('DBMSSQL::applyLimit() requires aggregate columns to have an Alias clause'); - } + // Aliases can be used in ORDER BY clauses on a SELECT, + // but aliases are not valid in the ORDER BY clause of ROW_NUMBER() OVER (...), + // so if we notice that part of $order is actually an alias, + // we replace it with the original Table.Column designation. + if ($selColCount) { + // column with alias + foreach (array(' ASC', ' DESC') as $sort) { + $index = array_search($selColArr[2] . $sort, $orders); + if ($index !== false) { + // replace alias with "Table.Column ASC/DESC" + $orders[$index] = $selColArr[0] . $sort; + break; + } + } + } - //aggregate column alias can't be used as the count column you must use the entire aggregate statement - if(isset($orderArr[$selColArr[$selColCount]])) { - $orders[$orderArr[$selColArr[$selColCount]]['key']] = str_replace($selColArr[$selColCount - 1] . ' ' . $selColArr[$selColCount], '', $selCol) . $orderArr[$selColArr[$selColCount]]['sort']; - } + if (isset($orderArr[$selColArr[0]])) { + $orders[$orderArr[$selColArr[0]]['key']] = $selColArr[0] . ' ' . $orderArr[$selColArr[0]]['sort']; + } - //quote the alias - $alias = $this->quoteIdentifier($selColArr[$selColCount]); - $innerSelect .= str_replace($selColArr[$selColCount], $alias, $selCol) . ', '; - $outerSelect .= $alias . ', '; - } - } + //use the alias if one was present otherwise use the column name + $alias = (!stristr($selCol, ' AS ')) ? $selColArr[0] : $selColArr[$selColCount]; + //don't quote the identifier if it is already quoted + if ($alias[0] != '[') { + $alias = $this->quoteIdentifier($alias); + } - if(is_array($orders)) { - $orderStatement = 'ORDER BY ' . implode(', ', $orders); - } else { - //use the first non aggregate column in our select statement if no ORDER BY clause present - if(isset($firstColumnOrderStatement)) { - $orderStatement = $firstColumnOrderStatement; - } else { - throw new Exception('DBMSSQL::applyLimit() unable to find column to use with ROW_NUMBER()'); - } - } + //save the first non-aggregate column for use in ROW_NUMBER() if required + if (!isset($firstColumnOrderStatement)) { + $firstColumnOrderStatement = 'ORDER BY ' . $selColArr[0]; + } - //substring the select strings to get rid of the last comma and add our FROM and SELECT clauses - $innerSelect = $selectText . 'ROW_NUMBER() OVER(' . $orderStatement . ') AS RowNumber, ' . substr($innerSelect, 0, - 2) . ' FROM'; - //outer select can't use * because of the RowNumber column - $outerSelect = 'SELECT ' . substr($outerSelect, 0, - 2) . ' FROM'; + //add an alias to the inner select so all columns will be unique + $innerSelect .= $selColArr[0] . ' AS ' . $alias . ', '; + $outerSelect .= $alias . ', '; + } else { + //aggregate columns must always have an alias clause + if (!stristr($selCol, ' AS ')) { + throw new Exception('DBMSSQL::applyLimit() requires aggregate columns to have an Alias clause'); + } - //ROW_NUMBER() starts at 1 not 0 - $sql = $outerSelect . ' (' . $innerSelect . ' ' . $fromStatement . ') AS derivedb WHERE RowNumber BETWEEN ' . ($offset + 1) . ' AND ' . ($limit + $offset); - return; - } + //aggregate column alias can't be used as the count column you must use the entire aggregate statement + if (isset($orderArr[$selColArr[$selColCount]])) { + $orders[$orderArr[$selColArr[$selColCount]]['key']] = str_replace($selColArr[$selColCount - 1] . ' ' . $selColArr[$selColCount], '', $selCol) . $orderArr[$selColArr[$selColCount]]['sort']; + } + + //quote the alias + $alias = $selColArr[$selColCount]; + //don't quote the identifier if it is already quoted + if ($alias[0] != '[') { + $alias = $this->quoteIdentifier($alias); + } + $innerSelect .= str_replace($selColArr[$selColCount], $alias, $selCol) . ', '; + $outerSelect .= $alias . ', '; + } + } + + if (is_array($orders)) { + $orderStatement = 'ORDER BY ' . implode(', ', $orders); + } else { + //use the first non aggregate column in our select statement if no ORDER BY clause present + if (isset($firstColumnOrderStatement)) { + $orderStatement = $firstColumnOrderStatement; + } else { + throw new Exception('DBMSSQL::applyLimit() unable to find column to use with ROW_NUMBER()'); + } + } + + //substring the select strings to get rid of the last comma and add our FROM and SELECT clauses + $innerSelect = $selectText . 'ROW_NUMBER() OVER(' . $orderStatement . ') AS [RowNumber], ' . substr($innerSelect, 0, -2) . ' FROM'; + //outer select can't use * because of the RowNumber column + $outerSelect = 'SELECT ' . substr($outerSelect, 0, -2) . ' FROM'; + + //ROW_NUMBER() starts at 1 not 0 + $sql = $outerSelect . ' (' . $innerSelect . ' ' . $fromStatement . ') AS derivedb WHERE RowNumber BETWEEN ' . ($offset + 1) . ' AND ' . ($limit + $offset); + } + + /** + * @see parent::cleanupSQL() + * + * @param string $sql + * @param array $params + * @param Criteria $values + * @param DatabaseMap $dbMap + */ + public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap) + { + $i = 1; + $paramCols = array(); + foreach ($params as $param) { + if (null !== $param['table']) { + $column = $dbMap->getTable($param['table'])->getColumn($param['column']); + /* MSSQL pdo_dblib and pdo_mssql blob values must be converted to hex and then the hex added + * to the query string directly. If it goes through PDOStatement::bindValue quotes will cause + * an error with the insert or update. + */ + if (is_resource($param['value']) && $column->isLob()) { + // we always need to make sure that the stream is rewound, otherwise nothing will + // get written to database. + rewind($param['value']); + $hexArr = unpack('H*hex', stream_get_contents($param['value'])); + $sql = str_replace(":p$i", '0x' . $hexArr['hex'], $sql); + unset($hexArr); + fclose($param['value']); + } else { + $paramCols[] = $param; + } + } + $i++; + } + + //if we made changes re-number the params + if ($params != $paramCols) { + $params = $paramCols; + unset($paramCols); + preg_match_all('/:p\d/', $sql, $matches); + foreach ($matches[0] as $key => $match) { + $sql = str_replace($match, ':p' . ($key + 1), $sql); + } + } + } } diff --git a/airtime_mvc/library/propel/runtime/lib/adapter/DBMySQL.php b/airtime_mvc/library/propel/runtime/lib/adapter/DBMySQL.php index 99818e8cd..f629c6818 100644 --- a/airtime_mvc/library/propel/runtime/lib/adapter/DBMySQL.php +++ b/airtime_mvc/library/propel/runtime/lib/adapter/DBMySQL.php @@ -15,131 +15,279 @@ * @author Jon S. Stevens (Torque) * @author Brett McLaughlin (Torque) * @author Daniel Rall (Torque) - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.adapter */ -class DBMySQL extends DBAdapter +class DBMySQL extends DBAdapter { + /** + * This method is used to ignore case. + * + * @param string $in The string to transform to upper case. + * + * @return string The upper case string. + */ + public function toUpperCase($in) + { + return "UPPER(" . $in . ")"; + } - /** - * This method is used to ignore case. - * - * @param in The string to transform to upper case. - * @return The upper case string. - */ - public function toUpperCase($in) - { - return "UPPER(" . $in . ")"; - } + /** + * This method is used to ignore case. + * + * @param string $in The string whose case to ignore. + * + * @return string The string in a case that can be ignored. + */ + public function ignoreCase($in) + { + return "UPPER(" . $in . ")"; + } - /** - * This method is used to ignore case. - * - * @param in The string whose case to ignore. - * @return The string in a case that can be ignored. - */ - public function ignoreCase($in) - { - return "UPPER(" . $in . ")"; - } + /** + * Returns SQL which concatenates the second string to the first. + * + * @param string $s1 String to concatenate. + * @param string $s2 String to append. + * + * @return string + */ + public function concatString($s1, $s2) + { + return "CONCAT($s1, $s2)"; + } - /** - * Returns SQL which concatenates the second string to the first. - * - * @param string String to concatenate. - * @param string String to append. - * @return string - */ - public function concatString($s1, $s2) - { - return "CONCAT($s1, $s2)"; - } + /** + * Returns SQL which extracts a substring. + * + * @param string $s String to extract from. + * @param integer $pos Offset to start from. + * @param integer $len Number of characters to extract. + * + * @return string + */ + public function subString($s, $pos, $len) + { + return "SUBSTRING($s, $pos, $len)"; + } - /** - * Returns SQL which extracts a substring. - * - * @param string String to extract from. - * @param int Offset to start from. - * @param int Number of characters to extract. - * @return string - */ - public function subString($s, $pos, $len) - { - return "SUBSTRING($s, $pos, $len)"; - } + /** + * Returns SQL which calculates the length (in chars) of a string. + * + * @param string $s String to calculate length of. + * + * @return string + */ + public function strLength($s) + { + return "CHAR_LENGTH($s)"; + } - /** - * Returns SQL which calculates the length (in chars) of a string. - * - * @param string String to calculate length of. - * @return string - */ - public function strLength($s) - { - return "CHAR_LENGTH($s)"; - } + /** + * Locks the specified table. + * + * @param PDO $con The Propel connection to use. + * @param string $table The name of the table to lock. + * + * @throws PDOException No Statement could be created or executed. + */ + public function lockTable(PDO $con, $table) + { + $con->exec("LOCK TABLE " . $table . " WRITE"); + } + /** + * Unlocks the specified table. + * + * @param PDO $con The PDO connection to use. + * @param string $table The name of the table to unlock. + * + * @throws PDOException No Statement could be created or executed. + */ + public function unlockTable(PDO $con, $table) + { + $statement = $con->exec("UNLOCK TABLES"); + } - /** - * Locks the specified table. - * - * @param Connection $con The Propel connection to use. - * @param string $table The name of the table to lock. - * @throws PDOException No Statement could be created or - * executed. - */ - public function lockTable(PDO $con, $table) - { - $con->exec("LOCK TABLE " . $table . " WRITE"); - } + /** + * @see DBAdapter::quoteIdentifier() + * + * @param string $text + * + * @return string + */ + public function quoteIdentifier($text) + { + return '`' . $text . '`'; + } - /** - * Unlocks the specified table. - * - * @param PDO $con The PDO connection to use. - * @param string $table The name of the table to unlock. - * @throws PDOException No Statement could be created or - * executed. - */ - public function unlockTable(PDO $con, $table) - { - $statement = $con->exec("UNLOCK TABLES"); - } + /** + * @see DBAdapter::quoteIdentifierTable() + * + * @param string $table + * + * @return string + */ + public function quoteIdentifierTable($table) + { + // e.g. 'database.table alias' should be escaped as '`database`.`table` `alias`' + return '`' . strtr($table, array('.' => '`.`', ' ' => '` `')) . '`'; + } - /** - * @see DBAdapter::quoteIdentifier() - */ - public function quoteIdentifier($text) - { - return '`' . $text . '`'; - } + /** + * @see DBAdapter::useQuoteIdentifier() + * + * @return boolean + */ + public function useQuoteIdentifier() + { + return true; + } - /** - * @see DBAdapter::useQuoteIdentifier() - */ - public function useQuoteIdentifier() - { - return true; - } + /** + * @see DBAdapter::applyLimit() + * + * @param string $sql + * @param integer $offset + * @param integer $limit + */ + public function applyLimit(&$sql, $offset, $limit) + { + if ($limit > 0) { + $sql .= " LIMIT " . ($offset > 0 ? $offset . ", " : "") . $limit; + } elseif ($offset > 0) { + $sql .= " LIMIT " . $offset . ", 18446744073709551615"; + } + } - /** - * @see DBAdapter::applyLimit() - */ - public function applyLimit(&$sql, $offset, $limit) - { - if ( $limit > 0 ) { - $sql .= " LIMIT " . ($offset > 0 ? $offset . ", " : "") . $limit; - } else if ( $offset > 0 ) { - $sql .= " LIMIT " . $offset . ", 18446744073709551615"; - } - } + /** + * @see DBAdapter::random() + * + * @param string $seed + * + * @return string + */ + public function random($seed = null) + { + return 'rand(' . ((int) $seed) . ')'; + } - /** - * @see DBAdapter::random() - */ - public function random($seed = null) - { - return 'rand('.((int) $seed).')'; - } + /** + * @see DBAdapter::bindValue() + * + * @param PDOStatement $stmt + * @param string $parameter + * @param mixed $value + * @param ColumnMap $cMap + * @param null|integer $position + * + * @return boolean + */ + public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + { + $pdoType = $cMap->getPdoType(); + // FIXME - This is a temporary hack to get around apparent bugs w/ PDO+MYSQL + // See http://pecl.php.net/bugs/bug.php?id=9919 + if ($pdoType == PDO::PARAM_BOOL) { + $value = (int) $value; + $pdoType = PDO::PARAM_INT; + return $stmt->bindValue($parameter, $value, $pdoType); + } elseif ($cMap->isTemporal()) { + $value = $this->formatTemporalValue($value, $cMap); + } elseif (is_resource($value) && $cMap->isLob()) { + // we always need to make sure that the stream is rewound, otherwise nothing will + // get written to database. + rewind($value); + } + + return $stmt->bindValue($parameter, $value, $pdoType); + } + + /** + * Prepare connection parameters. + * See: http://www.propelorm.org/ticket/1360 + * + * @param array $params + * + * @return array + * + * @throws PropelException + */ + public function prepareParams($params) + { + $params = parent::prepareParams($params); + // Whitelist based on https://bugs.php.net/bug.php?id=47802 + // And https://bugs.php.net/bug.php?id=47802 + $whitelist = array( + 'ASCII', + 'CP1250', + 'CP1251', + 'CP1252', + 'CP1256', + 'CP1257', + 'GREEK', + 'HEBREW', + 'LATIN1', + 'LATIN2', + 'LATIN5', + 'LATIN7', + 'SWE7', + 'UTF8', + 'UTF-8', + ); + + if (isset($params['settings']['charset']['value'])) { + if (version_compare(PHP_VERSION, '5.3.6', '<')) { + $charset = strtoupper($params['settings']['charset']['value']); + + if (!in_array($charset, $whitelist)) { + throw new PropelException(<<getDbName()); + $sql = BasePeer::createSelectSql($query, $params); + $sql = 'EXPLAIN ' . $sql; + } else { + $sql = 'EXPLAIN ' . $query; + } + + $stmt = $con->prepare($sql); + + if ($query instanceof ModelCriteria) { + $this->bindValues($stmt, $params, $dbMap); + } + + $stmt->execute(); + + return $stmt; + } } diff --git a/airtime_mvc/library/propel/runtime/lib/adapter/DBNone.php b/airtime_mvc/library/propel/runtime/lib/adapter/DBNone.php index 1349f17da..841677d3e 100644 --- a/airtime_mvc/library/propel/runtime/lib/adapter/DBNone.php +++ b/airtime_mvc/library/propel/runtime/lib/adapter/DBNone.php @@ -14,91 +14,102 @@ * @author Hans Lellelid (Propel) * @author Jon S. Stevens (Torque) * @author Brett McLaughlin (Torque) - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.adapter */ class DBNone extends DBAdapter { - /** - * @see DBAdapter::initConnection() - */ - public function initConnection(PDO $con, array $settings) - { - } + /** + * @see DBAdapter::initConnection() + * + * @param PDO $con + * @param array $settings + */ + public function initConnection(PDO $con, array $settings) + { + } - /** - * This method is used to ignore case. - * - * @param in The string to transform to upper case. - * @return The upper case string. - */ - public function toUpperCase($in) - { - return $in; - } + /** + * This method is used to ignore case. + * + * @param string $in The string to transform to upper case. + * + * @return string The upper case string. + */ + public function toUpperCase($in) + { + return $in; + } - /** - * This method is used to ignore case. - * - * @param in The string whose case to ignore. - * @return The string in a case that can be ignored. - */ - public function ignoreCase($in) - { - return $in; - } + /** + * This method is used to ignore case. + * + * @param string $in The string whose case to ignore. + * + * @return string The string in a case that can be ignored. + */ + public function ignoreCase($in) + { + return $in; + } - /** - * Returns SQL which concatenates the second string to the first. - * - * @param string String to concatenate. - * @param string String to append. - * @return string - */ - public function concatString($s1, $s2) - { - return ($s1 . $s2); - } + /** + * Returns SQL which concatenates the second string to the first. + * + * @param string $s1 String to concatenate. + * @param string $s2 String to append. + * + * @return string + */ + public function concatString($s1, $s2) + { + return ($s1 . $s2); + } - /** - * Returns SQL which extracts a substring. - * - * @param string String to extract from. - * @param int Offset to start from. - * @param int Number of characters to extract. - * @return string - */ - public function subString($s, $pos, $len) - { - return substr($s, $pos, $len); - } + /** + * Returns SQL which extracts a substring. + * + * @param string $s String to extract from. + * @param integer $pos Offset to start from. + * @param integer $len Number of characters to extract. + * + * @return string + */ + public function subString($s, $pos, $len) + { + return substr($s, $pos, $len); + } - /** - * Returns SQL which calculates the length (in chars) of a string. - * - * @param string String to calculate length of. - * @return string - */ - public function strLength($s) - { - return strlen($s); - } - - /** - * Modifies the passed-in SQL to add LIMIT and/or OFFSET. - */ - public function applyLimit(&$sql, $offset, $limit) - { - } + /** + * Returns SQL which calculates the length (in chars) of a string. + * + * @param string $s String to calculate length of. + * + * @return string + */ + public function strLength($s) + { + return strlen($s); + } - /** - * Gets the SQL string that this adapter uses for getting a random number. - * - * @param mixed $seed (optional) seed value for databases that support this - */ - public function random($seed = null) - { - } - + /** + * Modifies the passed-in SQL to add LIMIT and/or OFFSET. + * + * @param string $sql + * @param integer $offset + * @param integer $limit + */ + public function applyLimit(&$sql, $offset, $limit) + { + } + + /** + * Gets the SQL string that this adapter uses for getting a random number. + * + * @param string $seed (optional) seed value for databases that support this + */ + public function random($seed = null) + { + } } diff --git a/airtime_mvc/library/propel/runtime/lib/adapter/DBOracle.php b/airtime_mvc/library/propel/runtime/lib/adapter/DBOracle.php index f67000a8e..77aef5698 100644 --- a/airtime_mvc/library/propel/runtime/lib/adapter/DBOracle.php +++ b/airtime_mvc/library/propel/runtime/lib/adapter/DBOracle.php @@ -17,134 +17,293 @@ * @author Brett McLaughlin (Torque) * @author Bill Schneider (Torque) * @author Daniel Rall (Torque) - * @version $Revision: 1669 $ + * @version $Revision$ * @package propel.runtime.adapter */ class DBOracle extends DBAdapter { - /** - * This method is called after a connection was created to run necessary - * post-initialization queries or code. - * Removes the charset query and adds the date queries - * - * @param PDO A PDO connection instance. - * @see parent::initConnection() - */ - public function initConnection(PDO $con, array $settings) - { - $con->exec("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'"); - $con->exec("ALTER SESSION SET NLS_TIMESTAMP_FORMAT='YYYY-MM-DD HH24:MI:SS'"); - if (isset($settings['queries']) && is_array($settings['queries'])) { - foreach ($settings['queries'] as $queries) { - foreach ((array)$queries as $query) { - $con->exec($query); - } - } - } - } - - /** - * This method is used to ignore case. - * - * @param string $in The string to transform to upper case. - * @return string The upper case string. - */ - public function toUpperCase($in) - { - return "UPPER(" . $in . ")"; - } + /** + * This method is called after a connection was created to run necessary + * post-initialization queries or code. + * Removes the charset query and adds the date queries + * + * @see parent::initConnection() + * + * @param PDO $con + * @param array $settings A $PDO PDO connection instance + */ + public function initConnection(PDO $con, array $settings) + { + $con->exec("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'"); + $con->exec("ALTER SESSION SET NLS_TIMESTAMP_FORMAT='YYYY-MM-DD HH24:MI:SS'"); + if (isset($settings['queries']) && is_array($settings['queries'])) { + foreach ($settings['queries'] as $queries) { + foreach ((array) $queries as $query) { + $con->exec($query); + } + } + } + } - /** - * This method is used to ignore case. - * - * @param string $in The string whose case to ignore. - * @return string The string in a case that can be ignored. - */ - public function ignoreCase($in) - { - return "UPPER(" . $in . ")"; - } + /** + * This method is used to ignore case. + * + * @param string $in The string to transform to upper case. + * + * @return string The upper case string. + */ + public function toUpperCase($in) + { + return "UPPER(" . $in . ")"; + } - /** - * Returns SQL which concatenates the second string to the first. - * - * @param string String to concatenate. - * @param string String to append. - * @return string - */ - public function concatString($s1, $s2) - { - return "CONCAT($s1, $s2)"; - } + /** + * This method is used to ignore case. + * + * @param string $in The string whose case to ignore. + * + * @return string The string in a case that can be ignored. + */ + public function ignoreCase($in) + { + return "UPPER(" . $in . ")"; + } - /** - * Returns SQL which extracts a substring. - * - * @param string String to extract from. - * @param int Offset to start from. - * @param int Number of characters to extract. - * @return string - */ - public function subString($s, $pos, $len) - { - return "SUBSTR($s, $pos, $len)"; - } + /** + * Returns SQL which concatenates the second string to the first. + * + * @param string $s1 String to concatenate. + * @param string $s2 String to append. + * + * @return string + */ + public function concatString($s1, $s2) + { + return "CONCAT($s1, $s2)"; + } - /** - * Returns SQL which calculates the length (in chars) of a string. - * - * @param string String to calculate length of. - * @return string - */ - public function strLength($s) - { - return "LENGTH($s)"; - } + /** + * Returns SQL which extracts a substring. + * + * @param string $s String to extract from. + * @param integer $pos Offset to start from. + * @param integer $len Number of characters to extract. + * + * @return string + */ + public function subString($s, $pos, $len) + { + return "SUBSTR($s, $pos, $len)"; + } - /** - * @see DBAdapter::applyLimit() - */ - public function applyLimit(&$sql, $offset, $limit, $criteria = null) - { - if (BasePeer::needsSelectAliases($criteria)) { - $selectSql = BasePeer::createSelectSqlPart($criteria, $params, true); - $sql = $selectSql . substr($sql, strpos('FROM', $sql)); - } - $sql = 'SELECT B.* FROM (' - . 'SELECT A.*, rownum AS PROPEL_ROWNUM FROM (' . $sql . ') A ' - . ') B WHERE '; + /** + * Returns SQL which calculates the length (in chars) of a string. + * + * @param string $s String to calculate length of. + * + * @return string + */ + public function strLength($s) + { + return "LENGTH($s)"; + } - if ( $offset > 0 ) { - $sql .= ' B.PROPEL_ROWNUM > ' . $offset; - if ( $limit > 0 ) { - $sql .= ' AND B.PROPEL_ROWNUM <= ' . ( $offset + $limit ); - } - } else { - $sql .= ' B.PROPEL_ROWNUM <= ' . $limit; - } - } + /** + * @see DBAdapter::applyLimit() + * + * @param string $sql + * @param integer $offset + * @param integer $limit + * @param null|Criteria $criteria + */ + public function applyLimit(&$sql, $offset, $limit, $criteria = null) + { + if (BasePeer::needsSelectAliases($criteria)) { + $crit = clone $criteria; + $selectSql = $this->createSelectSqlPart($crit, $params, true); + $sql = $selectSql . substr($sql, strpos($sql, 'FROM') - 1); + } + $sql = 'SELECT B.* FROM (' + . 'SELECT A.*, rownum AS PROPEL_ROWNUM FROM (' . $sql . ') A ' + . ') B WHERE '; - protected function getIdMethod() - { - return DBAdapter::ID_METHOD_SEQUENCE; - } + if ($offset > 0) { + $sql .= ' B.PROPEL_ROWNUM > ' . $offset; + if ($limit > 0) { + $sql .= ' AND B.PROPEL_ROWNUM <= ' . ($offset + $limit); + } + } else { + $sql .= ' B.PROPEL_ROWNUM <= ' . $limit; + } + } - public function getId(PDO $con, $name = null) - { - if ($name === null) { - throw new PropelException("Unable to fetch next sequence ID without sequence name."); - } + /** + * @return int + */ + protected function getIdMethod() + { + return DBAdapter::ID_METHOD_SEQUENCE; + } - $stmt = $con->query("SELECT " . $name . ".nextval FROM dual"); - $row = $stmt->fetch(PDO::FETCH_NUM); + /** + * @param PDO $con + * @param string $name + * + * @throws PropelException + * @return integer + */ + public function getId(PDO $con, $name = null) + { + if ($name === null) { + throw new PropelException("Unable to fetch next sequence ID without sequence name."); + } - return $row[0]; - } + $stmt = $con->query("SELECT " . $name . ".nextval FROM dual"); + $row = $stmt->fetch(PDO::FETCH_NUM); - public function random($seed=NULL) - { - return 'dbms_random.value'; - } + return $row[0]; + } + /** + * @param string $seed + * + * @return string + */ + public function random($seed = null) + { + return 'dbms_random.value'; + } + /** + * Ensures uniqueness of select column names by turning them all into aliases + * This is necessary for queries on more than one table when the tables share a column name + * + * @see http://propel.phpdb.org/trac/ticket/795 + * + * @param Criteria $criteria + * + * @return Criteria The input, with Select columns replaced by aliases + */ + public function turnSelectColumnsToAliases(Criteria $criteria) + { + $selectColumns = $criteria->getSelectColumns(); + // clearSelectColumns also clears the aliases, so get them too + $asColumns = $criteria->getAsColumns(); + $criteria->clearSelectColumns(); + $columnAliases = $asColumns; + // add the select columns back + foreach ($selectColumns as $id => $clause) { + // Generate a unique alias + $baseAlias = "ORA_COL_ALIAS_" . $id; + $alias = $baseAlias; + // If it already exists, add a unique suffix + $i = 0; + while (isset($columnAliases[$alias])) { + $i++; + $alias = $baseAlias . '_' . $i; + } + // Add it as an alias + $criteria->addAsColumn($alias, $clause); + $columnAliases[$alias] = $clause; + } + // Add the aliases back, don't modify them + foreach ($asColumns as $name => $clause) { + $criteria->addAsColumn($name, $clause); + } + + return $criteria; + } + + /** + * @see DBAdapter::bindValue() + * Warning: duplicates logic from OraclePlatform::getColumnBindingPHP(). + * Any code modification here must be ported there. + * + * @param PDOStatement $stmt + * @param string $parameter + * @param mixed $value + * @param ColumnMap $cMap + * @param null|integer $position + * + * @return boolean + */ + public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + { + if ($cMap->isTemporal()) { + $value = $this->formatTemporalValue($value, $cMap); + } elseif ($cMap->getType() == PropelColumnTypes::CLOB_EMU) { + return $stmt->bindParam(':p' . $position, $value, $cMap->getPdoType(), strlen($value)); + } elseif (is_resource($value) && $cMap->isLob()) { + // we always need to make sure that the stream is rewound, otherwise nothing will + // get written to database. + rewind($value); + } + + return $stmt->bindValue($parameter, $value, $cMap->getPdoType()); + } + + /** + * Do Explain Plan for query object or query string + * + * @param PropelPDO $con propel connection + * @param ModelCriteria|string $query query the criteria or the query string + * + * @throws PropelException + * @return PDOStatement A PDO statement executed using the connection, ready to be fetched + */ + public function doExplainPlan(PropelPDO $con, $query) + { + $con->beginTransaction(); + if ($query instanceof ModelCriteria) { + $params = array(); + $dbMap = Propel::getDatabaseMap($query->getDbName()); + $sql = BasePeer::createSelectSql($query, $params); + } else { + $sql = $query; + } + // unique id for the query string + $uniqueId = uniqid('Propel', true); + + $stmt = $con->prepare($this->getExplainPlanQuery($sql, $uniqueId)); + + if ($query instanceof ModelCriteria) { + $this->bindValues($stmt, $params, $dbMap); + } + + $stmt->execute(); + // explain plan is save in a table, data must be commit + $con->commit(); + + $stmt = $con->prepare($this->getExplainPlanReadQuery($uniqueId)); + $stmt->execute(); + + return $stmt; + } + + /** + * Explain Plan compute query getter + * + * @param string $query query to explain + * @param string $uniqueId query unique id + * + * @return string + */ + public function getExplainPlanQuery($query, $uniqueId) + { + return sprintf('EXPLAIN PLAN SET STATEMENT_ID = \'%s\' FOR %s', $uniqueId, $query); + } + + /** + * Explain Plan read query + * + * @param string $uniqueId + * + * @return string query unique id + */ + public function getExplainPlanReadQuery($uniqueId) + { + return sprintf('SELECT LEVEL, OPERATION, OPTIONS, COST, CARDINALITY, BYTES +FROM PLAN_TABLE CONNECT BY PRIOR ID = PARENT_ID AND PRIOR STATEMENT_ID = STATEMENT_ID +START WITH ID = 0 AND STATEMENT_ID = \'%s\' ORDER BY ID', $uniqueId); + } } diff --git a/airtime_mvc/library/propel/runtime/lib/adapter/DBPostgres.php b/airtime_mvc/library/propel/runtime/lib/adapter/DBPostgres.php index ad3243402..bbf899ac1 100644 --- a/airtime_mvc/library/propel/runtime/lib/adapter/DBPostgres.php +++ b/airtime_mvc/library/propel/runtime/lib/adapter/DBPostgres.php @@ -15,127 +15,238 @@ * * @author Hans Lellelid (Propel) * @author Hakan Tandogan (Torque) - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.adapter */ class DBPostgres extends DBAdapter { - /** - * This method is used to ignore case. - * - * @param string $in The string to transform to upper case. - * @return string The upper case string. - */ - public function toUpperCase($in) - { - return "UPPER(" . $in . ")"; - } + /** + * This method is used to ignore case. + * + * @param string $in The string to transform to upper case. + * + * @return string The upper case string. + */ + public function toUpperCase($in) + { + return "UPPER(" . $in . ")"; + } - /** - * This method is used to ignore case. - * - * @param in The string whose case to ignore. - * @return The string in a case that can be ignored. - */ - public function ignoreCase($in) - { - return "UPPER(" . $in . ")"; - } + /** + * This method is used to ignore case. + * + * @param string $in The string whose case to ignore. + * + * @return string The string in a case that can be ignored. + */ + public function ignoreCase($in) + { + return "UPPER(" . $in . ")"; + } - /** - * Returns SQL which concatenates the second string to the first. - * - * @param string String to concatenate. - * @param string String to append. - * @return string - */ - public function concatString($s1, $s2) - { - return "($s1 || $s2)"; - } + /** + * Returns SQL which concatenates the second string to the first. + * + * @param string $s1 String to concatenate. + * @param string $s2 String to append. + * + * @return string + */ + public function concatString($s1, $s2) + { + return "($s1 || $s2)"; + } - /** - * Returns SQL which extracts a substring. - * - * @param string String to extract from. - * @param int Offset to start from. - * @param int Number of characters to extract. - * @return string - */ - public function subString($s, $pos, $len) - { - return "substring($s from $pos" . ($len > -1 ? "for $len" : "") . ")"; - } + /** + * Returns SQL which extracts a substring. + * + * @param string $s String to extract from. + * @param integer $pos Offset to start from. + * @param integer $len Number of characters to extract. + * + * @return string + */ + public function subString($s, $pos, $len) + { + return "substring($s from $pos" . ($len > -1 ? "for $len" : "") . ")"; + } - /** - * Returns SQL which calculates the length (in chars) of a string. - * - * @param string String to calculate length of. - * @return string - */ - public function strLength($s) - { - return "char_length($s)"; - } + /** + * Returns SQL which calculates the length (in chars) of a string. + * + * @param string $s String to calculate length of. + * + * @return string + */ + public function strLength($s) + { + return "char_length($s)"; + } - /** - * @see DBAdapter::getIdMethod() - */ - protected function getIdMethod() - { - return DBAdapter::ID_METHOD_SEQUENCE; - } + /** + * @see DBAdapter::getIdMethod() + * + * @return integer + */ + protected function getIdMethod() + { + return DBAdapter::ID_METHOD_SEQUENCE; + } - /** - * Gets ID for specified sequence name. - */ - public function getId(PDO $con, $name = null) - { - if ($name === null) { - throw new PropelException("Unable to fetch next sequence ID without sequence name."); - } - $stmt = $con->query("SELECT nextval(".$con->quote($name).")"); - $row = $stmt->fetch(PDO::FETCH_NUM); - return $row[0]; - } + /** + * Gets ID for specified sequence name. + * Warning: duplicates logic from PgsqlPlatform::getIdentifierPhp(). + * Any code modification here must be ported there. + * + * @param PDO $con + * @param string $name + * + * @return integer + * + * @throws PropelException + */ + public function getId(PDO $con, $name = null) + { + if ($name === null) { + throw new PropelException("Unable to fetch next sequence ID without sequence name."); + } + $stmt = $con->query("SELECT nextval(" . $con->quote($name) . ")"); + $row = $stmt->fetch(PDO::FETCH_NUM); - /** - * Returns timestamp formatter string for use in date() function. - * @return string - */ - public function getTimestampFormatter() - { - return "Y-m-d H:i:s O"; - } + return $row[0]; + } - /** - * Returns timestamp formatter string for use in date() function. - * @return string - */ - public function getTimeFormatter() - { - return "H:i:s O"; - } + /** + * Returns timestamp formatter string for use in date() function. + * + * @return string + */ + public function getTimestampFormatter() + { + return "Y-m-d H:i:s O"; + } - /** - * @see DBAdapter::applyLimit() - */ - public function applyLimit(&$sql, $offset, $limit) - { - if ( $limit > 0 ) { - $sql .= " LIMIT ".$limit; - } - if ( $offset > 0 ) { - $sql .= " OFFSET ".$offset; - } - } - - /** - * @see DBAdapter::random() - */ - public function random($seed=NULL) - { - return 'random()'; - } + /** + * Returns timestamp formatter string for use in date() function. + * + * @return string + */ + public function getTimeFormatter() + { + return "H:i:s O"; + } + + /** + * @see DBAdapter::applyLimit() + * + * @param string $sql + * @param integer $offset + * @param integer $limit + */ + public function applyLimit(&$sql, $offset, $limit) + { + if ($limit > 0) { + $sql .= " LIMIT " . $limit; + } + if ($offset > 0) { + $sql .= " OFFSET " . $offset; + } + } + + /** + * @see DBAdapter::random() + * + * @param string $seed + * + * @return string + */ + public function random($seed = null) + { + return 'random()'; + } + + /** + * @see DBAdapter::getDeleteFromClause() + * + * @param Criteria $criteria + * @param string $tableName + * + * @return string + */ + public function getDeleteFromClause($criteria, $tableName) + { + $sql = 'DELETE '; + if ($queryComment = $criteria->getComment()) { + $sql .= '/* ' . $queryComment . ' */ '; + } + if ($realTableName = $criteria->getTableForAlias($tableName)) { + if ($this->useQuoteIdentifier()) { + $realTableName = $this->quoteIdentifierTable($realTableName); + } + $sql .= 'FROM ' . $realTableName . ' AS ' . $tableName; + } else { + if ($this->useQuoteIdentifier()) { + $tableName = $this->quoteIdentifierTable($tableName); + } + $sql .= 'FROM ' . $tableName; + } + + return $sql; + } + + /** + * @see DBAdapter::quoteIdentifierTable() + * + * @param string $table + * + * @return string + */ + public function quoteIdentifierTable($table) + { + // e.g. 'database.table alias' should be escaped as '"database"."table" "alias"' + return '"' . strtr($table, array('.' => '"."', ' ' => '" "')) . '"'; + } + + /** + * Do Explain Plan for query object or query string + * + * @param PropelPDO $con propel connection + * @param ModelCriteria|string $query query the criteria or the query string + * + * @throws PropelException + * @return PDOStatement A PDO statement executed using the connection, ready to be fetched + */ + public function doExplainPlan(PropelPDO $con, $query) + { + if ($query instanceof ModelCriteria) { + $params = array(); + $dbMap = Propel::getDatabaseMap($query->getDbName()); + $sql = BasePeer::createSelectSql($query, $params); + } else { + $sql = $query; + } + + $stmt = $con->prepare($this->getExplainPlanQuery($sql)); + + if ($query instanceof ModelCriteria) { + $this->bindValues($stmt, $params, $dbMap); + } + + $stmt->execute(); + + return $stmt; + } + + /** + * Explain Plan compute query getter + * + * @param string $query query to explain + * + * @return string + */ + public function getExplainPlanQuery($query) + { + return 'EXPLAIN ' . $query; + } } diff --git a/airtime_mvc/library/propel/runtime/lib/adapter/DBSQLSRV.php b/airtime_mvc/library/propel/runtime/lib/adapter/DBSQLSRV.php new file mode 100644 index 000000000..adb3c63ad --- /dev/null +++ b/airtime_mvc/library/propel/runtime/lib/adapter/DBSQLSRV.php @@ -0,0 +1,115 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $con->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); + + parent::initConnection($con, $settings); + } + + /** + * @see parent::setCharset() + * + * @param PDO $con + * @param string $charset + * + * @throws PropelException + */ + public function setCharset(PDO $con, $charset) + { + switch (strtolower($charset)) { + case 'utf-8': + $con->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_UTF8); + break; + case 'system': + $con->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_SYSTEM); + break; + default: + throw new PropelException('only utf-8 or system encoding are supported by the pdo_sqlsrv driver'); + } + } + + /** + * @see parent::cleanupSQL() + * + * @param string $sql + * @param array $params + * @param Criteria $values + * @param DatabaseMap $dbMap + */ + public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap) + { + $i = 1; + foreach ($params as $param) { + $tableName = $param['table']; + $columnName = $param['column']; + $value = $param['value']; + + // this is to workaround for a bug with pdo_sqlsrv inserting or updating blobs with null values + // http://social.msdn.microsoft.com/Forums/en-US/sqldriverforphp/thread/5a755bdd-41e9-45cb-9166-c9da4475bb94 + if (null !== $tableName) { + $cMap = $dbMap->getTable($tableName)->getColumn($columnName); + if ($value === null && $cMap->isLob()) { + $sql = str_replace(":p$i", "CONVERT(VARBINARY(MAX), :p$i)", $sql); + } + } + $i++; + } + } + + /** + * @see DBAdapter::bindValue() + * + * @param PDOStatement $stmt + * @param string $parameter + * @param mixed $value + * @param ColumnMap $cMap + * @param null|integer $position + * + * @return boolean + */ + public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + { + if ($cMap->isTemporal()) { + $value = $this->formatTemporalValue($value, $cMap); + } elseif (is_resource($value) && $cMap->isLob()) { + // we always need to make sure that the stream is rewound, otherwise nothing will + // get written to database. + rewind($value); + // pdo_sqlsrv must have bind binaries using bindParam so that the PDO::SQLSRV_ENCODING_BINARY + // driver option can be utilized. This requires a unique blob parameter because the bindParam + // value is passed by reference and if we didn't do this then the referenced parameter value + // would change on the next loop + $blob = "blob" . $position; + $$blob = $value; + + return $stmt->bindParam($parameter, ${$blob}, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY); + } + + return $stmt->bindValue($parameter, $value, $cMap->getPdoType()); + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/adapter/DBSQLite.php b/airtime_mvc/library/propel/runtime/lib/adapter/DBSQLite.php index 4b1da232d..be625144c 100644 --- a/airtime_mvc/library/propel/runtime/lib/adapter/DBSQLite.php +++ b/airtime_mvc/library/propel/runtime/lib/adapter/DBSQLite.php @@ -12,105 +12,123 @@ * This is used in order to connect to a SQLite database. * * @author Hans Lellelid - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.adapter */ class DBSQLite extends DBAdapter { - /** - * For SQLite this method has no effect, since SQLite doesn't support specifying a character - * set (or, another way to look at it, it doesn't require a single character set per DB). - * - * @param PDO A PDO connection instance. - * @param string The charset encoding. - * @throws PropelException If the specified charset doesn't match sqlite_libencoding() - */ - public function setCharset(PDO $con, $charset) - { - } + /** + * For SQLite this method has no effect, since SQLite doesn't support specifying a character + * set (or, another way to look at it, it doesn't require a single character set per DB). + * + * @param PDO $con A PDO connection instance. + * @param string $charset The charset encoding. + * + * @throws PropelException If the specified charset doesn't match sqlite_libencoding() + */ + public function setCharset(PDO $con, $charset) + { + } - /** - * This method is used to ignore case. - * - * @param in The string to transform to upper case. - * @return The upper case string. - */ - public function toUpperCase($in) - { - return 'UPPER(' . $in . ')'; - } + /** + * This method is used to ignore case. + * + * @param string $in The string to transform to upper case. + * + * @return string The upper case string. + */ + public function toUpperCase($in) + { + return 'UPPER(' . $in . ')'; + } - /** - * This method is used to ignore case. - * - * @param in The string whose case to ignore. - * @return The string in a case that can be ignored. - */ - public function ignoreCase($in) - { - return 'UPPER(' . $in . ')'; - } + /** + * This method is used to ignore case. + * + * @param string $in The string whose case to ignore. + * + * @return string The string in a case that can be ignored. + */ + public function ignoreCase($in) + { + return 'UPPER(' . $in . ')'; + } - /** - * Returns SQL which concatenates the second string to the first. - * - * @param string String to concatenate. - * @param string String to append. - * @return string - */ - public function concatString($s1, $s2) - { - return "($s1 || $s2)"; - } + /** + * Returns SQL which concatenates the second string to the first. + * + * @param string $s1 String to concatenate. + * @param string $s2 String to append. + * + * @return string + */ + public function concatString($s1, $s2) + { + return "($s1 || $s2)"; + } - /** - * Returns SQL which extracts a substring. - * - * @param string String to extract from. - * @param int Offset to start from. - * @param int Number of characters to extract. - * @return string - */ - public function subString($s, $pos, $len) - { - return "substr($s, $pos, $len)"; - } + /** + * Returns SQL which extracts a substring. + * + * @param string $s String to extract from. + * @param integer $pos Offset to start from. + * @param integer $len Number of characters to extract. + * + * @return string + */ + public function subString($s, $pos, $len) + { + return "substr($s, $pos, $len)"; + } - /** - * Returns SQL which calculates the length (in chars) of a string. - * - * @param string String to calculate length of. - * @return string - */ - public function strLength($s) - { - return "length($s)"; - } + /** + * Returns SQL which calculates the length (in chars) of a string. + * + * @param string $s String to calculate length of. + * + * @return string + */ + public function strLength($s) + { + return "length($s)"; + } - /** - * @see DBAdapter::quoteIdentifier() - */ - public function quoteIdentifier($text) - { - return '[' . $text . ']'; - } + /** + * @see DBAdapter::quoteIdentifier() + * + * @param string $text + * + * @return string + */ + public function quoteIdentifier($text) + { + return '[' . $text . ']'; + } - /** - * @see DBAdapter::applyLimit() - */ - public function applyLimit(&$sql, $offset, $limit) - { - if ( $limit > 0 ) { - $sql .= " LIMIT " . $limit . ($offset > 0 ? " OFFSET " . $offset : ""); - } elseif ( $offset > 0 ) { - $sql .= " LIMIT -1 OFFSET " . $offset; - } - } - - public function random($seed=NULL) - { - return 'random()'; - } + /** + * @see DBAdapter::applyLimit() + * + * @param string $sql + * @param integer $offset + * @param integer $limit + */ + public function applyLimit(&$sql, $offset, $limit) + { + if ($limit > 0) { + $sql .= " LIMIT " . $limit . ($offset > 0 ? " OFFSET " . $offset : ""); + } elseif ($offset > 0) { + $sql .= " LIMIT -1 OFFSET " . $offset; + } + } + /** + * @param string $seed + * + * @return string + */ + public function random($seed = null) + { + return 'random()'; + } } diff --git a/airtime_mvc/library/propel/runtime/lib/adapter/MSSQL/MssqlDateTime.class.php b/airtime_mvc/library/propel/runtime/lib/adapter/MSSQL/MssqlDateTime.class.php deleted file mode 100644 index 512c9b497..000000000 --- a/airtime_mvc/library/propel/runtime/lib/adapter/MSSQL/MssqlDateTime.class.php +++ /dev/null @@ -1,35 +0,0 @@ -getNestedTransactionCount(); - if ( $opcount === 0 ) { - $return = self::exec('BEGIN TRANSACTION'); - if ($this->useDebug) { - $this->log('Begin transaction', null, __METHOD__); - } - $this->isUncommitable = false; - } - $this->nestedTransactionCount++; - return $return; - } - - /** - * Commit a transaction. - * - * It is necessary to override the abstract PDO transaction functions here, as - * the PDO driver for MSSQL does not support transactions. - */ - public function commit() - { - $return = true; - $opcount = $this->getNestedTransactionCount(); - if ($opcount > 0) { - if ($opcount === 1) { - if ($this->isUncommitable) { - throw new PropelException('Cannot commit because a nested transaction was rolled back'); - } else { - $return = self::exec('COMMIT TRANSACTION'); - if ($this->useDebug) { - $this->log('Commit transaction', null, __METHOD__); - } + /** + * Begin a transaction. + * + * It is necessary to override the abstract PDO transaction functions here, as + * the PDO driver for MSSQL does not support transactions. + * + * @return integer + */ + public function beginTransaction() + { + $return = true; + $opcount = $this->getNestedTransactionCount(); + if ($opcount === 0) { + $return = self::exec('BEGIN TRANSACTION'); + if ($this->useDebug) { + $this->log('Begin transaction', null, __METHOD__); + } + $this->isUncommitable = false; + } + $this->nestedTransactionCount++; - } - } - $this->nestedTransactionCount--; - } - return $return; - } + return $return; + } - /** - * Roll-back a transaction. - * - * It is necessary to override the abstract PDO transaction functions here, as - * the PDO driver for MSSQL does not support transactions. - */ - public function rollBack() - { - $return = true; - $opcount = $this->getNestedTransactionCount(); - if ($opcount > 0) { - if ($opcount === 1) { - $return = self::exec('ROLLBACK TRANSACTION'); - if ($this->useDebug) { - $this->log('Rollback transaction', null, __METHOD__); - } - } else { - $this->isUncommitable = true; - } - $this->nestedTransactionCount--; - } - return $return; - } + /** + * Commit a transaction. + * + * It is necessary to override the abstract PDO transaction functions here, as + * the PDO driver for MSSQL does not support transactions. + * + * @return integer + * + * @throws PropelException + */ + public function commit() + { + $return = true; + $opcount = $this->getNestedTransactionCount(); + if ($opcount > 0) { + if ($opcount === 1) { + if ($this->isUncommitable) { + throw new PropelException('Cannot commit because a nested transaction was rolled back'); + } else { + $return = self::exec('COMMIT TRANSACTION'); + if ($this->useDebug) { + $this->log('Commit transaction', null, __METHOD__); + } + } + } + $this->nestedTransactionCount--; + } - /** - * Rollback the whole transaction, even if this is a nested rollback - * and reset the nested transaction count to 0. - * - * It is necessary to override the abstract PDO transaction functions here, as - * the PDO driver for MSSQL does not support transactions. - */ - public function forceRollBack() - { - $return = true; - $opcount = $this->getNestedTransactionCount(); - if ($opcount > 0) { - // If we're in a transaction, always roll it back - // regardless of nesting level. - $return = self::exec('ROLLBACK TRANSACTION'); + return $return; + } - // reset nested transaction count to 0 so that we don't - // try to commit (or rollback) the transaction outside this scope. - $this->nestedTransactionCount = 0; + /** + * Roll-back a transaction. + * + * It is necessary to override the abstract PDO transaction functions here, as + * the PDO driver for MSSQL does not support transactions. + * + * @return integer + */ + public function rollBack() + { + $return = true; + $opcount = $this->getNestedTransactionCount(); + if ($opcount > 0) { + if ($opcount === 1) { + $return = self::exec('ROLLBACK TRANSACTION'); + if ($this->useDebug) { + $this->log('Rollback transaction', null, __METHOD__); + } + } else { + $this->isUncommitable = true; + } + $this->nestedTransactionCount--; + } - if ($this->useDebug) { - $this->log('Rollback transaction', null, __METHOD__); - } - } - return $return; - } + return $return; + } - public function lastInsertId($seqname = null) - { - $result = self::query('SELECT SCOPE_IDENTITY()'); - return (int) $result->fetchColumn(); - } - - public function quoteIdentifier($text) - { - return '[' . $text . ']'; - } - - public function useQuoteIdentifier() - { - return true; - } + /** + * Rollback the whole transaction, even if this is a nested rollback + * and reset the nested transaction count to 0. + * + * It is necessary to override the abstract PDO transaction functions here, as + * the PDO driver for MSSQL does not support transactions. + * + * @return integer + */ + public function forceRollBack() + { + $return = true; + $opcount = $this->getNestedTransactionCount(); + if ($opcount > 0) { + // If we're in a transaction, always roll it back + // regardless of nesting level. + $return = self::exec('ROLLBACK TRANSACTION'); + + // reset nested transaction count to 0 so that we don't + // try to commit (or rollback) the transaction outside this scope. + $this->nestedTransactionCount = 0; + + if ($this->useDebug) { + $this->log('Rollback transaction', null, __METHOD__); + } + } + + return $return; + } + + /** + * @param string $seqname + * + * @return integer + */ + public function lastInsertId($seqname = null) + { + $result = self::query('SELECT SCOPE_IDENTITY()'); + + return (int) $result->fetchColumn(); + } + + /** + * @param string $text + * + * @return string + */ + public function quoteIdentifier($text) + { + return '[' . $text . ']'; + } + + /** + * @return boolean + */ + public function useQuoteIdentifier() + { + return true; + } } diff --git a/airtime_mvc/library/propel/runtime/lib/collection/PropelArrayCollection.php b/airtime_mvc/library/propel/runtime/lib/collection/PropelArrayCollection.php index c85bcecc4..c81e21d19 100644 --- a/airtime_mvc/library/propel/runtime/lib/collection/PropelArrayCollection.php +++ b/airtime_mvc/library/propel/runtime/lib/collection/PropelArrayCollection.php @@ -16,173 +16,199 @@ */ class PropelArrayCollection extends PropelCollection { - protected $workerObject; + protected $workerObject; - /** - * Save all the elements in the collection - */ - public function save($con = null) - { - if (null === $con) { - $con = $this->getConnection(Propel::CONNECTION_WRITE); - } - $con->beginTransaction(); - try { - $obj = $this->getWorkerObject(); - foreach ($this as $element) { - $obj->clear(); - $obj->fromArray($element); - $obj->setNew($obj->isPrimaryKeyNull()); - $obj->save($con); - } - $con->commit(); - } catch (PropelException $e) { - $con->rollback(); - } - } - - /** - * Delete all the elements in the collection - */ - public function delete($con = null) - { - if (null === $con) { - $con = $this->getConnection(Propel::CONNECTION_WRITE); - } - $con->beginTransaction(); - try { - foreach ($this as $element) { - $obj = $this->getWorkerObject(); - $obj->setDeleted(false); - $obj->fromArray($element); - $obj->delete($con); - } - $con->commit(); - } catch (PropelException $e) { - $con->rollback(); - throw $e; - } - } + /** + * Save all the elements in the collection + * + * @param PropelPDO $con + * + * @throws PropelException + */ + public function save($con = null) + { + if (!method_exists($this->getModel(), 'save')) { + throw new PropelException('Cannot save objects on a read-only model'); + } + if (null === $con) { + $con = $this->getConnection(Propel::CONNECTION_WRITE); + } + $con->beginTransaction(); + try { + $obj = $this->getWorkerObject(); + foreach ($this as $element) { + $obj->clear(); + $obj->fromArray($element); + $obj->setNew($obj->isPrimaryKeyNull()); + $obj->save($con); + } + $con->commit(); + } catch (Exception $e) { + $con->rollback(); + } + } - /** - * Get an array of the primary keys of all the objects in the collection - * - * @return array The list of the primary keys of the collection - */ - public function getPrimaryKeys($usePrefix = true) - { - $callable = array($this->getPeerClass(), 'getPrimaryKeyFromRow'); - $ret = array(); - foreach ($this as $key => $element) { - $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; - $ret[$key]= call_user_func($callable, array_values($element)); - } - - return $ret; - } + /** + * Delete all the elements in the collection + * + * @param PropelPDO $con + * + * @throws PropelException + */ + public function delete($con = null) + { + if (!method_exists($this->getModel(), 'delete')) { + throw new PropelException('Cannot delete objects on a read-only model'); + } + if (null === $con) { + $con = $this->getConnection(Propel::CONNECTION_WRITE); + } + $con->beginTransaction(); + try { + foreach ($this as $element) { + $obj = $this->getWorkerObject(); + $obj->setDeleted(false); + $obj->fromArray($element); + $obj->delete($con); + } + $con->commit(); + } catch (Exception $e) { + $con->rollback(); + throw $e; + } + } - /** - * Populates the collection from an array - * Uses the object model to force the column types - * Does not empty the collection before adding the data from the array - * - * @param array $arr - */ - public function fromArray($arr) - { - $obj = $this->getWorkerObject(); - foreach ($arr as $element) { - $obj->clear(); - $obj->fromArray($element); - $this->append($obj->toArray()); - } - } - - /** - * Get an array representation of the collection - * This is not an alias for getData(), since it returns a copy of the data - * - * @param string $keyColumn If null, the returned array uses an incremental index. - * Otherwise, the array is indexed using the specified column - * @param boolean $usePrefix If true, the returned array prefixes keys - * with the model class name ('Article_0', 'Article_1', etc). - * - * - * $bookCollection->toArray(); - * array( - * 0 => array('Id' => 123, 'Title' => 'War And Peace'), - * 1 => array('Id' => 456, 'Title' => 'Don Juan'), - * ) - * $bookCollection->toArray('Id'); - * array( - * 123 => array('Id' => 123, 'Title' => 'War And Peace'), - * 456 => array('Id' => 456, 'Title' => 'Don Juan'), - * ) - * $bookCollection->toArray(null, true); - * array( - * 'Book_0' => array('Id' => 123, 'Title' => 'War And Peace'), - * 'Book_1' => array('Id' => 456, 'Title' => 'Don Juan'), - * ) - * - * @return array - */ - public function toArray($keyColumn = null, $usePrefix = false) - { - $ret = array(); - foreach ($this as $key => $element) { - $key = null === $keyColumn ? $key : $element[$keyColumn]; - $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; - $ret[$key] = $element; - } + /** + * Get an array of the primary keys of all the objects in the collection + * + * @param boolean $usePrefix + * + * @return array The list of the primary keys of the collection + */ + public function getPrimaryKeys($usePrefix = true) + { + $callable = array($this->getPeerClass(), 'getPrimaryKeyFromRow'); + $ret = array(); + foreach ($this as $key => $element) { + $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; + $ret[$key] = call_user_func($callable, array_values($element)); + } - return $ret; - } - - /** - * Synonym for toArray(), to provide a similar interface to PopelObjectCollection - */ - public function getArrayCopy($keyColumn = null, $usePrefix = false) - { - if (null === $keyColumn && false === $usePrefix) { - return parent::getArrayCopy(); - } else { - return $this->toArray($keyColumn, $usePrefix); - } - } - - /** - * Get an associative array representation of the collection - * The first parameter specifies the column to be used for the key, - * And the seconf for the value. - * - * $res = $coll->toKeyValue('Id', 'Name'); - * - * - * @return array - */ - public function toKeyValue($keyColumn, $valueColumn) - { - $ret = array(); - foreach ($this as $obj) { - $ret[$obj[$keyColumn]] = $obj[$valueColumn]; - } - - return $ret; - } + return $ret; + } - protected function getWorkerObject() - { - if (null === $this->workerObject) { - if ($this->model == '') { - throw new PropelException('You must set the collection model before interacting with it'); - } - $class = $this->getModel(); - $this->workerObject = new $class(); - } - - return $this->workerObject; - } + /** + * Populates the collection from an array + * Uses the object model to force the column types + * Does not empty the collection before adding the data from the array + * + * @param array $arr + */ + public function fromArray($arr) + { + $obj = $this->getWorkerObject(); + foreach ($arr as $element) { + $obj->clear(); + $obj->fromArray($element); + $this->append($obj->toArray()); + } + } + /** + * Get an array representation of the collection + * This is not an alias for getData(), since it returns a copy of the data + * + * @param string $keyColumn If null, the returned array uses an incremental index. + * Otherwise, the array is indexed using the specified column + * @param boolean $usePrefix If true, the returned array prefixes keys + * with the model class name ('Article_0', 'Article_1', etc). + * + * + * $bookCollection->toArray(); + * array( + * 0 => array('Id' => 123, 'Title' => 'War And Peace'), + * 1 => array('Id' => 456, 'Title' => 'Don Juan'), + * ) + * $bookCollection->toArray('Id'); + * array( + * 123 => array('Id' => 123, 'Title' => 'War And Peace'), + * 456 => array('Id' => 456, 'Title' => 'Don Juan'), + * ) + * $bookCollection->toArray(null, true); + * array( + * 'Book_0' => array('Id' => 123, 'Title' => 'War And Peace'), + * 'Book_1' => array('Id' => 456, 'Title' => 'Don Juan'), + * ) + * + * + * @return array + */ + public function toArray($keyColumn = null, $usePrefix = false, $keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) + { + $ret = array(); + foreach ($this as $key => $element) { + $key = null === $keyColumn ? $key : $element[$keyColumn]; + $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; + $ret[$key] = $element; + } + + return $ret; + } + + /** + * Synonym for toArray(), to provide a similar interface to PopelObjectCollection + * + * @param string $keyColumn + * @param boolean $usePrefix + * + * @return array + */ + public function getArrayCopy($keyColumn = null, $usePrefix = false) + { + if (null === $keyColumn && false === $usePrefix) { + return parent::getArrayCopy(); + } else { + return $this->toArray($keyColumn, $usePrefix); + } + } + + /** + * Get an associative array representation of the collection + * The first parameter specifies the column to be used for the key, + * And the seconf for the value. + * + * $res = $coll->toKeyValue('Id', 'Name'); + * + * + * @param string $keyColumn + * @param string $valueColumn + * + * @return array + */ + public function toKeyValue($keyColumn, $valueColumn) + { + $ret = array(); + foreach ($this as $obj) { + $ret[$obj[$keyColumn]] = $obj[$valueColumn]; + } + + return $ret; + } + + /** + * @throws PropelException + * @return BaseObject + */ + protected function getWorkerObject() + { + if (null === $this->workerObject) { + if ($this->model == '') { + throw new PropelException('You must set the collection model before interacting with it'); + } + $class = $this->getModel(); + $this->workerObject = new $class(); + } + + return $this->workerObject; + } } - -?> \ No newline at end of file diff --git a/airtime_mvc/library/propel/runtime/lib/collection/PropelCollection.php b/airtime_mvc/library/propel/runtime/lib/collection/PropelCollection.php index a62b12da7..2e5eccf00 100644 --- a/airtime_mvc/library/propel/runtime/lib/collection/PropelCollection.php +++ b/airtime_mvc/library/propel/runtime/lib/collection/PropelCollection.php @@ -12,398 +12,640 @@ * Class for iterating over a list of Propel elements * The collection keys must be integers - no associative array accepted * + * @method PropelCollection fromXML(string $data) Populate the collection from an XML string + * @method PropelCollection fromYAML(string $data) Populate the collection from a YAML string + * @method PropelCollection fromJSON(string $data) Populate the collection from a JSON string + * @method PropelCollection fromCSV(string $data) Populate the collection from a CSV string + * + * @method string toXML(boolean $usePrefix, boolean $includeLazyLoadColumns) Export the collection to an XML string + * @method string toYAML(boolean $usePrefix, boolean $includeLazyLoadColumns) Export the collection to a YAML string + * @method string toJSON(boolean $usePrefix, boolean $includeLazyLoadColumns) Export the collection to a JSON string + * @method string toCSV(boolean $usePrefix, boolean $includeLazyLoadColumns) Export the collection to a CSV string + * * @author Francois Zaninotto * @package propel.runtime.collection */ class PropelCollection extends ArrayObject implements Serializable { - protected $model = ''; - protected $iterator; - protected $formatter; - + /** + * @var string + */ + protected $model = ''; - // Generic Collection methods - - /** - * Get the data in the collection - * - * @return array - */ - public function getData() - { - return $this->getArrayCopy(); - } + /** + * @var ArrayIterator + */ + protected $iterator; - /** - * Set the data in the collection - * - * @param array $data - */ - public function setData($data) - { - $this->exchangeArray($data); - } + /** + * @var PropelFormatter + */ + protected $formatter; - /** - * Gets the position of the internal pointer - * This position can be later used in seek() - * - * @return int - */ - public function getPosition() - { - return (int) $this->getInternalIterator()->key(); - } + // Generic Collection methods - /** - * Move the internal pointer to the beginning of the list - * And get the first element in the collection - * - * @return mixed - */ - public function getFirst() - { - $this->getInternalIterator()->rewind(); - return $this->getCurrent(); - } - - /** - * Check whether the internal pointer is at the beginning of the list - * - * @return boolean - */ - public function isFirst() - { - return $this->getPosition() == 0; - } + /** + * Get the data in the collection + * + * @return array + */ + public function getData() + { + return $this->getArrayCopy(); + } - /** - * Move the internal pointer backward - * And get the previous element in the collection - * - * @return mixed - */ - public function getPrevious() - { - $pos = $this->getPosition(); - if ($pos == 0) { - return null; - } else { - $this->getInternalIterator()->seek($pos - 1); - return $this->getCurrent(); - } - } + /** + * Set the data in the collection + * + * @param array $data + */ + public function setData($data) + { + $this->exchangeArray($data); + } - /** - * Get the current element in the collection - * - * @return mixed - */ - public function getCurrent() - { - return $this->getInternalIterator()->current(); - } + /** + * Gets the position of the internal pointer + * This position can be later used in seek() + * + * @return integer + */ + public function getPosition() + { + return (int) $this->getInternalIterator()->key(); + } - /** - * Move the internal pointer forward - * And get the next element in the collection - * - * @return mixed - */ - public function getNext() - { - $this->getInternalIterator()->next(); - return $this->getCurrent(); - } + /** + * Move the internal pointer to the beginning of the list + * And get the first element in the collection + * + * @return mixed + */ + public function getFirst() + { + $this->getInternalIterator()->rewind(); - /** - * Move the internal pointer to the end of the list - * And get the last element in the collection - * - * @return mixed - */ - public function getLast() - { - $count = $this->count(); - if ($count == 0) { - return null; - } else { - $this->getInternalIterator()->seek($count - 1); - return $this->getCurrent(); - } - } + return $this->getCurrent(); + } - /** - * Check whether the internal pointer is at the end of the list - * - * @return boolean - */ - public function isLast() - { - $count = $this->count(); - if ($count == 0) { - // empty list... so yes, this is the last - return true; - } else { - return $this->getPosition() == $count - 1; - } - } + /** + * Check whether the internal pointer is at the beginning of the list + * + * @return boolean + */ + public function isFirst() + { + return $this->getPosition() == 0; + } - /** - * Check if the collection is empty - * - * @return boolean - */ - public function isEmpty() - { - return $this->count() == 0; - } - - /** - * Check if the current index is an odd integer - * - * @return boolean - */ - public function isOdd() - { - return (boolean) ($this->getInternalIterator()->key() % 2); - } + /** + * Move the internal pointer backward + * And get the previous element in the collection + * + * @return mixed + */ + public function getPrevious() + { + $pos = $this->getPosition(); + if ($pos == 0) { + return null; + } else { + $this->getInternalIterator()->seek($pos - 1); - /** - * Check if the current index is an even integer - * - * @return boolean - */ - public function isEven() - { - return !$this->isOdd(); - } + return $this->getCurrent(); + } + } - /** - * Get an element from its key - * Alias for ArrayObject::offsetGet() - * - * @param mixed $key - * - * @return mixed The element - */ - public function get($key) - { - if (!$this->offsetExists($key)) { - throw new PropelException('Unknown key ' . $key); - } - return $this->offsetGet($key); - } - - /** - * Pops an element off the end of the collection - * - * @return mixed The popped element - */ - public function pop() - { - if ($this->count() == 0) { - return null; - } - $ret = $this->getLast(); - $lastKey = $this->getInternalIterator()->key(); - $this->offsetUnset((string) $lastKey); - return $ret; - } + /** + * Get the current element in the collection + * + * @return mixed + */ + public function getCurrent() + { + return $this->getInternalIterator()->current(); + } - /** - * Pops an element off the beginning of the collection - * - * @return mixed The popped element - */ - public function shift() - { - // the reindexing is complicated to deal with through the iterator - // so let's use the simple solution - $arr = $this->getArrayCopy(); - $ret = array_shift($arr); - $this->exchangeArray($arr); - - return $ret; - } + /** + * Move the internal pointer forward + * And get the next element in the collection + * + * @return mixed + */ + public function getNext() + { + $this->getInternalIterator()->next(); - /** - * Prepend one or more elements to the beginning of the collection - * - * @param mixed $value the element to prepend - * - * @return int The number of new elements in the array - */ - public function prepend($value) - { - // the reindexing is complicated to deal with through the iterator - // so let's use the simple solution - $arr = $this->getArrayCopy(); - $ret = array_unshift($arr, $value); - $this->exchangeArray($arr); + return $this->getCurrent(); + } - return $ret; - } + /** + * Move the internal pointer to the end of the list + * And get the last element in the collection + * + * @return mixed + */ + public function getLast() + { + $count = $this->count(); + if ($count == 0) { + return null; + } else { + $this->getInternalIterator()->seek($count - 1); - /** - * Add an element to the collection with the given key - * Alias for ArrayObject::offsetSet() - * - * @param mixed $key - * @param mixed $value - */ - public function set($key, $value) - { - return $this->offsetSet($key, $value); - } - - /** - * Removes a specified collection element - * Alias for ArrayObject::offsetUnset() - * - * @param mixed $key - * - * @return mixed The removed element - */ - public function remove($key) - { - if (!$this->offsetExists($key)) { - throw new PropelException('Unknown key ' . $key); - } - return $this->offsetUnset($key); - } - - /** - * Clears the collection - * - * @return array The previous collection - */ - public function clear() - { - return $this->exchangeArray(array()); - } + return $this->getCurrent(); + } + } - /** - * Whether or not this collection contains a specified element - * - * @param mixed $element the element - * - * @return boolean - */ - public function contains($element) - { - return in_array($element, $this->getArrayCopy(), true); - } + /** + * Check whether the internal pointer is at the end of the list + * + * @return boolean + */ + public function isLast() + { + $count = $this->count(); + if ($count == 0) { + // empty list... so yes, this is the last + return true; + } else { + return $this->getPosition() == $count - 1; + } + } - /** - * Search an element in the collection - * - * @param mixed $element - * - * @return mixed Returns the key for the element if it is found in the collection, FALSE otherwise - */ - public function search($element) - { - return array_search($element, $this->getArrayCopy(), true); - } - - // Serializable interface - - public function serialize() - { - $repr = array( - 'data' => $this->getArrayCopy(), - 'model' => $this->model, - ); - return serialize($repr); - } - - public function unserialize($data) - { - $repr = unserialize($data); - $this->exchangeArray($repr['data']); - $this->model = $repr['model']; - } - - // IteratorAggregate method - - /** - * Overrides ArrayObject::getIterator() to save the iterator object - * for internal use e.g. getNext(), isOdd(), etc. - */ - public function getIterator() - { - $this->iterator = new ArrayIterator($this); - return $this->iterator; - } - - public function getInternalIterator() - { - if (null === $this->iterator) { - return $this->getIterator(); - } - return $this->iterator; - } - - // Propel collection methods - - /** - * Set the model of the elements in the collection - * - * @param string $model Name of the Propel object classes stored in the collection - */ - public function setModel($model) - { - $this->model = $model; - } + /** + * Check if the collection is empty + * + * @return boolean + */ + public function isEmpty() + { + return $this->count() == 0; + } - /** - * Get the model of the elements in the collection - * - * @return string Name of the Propel object class stored in the collection - */ - public function getModel() - { - return $this->model; - } - - /** - * Get the peer class of the elements in the collection - * - * @return string Name of the Propel peer class stored in the collection - */ - public function getPeerClass() - { - if ($this->model == '') { - throw new PropelException('You must set the collection model before interacting with it'); - } - return constant($this->getModel() . '::PEER'); - } - - public function setFormatter(PropelFormatter $formatter) - { - $this->formatter = $formatter; - } - - public function getFormatter() - { - return $this->formatter; - } + /** + * Check if the current index is an odd integer + * + * @return boolean + */ + public function isOdd() + { + return (boolean) ($this->getInternalIterator()->key() % 2); + } - /** - * Get a connection object for the database containing the elements of the collection - * - * @param string $type The connection type (Propel::CONNECTION_READ by default; can be Propel::connection_WRITE) - * - * @return PropelPDO a connection object - */ - public function getConnection($type = Propel::CONNECTION_READ) - { - $databaseName = constant($this->getPeerClass() . '::DATABASE_NAME'); - - return Propel::getConnection($databaseName, $type); - } - + /** + * Check if the current index is an even integer + * + * @return boolean + */ + public function isEven() + { + return !$this->isOdd(); + } + + /** + * Get an element from its key + * Alias for ArrayObject::offsetGet() + * + * @param mixed $key + * + * @return mixed The element + * + * @throws PropelException + */ + public function get($key) + { + if (!$this->offsetExists($key)) { + throw new PropelException('Unknown key ' . $key); + } + + return $this->offsetGet($key); + } + + /** + * Pops an element off the end of the collection + * + * @return mixed The popped element + */ + public function pop() + { + if ($this->count() == 0) { + return null; + } + $ret = $this->getLast(); + $lastKey = $this->getInternalIterator()->key(); + $this->offsetUnset((string) $lastKey); + + return $ret; + } + + /** + * Pops an element off the beginning of the collection + * + * @return mixed The popped element + */ + public function shift() + { + // the reindexing is complicated to deal with through the iterator + // so let's use the simple solution + $arr = $this->getArrayCopy(); + $ret = array_shift($arr); + $this->exchangeArray($arr); + + return $ret; + } + + /** + * Prepend one or more elements to the beginning of the collection + * + * @param mixed $value the element to prepend + * + * @return integer The number of new elements in the array + */ + public function prepend($value) + { + // the reindexing is complicated to deal with through the iterator + // so let's use the simple solution + $arr = $this->getArrayCopy(); + $ret = array_unshift($arr, $value); + $this->exchangeArray($arr); + + return $ret; + } + + /** + * Add an element to the collection with the given key + * Alias for ArrayObject::offsetSet() + * + * @param mixed $key + * @param mixed $value + */ + public function set($key, $value) + { + $this->offsetSet($key, $value); + } + + /** + * Removes a specified collection element + * Alias for ArrayObject::offsetUnset() + * + * @param mixed $key + * + * @return mixed The removed element + * + * @throws PropelException + */ + public function remove($key) + { + if (!$this->offsetExists($key)) { + throw new PropelException('Unknown key ' . $key); + } + + return $this->offsetUnset($key); + } + + /** + * Clears the collection + * + * @return array The previous collection + */ + public function clear() + { + return $this->exchangeArray(array()); + } + + /** + * Whether or not this collection contains a specified element + * + * @param mixed $element + * + * @return boolean + */ + public function contains($element) + { + return in_array($element, $this->getArrayCopy(), true); + } + + /** + * Search an element in the collection + * + * @param mixed $element + * + * @return mixed Returns the key for the element if it is found in the collection, FALSE otherwise + */ + public function search($element) + { + return array_search($element, $this->getArrayCopy(), true); + } + + /** + * Returns an array of objects present in the collection that + * are not presents in the given collection. + * + * @param PropelCollection $collection A Propel collection. + * + * @return PropelCollection An array of Propel objects from the collection that are not presents in the given collection. + */ + public function diff(PropelCollection $collection) + { + $diff = clone $this; + $diff->clear(); + + foreach ($this as $object) { + if (!$collection->contains($object)) { + $diff[] = $object; + } + } + + return $diff; + } + + // Serializable interface + + /** + * @return string + */ + public function serialize() + { + $repr = array( + 'data' => $this->getArrayCopy(), + 'model' => $this->model, + ); + + return serialize($repr); + } + + /** + * @param string $data + * + * @return void + */ + public function unserialize($data) + { + $repr = unserialize($data); + $this->exchangeArray($repr['data']); + $this->model = $repr['model']; + } + + // IteratorAggregate method + + /** + * Overrides ArrayObject::getIterator() to save the iterator object + * for internal use e.g. getNext(), isOdd(), etc. + * + * @return ArrayIterator + */ + public function getIterator() + { + $this->iterator = new ArrayIterator($this); + + return $this->iterator; + } + + /** + * @return ArrayIterator + */ + public function getInternalIterator() + { + if (null === $this->iterator) { + return $this->getIterator(); + } + + return $this->iterator; + } + + /** + * Clear the internal Iterator. + * PHP 5.3 doesn't know how to free a PropelCollection object if it has an attached + * Iterator, so this must be done manually to avoid memory leaks. + * + * @see http://www.propelorm.org/ticket/1232 + */ + public function clearIterator() + { + $this->iterator = null; + } + + // Propel collection methods + + /** + * Set the model of the elements in the collection + * + * @param string $model Name of the Propel object classes stored in the collection + */ + public function setModel($model) + { + $this->model = $model; + } + + /** + * Get the model of the elements in the collection + * + * @return string Name of the Propel object class stored in the collection + */ + public function getModel() + { + return $this->model; + } + + /** + * Get the peer class of the elements in the collection + * + * @return string Name of the Propel peer class stored in the collection + * + * @throws PropelException + */ + public function getPeerClass() + { + if ($this->model == '') { + throw new PropelException('You must set the collection model before interacting with it'); + } + + return constant($this->getModel() . '::PEER'); + } + + /** + * @param PropelFormatter $formatter + */ + public function setFormatter(PropelFormatter $formatter) + { + $this->formatter = $formatter; + } + + /** + * @return PropelFormatter + */ + public function getFormatter() + { + return $this->formatter; + } + + /** + * Get a connection object for the database containing the elements of the collection + * + * @param string $type The connection type (Propel::CONNECTION_READ by default; can be Propel::connection_WRITE) + * + * @return PropelPDO A PropelPDO connection object + */ + public function getConnection($type = Propel::CONNECTION_READ) + { + $databaseName = constant($this->getPeerClass() . '::DATABASE_NAME'); + + return Propel::getConnection($databaseName, $type); + } + + /** + * Populate the current collection from a string, using a given parser format + * + * $coll = new PropelObjectCollection(); + * $coll->setModel('Book'); + * $coll->importFrom('JSON', '{{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}}'); + * + * + * @param mixed $parser A PropelParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return BaseObject The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof PropelParser) { + $parser = PropelParser::getParser($parser); + } + + return $this->fromArray($parser->listToArray($data), BasePeer::TYPE_PHPNAME); + } + + /** + * Export the current collection to a string, using a given parser format + * + * $books = BookQuery::create()->find(); + * echo $book->exportTo('JSON'); + * => {{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}}'); + * + * + * A PropelOnDemandCollection cannot be exported. Any attempt will result in a PropelExecption being thrown. + * + * @param mixed $parser A PropelParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $usePrefix (optional) If true, the returned element keys will be prefixed with the + * model class name ('Article_0', 'Article_1', etc). Defaults to TRUE. + * Not supported by PropelArrayCollection, as PropelArrayFormatter has + * already created the array used here with integers as keys. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * Not supported by PropelArrayCollection, as PropelArrayFormatter has + * already included lazy-load columns in the array used here. + * + * @return string The exported data + */ + public function exportTo($parser, $usePrefix = true, $includeLazyLoadColumns = true) + { + if (!$parser instanceof PropelParser) { + $parser = PropelParser::getParser($parser); + } + + return $parser->listFromArray($this->toArray(null, $usePrefix, BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns)); + } + + /** + * Catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you use a custom BaseObject + * + * @param string $name + * @param mixed $params + * + * @return array|string + * + * @throws PropelException + */ + public function __call($name, $params) + { + if (preg_match('/^from(\w+)$/', $name, $matches)) { + return $this->importFrom($matches[1], reset($params)); + } + if (preg_match('/^to(\w+)$/', $name, $matches)) { + $usePrefix = isset($params[0]) ? $params[0] : true; + $includeLazyLoadColumns = isset($params[1]) ? $params[1] : true; + + return $this->exportTo($matches[1], $usePrefix, $includeLazyLoadColumns); + } + throw new PropelException('Call to undefined method: ' . $name); + } + + /** + * Returns a string representation of the current collection. + * Based on the string representation of the underlying objects, defined in + * the Peer::DEFAULT_STRING_FORMAT constant + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(constant($this->getPeerClass() . '::DEFAULT_STRING_FORMAT')); + } + + /** + * Creates clones of the containing data. + */ + public function __clone() + { + foreach ($this as $key => $val) { + // we need to clone only objects, all scalar values will be copied using "=" + if (is_object($val)) { + $this[$key] = clone $val; + } else { + $this[$key] = $val; + } + } + } + + /** + * Get an array representation of the collection + * Each object is turned into an array and the result is returned + * + * @param string $keyColumn If null, the returned array uses an incremental index. + * Otherwise, the array is indexed using the specified column + * @param boolean $usePrefix If true, the returned array prefixes keys + * with the model class name ('Article_0', 'Article_1', etc). + * @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 array $alreadyDumpedObjects List of objects to skip to avoid recursion + * + * + * $bookCollection->toArray(); + * array( + * 0 => array('Id' => 123, 'Title' => 'War And Peace'), + * 1 => array('Id' => 456, 'Title' => 'Don Juan'), + * ) + * $bookCollection->toArray('Id'); + * array( + * 123 => array('Id' => 123, 'Title' => 'War And Peace'), + * 456 => array('Id' => 456, 'Title' => 'Don Juan'), + * ) + * $bookCollection->toArray(null, true); + * array( + * 'Book_0' => array('Id' => 123, 'Title' => 'War And Peace'), + * 'Book_1' => array('Id' => 456, 'Title' => 'Don Juan'), + * ) + * + * + * @return array + */ + public function toArray($keyColumn = null, $usePrefix = false, $keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) + { + $ret = array(); + $keyGetterMethod = 'get' . $keyColumn; + + /** @var $obj BaseObject */ + foreach ($this as $key => $obj) { + $key = null === $keyColumn ? $key : $obj->$keyGetterMethod(); + $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; + $ret[$key] = $obj->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + + return $ret; + } } - -?> \ No newline at end of file diff --git a/airtime_mvc/library/propel/runtime/lib/collection/PropelObjectCollection.php b/airtime_mvc/library/propel/runtime/lib/collection/PropelObjectCollection.php index 37061affa..265da242f 100644 --- a/airtime_mvc/library/propel/runtime/lib/collection/PropelObjectCollection.php +++ b/airtime_mvc/library/propel/runtime/lib/collection/PropelObjectCollection.php @@ -15,235 +15,303 @@ * @package propel.runtime.collection */ class PropelObjectCollection extends PropelCollection -{ - - /** - * Save all the elements in the collection - */ - public function save($con = null) - { - if (null === $con) { - $con = $this->getConnection(Propel::CONNECTION_WRITE); - } - $con->beginTransaction(); - try { - foreach ($this as $element) { - $element->save($con); - } - $con->commit(); - } catch (PropelException $e) { - $con->rollback(); - throw $e; - } - } - - /** - * Delete all the elements in the collection - */ - public function delete($con = null) - { - if (null === $con) { - $con = $this->getConnection(Propel::CONNECTION_WRITE); - } - $con->beginTransaction(); - try { - foreach ($this as $element) { - $element->delete($con); - } - $con->commit(); - } catch (PropelException $e) { - $con->rollback(); - throw $e; - } - } +{ + /** + * Save all the elements in the collection + * + * @param PropelPDO $con + * + * @throws PropelException + */ + public function save($con = null) + { + if (!method_exists($this->getModel(), 'save')) { + throw new PropelException('Cannot save objects on a read-only model'); + } + if (null === $con) { + $con = $this->getConnection(Propel::CONNECTION_WRITE); + } + $con->beginTransaction(); + try { + /** @var $element BaseObject */ + foreach ($this as $element) { + $element->save($con); + } + $con->commit(); + } catch (Exception $e) { + $con->rollback(); + throw $e; + } + } - /** - * Get an array of the primary keys of all the objects in the collection - * - * @return array The list of the primary keys of the collection - */ - public function getPrimaryKeys($usePrefix = true) - { - $ret = array(); - foreach ($this as $key => $obj) { - $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; - $ret[$key]= $obj->getPrimaryKey(); - } - - return $ret; - } + /** + * Delete all the elements in the collection + * + * @param PropelPDO $con + * + * @throws PropelException + */ + public function delete($con = null) + { + if (!method_exists($this->getModel(), 'delete')) { + throw new PropelException('Cannot delete objects on a read-only model'); + } + if (null === $con) { + $con = $this->getConnection(Propel::CONNECTION_WRITE); + } + $con->beginTransaction(); + try { + /** @var $element BaseObject */ + foreach ($this as $element) { + $element->delete($con); + } + $con->commit(); + } catch (Exception $e) { + $con->rollback(); + throw $e; + } + } - /** - * Populates the collection from an array - * Each object is populated from an array and the result is stored - * Does not empty the collection before adding the data from the array - * - * @param array $arr - */ - public function fromArray($arr) - { - $class = $this->getModel(); - foreach ($arr as $element) { - $obj = new $class(); - $obj->fromArray($element); - $this->append($obj); - } - } - - /** - * Get an array representation of the collection - * Each object is turned into an array and the result is returned - * - * @param string $keyColumn If null, the returned array uses an incremental index. - * Otherwise, the array is indexed using the specified column - * @param boolean $usePrefix If true, the returned array prefixes keys - * with the model class name ('Article_0', 'Article_1', etc). - * - * - * $bookCollection->toArray(); - * array( - * 0 => array('Id' => 123, 'Title' => 'War And Peace'), - * 1 => array('Id' => 456, 'Title' => 'Don Juan'), - * ) - * $bookCollection->toArray('Id'); - * array( - * 123 => array('Id' => 123, 'Title' => 'War And Peace'), - * 456 => array('Id' => 456, 'Title' => 'Don Juan'), - * ) - * $bookCollection->toArray(null, true); - * array( - * 'Book_0' => array('Id' => 123, 'Title' => 'War And Peace'), - * 'Book_1' => array('Id' => 456, 'Title' => 'Don Juan'), - * ) - * - * @return array - */ - public function toArray($keyColumn = null, $usePrefix = false) - { - $ret = array(); - $keyGetterMethod = 'get' . $keyColumn; - foreach ($this as $key => $obj) { - $key = null === $keyColumn ? $key : $obj->$keyGetterMethod(); - $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; - $ret[$key] = $obj->toArray(); - } - - return $ret; - } - - /** - * Get an array representation of the collection - * - * @param string $keyColumn If null, the returned array uses an incremental index. - * Otherwise, the array is indexed using the specified column - * @param boolean $usePrefix If true, the returned array prefixes keys - * with the model class name ('Article_0', 'Article_1', etc). - * - * - * $bookCollection->getArrayCopy(); - * array( - * 0 => $book0, - * 1 => $book1, - * ) - * $bookCollection->getArrayCopy('Id'); - * array( - * 123 => $book0, - * 456 => $book1, - * ) - * $bookCollection->getArrayCopy(null, true); - * array( - * 'Book_0' => $book0, - * 'Book_1' => $book1, - * ) - * - * @return array - */ - public function getArrayCopy($keyColumn = null, $usePrefix = false) - { - if (null === $keyColumn && false === $usePrefix) { - return parent::getArrayCopy(); - } - $ret = array(); - $keyGetterMethod = 'get' . $keyColumn; - foreach ($this as $key => $obj) { - $key = null === $keyColumn ? $key : $obj->$keyGetterMethod(); - $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; - $ret[$key] = $obj; - } - - return $ret; - } - - /** - * Get an associative array representation of the collection - * The first parameter specifies the column to be used for the key, - * And the seconf for the value. - * - * $res = $coll->toKeyValue('Id', 'Name'); - * - * - * @return array - */ - public function toKeyValue($keyColumn = 'PrimaryKey', $valueColumn = null) - { - $ret = array(); - $keyGetterMethod = 'get' . $keyColumn; - $valueGetterMethod = (null === $valueColumn) ? '__toString' : ('get' . $valueColumn); - foreach ($this as $obj) { - $ret[$obj->$keyGetterMethod()] = $obj->$valueGetterMethod(); - } - - return $ret; - } - - /** - * Makes an additional query to populate the objects related to the collection objects - * by a certain relation - * - * @param string $relation Relation name (e.g. 'Book') - * @param Criteria $criteria Optional Criteria object to filter the related object collection - * @param PropelPDO $con Optional connection object - * - * @return PropelObjectCollection the list of related objects - */ - public function populateRelation($relation, $criteria = null, $con = null) - { - if (!Propel::isInstancePoolingEnabled()) { - throw new PropelException('populateRelation() needs instance pooling to be enabled prior to populating the collection'); - } - $relationMap = $this->getFormatter()->getTableMap()->getRelation($relation); - $symRelationMap = $relationMap->getSymmetricalRelation(); - - // query the db for the related objects - $useMethod = 'use' . $symRelationMap->getName() . 'Query'; - $query = PropelQuery::from($relationMap->getRightTable()->getPhpName()); - if (null !== $criteria) { - $query->mergeWith($criteria); - } - $relatedObjects = $query - ->$useMethod() - ->filterByPrimaryKeys($this->getPrimaryKeys()) - ->endUse() - ->find($con); - - // associate the related objects to the main objects - if ($relationMap->getType() == RelationMap::ONE_TO_MANY) { - $getMethod = 'get' . $symRelationMap->getName(); - $addMethod = 'add' . $relationMap->getName(); - foreach ($relatedObjects as $object) { - $mainObj = $object->$getMethod(); // instance pool is used here to avoid a query - $mainObj->$addMethod($object); - } - } elseif ($relationMap->getType() == RelationMap::MANY_TO_ONE) { - // nothing to do; the instance pool will catch all calls to getRelatedObject() - // and return the object in memory - } else { - throw new PropelException('populateRelation() does not support this relation type'); - } - - return $relatedObjects; - } + /** + * Get an array of the primary keys of all the objects in the collection + * + * @param boolean $usePrefix + * + * @return array The list of the primary keys of the collection + */ + public function getPrimaryKeys($usePrefix = true) + { + $ret = array(); + /** @var $obj BaseObject */ + foreach ($this as $key => $obj) { + $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; + $ret[$key] = $obj->getPrimaryKey(); + } + + return $ret; + } + + /** + * Populates the collection from an array + * Each object is populated from an array and the result is stored + * Does not empty the collection before adding the data from the array + * + * @param array $arr + */ + public function fromArray($arr) + { + $class = $this->getModel(); + foreach ($arr as $element) { + /** @var $obj BaseObject */ + $obj = new $class(); + $obj->fromArray($element); + $this->append($obj); + } + } + + /** + * Get an array representation of the collection + * + * @param string $keyColumn If null, the returned array uses an incremental index. + * Otherwise, the array is indexed using the specified column + * @param boolean $usePrefix If true, the returned array prefixes keys + * with the model class name ('Article_0', 'Article_1', etc). + * + * + * $bookCollection->getArrayCopy(); + * array( + * 0 => $book0, + * 1 => $book1, + * ) + * $bookCollection->getArrayCopy('Id'); + * array( + * 123 => $book0, + * 456 => $book1, + * ) + * $bookCollection->getArrayCopy(null, true); + * array( + * 'Book_0' => $book0, + * 'Book_1' => $book1, + * ) + * + * + * @return array + */ + public function getArrayCopy($keyColumn = null, $usePrefix = false) + { + if (null === $keyColumn && false === $usePrefix) { + return parent::getArrayCopy(); + } + $ret = array(); + $keyGetterMethod = 'get' . $keyColumn; + foreach ($this as $key => $obj) { + $key = null === $keyColumn ? $key : $obj->$keyGetterMethod(); + $key = $usePrefix ? ($this->getModel() . '_' . $key) : $key; + $ret[$key] = $obj; + } + + return $ret; + } + + /** + * Get an associative array representation of the collection + * The first parameter specifies the column to be used for the key, + * And the seconf for the value. + * + * + * $res = $coll->toKeyValue('Id', 'Name'); + * + * + * $res = $coll->toKeyValue(array('RelatedModel', 'Name'), 'Name'); + * + * + * @param string|array $keyColumn The name of the column, or a list of columns to call. + * @param string $valueColumn + * + * @return array + */ + public function toKeyValue($keyColumn = 'PrimaryKey', $valueColumn = null) + { + $ret = array(); + $valueGetterMethod = (null === $valueColumn) ? '__toString' : ('get' . $valueColumn); + + if (!is_array($keyColumn)) { + $keyColumn = array($keyColumn); + } + + foreach ($this as $obj) { + $ret[$this->getValueForColumns($obj, $keyColumn)] = $obj->$valueGetterMethod(); + } + + return $ret; + } + + /** + * Return the value for a given set of key columns. + * + * Each column will be resolved on the value returned by the previous one. + * + * @param object $object The object to start with. + * @param array $columns The sequence of key columns. + * + * @return mixed + */ + protected function getValueForColumns($object, array $columns) + { + $value = $object; + + foreach ($columns as $eachKeyColumn) { + $keyGetterMethod = 'get' . $eachKeyColumn; + $value = $value->$keyGetterMethod(); + } + + return $value; + } + + /** + * Makes an additional query to populate the objects related to the collection objects + * by a certain relation + * + * @param string $relation Relation name (e.g. 'Book') + * @param Criteria $criteria Optional Criteria object to filter the related object collection + * @param PropelPDO $con Optional connection object + * + * @return PropelObjectCollection The list of related objects + * + * @throws PropelException + */ + public function populateRelation($relation, $criteria = null, $con = null) + { + if (!Propel::isInstancePoolingEnabled()) { + throw new PropelException('populateRelation() needs instance pooling to be enabled prior to populating the collection'); + } + $relationMap = $this->getFormatter()->getTableMap()->getRelation($relation); + if ($this->isEmpty()) { + // save a useless query and return an empty collection + $coll = new PropelObjectCollection(); + $coll->setModel($relationMap->getRightTable()->getClassname()); + + return $coll; + } + $symRelationMap = $relationMap->getSymmetricalRelation(); + + $query = PropelQuery::from($relationMap->getRightTable()->getClassname()); + if (null !== $criteria) { + $query->mergeWith($criteria); + } + // query the db for the related objects + $filterMethod = 'filterBy' . $symRelationMap->getName(); + $relatedObjects = $query + ->$filterMethod($this) + ->find($con); + if ($relationMap->getType() == RelationMap::ONE_TO_MANY) { + // initialize the embedded collections of the main objects + $relationName = $relationMap->getName(); + foreach ($this as $mainObj) { + $mainObj->initRelation($relationName); + } + // associate the related objects to the main objects + $getMethod = 'get' . $symRelationMap->getName(); + $addMethod = 'add' . $relationName; + foreach ($relatedObjects as $object) { + $mainObj = $object->$getMethod(); // instance pool is used here to avoid a query + $mainObj->$addMethod($object); + } + $relatedObjects->clearIterator(); + } elseif ($relationMap->getType() == RelationMap::MANY_TO_ONE) { + // nothing to do; the instance pool will catch all calls to getRelatedObject() + // and return the object in memory + } else { + throw new PropelException('populateRelation() does not support this relation type'); + } + + return $relatedObjects; + } + + /** + * {@inheritdoc} + */ + public function search($element) + { + if ($element instanceof BaseObject) { + if (null !== $elt = $this->getIdenticalObject($element)) { + $element = $elt; + } + } + + return parent::search($element); + } + + /** + * {@inheritdoc} + */ + public function contains($element) + { + if ($element instanceof BaseObject) { + if (null !== $elt = $this->getIdenticalObject($element)) { + $element = $elt; + } + } + + return parent::contains($element); + } + + private function getIdenticalObject(BaseObject $object) + { + $objectHashCode = null; + foreach ($this as $obj) { + if ($obj instanceof BaseObject) { + if (null === $objectHashCode) { + $objectHashCode = $object->hashCode(); + } + + if ($obj->hashCode() === $objectHashCode) { + return $obj; + } + } + } + + return null; + } } - -?> \ No newline at end of file diff --git a/airtime_mvc/library/propel/runtime/lib/collection/PropelOnDemandCollection.php b/airtime_mvc/library/propel/runtime/lib/collection/PropelOnDemandCollection.php index 409aef32f..dc8a993c5 100644 --- a/airtime_mvc/library/propel/runtime/lib/collection/PropelOnDemandCollection.php +++ b/airtime_mvc/library/propel/runtime/lib/collection/PropelOnDemandCollection.php @@ -16,136 +16,193 @@ */ class PropelOnDemandCollection extends PropelCollection { - protected - $iterator, - $currentRow, - $currentKey = -1, - $isValid = null; - - public function initIterator(PropelFormatter $formatter, PDOStatement $stmt) - { - $this->iterator = new PropelOnDemandIterator($formatter, $stmt); - } - - // IteratorAggregate Interface - - public function getIterator() - { - return $this->iterator; - } + /** + * @var PropelOnDemandIterator + */ + protected $iterator; - // ArrayAccess Interface - - public function offsetExists($offset) - { - if ($offset == $this->currentKey) { - return true; - } - throw new PropelException('The On Demand Collection does not allow acces by offset'); - } + /** + * @param PropelFormatter $formatter + * @param PDOStatement $stmt + */ + public function initIterator(PropelFormatter $formatter, PDOStatement $stmt) + { + $this->iterator = new PropelOnDemandIterator($formatter, $stmt); + } - public function offsetGet($offset) - { - if ($offset == $this->currentKey) { - return $this->currentRow; - } - throw new PropelException('The On Demand Collection does not allow acces by offset'); - } - - public function offsetSet($offset, $value) - { - throw new PropelException('The On Demand Collection is read only'); - } + /** + * Populates the collection from an array + * Each object is populated from an array and the result is stored + * Does not empty the collection before adding the data from the array + * + * @param array $arr + * + * @throws PropelException + */ + public function fromArray($arr) + { + throw new PropelException('The On Demand Collection is read only'); + } - public function offsetUnset($offset) - { - throw new PropelException('The On Demand Collection is read only'); - } - - // Serializable Interface - - public function serialize() - { - throw new PropelException('The On Demand Collection cannot be serialized'); - } + // IteratorAggregate Interface - public function unserialize($data) - { - throw new PropelException('The On Demand Collection cannot be serialized'); - } - - // Countable Interface - - /** - * Returns the number of rows in the resultset - * Warning: this number is inaccurate for most databases. Do not rely on it for a portable application. - * - * @return int number of results - */ - public function count() - { - return $this->iterator->count(); - } - - // ArrayObject methods - - public function append($value) - { - throw new PropelException('The On Demand Collection is read only'); - } - - public function prepend($value) - { - throw new PropelException('The On Demand Collection is read only'); - } + /** + * @return PropelOnDemandIterator + */ + public function getIterator() + { + return $this->iterator; + } - public function asort() - { - throw new PropelException('The On Demand Collection is read only'); - } - - public function exchangeArray($input) - { - throw new PropelException('The On Demand Collection is read only'); - } - - public function getArrayCopy() - { - throw new PropelException('The On Demand Collection does not allow acces by offset'); - } - - public function getFlags() - { - throw new PropelException('The On Demand Collection does not allow acces by offset'); - } - - public function ksort() - { - throw new PropelException('The On Demand Collection is read only'); - } - - public function natcasesort() - { - throw new PropelException('The On Demand Collection is read only'); - } - - public function natsort() - { - throw new PropelException('The On Demand Collection is read only'); - } - - public function setFlags($flags) - { - throw new PropelException('The On Demand Collection does not allow acces by offset'); - } - - public function uasort($cmp_function) - { - throw new PropelException('The On Demand Collection is read only'); - } - - public function uksort($cmp_function) - { - throw new PropelException('The On Demand Collection is read only'); - } -} \ No newline at end of file + // ArrayAccess Interface + + /** + * @throws PropelException + * + * @param integer $offset + * + * @return boolean + */ + public function offsetExists($offset) + { + throw new PropelException('The On Demand Collection does not allow access by offset'); + } + + /** + * @throws PropelException + * + * @param integer $offset + * + * @return mixed + */ + public function offsetGet($offset) + { + throw new PropelException('The On Demand Collection does not allow access by offset'); + } + + /** + * @throws PropelException + * + * @param integer $offset + * @param mixed $value + */ + public function offsetSet($offset, $value) + { + throw new PropelException('The On Demand Collection is read only'); + } + + /** + * @throws PropelException + * + * @param integer $offset + */ + public function offsetUnset($offset) + { + throw new PropelException('The On Demand Collection is read only'); + } + + // Serializable Interface + + /** + * @throws PropelException + */ + public function serialize() + { + throw new PropelException('The On Demand Collection cannot be serialized'); + } + + /** + * @throws PropelException + * + * @param string $data + * + * @return void + */ + public function unserialize($data) + { + throw new PropelException('The On Demand Collection cannot be serialized'); + } + + // Countable Interface + + /** + * Returns the number of rows in the resultset + * Warning: this number is inaccurate for most databases. Do not rely on it for a portable application. + * + * @return integer Number of results + */ + public function count() + { + return $this->iterator->count(); + } + + // ArrayObject methods + + public function append($value) + { + throw new PropelException('The On Demand Collection is read only'); + } + + public function prepend($value) + { + throw new PropelException('The On Demand Collection is read only'); + } + + public function asort() + { + throw new PropelException('The On Demand Collection is read only'); + } + + public function exchangeArray($input) + { + throw new PropelException('The On Demand Collection is read only'); + } + + public function getArrayCopy() + { + throw new PropelException('The On Demand Collection does not allow access by offset'); + } + + public function getFlags() + { + throw new PropelException('The On Demand Collection does not allow access by offset'); + } + + public function ksort() + { + throw new PropelException('The On Demand Collection is read only'); + } + + public function natcasesort() + { + throw new PropelException('The On Demand Collection is read only'); + } + + public function natsort() + { + throw new PropelException('The On Demand Collection is read only'); + } + + public function setFlags($flags) + { + throw new PropelException('The On Demand Collection does not allow acces by offset'); + } + + public function uasort($cmp_function) + { + throw new PropelException('The On Demand Collection is read only'); + } + + public function uksort($cmp_function) + { + throw new PropelException('The On Demand Collection is read only'); + } + + /** + * {@inheritdoc} + */ + public function exportTo($parser, $usePrefix = true, $includeLazyLoadColumns = true) + { + throw new PropelException('A PropelOnDemandCollection cannot be exported.'); + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/collection/PropelOnDemandIterator.php b/airtime_mvc/library/propel/runtime/lib/collection/PropelOnDemandIterator.php index e814781b5..ed20385f3 100644 --- a/airtime_mvc/library/propel/runtime/lib/collection/PropelOnDemandIterator.php +++ b/airtime_mvc/library/propel/runtime/lib/collection/PropelOnDemandIterator.php @@ -16,103 +16,123 @@ */ class PropelOnDemandIterator implements Iterator { - protected - $formatter, - $stmt, - $currentRow, - $currentKey = -1, - $isValid = null, - $enableInstancePoolingOnFinish = false; - - public function __construct(PropelFormatter $formatter, PDOStatement $stmt) - { - $this->formatter = $formatter; - $this->stmt = $stmt; - $this->enableInstancePoolingOnFinish = Propel::disableInstancePooling(); - } - - public function closeCursor() - { - $this->stmt->closeCursor(); - } - - /** - * Returns the number of rows in the resultset - * Warning: this number is inaccurate for most databases. Do not rely on it for a portable application. - * - * @return int number of results - */ - public function count() - { - return $this->stmt->rowCount(); - } + /** + * @var PropelObjectFormatter + */ + protected $formatter; - // Iterator Interface - - /** - * Gets the current Model object in the collection - * This is where the hydration takes place. - * - * @see PropelObjectFormatter::getAllObjectsFromRow() - * - * @return BaseObject - */ - public function current() - { - return $this->formatter->getAllObjectsFromRow($this->currentRow); - } - - /** - * Gets the current key in the iterator - * - * @return string - */ - public function key() - { - return $this->currentKey; - } - - /** - * Advances the curesor in the statement - * Closes the cursor if the end of the statement is reached - */ - public function next() - { - $this->currentRow = $this->stmt->fetch(PDO::FETCH_NUM); - $this->currentKey++; - $this->isValid = (boolean) $this->currentRow; - if (!$this->isValid) { - $this->closeCursor(); - if ($this->enableInstancePoolingOnFinish) { - Propel::enableInstancePooling(); - } - } - } - - /** - * Initializes the iterator by advancing to the first position - * This method can only be called once (this is a NoRewindIterator) - */ - public function rewind() - { - // check that the hydration can begin - if (null === $this->formatter) { - throw new PropelException('The On Demand collection requires a formatter. Add it by calling setFormatter()'); - } - if (null === $this->stmt) { - throw new PropelException('The On Demand collection requires a statement. Add it by calling setStatement()'); - } - if (null !== $this->isValid) { - throw new PropelException('The On Demand collection can only be iterated once'); - } - - // initialize the current row and key - $this->next(); - } - - public function valid() - { - return $this->isValid; - } + /** + * @var PDOStatement + */ + protected $stmt; -} \ No newline at end of file + protected $currentRow; + + protected $currentKey = -1; + + /** + * @var boolean|null + */ + protected $isValid = null; + + /** + * @var boolean + */ + protected $enableInstancePoolingOnFinish = false; + + /** + * @param PropelFormatter $formatter + * @param PDOStatement $stmt + */ + public function __construct(PropelFormatter $formatter, PDOStatement $stmt) + { + $this->formatter = $formatter; + $this->stmt = $stmt; + $this->enableInstancePoolingOnFinish = Propel::disableInstancePooling(); + } + + public function closeCursor() + { + $this->stmt->closeCursor(); + } + + /** + * Returns the number of rows in the resultset + * Warning: this number is inaccurate for most databases. Do not rely on it for a portable application. + * + * @return integer Number of results + */ + public function count() + { + return $this->stmt->rowCount(); + } + + /** + * Gets the current Model object in the collection + * This is where the hydration takes place. + * + * @see PropelObjectFormatter::getAllObjectsFromRow() + * + * @return BaseObject + */ + public function current() + { + return $this->formatter->getAllObjectsFromRow($this->currentRow); + } + + /** + * Gets the current key in the iterator + * + * @return string + */ + public function key() + { + return $this->currentKey; + } + + /** + * Advances the cursor in the statement + * Closes the cursor if the end of the statement is reached + */ + public function next() + { + $this->currentRow = $this->stmt->fetch(PDO::FETCH_NUM); + $this->currentKey++; + $this->isValid = (boolean) $this->currentRow; + if (!$this->isValid) { + $this->closeCursor(); + if ($this->enableInstancePoolingOnFinish) { + Propel::enableInstancePooling(); + } + } + } + + /** + * Initializes the iterator by advancing to the first position + * This method can only be called once (this is a NoRewindIterator) + */ + public function rewind() + { + // check that the hydration can begin + if (null === $this->formatter) { + throw new PropelException('The On Demand collection requires a formatter. Add it by calling setFormatter()'); + } + if (null === $this->stmt) { + throw new PropelException('The On Demand collection requires a statement. Add it by calling setStatement()'); + } + if (null !== $this->isValid) { + throw new PropelException('The On Demand collection can only be iterated once'); + } + + // initialize the current row and key + $this->next(); + } + + /** + * @return boolean + */ + public function valid() + { + return (boolean) $this->isValid; + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/config/PropelConfiguration.php b/airtime_mvc/library/propel/runtime/lib/config/PropelConfiguration.php index 299677f29..cd44624b4 100644 --- a/airtime_mvc/library/propel/runtime/lib/config/PropelConfiguration.php +++ b/airtime_mvc/library/propel/runtime/lib/config/PropelConfiguration.php @@ -9,151 +9,185 @@ */ /** - * PropelConfiguration is a container for all Propel's configuration data. + * PropelConfiguration is a container for all Propel's runtime configuration data. * * PropelConfiguration implements ArrayAccess interface so the configuration * can be accessed as an array or using a simple getter and setter. The whole * configuration can also be retrieved as a nested arrays, flat array or as a * PropelConfiguration instance. * - * @author Veikko Mäkinen - * @version $Revision: 1612 $ + * @author Veikko M�kinen + * @version $Revision$ * @package propel.runtime.config */ class PropelConfiguration implements ArrayAccess { - const TYPE_ARRAY = 1; + const TYPE_ARRAY = 1; + const TYPE_ARRAY_FLAT = 2; + const TYPE_OBJECT = 3; - const TYPE_ARRAY_FLAT = 2; + protected $parameters = array(); + protected $flattenedParameters = array(); + protected $isFlattened = false; - const TYPE_OBJECT = 3; + /** + * Construct a new configuration container + * + * @param array $parameters + */ + public function __construct(array $parameters = array()) + { + $this->parameters = $parameters; + } - /** - * @var array An array of parameters - */ - protected $parameters = array(); + /** + * @see http://www.php.net/ArrayAccess + * + * @param integer $offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return array_key_exists($offset, $this->parameters); + } - /** - * Construct a new configuration container - * - * @param array $parameters - */ - public function __construct(array $parameters = array()) - { - $this->parameters = $parameters; - } + /** + * @see http://www.php.net/ArrayAccess + * + * @param integer $offset + * @param mixed $value + */ + public function offsetSet($offset, $value) + { + $this->parameters[$offset] = $value; + $this->isFlattened = false; + } - /** - * @see http://www.php.net/ArrayAccess - */ - public function offsetExists($offset) - { - return array_key_exists($offset, $this->parameters); - } + /** + * @see http://www.php.net/ArrayAccess + * + * @param integer $offset + * + * @return array + */ + public function offsetGet($offset) + { + return $this->parameters[$offset]; + } - /** - * @see http://www.php.net/ArrayAccess - */ - public function offsetSet($offset, $value) - { - $this->parameter[$offset] = $value; - } + /** + * @see http://www.php.net/ArrayAccess + * + * @param integer $offset + */ + public function offsetUnset($offset) + { + unset($this->parameters[$offset]); + $this->isFlattened = false; + } - /** - * @see http://www.php.net/ArrayAccess - */ - public function offsetGet($offset) - { - return $this->parameters[$offset]; - } + /** + * Get a value from the container, using a namespaced key. + * If the specified value is supposed to be an array, the actual return value will be null. + * Examples: + * + * $c['foo'] = 'bar'; + * echo $c->getParameter('foo'); => 'bar' + * $c['foo1'] = array('foo2' => 'bar'); + * echo $c->getParameter('foo1'); => null + * echo $c->getParameter('foo1.foo2'); => 'bar' + * + * + * @param string $name Parameter name + * @param mixed $default Default value to be used if the requested value is not found + * + * @return mixed Parameter value or the default + */ + public function getParameter($name, $default = null) + { + $flattenedParameters = $this->getFlattenedParameters(); + if (isset($flattenedParameters[$name])) { + return $flattenedParameters[$name]; + } - /** - * @see http://www.php.net/ArrayAccess - */ - public function offsetUnset($offset) - { - unset($this->parameters[$offset]); - } + return $default; + } - /** - * Get parameter value from the container - * - * @param string $name Parameter name - * @param mixed $default Default value to be used if the - * requested value is not found - * @return mixed Parameter value or the default - */ - public function getParameter($name, $default = null) - { - $ret = $this->parameters; - $parts = explode('.', $name); //name.space.name - while ($part = array_shift($parts)) { - if (isset($ret[$part])) { - $ret = $ret[$part]; - } else { - return $default; - } - } - return $ret; - } + /** + * Store a value to the container. Accept scalar and array values. + * Examples: + * + * $c->setParameter('foo', 'bar'); + * echo $c['foo']; => 'bar' + * $c->setParameter('foo1.foo2', 'bar'); + * print_r($c['foo1']); => array('foo2' => 'bar') + * + * + * @param string $name Configuration item name (name.space.name) + * @param mixed $value Value to be stored + * @param Boolean $autoFlattenArrays + */ + public function setParameter($name, $value, $autoFlattenArrays = true) + { + $param = &$this->parameters; + $parts = explode('.', $name); //name.space.name + foreach ($parts as $part) { + $param = &$param[$part]; + } + $param = $value; + if (is_array($value) && $autoFlattenArrays) { + // The list will need to be re-flattened. + $this->isFlattened = false; + } else { + $this->flattenedParameters[$name] = $value; + } + } - /** - * Store a value to the container - * - * @param string $name Configuration item name (name.space.name) - * @param mixed $value Value to be stored - */ - public function setParameter($name, $value) - { - $param = &$this->parameters; - $parts = explode('.', $name); //name.space.name - while ($part = array_shift($parts)) { - $param = &$param[$part]; - } - $param = $value; - } + /** + * @throws PropelException + * + * @param integer $type + * + * @return mixed + */ + public function getParameters($type = PropelConfiguration::TYPE_ARRAY) + { + switch ($type) { + case PropelConfiguration::TYPE_ARRAY: + return $this->parameters; + case PropelConfiguration::TYPE_ARRAY_FLAT: + return $this->getFlattenedParameters(); + case PropelConfiguration::TYPE_OBJECT: + return $this; + default: + throw new PropelException('Unknown configuration type: ' . var_export($type, true)); + } + } - /** - * - * - * @param int $type - * @return mixed - */ - public function getParameters($type = PropelConfiguration::TYPE_ARRAY) - { - switch ($type) { - case PropelConfiguration::TYPE_ARRAY: - return $this->parameters; - case PropelConfiguration::TYPE_ARRAY_FLAT: - return $this->toFlatArray(); - case PropelConfiguration::TYPE_OBJECT: - return $this; - default: - throw new PropelException('Unknown configuration type: '. var_export($type, true)); - } + /** + * @return array + */ + public function getFlattenedParameters() + { + if (!$this->isFlattened) { + $this->flattenParameters(); + $this->isFlattened = true; + } - } - - - /** - * Get the configuration as a flat array. ($array['name.space.item'] = 'value') - * - * @return array - */ - protected function toFlatArray() - { - $result = array(); - $it = new PropelConfigurationIterator(new RecursiveArrayIterator($this->parameters), RecursiveIteratorIterator::SELF_FIRST); - foreach($it as $key => $value) { - $ns = $it->getDepth() ? $it->getNamespace() . '.'. $key : $key; - if ($it->getNodeType() == PropelConfigurationIterator::NODE_ITEM) { - $result[$ns] = $value; - } - } - - return $result; - } + return $this->flattenedParameters; + } + protected function flattenParameters() + { + $result = array(); + $it = new PropelConfigurationIterator(new RecursiveArrayIterator($this->parameters), RecursiveIteratorIterator::SELF_FIRST); + foreach ($it as $key => $value) { + $ns = $it->getDepth() ? $it->getNamespace() . '.' . $key : $key; + if ($it->getNodeType() == PropelConfigurationIterator::NODE_ITEM) { + $result[$ns] = $value; + } + } + $this->flattenedParameters = array_merge($this->flattenedParameters, $result); + } } - -?> diff --git a/airtime_mvc/library/propel/runtime/lib/config/PropelConfigurationIterator.php b/airtime_mvc/library/propel/runtime/lib/config/PropelConfigurationIterator.php index 45552d9db..1c74e4fdd 100644 --- a/airtime_mvc/library/propel/runtime/lib/config/PropelConfigurationIterator.php +++ b/airtime_mvc/library/propel/runtime/lib/config/PropelConfigurationIterator.php @@ -13,91 +13,87 @@ * build a flat array from nesting configuration arrays. * * @author Veikko Mäkinen - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.config */ class PropelConfigurationIterator extends RecursiveIteratorIterator { - /** - * Node is a parent node - */ - const NODE_PARENT = 0; + /** + * Node is a parent node + */ + const NODE_PARENT = 0; - /** - * Node is an actual configuration item - */ - const NODE_ITEM = 1; + /** + * Node is an actual configuration item + */ + const NODE_ITEM = 1; - /** - * Namespace stack when recursively iterating the configuration tree - * - * @var array - */ - protected $namespaceStack = array(); + /** + * Namespace stack when recursively iterating the configuration tree + * + * @var array + */ + protected $namespaceStack = array(); - /** - * Current node type. Possible values: null (undefined), self::NODE_PARENT or self::NODE_ITEM - * - * @var int - */ - protected $nodeType = null; + /** + * Current node type. Possible values: null (undefined), self::NODE_PARENT or self::NODE_ITEM + * + * @var integer + */ + protected $nodeType = null; - /** - * Get current namespace - * - * @return string - */ - public function getNamespace() - { - return implode('.', $this->namespaceStack); - } + /** + * Get current namespace + * + * @return string + */ + public function getNamespace() + { + return implode('.', $this->namespaceStack); + } - /** - * Get current node type. - * - * @see http://www.php.net/RecursiveIteratorIterator - * @return int - * - null (undefined) - * - self::NODE_PARENT - * - self::NODE_ITEM - */ - public function getNodeType() - { - return $this->nodeType; - } + /** + * Get current node type. + * + * @see http://www.php.net/RecursiveIteratorIterator + * @return integer + * - null (undefined) + * - self::NODE_PARENT + * - self::NODE_ITEM + */ + public function getNodeType() + { + return $this->nodeType; + } - /** - * Get the current element - * - * @see http://www.php.net/RecursiveIteratorIterator - * @return mixed - */ - public function current() - { - $current = parent::current(); - if (is_array($current)) { - $this->namespaceStack[] = $this->key(); - $this->nodeType = self::NODE_PARENT; - } - else { - $this->nodeType = self::NODE_ITEM; - } + /** + * Get the current element + * + * @see http://www.php.net/RecursiveIteratorIterator + * @return mixed + */ + public function current() + { + $current = parent::current(); + if (is_array($current)) { + $this->namespaceStack[] = $this->key(); + $this->nodeType = self::NODE_PARENT; + } else { + $this->nodeType = self::NODE_ITEM; + } - return $current; - } - - /** - * Called after current child iterator is invalid and right before it gets destructed. - * - * @see http://www.php.net/RecursiveIteratorIterator - */ - public function endChildren() - { - if ($this->namespaceStack) { - array_pop($this->namespaceStack); - } - } + return $current; + } + /** + * Called after current child iterator is invalid and right before it gets destructed. + * + * @see http://www.php.net/RecursiveIteratorIterator + */ + public function endChildren() + { + if ($this->namespaceStack) { + array_pop($this->namespaceStack); + } + } } - -?> diff --git a/airtime_mvc/library/propel/runtime/lib/connection/DebugPDO.php b/airtime_mvc/library/propel/runtime/lib/connection/DebugPDO.php index e9dd0759a..34ad8794d 100644 --- a/airtime_mvc/library/propel/runtime/lib/connection/DebugPDO.php +++ b/airtime_mvc/library/propel/runtime/lib/connection/DebugPDO.php @@ -13,90 +13,90 @@ * * This class is ONLY intended for development use. This class is also a work in-progress * and, as such, it should be expected that this class' API may change. - * + * * The following runtime configuration items affect the behaviour of this class: - * - * - debugpdo.logging.enabled (default: true) - * Should any logging take place - * + * * - debugpdo.logging.innerglue (default: ": ") * String to use for combining the title of a detail and its value - * + * * - debugpdo.logging.outerglue (default: " | ") * String to use for combining details together on a log line - * + * * - debugpdo.logging.realmemoryusage (default: false) - * Parameter to memory_get_usage() and memory_get_peak_usage() calls - * + * Parameter to memory_get_usage() and memory_get_peak_usage() calls + * * - debugpdo.logging.methods (default: DebugPDO::$defaultLogMethods) * An array of method names ("Class::method") to be included in method call logging - * + * * - debugpdo.logging.onlyslow (default: false) * Suppress logging of non-slow queries. - * + * * - debugpdo.logging.details.slow.enabled (default: false) * Enables flagging of slow method calls - * + * * - debugpdo.logging.details.slow.threshold (default: 0.1) - * Method calls taking more seconds than this threshold are considered slow - * + * Method calls taking more seconds than this threshold are considered slow + * * - debugpdo.logging.details.time.enabled (default: false) * Enables logging of method execution times - * + * * - debugpdo.logging.details.time.precision (default: 3) * Determines the precision of the execution time logging - * + * * - debugpdo.logging.details.time.pad (default: 10) * How much horizontal space to reserve for the execution time on a log line - * + * * - debugpdo.logging.details.mem.enabled (default: false) * Enables logging of the instantaneous PHP memory consumption - * + * * - debugpdo.logging.details.mem.precision (default: 1) * Determines the precision of the memory consumption logging - * + * * - debugpdo.logging.details.mem.pad (default: 9) * How much horizontal space to reserve for the memory consumption on a log line - * + * * - debugpdo.logging.details.memdelta.enabled (default: false) * Enables logging differences in memory consumption before and after the method call - * + * * - debugpdo.logging.details.memdelta.precision (default: 1) * Determines the precision of the memory difference logging - * + * * - debugpdo.logging.details.memdelta.pad (default: 10) * How much horizontal space to reserve for the memory difference on a log line - * + * * - debugpdo.logging.details.mempeak.enabled (default: false) * Enables logging the peak memory consumption thus far by the currently executing PHP script - * + * * - debugpdo.logging.details.mempeak.precision (default: 1) * Determines the precision of the memory peak logging - * + * * - debugpdo.logging.details.mempeak.pad (default: 9) * How much horizontal space to reserve for the memory peak on a log line - * + * * - debugpdo.logging.details.querycount.enabled (default: false) * Enables logging of the number of queries performed by the DebugPDO instance thus far - * + * * - debugpdo.logging.details.querycount.pad (default: 2) * How much horizontal space to reserve for the query count on a log line - * + * * - debugpdo.logging.details.method.enabled (default: false) * Enables logging of the name of the method call - * + * * - debugpdo.logging.details.method.pad (default: 28) * How much horizontal space to reserve for the method name on a log line - * + * + * - debugpdo.logging.connection (default: false) + * Add connectionName in log used for explains + * * The order in which the logging details are enabled is significant, since it determines the order in * which they will appear in the log file. - * + * * @example // Enable simple query profiling, flagging calls taking over 1.5 seconds as slow: * $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT); * $config->setParameter('debugpdo.logging.details.slow.enabled', true); * $config->setParameter('debugpdo.logging.details.slow.threshold', 1.5); * $config->setParameter('debugpdo.logging.details.time.enabled', true); - * + * * @author Francois Zaninotto * @author Cameron Brunner * @author Hans Lellelid @@ -107,5 +107,8 @@ */ class DebugPDO extends PropelPDO { - public $useDebug = true; + /** + * @var boolean + */ + public $useDebug = true; } diff --git a/airtime_mvc/library/propel/runtime/lib/connection/DebugPDOStatement.php b/airtime_mvc/library/propel/runtime/lib/connection/DebugPDOStatement.php index f1b2243e1..5773a6c47 100644 --- a/airtime_mvc/library/propel/runtime/lib/connection/DebugPDOStatement.php +++ b/airtime_mvc/library/propel/runtime/lib/connection/DebugPDOStatement.php @@ -20,103 +20,147 @@ */ class DebugPDOStatement extends PDOStatement { + /** + * The PDO connection from which this instance was created. + * + * @var PropelPDO + */ + protected $pdo; - /** - * The PDO connection from which this instance was created. - * - * @var PropelPDO - */ - protected $pdo; - - /** - * Hashmap for resolving the PDO::PARAM_* class constants to their human-readable names. - * - * This is only used in logging the binding of variables. - * - * @see self::bindValue() - * @var array - */ - protected static $typeMap = array( - PDO::PARAM_BOOL => "PDO::PARAM_BOOL", - PDO::PARAM_INT => "PDO::PARAM_INT", - PDO::PARAM_STR => "PDO::PARAM_STR", - PDO::PARAM_LOB => "PDO::PARAM_LOB", - PDO::PARAM_NULL => "PDO::PARAM_NULL", - ); + /** + * Hashmap for resolving the PDO::PARAM_* class constants to their human-readable names. + * This is only used in logging the binding of variables. + * + * @see self::bindValue() + * @var array + */ + protected static $typeMap = array( + PDO::PARAM_BOOL => "PDO::PARAM_BOOL", + PDO::PARAM_INT => "PDO::PARAM_INT", + PDO::PARAM_STR => "PDO::PARAM_STR", + PDO::PARAM_LOB => "PDO::PARAM_LOB", + PDO::PARAM_NULL => "PDO::PARAM_NULL", + ); - /** - * @var array The values that have been bound - */ - protected $boundValues = array(); + /** + * @var array The values that have been bound + */ + protected $boundValues = array(); - /** - * Construct a new statement class with reference to main DebugPDO object from - * which this instance was created. - * - * @param DebugPDO $pdo Reference to the parent PDO instance. - */ - protected function __construct(PropelPDO $pdo) - { - $this->pdo = $pdo; - } + /** + * Construct a new statement class with reference to main DebugPDO object from + * which this instance was created. + * + * @param PropelPDO $pdo Reference to the parent PDO instance. + * + * @return DebugPDOStatement + */ + protected function __construct(PropelPDO $pdo) + { + $this->pdo = $pdo; + } - public function getExecutedQueryString() - { - $sql = $this->queryString; - $matches = array(); - if (preg_match_all('/(:p[0-9]+\b)/', $sql, $matches)) { - $size = count($matches[1]); - for ($i = $size-1; $i >= 0; $i--) { - $pos = $matches[1][$i]; - $sql = str_replace($pos, $this->boundValues[$pos], $sql); - } - } - - return $sql; - } + /** + * @param array $values Parameters which were passed to execute(), if any. Default: bound parameters. + * + * @return string + */ + public function getExecutedQueryString(array $values = array()) + { + $sql = $this->queryString; + $boundValues = empty($values) ? $this->boundValues : $values; + $matches = array(); + if (preg_match_all('/(:p[0-9]+\b)/', $sql, $matches)) { + $size = count($matches[1]); + for ($i = $size - 1; $i >= 0; $i--) { + $pos = $matches[1][$i]; - /** - * Executes a prepared statement. Returns a boolean value indicating success. - * - * Overridden for query counting and logging. - * - * @return bool - */ - public function execute($input_parameters = null) - { - $debug = $this->pdo->getDebugSnapshot(); - $return = parent::execute($input_parameters); - - $sql = $this->getExecutedQueryString(); - $this->pdo->log($sql, null, __METHOD__, $debug); - $this->pdo->setLastExecutedQuery($sql); - $this->pdo->incrementQueryCount(); - - return $return; - } + // trimming extra quotes, making sure value is properly quoted afterwards + $boundValue = $boundValues[$pos]; + if (is_string($boundValue)) { // quoting only needed for string values + $boundValue = trim($boundValue, "'"); + $boundValue = $this->pdo->quote($boundValue); + } + $sql = str_replace($pos, $boundValue, $sql); + } + } - /** - * Binds a value to a corresponding named or question mark placeholder in the SQL statement - * that was use to prepare the statement. Returns a boolean value indicating success. - * - * @param int $pos Parameter identifier (for determining what to replace in the query). - * @param mixed $value The value to bind to the parameter. - * @param int $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. - * @return boolean - */ - public function bindValue($pos, $value, $type = PDO::PARAM_STR) - { - $debug = $this->pdo->getDebugSnapshot(); - $typestr = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)'; - $return = parent::bindValue($pos, $value, $type); - $valuestr = $type == PDO::PARAM_LOB ? '[LOB value]' : var_export($value, true); - $msg = "Binding $valuestr at position $pos w/ PDO type $typestr"; + return $sql; + } - $this->boundValues[$pos] = $valuestr; - - $this->pdo->log($msg, null, __METHOD__, $debug); - - return $return; - } - + /** + * Executes a prepared statement. Returns a boolean value indicating success. + * Overridden for query counting and logging. + * + * @param string $input_parameters + * + * @return boolean + */ + public function execute($input_parameters = null) + { + $debug = $this->pdo->getDebugSnapshot(); + $return = parent::execute($input_parameters); + + $sql = $this->getExecutedQueryString($input_parameters?:array()); + $this->pdo->log($sql, null, __METHOD__, $debug); + $this->pdo->setLastExecutedQuery($sql); + $this->pdo->incrementQueryCount(); + + return $return; + } + + /** + * Binds a value to a corresponding named or question mark placeholder in the SQL statement + * that was use to prepare the statement. Returns a boolean value indicating success. + * + * @param integer $pos Parameter identifier (for determining what to replace in the query). + * @param mixed $value The value to bind to the parameter. + * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. + * + * @return boolean + */ + public function bindValue($pos, $value, $type = PDO::PARAM_STR) + { + $debug = $this->pdo->getDebugSnapshot(); + $typestr = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)'; + $return = parent::bindValue($pos, $value, $type); + $valuestr = $type == PDO::PARAM_LOB ? '[LOB value]' : var_export($value, true); + $msg = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $pos, $typestr); + + $this->boundValues[$pos] = $value; + + $this->pdo->log($msg, null, __METHOD__, $debug); + + return $return; + } + + /** + * Binds a PHP variable to a corresponding named or question mark placeholder in the SQL statement + * that was use to prepare the statement. Unlike PDOStatement::bindValue(), the variable is bound + * as a reference and will only be evaluated at the time that PDOStatement::execute() is called. + * Returns a boolean value indicating success. + * + * @param integer $pos Parameter identifier (for determining what to replace in the query). + * @param mixed $value The value to bind to the parameter. + * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR. + * @param integer $length Length of the data type. To indicate that a parameter is an OUT parameter from a stored procedure, you must explicitly set the length. + * @param mixed $driver_options + * + * @return boolean + */ + public function bindParam($pos, &$value, $type = PDO::PARAM_STR, $length = 0, $driver_options = null) + { + $originalValue = $value; + $debug = $this->pdo->getDebugSnapshot(); + $typestr = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)'; + $return = parent::bindParam($pos, $value, $type, $length, $driver_options); + $valuestr = $length > 100 ? '[Large value]' : var_export($value, true); + $msg = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $pos, $typestr); + + $this->boundValues[$pos] = $originalValue; + + $this->pdo->log($msg, null, __METHOD__, $debug); + + return $return; + } } diff --git a/airtime_mvc/library/propel/runtime/lib/connection/PropelPDO.php b/airtime_mvc/library/propel/runtime/lib/connection/PropelPDO.php index 6bfa5a07b..7d30a08f1 100644 --- a/airtime_mvc/library/propel/runtime/lib/connection/PropelPDO.php +++ b/airtime_mvc/library/propel/runtime/lib/connection/PropelPDO.php @@ -30,687 +30,777 @@ class PropelPDO extends PDO { - /** - * Attribute to use to set whether to cache prepared statements. - */ - const PROPEL_ATTR_CACHE_PREPARES = -1; - - const DEFAULT_SLOW_THRESHOLD = 0.1; - const DEFAULT_ONLYSLOW_ENABLED = false; + /** + * Attribute to use to set whether to cache prepared statements. + */ + const PROPEL_ATTR_CACHE_PREPARES = -1; - /** - * The current transaction depth. - * @var int - */ - protected $nestedTransactionCount = 0; + /** + * Attribute to use to set the connection name useful for explains + */ + const PROPEL_ATTR_CONNECTION_NAME = -2; - /** - * Cache of prepared statements (PDOStatement) keyed by md5 of SQL. - * - * @var array [md5(sql) => PDOStatement] - */ - protected $preparedStatements = array(); + const DEFAULT_SLOW_THRESHOLD = 0.1; + const DEFAULT_ONLYSLOW_ENABLED = false; - /** - * Whether to cache prepared statements. - * - * @var boolean - */ - protected $cachePreparedStatements = false; - - /** - * Whether the final commit is possible - * Is false if a nested transaction is rolled back - */ - protected $isUncommitable = false; - - /** - * Count of queries performed. - * - * @var int - */ - protected $queryCount = 0; - - /** - * SQL code of the latest performed query. - * - * @var string - */ - protected $lastExecutedQuery; - - /** - * Whether or not the debug is enabled - * - * @var boolean - */ - public $useDebug = false; - - /** - * Configured BasicLogger (or compatible) logger. - * - * @var BasicLogger - */ - protected $logger; + /** + * The current transaction depth. + * + * @var integer + */ + protected $nestedTransactionCount = 0; - /** - * The log level to use for logging. - * - * @var int - */ - private $logLevel = Propel::LOG_DEBUG; - - /** - * The default value for runtime config item "debugpdo.logging.methods". - * - * @var array - */ - protected static $defaultLogMethods = array( - 'PropelPDO::exec', - 'PropelPDO::query', - 'DebugPDOStatement::execute', - ); + /** + * Cache of prepared statements (PDOStatement) keyed by md5 of SQL. + * + * @var array [md5(sql) => PDOStatement] + */ + protected $preparedStatements = array(); - /** - * Creates a PropelPDO instance representing a connection to a database. - *. - * If so configured, specifies a custom PDOStatement class and makes an entry - * to the log with the state of this object just after its initialization. - * Add PropelPDO::__construct to $defaultLogMethods to see this message - * - * @param string $dsn Connection DSN. - * @param string $username (optional) The user name for the DSN string. - * @param string $password (optional) The password for the DSN string. - * @param array $driver_options (optional) A key=>value array of driver-specific connection options. - * @throws PDOException if there is an error during connection initialization. - */ - public function __construct($dsn, $username = null, $password = null, $driver_options = array()) - { - if ($this->useDebug) { - $debug = $this->getDebugSnapshot(); - } - - parent::__construct($dsn, $username, $password, $driver_options); - - if ($this->useDebug) { - $this->configureStatementClass('DebugPDOStatement', $suppress = true); - $this->log('Opening connection', null, __METHOD__, $debug); - } - } - - /** - * Gets the current transaction depth. - * @return int - */ - public function getNestedTransactionCount() - { - return $this->nestedTransactionCount; - } + /** + * Whether to cache prepared statements. + * + * @var boolean + */ + protected $cachePreparedStatements = false; - /** - * Set the current transaction depth. - * @param int $v The new depth. - */ - protected function setNestedTransactionCount($v) - { - $this->nestedTransactionCount = $v; - } + /** + * Whether the final commit is possible + * Is false if a nested transaction is rolled back + */ + protected $isUncommitable = false; - /** - * Is this PDO connection currently in-transaction? - * This is equivalent to asking whether the current nested transaction count - * is greater than 0. - * @return boolean - */ - public function isInTransaction() - { - return ($this->getNestedTransactionCount() > 0); - } - - /** - * Check whether the connection contains a transaction that can be committed. - * To be used in an evironment where Propelexceptions are caught. - * - * @return boolean True if the connection is in a committable transaction - */ - public function isCommitable() - { - return $this->isInTransaction() && !$this->isUncommitable; - } - - /** - * Overrides PDO::beginTransaction() to prevent errors due to already-in-progress transaction. - */ - public function beginTransaction() - { - $return = true; - if (!$this->nestedTransactionCount) { - $return = parent::beginTransaction(); - if ($this->useDebug) { - $this->log('Begin transaction', null, __METHOD__); - } - $this->isUncommitable = false; - } - $this->nestedTransactionCount++; - return $return; - } + /** + * Count of queries performed. + * + * @var integer + */ + protected $queryCount = 0; - /** - * Overrides PDO::commit() to only commit the transaction if we are in the outermost - * transaction nesting level. - */ - public function commit() - { - $return = true; - $opcount = $this->nestedTransactionCount; - if ($opcount > 0) { - if ($opcount === 1) { - if ($this->isUncommitable) { - throw new PropelException('Cannot commit because a nested transaction was rolled back'); - } else { - $return = parent::commit(); - if ($this->useDebug) { - $this->log('Commit transaction', null, __METHOD__); - } - } - } - $this->nestedTransactionCount--; - } - return $return; - } + /** + * SQL code of the latest performed query. + * + * @var string + */ + protected $lastExecutedQuery; - /** - * Overrides PDO::rollBack() to only rollback the transaction if we are in the outermost - * transaction nesting level - * @return boolean Whether operation was successful. - */ - public function rollBack() - { - $return = true; - $opcount = $this->nestedTransactionCount; - if ($opcount > 0) { - if ($opcount === 1) { - $return = parent::rollBack(); - if ($this->useDebug) { - $this->log('Rollback transaction', null, __METHOD__); - } - } else { - $this->isUncommitable = true; - } - $this->nestedTransactionCount--; - } - return $return; - } + /** + * Whether or not the debug is enabled + * + * @var boolean + */ + public $useDebug = false; - /** - * Rollback the whole transaction, even if this is a nested rollback - * and reset the nested transaction count to 0. - * @return boolean Whether operation was successful. - */ - public function forceRollBack() - { - $return = true; - if ($this->nestedTransactionCount) { - // If we're in a transaction, always roll it back - // regardless of nesting level. - $return = parent::rollBack(); + /** + * Configured BasicLogger (or compatible) logger. + * + * @var BasicLogger + */ + protected $logger; - // reset nested transaction count to 0 so that we don't - // try to commit (or rollback) the transaction outside this scope. - $this->nestedTransactionCount = 0; + /** + * The log level to use for logging. + * + * @var integer + */ + private $logLevel = Propel::LOG_DEBUG; - if ($this->useDebug) { - $this->log('Rollback transaction', null, __METHOD__); - } - } - return $return; - } - - /** - * Sets a connection attribute. - * - * This is overridden here to provide support for setting Propel-specific attributes - * too. - * - * @param int $attribute The attribute to set (e.g. PropelPDO::PROPEL_ATTR_CACHE_PREPARES). - * @param mixed $value The attribute value. - */ - public function setAttribute($attribute, $value) - { - switch($attribute) { - case self::PROPEL_ATTR_CACHE_PREPARES: - $this->cachePreparedStatements = $value; - break; - default: - parent::setAttribute($attribute, $value); - } - } + /** + * The runtime configuration + * + * @var PropelConfiguration + */ + protected $configuration; - /** - * Gets a connection attribute. - * - * This is overridden here to provide support for setting Propel-specific attributes - * too. - * - * @param int $attribute The attribute to get (e.g. PropelPDO::PROPEL_ATTR_CACHE_PREPARES). - */ - public function getAttribute($attribute) - { - switch($attribute) { - case self::PROPEL_ATTR_CACHE_PREPARES: - return $this->cachePreparedStatements; - break; - default: - return parent::getAttribute($attribute); - } - } + /** + * The connection name + * + * @var string + */ + protected $connectionName; - /** - * Prepares a statement for execution and returns a statement object. - * - * Overrides PDO::prepare() in order to: - * - Add logging and query counting if logging is true. - * - Add query caching support if the PropelPDO::PROPEL_ATTR_CACHE_PREPARES was set to true. - * - * @param string $sql This must be a valid SQL statement for the target database server. - * @param array One or more key => value pairs to set attribute values - * for the PDOStatement object that this method returns. - * @return PDOStatement - */ - public function prepare($sql, $driver_options = array()) - { - if ($this->useDebug) { - $debug = $this->getDebugSnapshot(); - } - - if ($this->cachePreparedStatements) { - if (!isset($this->preparedStatements[$sql])) { - $return = parent::prepare($sql, $driver_options); - $this->preparedStatements[$sql] = $return; - } else { - $return = $this->preparedStatements[$sql]; - } - } else { - $return = parent::prepare($sql, $driver_options); - } - - if ($this->useDebug) { - $this->log($sql, null, __METHOD__, $debug); - } - - return $return; - } + /** + * The default value for runtime config item "debugpdo.logging.methods". + * + * @var array + */ + protected static $defaultLogMethods = array( + 'PropelPDO::exec', + 'PropelPDO::query', + 'DebugPDOStatement::execute', + ); - /** - * Execute an SQL statement and return the number of affected rows. - * - * Overrides PDO::exec() to log queries when required - * - * @return int - */ - public function exec($sql) - { - if ($this->useDebug) { - $debug = $this->getDebugSnapshot(); - } - - $return = parent::exec($sql); - - if ($this->useDebug) { - $this->log($sql, null, __METHOD__, $debug); - $this->setLastExecutedQuery($sql); - $this->incrementQueryCount(); - } - - return $return; - } + /** + * Creates a PropelPDO instance representing a connection to a database. + *. + * If so configured, specifies a custom PDOStatement class and makes an entry + * to the log with the state of this object just after its initialization. + * Add PropelPDO::__construct to $defaultLogMethods to see this message + * + * @param string $dsn Connection DSN. + * @param string $username The user name for the DSN string. + * @param string $password The password for the DSN string. + * @param array $driver_options A key=>value array of driver-specific connection options. + * + * @throws PDOException if there is an error during connection initialization. + */ + public function __construct($dsn, $username = null, $password = null, $driver_options = array()) + { + if ($this->useDebug) { + $debug = $this->getDebugSnapshot(); + } - /** - * Executes an SQL statement, returning a result set as a PDOStatement object. - * Despite its signature here, this method takes a variety of parameters. - * - * Overrides PDO::query() to log queries when required - * - * @see http://php.net/manual/en/pdo.query.php for a description of the possible parameters. - * @return PDOStatement - */ - public function query() - { - if ($this->useDebug) { - $debug = $this->getDebugSnapshot(); - } - - $args = func_get_args(); - if (version_compare(PHP_VERSION, '5.3', '<')) { - $return = call_user_func_array(array($this, 'parent::query'), $args); - } else { - $return = call_user_func_array('parent::query', $args); - } - - if ($this->useDebug) { - $sql = $args[0]; - $this->log($sql, null, __METHOD__, $debug); - $this->setLastExecutedQuery($sql); - $this->incrementQueryCount(); - } - - return $return; - } - - /** - * Clears any stored prepared statements for this connection. - */ - public function clearStatementCache() - { - $this->preparedStatements = array(); - } + parent::__construct($dsn, $username, $password, $driver_options); - /** - * Configures the PDOStatement class for this connection. - * - * @param boolean $suppressError Whether to suppress an exception if the statement class cannot be set. - * @throws PropelException if the statement class cannot be set (and $suppressError is false). - */ - protected function configureStatementClass($class = 'PDOStatement', $suppressError = true) - { - // extending PDOStatement is only supported with non-persistent connections - if (!$this->getAttribute(PDO::ATTR_PERSISTENT)) { - $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($class, array($this))); - } elseif (!$suppressError) { - throw new PropelException('Extending PDOStatement is not supported with persistent connections.'); - } - } + if ($this->useDebug) { + $this->configureStatementClass('DebugPDOStatement', true); + $this->log('Opening connection', null, __METHOD__, $debug); + } + } - /** - * Returns the number of queries this DebugPDO instance has performed on the database connection. - * - * When using DebugPDOStatement as the statement class, any queries by DebugPDOStatement instances - * are counted as well. - * - * @return int - * @throws PropelException if persistent connection is used (since unable to override PDOStatement in that case). - */ - public function getQueryCount() - { - // extending PDOStatement is not supported with persistent connections - if ($this->getAttribute(PDO::ATTR_PERSISTENT)) { - throw new PropelException('Extending PDOStatement is not supported with persistent connections. Count would be inaccurate, because we cannot count the PDOStatment::execute() calls. Either don\'t use persistent connections or don\'t call PropelPDO::getQueryCount()'); - } - return $this->queryCount; - } + /** + * Inject the runtime configuration + * + * @param PropelConfiguration $configuration + */ + public function setConfiguration($configuration) + { + $this->configuration = $configuration; + } - /** - * Increments the number of queries performed by this DebugPDO instance. - * - * Returns the original number of queries (ie the value of $this->queryCount before calling this method). - * - * @return int - */ - public function incrementQueryCount() - { - $this->queryCount++; - } + /** + * Get the runtime configuration + * + * @return PropelConfiguration + */ + public function getConfiguration() + { + if (null === $this->configuration) { + $this->configuration = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT); + } - /** - * Get the SQL code for the latest query executed by Propel - * - * @return string Executable SQL code - */ - public function getLastExecutedQuery() - { - return $this->lastExecutedQuery; - } - - /** - * Set the SQL code for the latest query executed by Propel - * - * @param string $query Executable SQL code - */ - public function setLastExecutedQuery($query) - { - $this->lastExecutedQuery = $query; - } - - /** - * Enable or disable the query debug features - * - * @var boolean $value True to enable debug (default), false to disable it - */ - public function useDebug($value = true) - { - if ($value) { - $this->configureStatementClass('DebugPDOStatement', $suppress = true); - } else { - // reset query logging - $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement')); - $this->setLastExecutedQuery(''); - $this->queryCount = 0; - } - $this->clearStatementCache(); - $this->useDebug = $value; - } - - /** - * Sets the logging level to use for logging method calls and SQL statements. - * - * @param int $level Value of one of the Propel::LOG_* class constants. - */ - public function setLogLevel($level) - { - $this->logLevel = $level; - } + return $this->configuration; + } - /** - * Sets a logger to use. - * - * The logger will be used by this class to log various method calls and their properties. - * - * @param BasicLogger $logger A Logger with an API compatible with BasicLogger (or PEAR Log). - */ - public function setLogger($logger) - { - $this->logger = $logger; - } + /** + * Gets the current transaction depth. + * + * @return integer + */ + public function getNestedTransactionCount() + { + return $this->nestedTransactionCount; + } - /** - * Gets the logger in use. - * - * @return BasicLogger $logger A Logger with an API compatible with BasicLogger (or PEAR Log). - */ - public function getLogger() - { - return $this->logger; - } + /** + * Set the current transaction depth. + * + * @param int $v The new depth. + */ + protected function setNestedTransactionCount($v) + { + $this->nestedTransactionCount = $v; + } - /** - * Logs the method call or SQL using the Propel::log() method or a registered logger class. - * - * @uses self::getLogPrefix() - * @see self::setLogger() - * - * @param string $msg Message to log. - * @param int $level (optional) Log level to use; will use self::setLogLevel() specified level by default. - * @param string $methodName (optional) Name of the method whose execution is being logged. - * @param array $debugSnapshot (optional) Previous return value from self::getDebugSnapshot(). - */ - public function log($msg, $level = null, $methodName = null, array $debugSnapshot = null) - { - // If logging has been specifically disabled, this method won't do anything - if (!$this->getLoggingConfig('enabled', true)) { - return; - } - - // If the method being logged isn't one of the ones to be logged, bail - if (!in_array($methodName, $this->getLoggingConfig('methods', self::$defaultLogMethods))) { - return; - } - - // If a logging level wasn't provided, use the default one - if ($level === null) { - $level = $this->logLevel; - } + /** + * Is this PDO connection currently in-transaction? + * This is equivalent to asking whether the current nested transaction count is greater than 0. + * + * @return boolean + */ + public function isInTransaction() + { + return ($this->getNestedTransactionCount() > 0); + } - // Determine if this query is slow enough to warrant logging - if ($this->getLoggingConfig("onlyslow", self::DEFAULT_ONLYSLOW_ENABLED)) { - $now = $this->getDebugSnapshot(); - if ($now['microtime'] - $debugSnapshot['microtime'] < $this->getLoggingConfig("details.slow.threshold", self::DEFAULT_SLOW_THRESHOLD)) return; - } - - // If the necessary additional parameters were given, get the debug log prefix for the log line - if ($methodName && $debugSnapshot) { - $msg = $this->getLogPrefix($methodName, $debugSnapshot) . $msg; - } - - // We won't log empty messages - if (!$msg) { - return; - } - - // Delegate the actual logging forward - if ($this->logger) { - $this->logger->log($msg, $level); - } else { - Propel::log($msg, $level); - } - } - - /** - * Returns a snapshot of the current values of some functions useful in debugging. - * - * @return array - */ - public function getDebugSnapshot() - { - if ($this->useDebug) { - return array( - 'microtime' => microtime(true), - 'memory_get_usage' => memory_get_usage($this->getLoggingConfig('realmemoryusage', false)), - 'memory_get_peak_usage' => memory_get_peak_usage($this->getLoggingConfig('realmemoryusage', false)), - ); - } else { - throw new PropelException('Should not get debug snapshot when not debugging'); - } - } - - /** - * Returns a named configuration item from the Propel runtime configuration, from under the - * 'debugpdo.logging' prefix. If such a configuration setting hasn't been set, the given default - * value will be returned. - * - * @param string $key Key for which to return the value. - * @param mixed $defaultValue Default value to apply if config item hasn't been set. - * @return mixed - */ - protected function getLoggingConfig($key, $defaultValue) - { - return Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT)->getParameter("debugpdo.logging.$key", $defaultValue); - } - - /** - * Returns a prefix that may be prepended to a log line, containing debug information according - * to the current configuration. - * - * Uses a given $debugSnapshot to calculate how much time has passed since the call to self::getDebugSnapshot(), - * how much the memory consumption by PHP has changed etc. - * - * @see self::getDebugSnapshot() - * - * @param string $methodName Name of the method whose execution is being logged. - * @param array $debugSnapshot A previous return value from self::getDebugSnapshot(). - * @return string - */ - protected function getLogPrefix($methodName, $debugSnapshot) - { - $prefix = ''; - $now = $this->getDebugSnapshot(); - $logDetails = array_keys($this->getLoggingConfig('details', array())); - $innerGlue = $this->getLoggingConfig('innerglue', ': '); - $outerGlue = $this->getLoggingConfig('outerglue', ' | '); - - // Iterate through each detail that has been configured to be enabled - foreach ($logDetails as $detailName) { - - if (!$this->getLoggingConfig("details.$detailName.enabled", false)) - continue; - - switch ($detailName) { - - case 'slow'; - $value = $now['microtime'] - $debugSnapshot['microtime'] >= $this->getLoggingConfig("details.$detailName.threshold", self::DEFAULT_SLOW_THRESHOLD) ? 'YES' : ' NO'; - break; - - case 'time': - $value = number_format($now['microtime'] - $debugSnapshot['microtime'], $this->getLoggingConfig("details.$detailName.precision", 3)) . ' sec'; - $value = str_pad($value, $this->getLoggingConfig("details.$detailName.pad", 10), ' ', STR_PAD_LEFT); - break; - - case 'mem': - $value = self::getReadableBytes($now['memory_get_usage'], $this->getLoggingConfig("details.$detailName.precision", 1)); - $value = str_pad($value, $this->getLoggingConfig("details.$detailName.pad", 9), ' ', STR_PAD_LEFT); - break; - - case 'memdelta': - $value = $now['memory_get_usage'] - $debugSnapshot['memory_get_usage']; - $value = ($value > 0 ? '+' : '') . self::getReadableBytes($value, $this->getLoggingConfig("details.$detailName.precision", 1)); - $value = str_pad($value, $this->getLoggingConfig("details.$detailName.pad", 10), ' ', STR_PAD_LEFT); - break; - - case 'mempeak': - $value = self::getReadableBytes($now['memory_get_peak_usage'], $this->getLoggingConfig("details.$detailName.precision", 1)); - $value = str_pad($value, $this->getLoggingConfig("details.$detailName.pad", 9), ' ', STR_PAD_LEFT); - break; - - case 'querycount': - $value = $this->getQueryCount(); - $value = str_pad($value, $this->getLoggingConfig("details.$detailName.pad", 2), ' ', STR_PAD_LEFT); - break; - - case 'method': - $value = $methodName; - $value = str_pad($value, $this->getLoggingConfig("details.$detailName.pad", 28), ' ', STR_PAD_RIGHT); - break; - - default: - $value = 'n/a'; - break; - - } - - $prefix .= $detailName . $innerGlue . $value . $outerGlue; - - } - - return $prefix; - } - - /** - * Returns a human-readable representation of the given byte count. - * - * @param int $bytes Byte count to convert. - * @param int $precision How many decimals to include. - * @return string - */ - protected function getReadableBytes($bytes, $precision) - { - $suffix = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); - $total = count($suffix); - - for ($i = 0; $bytes > 1024 && $i < $total; $i++) - $bytes /= 1024; - - return number_format($bytes, $precision) . ' ' . $suffix[$i]; - } - - /** - * If so configured, makes an entry to the log of the state of this object just prior to its destruction. - * Add PropelPDO::__destruct to $defaultLogMethods to see this message - * - * @see self::log() - */ - public function __destruct() - { - if ($this->useDebug) { - $this->log('Closing connection', null, __METHOD__, $this->getDebugSnapshot()); - } - } + /** + * Check whether the connection contains a transaction that can be committed. + * To be used in an environment where Propelexceptions are caught. + * + * @return boolean True if the connection is in a committable transaction + */ + public function isCommitable() + { + return $this->isInTransaction() && !$this->isUncommitable; + } + /** + * Overrides PDO::beginTransaction() to prevent errors due to already-in-progress transaction. + * + * @return boolean + */ + public function beginTransaction() + { + $return = true; + if (!$this->nestedTransactionCount) { + $return = parent::beginTransaction(); + if ($this->useDebug) { + $this->log('Begin transaction', null, __METHOD__); + } + $this->isUncommitable = false; + } + $this->nestedTransactionCount++; + + return $return; + } + + /** + * Overrides PDO::commit() to only commit the transaction if we are in the outermost + * transaction nesting level. + * + * @return boolean + * + * @throws PropelException + */ + public function commit() + { + $return = true; + $opcount = $this->nestedTransactionCount; + + if ($opcount > 0) { + if ($opcount === 1) { + if ($this->isUncommitable) { + throw new PropelException('Cannot commit because a nested transaction was rolled back'); + } else { + $return = parent::commit(); + if ($this->useDebug) { + $this->log('Commit transaction', null, __METHOD__); + } + } + } + + $this->nestedTransactionCount--; + } + + return $return; + } + + /** + * Overrides PDO::rollBack() to only rollback the transaction if we are in the outermost + * transaction nesting level + * + * @return boolean Whether operation was successful. + */ + public function rollBack() + { + $return = true; + $opcount = $this->nestedTransactionCount; + + if ($opcount > 0) { + if ($opcount === 1) { + $return = parent::rollBack(); + if ($this->useDebug) { + $this->log('Rollback transaction', null, __METHOD__); + } + } else { + $this->isUncommitable = true; + } + + $this->nestedTransactionCount--; + } + + return $return; + } + + /** + * Rollback the whole transaction, even if this is a nested rollback + * and reset the nested transaction count to 0. + * + * @return boolean Whether operation was successful. + */ + public function forceRollBack() + { + $return = true; + + if ($this->nestedTransactionCount) { + // If we're in a transaction, always roll it back + // regardless of nesting level. + $return = parent::rollBack(); + + // reset nested transaction count to 0 so that we don't + // try to commit (or rollback) the transaction outside this scope. + $this->nestedTransactionCount = 0; + + if ($this->useDebug) { + $this->log('Rollback transaction', null, __METHOD__); + } + } + + return $return; + } + + /** + * Sets a connection attribute. + * + * This is overridden here to provide support for setting Propel-specific attributes too. + * + * @param integer $attribute The attribute to set (e.g. PropelPDO::PROPEL_ATTR_CACHE_PREPARES). + * @param mixed $value The attribute value. + * + * @return void + */ + public function setAttribute($attribute, $value) + { + switch ($attribute) { + case self::PROPEL_ATTR_CACHE_PREPARES: + $this->cachePreparedStatements = $value; + break; + case self::PROPEL_ATTR_CONNECTION_NAME: + $this->connectionName = $value; + break; + default: + parent::setAttribute($attribute, $value); + } + } + + /** + * Gets a connection attribute. + * + * This is overridden here to provide support for setting Propel-specific attributes too. + * + * @param integer $attribute The attribute to get (e.g. PropelPDO::PROPEL_ATTR_CACHE_PREPARES). + * + * @return mixed + */ + public function getAttribute($attribute) + { + switch ($attribute) { + case self::PROPEL_ATTR_CACHE_PREPARES: + return $this->cachePreparedStatements; + break; + case self::PROPEL_ATTR_CONNECTION_NAME: + return $this->connectionName; + break; + default: + return parent::getAttribute($attribute); + } + } + + /** + * Prepares a statement for execution and returns a statement object. + * + * Overrides PDO::prepare() in order to: + * - Add logging and query counting if logging is true. + * - Add query caching support if the PropelPDO::PROPEL_ATTR_CACHE_PREPARES was set to true. + * + * @param string $sql This must be a valid SQL statement for the target database server. + * @param array $driver_options One $array or more key => value pairs to set attribute values + * for the PDOStatement object that this method returns. + * + * @return PDOStatement + */ + public function prepare($sql, $driver_options = array()) + { + if ($this->useDebug) { + $debug = $this->getDebugSnapshot(); + } + + if ($this->cachePreparedStatements) { + if (!isset($this->preparedStatements[$sql])) { + $return = parent::prepare($sql, $driver_options); + $this->preparedStatements[$sql] = $return; + } else { + $return = $this->preparedStatements[$sql]; + } + } else { + $return = parent::prepare($sql, $driver_options); + } + + if ($this->useDebug) { + $this->log($sql, null, __METHOD__, $debug); + } + + return $return; + } + + /** + * Execute an SQL statement and return the number of affected rows. + * Overrides PDO::exec() to log queries when required + * + * @param string $sql + * + * @return integer + */ + public function exec($sql) + { + if ($this->useDebug) { + $debug = $this->getDebugSnapshot(); + } + + $return = parent::exec($sql); + + if ($this->useDebug) { + $this->log($sql, null, __METHOD__, $debug); + $this->setLastExecutedQuery($sql); + $this->incrementQueryCount(); + } + + return $return; + } + + /** + * Executes an SQL statement, returning a result set as a PDOStatement object. + * Despite its signature here, this method takes a variety of parameters. + * + * Overrides PDO::query() to log queries when required + * + * @see http://php.net/manual/en/pdo.query.php for a description of the possible parameters. + * + * @return PDOStatement + */ + public function query() + { + if ($this->useDebug) { + $debug = $this->getDebugSnapshot(); + } + + $args = func_get_args(); + if (version_compare(PHP_VERSION, '5.3', '<')) { + $return = call_user_func_array(array($this, 'parent::query'), $args); + } else { + $return = call_user_func_array('parent::query', $args); + } + + if ($this->useDebug) { + $sql = $args[0]; + $this->log($sql, null, __METHOD__, $debug); + $this->setLastExecutedQuery($sql); + $this->incrementQueryCount(); + } + + return $return; + } + + /** + * Clears any stored prepared statements for this connection. + */ + public function clearStatementCache() + { + $this->preparedStatements = array(); + } + + /** + * Configures the PDOStatement class for this connection. + * + * @param string $class + * @param boolean $suppressError Whether to suppress an exception if the statement class cannot be set. + * + * @throws PropelException if the statement class cannot be set (and $suppressError is false). + */ + protected function configureStatementClass($class = 'PDOStatement', $suppressError = true) + { + // extending PDOStatement is only supported with non-persistent connections + if (!$this->getAttribute(PDO::ATTR_PERSISTENT)) { + $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($class, array($this))); + } elseif (!$suppressError) { + throw new PropelException('Extending PDOStatement is not supported with persistent connections.'); + } + } + + /** + * Returns the number of queries this DebugPDO instance has performed on the database connection. + * + * When using DebugPDOStatement as the statement class, any queries by DebugPDOStatement instances + * are counted as well. + * + * @throws PropelException if persistent connection is used (since unable to override PDOStatement in that case). + * @return integer + */ + public function getQueryCount() + { + // extending PDOStatement is not supported with persistent connections + if ($this->getAttribute(PDO::ATTR_PERSISTENT)) { + throw new PropelException('Extending PDOStatement is not supported with persistent connections. Count would be inaccurate, because we cannot count the PDOStatment::execute() calls. Either don\'t use persistent connections or don\'t call PropelPDO::getQueryCount()'); + } + + return $this->queryCount; + } + + /** + * Increments the number of queries performed by this DebugPDO instance. + * + * Returns the original number of queries (ie the value of $this->queryCount before calling this method). + * + * @return integer + */ + public function incrementQueryCount() + { + $this->queryCount++; + } + + /** + * Get the SQL code for the latest query executed by Propel + * + * @return string Executable SQL code + */ + public function getLastExecutedQuery() + { + return $this->lastExecutedQuery; + } + + /** + * Set the SQL code for the latest query executed by Propel + * + * @param string $query Executable SQL code + */ + public function setLastExecutedQuery($query) + { + $this->lastExecutedQuery = $query; + } + + /** + * Enable or disable the query debug features + * + * @param boolean $value True to enable debug (default), false to disable it + */ + public function useDebug($value = true) + { + if ($value) { + $this->configureStatementClass('DebugPDOStatement', true); + } else { + // reset query logging + $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement')); + $this->setLastExecutedQuery(''); + $this->queryCount = 0; + } + $this->clearStatementCache(); + $this->useDebug = $value; + } + + /** + * Sets the logging level to use for logging method calls and SQL statements. + * + * @param integer $level Value of one of the Propel::LOG_* class constants. + */ + public function setLogLevel($level) + { + $this->logLevel = $level; + } + + /** + * Sets a logger to use. + * + * The logger will be used by this class to log various method calls and their properties. + * + * @param BasicLogger $logger A Logger with an API compatible with BasicLogger (or PEAR Log). + */ + public function setLogger($logger) + { + $this->logger = $logger; + } + + /** + * Gets the logger in use. + * + * @return BasicLogger A Logger with an API compatible with BasicLogger (or PEAR Log). + */ + public function getLogger() + { + return $this->logger; + } + + /** + * Logs the method call or SQL using the Propel::log() method or a registered logger class. + * + * @uses self::getLogPrefix() + * @see self::setLogger() + * + * @param string $msg Message to log. + * @param integer $level Log level to use; will use self::setLogLevel() specified level by default. + * @param string $methodName Name of the method whose execution is being logged. + * @param array $debugSnapshot Previous return value from self::getDebugSnapshot(). + */ + public function log($msg, $level = null, $methodName = null, array $debugSnapshot = null) + { + // If logging has been specifically disabled, this method won't do anything + if (!$this->getLoggingConfig('enabled', true)) { + return; + } + + // If the method being logged isn't one of the ones to be logged, bail + if (!in_array($methodName, $this->getLoggingConfig('methods', self::$defaultLogMethods))) { + return; + } + + // If a logging level wasn't provided, use the default one + if ($level === null) { + $level = $this->logLevel; + } + + // Determine if this query is slow enough to warrant logging + if ($this->getLoggingConfig("onlyslow", self::DEFAULT_ONLYSLOW_ENABLED)) { + $now = $this->getDebugSnapshot(); + if ($now['microtime'] - $debugSnapshot['microtime'] < $this->getLoggingConfig("details.slow.threshold", self::DEFAULT_SLOW_THRESHOLD)) { + return; + } + } + + // If the necessary additional parameters were given, get the debug log prefix for the log line + if ($methodName && $debugSnapshot) { + $msg = $this->getLogPrefix($methodName, $debugSnapshot) . $msg; + } + + // We won't log empty messages + if (!$msg) { + return; + } + + // Delegate the actual logging forward + if ($this->logger) { + $this->logger->log($msg, $level); + } else { + Propel::log($msg, $level); + } + } + + /** + * Returns a snapshot of the current values of some functions useful in debugging. + * + * @return array + * + * @throws PropelException + */ + public function getDebugSnapshot() + { + if ($this->useDebug) { + return array( + 'microtime' => microtime(true), + 'memory_get_usage' => memory_get_usage($this->getLoggingConfig('realmemoryusage', false)), + 'memory_get_peak_usage' => memory_get_peak_usage($this->getLoggingConfig('realmemoryusage', false)), + ); + } else { + throw new PropelException('Should not get debug snapshot when not debugging'); + } + } + + /** + * Returns a named configuration item from the Propel runtime configuration, from under the + * 'debugpdo.logging' prefix. If such a configuration setting hasn't been set, the given default + * value will be returned. + * + * @param string $key Key for which to return the value. + * @param mixed $defaultValue Default value to apply if config item hasn't been set. + * + * @return mixed + */ + protected function getLoggingConfig($key, $defaultValue) + { + return $this->getConfiguration()->getParameter("debugpdo.logging.$key", $defaultValue); + } + + /** + * Returns a prefix that may be prepended to a log line, containing debug information according + * to the current configuration. + * + * Uses a given $debugSnapshot to calculate how much time has passed since the call to self::getDebugSnapshot(), + * how much the memory consumption by PHP has changed etc. + * + * @see self::getDebugSnapshot() + * + * @param string $methodName Name of the method whose execution is being logged. + * @param array $debugSnapshot A previous return value from self::getDebugSnapshot(). + * + * @return string + */ + protected function getLogPrefix($methodName, $debugSnapshot) + { + $config = $this->getConfiguration()->getParameters(); + if (!isset($config['debugpdo']['logging']['details'])) { + return ''; + } + $prefix = ''; + $logDetails = $config['debugpdo']['logging']['details']; + $now = $this->getDebugSnapshot(); + $innerGlue = $this->getLoggingConfig('innerglue', ': '); + $outerGlue = $this->getLoggingConfig('outerglue', ' | '); + + // Iterate through each detail that has been configured to be enabled + foreach ($logDetails as $detailName => $details) { + + if (!$this->getLoggingConfig("details.$detailName.enabled", false)) { + continue; + } + + switch ($detailName) { + + case 'slow'; + $value = $now['microtime'] - $debugSnapshot['microtime'] >= $this->getLoggingConfig('details.slow.threshold', self::DEFAULT_SLOW_THRESHOLD) ? 'YES' : ' NO'; + break; + + case 'time': + $value = number_format($now['microtime'] - $debugSnapshot['microtime'], $this->getLoggingConfig('details.time.precision', 3)) . ' sec'; + $value = str_pad($value, $this->getLoggingConfig('details.time.pad', 10), ' ', STR_PAD_LEFT); + break; + + case 'mem': + $value = self::getReadableBytes($now['memory_get_usage'], $this->getLoggingConfig('details.mem.precision', 1)); + $value = str_pad($value, $this->getLoggingConfig('details.mem.pad', 9), ' ', STR_PAD_LEFT); + break; + + case 'memdelta': + $value = $now['memory_get_usage'] - $debugSnapshot['memory_get_usage']; + $value = ($value > 0 ? '+' : '') . self::getReadableBytes($value, $this->getLoggingConfig('details.memdelta.precision', 1)); + $value = str_pad($value, $this->getLoggingConfig('details.memdelta.pad', 10), ' ', STR_PAD_LEFT); + break; + + case 'mempeak': + $value = self::getReadableBytes($now['memory_get_peak_usage'], $this->getLoggingConfig('details.mempeak.precision', 1)); + $value = str_pad($value, $this->getLoggingConfig('details.mempeak.pad', 9), ' ', STR_PAD_LEFT); + break; + + case 'querycount': + $value = str_pad($this->getQueryCount(), $this->getLoggingConfig('details.querycount.pad', 2), ' ', STR_PAD_LEFT); + break; + + case 'method': + $value = str_pad($methodName, $this->getLoggingConfig('details.method.pad', 28), ' ', STR_PAD_RIGHT); + break; + + case 'connection': + $value = $this->connectionName; + break; + + default: + $value = 'n/a'; + break; + } + + $prefix .= $detailName . $innerGlue . $value . $outerGlue; + } + + return $prefix; + } + + /** + * Returns a human-readable representation of the given byte count. + * + * @param integer $bytes Byte count to convert. + * @param integer $precision How many decimals to include. + * + * @return string + */ + protected function getReadableBytes($bytes, $precision) + { + $suffix = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); + $total = count($suffix); + + for ($i = 0; $bytes > 1024 && $i < $total; $i++) { + $bytes /= 1024; + } + + return number_format($bytes, $precision) . ' ' . $suffix[$i]; + } + + /** + * If so configured, makes an entry to the log of the state of this object just prior to its destruction. + * Add PropelPDO::__destruct to $defaultLogMethods to see this message + * + * @see self::log() + */ + public function __destruct() + { + if ($this->useDebug) { + $this->log('Closing connection', null, __METHOD__, $this->getDebugSnapshot()); + } + } } diff --git a/airtime_mvc/library/propel/runtime/lib/exception/PropelException.php b/airtime_mvc/library/propel/runtime/lib/exception/PropelException.php index b6a7bc700..ac41d55c2 100644 --- a/airtime_mvc/library/propel/runtime/lib/exception/PropelException.php +++ b/airtime_mvc/library/propel/runtime/lib/exception/PropelException.php @@ -10,41 +10,60 @@ /** * The base class of all exceptions thrown by Propel. + * * @author Hans Lellelid - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.exception */ -class PropelException extends Exception { +class PropelException extends Exception +{ + /** + * The nested "cause" exception. + * + * @var Exception + */ + protected $cause; - /** The nested "cause" exception. */ - protected $cause; + /** + * Emulates wrapped exceptions for PHP < 5.3 + * + * @param string $message + * @param Exception $previous + * + * @return PropelException + */ + public function __construct($message = null, Exception $previous = null) + { + if ($previous === null && $message instanceof Exception) { + $previous = $message; + $message = ""; + } - function __construct($p1, $p2 = null) { - - $cause = null; - - if ($p2 !== null) { - $msg = $p1; - $cause = $p2; - } else { - if ($p1 instanceof Exception) { - $msg = ""; - $cause = $p1; - } else { - $msg = $p1; - } - } - - parent::__construct($msg); - - if ($cause !== null) { - $this->cause = $cause; - $this->message .= " [wrapped: " . $cause->getMessage() ."]"; - } - } - - function getCause() { - return $this->cause; - } + if ($previous !== null) { + $message .= " [wrapped: " . $previous->getMessage() . "]"; + if (version_compare(PHP_VERSION, '5.3.0') >= 0) { + parent::__construct($message, 0, $previous); + } else { + parent::__construct($message); + $this->cause = $previous; + } + } else { + parent::__construct($message); + } + } + /** + * Get the previous Exception + * We can't override getPrevious() since it's final + * + * @return Exception The previous exception + */ + public function getCause() + { + if (version_compare(PHP_VERSION, '5.3.0') >= 0) { + return $this->getPrevious(); + } else { + return $this->cause; + } + } } diff --git a/airtime_mvc/library/propel/runtime/lib/formatter/ModelWith.php b/airtime_mvc/library/propel/runtime/lib/formatter/ModelWith.php index 2e295505d..3c5454c48 100644 --- a/airtime_mvc/library/propel/runtime/lib/formatter/ModelWith.php +++ b/airtime_mvc/library/propel/runtime/lib/formatter/ModelWith.php @@ -17,128 +17,176 @@ */ class ModelWith { - protected $modelName = ''; - protected $modelPeerName = ''; - protected $isSingleTableInheritance = false; - protected $isAdd = false; - protected $relationName = ''; - protected $relationMethod = ''; - protected $relatedClass; - - public function __construct(ModelJoin $join = null) - { - if (null !== $join) { - $this->init($join); - } - } - - /** - * Define the joined hydration schema based on a join object. - * Fills the ModelWith properties using a ModelJoin as source - * - * @param ModelJoin $join - */ - public function init(ModelJoin $join) - { - $tableMap = $join->getTableMap(); - $this->modelName = $tableMap->getClassname(); - $this->modelPeerName = $tableMap->getPeerClassname(); - $this->isSingleTableInheritance = $tableMap->isSingleTableInheritance(); - $relation = $join->getRelationMap(); - if ($relation->getType() == RelationMap::ONE_TO_MANY) { - $this->isAdd = true; - $this->relationName = $relation->getName() . 's'; - $this->relationMethod = 'add' . $relation->getName(); - } else { - $this->relationName = $relation->getName(); - $this->relationMethod = 'set' . $relation->getName(); - } - if (!$join->isPrimary()) { - $this->relatedClass = $join->hasLeftTableAlias() ? $join->getLeftTableAlias() : $relation->getLeftTable()->getPhpName(); - } - } - - // DataObject getters & setters - - public function setModelName($modelName) - { - $this->modelName = $modelName; - } - - public function getModelName() - { - return $this->modelName; - } - - public function setModelPeerName($modelPeerName) - { - $this->modelPeerName = $modelPeerName; - } - - public function getModelPeerName() - { - return $this->modelPeerName; - } - - public function setIsSingleTableInheritance($isSingleTableInheritance) - { - $this->isSingleTableInheritance = $isSingleTableInheritance; - } - - public function isSingleTableInheritance() - { - return $this->isSingleTableInheritance; - } - - public function setIsAdd($isAdd) - { - $this->isAdd = $isAdd;; - } - - public function isAdd() - { - return $this->isAdd; - } - - public function setRelationName($relationName) - { - $this->relationName = $relationName; - } - - public function getRelationName() - { - return $this->relationName; - } - - public function setRelationMethod($relationMethod) - { - $this->relationMethod = $relationMethod; - } + protected $modelName = ''; + protected $modelPeerName = ''; + protected $isSingleTableInheritance = false; + protected $isAdd = false; + protected $isWithOneToMany = false; + protected $relationName = ''; + protected $relationMethod = ''; + protected $initMethod = ''; + protected $resetPartialMethod = ''; + protected $leftPhpName; + protected $rightPhpName; - public function getRelationMethod() - { - return $this->relationMethod; - } - - public function setRelatedClass($relatedClass) - { - $this->relatedClass = $relatedClass; - } - - public function getRelatedClass() - { - return $this->relatedClass; - } - - // Utility methods - - public function isPrimary() - { - return null === $this->relatedClass; - } - - public function __toString() - { - return sprintf("modelName: %s, relationName: %s, relationMethod: %s, relatedClass: %s", $this->modelName, $this->relationName, $this->relationMethod, $this->relatedClass); - } -} \ No newline at end of file + public function __construct(ModelJoin $join = null) + { + if (null !== $join) { + $this->init($join); + } + } + + /** + * Define the joined hydration schema based on a join object. + * Fills the ModelWith properties using a ModelJoin as source + * + * @param ModelJoin $join + */ + public function init(ModelJoin $join) + { + $tableMap = $join->getTableMap(); + $this->modelName = $tableMap->getClassname(); + $this->modelPeerName = $tableMap->getPeerClassname(); + $this->isSingleTableInheritance = $tableMap->isSingleTableInheritance(); + $relation = $join->getRelationMap(); + $relationName = $relation->getName(); + if ($relation->getType() == RelationMap::ONE_TO_MANY) { + $this->isAdd = $this->isWithOneToMany = true; + $this->relationName = $relation->getPluralName(); + $this->relationMethod = 'add' . $relationName; + $this->initMethod = 'init' . $this->relationName; + $this->resetPartialMethod = 'resetPartial' . $this->relationName; + } else { + $this->relationName = $relationName; + $this->relationMethod = 'set' . $relationName; + } + $this->rightPhpName = $join->hasRelationAlias() ? $join->getRelationAlias() : $relationName; + if (!$join->isPrimary()) { + $this->leftPhpName = $join->hasLeftTableAlias() ? $join->getLeftTableAlias() : $join->getPreviousJoin()->getRelationMap()->getName(); + } + } + + // DataObject getters & setters + + public function setModelName($modelName) + { + $this->modelName = $modelName; + } + + public function getModelName() + { + return $this->modelName; + } + + public function setModelPeerName($modelPeerName) + { + $this->modelPeerName = $modelPeerName; + } + + public function getModelPeerName() + { + return $this->modelPeerName; + } + + public function setIsSingleTableInheritance($isSingleTableInheritance) + { + $this->isSingleTableInheritance = $isSingleTableInheritance; + } + + public function isSingleTableInheritance() + { + return $this->isSingleTableInheritance; + } + + public function setIsAdd($isAdd) + { + $this->isAdd = $isAdd; + } + + public function isAdd() + { + return $this->isAdd; + } + + public function setIsWithOneToMany($isWithOneToMany) + { + $this->isWithOneToMany = $isWithOneToMany; + } + + public function isWithOneToMany() + { + return $this->isWithOneToMany; + } + + public function setRelationName($relationName) + { + $this->relationName = $relationName; + } + + public function getRelationName() + { + return $this->relationName; + } + + public function setRelationMethod($relationMethod) + { + $this->relationMethod = $relationMethod; + } + + public function getRelationMethod() + { + return $this->relationMethod; + } + + public function setInitMethod($initMethod) + { + $this->initMethod = $initMethod; + } + + public function getInitMethod() + { + return $this->initMethod; + } + + public function setResetPartialMethod($resetPartialMethod) + { + $this->resetPartialMethod = $resetPartialMethod; + } + + public function getResetPartialMethod() + { + return $this->resetPartialMethod; + } + + public function setLeftPhpName($leftPhpName) + { + $this->leftPhpName = $leftPhpName; + } + + public function getLeftPhpName() + { + return $this->leftPhpName; + } + + public function setRightPhpName($rightPhpName) + { + $this->rightPhpName = $rightPhpName; + } + + public function getRightPhpName() + { + return $this->rightPhpName; + } + + // Utility methods + + public function isPrimary() + { + return null === $this->leftPhpName; + } + + public function __toString() + { + return sprintf("modelName: %s, relationName: %s, relationMethod: %s, leftPhpName: %s, rightPhpName: %s", $this->modelName, $this->relationName, $this->relationMethod, $this->leftPhpName, $this->rightPhpName); + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/formatter/PropelArrayFormatter.php b/airtime_mvc/library/propel/runtime/lib/formatter/PropelArrayFormatter.php index 97bc33427..a8dd8edbc 100644 --- a/airtime_mvc/library/propel/runtime/lib/formatter/PropelArrayFormatter.php +++ b/airtime_mvc/library/propel/runtime/lib/formatter/PropelArrayFormatter.php @@ -13,158 +13,157 @@ * format() returns a PropelArrayCollection of associative arrays * * @author Francois Zaninotto - * @version $Revision: 1796 $ + * @version $Revision$ * @package propel.runtime.formatter */ class PropelArrayFormatter extends PropelFormatter { - protected $collectionName = 'PropelArrayCollection'; - protected $alreadyHydratedObjects = array(); - protected $emptyVariable; - - public function format(PDOStatement $stmt) - { - $this->checkInit(); - if($class = $this->collectionName) { - $collection = new $class(); - $collection->setModel($this->class); - $collection->setFormatter($this); - } else { - $collection = array(); - } - if ($this->isWithOneToMany() && $this->hasLimit) { - throw new PropelException('Cannot use limit() in conjunction with with() on a one-to-many relationship. Please remove the with() call, or the limit() call.'); - } - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - if ($object = &$this->getStructuredArrayFromRow($row)) { - $collection[] = $object; - } - } - $this->currentObjects = array(); - $this->alreadyHydratedObjects = array(); - $stmt->closeCursor(); - - return $collection; - } + protected $collectionName = 'PropelArrayCollection'; + protected $alreadyHydratedObjects = array(); + protected $emptyVariable; - public function formatOne(PDOStatement $stmt) - { - $this->checkInit(); - $result = null; - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - if ($object = &$this->getStructuredArrayFromRow($row)) { - $result = &$object; - } - } - $this->currentObjects = array(); - $this->alreadyHydratedObjects = array(); - $stmt->closeCursor(); - return $result; - } + public function format(PDOStatement $stmt) + { + $this->checkInit(); + if ($class = $this->collectionName) { + $collection = new $class(); + $collection->setModel($this->class); + $collection->setFormatter($this); + } else { + $collection = array(); + } + if ($this->isWithOneToMany() && $this->hasLimit) { + throw new PropelException('Cannot use limit() in conjunction with with() on a one-to-many relationship. Please remove the with() call, or the limit() call.'); + } + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + if ($object = &$this->getStructuredArrayFromRow($row)) { + $collection[] = $object; + } + } + $this->currentObjects = array(); + $this->alreadyHydratedObjects = array(); + $stmt->closeCursor(); - /** - * Formats an ActiveRecord object - * - * @param BaseObject $record the object to format - * - * @return array The original record turned into an array - */ - public function formatRecord($record = null) - { - return $record ? $record->toArray() : array(); - } - - public function isObjectFormatter() - { - return false; - } - + return $collection; + } - /** - * Hydrates a series of objects from a result row - * The first object to hydrate is the model of the Criteria - * The following objects (the ones added by way of ModelCriteria::with()) are linked to the first one - * - * @param array $row associative array indexed by column number, - * as returned by PDOStatement::fetch(PDO::FETCH_NUM) - * - * @return Array - */ - public function &getStructuredArrayFromRow($row) - { - $col = 0; - - // hydrate main object or take it from registry - $mainObjectIsNew = false; - $mainKey = call_user_func(array($this->peer, 'getPrimaryKeyHashFromRow'), $row); - // we hydrate the main object even in case of a one-to-many relationship - // in order to get the $col variable increased anyway - $obj = $this->getSingleObjectFromRow($row, $this->class, $col); - if (!isset($this->alreadyHydratedObjects[$this->class][$mainKey])) { - $this->alreadyHydratedObjects[$this->class][$mainKey] = $obj->toArray(); - $mainObjectIsNew = true; - } - - $hydrationChain = array(); - - // related objects added using with() - foreach ($this->getWith() as $relAlias => $modelWith) { - - // determine class to use - if ($modelWith->isSingleTableInheritance()) { - $class = call_user_func(array($modelWith->getModelPeerName(), 'getOMClass'), $row, $col, false); - $refl = new ReflectionClass($class); - if ($refl->isAbstract()) { - $col += constant($class . 'Peer::NUM_COLUMNS'); - continue; - } - } else { - $class = $modelWith->getModelName(); - } - - // hydrate related object or take it from registry - $key = call_user_func(array($modelWith->getModelPeerName(), 'getPrimaryKeyHashFromRow'), $row, $col); - // we hydrate the main object even in case of a one-to-many relationship - // in order to get the $col variable increased anyway - $secondaryObject = $this->getSingleObjectFromRow($row, $class, $col); - if (!isset($this->alreadyHydratedObjects[$relAlias][$key])) { - - if ($secondaryObject->isPrimaryKeyNull()) { - $this->alreadyHydratedObjects[$relAlias][$key] = array(); - } else { - $this->alreadyHydratedObjects[$relAlias][$key] = $secondaryObject->toArray(); - } - } - - if ($modelWith->isPrimary()) { - $arrayToAugment = &$this->alreadyHydratedObjects[$this->class][$mainKey]; - } else { - $arrayToAugment = &$hydrationChain[$modelWith->getRelatedClass()]; - } - - if ($modelWith->isAdd()) { - if (!isset($arrayToAugment[$modelWith->getRelationName()]) || !in_array($this->alreadyHydratedObjects[$relAlias][$key], $arrayToAugment[$modelWith->getRelationName()])) { - $arrayToAugment[$modelWith->getRelationName()][] = &$this->alreadyHydratedObjects[$relAlias][$key]; - } - } else { - $arrayToAugment[$modelWith->getRelationName()] = &$this->alreadyHydratedObjects[$relAlias][$key]; - } - - $hydrationChain[$relAlias] = &$this->alreadyHydratedObjects[$relAlias][$key]; - } - - // columns added using withColumn() - foreach ($this->getAsColumns() as $alias => $clause) { - $this->alreadyHydratedObjects[$this->class][$mainKey][$alias] = $row[$col]; - $col++; - } - - if ($mainObjectIsNew) { - return $this->alreadyHydratedObjects[$this->class][$mainKey]; - } else { - // we still need to return a reference to something to avoid a warning - return $emptyVariable; - } - } + public function formatOne(PDOStatement $stmt) + { + $this->checkInit(); + $result = null; + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + if ($object = &$this->getStructuredArrayFromRow($row)) { + $result = &$object; + } + } + $this->currentObjects = array(); + $this->alreadyHydratedObjects = array(); + $stmt->closeCursor(); -} \ No newline at end of file + return $result; + } + + /** + * Formats an ActiveRecord object + * + * @param BaseObject $record the object to format + * + * @return array The original record turned into an array + */ + public function formatRecord($record = null) + { + return $record ? $record->toArray() : array(); + } + + public function isObjectFormatter() + { + return false; + } + + /** + * Hydrates a series of objects from a result row + * The first object to hydrate is the model of the Criteria + * The following objects (the ones added by way of ModelCriteria::with()) are linked to the first one + * + * @param array $row associative array indexed by column number, + * as returned by PDOStatement::fetch(PDO::FETCH_NUM) + * + * @return Array + */ + public function &getStructuredArrayFromRow($row) + { + $col = 0; + + // hydrate main object or take it from registry + $mainObjectIsNew = false; + $mainKey = call_user_func(array($this->peer, 'getPrimaryKeyHashFromRow'), $row); + // we hydrate the main object even in case of a one-to-many relationship + // in order to get the $col variable increased anyway + $obj = $this->getSingleObjectFromRow($row, $this->class, $col); + if (!isset($this->alreadyHydratedObjects[$this->class][$mainKey])) { + $this->alreadyHydratedObjects[$this->class][$mainKey] = $obj->toArray(); + $mainObjectIsNew = true; + } + + $hydrationChain = array(); + + // related objects added using with() + foreach ($this->getWith() as $relAlias => $modelWith) { + + // determine class to use + if ($modelWith->isSingleTableInheritance()) { + $class = call_user_func(array($modelWith->getModelPeerName(), 'getOMClass'), $row, $col); + $refl = new ReflectionClass($class); + if ($refl->isAbstract()) { + $col += constant($class . 'Peer::NUM_COLUMNS'); + continue; + } + } else { + $class = $modelWith->getModelName(); + } + + // hydrate related object or take it from registry + $key = call_user_func(array($modelWith->getModelPeerName(), 'getPrimaryKeyHashFromRow'), $row, $col); + // we hydrate the main object even in case of a one-to-many relationship + // in order to get the $col variable increased anyway + $secondaryObject = $this->getSingleObjectFromRow($row, $class, $col); + if (!isset($this->alreadyHydratedObjects[$relAlias][$key])) { + + if ($secondaryObject->isPrimaryKeyNull()) { + $this->alreadyHydratedObjects[$relAlias][$key] = array(); + } else { + $this->alreadyHydratedObjects[$relAlias][$key] = $secondaryObject->toArray(); + } + } + + if ($modelWith->isPrimary()) { + $arrayToAugment = &$this->alreadyHydratedObjects[$this->class][$mainKey]; + } else { + $arrayToAugment = &$hydrationChain[$modelWith->getLeftPhpName()]; + } + + if ($modelWith->isAdd()) { + if (!isset($arrayToAugment[$modelWith->getRelationName()]) || !in_array($this->alreadyHydratedObjects[$relAlias][$key], $arrayToAugment[$modelWith->getRelationName()])) { + $arrayToAugment[$modelWith->getRelationName()][] = &$this->alreadyHydratedObjects[$relAlias][$key]; + } + } else { + $arrayToAugment[$modelWith->getRelationName()] = &$this->alreadyHydratedObjects[$relAlias][$key]; + } + + $hydrationChain[$modelWith->getRightPhpName()] = &$this->alreadyHydratedObjects[$relAlias][$key]; + } + + // columns added using withColumn() + foreach ($this->getAsColumns() as $alias => $clause) { + $this->alreadyHydratedObjects[$this->class][$mainKey][$alias] = $row[$col]; + $col++; + } + + if ($mainObjectIsNew) { + return $this->alreadyHydratedObjects[$this->class][$mainKey]; + } else { + // we still need to return a reference to something to avoid a warning + return $emptyVariable; + } + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/formatter/PropelFormatter.php b/airtime_mvc/library/propel/runtime/lib/formatter/PropelFormatter.php index 5933515d9..362faf1d6 100644 --- a/airtime_mvc/library/propel/runtime/lib/formatter/PropelFormatter.php +++ b/airtime_mvc/library/propel/runtime/lib/formatter/PropelFormatter.php @@ -1,4 +1,4 @@ -init($criteria); - } - } - - /** - * Define the hydration schema based on a query object. - * Fills the Formatter's properties using a Criteria as source - * - * @param ModelCriteria $criteria - * - * @return PropelFormatter The current formatter object - */ - public function init(ModelCriteria $criteria) - { - $this->dbName = $criteria->getDbName(); - $this->class = $criteria->getModelName(); - $this->peer = $criteria->getModelPeerName(); - $this->setWith($criteria->getWith()); - $this->asColumns = $criteria->getAsColumns(); - $this->hasLimit = $criteria->getLimit() != 0; - - return $this; - } - - // DataObject getters & setters + protected + $dbName, + $class, + $peer, + $with = array(), + $asColumns = array(), + $hasLimit = false, + $currentObjects = array(); - public function setDbName($dbName) - { - $this->dbName = $dbName; - } - - public function getDbName() - { - return $this->dbName; - } - - public function setClass($class) - { - $this->class = $class; - } - - public function getClass() - { - return $this->class; - } - - public function setPeer($peer) - { - $this->peer = $peer; - } - - public function getPeer() - { - return $this->peer; - } - - public function setWith($withs = array()) - { - $this->with = array(); - foreach ($withs as $relation => $join) { - $this->with[$relation] = new ModelWith($join); - } - } - - public function getWith() - { - return $this->with; - } + public function __construct(ModelCriteria $criteria = null) + { + if (null !== $criteria) { + $this->init($criteria); + } + } - public function setAsColumns($asColumns = array()) - { - $this->asColumns = $asColumns; - } - - public function getAsColumns() - { - return $this->asColumns; - } + /** + * Define the hydration schema based on a query object. + * Fills the Formatter's properties using a Criteria as source + * + * @param ModelCriteria $criteria + * + * @return PropelFormatter The current formatter object + */ + public function init(ModelCriteria $criteria) + { + $this->dbName = $criteria->getDbName(); + $this->setClass($criteria->getModelName()); + $this->setWith($criteria->getWith()); + $this->asColumns = $criteria->getAsColumns(); + $this->hasLimit = $criteria->getLimit() != 0; - public function setHasLimit($hasLimit = false) - { - $this->hasLimit = $hasLimit; - } - - public function hasLimit() - { - return $this->hasLimit; - } - - /** - * Formats an ActiveRecord object - * - * @param BaseObject $record the object to format - * - * @return BaseObject The original record - */ - public function formatRecord($record = null) - { - return $record; - } - - abstract public function format(PDOStatement $stmt); + return $this; + } - abstract public function formatOne(PDOStatement $stmt); - - abstract public function isObjectFormatter(); - - public function checkInit() - { - if (null === $this->peer) { - throw new PropelException('You must initialize a formatter object before calling format() or formatOne()'); - } - } - - public function getTableMap() - { - return Propel::getDatabaseMap($this->dbName)->getTableByPhpName($this->class); - } - - protected function isWithOneToMany() - { - foreach ($this->with as $modelWith) { - if ($modelWith->isAdd()) { - return true; - } - } - return false; - } - - /** - * Gets the worker object for the class. - * To save memory, we don't create a new object for each row, - * But we keep hydrating a single object per class. - * The column offset in the row is used to index the array of classes - * As there may be more than one object of the same class in the chain - * - * @param int $col Offset of the object in the list of objects to hydrate - * @param string $class Propel model object class - * - * @return BaseObject - */ - protected function getWorkerObject($col, $class) - { - if(isset($this->currentObjects[$col])) { - $this->currentObjects[$col]->clear(); - } else { - $this->currentObjects[$col] = new $class(); - } - return $this->currentObjects[$col]; - } - - /** - * Gets a Propel object hydrated from a selection of columns in statement row - * - * @param array $row associative array indexed by column number, - * as returned by PDOStatement::fetch(PDO::FETCH_NUM) - * @param string $class The classname of the object to create - * @param int $col The start column for the hydration (modified) - * - * @return BaseObject - */ - public function getSingleObjectFromRow($row, $class, &$col = 0) - { - $obj = $this->getWorkerObject($col, $class); - $col = $obj->hydrate($row, $col); - - return $obj; - } - - + // DataObject getters & setters + + public function setDbName($dbName) + { + $this->dbName = $dbName; + } + + public function getDbName() + { + return $this->dbName; + } + + public function setClass($class) + { + $this->class = $class; + $this->peer = constant($this->class . '::PEER'); + } + + public function getClass() + { + return $this->class; + } + + public function setPeer($peer) + { + $this->peer = $peer; + } + + public function getPeer() + { + return $this->peer; + } + + public function setWith($withs = array()) + { + $this->with = $withs; + } + + public function getWith() + { + return $this->with; + } + + public function setAsColumns($asColumns = array()) + { + $this->asColumns = $asColumns; + } + + public function getAsColumns() + { + return $this->asColumns; + } + + public function setHasLimit($hasLimit = false) + { + $this->hasLimit = $hasLimit; + } + + public function hasLimit() + { + return $this->hasLimit; + } + + /** + * Formats an ActiveRecord object + * + * @param BaseObject $record the object to format + * + * @return BaseObject The original record + */ + public function formatRecord($record = null) + { + return $record; + } + + abstract public function format(PDOStatement $stmt); + + abstract public function formatOne(PDOStatement $stmt); + + abstract public function isObjectFormatter(); + + public function checkInit() + { + if (null === $this->peer) { + throw new PropelException('You must initialize a formatter object before calling format() or formatOne()'); + } + } + + public function getTableMap() + { + return Propel::getDatabaseMap($this->dbName)->getTableByPhpName($this->class); + } + + protected function isWithOneToMany() + { + foreach ($this->with as $modelWith) { + if ($modelWith->isWithOneToMany()) { + return true; + } + } + + return false; + } + + /** + * Gets the worker object for the class. + * To save memory, we don't create a new object for each row, + * But we keep hydrating a single object per class. + * The column offset in the row is used to index the array of classes + * As there may be more than one object of the same class in the chain + * + * @param int $col Offset of the object in the list of objects to hydrate + * @param string $class Propel model object class + * + * @return BaseObject + */ + protected function getWorkerObject($col, $class) + { + $key = $col . '_' . $class; + + if (isset($this->currentObjects[$key])) { + $this->currentObjects[$key]->clear(); + } else { + $this->currentObjects[$key] = new $class(); + } + + return $this->currentObjects[$key]; + } + + /** + * Gets a Propel object hydrated from a selection of columns in statement row + * + * @param array $row associative array indexed by column number, + * as returned by PDOStatement::fetch(PDO::FETCH_NUM) + * @param string $class The classname of the object to create + * @param int $col The start column for the hydration (modified) + * + * @return BaseObject + */ + public function getSingleObjectFromRow($row, $class, &$col = 0) + { + $obj = $this->getWorkerObject($col, $class); + $col = $obj->hydrate($row, $col); + + return $obj; + } } diff --git a/airtime_mvc/library/propel/runtime/lib/formatter/PropelObjectFormatter.php b/airtime_mvc/library/propel/runtime/lib/formatter/PropelObjectFormatter.php index af6444e12..ba76cae35 100644 --- a/airtime_mvc/library/propel/runtime/lib/formatter/PropelObjectFormatter.php +++ b/airtime_mvc/library/propel/runtime/lib/formatter/PropelObjectFormatter.php @@ -13,100 +13,141 @@ * format() returns a PropelObjectCollection of Propel model objects * * @author Francois Zaninotto - * @version $Revision: 1733 $ + * @version $Revision$ * @package propel.runtime.formatter */ class PropelObjectFormatter extends PropelFormatter { - protected $collectionName = 'PropelObjectCollection'; - - public function format(PDOStatement $stmt) - { - $this->checkInit(); - if($class = $this->collectionName) { - $collection = new $class(); - $collection->setModel($this->class); - $collection->setFormatter($this); - } else { - $collection = array(); - } - if ($this->isWithOneToMany()) { - if ($this->hasLimit) { - throw new PropelException('Cannot use limit() in conjunction with with() on a one-to-many relationship. Please remove the with() call, or the limit() call.'); - } - $pks = array(); - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $object = $this->getAllObjectsFromRow($row); - $pk = $object->getPrimaryKey(); - if (!in_array($pk, $pks)) { - $collection[] = $object; - $pks[] = $pk; - } - } - } else { - // only many-to-one relationships - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $collection[] = $this->getAllObjectsFromRow($row); - } - } - $stmt->closeCursor(); - - return $collection; - } - - public function formatOne(PDOStatement $stmt) - { - $this->checkInit(); - $result = null; - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $result = $this->getAllObjectsFromRow($row); - } - $stmt->closeCursor(); - - return $result; - } - - public function isObjectFormatter() - { - return true; - } + protected $collectionName = 'PropelObjectCollection'; - /** - * Hydrates a series of objects from a result row - * The first object to hydrate is the model of the Criteria - * The following objects (the ones added by way of ModelCriteria::with()) are linked to the first one - * - * @param array $row associative array indexed by column number, - * as returned by PDOStatement::fetch(PDO::FETCH_NUM) - * - * @return BaseObject - */ - public function getAllObjectsFromRow($row) - { - // main object - list($obj, $col) = call_user_func(array($this->peer, 'populateObject'), $row); - // related objects added using with() - foreach ($this->getWith() as $class => $modelWith) { - list($endObject, $col) = call_user_func(array($modelWith->getModelPeerName(), 'populateObject'), $row, $col); - // as we may be in a left join, the endObject may be empty - // in which case it should not be related to the previous object - if (null === $endObject || $endObject->isPrimaryKeyNull()) { - continue; - } - if (isset($hydrationChain)) { - $hydrationChain[$class] = $endObject; - } else { - $hydrationChain = array($class => $endObject); - } - $startObject = $modelWith->isPrimary() ? $obj : $hydrationChain[$modelWith->getRelatedClass()]; - call_user_func(array($startObject, $modelWith->getRelationMethod()), $endObject); - } - // columns added using withColumn() - foreach ($this->getAsColumns() as $alias => $clause) { - $obj->setVirtualColumn($alias, $row[$col]); - $col++; - } - return $obj; - } + private $mainObject; -} \ No newline at end of file + public function format(PDOStatement $stmt) + { + $this->checkInit(); + if ($class = $this->collectionName) { + $collection = new $class(); + $collection->setModel($this->class); + $collection->setFormatter($this); + } else { + $collection = array(); + } + if ($this->isWithOneToMany()) { + if ($this->hasLimit) { + throw new PropelException('Cannot use limit() in conjunction with with() on a one-to-many relationship. Please remove the with() call, or the limit() call.'); + } + $pks = array(); + $objectsByPks = array(); + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $object = $this->getAllObjectsFromRow($row); + $pk = $object->getPrimaryKey(); + + if (false === Propel::isInstancePoolingEnabled()) { + if (isset($objectsByPks[$pk])) { + $this->mainObject = $objectsByPks[$pk]; + $object = $this->getAllObjectsFromRow($row); + } + + $objectsByPks[$pk] = $object; + } + + if (!in_array($pk, $pks)) { + $collection[] = $object; + $pks[] = $pk; + } + } + } else { + // only many-to-one relationships + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $collection[] = $this->getAllObjectsFromRow($row); + } + } + $stmt->closeCursor(); + + return $collection; + } + + public function formatOne(PDOStatement $stmt) + { + $this->checkInit(); + + $result = null; + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + $this->mainObject = $result; + $result = $this->getAllObjectsFromRow($row); + } + + $stmt->closeCursor(); + + return $result; + } + + public function isObjectFormatter() + { + return true; + } + + /** + * Hydrates a series of objects from a result row + * The first object to hydrate is the model of the Criteria + * The following objects (the ones added by way of ModelCriteria::with()) are linked to the first one + * + * @param array $row associative array indexed by column number, + * as returned by PDOStatement::fetch(PDO::FETCH_NUM) + * + * @return BaseObject + */ + public function getAllObjectsFromRow($row) + { + // get the main object + list($obj, $col) = call_user_func(array($this->peer, 'populateObject'), $row); + + if (null !== $this->mainObject) { + $obj = $this->mainObject; + } + + // related objects added using with() + foreach ($this->getWith() as $modelWith) { + list($endObject, $col) = call_user_func(array($modelWith->getModelPeerName(), 'populateObject'), $row, $col); + + if (null !== $modelWith->getLeftPhpName() && !isset($hydrationChain[$modelWith->getLeftPhpName()])) { + continue; + } + + if ($modelWith->isPrimary()) { + $startObject = $obj; + } elseif (isset($hydrationChain)) { + $startObject = $hydrationChain[$modelWith->getLeftPhpName()]; + } else { + continue; + } + // as we may be in a left join, the endObject may be empty + // in which case it should not be related to the previous object + if (null === $endObject || $endObject->isPrimaryKeyNull()) { + if ($modelWith->isAdd()) { + call_user_func(array($startObject, $modelWith->getInitMethod()), false); + } + continue; + } + if (isset($hydrationChain)) { + $hydrationChain[$modelWith->getRightPhpName()] = $endObject; + } else { + $hydrationChain = array($modelWith->getRightPhpName() => $endObject); + } + + call_user_func(array($startObject, $modelWith->getRelationMethod()), $endObject); + + if ($modelWith->isAdd()) { + call_user_func(array($startObject, $modelWith->getResetPartialMethod()), false); + } + } + + // columns added using withColumn() + foreach ($this->getAsColumns() as $alias => $clause) { + $obj->setVirtualColumn($alias, $row[$col]); + $col++; + } + + return $obj; + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/formatter/PropelOnDemandFormatter.php b/airtime_mvc/library/propel/runtime/lib/formatter/PropelOnDemandFormatter.php index f717ccb20..ed2faefc8 100644 --- a/airtime_mvc/library/propel/runtime/lib/formatter/PropelOnDemandFormatter.php +++ b/airtime_mvc/library/propel/runtime/lib/formatter/PropelOnDemandFormatter.php @@ -14,83 +14,93 @@ * This formatter consumes less memory than the PropelObjectFormatter, but doesn't use Instance Pool * * @author Francois Zaninotto - * @version $Revision: 1733 $ + * @version $Revision$ * @package propel.runtime.formatter */ class PropelOnDemandFormatter extends PropelObjectFormatter { - protected $collectionName = 'PropelOnDemandCollection'; - protected $isSingleTableInheritance = false; - - public function init(ModelCriteria $criteria) - { - parent::init($criteria); - $this->isSingleTableInheritance = $criteria->getTableMap()->isSingleTableInheritance(); - - return $this; - } - - public function format(PDOStatement $stmt) - { - $this->checkInit(); - if ($this->isWithOneToMany()) { - throw new PropelException('PropelOnDemandFormatter cannot hydrate related objects using a one-to-many relationship. Try removing with() from your query.'); - } - $class = $this->collectionName; - $collection = new $class(); - $collection->setModel($this->class); - $collection->initIterator($this, $stmt); - - return $collection; - } - - /** - * Hydrates a series of objects from a result row - * The first object to hydrate is the model of the Criteria - * The following objects (the ones added by way of ModelCriteria::with()) are linked to the first one - * - * @param array $row associative array indexed by column number, - * as returned by PDOStatement::fetch(PDO::FETCH_NUM) - * - * @return BaseObject - */ - public function getAllObjectsFromRow($row) - { - $col = 0; - // main object - $class = $this->isSingleTableInheritance ? call_user_func(array($his->peer, 'getOMClass'), $row, $col, false) : $this->class; - $obj = $this->getSingleObjectFromRow($row, $class, $col); - // related objects using 'with' - foreach ($this->getWith() as $modelWith) { - if ($modelWith->isSingleTableInheritance()) { - $class = call_user_func(array($modelWith->getModelPeerName(), 'getOMClass'), $row, $col, false); - $refl = new ReflectionClass($class); - if ($refl->isAbstract()) { - $col += constant($class . 'Peer::NUM_COLUMNS'); - continue; - } - } else { - $class = $modelWith->getModelName(); - } - $endObject = $this->getSingleObjectFromRow($row, $class, $col); - // as we may be in a left join, the endObject may be empty - // in which case it should not be related to the previous object - if (null === $endObject || $endObject->isPrimaryKeyNull()) { - continue; - } - if (isset($hydrationChain)) { - $hydrationChain[$class] = $endObject; - } else { - $hydrationChain = array($class => $endObject); - } - $startObject = $modelWith->isPrimary() ? $obj : $hydrationChain[$modelWith->getRelatedClass()]; - call_user_func(array($startObject, $modelWith->getRelationMethod()), $endObject); - } - foreach ($this->getAsColumns() as $alias => $clause) { - $obj->setVirtualColumn($alias, $row[$col]); - $col++; - } - return $obj; - } - -} \ No newline at end of file + protected $collectionName = 'PropelOnDemandCollection'; + + protected $isSingleTableInheritance = false; + + public function init(ModelCriteria $criteria) + { + parent::init($criteria); + $this->isSingleTableInheritance = $criteria->getTableMap()->isSingleTableInheritance(); + + return $this; + } + + public function format(PDOStatement $stmt) + { + $this->checkInit(); + if ($this->isWithOneToMany()) { + throw new PropelException('PropelOnDemandFormatter cannot hydrate related objects using a one-to-many relationship. Try removing with() from your query.'); + } + $class = $this->collectionName; + $collection = new $class(); + $collection->setModel($this->class); + $collection->initIterator($this, $stmt); + + return $collection; + } + + /** + * Hydrates a series of objects from a result row + * The first object to hydrate is the model of the Criteria + * The following objects (the ones added by way of ModelCriteria::with()) are linked to the first one + * + * @param array $row associative array indexed by column number, + * as returned by PDOStatement::fetch(PDO::FETCH_NUM) + * + * @return BaseObject + */ + public function getAllObjectsFromRow($row) + { + $col = 0; + // main object + $class = $this->isSingleTableInheritance ? call_user_func(array($this->peer, 'getOMClass'), $row, $col) : $this->class; + $obj = $this->getSingleObjectFromRow($row, $class, $col); + // related objects using 'with' + foreach ($this->getWith() as $modelWith) { + if ($modelWith->isSingleTableInheritance()) { + $class = call_user_func(array($modelWith->getModelPeerName(), 'getOMClass'), $row, $col); + $refl = new ReflectionClass($class); + if ($refl->isAbstract()) { + $col += constant($class . 'Peer::NUM_COLUMNS'); + continue; + } + } else { + $class = $modelWith->getModelName(); + } + $endObject = $this->getSingleObjectFromRow($row, $class, $col); + if ($modelWith->isPrimary()) { + $startObject = $obj; + } elseif (isset($hydrationChain)) { + $startObject = $hydrationChain[$modelWith->getLeftPhpName()]; + } else { + continue; + } + // as we may be in a left join, the endObject may be empty + // in which case it should not be related to the previous object + if (null === $endObject || $endObject->isPrimaryKeyNull()) { + if ($modelWith->isAdd()) { + call_user_func(array($startObject, $modelWith->getInitMethod()), false); + } + continue; + } + if (isset($hydrationChain)) { + $hydrationChain[$modelWith->getRightPhpName()] = $endObject; + } else { + $hydrationChain = array($modelWith->getRightPhpName() => $endObject); + } + call_user_func(array($startObject, $modelWith->getRelationMethod()), $endObject); + } + foreach ($this->getAsColumns() as $alias => $clause) { + $obj->setVirtualColumn($alias, $row[$col]); + $col++; + } + + return $obj; + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/formatter/PropelSimpleArrayFormatter.php b/airtime_mvc/library/propel/runtime/lib/formatter/PropelSimpleArrayFormatter.php new file mode 100644 index 000000000..fa422f827 --- /dev/null +++ b/airtime_mvc/library/propel/runtime/lib/formatter/PropelSimpleArrayFormatter.php @@ -0,0 +1,80 @@ +checkInit(); + if ($class = $this->collectionName) { + $collection = new $class(); + $collection->setModel($this->class); + $collection->setFormatter($this); + } else { + $collection = array(); + } + if ($this->isWithOneToMany() && $this->hasLimit) { + throw new PropelException('Cannot use limit() in conjunction with with() on a one-to-many relationship. Please remove the with() call, or the limit() call.'); + } + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + if (false !== $rowArray = $this->getStructuredArrayFromRow($row)) { + $collection[] = $rowArray; + } + } + $stmt->closeCursor(); + + return $collection; + } + + public function formatOne(PDOStatement $stmt) + { + $this->checkInit(); + $result = null; + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { + if (false !== $rowArray = $this->getStructuredArrayFromRow($row)) { + $result = $rowArray; + } + } + $stmt->closeCursor(); + + return $result; + } + + public function isObjectFormatter() + { + return false; + } + + public function getStructuredArrayFromRow($row) + { + $columnNames = array_keys($this->getAsColumns()); + if (count($columnNames) > 1 && count($row) > 1) { + $finalRow = array(); + foreach ($row as $index => $value) { + $finalRow[str_replace('"', '', $columnNames[$index])] = $value; + } + } else { + $finalRow = $row[0]; + } + + return $finalRow; + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/formatter/PropelStatementFormatter.php b/airtime_mvc/library/propel/runtime/lib/formatter/PropelStatementFormatter.php index 5103c8234..9566b4518 100644 --- a/airtime_mvc/library/propel/runtime/lib/formatter/PropelStatementFormatter.php +++ b/airtime_mvc/library/propel/runtime/lib/formatter/PropelStatementFormatter.php @@ -13,33 +13,32 @@ * format() returns a PDO statement * * @author Francois Zaninotto - * @version $Revision: 1796 $ + * @version $Revision$ * @package propel.runtime.formatter */ class PropelStatementFormatter extends PropelFormatter { - public function format(PDOStatement $stmt) - { - return $stmt; - } - - public function formatOne(PDOStatement $stmt) - { - if ($stmt->rowCount() == 0) { - return null; - } else { - return $stmt; - } - } - - public function formatRecord($record = null) - { - throw new PropelException('The Statement formatter cannot transform a record into a statement'); - } + public function format(PDOStatement $stmt) + { + return $stmt; + } - public function isObjectFormatter() - { - return false; - } + public function formatOne(PDOStatement $stmt) + { + if ($stmt->rowCount() == 0) { + return null; + } else { + return $stmt; + } + } -} \ No newline at end of file + public function formatRecord($record = null) + { + throw new PropelException('The Statement formatter cannot transform a record into a statement'); + } + + public function isObjectFormatter() + { + return false; + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/logger/BasicLogger.php b/airtime_mvc/library/propel/runtime/lib/logger/BasicLogger.php index ce335d2ee..121280c68 100644 --- a/airtime_mvc/library/propel/runtime/lib/logger/BasicLogger.php +++ b/airtime_mvc/library/propel/runtime/lib/logger/BasicLogger.php @@ -18,74 +18,67 @@ * and Jon Parise . * * @author Hans Lellelid - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.logger */ interface BasicLogger { - /** - * A convenience function for logging an alert event. - * - * @param mixed $message String or Exception object containing the message - * to log. - */ - public function alert($message); + /** + * A convenience function for logging an alert event. + * + * @param mixed $message String or Exception object containing the message to log. + */ + public function alert($message); - /** - * A convenience function for logging a critical event. - * - * @param mixed $message String or Exception object containing the message - * to log. - */ - public function crit($message); + /** + * A convenience function for logging a critical event. + * + * @param mixed $message String or Exception object containing the message to log. + */ + public function crit($message); - /** - * A convenience function for logging an error event. - * - * @param mixed $message String or Exception object containing the message - * to log. - */ - public function err($message); + /** + * A convenience function for logging an error event. + * + * @param mixed $message String or Exception object containing the message to log. + */ + public function err($message); - /** - * A convenience function for logging a warning event. - * - * @param mixed $message String or Exception object containing the message - * to log. - */ - public function warning($message); - /** - * A convenience function for logging an critical event. - * - * @param mixed $message String or Exception object containing the message - * to log. - */ - public function notice($message); - /** - * A convenience function for logging an critical event. - * - * @param mixed $message String or Exception object containing the message - * to log. - */ - public function info($message); + /** + * A convenience function for logging a warning event. + * + * @param mixed $message String or Exception object containing the message to log. + */ + public function warning($message); - /** - * A convenience function for logging a debug event. - * - * @param mixed $message String or Exception object containing the message - * to log. - */ - public function debug($message); + /** + * A convenience function for logging an critical event. + * + * @param mixed $message String or Exception object containing the message to log. + */ + public function notice($message); - /** - * Primary method to handle logging. - * - * @param mixed $message String or Exception object containing the message - * to log. - * @param int $severity The numeric severity. Defaults to null so that no - * assumptions are made about the logging backend. - */ - public function log($message, $severity = null); + /** + * A convenience function for logging an critical event. + * + * @param mixed $message String or Exception object containing the message to log. + */ + public function info($message); + /** + * A convenience function for logging a debug event. + * + * @param mixed $message String or Exception object containing the message to log. + */ + public function debug($message); + + /** + * Primary method to handle logging. + * + * @param mixed $message String or Exception object containing the message to log. + * @param int $severity The numeric severity. Defaults to null so that no + * assumptions are made about the logging backend. + */ + public function log($message, $severity = null); } diff --git a/airtime_mvc/library/propel/runtime/lib/logger/MojaviLogAdapter.php b/airtime_mvc/library/propel/runtime/lib/logger/MojaviLogAdapter.php index af8e48423..766d1614d 100644 --- a/airtime_mvc/library/propel/runtime/lib/logger/MojaviLogAdapter.php +++ b/airtime_mvc/library/propel/runtime/lib/logger/MojaviLogAdapter.php @@ -12,149 +12,140 @@ * Mojavi logging adapter for propel * * @author Brandon Keepers - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.logger */ class MojaviLogAdapter implements BasicLogger { + /** + * Instance of mojavi logger + */ + private $logger = null; - /** - * Instance of mojavi logger - */ - private $logger = null; + /** + * constructor for setting up Mojavi log adapter + * + * @param ErrorLog $logger Instance of Mojavi error log obtained by + * calling LogManager::getLogger(); + */ + public function __construct($logger = null) + { + $this->logger = $logger; + } - /** - * constructor for setting up Mojavi log adapter - * - * @param ErrorLog $logger instance of Mojavi error log obtained by - * calling LogManager::getLogger(); - */ - public function __construct($logger = null) - { - $this->logger = $logger; - } + /** + * A convenience function for logging an alert event. + * + * @param mixed $message String or Exception object containing the message to log. + */ + public function alert($message) + { + $this->log($message, 'alert'); + } - /** - * A convenience function for logging an alert event. - * - * @param mixed $message String or Exception object containing the message - * to log. - */ - public function alert($message) - { - $this->log($message, 'alert'); - } + /** + * A convenience function for logging a critical event. + * + * @param mixed $message String or Exception object containing the message to log. + */ + public function crit($message) + { + $this->log($message, 'crit'); + } - /** - * A convenience function for logging a critical event. - * - * @param mixed $message String or Exception object containing the message - * to log. - */ - public function crit($message) - { - $this->log($message, 'crit'); - } + /** + * A convenience function for logging an error event. + * + * @param mixed $message String or Exception object containing the message to log. + */ + public function err($message) + { + $this->log($message, 'err'); + } - /** - * A convenience function for logging an error event. - * - * @param mixed $message String or Exception object containing the message - * to log. - */ - public function err($message) - { - $this->log($message, 'err'); - } + /** + * A convenience function for logging a warning event. + * + * @param mixed $message String or Exception object containing the message to log. + */ + public function warning($message) + { + $this->log($message, 'warning'); + } - /** - * A convenience function for logging a warning event. - * - * @param mixed $message String or Exception object containing the message - * to log. - */ - public function warning($message) - { - $this->log($message, 'warning'); - } + /** + * A convenience function for logging an critical event. + * + * @param mixed $message String or Exception object containing the message to log. + */ + public function notice($message) + { + $this->log($message, 'notice'); + } + /** + * A convenience function for logging an critical event. + * + * @param mixed $message String or Exception object containing the message to log. + */ + public function info($message) + { + $this->log($message, 'info'); + } - /** - * A convenience function for logging an critical event. - * - * @param mixed $message String or Exception object containing the message - * to log. - */ - public function notice($message) - { - $this->log($message, 'notice'); - } - /** - * A convenience function for logging an critical event. - * - * @param mixed $message String or Exception object containing the message - * to log. - */ - public function info($message) - { - $this->log($message, 'info'); - } + /** + * A convenience function for logging a debug event. + * + * @param mixed $message String or Exception object containing the message to log. + */ + public function debug($message) + { + $this->log($message, 'debug'); + } - /** - * A convenience function for logging a debug event. - * - * @param mixed $message String or Exception object containing the message - * to log. - */ - public function debug($message) - { - $this->log($message, 'debug'); - } + /** + * Primary method to handle logging. + * + * @param mixed $message String or Exception object containing the message to log. + * @param integer $severity The numeric severity. Defaults to null so that no + * assumptions are made about the logging backend. + */ + public function log($message, $severity = null) + { + if (is_null($this->logger)) { + $this->logger = LogManager::getLogger('propel'); + } - /** - * Primary method to handle logging. - * - * @param mixed $message String or Exception object containing the message - * to log. - * @param int $severity The numeric severity. Defaults to null so that no - * assumptions are made about the logging backend. - */ - public function log($message, $severity = null) - { - if (is_null($this->logger)) - $this->logger = LogManager::getLogger('propel'); + switch ($severity) { + case 'crit': + $method = 'fatal'; + break; + case 'err': + $method = 'error'; + break; + case 'alert': + case 'warning': + $method = 'warning'; + break; + case 'notice': + case 'info': + $method = 'info'; + break; + case 'debug': + default: + $method = 'debug'; + } - switch($severity) - { - case 'crit': - $method = 'fatal'; - break; - case 'err': - $method = 'error'; - break; - case 'alert': - case 'warning': - $method = 'warning'; - break; - case 'notice': - case 'info': - $method = 'info'; - break; - case 'debug': - default: - $method = 'debug'; - } + // get a backtrace to pass class, function, file, & line to Mojavi logger + $trace = debug_backtrace(); - // get a backtrace to pass class, function, file, & line to Mojavi logger - $trace = debug_backtrace(); - - // call the appropriate Mojavi logger method - $this->logger->{$method} ( - $message, - $trace[2]['class'], - $trace[2]['function'], - $trace[1]['file'], - $trace[1]['line'] - ); - } + // call the appropriate Mojavi logger method + $this->logger->{$method} ( + $message, + $trace[2]['class'], + $trace[2]['function'], + $trace[1]['file'], + $trace[1]['line'] + ); + } } diff --git a/airtime_mvc/library/propel/runtime/lib/map/ColumnMap.php b/airtime_mvc/library/propel/runtime/lib/map/ColumnMap.php index 69868ced5..c6f5affcf 100644 --- a/airtime_mvc/library/propel/runtime/lib/map/ColumnMap.php +++ b/airtime_mvc/library/propel/runtime/lib/map/ColumnMap.php @@ -20,445 +20,529 @@ * * @author Hans Lellelid (Propel) * @author John D. McNally (Torque) - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.map */ class ColumnMap { - // Propel type of the column - protected $type; + // Propel type of the column + protected $type; - // Size of the column - protected $size = 0; + // Size of the column + protected $size = 0; - // Is it a primary key? - protected $pk = false; + // Is it a primary key? + protected $pk = false; - // Is null value allowed? - protected $notNull = false; + // Is null value allowed? + protected $notNull = false; - // The default value for this column - protected $defaultValue; + // The default value for this column + protected $defaultValue; - // Name of the table that this column is related to - protected $relatedTableName = ""; + // Name of the table that this column is related to + protected $relatedTableName = ""; - // Name of the column that this column is related to - protected $relatedColumnName = ""; + // Name of the column that this column is related to + protected $relatedColumnName = ""; - // The TableMap for this column - protected $table; + // The TableMap for this column + protected $table; - // The name of the column - protected $columnName; + // The name of the column + protected $columnName; - // The php name of the column - protected $phpName; + // The php name of the column + protected $phpName; - // The validators for this column - protected $validators = array(); + // The validators for this column + protected $validators = array(); - /** - * Constructor. - * - * @param string $name The name of the column. - * @param TableMap containingTable TableMap of the table this column is in. - */ - public function __construct($name, TableMap $containingTable) - { - $this->columnName = $name; - $this->table = $containingTable; - } + // The allowed values for an ENUM column + protected $valueSet = array(); - /** - * Get the name of a column. - * - * @return string A String with the column name. - */ - public function getName() - { - return $this->columnName; - } + // Is this a primaryString column? + protected $isPkString = false; - /** - * Get the table map this column belongs to. - * @return TableMap - */ - public function getTable() - { - return $this->table; - } - - /** - * Get the name of the table this column is in. - * - * @return string A String with the table name. - */ - public function getTableName() - { - return $this->table->getName(); - } - - /** - * Get the table name + column name. - * - * @return string A String with the full column name. - */ - public function getFullyQualifiedName() - { - return $this->getTableName() . "." . $this->columnName; - } - - /** - * Set the php anme of this column. - * - * @param string $phpName A string representing the PHP name. - * @return void - */ - public function setPhpName($phpName) - { - $this->phpName = $phpName; - } - - /** - * Get the name of a column. - * - * @return string A String with the column name. - */ - public function getPhpName() - { - return $this->phpName; - } - - /** - * Set the Propel type of this column. - * - * @param string $type A string representing the Propel type (e.g. PropelColumnTypes::DATE). - * @return void - */ - public function setType($type) - { - $this->type = $type; - } - - /** - * Get the Propel type of this column. - * - * @return string A string representing the Propel type (e.g. PropelColumnTypes::DATE). - */ - public function getType() - { - return $this->type; - } - - /** - * Get the PDO type of this column. - * - * @return int The PDO::PARMA_* value - */ - public function getPdoType() - { - return PropelColumnTypes::getPdoType($this->type); - } - - /** - * Whether this is a BLOB, LONGVARBINARY, or VARBINARY. - * @return boolean - */ - public function isLob() - { - return ($this->type == PropelColumnTypes::BLOB || $this->type == PropelColumnTypes::VARBINARY || $this->type == PropelColumnTypes::LONGVARBINARY); - } - - /** - * Whether this is a DATE/TIME/TIMESTAMP column. - * - * @return boolean - * @since 1.3 - */ - public function isTemporal() - { - return ($this->type == PropelColumnTypes::TIMESTAMP || $this->type == PropelColumnTypes::DATE || $this->type == PropelColumnTypes::TIME || $this->type == PropelColumnTypes::BU_DATE || $this->type == PropelColumnTypes::BU_TIMESTAMP); - } - - /** - * Whether this is a DATE/TIME/TIMESTAMP column that is post-epoch (1970). - * - * PHP cannot handle pre-epoch timestamps well -- hence the need to differentiate - * between epoch and pre-epoch timestamps. - * - * @return boolean - * @deprecated Propel supports non-epoch dates - */ - public function isEpochTemporal() - { - return ($this->type == PropelColumnTypes::TIMESTAMP || $this->type == PropelColumnTypes::DATE || $this->type == PropelColumnTypes::TIME); - } - - /** - * Whether this column is numeric (int, decimal, bigint etc). - * @return boolean - */ - public function isNumeric() - { - return ($this->type == PropelColumnTypes::NUMERIC || $this->type == PropelColumnTypes::DECIMAL || $this->type == PropelColumnTypes::TINYINT || $this->type == PropelColumnTypes::SMALLINT || $this->type == PropelColumnTypes::INTEGER || $this->type == PropelColumnTypes::BIGINT || $this->type == PropelColumnTypes::REAL || $this->type == PropelColumnTypes::FLOAT || $this->type == PropelColumnTypes::DOUBLE); - } - - /** - * Whether this column is a text column (varchar, char, longvarchar). - * @return boolean - */ - public function isText() - { - return ($this->type == PropelColumnTypes::VARCHAR || $this->type == PropelColumnTypes::LONGVARCHAR || $this->type == PropelColumnTypes::CHAR); - } - - /** - * Set the size of this column. - * - * @param int $size An int specifying the size. - * @return void - */ - public function setSize($size) - { - $this->size = $size; - } - - /** - * Get the size of this column. - * - * @return int An int specifying the size. - */ - public function getSize() - { - return $this->size; - } - - /** - * Set if this column is a primary key or not. - * - * @param boolean $pk True if column is a primary key. - * @return void - */ - public function setPrimaryKey($pk) - { - $this->pk = $pk; - } - - /** - * Is this column a primary key? - * - * @return boolean True if column is a primary key. - */ - public function isPrimaryKey() - { - return $this->pk; - } - - /** - * Set if this column may be null. - * - * @param boolean nn True if column may be null. - * @return void - */ - public function setNotNull($nn) - { - $this->notNull = $nn; - } - - /** - * Is null value allowed ? - * - * @return boolean True if column may not be null. - */ - public function isNotNull() - { - return ($this->notNull || $this->isPrimaryKey()); - } - - /** - * Sets the default value for this column. - * @param mixed $defaultValue the default value for the column - * @return void - */ - public function setDefaultValue($defaultValue) - { - $this->defaultValue = $defaultValue; - } - - /** - * Gets the default value for this column. - * @return mixed String or NULL - */ - public function getDefaultValue() - { - return $this->defaultValue; - } - - /** - * Set the foreign key for this column. - * - * @param string tableName The name of the table that is foreign. - * @param string columnName The name of the column that is foreign. - * @return void - */ - public function setForeignKey($tableName, $columnName) - { - if ($tableName && $columnName) { - $this->relatedTableName = $tableName; - $this->relatedColumnName = $columnName; - } else { - $this->relatedTableName = ""; - $this->relatedColumnName = ""; - } - } - - /** - * Is this column a foreign key? - * - * @return boolean True if column is a foreign key. - */ - public function isForeignKey() - { - if ($this->relatedTableName) { - return true; - } else { - return false; - } - } - - /** - * Get the RelationMap object for this foreign key - */ - public function getRelation() - { - if(!$this->relatedTableName) return null; - foreach ($this->getTable()->getRelations() as $name => $relation) + /** + * Constructor. + * + * @param string $name The name of the column. + * @param TableMap containingTable TableMap of the table this column is in. + */ + public function __construct($name, TableMap $containingTable) { - if($relation->getType() == RelationMap::MANY_TO_ONE) - { - if ($relation->getForeignTable()->getName() == $this->getRelatedTableName() - && array_key_exists($this->getFullyQualifiedName(), $relation->getColumnMappings())) - { - return $relation; + $this->columnName = $name; + $this->table = $containingTable; + } + + /** + * Get the name of a column. + * + * @return string A String with the column name. + */ + public function getName() + { + return $this->columnName; + } + + /** + * Get the table map this column belongs to. + * + * @return TableMap + */ + public function getTable() + { + return $this->table; + } + + /** + * Get the name of the table this column is in. + * + * @return string A String with the table name. + */ + public function getTableName() + { + return $this->table->getName(); + } + + /** + * Get the table name + column name. + * + * @return string A String with the full column name. + */ + public function getFullyQualifiedName() + { + return $this->getTableName() . "." . $this->columnName; + } + + /** + * Set the php name of this column. + * + * @param string $phpName A string representing the PHP name. + * + * @return void + */ + public function setPhpName($phpName) + { + $this->phpName = $phpName; + } + + /** + * Get the name of a column. + * + * @return string A String with the column name. + */ + public function getPhpName() + { + return $this->phpName; + } + + /** + * Set the Propel type of this column. + * + * @param string $type A string representing the Propel type (e.g. PropelColumnTypes::DATE). + * + * @return void + */ + public function setType($type) + { + $this->type = $type; + } + + /** + * Get the Propel type of this column. + * + * @return string A string representing the Propel type (e.g. PropelColumnTypes::DATE). + */ + public function getType() + { + return $this->type; + } + + /** + * Get the PDO type of this column. + * + * @return int The PDO::PARMA_* value + */ + public function getPdoType() + { + return PropelColumnTypes::getPdoType($this->type); + } + + /** + * Whether this is a BLOB, LONGVARBINARY, or VARBINARY. + * + * @return boolean + */ + public function isLob() + { + return ($this->type == PropelColumnTypes::BLOB || $this->type == PropelColumnTypes::VARBINARY || $this->type == PropelColumnTypes::LONGVARBINARY); + } + + /** + * Whether this is a DATE/TIME/TIMESTAMP column. + * + * @return boolean + * @since 1.3 + */ + public function isTemporal() + { + return ($this->type == PropelColumnTypes::TIMESTAMP || $this->type == PropelColumnTypes::DATE || $this->type == PropelColumnTypes::TIME || $this->type == PropelColumnTypes::BU_DATE || $this->type == PropelColumnTypes::BU_TIMESTAMP); + } + + /** + * Whether this is a DATE/TIME/TIMESTAMP column that is post-epoch (1970). + * + * PHP cannot handle pre-epoch timestamps well -- hence the need to differentiate + * between epoch and pre-epoch timestamps. + * + * @return boolean + * @deprecated Propel supports non-epoch dates + */ + public function isEpochTemporal() + { + return ($this->type == PropelColumnTypes::TIMESTAMP || $this->type == PropelColumnTypes::DATE || $this->type == PropelColumnTypes::TIME); + } + + /** + * Whether this column is numeric (int, decimal, bigint etc). + * + * @return boolean + */ + public function isNumeric() + { + return ($this->type == PropelColumnTypes::NUMERIC || $this->type == PropelColumnTypes::DECIMAL || $this->type == PropelColumnTypes::TINYINT || $this->type == PropelColumnTypes::SMALLINT || $this->type == PropelColumnTypes::INTEGER || $this->type == PropelColumnTypes::BIGINT || $this->type == PropelColumnTypes::REAL || $this->type == PropelColumnTypes::FLOAT || $this->type == PropelColumnTypes::DOUBLE); + } + + /** + * Whether this column is an integer + * + * @return boolean + */ + public function isInteger() + { + return $this->getPdoType() === PDO::PARAM_INT; + } + + /** + * Whether this column is a text column (varchar, char, longvarchar). + * + * @return boolean + */ + public function isText() + { + return ($this->type == PropelColumnTypes::VARCHAR || $this->type == PropelColumnTypes::LONGVARCHAR || $this->type == PropelColumnTypes::CHAR); + } + + /** + * Set the size of this column. + * + * @param int $size An int specifying the size. + * + * @return void + */ + public function setSize($size) + { + $this->size = $size; + } + + /** + * Get the size of this column. + * + * @return int An int specifying the size. + */ + public function getSize() + { + return $this->size; + } + + /** + * Set if this column is a primary key or not. + * + * @param boolean $pk True if column is a primary key. + * + * @return void + */ + public function setPrimaryKey($pk) + { + $this->pk = $pk; + } + + /** + * Is this column a primary key? + * + * @return boolean True if column is a primary key. + */ + public function isPrimaryKey() + { + return $this->pk; + } + + /** + * Set if this column may be null. + * + * @param boolean nn True if column may be null. + * + * @return void + */ + public function setNotNull($nn) + { + $this->notNull = $nn; + } + + /** + * Is null value allowed ? + * + * @return boolean True if column may not be null. + */ + public function isNotNull() + { + return ($this->notNull || $this->isPrimaryKey()); + } + + /** + * Sets the default value for this column. + * + * @param mixed $defaultValue the default value for the column + * + * @return void + */ + public function setDefaultValue($defaultValue) + { + $this->defaultValue = $defaultValue; + } + + /** + * Gets the default value for this column. + * + * @return mixed String or NULL + */ + public function getDefaultValue() + { + return $this->defaultValue; + } + + /** + * Set the foreign key for this column. + * + * @param string tableName The name of the table that is foreign. + * @param string columnName The name of the column that is foreign. + * + * @return void + */ + public function setForeignKey($tableName, $columnName) + { + if ($tableName && $columnName) { + $this->relatedTableName = $tableName; + $this->relatedColumnName = $columnName; + } else { + $this->relatedTableName = ""; + $this->relatedColumnName = ""; } - } } - } - - /** - * Get the table.column that this column is related to. - * - * @return string A String with the full name for the related column. - */ - public function getRelatedName() - { - return $this->relatedTableName . "." . $this->relatedColumnName; - } - /** - * Get the table name that this column is related to. - * - * @return string A String with the name for the related table. - */ - public function getRelatedTableName() - { - return $this->relatedTableName; - } - - /** - * Get the column name that this column is related to. - * - * @return string A String with the name for the related column. - */ - public function getRelatedColumnName() - { - return $this->relatedColumnName; - } - - /** - * Get the TableMap object that this column is related to. - * - * @return TableMap The related TableMap object - * @throws PropelException when called on a column with no foreign key - */ - public function getRelatedTable() - { - if ($this->relatedTableName) { - return $this->table->getDatabaseMap()->getTable($this->relatedTableName); - } else { - throw new PropelException("Cannot fetch RelatedTable for column with no foreign key: " . $this->columnName); + /** + * Is this column a foreign key? + * + * @return boolean True if column is a foreign key. + */ + public function isForeignKey() + { + if ($this->relatedTableName) { + return true; + } else { + return false; + } } - } - - /** - * Get the TableMap object that this column is related to. - * - * @return ColumnMap The related ColumnMap object - * @throws PropelException when called on a column with no foreign key - */ - public function getRelatedColumn() - { - return $this->getRelatedTable()->getColumn($this->relatedColumnName); - } - public function addValidator($validator) - { - $this->validators[] = $validator; - } - - public function hasValidators() - { - return count($this->validators) > 0; - } - - public function getValidators() - { - return $this->validators; - } - - /** - * Performs DB-specific ignore case, but only if the column type necessitates it. - * @param string $str The expression we want to apply the ignore case formatting to (e.g. the column name). - * @param DBAdapter $db - */ - public function ignoreCase($str, DBAdapter $db) - { - if ($this->isText()) { - return $db->ignoreCase($str); - } else { - return $str; + /** + * Get the RelationMap object for this foreign key + * + * @return RelationMap|null + */ + public function getRelation() + { + if (!$this->relatedTableName) { + return null; + } + foreach ($this->getTable()->getRelations() as $name => $relation) { + if ($relation->getType() == RelationMap::MANY_TO_ONE) { + if ($relation->getForeignTable()->getName() == $this->getRelatedTableName() && array_key_exists($this->getFullyQualifiedName(), $relation->getColumnMappings())) { + return $relation; + } + } + } } - } - - /** - * Normalizes the column name, removing table prefix and uppercasing. - * - * article.first_name becomes FIRST_NAME - * - * @param string $name - * @return string Normalized column name. - */ - public static function normalizeName($name) - { - if (false !== ($pos = strpos($name, '.'))) { - $name = substr($name, $pos + 1); + + /** + * Get the table.column that this column is related to. + * + * @return string A String with the full name for the related column. + */ + public function getRelatedName() + { + return $this->relatedTableName . "." . $this->relatedColumnName; + } + + /** + * Get the table name that this column is related to. + * + * @return string A String with the name for the related table. + */ + public function getRelatedTableName() + { + return $this->relatedTableName; + } + + /** + * Get the column name that this column is related to. + * + * @return string A String with the name for the related column. + */ + public function getRelatedColumnName() + { + return $this->relatedColumnName; + } + + /** + * Get the TableMap object that this column is related to. + * + * @return TableMap The related TableMap object + * @throws PropelException when called on a column with no foreign key + */ + public function getRelatedTable() + { + if ($this->relatedTableName) { + return $this->table->getDatabaseMap()->getTable($this->relatedTableName); + } else { + throw new PropelException("Cannot fetch RelatedTable for column with no foreign key: " . $this->columnName); + } + } + + /** + * Get the TableMap object that this column is related to. + * + * @return ColumnMap The related ColumnMap object + * @throws PropelException when called on a column with no foreign key + */ + public function getRelatedColumn() + { + return $this->getRelatedTable()->getColumn($this->relatedColumnName); + } + + public function addValidator($validator) + { + $this->validators[] = $validator; + } + + public function hasValidators() + { + return count($this->validators) > 0; + } + + public function getValidators() + { + return $this->validators; + } + + /** + * Set the valueSet of this column (only valid for ENUM columns). + * + * @param array $values A list of allowed values + */ + public function setValueSet($values) + { + $this->valueSet = $values; + } + + /** + * Get the valueSet of this column (only valid for ENUM columns). + * + * @return array A list of allowed values + */ + public function getValueSet() + { + return $this->valueSet; + } + + public function isInValueSet($value) + { + return in_array($value, $this->valueSet); + } + + public function getValueSetKey($value) + { + return array_search($value, $this->valueSet); + } + + /** + * Performs DB-specific ignore case, but only if the column type necessitates it. + * + * @param string $str The expression we want to apply the ignore case formatting to (e.g. the column name). + * @param DBAdapter $db + * + * @return string + */ + public function ignoreCase($str, DBAdapter $db) + { + if ($this->isText()) { + return $db->ignoreCase($str); + } else { + return $str; + } + } + + /** + * Normalizes the column name, removing table prefix and uppercasing. + * + * article.first_name becomes first_name + * + * @param string $name + * + * @return string Normalized column name. + */ + public static function normalizeName($name) + { + if (false !== ($pos = strrpos($name, '.'))) { + $name = substr($name, $pos + 1); + } + + return $name; + } + + /** + * Set this column to be a primaryString column. + * + * @param boolean $pkString + */ + public function setPrimaryString($pkString) + { + $this->isPkString = (bool) $pkString; + } + + /** + * Is this column a primaryString column? + * + * @return boolean True, if this column is the primaryString column. + */ + public function isPrimaryString() + { + return $this->isPkString; + } + + // deprecated methods + + /** + * Gets column name + * + * @deprecated Use getName() instead + * @return string + * @deprecated Use getName() instead. + */ + public function getColumnName() + { + return $this->getName(); } - $name = strtoupper($name); - return $name; - } - - // deprecated methods - - /** - * Gets column name - * @deprecated Use getName() instead - * @return string - * @deprecated Use getName() instead. - */ - public function getColumnName() - { - return $this->getName(); - } } diff --git a/airtime_mvc/library/propel/runtime/lib/map/DatabaseMap.php b/airtime_mvc/library/propel/runtime/lib/map/DatabaseMap.php index e4e29e444..6c2880b8f 100644 --- a/airtime_mvc/library/propel/runtime/lib/map/DatabaseMap.php +++ b/airtime_mvc/library/propel/runtime/lib/map/DatabaseMap.php @@ -21,171 +21,180 @@ * @author Hans Lellelid (Propel) * @author John D. McNally (Torque) * @author Daniel Rall (Torque) - * @version $Revision: 1802 $ + * @version $Revision$ * @package propel.runtime.map */ class DatabaseMap { + /** @var string Name of the database. */ + protected $name; - /** @var string Name of the database. */ - protected $name; + /** @var array TableMap[] Tables in the database, using table name as key */ + protected $tables = array(); - /** @var array TableMap[] Tables in the database, using table name as key */ - protected $tables = array(); - - /** @var array TableMap[] Tables in the database, using table phpName as key */ - protected $tablesByPhpName = array(); + /** @var array TableMap[] Tables in the database, using table phpName as key */ + protected $tablesByPhpName = array(); - /** - * Constructor. - * - * @param string $name Name of the database. - */ - public function __construct($name) - { - $this->name = $name; - } - - /** - * Get the name of this database. - * - * @return string The name of the database. - */ - public function getName() - { - return $this->name; - } - - /** - * Add a new table to the database by name. - * - * @param string $tableName The name of the table. - * @return TableMap The newly created TableMap. - */ - public function addTable($tableName) - { - $this->tables[$tableName] = new TableMap($tableName, $this); - return $this->tables[$tableName]; - } - - /** - * Add a new table object to the database. - * - * @param TableMap $table The table to add - */ - public function addTableObject(TableMap $table) - { - $table->setDatabaseMap($this); - $this->tables[$table->getName()] = $table; - $this->tablesByPhpName[$table->getClassname()] = $table; - } - - /** - * Add a new table to the database, using the tablemap class name. - * - * @param string $tableMapClass The name of the table map to add - * @return TableMap The TableMap object - */ - public function addTableFromMapClass($tableMapClass) - { - $table = new $tableMapClass(); - if(!$this->hasTable($table->getName())) { - $this->addTableObject($table); - return $table; - } else { - return $this->getTable($table->getName()); + /** + * Constructor. + * + * @param string $name Name of the database. + */ + public function __construct($name) + { + $this->name = $name; } - } - - /** - * Does this database contain this specific table? - * - * @param string $name The String representation of the table. - * @return boolean True if the database contains the table. - */ - public function hasTable($name) - { - if ( strpos($name, '.') > 0) { - $name = substr($name, 0, strpos($name, '.')); - } - return array_key_exists($name, $this->tables); - } - /** - * Get a TableMap for the table by name. - * - * @param string $name Name of the table. - * @return TableMap A TableMap - * @throws PropelException if the table is undefined - */ - public function getTable($name) - { - if (!isset($this->tables[$name])) { - throw new PropelException("Cannot fetch TableMap for undefined table: " . $name ); + /** + * Get the name of this database. + * + * @return string The name of the database. + */ + public function getName() + { + return $this->name; } - return $this->tables[$name]; - } - /** - * Get a TableMap[] of all of the tables in the database. - * - * @return array A TableMap[]. - */ - public function getTables() - { - return $this->tables; - } + /** + * Add a new table to the database by name. + * + * @param string $tableName The name of the table. + * + * @return TableMap The newly created TableMap. + */ + public function addTable($tableName) + { + $this->tables[$tableName] = new TableMap($tableName, $this); - /** - * Get a ColumnMap for the column by name. - * Name must be fully qualified, e.g. book.AUTHOR_ID - * - * @param $qualifiedColumnName Name of the column. - * @return ColumnMap A TableMap - * @throws PropelException if the table is undefined, or if the table is undefined - */ - public function getColumn($qualifiedColumnName) - { - list($tableName, $columnName) = explode('.', $qualifiedColumnName); - return $this->getTable($tableName)->getColumn($columnName, false); - } - - // deprecated methods - - /** - * Does this database contain this specific table? - * - * @deprecated Use hasTable() instead - * @param string $name The String representation of the table. - * @return boolean True if the database contains the table. - */ - public function containsTable($name) - { - return $this->hasTable($name); - } - - public function getTableByPhpName($phpName) - { - if (array_key_exists($phpName, $this->tablesByPhpName)) { - return $this->tablesByPhpName[$phpName]; - } else if (class_exists($tmClass = $phpName . 'TableMap')) { - $this->addTableFromMapClass($tmClass); - return $this->tablesByPhpName[$phpName]; - } else if (class_exists($tmClass = substr_replace($phpName, '\\map\\', strrpos($phpName, '\\'), 1) . 'TableMap')) { - $this->addTableFromMapClass($tmClass); - return $this->tablesByPhpName[$phpName]; - } else { - throw new PropelException("Cannot fetch TableMap for undefined table phpName: " . $phpName); + return $this->tables[$tableName]; + } + + /** + * Add a new table object to the database. + * + * @param TableMap $table The table to add + */ + public function addTableObject(TableMap $table) + { + $table->setDatabaseMap($this); + $this->tables[$table->getName()] = $table; + $this->tablesByPhpName[$table->getClassname()] = $table; + } + + /** + * Add a new table to the database, using the tablemap class name. + * + * @param string $tableMapClass The name of the table map to add + * + * @return TableMap The TableMap object + */ + public function addTableFromMapClass($tableMapClass) + { + $table = new $tableMapClass(); + if (!$this->hasTable($table->getName())) { + $this->addTableObject($table); + + return $table; + } else { + return $this->getTable($table->getName()); + } + } + + /** + * Does this database contain this specific table? + * + * @param string $name The String representation of the table. + * + * @return boolean True if the database contains the table. + */ + public function hasTable($name) + { + return array_key_exists($name, $this->tables); + } + + /** + * Get a TableMap for the table by name. + * + * @param string $name Name of the table. + * + * @return TableMap A TableMap + * @throws PropelException if the table is undefined + */ + public function getTable($name) + { + if (!isset($this->tables[$name])) { + throw new PropelException("Cannot fetch TableMap for undefined table: " . $name); + } + + return $this->tables[$name]; + } + + /** + * Get a TableMap[] of all of the tables in the database. + * + * @return array A TableMap[]. + */ + public function getTables() + { + return $this->tables; + } + + /** + * Get a ColumnMap for the column by name. + * Name must be fully qualified, e.g. book.AUTHOR_ID + * + * @param $qualifiedColumnName Name of the column. + * + * @return ColumnMap A TableMap + * @throws PropelException if the table is undefined, or if the table is undefined + */ + public function getColumn($qualifiedColumnName) + { + list($tableName, $columnName) = explode('.', $qualifiedColumnName); + + return $this->getTable($tableName)->getColumn($columnName, false); + } + + // deprecated methods + + /** + * Does this database contain this specific table? + * + * @deprecated Use hasTable() instead + * + * @param string $name The String representation of the table. + * + * @return boolean True if the database contains the table. + */ + public function containsTable($name) + { + return $this->hasTable($name); + } + + public function getTableByPhpName($phpName) + { + if (array_key_exists($phpName, $this->tablesByPhpName)) { + return $this->tablesByPhpName[$phpName]; + } elseif (defined($phpName . '::PEER')) { + $peerClass = constant($phpName . '::PEER'); + $tmClass = constant($peerClass . '::TM_CLASS'); + + $this->addTableFromMapClass($tmClass); + + return $this->tablesByPhpName[$phpName]; + } else { + throw new PropelException("Cannot fetch TableMap for undefined table phpName: " . $phpName); + } + } + + /** + * Convenience method to get the DBAdapter registered with Propel for this database. + * + * @return DBAdapter + * @see Propel::getDB(string) + */ + public function getDBAdapter() + { + return Propel::getDB($this->name); } - } - - /** - * Convenience method to get the DBAdapter registered with Propel for this database. - * @return DBAdapter - * @see Propel::getDB(string) - */ - public function getDBAdapter() - { - return Propel::getDB($this->name); - } } diff --git a/airtime_mvc/library/propel/runtime/lib/map/RelationMap.php b/airtime_mvc/library/propel/runtime/lib/map/RelationMap.php index 059cd00a4..3109ecbd2 100644 --- a/airtime_mvc/library/propel/runtime/lib/map/RelationMap.php +++ b/airtime_mvc/library/propel/runtime/lib/map/RelationMap.php @@ -19,281 +19,307 @@ * These classes in themselves do not do any database metadata lookups. * * @author Francois Zaninotto - * @version $Revision: 1728 $ + * @version $Revision$ * @package propel.runtime.map */ class RelationMap { - - const // types - MANY_TO_ONE = 1, - ONE_TO_MANY = 2, - ONE_TO_ONE = 3, - MANY_TO_MANY = 4, + const MANY_TO_ONE = 1; + const ONE_TO_MANY = 2; + const ONE_TO_ONE = 3; + const MANY_TO_MANY = 4; + // representations - LOCAL_TO_FOREIGN = 0, - LEFT_TO_RIGHT = 1; - - protected - $name, - $type, - $localTable, - $foreignTable, - $localColumns = array(), - $foreignColumns = array(), - $onUpdate, $onDelete; + const LOCAL_TO_FOREIGN = 0; + const LEFT_TO_RIGHT = 1; - /** - * Constructor. - * - * @param string $name Name of the relation. - */ - public function __construct($name) - { - $this->name = $name; - } - - /** - * Get the name of this relation. - * - * @return string The name of the relation. - */ - public function getName() - { - return $this->name; - } + protected $name; + protected $pluralName; + protected $type; + protected $localTable; + protected $foreignTable; + /** + * @var ColumnMap[] + */ + protected $localColumns = array(); + /** + * @var ColumnMap[] + */ + protected $foreignColumns = array(); + protected $onUpdate; + protected $onDelete; - /** - * Set the type - * - * @param integer $type The relation type (either self::MANY_TO_ONE, self::ONE_TO_MANY, or self::ONE_TO_ONE) - */ - public function setType($type) - { - $this->type = $type; - } + /** + * Constructor. + * + * @param string $name Name of the relation. + */ + public function __construct($name) + { + $this->name = $name; + } - /** - * Get the type - * - * @return integer the relation type - */ - public function getType() - { - return $this->type; - } + /** + * Get the name of this relation. + * + * @return string The name of the relation. + */ + public function getName() + { + return $this->name; + } - /** - * Set the local table - * - * @param TableMap $table The local table for this relationship - */ - public function setLocalTable($table) - { - $this->localTable = $table; - } + public function setPluralName($pluralName) + { + $this->pluralName = $pluralName; + } - /** - * Get the local table - * - * @return TableMap The local table for this relationship - */ - public function getLocalTable() - { - return $this->localTable; - } + /** + * Get the plural name of this relation. + * + * @return string The plural name of the relation. + */ + public function getPluralName() + { + return null !== $this->pluralName ? $this->pluralName : ($this->name . 's'); + } - /** - * Set the foreign table - * - * @param TableMap $table The foreign table for this relationship - */ - public function setForeignTable($table) - { - $this->foreignTable = $table; - } + /** + * Set the type + * + * @param integer $type The relation type (either self::MANY_TO_ONE, self::ONE_TO_MANY, or self::ONE_TO_ONE) + */ + public function setType($type) + { + $this->type = $type; + } - /** - * Get the foreign table - * - * @return TableMap The foreign table for this relationship - */ - public function getForeignTable() - { - return $this->foreignTable; - } - - /** - * Get the left table of the relation - * - * @return TableMap The left table for this relationship - */ - public function getLeftTable() - { - return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getLocalTable() : $this->getForeignTable(); - } + /** + * Get the type + * + * @return integer the relation type + */ + public function getType() + { + return $this->type; + } - /** - * Get the right table of the relation - * - * @return TableMap The right table for this relationship - */ - public function getRightTable() - { - return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getForeignTable() : $this->getLocalTable(); - } - - /** - * Add a column mapping - * - * @param ColumnMap $local The local column - * @param ColumnMap $foreign The foreign column - */ - public function addColumnMapping(ColumnMap $local, ColumnMap $foreign) - { - $this->localColumns[] = $local; - $this->foreignColumns[] = $foreign; - } - - /** - * Get an associative array mapping local column names to foreign column names - * The arrangement of the returned array depends on the $direction parameter: - * - If the value is RelationMap::LOCAL_TO_FOREIGN, then the returned array is local => foreign - * - If the value is RelationMap::LEFT_TO_RIGHT, then the returned array is left => right - * - * @param int $direction How the associative array must return columns - * @return Array Associative array (local => foreign) of fully qualified column names - */ - public function getColumnMappings($direction = RelationMap::LOCAL_TO_FOREIGN) - { - $h = array(); - if ($direction == RelationMap::LEFT_TO_RIGHT && $this->getType() == RelationMap::MANY_TO_ONE) { - $direction = RelationMap::LOCAL_TO_FOREIGN; - } - for ($i=0, $size=count($this->localColumns); $i < $size; $i++) { - if ($direction == RelationMap::LOCAL_TO_FOREIGN) { - $h[$this->localColumns[$i]->getFullyQualifiedName()] = $this->foreignColumns[$i]->getFullyQualifiedName(); - } else { - $h[$this->foreignColumns[$i]->getFullyQualifiedName()] = $this->localColumns[$i]->getFullyQualifiedName(); - } - } - return $h; - } - - /** - * Returns true if the relation has more than one column mapping - * - * @return boolean - */ - public function isComposite() - { - return $this->countColumnMappings() > 1; - } - - /** - * Return the number of column mappings - * - * @return int - */ - public function countColumnMappings() - { - return count($this->localColumns); - } - - /** - * Get the local columns - * - * @return Array list of ColumnMap objects - */ - public function getLocalColumns() - { - return $this->localColumns; - } - - /** - * Get the foreign columns - * - * @return Array list of ColumnMap objects - */ - public function getForeignColumns() - { - return $this->foreignColumns; - } - - /** - * Get the left columns of the relation - * - * @return array of ColumnMap objects - */ - public function getLeftColumns() - { - return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getLocalColumns() : $this->getForeignColumns(); - } + /** + * Set the local table + * + * @param TableMap $table The local table for this relationship + */ + public function setLocalTable($table) + { + $this->localTable = $table; + } - /** - * Get the right columns of the relation - * - * @return array of ColumnMap objects - */ - public function getRightColumns() - { - return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getForeignColumns() : $this->getLocalColumns(); - } + /** + * Get the local table + * + * @return TableMap The local table for this relationship + */ + public function getLocalTable() + { + return $this->localTable; + } + /** + * Set the foreign table + * + * @param TableMap $table The foreign table for this relationship + */ + public function setForeignTable($table) + { + $this->foreignTable = $table; + } - /** - * Set the onUpdate behavior - * - * @param string $onUpdate - */ - public function setOnUpdate($onUpdate) - { - $this->onUpdate = $onUpdate; - } + /** + * Get the foreign table + * + * @return TableMap The foreign table for this relationship + */ + public function getForeignTable() + { + return $this->foreignTable; + } - /** - * Get the onUpdate behavior - * - * @return integer the relation type - */ - public function getOnUpdate() - { - return $this->onUpdate; - } - - /** - * Set the onDelete behavior - * - * @param string $onDelete - */ - public function setOnDelete($onDelete) - { - $this->onDelete = $onDelete; - } + /** + * Get the left table of the relation + * + * @return TableMap The left table for this relationship + */ + public function getLeftTable() + { + return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getLocalTable() : $this->getForeignTable(); + } - /** - * Get the onDelete behavior - * - * @return integer the relation type - */ - public function getOnDelete() - { - return $this->onDelete; - } - - /** - * Gets the symmetrical relation - * - * @return RelationMap - */ - public function getSymmetricalRelation() - { - $localMapping = array($this->getLeftColumns(), $this->getRightColumns()); - foreach ($this->getRightTable()->getRelations() as $relation) { - if ($localMapping == array($relation->getRightColumns(), $relation->getLeftColumns())) { - return $relation; - } - } - } + /** + * Get the right table of the relation + * + * @return TableMap The right table for this relationship + */ + public function getRightTable() + { + return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getForeignTable() : $this->getLocalTable(); + } + + /** + * Add a column mapping + * + * @param ColumnMap $local The local column + * @param ColumnMap $foreign The foreign column + */ + public function addColumnMapping(ColumnMap $local, ColumnMap $foreign) + { + $this->localColumns[] = $local; + $this->foreignColumns[] = $foreign; + } + + /** + * Get an associative array mapping local column names to foreign column names + * The arrangement of the returned array depends on the $direction parameter: + * - If the value is RelationMap::LOCAL_TO_FOREIGN, then the returned array is local => foreign + * - If the value is RelationMap::LEFT_TO_RIGHT, then the returned array is left => right + * + * @param int $direction How the associative array must return columns + * + * @return Array Associative array (local => foreign) of fully qualified column names + */ + public function getColumnMappings($direction = RelationMap::LOCAL_TO_FOREIGN) + { + $h = array(); + if ($direction == RelationMap::LEFT_TO_RIGHT && $this->getType() == RelationMap::MANY_TO_ONE) { + $direction = RelationMap::LOCAL_TO_FOREIGN; + } + for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) { + if ($direction == RelationMap::LOCAL_TO_FOREIGN) { + $h[$this->localColumns[$i]->getFullyQualifiedName()] = $this->foreignColumns[$i]->getFullyQualifiedName(); + } else { + $h[$this->foreignColumns[$i]->getFullyQualifiedName()] = $this->localColumns[$i]->getFullyQualifiedName(); + } + } + + return $h; + } + + /** + * Returns true if the relation has more than one column mapping + * + * @return boolean + */ + public function isComposite() + { + return $this->countColumnMappings() > 1; + } + + /** + * Return the number of column mappings + * + * @return int + */ + public function countColumnMappings() + { + return count($this->localColumns); + } + + /** + * Get the local columns + * + * @return Array list of ColumnMap objects + */ + public function getLocalColumns() + { + return $this->localColumns; + } + + /** + * Get the foreign columns + * + * @return Array list of ColumnMap objects + */ + public function getForeignColumns() + { + return $this->foreignColumns; + } + + /** + * Get the left columns of the relation + * + * @return ColumnMap[] + */ + public function getLeftColumns() + { + return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getLocalColumns() : $this->getForeignColumns(); + } + + /** + * Get the right columns of the relation + * + * @return ColumnMap[] + */ + public function getRightColumns() + { + return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getForeignColumns() : $this->getLocalColumns(); + } + + /** + * Set the onUpdate behavior + * + * @param string $onUpdate + */ + public function setOnUpdate($onUpdate) + { + $this->onUpdate = $onUpdate; + } + + /** + * Get the onUpdate behavior + * + * @return integer the relation type + */ + public function getOnUpdate() + { + return $this->onUpdate; + } + + /** + * Set the onDelete behavior + * + * @param string $onDelete + */ + public function setOnDelete($onDelete) + { + $this->onDelete = $onDelete; + } + + /** + * Get the onDelete behavior + * + * @return integer the relation type + */ + public function getOnDelete() + { + return $this->onDelete; + } + + /** + * Gets the symmetrical relation + * + * @return RelationMap + * + * @throws PropelException + */ + public function getSymmetricalRelation() + { + $localMapping = array($this->getLeftColumns(), $this->getRightColumns()); + foreach ($this->getRightTable()->getRelations() as $relation) { + if ($localMapping == array($relation->getRightColumns(), $relation->getLeftColumns())) { + return $relation; + } + } + + throw new PropelException('The relation could not be resolved.'); + } } diff --git a/airtime_mvc/library/propel/runtime/lib/map/TableMap.php b/airtime_mvc/library/propel/runtime/lib/map/TableMap.php index 164e137f5..8ec8a521f 100644 --- a/airtime_mvc/library/propel/runtime/lib/map/TableMap.php +++ b/airtime_mvc/library/propel/runtime/lib/map/TableMap.php @@ -21,692 +21,824 @@ * @author Hans Lellelid (Propel) * @author John D. McNally (Torque) * @author Daniel Rall (Torque) - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.map */ class TableMap { + /** + * Columns in the table + * + * @var ColumnMap[] + */ + protected $columns = array(); - /** - * Columns in the table - * @var array TableMap[] - */ - protected $columns = array(); + /** + * Columns in the table, using table phpName as key + * + * @var ColumnMap[] + */ + protected $columnsByPhpName = array(); - /** - * Columns in the table, using table phpName as key - * @var array TableMap[] - */ - protected $columnsByPhpName = array(); - - // The database this table belongs to - protected $dbMap; + /** + * Columns in the table, using as key + * + * @var ColumnMap[] + */ + protected $columnsByInsensitiveCase = array(); - // The name of the table - protected $tableName; + /** + * The database this table belongs to + * + * @var DatabaseMap + */ + protected $dbMap; - // The PHP name of the table - protected $phpName; + // The name of the table + protected $tableName; - // The Classname for this table - protected $classname; + // The PHP name of the table + protected $phpName; - // The Package for this table - protected $package; - - // Whether to use an id generator for pkey - protected $useIdGenerator; + // The Classname for this table + protected $classname; - // Whether the table uses single table inheritance - protected $isSingleTableInheritance = false; - - // The primary key columns in the table - protected $primaryKeys = array(); - - // The foreign key columns in the table - protected $foreignKeys = array(); + // The Package for this table + protected $package; - // The relationships in the table - protected $relations = array(); + // Whether to use an id generator for pkey + protected $useIdGenerator; - // Relations are lazy loaded. This property tells if the relations are loaded or not - protected $relationsBuilt = false; - - // Object to store information that is needed if the for generating primary keys - protected $pkInfo; - - /** - * Construct a new TableMap. - * - */ - public function __construct($name = null, $dbMap = null) - { - if (null !== $name) { - $this->setName($name); - } - if (null !== $dbMap) { - $this->setDatabaseMap($dbMap); - } - $this->initialize(); - } - - /** - * Initialize the TableMap to build columns, relations, etc - * This method should be overridden by descendents - */ - public function initialize() - { - } + // Whether the table uses single table inheritance + protected $isSingleTableInheritance = false; - /** - * Set the DatabaseMap containing this TableMap. - * - * @param DatabaseMap $dbMap A DatabaseMap. - */ - public function setDatabaseMap(DatabaseMap $dbMap) - { - $this->dbMap = $dbMap; - } - - /** - * Get the DatabaseMap containing this TableMap. - * - * @return DatabaseMap A DatabaseMap. - */ - public function getDatabaseMap() - { - return $this->dbMap; - } + // Whether the table is a Many to Many table + protected $isCrossRef = false; - /** - * Set the name of the Table. - * - * @param string $name The name of the table. - */ - public function setName($name) - { - $this->tableName = $name; - } - - /** - * Get the name of the Table. - * - * @return string A String with the name of the table. - */ - public function getName() - { - return $this->tableName; - } + // The primary key columns in the table + protected $primaryKeys = array(); - /** - * Set the PHP name of the Table. - * - * @param string $phpName The PHP Name for this table - */ - public function setPhpName($phpName) - { - $this->phpName = $phpName; - } - - /** - * Get the PHP name of the Table. - * - * @return string A String with the name of the table. - */ - public function getPhpName() - { - return $this->phpName; - } + // The foreign key columns in the table + protected $foreignKeys = array(); - /** - * Set the Classname of the Table. Could be useful for calling - * Peer and Object methods dynamically. - * @param string $classname The Classname - */ - public function setClassname($classname) - { - $this->classname = $classname; - } + /** + * The relationships in the table + * + * @var RelationMap[] + */ + protected $relations = array(); - /** - * Get the Classname of the Propel Class belonging to this table. - * @return string - */ - public function getClassname() - { - return $this->classname; - } - - /** - * Get the Peer Classname of the Propel Class belonging to this table. - * @return string - */ - public function getPeerClassname() - { - return constant($this->classname . '::PEER'); - } - - /** - * Set the Package of the Table - * - * @param string $package The Package - */ - public function setPackage($package) - { - $this->package = $package; - } + // Relations are lazy loaded. This property tells if the relations are loaded or not + protected $relationsBuilt = false; - /** - * Get the Package of the table. - * @return string - */ - public function getPackage() - { - return $this->package; - } - - /** - * Set whether or not to use Id generator for primary key. - * @param boolean $bit - */ - public function setUseIdGenerator($bit) - { - $this->useIdGenerator = $bit; - } + // Object to store information that is needed if the for generating primary keys + protected $pkInfo; - /** - * Whether to use Id generator for primary key. - * @return boolean - */ - public function isUseIdGenerator() - { - return $this->useIdGenerator; - } - - /** - * Set whether or not to this table uses single table inheritance - * @param boolean $bit - */ - public function setSingleTableInheritance($bit) - { - $this->isSingleTableInheritance = $bit; - } - - /** - * Whether this table uses single table inheritance - * @return boolean - */ - public function isSingleTableInheritance() - { - return $this->isSingleTableInheritance; - } - - /** - * Sets the pk information needed to generate a key - * - * @param $pkInfo information needed to generate a key - */ - public function setPrimaryKeyMethodInfo($pkInfo) - { - $this->pkInfo = $pkInfo; - } - - /** - * Get the information used to generate a primary key - * - * @return An Object. - */ - public function getPrimaryKeyMethodInfo() - { - return $this->pkInfo; - } - - /** - * Add a column to the table. - * - * @param string name A String with the column name. - * @param string $type A string specifying the Propel type. - * @param boolean $isNotNull Whether column does not allow NULL values. - * @param int $size An int specifying the size. - * @param boolean $pk True if column is a primary key. - * @param string $fkTable A String with the foreign key table name. - * @param $fkColumn A String with the foreign key column name. - * @param string $defaultValue The default value for this column. - * @return ColumnMap The newly created column. - */ - public function addColumn($name, $phpName, $type, $isNotNull = false, $size = null, $defaultValue = null, $pk = false, $fkTable = null, $fkColumn = null) - { - $col = new ColumnMap($name, $this); - $col->setType($type); - $col->setSize($size); - $col->setPhpName($phpName); - $col->setNotNull($isNotNull); - $col->setDefaultValue($defaultValue); - - if ($pk) { - $col->setPrimaryKey(true); - $this->primaryKeys[$name] = $col; - } - - if ($fkTable && $fkColumn) { - $col->setForeignKey($fkTable, $fkColumn); - $this->foreignKeys[$name] = $col; - } - - $this->columns[$name] = $col; - $this->columnsByPhpName[$phpName] = $col; - - return $col; - } - - /** - * Add a pre-created column to this table. It will replace any - * existing column. - * - * @param ColumnMap $cmap A ColumnMap. - * @return ColumnMap The added column map. - */ - public function addConfiguredColumn($cmap) - { - $this->columns[ $cmap->getColumnName() ] = $cmap; - return $cmap; - } - - /** - * Does this table contain the specified column? - * - * @param mixed $name name of the column or ColumnMap instance - * @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME) - * @return boolean True if the table contains the column. - */ - public function hasColumn($name, $normalize = true) - { - if ($name instanceof ColumnMap) { - $name = $name->getColumnName(); - } else if($normalize) { - $name = ColumnMap::normalizeName($name); - } - return isset($this->columns[$name]); - } - - /** - * Get a ColumnMap for the table. - * - * @param string $name A String with the name of the table. - * @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME) - * @return ColumnMap A ColumnMap. - * @throws PropelException if the column is undefined - */ - public function getColumn($name, $normalize = true) - { - if ($normalize) { - $name = ColumnMap::normalizeName($name); - } - if (!$this->hasColumn($name, false)) { - throw new PropelException("Cannot fetch ColumnMap for undefined column: " . $name); - } - return $this->columns[$name]; - } - - /** - * Does this table contain the specified column? - * - * @param mixed $phpName name of the column - * @return boolean True if the table contains the column. - */ - public function hasColumnByPhpName($phpName) - { - return isset($this->columnsByPhpName[$phpName]); - } - - /** - * Get a ColumnMap for the table. - * - * @param string $phpName A String with the name of the table. - * @return ColumnMap A ColumnMap. - * @throws PropelException if the column is undefined - */ - public function getColumnByPhpName($phpName) - { - if (!isset($this->columnsByPhpName[$phpName])) { - throw new PropelException("Cannot fetch ColumnMap for undefined column phpName: " . $phpName); - } - return $this->columnsByPhpName[$phpName]; - } - - /** - * Get a ColumnMap[] of the columns in this table. - * - * @return array A ColumnMap[]. - */ - public function getColumns() - { - return $this->columns; - } - - /** - * Add a primary key column to this Table. - * - * @param string $columnName A String with the column name. - * @param string $type A string specifying the Propel type. - * @param boolean $isNotNull Whether column does not allow NULL values. - * @param $size An int specifying the size. - * @return ColumnMap Newly added PrimaryKey column. - */ - public function addPrimaryKey($columnName, $phpName, $type, $isNotNull = false, $size = null, $defaultValue = null) - { - return $this->addColumn($columnName, $phpName, $type, $isNotNull, $size, $defaultValue, true, null, null); - } - - /** - * Add a foreign key column to the table. - * - * @param string $columnName A String with the column name. - * @param string $type A string specifying the Propel type. - * @param string $fkTable A String with the foreign key table name. - * @param string $fkColumn A String with the foreign key column name. - * @param boolean $isNotNull Whether column does not allow NULL values. - * @param int $size An int specifying the size. - * @param string $defaultValue The default value for this column. - * @return ColumnMap Newly added ForeignKey column. - */ - public function addForeignKey($columnName, $phpName, $type, $fkTable, $fkColumn, $isNotNull = false, $size = 0, $defaultValue = null) - { - return $this->addColumn($columnName, $phpName, $type, $isNotNull, $size, $defaultValue, false, $fkTable, $fkColumn); - } - - /** - * Add a foreign primary key column to the table. - * - * @param string $columnName A String with the column name. - * @param string $type A string specifying the Propel type. - * @param string $fkTable A String with the foreign key table name. - * @param string $fkColumn A String with the foreign key column name. - * @param boolean $isNotNull Whether column does not allow NULL values. - * @param int $size An int specifying the size. - * @param string $defaultValue The default value for this column. - * @return ColumnMap Newly created foreign pkey column. - */ - public function addForeignPrimaryKey($columnName, $phpName, $type, $fkTable, $fkColumn, $isNotNull = false, $size = 0, $defaultValue = null) - { - return $this->addColumn($columnName, $phpName, $type, $isNotNull, $size, $defaultValue, true, $fkTable, $fkColumn); - } - - /** - * Returns array of ColumnMap objects that make up the primary key for this table - * - * @return array ColumnMap[] - */ - public function getPrimaryKeys() - { - return $this->primaryKeys; - } - - /** - * Returns array of ColumnMap objects that are foreign keys for this table - * - * @return array ColumnMap[] - */ - public function getForeignKeys() - { - return $this->foreignKeys; - } - - /** - * Add a validator to a table's column - * - * @param string $columnName The name of the validator's column - * @param string $name The rule name of this validator - * @param string $classname The dot-path name of class to use (e.g. myapp.propel.MyValidator) - * @param string $value - * @param string $message The error message which is returned on invalid values - * @return void - */ - public function addValidator($columnName, $name, $classname, $value, $message) - { - if (false !== ($pos = strpos($columnName, '.'))) { - $columnName = substr($columnName, $pos + 1); - } - - $col = $this->getColumn($columnName); - if ($col !== null) { - $validator = new ValidatorMap($col); - $validator->setName($name); - $validator->setClass($classname); - $validator->setValue($value); - $validator->setMessage($message); - $col->addValidator($validator); - } - } - - /** - * Build relations - * Relations are lazy loaded for performance reasons - * This method should be overridden by descendents - */ - public function buildRelations() - { - } - - /** - * Adds a RelationMap to the table - * - * @param string $name The relation name - * @param string $tablePhpName The related table name - * @param integer $type The relation type (either RelationMap::MANY_TO_ONE, RelationMap::ONE_TO_MANY, or RelationMAp::ONE_TO_ONE) - * @param array $columnMapping An associative array mapping column names (local => foreign) - * @return RelationMap the built RelationMap object - */ - public function addRelation($name, $tablePhpName, $type, $columnMapping = array(), $onDelete = null, $onUpdate = null) - { - // note: using phpName for the second table allows the use of DatabaseMap::getTableByPhpName() - // and this method autoloads the TableMap if the table isn't loaded yet - $relation = new RelationMap($name); - $relation->setType($type); - $relation->setOnUpdate($onUpdate); - $relation->setOnDelete($onDelete); - // set tables - if ($type == RelationMap::MANY_TO_ONE) { - $relation->setLocalTable($this); - $relation->setForeignTable($this->dbMap->getTableByPhpName($tablePhpName)); - } else { - $relation->setLocalTable($this->dbMap->getTableByPhpName($tablePhpName)); - $relation->setForeignTable($this); - $columnMapping = array_flip($columnMapping); - } - // set columns - foreach ($columnMapping as $local => $foreign) { - $relation->addColumnMapping( - $relation->getLocalTable()->getColumn($local), - $relation->getForeignTable()->getColumn($foreign) - ); - } - $this->relations[$name] = $relation; - return $relation; - } - - /** - * Gets a RelationMap of the table by relation name - * This method will build the relations if they are not built yet - * - * @param String $name The relation name - * @return boolean true if the relation exists - */ - public function hasRelation($name) - { - return array_key_exists($name, $this->getRelations()); - } - - /** - * Gets a RelationMap of the table by relation name - * This method will build the relations if they are not built yet - * - * @param String $name The relation name - * @return RelationMap The relation object - * @throws PropelException When called on an inexistent relation - */ - public function getRelation($name) - { - if (!array_key_exists($name, $this->getRelations())) + /** + * Construct a new TableMap. + * + */ + public function __construct($name = null, $dbMap = null) { - throw new PropelException('Calling getRelation() on an unknown relation, ' . $name); + if (null !== $name) { + $this->setName($name); + } + if (null !== $dbMap) { + $this->setDatabaseMap($dbMap); + } + $this->initialize(); } - return $this->relations[$name]; - } - /** - * Gets the RelationMap objects of the table - * This method will build the relations if they are not built yet - * - * @return Array list of RelationMap objects - */ - public function getRelations() - { - if(!$this->relationsBuilt) + /** + * Initialize the TableMap to build columns, relations, etc + * This method should be overridden by descendents + */ + public function initialize() { - $this->buildRelations(); - $this->relationsBuilt = true; } - return $this->relations; - } - /** - * - * Gets the list of behaviors registered for this table - * - * @return array - */ - public function getBehaviors() - { - return array(); - } - - // Deprecated methods and attributres, to be removed - - /** - * Does this table contain the specified column? - * - * @deprecated Use hasColumn instead - * @param mixed $name name of the column or ColumnMap instance - * @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME) - * @return boolean True if the table contains the column. - */ - public function containsColumn($name, $normalize = true) - { - return $this->hasColumn($name, $normalize); - } - - /** - * Normalizes the column name, removing table prefix and uppercasing. - * article.first_name becomes FIRST_NAME - * - * @deprecated Use ColumnMap::normalizeColumName() instead - * @param string $name - * @return string Normalized column name. - */ - protected function normalizeColName($name) - { - return ColumnMap::normalizeName($name); - } - - /** - * Returns array of ColumnMap objects that make up the primary key for this table. - * - * @deprecated Use getPrimaryKeys instead - * @return array ColumnMap[] - */ - public function getPrimaryKeyColumns() - { - return array_values($this->primaryKeys); - } - - //---Utility methods for doing intelligent lookup of table names - - /** - * The prefix on the table name. - * @deprecated Not used anywhere in Propel - */ - private $prefix; - - /** - * Get table prefix name. - * - * @deprecated Not used anywhere in Propel - * @return string A String with the prefix. - */ - public function getPrefix() - { - return $this->prefix; - } - - /** - * Set table prefix name. - * - * @deprecated Not used anywhere in Propel - * @param string $prefix The prefix for the table name (ie: SCARAB for - * SCARAB_PROJECT). - * @return void - */ - public function setPrefix($prefix) - { - $this->prefix = $prefix; - } - - /** - * Tell me if i have PREFIX in my string. - * - * @deprecated Not used anywhere in Propel - * @param data A String. - * @return boolean True if prefix is contained in data. - */ - protected function hasPrefix($data) - { - return (strpos($data, $this->prefix) === 0); - } - - /** - * Removes the PREFIX if found - * - * @deprecated Not used anywhere in Propel - * @param string $data A String. - * @return string A String with data, but with prefix removed. - */ - protected function removePrefix($data) - { - return $this->hasPrefix($data) ? substr($data, strlen($this->prefix)) : $data; - } - - /** - * Removes the PREFIX, removes the underscores and makes - * first letter caps. - * - * SCARAB_FOO_BAR becomes FooBar. - * - * @deprecated Not used anywhere in Propel. At buildtime, use Column::generatePhpName() for that purpose - * @param data A String. - * @return string A String with data processed. - */ - public final function removeUnderScores($data) - { - $out = ''; - $tmp = $this->removePrefix($data); - $tok = strtok($tmp, '_'); - while ($tok) { - $out .= ucfirst($tok); - $tok = strtok('_'); + /** + * Set the DatabaseMap containing this TableMap. + * + * @param DatabaseMap $dbMap A DatabaseMap. + */ + public function setDatabaseMap(DatabaseMap $dbMap) + { + $this->dbMap = $dbMap; } - return $out; - } - /** - * Makes the first letter caps and the rest lowercase. - * - * @deprecated Not used anywhere in Propel. - * @param string $data A String. - * @return string A String with data processed. - */ - private function firstLetterCaps($data) - { - return(ucfirst(strtolower($data))); - } + /** + * Get the DatabaseMap containing this TableMap. + * + * @return DatabaseMap A DatabaseMap. + */ + public function getDatabaseMap() + { + return $this->dbMap; + } + + /** + * Set the name of the Table. + * + * @param string $name The name of the table. + */ + public function setName($name) + { + $this->tableName = $name; + } + + /** + * Get the name of the Table. + * + * @return string A String with the name of the table. + */ + public function getName() + { + return $this->tableName; + } + + /** + * Set the PHP name of the Table. + * + * @param string $phpName The PHP Name for this table + */ + public function setPhpName($phpName) + { + $this->phpName = $phpName; + } + + /** + * Get the PHP name of the Table. + * + * @return string A String with the name of the table. + */ + public function getPhpName() + { + return $this->phpName; + } + + /** + * Set the Classname of the Table. Could be useful for calling + * Peer and Object methods dynamically. + * + * @param string $classname The Classname + */ + public function setClassname($classname) + { + $this->classname = $classname; + } + + /** + * Get the Classname of the Propel Class belonging to this table. + * + * @return string + */ + public function getClassname() + { + return $this->classname; + } + + /** + * Get the Peer Classname of the Propel Class belonging to this table. + * + * @return string + */ + public function getPeerClassname() + { + return constant($this->classname . '::PEER'); + } + + /** + * Set the Package of the Table + * + * @param string $package The Package + */ + public function setPackage($package) + { + $this->package = $package; + } + + /** + * Get the Package of the table. + * + * @return string + */ + public function getPackage() + { + return $this->package; + } + + /** + * Set whether or not to use Id generator for primary key. + * + * @param boolean $bit + */ + public function setUseIdGenerator($bit) + { + $this->useIdGenerator = $bit; + } + + /** + * Whether to use Id generator for primary key. + * + * @return boolean + */ + public function isUseIdGenerator() + { + return $this->useIdGenerator; + } + + /** + * Set whether or not to this table uses single table inheritance + * + * @param boolean $bit + */ + public function setSingleTableInheritance($bit) + { + $this->isSingleTableInheritance = $bit; + } + + /** + * Whether this table uses single table inheritance + * + * @return boolean + */ + public function isSingleTableInheritance() + { + return $this->isSingleTableInheritance; + } + + /** + * Sets the name of the sequence used to generate a key + * + * @param $pkInfo information needed to generate a key + */ + public function setPrimaryKeyMethodInfo($pkInfo) + { + $this->pkInfo = $pkInfo; + } + + /** + * Get the name of the sequence used to generate a primary key + * + * @return An Object. + */ + public function getPrimaryKeyMethodInfo() + { + return $this->pkInfo; + } + + /** + * Add a column to the table. + * + * @param string $name A string with the column name. + * @param string $phpName A string specifying php name. + * @param string $type A string specifying the Propel type. + * @param boolean $isNotNull Whether column does not allow NULL values. + * @param int $size An int specifying the size. + * @param boolean $pk True if column is a primary key. + * @param string $fkTable A String with the foreign key table name. + * @param string $fkColumn A String with the foreign key column name. + * @param string $defaultValue The default value for this column. + * + * @return ColumnMap The newly created column. + */ + public function addColumn($name, $phpName, $type, $isNotNull = false, $size = null, $defaultValue = null, $pk = false, $fkTable = null, $fkColumn = null) + { + $col = new ColumnMap($name, $this); + $col->setType($type); + $col->setSize($size); + $col->setPhpName($phpName); + $col->setNotNull($isNotNull); + $col->setDefaultValue($defaultValue); + + if ($pk) { + $col->setPrimaryKey(true); + $this->primaryKeys[$name] = $col; + } + + if ($fkTable && $fkColumn) { + $col->setForeignKey($fkTable, $fkColumn); + $this->foreignKeys[$name] = $col; + } + + $this->columns[$name] = $col; + $this->columnsByPhpName[$phpName] = $col; + $this->columnsByInsensitiveCase[strtolower($phpName)] = $col; + + return $col; + } + + /** + * Add a pre-created column to this table. It will replace any + * existing column. + * + * @param ColumnMap $cmap A ColumnMap. + * + * @return ColumnMap The added column map. + */ + public function addConfiguredColumn($cmap) + { + $this->columns[$cmap->getName()] = $cmap; + + return $cmap; + } + + /** + * Does this table contain the specified column? + * + * @param mixed $name name of the column or ColumnMap instance + * @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME) + * + * @return boolean True if the table contains the column. + */ + public function hasColumn($name, $normalize = true) + { + if ($name instanceof ColumnMap) { + $name = $name->getColumnName(); + } elseif ($normalize) { + $name = ColumnMap::normalizeName($name); + } + + return isset($this->columns[$name]); + } + + /** + * Get a ColumnMap for the table. + * + * @param string $name A String with the name of the table. + * @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME) + * + * @return ColumnMap A ColumnMap. + * @throws PropelException if the column is undefined + */ + public function getColumn($name, $normalize = true) + { + if ($normalize) { + $name = ColumnMap::normalizeName($name); + } + if (!$this->hasColumn($name, false)) { + throw new PropelException("Cannot fetch ColumnMap for undefined column: " . $name); + } + + return $this->columns[$name]; + } + + /** + * Does this table contain the specified column? + * + * @param mixed $phpName name of the column + * + * @return boolean True if the table contains the column. + */ + public function hasColumnByPhpName($phpName) + { + return isset($this->columnsByPhpName[$phpName]); + } + + /** + * Get a ColumnMap for the table. + * + * @param string $phpName A String with the name of the table. + * + * @return ColumnMap A ColumnMap. + * @throws PropelException if the column is undefined + */ + public function getColumnByPhpName($phpName) + { + if (!isset($this->columnsByPhpName[$phpName])) { + throw new PropelException("Cannot fetch ColumnMap for undefined column phpName: " . $phpName); + } + + return $this->columnsByPhpName[$phpName]; + } + + public function hasColumnByInsensitiveCase($colName) + { + return isset($this->columnsByInsensitiveCase[strtolower($colName)]); + } + + public function getColumnByInsensitiveCase($colName) + { + $colName = strtolower($colName); + if (!isset($this->columnsByInsensitiveCase[$colName])) { + throw new PropelException("Cannot fetch ColumnMap for undefined column name: " . $colName); + } + + return $this->columnsByInsensitiveCase[$colName]; + } + + /** + * Get a ColumnMap[] of the columns in this table. + * + * @return ColumnMap[] + */ + public function getColumns() + { + return $this->columns; + } + + /** + * Add a primary key column to this Table. + * + * @param string $columnName A string with the column name. + * @param string $phpName A string with the php name. + * @param string $type A string specifying the Propel type. + * @param boolean $isNotNull Whether column does not allow NULL values. + * @param int $size An int specifying the size. + * @param string $defaultValue + * + * @return ColumnMap Newly added PrimaryKey column. + */ + public function addPrimaryKey($columnName, $phpName, $type, $isNotNull = false, $size = null, $defaultValue = null) + { + return $this->addColumn($columnName, $phpName, $type, $isNotNull, $size, $defaultValue, true, null, null); + } + + /** + * Add a foreign key column to the table. + * + * @param string $columnName A String with the column name. + * @param string $phpName A string with the php name. + * @param string $type A string specifying the Propel type. + * @param string $fkTable A String with the foreign key table name. + * @param string $fkColumn A String with the foreign key column name. + * @param boolean $isNotNull Whether column does not allow NULL values. + * @param int $size An int specifying the size. + * @param string $defaultValue The default value for this column. + * + * @return ColumnMap Newly added ForeignKey column. + */ + public function addForeignKey($columnName, $phpName, $type, $fkTable, $fkColumn, $isNotNull = false, $size = 0, $defaultValue = null) + { + return $this->addColumn($columnName, $phpName, $type, $isNotNull, $size, $defaultValue, false, $fkTable, $fkColumn); + } + + /** + * Add a foreign primary key column to the table. + * + * @param string $columnName A String with the column name. + * @param string $phpName A string with the php name. + * @param string $type A string specifying the Propel type. + * @param string $fkTable A String with the foreign key table name. + * @param string $fkColumn A String with the foreign key column name. + * @param boolean $isNotNull Whether column does not allow NULL values. + * @param int $size An int specifying the size. + * @param string $defaultValue The default value for this column. + * + * @return ColumnMap Newly created foreign pkey column. + */ + public function addForeignPrimaryKey($columnName, $phpName, $type, $fkTable, $fkColumn, $isNotNull = false, $size = 0, $defaultValue = null) + { + return $this->addColumn($columnName, $phpName, $type, $isNotNull, $size, $defaultValue, true, $fkTable, $fkColumn); + } + + /** + * @return boolean true if the table is a many to many + */ + public function isCrossRef() + { + return $this->isCrossRef; + } + + /** + * set the isCrossRef + * + * @param boolean $isCrossRef + */ + public function setIsCrossRef($isCrossRef) + { + $this->isCrossRef = $isCrossRef; + } + + /** + * Returns array of ColumnMap objects that make up the primary key for this table + * + * @return array ColumnMap[] + */ + public function getPrimaryKeys() + { + return $this->primaryKeys; + } + + /** + * Returns array of ColumnMap objects that are foreign keys for this table + * + * @return array ColumnMap[] + */ + public function getForeignKeys() + { + return $this->foreignKeys; + } + + /** + * Add a validator to a table's column + * + * @param string $columnName The name of the validator's column + * @param string $name The rule name of this validator + * @param string $classname The dot-path name of class to use (e.g. myapp.propel.MyValidator) + * @param string $value + * @param string $message The error message which is returned on invalid values + * + * @return void + */ + public function addValidator($columnName, $name, $classname, $value, $message) + { + if (false !== ($pos = strpos($columnName, '.'))) { + $columnName = substr($columnName, $pos + 1); + } + + $col = $this->getColumn($columnName); + if ($col !== null) { + $validator = new ValidatorMap($col); + $validator->setName($name); + $validator->setClass($classname); + $validator->setValue($value); + $validator->setMessage($message); + $col->addValidator($validator); + } + } + + /** + * Build relations + * Relations are lazy loaded for performance reasons + * This method should be overridden by descendents + */ + public function buildRelations() + { + } + + /** + * Adds a RelationMap to the table + * + * @param string $name The relation name + * @param string $tablePhpName The related table name + * @param integer $type The relation type (either RelationMap::MANY_TO_ONE, RelationMap::ONE_TO_MANY, or RelationMAp::ONE_TO_ONE) + * @param array $columnMapping An associative array mapping column names (local => foreign) + * @param string $onDelete SQL behavior upon deletion ('SET NULL', 'CASCADE', ...) + * @param string $onUpdate SQL behavior upon update ('SET NULL', 'CASCADE', ...) + * @param string $pluralName Optional plural name for *_TO_MANY relationships + * + * @return RelationMap the built RelationMap object + */ + public function addRelation($name, $tablePhpName, $type, $columnMapping = array(), $onDelete = null, $onUpdate = null, $pluralName = null) + { + // note: using phpName for the second table allows the use of DatabaseMap::getTableByPhpName() + // and this method autoloads the TableMap if the table isn't loaded yet + $relation = new RelationMap($name); + $relation->setType($type); + $relation->setOnUpdate($onUpdate); + $relation->setOnDelete($onDelete); + if (null !== $pluralName) { + $relation->setPluralName($pluralName); + } + // set tables + if ($type == RelationMap::MANY_TO_ONE) { + $relation->setLocalTable($this); + $relation->setForeignTable($this->dbMap->getTableByPhpName($tablePhpName)); + } else { + $relation->setLocalTable($this->dbMap->getTableByPhpName($tablePhpName)); + $relation->setForeignTable($this); + $columnMapping = array_flip($columnMapping); + } + // set columns + foreach ($columnMapping as $local => $foreign) { + $relation->addColumnMapping( + $relation->getLocalTable()->getColumn($local), + $relation->getForeignTable()->getColumn($foreign) + ); + } + $this->relations[$name] = $relation; + + return $relation; + } + + /** + * Gets a RelationMap of the table by relation name + * This method will build the relations if they are not built yet + * + * @param String $name The relation name + * + * @return boolean true if the relation exists + */ + public function hasRelation($name) + { + return array_key_exists($name, $this->getRelations()); + } + + /** + * Gets a RelationMap of the table by relation name + * This method will build the relations if they are not built yet + * + * @param String $name The relation name + * + * @return RelationMap The relation object + * @throws PropelException When called on an inexistent relation + */ + public function getRelation($name) + { + if (!array_key_exists($name, $this->getRelations())) { + throw new PropelException('Calling getRelation() on an unknown relation, ' . $name); + } + + return $this->relations[$name]; + } + + /** + * Gets the RelationMap objects of the table + * This method will build the relations if they are not built yet + * + * @return RelationMap[] + */ + public function getRelations() + { + if (!$this->relationsBuilt) { + $this->buildRelations(); + $this->relationsBuilt = true; + } + + return $this->relations; + } + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array + */ + public function getBehaviors() + { + return array(); + } + + /** + * Does this table has a primaryString column? + * + * @return boolean True if the table has a primaryString column. + */ + public function hasPrimaryStringColumn() + { + return null !== $this->getPrimaryStringColumn(); + } + + /** + * Gets the ColumnMap for the primary string column. + * + * @return ColumnMap|null The primary string column, null if none given. + */ + public function getPrimaryStringColumn() + { + foreach ($this->getColumns() as $column) { + if ($column->isPrimaryString()) { + return $column; + } + } + + return null; + } + + // Deprecated methods and attributes, to be removed + + /** + * Does this table contain the specified column? + * + * @deprecated Use hasColumn instead + * + * @param mixed $name name of the column or ColumnMap instance + * @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME) + * + * @return boolean True if the table contains the column. + */ + public function containsColumn($name, $normalize = true) + { + return $this->hasColumn($name, $normalize); + } + + /** + * Normalizes the column name, removing table prefix and uppercasing. + * article.first_name becomes FIRST_NAME + * + * @deprecated Use ColumnMap::normalizeColumnName() instead + * + * @param string $name + * + * @return string Normalized column name. + */ + protected function normalizeColName($name) + { + return ColumnMap::normalizeName($name); + } + + /** + * Returns array of ColumnMap objects that make up the primary key for this table. + * + * @deprecated Use getPrimaryKeys instead + * @return ColumnMap[] + */ + public function getPrimaryKeyColumns() + { + return array_values($this->primaryKeys); + } + + //---Utility methods for doing intelligent lookup of table names + + /** + * The prefix on the table name. + * + * @deprecated Not used anywhere in Propel + */ + private $prefix; + + /** + * Get table prefix name. + * + * @deprecated Not used anywhere in Propel + * @return string A String with the prefix. + */ + public function getPrefix() + { + return $this->prefix; + } + + /** + * Set table prefix name. + * + * @deprecated Not used anywhere in Propel + * + * @param string $prefix The prefix for the table name (ie: SCARAB for + * SCARAB_PROJECT). + * + * @return void + */ + public function setPrefix($prefix) + { + $this->prefix = $prefix; + } + + /** + * Tell me if i have PREFIX in my string. + * + * @deprecated Not used anywhere in Propel + * + * @param string $data + * + * @return boolean True if prefix is contained in data. + */ + protected function hasPrefix($data) + { + return (strpos($data, $this->prefix) === 0); + } + + /** + * Removes the PREFIX if found + * + * @deprecated Not used anywhere in Propel + * + * @param string $data A String. + * + * @return string A String with data, but with prefix removed. + */ + protected function removePrefix($data) + { + return $this->hasPrefix($data) ? substr($data, strlen($this->prefix)) : $data; + } + + /** + * Removes the PREFIX, removes the underscores and makes + * first letter caps. + * + * SCARAB_FOO_BAR becomes FooBar. + * + * @deprecated Not used anywhere in Propel. At buildtime, use Column::generatePhpName() for that purpose + * + * @param string $data + * + * @return string A String with data processed. + */ + final public function removeUnderScores($data) + { + $out = ''; + $tmp = $this->removePrefix($data); + $tok = strtok($tmp, '_'); + while ($tok) { + $out .= ucfirst($tok); + $tok = strtok('_'); + } + + return $out; + } + + /** + * Makes the first letter caps and the rest lowercase. + * + * @deprecated Not used anywhere in Propel. + * + * @param string $data A String. + * + * @return string A String with data processed. + */ + private function firstLetterCaps($data) + { + return (ucfirst(strtolower($data))); + } } diff --git a/airtime_mvc/library/propel/runtime/lib/map/ValidatorMap.php b/airtime_mvc/library/propel/runtime/lib/map/ValidatorMap.php index 11f18c0a7..9d01a6d33 100644 --- a/airtime_mvc/library/propel/runtime/lib/map/ValidatorMap.php +++ b/airtime_mvc/library/propel/runtime/lib/map/ValidatorMap.php @@ -19,74 +19,74 @@ * These classes in themselves do not do any database metadata lookups. * * @author Michael Aichler - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.map */ class ValidatorMap { - /** rule name of this validator */ - private $name; - /** the dot-path to class to use for validator */ - private $classname; - /** value to check against */ - private $value; - /** execption message thrown on invalid input */ - private $message; - /** related column */ - private $column; + /** rule name of this validator */ + private $name; + /** the dot-path to class to use for validator */ + private $classname; + /** value to check against */ + private $value; + /** exception message thrown on invalid input */ + private $message; + /** related column */ + private $column; - public function __construct($containingColumn) - { - $this->column = $containingColumn; - } + public function __construct($containingColumn) + { + $this->column = $containingColumn; + } - public function getColumn() - { - return $this->column; - } + public function getColumn() + { + return $this->column; + } - public function getColumnName() - { - return $this->column->getColumnName(); - } + public function getColumnName() + { + return $this->column->getColumnName(); + } - public function setName($name) - { - $this->name = $name; - } + public function setName($name) + { + $this->name = $name; + } - public function setClass($classname) - { - $this->classname = $classname; - } + public function setClass($classname) + { + $this->classname = $classname; + } - public function setValue($value) - { - $this->value = $value; - } + public function setValue($value) + { + $this->value = $value; + } - public function setMessage($message) - { - $this->message = $message; - } + public function setMessage($message) + { + $this->message = $message; + } - public function getName() - { - return $this->name; - } + public function getName() + { + return $this->name; + } - public function getClass() - { - return $this->classname; - } + public function getClass() + { + return $this->classname; + } - public function getValue() - { - return $this->value; - } + public function getValue() + { + return $this->value; + } - public function getMessage() - { - return $this->message; - } + public function getMessage() + { + return $this->message; + } } diff --git a/airtime_mvc/library/propel/runtime/lib/om/BaseObject.php b/airtime_mvc/library/propel/runtime/lib/om/BaseObject.php index a0a7d126e..44b075599 100644 --- a/airtime_mvc/library/propel/runtime/lib/om/BaseObject.php +++ b/airtime_mvc/library/propel/runtime/lib/om/BaseObject.php @@ -12,308 +12,444 @@ * This class contains attributes and methods that are used by all * business objects within the system. * + * @method BaseObject fromXML(string $data) Populate the object from an XML string + * @method BaseObject fromYAML(string $data) Populate the object from a YAML string + * @method BaseObject fromJSON(string $data) Populate the object from a JSON string + * @method BaseObject fromCSV(string $data) Populate the object from a CSV string + * @method string toXML(boolean $includeLazyLoadColumns) Export the object to an XML string + * @method string toYAML(boolean $includeLazyLoadColumns) Export the object to a YAML string + * @method string toJSON(boolean $includeLazyLoadColumns) Export the object to a JSON string + * @method string toCSV(boolean $includeLazyLoadColumns) Export the object to a CSV string + * * @author Hans Lellelid (Propel) * @author Frank Y. Kim (Torque) * @author John D. McNally (Torque) - * @version $Revision: 1673 $ + * @version $Revision$ * @package propel.runtime.om */ abstract class BaseObject { - /** - * attribute to determine if this object has previously been saved. - * @var boolean - */ - protected $_new = true; + /** + * attribute to determine if this object has previously been saved. + * + * @var boolean + */ + protected $_new = true; - /** - * attribute to determine whether this object has been deleted. - * @var boolean - */ - protected $_deleted = false; + /** + * attribute to determine whether this object has been deleted. + * + * @var boolean + */ + protected $_deleted = false; - /** - * The columns that have been modified in current object. - * Tracking modified columns allows us to only update modified columns. - * @var array - */ - protected $modifiedColumns = array(); - - /** - * The (virtual) columns that are added at runtime - * The formatters can add supplementary columns based on a resultset - * @var array - */ - protected $virtualColumns = array(); - - /** - * Empty constructor (this allows people with their own BaseObject implementation to use its constructor) - */ - public function __construct() { + /** + * The columns that have been modified in current object. + * Tracking modified columns allows us to only update modified columns. + * + * @var array + */ + protected $modifiedColumns = array(); - } + /** + * The (virtual) columns that are added at runtime + * The formatters can add supplementary columns based on a resultset + * + * @var array + */ + protected $virtualColumns = array(); - /** - * Returns whether the object has been modified. - * - * @return boolean True if the object has been modified. - */ - public function isModified() - { - return !empty($this->modifiedColumns); - } + /** + * Empty constructor (this allows people with their own BaseObject implementation to use its constructor) + */ + public function __construct() + { + } - /** - * Has specified column been modified? - * - * @param string $col column fully qualified name (BasePeer::TYPE_COLNAME), e.g. Book::AUTHOR_ID - * @return boolean True if $col has been modified. - */ - public function isColumnModified($col) - { - return in_array($col, $this->modifiedColumns); - } + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } - /** - * Get the columns that have been modified in this object. - * @return array A unique list of the modified column names for this object. - */ - public function getModifiedColumns() - { - return array_unique($this->modifiedColumns); - } + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (BasePeer::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } - /** - * Returns whether the object has ever been saved. This will - * be false, if the object was retrieved from storage or was created - * and then saved. - * - * @return true, if the object has never been persisted. - */ - public function isNew() - { - return $this->_new; - } + /** + * Get the columns that have been modified in this object. + * + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } - /** - * Setter for the isNew attribute. This method will be called - * by Propel-generated children and Peers. - * - * @param boolean $b the state of the object. - */ - public function setNew($b) - { - $this->_new = (boolean) $b; - } + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->_new; + } - /** - * Whether this object has been deleted. - * @return boolean The deleted state of this object. - */ - public function isDeleted() - { - return $this->_deleted; - } + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and Peers. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->_new = (boolean) $b; + } - /** - * Specify whether this object has been deleted. - * @param boolean $b The deleted state of this object. - * @return void - */ - public function setDeleted($b) - { - $this->_deleted = (boolean) $b; - } + /** + * Whether this object has been deleted. + * + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->_deleted; + } - /** - * Code to be run before persisting the object - * @param PropelPDO $con - * @return bloolean - */ - public function preSave(PropelPDO $con = null) - { - return true; - } + /** + * Specify whether this object has been deleted. + * + * @param boolean $b The deleted state of this object. + * + * @return void + */ + public function setDeleted($b) + { + $this->_deleted = (boolean) $b; + } - /** - * Code to be run after persisting the object - * @param PropelPDO $con - */ - public function postSave(PropelPDO $con = null) { } + /** + * Code to be run before persisting the object + * + * @param PropelPDO $con + * + * @return boolean + */ + public function preSave(PropelPDO $con = null) + { + return true; + } - /** - * Code to be run before inserting to database - * @param PropelPDO $con - * @return boolean - */ - public function preInsert(PropelPDO $con = null) - { - return true; - } - - /** - * Code to be run after inserting to database - * @param PropelPDO $con - */ - public function postInsert(PropelPDO $con = null) { } + /** + * Code to be run after persisting the object + * + * @param PropelPDO $con + */ + public function postSave(PropelPDO $con = null) + { + } - /** - * Code to be run before updating the object in database - * @param PropelPDO $con - * @return boolean - */ - public function preUpdate(PropelPDO $con = null) - { - return true; - } + /** + * Code to be run before inserting to database + * + * @param PropelPDO $con + * + * @return boolean + */ + public function preInsert(PropelPDO $con = null) + { + return true; + } - /** - * Code to be run after updating the object in database - * @param PropelPDO $con - */ - public function postUpdate(PropelPDO $con = null) { } + /** + * Code to be run after inserting to database + * + * @param PropelPDO $con + */ + public function postInsert(PropelPDO $con = null) + { + } - /** - * Code to be run before deleting the object in database - * @param PropelPDO $con - * @return boolean - */ - public function preDelete(PropelPDO $con = null) - { - return true; - } + /** + * Code to be run before updating the object in database + * + * @param PropelPDO $con + * + * @return boolean + */ + public function preUpdate(PropelPDO $con = null) + { + return true; + } - /** - * Code to be run after deleting the object in database - * @param PropelPDO $con - */ - public function postDelete(PropelPDO $con = null) { } - - /** - * Sets the modified state for the object to be false. - * @param string $col If supplied, only the specified column is reset. - * @return void - */ - public function resetModified($col = null) - { - if ($col !== null) { - while (($offset = array_search($col, $this->modifiedColumns)) !== false) { - array_splice($this->modifiedColumns, $offset, 1); - } - } else { - $this->modifiedColumns = array(); - } - } + /** + * Code to be run after updating the object in database + * + * @param PropelPDO $con + */ + public function postUpdate(PropelPDO $con = null) + { + } - /** - * Compares this with another BaseObject instance. If - * obj is an instance of BaseObject, delegates to - * equals(BaseObject). Otherwise, returns false. - * - * @param obj The object to compare to. - * @return Whether equal to the object specified. - */ - public function equals($obj) - { - $thisclazz = get_class($this); - if (is_object($obj) && $obj instanceof $thisclazz) { - if ($this === $obj) { - return true; - } elseif ($this->getPrimaryKey() === null || $obj->getPrimaryKey() === null) { - return false; - } else { - return ($this->getPrimaryKey() === $obj->getPrimaryKey()); - } - } else { - return false; - } - } + /** + * Code to be run before deleting the object in database + * + * @param PropelPDO $con + * + * @return boolean + */ + public function preDelete(PropelPDO $con = null) + { + return true; + } - /** - * If the primary key is not null, return the hashcode of the - * primary key. Otherwise calls Object.hashCode(). - * - * @return int Hashcode - */ - public function hashCode() - { - $ok = $this->getPrimaryKey(); - if ($ok === null) { - return crc32(serialize($this)); - } - return crc32(serialize($ok)); // serialize because it could be an array ("ComboKey") - } - - /** - * Get the associative array of the virtual columns in this object - * - * @param string $name The virtual column name - * - * @return array - */ - public function getVirtualColumns() - { - return $this->virtualColumns; - } + /** + * Code to be run after deleting the object in database + * + * @param PropelPDO $con + */ + public function postDelete(PropelPDO $con = null) + { + } - /** - * Checks the existence of a virtual column in this object - * - * @return boolean - */ - public function hasVirtualColumn($name) - { - return array_key_exists($name, $this->virtualColumns); - } - - /** - * Get the value of a virtual column in this object - * - * @return mixed - */ - public function getVirtualColumn($name) - { - if (!$this->hasVirtualColumn($name)) { - throw new PropelException('Cannot get value of inexistent virtual column ' . $name); - } - return $this->virtualColumns[$name]; - } - - /** - * Get the value of a virtual column in this object - * - * @param string $name The virtual column name - * @param mixed $value The value to give to the virtual column - * - * @return BaseObject The current object, for fluid interface - */ - public function setVirtualColumn($name, $value) - { - $this->virtualColumns[$name] = $value; - return $this; - } + /** + * Code to be run after object hydration + * + * @param PropelPDO $con + */ + public function postHydrate($row, $startcol = 0, $rehydrate = false) + { + } - /** - * Logs a message using Propel::log(). - * - * @param string $msg - * @param int $priority One of the Propel::LOG_* logging levels - * @return boolean - */ - protected function log($msg, $priority = Propel::LOG_INFO) - { - return Propel::log(get_class($this) . ': ' . $msg, $priority); - } - - /** - * Clean up internal collections prior to serializing - * Avoids recursive loops that turn into segmentation faults when serializing - */ - public function __sleep() - { - $this->clearAllReferences(); - return array_keys(get_object_vars($this)); - } + /** + * Sets the modified state for the object to be false. + * + * @param string $col If supplied, only the specified column is reset. + * + * @return void + */ + public function resetModified($col = null) + { + if ($col !== null) { + while (($offset = array_search($col, $this->modifiedColumns)) !== false) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + /** + * Compares this with another BaseObject instance. If + * obj is an instance of BaseObject, delegates to + * equals(BaseObject). Otherwise, returns false. + * + * @param obj The object to compare to. + * + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclass = get_class($this); + if (is_object($obj) && $obj instanceof $thisclass) { + if ($this === $obj) { + return true; + } elseif ($this->getPrimaryKey() === null || $obj->getPrimaryKey() === null) { + return false; + } else { + return ($this->getPrimaryKey() === $obj->getPrimaryKey()); + } + } else { + return false; + } + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException('Cannot get value of inexistent virtual column ' . $name); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return BaseObject The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A PropelParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return BaseObject The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof PropelParser) { + $parser = PropelParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), BasePeer::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A PropelParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof PropelParser) { + $parser = PropelParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you use a custom BaseObject + * + * @param string $name + * @param mixed $params + * + * @return array|string + * + * @throws PropelException + */ + public function __call($name, $params) + { + if (preg_match('/get(\w+)/', $name, $matches)) { + $virtualColumn = $matches[1]; + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + if (preg_match('/^from(\w+)$/', $name, $matches)) { + return $this->importFrom($matches[1], reset($params)); + } + if (preg_match('/^to(\w+)$/', $name, $matches)) { + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($matches[1], $includeLazyLoadColumns); + } + throw new PropelException('Call to undefined method: ' . $name); + } } diff --git a/airtime_mvc/library/propel/runtime/lib/om/NestedSetRecursiveIterator.php b/airtime_mvc/library/propel/runtime/lib/om/NestedSetRecursiveIterator.php index 97a83028c..f1c501f74 100644 --- a/airtime_mvc/library/propel/runtime/lib/om/NestedSetRecursiveIterator.php +++ b/airtime_mvc/library/propel/runtime/lib/om/NestedSetRecursiveIterator.php @@ -12,75 +12,78 @@ * Pre-order node iterator for Node objects. * * @author Heltem - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.om */ class NestedSetRecursiveIterator implements RecursiveIterator { - protected $topNode = null; + protected $topNode = null; - protected $curNode = null; + protected $curNode = null; - public function __construct($node) - { - $this->topNode = $node; - $this->curNode = $node; - } + public function __construct($node) + { + $this->topNode = $node; + $this->curNode = $node; + } - public function rewind() - { - $this->curNode = $this->topNode; - } + public function rewind() + { + $this->curNode = $this->topNode; + } - public function valid() - { - return ($this->curNode !== null); - } + public function valid() + { + return ($this->curNode !== null); + } - public function current() - { - return $this->curNode; - } + public function current() + { + return $this->curNode; + } - public function key() - { - $method = method_exists($this->curNode, 'getPath') ? 'getPath' : 'getAncestors'; - $key = array(); - foreach ($this->curNode->$method() as $node) { - $key[] = $node->getPrimaryKey(); - } - return implode('.', $key); - } + public function key() + { + $method = method_exists($this->curNode, 'getPath') ? 'getPath' : 'getAncestors'; + $key = array(); + foreach ($this->curNode->$method() as $node) { + $key[] = $node->getPrimaryKey(); + } - public function next() - { - $nextNode = null; - $method = method_exists($this->curNode, 'retrieveNextSibling') ? 'retrieveNextSibling' : 'getNextSibling'; - if ($this->valid()) { - while (null === $nextNode) { - if (null === $this->curNode) { - break; - } + return implode('.', $key); + } - if ($this->curNode->hasNextSibling()) { - $nextNode = $this->curNode->$method(); - } else { - break; - } - } - $this->curNode = $nextNode; - } - return $this->curNode; - } + public function next() + { + $nextNode = null; + $method = method_exists($this->curNode, 'retrieveNextSibling') ? 'retrieveNextSibling' : 'getNextSibling'; + if ($this->valid()) { + while (null === $nextNode) { + if (null === $this->curNode) { + break; + } - public function hasChildren() - { - return $this->curNode->hasChildren(); - } + if ($this->curNode->hasNextSibling()) { + $nextNode = $this->curNode->$method(); + } else { + break; + } + } + $this->curNode = $nextNode; + } - public function getChildren() - { - $method = method_exists($this->curNode, 'retrieveFirstChild') ? 'retrieveFirstChild' : 'getFirstChild'; - return new NestedSetRecursiveIterator($this->curNode->$method()); - } + return $this->curNode; + } + + public function hasChildren() + { + return $this->curNode->hasChildren(); + } + + public function getChildren() + { + $method = method_exists($this->curNode, 'retrieveFirstChild') ? 'retrieveFirstChild' : 'getFirstChild'; + + return new NestedSetRecursiveIterator($this->curNode->$method()); + } } diff --git a/airtime_mvc/library/propel/runtime/lib/om/NodeObject.php b/airtime_mvc/library/propel/runtime/lib/om/NodeObject.php index 9353fe671..203295a2b 100644 --- a/airtime_mvc/library/propel/runtime/lib/om/NodeObject.php +++ b/airtime_mvc/library/propel/runtime/lib/om/NodeObject.php @@ -13,312 +13,344 @@ * business objects within the system to handle Node object. * * @author Heltem (Propel) - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.om */ interface NodeObject extends IteratorAggregate { - /** - * If object is saved without left/right values, set them as undefined (0) - * - * @param PropelPDO $con Connection to use. - * @return void - * @throws PropelException - */ - public function save(PropelPDO $con = null); + /** + * If object is saved without left/right values, set them as undefined (0) + * + * @param PropelPDO $con Connection to use. + * + * @return void + * @throws PropelException + */ + public function save(PropelPDO $con = null); - /** - * Delete node and descendants - * - * @param PropelPDO $con Connection to use. - * @return void - * @throws PropelException - */ - public function delete(PropelPDO $con = null); + /** + * Delete node and descendants + * + * @param PropelPDO $con Connection to use. + * + * @return void + * @throws PropelException + */ + public function delete(PropelPDO $con = null); - /** - * Sets node properties to make it a root node. - * - * @return object The current object (for fluent API support) - * @throws PropelException - */ - public function makeRoot(); + /** + * Sets node properties to make it a root node. + * + * @return object The current object (for fluent API support) + * @throws PropelException + */ + public function makeRoot(); - /** - * Gets the level if set, otherwise calculates this and returns it - * - * @param PropelPDO $con Connection to use. - * @return int - */ - public function getLevel(PropelPDO $con = null); + /** + * Gets the level if set, otherwise calculates this and returns it + * + * @param PropelPDO $con Connection to use. + * + * @return int + */ + public function getLevel(PropelPDO $con = null); - /** - * Get the path to the node in the tree - * - * @param PropelPDO $con Connection to use. - * @return array - */ - public function getPath(PropelPDO $con = null); + /** + * Get the path to the node in the tree + * + * @param PropelPDO $con Connection to use. + * + * @return array + */ + public function getPath(PropelPDO $con = null); - /** - * Gets the number of children for the node (direct descendants) - * - * @param PropelPDO $con Connection to use. - * @return int - */ - public function getNumberOfChildren(PropelPDO $con = null); + /** + * Gets the number of children for the node (direct descendants) + * + * @param PropelPDO $con Connection to use. + * + * @return int + */ + public function getNumberOfChildren(PropelPDO $con = null); - /** - * Gets the total number of desceandants for the node - * - * @param PropelPDO $con Connection to use. - * @return int - */ - public function getNumberOfDescendants(PropelPDO $con = null); + /** + * Gets the total number of descendants for the node + * + * @param PropelPDO $con Connection to use. + * + * @return int + */ + public function getNumberOfDescendants(PropelPDO $con = null); - /** - * Gets the children for the node - * - * @param PropelPDO $con Connection to use. - * @return array - */ - public function getChildren(PropelPDO $con = null); + /** + * Gets the children for the node + * + * @param PropelPDO $con Connection to use. + * + * @return array + */ + public function getChildren(PropelPDO $con = null); - /** - * Gets the descendants for the node - * - * @param PropelPDO $con Connection to use. - * @return array - */ - public function getDescendants(PropelPDO $con = null); + /** + * Gets the descendants for the node + * + * @param PropelPDO $con Connection to use. + * + * @return array + */ + public function getDescendants(PropelPDO $con = null); - /** - * Sets the level of the node in the tree - * - * @param int $v new value - * @return object The current object (for fluent API support) - */ - public function setLevel($level); + /** + * Sets the level of the node in the tree + * + * @param int $level new value + * + * @return object The current object (for fluent API support) + */ + public function setLevel($level); - /** - * Sets the children array of the node in the tree - * - * @param array of Node $children array of Propel node object - * @return object The current object (for fluent API support) - */ - public function setChildren(array $children); + /** + * Sets the children array of the node in the tree + * + * @param Node[] $children array of Propel node object + * + * @return object The current object (for fluent API support) + */ + public function setChildren(array $children); - /** - * Sets the parentNode of the node in the tree - * - * @param Node $parent Propel node object - * @return object The current object (for fluent API support) - */ - public function setParentNode(NodeObject $parent = null); + /** + * Sets the parentNode of the node in the tree + * + * @param Node $parent Propel node object + * + * @return object The current object (for fluent API support) + */ + public function setParentNode(NodeObject $parent = null); - /** - * Sets the previous sibling of the node in the tree - * - * @param Node $node Propel node object - * @return object The current object (for fluent API support) - */ - public function setPrevSibling(NodeObject $node = null); + /** + * Sets the previous sibling of the node in the tree + * + * @param Node $node Propel node object + * + * @return object The current object (for fluent API support) + */ + public function setPrevSibling(NodeObject $node = null); - /** - * Sets the next sibling of the node in the tree - * - * @param Node $node Propel node object - * @return object The current object (for fluent API support) - */ - public function setNextSibling(NodeObject $node = null); + /** + * Sets the next sibling of the node in the tree + * + * @param Node $node Propel node object + * + * @return object The current object (for fluent API support) + */ + public function setNextSibling(NodeObject $node = null); - /** - * Determines if the node is the root node - * - * @return bool - */ - public function isRoot(); + /** + * Determines if the node is the root node + * + * @return bool + */ + public function isRoot(); - /** - * Determines if the node is a leaf node - * - * @return bool - */ - public function isLeaf(); + /** + * Determines if the node is a leaf node + * + * @return bool + */ + public function isLeaf(); - /** - * Tests if object is equal to $node - * - * @param object $node Propel object for node to compare to - * @return bool - */ - public function isEqualTo(NodeObject $node); + /** + * Tests if object is equal to $node + * + * @param object $node Propel object for node to compare to + * + * @return bool + */ + public function isEqualTo(NodeObject $node); - /** - * Tests if object has an ancestor - * - * @param PropelPDO $con Connection to use. - * @return bool - */ - public function hasParent(PropelPDO $con = null); + /** + * Tests if object has an ancestor + * + * @param PropelPDO $con Connection to use. + * + * @return bool + */ + public function hasParent(PropelPDO $con = null); - /** - * Determines if the node has children / descendants - * - * @return bool - */ - public function hasChildren(); + /** + * Determines if the node has children / descendants + * + * @return bool + */ + public function hasChildren(); - /** - * Determines if the node has previous sibling - * - * @param PropelPDO $con Connection to use. - * @return bool - */ - public function hasPrevSibling(PropelPDO $con = null); + /** + * Determines if the node has previous sibling + * + * @param PropelPDO $con Connection to use. + * + * @return bool + */ + public function hasPrevSibling(PropelPDO $con = null); - /** - * Determines if the node has next sibling - * - * @param PropelPDO $con Connection to use. - * @return bool - */ - public function hasNextSibling(PropelPDO $con = null); + /** + * Determines if the node has next sibling + * + * @param PropelPDO $con Connection to use. + * + * @return bool + */ + public function hasNextSibling(PropelPDO $con = null); - /** - * Gets ancestor for the given node if it exists - * - * @param PropelPDO $con Connection to use. - * @return mixed Propel object if exists else false - */ - public function retrieveParent(PropelPDO $con = null); + /** + * Gets ancestor for the given node if it exists + * + * @param PropelPDO $con Connection to use. + * + * @return mixed Propel object if exists else false + */ + public function retrieveParent(PropelPDO $con = null); - /** - * Gets first child if it exists - * - * @param PropelPDO $con Connection to use. - * @return mixed Propel object if exists else false - */ - public function retrieveFirstChild(PropelPDO $con = null); + /** + * Gets first child if it exists + * + * @param PropelPDO $con Connection to use. + * + * @return mixed Propel object if exists else false + */ + public function retrieveFirstChild(PropelPDO $con = null); - /** - * Gets last child if it exists - * - * @param PropelPDO $con Connection to use. - * @return mixed Propel object if exists else false - */ - public function retrieveLastChild(PropelPDO $con = null); + /** + * Gets last child if it exists + * + * @param PropelPDO $con Connection to use. + * + * @return mixed Propel object if exists else false + */ + public function retrieveLastChild(PropelPDO $con = null); - /** - * Gets prev sibling for the given node if it exists - * - * @param PropelPDO $con Connection to use. - * @return mixed Propel object if exists else false - */ - public function retrievePrevSibling(PropelPDO $con = null); + /** + * Gets prev sibling for the given node if it exists + * + * @param PropelPDO $con Connection to use. + * + * @return mixed Propel object if exists else false + */ + public function retrievePrevSibling(PropelPDO $con = null); - /** - * Gets next sibling for the given node if it exists - * - * @param PropelPDO $con Connection to use. - * @return mixed Propel object if exists else false - */ - public function retrieveNextSibling(PropelPDO $con = null); + /** + * Gets next sibling for the given node if it exists + * + * @param PropelPDO $con Connection to use. + * + * @return mixed Propel object if exists else false + */ + public function retrieveNextSibling(PropelPDO $con = null); - /** - * Inserts as first child of destination node $parent - * - * @param object $parent Propel object for given destination node - * @param PropelPDO $con Connection to use. - * @return object The current object (for fluent API support) - */ - public function insertAsFirstChildOf(NodeObject $parent, PropelPDO $con = null); + /** + * Inserts as first child of destination node $parent + * + * @param object $parent Propel object for given destination node + * @param PropelPDO $con Connection to use. + * + * @return object The current object (for fluent API support) + */ + public function insertAsFirstChildOf(NodeObject $parent, PropelPDO $con = null); - /** - * Inserts as last child of destination node $parent - * - * @param object $parent Propel object for given destination node - * @param PropelPDO $con Connection to use. - * @return object The current object (for fluent API support) - */ - public function insertAsLastChildOf(NodeObject $parent, PropelPDO $con = null); + /** + * Inserts as last child of destination node $parent + * + * @param object $parent Propel object for given destination node + * @param PropelPDO $con Connection to use. + * + * @return object The current object (for fluent API support) + */ + public function insertAsLastChildOf(NodeObject $parent, PropelPDO $con = null); - /** - * Inserts node as previous sibling to destination node $dest - * - * @param object $dest Propel object for given destination node - * @param PropelPDO $con Connection to use. - * @return object The current object (for fluent API support) - */ - public function insertAsPrevSiblingOf(NodeObject $dest, PropelPDO $con = null); + /** + * Inserts node as previous sibling to destination node $dest + * + * @param object $dest Propel object for given destination node + * @param PropelPDO $con Connection to use. + * + * @return object The current object (for fluent API support) + */ + public function insertAsPrevSiblingOf(NodeObject $dest, PropelPDO $con = null); - /** - * Inserts node as next sibling to destination node $dest - * - * @param object $dest Propel object for given destination node - * @param PropelPDO $con Connection to use. - * @return object The current object (for fluent API support) - */ - public function insertAsNextSiblingOf(NodeObject $dest, PropelPDO $con = null); + /** + * Inserts node as next sibling to destination node $dest + * + * @param object $dest Propel object for given destination node + * @param PropelPDO $con Connection to use. + * + * @return object The current object (for fluent API support) + */ + public function insertAsNextSiblingOf(NodeObject $dest, PropelPDO $con = null); - /** - * Moves node to be first child of $parent - * - * @param object $parent Propel object for destination node - * @param PropelPDO $con Connection to use. - * @return void - */ - public function moveToFirstChildOf(NodeObject $parent, PropelPDO $con = null); + /** + * Moves node to be first child of $parent + * + * @param object $parent Propel object for destination node + * @param PropelPDO $con Connection to use. + * + * @return void + */ + public function moveToFirstChildOf(NodeObject $parent, PropelPDO $con = null); - /** - * Moves node to be last child of $parent - * - * @param object $parent Propel object for destination node - * @param PropelPDO $con Connection to use. - * @return void - */ - public function moveToLastChildOf(NodeObject $parent, PropelPDO $con = null); + /** + * Moves node to be last child of $parent + * + * @param object $parent Propel object for destination node + * @param PropelPDO $con Connection to use. + * + * @return void + */ + public function moveToLastChildOf(NodeObject $parent, PropelPDO $con = null); - /** - * Moves node to be prev sibling to $dest - * - * @param object $dest Propel object for destination node - * @param PropelPDO $con Connection to use. - * @return void - */ - public function moveToPrevSiblingOf(NodeObject $dest, PropelPDO $con = null); + /** + * Moves node to be prev sibling to $dest + * + * @param object $dest Propel object for destination node + * @param PropelPDO $con Connection to use. + * + * @return void + */ + public function moveToPrevSiblingOf(NodeObject $dest, PropelPDO $con = null); - /** - * Moves node to be next sibling to $dest - * - * @param object $dest Propel object for destination node - * @param PropelPDO $con Connection to use. - * @return void - */ - public function moveToNextSiblingOf(NodeObject $dest, PropelPDO $con = null); + /** + * Moves node to be next sibling to $dest + * + * @param object $dest Propel object for destination node + * @param PropelPDO $con Connection to use. + * + * @return void + */ + public function moveToNextSiblingOf(NodeObject $dest, PropelPDO $con = null); - /** - * Inserts node as parent of given node. - * - * @param object $node Propel object for given destination node - * @param PropelPDO $con Connection to use. - * @return void - * @throws Exception When trying to insert node as parent of a root node - */ - public function insertAsParentOf(NodeObject $node, PropelPDO $con = null); + /** + * Inserts node as parent of given node. + * + * @param object $node Propel object for given destination node + * @param PropelPDO $con Connection to use. + * + * @return void + * @throws Exception When trying to insert node as parent of a root node + */ + public function insertAsParentOf(NodeObject $node, PropelPDO $con = null); - /** - * Wraps the getter for the scope value - * - * @return int - */ - public function getScopeIdValue(); + /** + * Wraps the getter for the scope value + * + * @return int + */ + public function getScopeIdValue(); - /** - * Set the value of scope column - * - * @param int $v new value - * @return object The current object (for fluent API support) - */ - public function setScopeIdValue($v); + /** + * Set the value of scope column + * + * @param int $v new value + * + * @return object The current object (for fluent API support) + */ + public function setScopeIdValue($v); } // NodeObject diff --git a/airtime_mvc/library/propel/runtime/lib/om/Persistent.php b/airtime_mvc/library/propel/runtime/lib/om/Persistent.php index 02d6c20d9..64925a42b 100644 --- a/airtime_mvc/library/propel/runtime/lib/om/Persistent.php +++ b/airtime_mvc/library/propel/runtime/lib/om/Persistent.php @@ -14,95 +14,103 @@ * @author Hans Lellelid (Propel) * @author John D. McNally (Torque) * @author Fedor K. (Torque) - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.om */ interface Persistent { - /** - * getter for the object primaryKey. - * - * @return ObjectKey the object primaryKey as an Object - */ - public function getPrimaryKey(); + /** + * getter for the object primaryKey. + * + * @return ObjectKey the object primaryKey as an Object + */ + public function getPrimaryKey(); - /** - * Sets the PrimaryKey for the object. - * - * @param mixed $primaryKey The new PrimaryKey object or string (result of PrimaryKey.toString()). - * @return void - * @throws Exception, This method might throw an exceptions - */ - public function setPrimaryKey($primaryKey); + /** + * Sets the PrimaryKey for the object. + * + * @param mixed $primaryKey The new PrimaryKey object or string (result of PrimaryKey.toString()). + * + * @return void + * @throws Exception, This method might throw an exceptions + */ + public function setPrimaryKey($primaryKey); + /** + * Returns whether the object has been modified, since it was + * last retrieved from storage. + * + * @return boolean True if the object has been modified. + */ + public function isModified(); - /** - * Returns whether the object has been modified, since it was - * last retrieved from storage. - * - * @return boolean True if the object has been modified. - */ - public function isModified(); + /** + * Has specified column been modified? + * + * @param string $col + * + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col); - /** - * Has specified column been modified? - * - * @param string $col - * @return boolean True if $col has been modified. - */ - public function isColumnModified($col); + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean True, if the object has never been persisted. + */ + public function isNew(); - /** - * Returns whether the object has ever been saved. This will - * be false, if the object was retrieved from storage or was created - * and then saved. - * - * @return boolean True, if the object has never been persisted. - */ - public function isNew(); + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and Peers. + * + * @param boolean $b the state of the object. + */ + public function setNew($b); - /** - * Setter for the isNew attribute. This method will be called - * by Propel-generated children and Peers. - * - * @param boolean $b the state of the object. - */ - public function setNew($b); + /** + * Resets (to false) the "modified" state for this object. + * + * @return void + */ + public function resetModified(); - /** - * Resets (to false) the "modified" state for this object. - * - * @return void - */ - public function resetModified(); + /** + * Whether this object has been deleted. + * + * @return boolean The deleted state of this object. + */ + public function isDeleted(); - /** - * Whether this object has been deleted. - * @return boolean The deleted state of this object. - */ - public function isDeleted(); + /** + * Specify whether this object has been deleted. + * + * @param boolean $b The deleted state of this object. + * + * @return void + */ + public function setDeleted($b); - /** - * Specify whether this object has been deleted. - * @param boolean $b The deleted state of this object. - * @return void - */ - public function setDeleted($b); + /** + * Deletes the object. + * + * @param PropelPDO $con + * + * @return void + * @throws Exception + */ + public function delete(PropelPDO $con = null); - /** - * Deletes the object. - * @param PropelPDO $con - * @return void - * @throws Exception - */ - public function delete(PropelPDO $con = null); - - /** - * Saves the object. - * @param PropelPDO $con - * @return void - * @throws Exception - */ - public function save(PropelPDO $con = null); + /** + * Saves the object. + * + * @param PropelPDO $con + * + * @return void + * @throws Exception + */ + public function save(PropelPDO $con = null); } diff --git a/airtime_mvc/library/propel/runtime/lib/om/PreOrderNodeIterator.php b/airtime_mvc/library/propel/runtime/lib/om/PreOrderNodeIterator.php index 0afde7f91..4e91abb78 100644 --- a/airtime_mvc/library/propel/runtime/lib/om/PreOrderNodeIterator.php +++ b/airtime_mvc/library/propel/runtime/lib/om/PreOrderNodeIterator.php @@ -12,67 +12,73 @@ * Pre-order node iterator for Node objects. * * @author Dave Lawson - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.om */ class PreOrderNodeIterator implements Iterator { - private $topNode = null; + private $topNode = null; - private $curNode = null; + private $curNode = null; - private $querydb = false; + private $querydb = false; - private $con = null; + private $con = null; - public function __construct($node, $opts) { - $this->topNode = $node; - $this->curNode = $node; + public function __construct($node, $opts) + { + $this->topNode = $node; + $this->curNode = $node; - if (isset($opts['con'])) - $this->con = $opts['con']; + if (isset($opts['con'])) { + $this->con = $opts['con']; + } - if (isset($opts['querydb'])) - $this->querydb = $opts['querydb']; - } + if (isset($opts['querydb'])) { + $this->querydb = $opts['querydb']; + } + } - public function rewind() { - $this->curNode = $this->topNode; - } + public function rewind() + { + $this->curNode = $this->topNode; + } - public function valid() { - return ($this->curNode !== null); - } + public function valid() + { + return ($this->curNode !== null); + } - public function current() { - return $this->curNode; - } + public function current() + { + return $this->curNode; + } - public function key() { - return $this->curNode->getNodePath(); - } + public function key() + { + return $this->curNode->getNodePath(); + } - public function next() { + public function next() + { + if ($this->valid()) { + $nextNode = $this->curNode->getFirstChildNode($this->querydb, $this->con); - if ($this->valid()) - { - $nextNode = $this->curNode->getFirstChildNode($this->querydb, $this->con); + while ($nextNode === null) { + if ($this->curNode === null || $this->curNode->equals($this->topNode)) { + break; + } - while ($nextNode === null) - { - if ($this->curNode === null || $this->curNode->equals($this->topNode)) - break; + $nextNode = $this->curNode->getSiblingNode(false, $this->querydb, $this->con); - $nextNode = $this->curNode->getSiblingNode(false, $this->querydb, $this->con); + if ($nextNode === null) { + $this->curNode = $this->curNode->getParentNode($this->querydb, $this->con); + } + } - if ($nextNode === null) - $this->curNode = $this->curNode->getParentNode($this->querydb, $this->con); - } - - $this->curNode = $nextNode; - } - - return $this->curNode; - } + $this->curNode = $nextNode; + } + return $this->curNode; + } } diff --git a/airtime_mvc/library/propel/runtime/lib/parser/PropelCSVParser.php b/airtime_mvc/library/propel/runtime/lib/parser/PropelCSVParser.php new file mode 100644 index 000000000..37e213f71 --- /dev/null +++ b/airtime_mvc/library/propel/runtime/lib/parser/PropelCSVParser.php @@ -0,0 +1,314 @@ +formatRow(array_keys(reset($array))), $this->delimiter); + } + foreach ($array as $row) { + $rows[] = implode($this->formatRow($row), $this->delimiter); + } + } else { + if ($includeHeading) { + $rows[] = implode($this->formatRow(array_keys($array)), $this->delimiter); + } + $rows[] = implode($this->formatRow($array), $this->delimiter); + } + + return implode($rows, $this->lineTerminator) . $this->lineTerminator; + } + + public function listFromArray($array) + { + return $this->fromArray($array, true); + } + + /** + * Accepts a row of data and returns it formatted + * + * @param array $row An array of data to be formatted for output to the file + * + * @return array The formatted array + */ + protected function formatRow($row) + { + foreach ($row as &$column) { + if (!is_scalar($column)) { + $column = $this->serialize($column); + } + switch ($this->quoting) { + case self::QUOTE_NONE: + // do nothing... no quoting is happening here + break; + case self::QUOTE_ALL: + $column = $this->quote($this->escape($column)); + break; + case self::QUOTE_NONNUMERIC: + if (preg_match("/[^0-9]/", $column)) { + $column = $this->quote($this->escape($column)); + } + break; + case self::QUOTE_MINIMAL: + default: + if ($this->containsSpecialChars($column)) { + $column = $this->quote($this->escape($column)); + } + break; + } + } + + return $row; + } + + /** + * Escapes a column (escapes quotechar with escapechar) + * + * @param string $input A single value to be escaped for output + * + * @return string Escaped input value + */ + protected function escape($input) + { + return str_replace( + $this->quotechar, + $this->escapechar . $this->quotechar, + $input + ); + } + + /** + * Quotes a column with quotechar + * + * @param string $input A single value to be quoted for output + * + * @return string Quoted input value + */ + protected function quote($input) + { + return $this->quotechar . $input . $this->quotechar; + } + + /** + * Returns true if input contains quotechar, delimiter or any of the characters in lineTerminator + * + * @param string $input A single value to be checked for special characters + * + * @return boolean True if contains any special characters + */ + protected function containsSpecialChars($input) + { + $special_chars = str_split($this->lineTerminator, 1); + $special_chars[] = $this->quotechar; + $special_chars[] = $this->delimiter; + foreach ($special_chars as $char) { + if (strpos($input, $char) !== false) { + return true; + } + } + + return false; + } + + /** + * Serializes a value to place it into a CSV output + * + * @param mixed $input + * + * @return string + */ + protected function serialize($input) + { + return serialize($input); + } + + /** + * Alias for PropelCSVParser::fromArray() + * + * @param array $array Source data to convert + * @param boolean $isList Whether the input data contains more than one row + * @param boolean $includeHeading Whether the output should contain a heading line + * + * @return string Converted data, as a CSV string + */ + public function toCSV($array, $isList = false, $includeHeading = true) + { + return $this->fromArray($array, $isList, $includeHeading); + } + + /** + * Converts data from CSV to an associative array. + * + * @param string $data Source data to convert, as a CSV string + * @param boolean $isList Whether the input data contains more than one row + * @param boolean $includeHeading Whether the input contains a heading line + * + * @return array Converted data + */ + public function toArray($data, $isList = false, $includeHeading = true) + { + $rows = explode($this->lineTerminator, $data); + if ($includeHeading) { + $heading = array_shift($rows); + $keys = explode($this->delimiter, $heading); + } else { + $keys = range(0, count($this->getColumns($rows[0])) - 1); + } + if ($isList) { + $array = array(); + foreach ($rows as $row) { + $values = $this->cleanupRow($this->getColumns($row)); + if ($values !== array()) { + $array[] = array_combine($keys, $values); + } + } + } else { + $values = $this->cleanupRow($this->getColumns(array_shift($rows))); + if ($keys === array('') && $values === array()) { + $array = array(); + } else { + if (count($keys) > count($values)) { + // empty values at the end of the row are not match bu the getColumns() regexp + $values = array_pad($values, count($keys), null); + } + $array = array_combine($keys, $values); + } + } + + return $array; + } + + public function listToArray($array) + { + return $this->toArray($array, true); + } + + protected function getColumns($row) + { + $delim = preg_quote($this->delimiter, '/'); + preg_match_all('/(".+?"|[^' . $delim . ']+)(' . $delim . '|$)/', $row, $matches); + + return $matches[1]; + } + + /** + * Accepts a formatted row of data and returns it raw + * + * @param array An array of data from a CSV output + * + * @return array The cleaned up array + */ + protected function cleanupRow($row) + { + foreach ($row as $key => $column) { + if ($this->isQuoted($column)) { + $column = $this->unescape($this->unquote($column)); + } + if ($this->isSerialized($column)) { + $column = $this->unserialize($column); + } + if ($column === 'N;') { + $column = null; + } + $row[$key] = $column; + } + + return $row; + } + + protected function isQuoted($input) + { + $quote = preg_quote($this->quotechar, '/'); + + return preg_match('/^' . $quote . '.*' . $quote . '$/', $input); + } + + protected function unescape($input) + { + return str_replace( + $this->escapechar . $this->quotechar, + $this->quotechar, + $input + ); + } + + protected function unquote($input) + { + return trim($input, $this->quotechar); + } + + /** + * Checks whether a value from CSV output is serialized + */ + protected function isSerialized($input) + { + return preg_match('/^\w\:\d+\:\{/', $input); + } + + /** + * Unserializes a value from CSV output + * + * @param string $input + * + * @return mixed + */ + protected function unserialize($input) + { + return unserialize($input); + } + + /** + * Alias for PropelCSVParser::toArray() + * + * @param string $data Source data to convert, as a CSV string + * @param boolean $isList Whether the input data contains more than one row + * @param boolean $includeHeading Whether the input contains a heading line + * + * @return array Converted data + */ + public function fromCSV($data, $isList = false, $includeHeading = true) + { + return $this->toArray($data, $isList, $includeHeading); + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/parser/PropelJSONParser.php b/airtime_mvc/library/propel/runtime/lib/parser/PropelJSONParser.php new file mode 100644 index 000000000..8fd975cca --- /dev/null +++ b/airtime_mvc/library/propel/runtime/lib/parser/PropelJSONParser.php @@ -0,0 +1,67 @@ +fromArray($array); + } + + /** + * Converts data from JSON to an associative array. + * + * @param string $data Source data to convert, as a JSON string + * + * @return array Converted data + */ + public function toArray($data) + { + return json_decode($data, true); + } + + /** + * Alias for PropelJSONParser::toArray() + * + * @param string $data Source data to convert, as a JSON string + * + * @return array Converted data + */ + public function fromJSON($data) + { + return $this->toArray($data); + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/parser/PropelParser.php b/airtime_mvc/library/propel/runtime/lib/parser/PropelParser.php new file mode 100644 index 000000000..39b2b3e32 --- /dev/null +++ b/airtime_mvc/library/propel/runtime/lib/parser/PropelParser.php @@ -0,0 +1,108 @@ + (Doctrine_Parser) + * @package propel.runtime.parser + */ +abstract class PropelParser +{ + /** + * Converts data from an associative array to the parser format. + * + * Override in the parser driver. + * + * @param array $array Source data to convert + * + * @return mixed Converted data, depending on the parser format + */ + abstract public function fromArray($array); + + /** + * Converts data from the parser format to an associative array. + * + * Override in the parser driver. + * + * @param mixed $data Source data to convert, depending on the parser format + * + * @return array Converted data + */ + abstract public function toArray($data); + + public function listFromArray($data) + { + return $this->fromArray($data); + } + + public function listToArray($data) + { + return $this->toArray($data); + } + + /** + * Loads data from a file. Executes PHP code blocks in the file. + * + * @param string $path Path to the file to load + * + * @return string The file content processed by PHP + * + * @throws PropelException + */ + public function load($path) + { + if (!file_exists($path)) { + throw new PropelException(sprintf('File "%s" does not exist or is unreadable', $path)); + } + ob_start(); + include($path); + $contents = ob_get_clean(); + + return $contents; + } + + /** + * Dumps data to a file, or to STDOUT if no filename is given + * + * @param string $data The file content + * @param string $path Path of the file to create + * + * @return int|null If path given, the written bytes, null otherwise. + */ + public function dump($data, $path = null) + { + if ($path !== null) { + return file_put_contents($path, $data); + } else { + echo $data; + } + } + + /** + * Factory for getting an instance of a subclass of PropelParser + * + * @param string $type Parser type, amon 'XML', 'YAML', 'JSON', and 'CSV' + * + * @return PropelParser A PropelParser subclass instance + * + * @throws PropelException + */ + public static function getParser($type = 'XML') + { + $class = sprintf('Propel%sParser', $type); + if (!class_exists($class)) { + throw new PropelException(sprintf('Unknown parser class "%s"', $class)); + } + + return new $class; + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/parser/PropelXMLParser.php b/airtime_mvc/library/propel/runtime/lib/parser/PropelXMLParser.php new file mode 100644 index 000000000..f2f3bd632 --- /dev/null +++ b/airtime_mvc/library/propel/runtime/lib/parser/PropelXMLParser.php @@ -0,0 +1,211 @@ +getRootNode($rootElementName); + $this->arrayToDOM($array, $rootNode, $charset, false); + + return $rootNode->ownerDocument->saveXML(); + } + + public function listFromArray($array, $rootElementName = 'data', $charset = null) + { + $rootNode = $this->getRootNode($rootElementName); + $this->arrayToDOM($array, $rootNode, $charset, true); + + return $rootNode->ownerDocument->saveXML(); + } + + /** + * Create a DOMDocument and get the root DOMNode using a root element name + * + * @param string $rootElementName The Root Element Name + * + * @return DOMNode The root DOMNode + */ + protected function getRootNode($rootElementName = 'data') + { + $xml = new DOMDocument('1.0', 'UTF-8'); + $xml->preserveWhiteSpace = false; + $xml->formatOutput = true; + $rootElement = $xml->createElement($rootElementName); + $xml->appendChild($rootElement); + + return $rootElement; + } + + /** + * Alias for PropelXMLParser::fromArray() + * + * @param array $array Source data to convert + * @param string $rootElementName Name of the root element of the XML document + * @param string $charset Character set of the input data. Defaults to UTF-8. + * + * @return string Converted data, as an XML string + */ + public function toXML($array, $rootElementName = 'data', $charset = null) + { + return $this->fromArray($array, $rootElementName, $charset); + } + + /** + * Alias for PropelXMLParser::listFromArray() + * + * @param array $array Source data to convert + * @param string $rootElementName Name of the root element of the XML document + * @param string $charset Character set of the input data. Defaults to UTF-8. + * + * @return string Converted data, as an XML string + */ + public function listToXML($array, $rootElementName = 'data', $charset = null) + { + return $this->listFromArray($array, $rootElementName, $charset); + } + + /** + * @param array $array + * @param DOMElement $rootElement + * @param string $charset + * @param boolean $removeNumbersFromKeys + * + * @return DOMElement + */ + protected function arrayToDOM($array, $rootElement, $charset = null, $removeNumbersFromKeys = false) + { + foreach ($array as $key => $value) { + if ($removeNumbersFromKeys) { + $key = preg_replace('/[^a-z]/i', '', $key); + } + $element = $rootElement->ownerDocument->createElement($key); + if (is_array($value)) { + if (!empty($value)) { + $element = $this->arrayToDOM($value, $element, $charset); + } + } elseif (is_string($value)) { + $charset = $charset ? $charset : 'utf-8'; + if (function_exists('iconv') && strcasecmp($charset, 'utf-8') !== 0 && strcasecmp($charset, 'utf8') !== 0) { + $value = iconv($charset, 'UTF-8', $value); + } + $value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); + $child = $element->ownerDocument->createCDATASection($value); + $element->appendChild($child); + } else { + $child = $element->ownerDocument->createTextNode($value); + $element->appendChild($child); + } + $rootElement->appendChild($element); + } + + return $rootElement; + } + + /** + * Converts data from XML to an associative array. + * + * @param string $data Source data to convert, as an XML string + * + * @return array Converted data + */ + public function toArray($data) + { + $doc = new DomDocument('1.0', 'UTF-8'); + $doc->loadXML($data); + $element = $doc->documentElement; + + return $this->convertDOMElementToArray($element); + } + + /** + * Alias for PropelXMLParser::toArray() + * + * @param string $data Source data to convert, as an XML string + * + * @return array Converted data + */ + public function fromXML($data) + { + return $this->toArray($data); + } + + /** + * @param DOMNode $data + * + * @return array + */ + protected function convertDOMElementToArray(DOMNode $data) + { + $array = array(); + $elementNames = array(); + foreach ($data->childNodes as $element) { + if ($element->nodeType == XML_TEXT_NODE) { + continue; + } + $name = $element->nodeName; + if (isset($elementNames[$name])) { + if (isset($array[$name])) { + // change the first 'book' to 'book0' + $array[$name . $elementNames[$name]] = $array[$name]; + unset($array[$name]); + } + $elementNames[$name] += 1; + $index = $name . $elementNames[$name]; + } else { + $index = $name; + $elementNames[$name] = 0; + } + if ($element->hasChildNodes() && !$this->hasOnlyTextNodes($element)) { + $array[$index] = $this->convertDOMElementToArray($element); + } elseif ($element->hasChildNodes() && $element->firstChild->nodeType == XML_CDATA_SECTION_NODE) { + $array[$index] = htmlspecialchars_decode($element->firstChild->textContent); + } elseif (!$element->hasChildNodes()) { + $array[$index] = null; + } else { + $array[$index] = $element->textContent; + } + } + + return $array; + } + + /** + * @param DomNode $node + * + * @return boolean + */ + protected function hasOnlyTextNodes(DomNode $node) + { + foreach ($node->childNodes as $childNode) { + if ($childNode->nodeType != XML_CDATA_SECTION_NODE && $childNode->nodeType != XML_TEXT_NODE) { + return false; + } + } + + return true; + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/parser/PropelYAMLParser.php b/airtime_mvc/library/propel/runtime/lib/parser/PropelYAMLParser.php new file mode 100644 index 000000000..0d6be2c0d --- /dev/null +++ b/airtime_mvc/library/propel/runtime/lib/parser/PropelYAMLParser.php @@ -0,0 +1,71 @@ +fromArray($array); + } + + /** + * Converts data from YAML to an associative array. + * + * @param string $data Source data to convert, as a YAML string + * + * @return array Converted data + */ + public function toArray($data) + { + return sfYaml::load($data); + } + + /** + * Alias for PropelYAMLParser::toArray() + * + * @param string $data Source data to convert, as a YAML string + * + * @return array Converted data + */ + public function fromYAML($data) + { + return $this->toArray($data); + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/parser/yaml/LICENSE b/airtime_mvc/library/propel/runtime/lib/parser/yaml/LICENSE new file mode 100644 index 000000000..3cef85317 --- /dev/null +++ b/airtime_mvc/library/propel/runtime/lib/parser/yaml/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2008-2009 Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/airtime_mvc/library/propel/runtime/lib/parser/yaml/sfYaml.php b/airtime_mvc/library/propel/runtime/lib/parser/yaml/sfYaml.php new file mode 100644 index 000000000..e3b32de39 --- /dev/null +++ b/airtime_mvc/library/propel/runtime/lib/parser/yaml/sfYaml.php @@ -0,0 +1,129 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * sfYaml offers convenience methods to load and dump YAML. + * + * @package symfony + * @subpackage yaml + * @author Fabien Potencier + * @version SVN: $Id: sfYaml.class.php 8988 2008-05-15 20:24:26Z fabien $ + */ +class sfYaml +{ + static protected + $spec = '1.2'; + + /** + * Sets the YAML specification version to use. + * + * @param string $version The YAML specification version + */ + public static function setSpecVersion($version) + { + if (!in_array($version, array('1.1', '1.2'))) { + throw new InvalidArgumentException(sprintf('Version %s of the YAML specifications is not supported', $version)); + } + + self::$spec = $version; + } + + /** + * Gets the YAML specification version to use. + * + * @return string The YAML specification version + */ + public static function getSpecVersion() + { + return self::$spec; + } + + /** + * Loads YAML into a PHP array. + * + * The load method, when supplied with a YAML stream (string or file), + * will do its best to convert YAML in a file into a PHP array. + * + * Usage: + * + * $array = sfYaml::load('config.yml'); + * print_r($array); + * + * + * @param string $input Path of YAML file or string containing YAML + * + * @return array The YAML converted to a PHP array + * + * @throws InvalidArgumentException If the YAML is not valid + */ + public static function load($input) + { + $file = ''; + + // if input is a file, process it + if (strpos($input, "\n") === false && is_file($input)) { + $file = $input; + + ob_start(); + $retval = include($input); + $content = ob_get_clean(); + + // if an array is returned by the config file assume it's in plain php form else in YAML + $input = is_array($retval) ? $retval : $content; + } + + // if an array is returned by the config file assume it's in plain php form else in YAML + if (is_array($input)) { + return $input; + } + + require_once dirname(__FILE__).'/sfYamlParser.php'; + + $yaml = new sfYamlParser(); + + try { + $ret = $yaml->parse($input); + } catch (Exception $e) { + throw new InvalidArgumentException(sprintf('Unable to parse %s: %s', $file ? sprintf('file "%s"', $file) : 'string', $e->getMessage())); + } + + return $ret; + } + + /** + * Dumps a PHP array to a YAML string. + * + * The dump method, when supplied with an array, will do its best + * to convert the array into friendly YAML. + * + * @param array $array PHP array + * @param integer $inline The level where you switch to inline YAML + * + * @return string A YAML string representing the original PHP array + */ + public static function dump($array, $inline = 2) + { + require_once dirname(__FILE__).'/sfYamlDumper.php'; + + $yaml = new sfYamlDumper(); + + return $yaml->dump($array, $inline); + } +} + +/** + * Wraps echo to automatically provide a newline. + * + * @param string $string The string to echo with new line + */ +function echoln($string) +{ + echo $string."\n"; +} diff --git a/airtime_mvc/library/propel/runtime/lib/parser/yaml/sfYamlDumper.php b/airtime_mvc/library/propel/runtime/lib/parser/yaml/sfYamlDumper.php new file mode 100644 index 000000000..7f0a450a4 --- /dev/null +++ b/airtime_mvc/library/propel/runtime/lib/parser/yaml/sfYamlDumper.php @@ -0,0 +1,56 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfYamlInline.php'); + +/** + * sfYamlDumper dumps PHP variables to YAML strings. + * + * @package symfony + * @subpackage yaml + * @author Fabien Potencier + * @version SVN: $Id: sfYamlDumper.class.php 10575 2008-08-01 13:08:42Z nicolas $ + */ +class sfYamlDumper +{ + /** + * Dumps a PHP value to YAML. + * + * @param mixed $input The PHP value + * @param integer $inline The level where you switch to inline YAML + * @param integer $indent The level o indentation indentation (used internally) + * + * @return string The YAML representation of the PHP value + */ + public function dump($input, $inline = 0, $indent = 0) + { + $output = ''; + $prefix = $indent ? str_repeat(' ', $indent) : ''; + + if ($inline <= 0 || !is_array($input) || empty($input)) { + $output .= $prefix.sfYamlInline::dump($input); + } else { + $isAHash = array_keys($input) !== range(0, count($input) - 1); + + foreach ($input as $key => $value) { + $willBeInlined = $inline - 1 <= 0 || !is_array($value) || empty($value); + + $output .= sprintf('%s%s%s%s', + $prefix, + $isAHash ? sfYamlInline::dump($key).':' : '-', + $willBeInlined ? ' ' : "\n", + $this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + 2) + ).($willBeInlined ? "\n" : ''); + } + } + + return $output; + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/parser/yaml/sfYamlInline.php b/airtime_mvc/library/propel/runtime/lib/parser/yaml/sfYamlInline.php new file mode 100644 index 000000000..b39a945f7 --- /dev/null +++ b/airtime_mvc/library/propel/runtime/lib/parser/yaml/sfYamlInline.php @@ -0,0 +1,405 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once dirname(__FILE__).'/sfYaml.php'; + +/** + * sfYamlInline implements a YAML parser/dumper for the YAML inline syntax. + * + * @package symfony + * @subpackage yaml + * @author Fabien Potencier + * @version SVN: $Id: sfYamlInline.class.php 16177 2009-03-11 08:32:48Z fabien $ + */ +class sfYamlInline +{ + const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\']*(?:\'\'[^\']*)*)\')'; + + /** + * Convert a YAML string to a PHP array. + * + * @param string $value A YAML string + * + * @return array A PHP array representing the YAML string + */ + public static function load($value) + { + $value = trim($value); + + if (0 == strlen($value)) { + return ''; + } + + if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { + $mbEncoding = mb_internal_encoding(); + mb_internal_encoding('ASCII'); + } + + switch ($value[0]) { + case '[': + $result = self::parseSequence($value); + break; + case '{': + $result = self::parseMapping($value); + break; + default: + $result = self::parseScalar($value); + } + + if (isset($mbEncoding)) { + mb_internal_encoding($mbEncoding); + } + + return $result; + } + + /** + * Dumps a given PHP variable to a YAML string. + * + * @param mixed $value The PHP variable to convert + * + * @return string The YAML string representing the PHP array + */ + public static function dump($value) + { + if ('1.1' === sfYaml::getSpecVersion()) { + $trueValues = array('true', 'on', '+', 'yes', 'y'); + $falseValues = array('false', 'off', '-', 'no', 'n'); + } else { + $trueValues = array('true'); + $falseValues = array('false'); + } + + switch (true) { + case is_resource($value): + throw new InvalidArgumentException('Unable to dump PHP resources in a YAML file.'); + case is_object($value): + return '!!php/object:'.serialize($value); + case is_array($value): + return self::dumpArray($value); + case null === $value: + return 'null'; + case true === $value: + return 'true'; + case false === $value: + return 'false'; + case ctype_digit($value): + return is_string($value) ? "'$value'" : (int) $value; + case is_numeric($value): + return is_infinite($value) ? str_ireplace('INF', '.Inf', strval($value)) : (is_string($value) ? "'$value'" : $value); + case false !== strpos($value, "\n") || false !== strpos($value, "\r"): + return sprintf('"%s"', str_replace(array('"', "\n", "\r"), array('\\"', '\n', '\r'), $value)); + case preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ - ? | < > = ! % @ ` ]/x', $value): + return sprintf("'%s'", str_replace('\'', '\'\'', $value)); + case '' == $value: + return "''"; + case preg_match(self::getTimestampRegex(), $value): + return "'$value'"; + case in_array(strtolower($value), $trueValues): + return "'$value'"; + case in_array(strtolower($value), $falseValues): + return "'$value'"; + case in_array(strtolower($value), array('null', '~')): + return "'$value'"; + default: + return $value; + } + } + + /** + * Dumps a PHP array to a YAML string. + * + * @param array $value The PHP array to dump + * + * @return string The YAML string representing the PHP array + */ + protected static function dumpArray($value) + { + // array + $keys = array_keys($value); + if ( + (1 == count($keys) && '0' == $keys[0]) + || + (count($keys) > 1 && array_reduce($keys, create_function('$v,$w', 'return (integer) $v + $w;'), 0) == count($keys) * (count($keys) - 1) / 2)) + { + $output = array(); + foreach ($value as $val) { + $output[] = self::dump($val); + } + + return sprintf('[%s]', implode(', ', $output)); + } + + // mapping + $output = array(); + foreach ($value as $key => $val) { + $output[] = sprintf('%s: %s', self::dump($key), self::dump($val)); + } + + return sprintf('{ %s }', implode(', ', $output)); + } + + /** + * Parses a scalar to a YAML string. + * + * @param scalar $scalar + * @param string $delimiters + * @param array $stringDelimiter + * @param integer $i + * @param boolean $evaluate + * + * @return string A YAML string + */ + public static function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true) + { + if (in_array($scalar[$i], $stringDelimiters)) { + // quoted scalar + $output = self::parseQuotedScalar($scalar, $i); + } else { + // "normal" string + if (!$delimiters) { + $output = substr($scalar, $i); + $i += strlen($output); + + // remove comments + if (false !== $strpos = strpos($output, ' #')) { + $output = rtrim(substr($output, 0, $strpos)); + } + } elseif (preg_match('/^(.+?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) { + $output = $match[1]; + $i += strlen($output); + } else { + throw new InvalidArgumentException(sprintf('Malformed inline YAML string (%s).', $scalar)); + } + + $output = $evaluate ? self::evaluateScalar($output) : $output; + } + + return $output; + } + + /** + * Parses a quoted scalar to YAML. + * + * @param string $scalar + * @param integer $i + * + * @return string A YAML string + */ + protected static function parseQuotedScalar($scalar, &$i) + { + if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) { + throw new InvalidArgumentException(sprintf('Malformed inline YAML string (%s).', substr($scalar, $i))); + } + + $output = substr($match[0], 1, strlen($match[0]) - 2); + + if ('"' == $scalar[$i]) { + // evaluate the string + $output = str_replace(array('\\"', '\\n', '\\r'), array('"', "\n", "\r"), $output); + } else { + // unescape ' + $output = str_replace('\'\'', '\'', $output); + } + + $i += strlen($match[0]); + + return $output; + } + + /** + * Parses a sequence to a YAML string. + * + * @param string $sequence + * @param integer $i + * + * @return string A YAML string + */ + protected static function parseSequence($sequence, &$i = 0) + { + $output = array(); + $len = strlen($sequence); + $i += 1; + + // [foo, bar, ...] + while ($i < $len) { + switch ($sequence[$i]) { + case '[': + // nested sequence + $output[] = self::parseSequence($sequence, $i); + break; + case '{': + // nested mapping + $output[] = self::parseMapping($sequence, $i); + break; + case ']': + return $output; + case ',': + case ' ': + break; + default: + $isQuoted = in_array($sequence[$i], array('"', "'")); + $value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i); + + if (!$isQuoted && false !== strpos($value, ': ')) { + // embedded mapping? + try { + $value = self::parseMapping('{'.$value.'}'); + } catch (InvalidArgumentException $e) { + // no, it's not + } + } + + $output[] = $value; + + --$i; + } + + ++$i; + } + + throw new InvalidArgumentException(sprintf('Malformed inline YAML string %s', $sequence)); + } + + /** + * Parses a mapping to a YAML string. + * + * @param string $mapping + * @param integer $i + * + * @return string A YAML string + */ + protected static function parseMapping($mapping, &$i = 0) + { + $output = array(); + $len = strlen($mapping); + $i += 1; + + // {foo: bar, bar:foo, ...} + while ($i < $len) { + switch ($mapping[$i]) { + case ' ': + case ',': + ++$i; + continue 2; + case '}': + return $output; + } + + // key + $key = self::parseScalar($mapping, array(':', ' '), array('"', "'"), $i, false); + + // value + $done = false; + while ($i < $len) { + switch ($mapping[$i]) { + case '[': + // nested sequence + $output[$key] = self::parseSequence($mapping, $i); + $done = true; + break; + case '{': + // nested mapping + $output[$key] = self::parseMapping($mapping, $i); + $done = true; + break; + case ':': + case ' ': + break; + default: + $output[$key] = self::parseScalar($mapping, array(',', '}'), array('"', "'"), $i); + $done = true; + --$i; + } + + ++$i; + + if ($done) { + continue 2; + } + } + } + + throw new InvalidArgumentException(sprintf('Malformed inline YAML string %s', $mapping)); + } + + /** + * Evaluates scalars and replaces magic values. + * + * @param string $scalar + * + * @return string A YAML string + */ + protected static function evaluateScalar($scalar) + { + $scalar = trim($scalar); + + if ('1.1' === sfYaml::getSpecVersion()) { + $trueValues = array('true', 'on', '+', 'yes', 'y'); + $falseValues = array('false', 'off', '-', 'no', 'n'); + } else { + $trueValues = array('true'); + $falseValues = array('false'); + } + + switch (true) { + case 'null' == strtolower($scalar): + case '' == $scalar: + case '~' == $scalar: + return null; + case 0 === strpos($scalar, '!str'): + return (string) substr($scalar, 5); + case 0 === strpos($scalar, '! '): + return intval(self::parseScalar(substr($scalar, 2))); + case 0 === strpos($scalar, '!!php/object:'): + return unserialize(substr($scalar, 13)); + case ctype_digit($scalar): + $raw = $scalar; + $cast = intval($scalar); + + return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw); + case in_array(strtolower($scalar), $trueValues): + return true; + case in_array(strtolower($scalar), $falseValues): + return false; + case is_numeric($scalar): + return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar); + case 0 == strcasecmp($scalar, '.inf'): + case 0 == strcasecmp($scalar, '.NaN'): + return -log(0); + case 0 == strcasecmp($scalar, '-.inf'): + return log(0); + case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar): + return floatval(str_replace(',', '', $scalar)); + case preg_match(self::getTimestampRegex(), $scalar): + return strtotime($scalar); + default: + return (string) $scalar; + } + } + + protected static function getTimestampRegex() + { + return <<[0-9][0-9][0-9][0-9]) + -(?P[0-9][0-9]?) + -(?P[0-9][0-9]?) + (?:(?:[Tt]|[ \t]+) + (?P[0-9][0-9]?) + :(?P[0-9][0-9]) + :(?P[0-9][0-9]) + (?:\.(?P[0-9]*))? + (?:[ \t]*(?PZ|(?P[-+])(?P[0-9][0-9]?) + (?::(?P[0-9][0-9]))?))?)? + $~x +EOF; + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/parser/yaml/sfYamlParser.php b/airtime_mvc/library/propel/runtime/lib/parser/yaml/sfYamlParser.php new file mode 100644 index 000000000..a0363608c --- /dev/null +++ b/airtime_mvc/library/propel/runtime/lib/parser/yaml/sfYamlParser.php @@ -0,0 +1,512 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/sfYamlInline.php'); + +if (!defined('PREG_BAD_UTF8_OFFSET_ERROR')) { + define('PREG_BAD_UTF8_OFFSET_ERROR', 5); +} + +/** + * sfYamlParser parses YAML strings to convert them to PHP arrays. + * + * @package symfony + * @subpackage yaml + * @author Fabien Potencier + * @version SVN: $Id: sfYamlParser.class.php 10832 2008-08-13 07:46:08Z fabien $ + */ +class sfYamlParser +{ + protected + $offset = 0, + $lines = array(), + $currentLineNb = -1, + $currentLine = '', + $refs = array(); + + /** + * Constructor + * + * @param integer $offset The offset of YAML document (used for line numbers in error messages) + */ + public function __construct($offset = 0) + { + $this->offset = $offset; + } + + /** + * Parses a YAML string to a PHP value. + * + * @param string $value A YAML string + * + * @return mixed A PHP value + * + * @throws InvalidArgumentException If the YAML is not valid + */ + public function parse($value) + { + $this->currentLineNb = -1; + $this->currentLine = ''; + $this->lines = explode("\n", $this->cleanup($value)); + + if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { + $mbEncoding = mb_internal_encoding(); + mb_internal_encoding('UTF-8'); + } + + $data = array(); + while ($this->moveToNextLine()) { + if ($this->isCurrentLineEmpty()) { + continue; + } + + // tab? + if (preg_match('#^\t+#', $this->currentLine)) { + throw new InvalidArgumentException(sprintf('A YAML file cannot contain tabs as indentation at line %d (%s).', $this->getRealCurrentLineNb() + 1, $this->currentLine)); + } + + $isRef = $isInPlace = $isProcessed = false; + if (preg_match('#^\-(\s+(?P.+?))?\s*$#u', $this->currentLine, $values)) { + if (isset($values['value']) && preg_match('#^&(?P[^ ]+) *(?P.*)#u', $values['value'], $matches)) { + $isRef = $matches['ref']; + $values['value'] = $matches['value']; + } + + // array + if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { + $c = $this->getRealCurrentLineNb() + 1; + $parser = new sfYamlParser($c); + $parser->refs =& $this->refs; + $data[] = $parser->parse($this->getNextEmbedBlock()); + } else { + if (preg_match('/^([^ ]+)\: +({.*?)$/u', $values['value'], $matches)) { + $data[] = array($matches[1] => sfYamlInline::load($matches[2])); + } else { + $data[] = $this->parseValue($values['value']); + } + } + } elseif (preg_match('#^(?P'.sfYamlInline::REGEX_QUOTED_STRING.'|[^ ].*?) *\:(\s+(?P.+?))?\s*$#u', $this->currentLine, $values)) { + $key = sfYamlInline::parseScalar($values['key']); + + if ('<<' === $key) { + if (isset($values['value']) && '*' === substr($values['value'], 0, 1)) { + $isInPlace = substr($values['value'], 1); + if (!array_key_exists($isInPlace, $this->refs)) { + throw new InvalidArgumentException(sprintf('Reference "%s" does not exist at line %s (%s).', $isInPlace, $this->getRealCurrentLineNb() + 1, $this->currentLine)); + } + } else { + if (isset($values['value']) && $values['value'] !== '') { + $value = $values['value']; + } else { + $value = $this->getNextEmbedBlock(); + } + $c = $this->getRealCurrentLineNb() + 1; + $parser = new sfYamlParser($c); + $parser->refs =& $this->refs; + $parsed = $parser->parse($value); + + $merged = array(); + if (!is_array($parsed)) { + throw new InvalidArgumentException(sprintf("YAML merge keys used with a scalar value instead of an array at line %s (%s)", $this->getRealCurrentLineNb() + 1, $this->currentLine)); + } elseif (isset($parsed[0])) { + // Numeric array, merge individual elements + foreach (array_reverse($parsed) as $parsedItem) { + if (!is_array($parsedItem)) { + throw new InvalidArgumentException(sprintf("Merge items must be arrays at line %s (%s).", $this->getRealCurrentLineNb() + 1, $parsedItem)); + } + $merged = array_merge($parsedItem, $merged); + } + } else { + // Associative array, merge + $merged = array_merge($merged, $parsed); + } + + $isProcessed = $merged; + } + } elseif (isset($values['value']) && preg_match('#^&(?P[^ ]+) *(?P.*)#u', $values['value'], $matches)) { + $isRef = $matches['ref']; + $values['value'] = $matches['value']; + } + + if ($isProcessed) { + // Merge keys + $data = $isProcessed; + } + // hash + else if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { + // if next line is less indented or equal, then it means that the current value is null + if ($this->isNextLineIndented()) { + $data[$key] = null; + } else { + $c = $this->getRealCurrentLineNb() + 1; + $parser = new sfYamlParser($c); + $parser->refs =& $this->refs; + $data[$key] = $parser->parse($this->getNextEmbedBlock()); + } + } else { + if ($isInPlace) { + $data = $this->refs[$isInPlace]; + } else { + $data[$key] = $this->parseValue($values['value']); + } + } + } else { + // 1-liner followed by newline + if (2 == count($this->lines) && empty($this->lines[1])) { + $value = sfYamlInline::load($this->lines[0]); + if (is_array($value)) { + $first = reset($value); + if ('*' === substr($first, 0, 1)) { + $data = array(); + foreach ($value as $alias) { + $data[] = $this->refs[substr($alias, 1)]; + } + $value = $data; + } + } + + if (isset($mbEncoding)) { + mb_internal_encoding($mbEncoding); + } + + return $value; + } + + switch (preg_last_error()) { + case PREG_INTERNAL_ERROR: + $error = 'Internal PCRE error on line'; + break; + case PREG_BACKTRACK_LIMIT_ERROR: + $error = 'pcre.backtrack_limit reached on line'; + break; + case PREG_RECURSION_LIMIT_ERROR: + $error = 'pcre.recursion_limit reached on line'; + break; + case PREG_BAD_UTF8_ERROR: + $error = 'Malformed UTF-8 data on line'; + break; + case PREG_BAD_UTF8_OFFSET_ERROR: + $error = 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point on line'; + break; + default: + $error = 'Unable to parse line'; + } + + throw new InvalidArgumentException(sprintf('%s %d (%s).', $error, $this->getRealCurrentLineNb() + 1, $this->currentLine)); + } + + if ($isRef) { + $this->refs[$isRef] = end($data); + } + } + + if (isset($mbEncoding)) { + mb_internal_encoding($mbEncoding); + } + + return empty($data) ? null : $data; + } + + /** + * Returns the current line number (takes the offset into account). + * + * @return integer The current line number + */ + protected function getRealCurrentLineNb() + { + return $this->currentLineNb + $this->offset; + } + + /** + * Returns the current line indentation. + * + * @return integer The current line indentation + */ + protected function getCurrentLineIndentation() + { + return strlen($this->currentLine) - strlen(ltrim($this->currentLine, ' ')); + } + + /** + * Returns the next embed block of YAML. + * + * @return string A YAML string + */ + protected function getNextEmbedBlock() + { + $this->moveToNextLine(); + + $newIndent = $this->getCurrentLineIndentation(); + + if (!$this->isCurrentLineEmpty() && 0 == $newIndent) { + throw new InvalidArgumentException(sprintf('Indentation problem at line %d (%s)', $this->getRealCurrentLineNb() + 1, $this->currentLine)); + } + + $data = array(substr($this->currentLine, $newIndent)); + + while ($this->moveToNextLine()) { + if ($this->isCurrentLineEmpty()) { + if ($this->isCurrentLineBlank()) { + $data[] = substr($this->currentLine, $newIndent); + } + + continue; + } + + $indent = $this->getCurrentLineIndentation(); + + if (preg_match('#^(?P *)$#', $this->currentLine, $match)) { + // empty line + $data[] = $match['text']; + } elseif ($indent >= $newIndent) { + $data[] = substr($this->currentLine, $newIndent); + } elseif (0 == $indent) { + $this->moveToPreviousLine(); + + break; + } else { + throw new InvalidArgumentException(sprintf('Indentation problem at line %d (%s)', $this->getRealCurrentLineNb() + 1, $this->currentLine)); + } + } + + return implode("\n", $data); + } + + /** + * Moves the parser to the next line. + */ + protected function moveToNextLine() + { + if ($this->currentLineNb >= count($this->lines) - 1) { + return false; + } + + $this->currentLine = $this->lines[++$this->currentLineNb]; + + return true; + } + + /** + * Moves the parser to the previous line. + */ + protected function moveToPreviousLine() + { + $this->currentLine = $this->lines[--$this->currentLineNb]; + } + + /** + * Parses a YAML value. + * + * @param string $value A YAML value + * + * @return mixed A PHP value + */ + protected function parseValue($value) + { + if ('*' === substr($value, 0, 1)) { + if (false !== $pos = strpos($value, '#')) { + $value = substr($value, 1, $pos - 2); + } else { + $value = substr($value, 1); + } + + if (!array_key_exists($value, $this->refs)) { + throw new InvalidArgumentException(sprintf('Reference "%s" does not exist (%s).', $value, $this->currentLine)); + } + + return $this->refs[$value]; + } + + if (preg_match('/^(?P\||>)(?P\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P +#.*)?$/', $value, $matches)) { + $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : ''; + + return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers))); + } else { + return sfYamlInline::load($value); + } + } + + /** + * Parses a folded scalar. + * + * @param string $separator The separator that was used to begin this folded scalar (| or >) + * @param string $indicator The indicator that was used to begin this folded scalar (+ or -) + * @param integer $indentation The indentation that was used to begin this folded scalar + * + * @return string The text value + */ + protected function parseFoldedScalar($separator, $indicator = '', $indentation = 0) + { + $separator = '|' == $separator ? "\n" : ' '; + $text = ''; + + $notEOF = $this->moveToNextLine(); + + while ($notEOF && $this->isCurrentLineBlank()) { + $text .= "\n"; + + $notEOF = $this->moveToNextLine(); + } + + if (!$notEOF) { + return ''; + } + + if (!preg_match('#^(?P'.($indentation ? str_repeat(' ', $indentation) : ' +').')(?P.*)$#u', $this->currentLine, $matches)) { + $this->moveToPreviousLine(); + + return ''; + } + + $textIndent = $matches['indent']; + $previousIndent = 0; + + $text .= $matches['text'].$separator; + while ($this->currentLineNb + 1 < count($this->lines)) { + $this->moveToNextLine(); + + if (preg_match('#^(?P {'.strlen($textIndent).',})(?P.+)$#u', $this->currentLine, $matches)) { + if (' ' == $separator && $previousIndent != $matches['indent']) { + $text = substr($text, 0, -1)."\n"; + } + $previousIndent = $matches['indent']; + + $text .= str_repeat(' ', $diff = strlen($matches['indent']) - strlen($textIndent)).$matches['text'].($diff ? "\n" : $separator); + } elseif (preg_match('#^(?P *)$#', $this->currentLine, $matches)) { + $text .= preg_replace('#^ {1,'.strlen($textIndent).'}#', '', $matches['text'])."\n"; + } else { + $this->moveToPreviousLine(); + + break; + } + } + + if (' ' == $separator) { + // replace last separator by a newline + $text = preg_replace('/ (\n*)$/', "\n$1", $text); + } + + switch ($indicator) { + case '': + $text = preg_replace('#\n+$#s', "\n", $text); + break; + case '+': + break; + case '-': + $text = preg_replace('#\n+$#s', '', $text); + break; + } + + return $text; + } + + /** + * Returns true if the next line is indented. + * + * @return Boolean Returns true if the next line is indented, false otherwise + */ + protected function isNextLineIndented() + { + $currentIndentation = $this->getCurrentLineIndentation(); + $notEOF = $this->moveToNextLine(); + + while ($notEOF && $this->isCurrentLineEmpty()) { + $notEOF = $this->moveToNextLine(); + } + + if (false === $notEOF) { + return false; + } + + $ret = false; + if ($this->getCurrentLineIndentation() <= $currentIndentation) { + $ret = true; + } + + $this->moveToPreviousLine(); + + return $ret; + } + + /** + * Returns true if the current line is blank or if it is a comment line. + * + * @return Boolean Returns true if the current line is empty or if it is a comment line, false otherwise + */ + protected function isCurrentLineEmpty() + { + return $this->isCurrentLineBlank() || $this->isCurrentLineComment(); + } + + /** + * Returns true if the current line is blank. + * + * @return Boolean Returns true if the current line is blank, false otherwise + */ + protected function isCurrentLineBlank() + { + return '' == trim($this->currentLine, ' '); + } + + /** + * Returns true if the current line is a comment line. + * + * @return Boolean Returns true if the current line is a comment line, false otherwise + */ + protected function isCurrentLineComment() + { + //checking explicitly the first char of the trim is faster than loops or strpos + $ltrimmedLine = ltrim($this->currentLine, ' '); + + return $ltrimmedLine[0] === '#'; + } + + /** + * Cleanups a YAML string to be parsed. + * + * @param string $value The input YAML string + * + * @return string A cleaned up YAML string + */ + protected function cleanup($value) + { + $value = str_replace(array("\r\n", "\r"), "\n", $value); + + if (!preg_match("#\n$#", $value)) { + $value .= "\n"; + } + + // strip YAML header + $count = 0; + $value = preg_replace('#^\%YAML[: ][\d\.]+.*\n#su', '', $value, -1, $count); + $this->offset += $count; + + // remove leading comments + $trimmedValue = preg_replace('#^(\#.*?\n)+#s', '', $value, -1, $count); + if ($count == 1) { + // items have been removed, update the offset + $this->offset += substr_count($value, "\n") - substr_count($trimmedValue, "\n"); + $value = $trimmedValue; + } + + // remove start of the document marker (---) + $trimmedValue = preg_replace('#^\-\-\-.*?\n#s', '', $value, -1, $count); + if ($count == 1) { + // items have been removed, update the offset + $this->offset += substr_count($value, "\n") - substr_count($trimmedValue, "\n"); + $value = $trimmedValue; + + // remove end of the document marker (...) + $value = preg_replace('#\.\.\.\s*$#s', '', $value); + } + + return $value; + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/query/Criteria.php b/airtime_mvc/library/propel/runtime/lib/query/Criteria.php index cbb3317f1..005f83bcc 100644 --- a/airtime_mvc/library/propel/runtime/lib/query/Criteria.php +++ b/airtime_mvc/library/propel/runtime/lib/query/Criteria.php @@ -21,1541 +21,1938 @@ * @author Eric Dobbs (Torque) * @author Henning P. Schmiedehausen (Torque) * @author Sam Joseph (Torque) - * @version $Revision: 1765 $ + * @version $Revision$ * @package propel.runtime.query */ class Criteria implements IteratorAggregate { - /** Comparison type. */ - const EQUAL = "="; + /** Comparison type. */ + const EQUAL = "="; - /** Comparison type. */ - const NOT_EQUAL = "<>"; + /** Comparison type. */ + const NOT_EQUAL = "<>"; - /** Comparison type. */ - const ALT_NOT_EQUAL = "!="; + /** Comparison type. */ + const ALT_NOT_EQUAL = "!="; - /** Comparison type. */ - const GREATER_THAN = ">"; + /** Comparison type. */ + const GREATER_THAN = ">"; - /** Comparison type. */ - const LESS_THAN = "<"; + /** Comparison type. */ + const LESS_THAN = "<"; - /** Comparison type. */ - const GREATER_EQUAL = ">="; + /** Comparison type. */ + const GREATER_EQUAL = ">="; - /** Comparison type. */ - const LESS_EQUAL = "<="; + /** Comparison type. */ + const LESS_EQUAL = "<="; - /** Comparison type. */ - const LIKE = " LIKE "; - - /** Comparison type. */ - const NOT_LIKE = " NOT LIKE "; - - /** PostgreSQL comparison type */ - const ILIKE = " ILIKE "; - - /** PostgreSQL comparison type */ - const NOT_ILIKE = " NOT ILIKE "; - - /** Comparison type. */ - const CUSTOM = "CUSTOM"; - - /** Comparison type for update */ - const CUSTOM_EQUAL = "CUSTOM_EQUAL"; - - /** Comparison type. */ - const DISTINCT = "DISTINCT"; - - /** Comparison type. */ - const IN = " IN "; - - /** Comparison type. */ - const NOT_IN = " NOT IN "; - - /** Comparison type. */ - const ALL = "ALL"; - - /** Comparison type. */ - const JOIN = "JOIN"; - - /** Binary math operator: AND */ - const BINARY_AND = "&"; - - /** Binary math operator: OR */ - const BINARY_OR = "|"; - - /** "Order by" qualifier - ascending */ - const ASC = "ASC"; - - /** "Order by" qualifier - descending */ - const DESC = "DESC"; - - /** "IS NULL" null comparison */ - const ISNULL = " IS NULL "; - - /** "IS NOT NULL" null comparison */ - const ISNOTNULL = " IS NOT NULL "; - - /** "CURRENT_DATE" ANSI SQL function */ - const CURRENT_DATE = "CURRENT_DATE"; - - /** "CURRENT_TIME" ANSI SQL function */ - const CURRENT_TIME = "CURRENT_TIME"; - - /** "CURRENT_TIMESTAMP" ANSI SQL function */ - const CURRENT_TIMESTAMP = "CURRENT_TIMESTAMP"; - - /** "LEFT JOIN" SQL statement */ - const LEFT_JOIN = "LEFT JOIN"; - - /** "RIGHT JOIN" SQL statement */ - const RIGHT_JOIN = "RIGHT JOIN"; - - /** "INNER JOIN" SQL statement */ - const INNER_JOIN = "INNER JOIN"; - - /** logical OR operator */ - const LOGICAL_OR = "OR"; - - /** logical AND operator */ - const LOGICAL_AND = "AND"; - - protected $ignoreCase = false; - protected $singleRecord = false; - - /** - * Storage of select data. Collection of column names. - * @var array - */ - protected $selectColumns = array(); - - /** - * Storage of aliased select data. Collection of column names. - * @var array - */ - protected $asColumns = array(); - - /** - * Storage of select modifiers data. Collection of modifier names. - * @var array - */ - protected $selectModifiers = array(); - - /** - * Storage of conditions data. Collection of Criterion objects. - * @var array - */ - protected $map = array(); - - /** - * Storage of ordering data. Collection of column names. - * @var array - */ - protected $orderByColumns = array(); - - /** - * Storage of grouping data. Collection of column names. - * @var array - */ - protected $groupByColumns = array(); - - /** - * Storage of having data. - * @var Criterion - */ - protected $having = null; - - /** - * Storage of join data. colleciton of Join objects. - * @var array - */ - protected $joins = array(); - - /** - * The name of the database. - * @var string - */ - protected $dbName; - - /** - * The primary table for this Criteria. - * Useful in cases where there are no select or where - * columns. - * @var string - */ - protected $primaryTableName; - - /** The name of the database as given in the contructor. */ - protected $originalDbName; - - /** - * To limit the number of rows to return. 0 means return all - * rows. - */ - protected $limit = 0; - - /** To start the results at a row other than the first one. */ - protected $offset = 0; - - /** - * Comment to add to the SQL query - * @var string - */ - protected $queryComment; - - // flag to note that the criteria involves a blob. - protected $blobFlag = null; - - protected $aliases = array(); - - protected $useTransaction = false; - - /** - * Storage for Criterions expected to be combined - * @var array - */ - protected $namedCriterions = array(); - - /** - * Creates a new instance with the default capacity which corresponds to - * the specified database. - * - * @param dbName The dabase name. - */ - public function __construct($dbName = null) - { - $this->setDbName($dbName); - $this->originalDbName = $dbName; - } - - /** - * Implementing SPL IteratorAggregate interface. This allows - * you to foreach () over a Criteria object. - */ - public function getIterator() - { - return new CriterionIterator($this); - } - - /** - * Get the criteria map, i.e. the array of Criterions - * @return array - */ - public function getMap() - { - return $this->map; - } - - /** - * Brings this criteria back to its initial state, so that it - * can be reused as if it was new. Except if the criteria has grown in - * capacity, it is left at the current capacity. - * @return void - */ - public function clear() - { - $this->map = array(); - $this->namedCriterions = array(); - $this->ignoreCase = false; - $this->singleRecord = false; - $this->selectModifiers = array(); - $this->selectColumns = array(); - $this->orderByColumns = array(); - $this->groupByColumns = array(); - $this->having = null; - $this->asColumns = array(); - $this->joins = array(); - $this->dbName = $this->originalDbName; - $this->offset = 0; - $this->limit = -1; - $this->blobFlag = null; - $this->aliases = array(); - $this->useTransaction = false; - } - - /** - * Add an AS clause to the select columns. Usage: - * - * - * Criteria myCrit = new Criteria(); - * myCrit->addAsColumn("alias", "ALIAS(".MyPeer::ID.")"); - * - * - * @param string $name Wanted Name of the column (alias). - * @param string $clause SQL clause to select from the table - * - * If the name already exists, it is replaced by the new clause. - * - * @return Criteria A modified Criteria object. - */ - public function addAsColumn($name, $clause) - { - $this->asColumns[$name] = $clause; - return $this; - } - - /** - * Get the column aliases. - * - * @return array An assoc array which map the column alias names - * to the alias clauses. - */ - public function getAsColumns() - { - return $this->asColumns; - } - - /** - * Returns the column name associated with an alias (AS-column). - * - * @param string $alias - * @return string $string - */ - public function getColumnForAs($as) - { - if (isset($this->asColumns[$as])) { - return $this->asColumns[$as]; - } - } - - /** - * Allows one to specify an alias for a table that can - * be used in various parts of the SQL. - * - * @param string $alias - * @param string $table - * - * @return Criteria A modified Criteria object. - */ - public function addAlias($alias, $table) - { - $this->aliases[$alias] = $table; - - return $this; - } - - /** - * Remove an alias for a table (useful when merging Criterias). - * - * @param string $alias - * - * @return Criteria A modified Criteria object. - */ - public function removeAlias($alias) - { - unset($this->aliases[$alias]); - - return $this; - } - - /** - * Returns the aliases for this Criteria - * - * @return array - */ - public function getAliases() - { - return $this->aliases; - } - - /** - * Returns the table name associated with an alias. - * - * @param string $alias - * @return string $string - */ - public function getTableForAlias($alias) - { - if (isset($this->aliases[$alias])) { - return $this->aliases[$alias]; - } - } - - /** - * Get the keys of the criteria map, i.e. the list of columns bearing a condition - * - * print_r($c->keys()); - * => array('book.price', 'book.title', 'author.first_name') - * - * - * @return array - */ - public function keys() - { - return array_keys($this->map); - } - - /** - * Does this Criteria object contain the specified key? - * - * @param string $column [table.]column - * @return boolean True if this Criteria object contain the specified key. - */ - public function containsKey($column) - { - // must use array_key_exists() because the key could - // exist but have a NULL value (that'd be valid). - return array_key_exists($column, $this->map); - } - - /** - * Does this Criteria object contain the specified key and does it have a value set for the key - * - * @param string $column [table.]column - * @return boolean True if this Criteria object contain the specified key and a value for that key - */ - public function keyContainsValue($column) - { - // must use array_key_exists() because the key could - // exist but have a NULL value (that'd be valid). - return (array_key_exists($column, $this->map) && ($this->map[$column]->getValue() !== null) ); - } - - /** - * Whether this Criteria has any where columns. - * - * This counts conditions added with the add() method. - * - * @return boolean - * @see add() - */ - public function hasWhereClause() - { - return !empty($this->map); - } - - /** - * Will force the sql represented by this criteria to be executed within - * a transaction. This is here primarily to support the oid type in - * postgresql. Though it can be used to require any single sql statement - * to use a transaction. - * @return void - */ - public function setUseTransaction($v) - { - $this->useTransaction = (boolean) $v; - } - - /** - * Whether the sql command specified by this criteria must be wrapped - * in a transaction. - * - * @return boolean - */ - public function isUseTransaction() - { - return $this->useTransaction; - } - - /** - * Method to return criteria related to columns in a table. - * - * Make sure you call containsKey($column) prior to calling this method, - * since no check on the existence of the $column is made in this method. - * - * @param string $column Column name. - * @return Criterion A Criterion object. - */ - public function getCriterion($column) - { - return $this->map[$column]; - } - - /** - * Method to return the latest Criterion in a table. - * - * @return Criterion A Criterion or null no Criterion is added. - */ - public function getLastCriterion() - { - if($cnt = count($this->map)) { - $map = array_values($this->map); - return $map[$cnt - 1]; - } - return null; - } - - /** - * Method to return criterion that is not added automatically - * to this Criteria. This can be used to chain the - * Criterions to form a more complex where clause. - * - * @param string $column Full name of column (for example TABLE.COLUMN). - * @param mixed $value - * @param string $comparison - * @return Criterion - */ - public function getNewCriterion($column, $value = null, $comparison = self::EQUAL) - { - return new Criterion($this, $column, $value, $comparison); - } - - /** - * Method to return a String table name. - * - * @param string $name Name of the key. - * @return string The value of the object at key. - */ - public function getColumnName($name) - { - if (isset($this->map[$name])) { - return $this->map[$name]->getColumn(); - } - return null; - } - - /** - * Shortcut method to get an array of columns indexed by table. - * - * print_r($c->getTablesColumns()); - * => array( - * 'book' => array('book.price', 'book.title'), - * 'author' => array('author.first_name') - * ) - * - * - * @return array array(table => array(table.column1, table.column2)) - */ - public function getTablesColumns() - { - $tables = array(); - foreach ($this->keys() as $key) { - $tableName = substr($key, 0, strrpos($key, '.' )); - $tables[$tableName][] = $key; - } - return $tables; - } - - /** - * Method to return a comparison String. - * - * @param string $key String name of the key. - * @return string A String with the value of the object at key. - */ - public function getComparison($key) - { - if ( isset ( $this->map[$key] ) ) { - return $this->map[$key]->getComparison(); - } - return null; - } - - /** - * Get the Database(Map) name. - * - * @return string A String with the Database(Map) name. - */ - public function getDbName() - { - return $this->dbName; - } - - /** - * Set the DatabaseMap name. If null is supplied, uses value - * provided by Propel::getDefaultDB(). - * - * @param string $dbName The Database (Map) name. - * @return void - */ - public function setDbName($dbName = null) - { - $this->dbName = ($dbName === null ? Propel::getDefaultDB() : $dbName); - } - - /** - * Get the primary table for this Criteria. - * - * This is useful for cases where a Criteria may not contain - * any SELECT columns or WHERE columns. This must be explicitly - * set, of course, in order to be useful. - * - * @return string - */ - public function getPrimaryTableName() - { - return $this->primaryTableName; - } - - /** - * Sets the primary table for this Criteria. - * - * This is useful for cases where a Criteria may not contain - * any SELECT columns or WHERE columns. This must be explicitly - * set, of course, in order to be useful. - * - * @param string $v - */ - public function setPrimaryTableName($tableName) - { - $this->primaryTableName = $tableName; - } - - /** - * Method to return a String table name. - * - * @param string $name The name of the key. - * @return string The value of table for criterion at key. - */ - public function getTableName($name) - { - if (isset($this->map[$name])) { - return $this->map[$name]->getTable(); - } - return null; - } - - /** - * Method to return the value that was added to Criteria. - * - * @param string $name A String with the name of the key. - * @return mixed The value of object at key. - */ - public function getValue($name) - { - if (isset($this->map[$name])) { - return $this->map[$name]->getValue(); - } - return null; - } - - /** - * An alias to getValue() -- exposing a Hashtable-like interface. - * - * @param string $key An Object. - * @return mixed The value within the Criterion (not the Criterion object). - */ - public function get($key) - { - return $this->getValue($key); - } - - /** - * Overrides Hashtable put, so that this object is returned - * instead of the value previously in the Criteria object. - * The reason is so that it more closely matches the behavior - * of the add() methods. If you want to get the previous value - * then you should first Criteria.get() it yourself. Note, if - * you attempt to pass in an Object that is not a String, it will - * throw a NPE. The reason for this is that none of the add() - * methods support adding anything other than a String as a key. - * - * @param string $key - * @param mixed $value - * @return Instance of self. - */ - public function put($key, $value) - { - return $this->add($key, $value); - } - - /** - * Copies all of the mappings from the specified Map to this Criteria - * These mappings will replace any mappings that this Criteria had for any - * of the keys currently in the specified Map. - * - * if the map was another Criteria, its attributes are copied to this - * Criteria, overwriting previous settings. - * - * @param mixed $t Mappings to be stored in this map. - */ - public function putAll($t) - { - if (is_array($t)) { - foreach ($t as $key=>$value) { - if ($value instanceof Criterion) { - $this->map[$key] = $value; - } else { - $this->put($key, $value); - } - } - } elseif ($t instanceof Criteria) { - $this->joins = $t->joins; - } - } - - /** - * This method adds a new criterion to the list of criterias. - * If a criterion for the requested column already exists, it is - * replaced. If is used as follow: - * - * - * $crit = new Criteria(); - * $crit->add($column, $value, Criteria::GREATER_THAN); - * - * - * Any comparison can be used. - * - * The name of the table must be used implicitly in the column name, - * so the Column name must be something like 'TABLE.id'. - * - * @param string $critOrColumn The column to run the comparison on, or Criterion object. - * @param mixed $value - * @param string $comparison A String. - * - * @return A modified Criteria object. - */ - public function add($p1, $value = null, $comparison = null) - { - if ($p1 instanceof Criterion) { - $this->map[$p1->getTable() . '.' . $p1->getColumn()] = $p1; - } else { - $criterion = new Criterion($this, $p1, $value, $comparison); - $this->map[$p1] = $criterion; - } - return $this; - } - - /** - * This method creates a new criterion but keeps it for later use with combine() - * Until combine() is called, the condition is not added to the query - * - * - * $crit = new Criteria(); - * $crit->addCond('cond1', $column1, $value1, Criteria::GREATER_THAN); - * $crit->addCond('cond2', $column2, $value2, Criteria::EQUAL); - * $crit->combine(array('cond1', 'cond2'), Criteria::LOGICAL_OR); - * - * - * Any comparison can be used. - * - * The name of the table must be used implicitly in the column name, - * so the Column name must be something like 'TABLE.id'. - * - * @param string $name name to combine the criterion later - * @param string $p1 The column to run the comparison on, or Criterion object. - * @param mixed $value - * @param string $comparison A String. - * - * @return A modified Criteria object. - */ - public function addCond($name, $p1, $value = null, $comparison = null) - { - if ($p1 instanceof Criterion) { - $this->namedCriterions[$name] = $p1; - } else { - $criterion = new Criterion($this, $p1, $value, $comparison); - $this->namedCriterions[$name] = $criterion; - } - return $this; - } - - /** - * Combine several named criterions with a logical operator - * - * @param array $criterions array of the name of the criterions to combine - * @param string $operator logical operator, either Criteria::LOGICAL_AND, or Criteria::LOGICAL_OR - * @param string $name optional name to combine the criterion later - */ - public function combine($criterions = array(), $operator = self::LOGICAL_AND, $name = null) - { - $operatorMethod = (strtoupper($operator) == self::LOGICAL_AND) ? 'addAnd' : 'addOr'; - $namedCriterions = array(); - foreach ($criterions as $key) { - if (array_key_exists($key, $this->namedCriterions)) { - $namedCriterions[]= $this->namedCriterions[$key]; - unset($this->namedCriterions[$key]); - } else { - throw new PropelException('Cannot combine unknown condition ' . $key); - } - } - $firstCriterion = array_shift($namedCriterions); - foreach ($namedCriterions as $criterion) { - $firstCriterion->$operatorMethod($criterion); - } - if ($name === null) { - $this->add($firstCriterion, null, null); - } else { - $this->addCond($name, $firstCriterion, null, null); - } - - return $this; - } - - /** - * This is the way that you should add a join of two tables. - * Example usage: - * - * $c->addJoin(ProjectPeer::ID, FooPeer::PROJECT_ID, Criteria::LEFT_JOIN); - * // LEFT JOIN FOO ON PROJECT.ID = FOO.PROJECT_ID - * - * - * @param mixed $left A String with the left side of the join. - * @param mixed $right A String with the right side of the join. - * @param mixed $operator A String with the join operator - * among Criteria::INNER_JOIN, Criteria::LEFT_JOIN, - * and Criteria::RIGHT_JOIN - * - * @return Criteria A modified Criteria object. - */ - public function addJoin($left, $right, $operator = null) - { - $join = new Join(); - if (!is_array($left)) { - // simple join - $join->addCondition($left, $right); - } else { - // join with multiple conditions - // deprecated: use addMultipleJoin() instead - foreach ($left as $key => $value) - { - $join->addCondition($value, $right[$key]); - } + /** Comparison type. */ + const LIKE = " LIKE "; + + /** Comparison type. */ + const NOT_LIKE = " NOT LIKE "; + + /** Comparison for array column types */ + const CONTAINS_ALL = "CONTAINS_ALL"; + + /** Comparison for array column types */ + const CONTAINS_SOME = "CONTAINS_SOME"; + + /** Comparison for array column types */ + const CONTAINS_NONE = "CONTAINS_NONE"; + + /** PostgreSQL comparison type */ + const ILIKE = " ILIKE "; + + /** PostgreSQL comparison type */ + const NOT_ILIKE = " NOT ILIKE "; + + /** Comparison type. */ + const CUSTOM = "CUSTOM"; + + /** Comparison type */ + const RAW = "RAW"; + + /** Comparison type for update */ + const CUSTOM_EQUAL = "CUSTOM_EQUAL"; + + /** Comparison type. */ + const DISTINCT = "DISTINCT"; + + /** Comparison type. */ + const IN = " IN "; + + /** Comparison type. */ + const NOT_IN = " NOT IN "; + + /** Comparison type. */ + const ALL = "ALL"; + + /** Comparison type. */ + const JOIN = "JOIN"; + + /** Binary math operator: AND */ + const BINARY_AND = "&"; + + /** Binary math operator: OR */ + const BINARY_OR = "|"; + + /** "Order by" qualifier - ascending */ + const ASC = "ASC"; + + /** "Order by" qualifier - descending */ + const DESC = "DESC"; + + /** "IS NULL" null comparison */ + const ISNULL = " IS NULL "; + + /** "IS NOT NULL" null comparison */ + const ISNOTNULL = " IS NOT NULL "; + + /** "CURRENT_DATE" ANSI SQL function */ + const CURRENT_DATE = "CURRENT_DATE"; + + /** "CURRENT_TIME" ANSI SQL function */ + const CURRENT_TIME = "CURRENT_TIME"; + + /** "CURRENT_TIMESTAMP" ANSI SQL function */ + const CURRENT_TIMESTAMP = "CURRENT_TIMESTAMP"; + + /** "LEFT JOIN" SQL statement */ + const LEFT_JOIN = "LEFT JOIN"; + + /** "RIGHT JOIN" SQL statement */ + const RIGHT_JOIN = "RIGHT JOIN"; + + /** "INNER JOIN" SQL statement */ + const INNER_JOIN = "INNER JOIN"; + + /** logical OR operator */ + const LOGICAL_OR = "OR"; + + /** logical AND operator */ + const LOGICAL_AND = "AND"; + + protected $ignoreCase = false; + protected $singleRecord = false; + + /** + * Storage of select data. Collection of column names. + * + * @var array + */ + protected $selectColumns = array(); + + /** + * Storage of aliased select data. Collection of column names. + * + * @var array + */ + protected $asColumns = array(); + + /** + * Storage of select modifiers data. Collection of modifier names. + * + * @var array + */ + protected $selectModifiers = array(); + + /** + * Storage of conditions data. Collection of Criterion objects. + * + * @var Criterion[] + */ + protected $map = array(); + + /** + * Storage of ordering data. Collection of column names. + * + * @var array + */ + protected $orderByColumns = array(); + + /** + * Storage of grouping data. Collection of column names. + * + * @var array + */ + protected $groupByColumns = array(); + + /** + * Storage of having data. + * + * @var Criterion + */ + protected $having = null; + + /** + * Storage of join data. collection of Join objects. + * + * @var array + */ + protected $joins = array(); + + /** + * @var Criteria[] + */ + protected $selectQueries = array(); + + /** + * The name of the database. + * + * @var string + */ + protected $dbName; + + /** + * The primary table for this Criteria. + * Useful in cases where there are no select or where + * columns. + * + * @var string + */ + protected $primaryTableName = null; + + /** The name of the database as given in the constructor. */ + protected $originalDbName; + + /** + * To limit the number of rows to return. 0 means return all + * rows. + */ + protected $limit = 0; + + /** To start the results at a row other than the first one. */ + protected $offset = 0; + + /** + * Comment to add to the SQL query + * + * @var string + */ + protected $queryComment = null; + + // flag to note that the criteria involves a blob. + protected $blobFlag = null; + + protected $aliases = array(); + + protected $useTransaction = false; + + /** + * Storage for Criterions expected to be combined + * + * @var array + */ + protected $namedCriterions = array(); + + /** + * Default operator for combination of criterions + * + * @see addUsingOperator + * @var string Criteria::LOGICAL_AND or Criteria::LOGICAL_OR + */ + protected $defaultCombineOperator = Criteria::LOGICAL_AND; + + /** + * Flags for boolean functions + * + * @var PropelConditionalProxy + */ + protected $conditionalProxy = null; + + /** + * Creates a new instance with the default capacity which corresponds to + * the specified database. + * + * @param string $dbName The database name. + */ + public function __construct($dbName = null) + { + $this->setDbName($dbName); + $this->originalDbName = $dbName; } - $join->setJoinType($operator); - - return $this->addJoinObject($join); - } - /** - * Add a join with multiple conditions - * @see http://propel.phpdb.org/trac/ticket/167, http://propel.phpdb.org/trac/ticket/606 - * - * Example usage: - * $c->addMultipleJoin(array( - * array(LeftPeer::LEFT_COLUMN, RightPeer::RIGHT_COLUMN), // if no third argument, defaults to Criteria::EQUAL - * array(FoldersPeer::alias( 'fo', FoldersPeer::LFT ), FoldersPeer::alias( 'parent', FoldersPeer::RGT ), Criteria::LESS_EQUAL ) - * ), - * Criteria::LEFT_JOIN - * ); - * - * @see addJoin() - * @param array $conditions An array of conditions, each condition being an array (left, right, operator) - * @param string $joinType A String with the join operator. Defaults to an implicit join. - * - * @return Criteria A modified Criteria object. - */ - public function addMultipleJoin($conditions, $joinType = null) - { - $join = new Join(); - foreach ($conditions as $condition) { - $join->addCondition($condition[0], $condition[1], isset($condition[2]) ? $condition[2] : Criteria::EQUAL); - } - $join->setJoinType($joinType); - - return $this->addJoinObject($join); - } - - /** - * Add a join object to the Criteria - * - * @param Join $join A join object - * - * @return Criteria A modified Criteria object - */ - public function addJoinObject(Join $join) - { - if (!in_array($join, $this->joins)) { // compare equality, NOT identity - $this->joins[] = $join; - } - return $this; - } + /** + * Implementing SPL IteratorAggregate interface. This allows + * you to foreach () over a Criteria object. + */ + public function getIterator() + { + return new CriterionIterator($this); + } + /** + * Get the criteria map, i.e. the array of Criterions + * + * @return Criterion[] + */ + public function getMap() + { + return $this->map; + } - /** - * Get the array of Joins. - * @return array Join[] - */ - public function getJoins() - { - return $this->joins; - } + /** + * Brings this criteria back to its initial state, so that it + * can be reused as if it was new. Except if the criteria has grown in + * capacity, it is left at the current capacity. + * + * @return void + */ + public function clear() + { + $this->map = array(); + $this->namedCriterions = array(); + $this->ignoreCase = false; + $this->singleRecord = false; + $this->selectModifiers = array(); + $this->selectColumns = array(); + $this->orderByColumns = array(); + $this->groupByColumns = array(); + $this->having = null; + $this->asColumns = array(); + $this->joins = array(); + $this->selectQueries = array(); + $this->dbName = $this->originalDbName; + $this->offset = 0; + $this->limit = 0; + $this->blobFlag = null; + $this->aliases = array(); + $this->useTransaction = false; + $this->conditionalProxy = null; + $this->defaultCombineOperator = Criteria::LOGICAL_AND; + $this->primaryTableName = null; + $this->queryComment = null; - /** - * Adds "ALL" modifier to the SQL statement. - * @return Criteria Modified Criteria object (for fluent API) - */ - public function setAll() - { - $this->removeSelectModifier(self::DISTINCT); - $this->addSelectModifier(self::ALL); - - return $this; - } + } - /** - * Adds "DISTINCT" modifier to the SQL statement. - * @return Criteria Modified Criteria object (for fluent API) - */ - public function setDistinct() - { - $this->removeSelectModifier(self::ALL); - $this->addSelectModifier(self::DISTINCT); - - return $this; - } - - /** - * Adds a modifier to the SQL statement. - * e.g. self::ALL, self::DISTINCT, 'SQL_CALC_FOUND_ROWS', 'HIGH_PRIORITY', etc. - * - * @param string $modifier The modifier to add - * - * @return Criteria Modified Criteria object (for fluent API) - */ - public function addSelectModifier($modifier) - { - //only allow the keyword once - if (!$this->hasSelectModifier($modifier)) { - $this->selectModifiers[] = $modifier; - } - - return $this; - } - - /** - * Removes a modifier to the SQL statement. - * Checks for existence before removal - * - * @param string $modifier The modifier to add - * - * @return Criteria Modified Criteria object (for fluent API) - */ - public function removeSelectModifier($modifier) - { - $this->selectModifiers = array_values(array_diff($this->selectModifiers, array($modifier))); - - return $this; - } - - /** - * Checks the existence of a SQL select modifier - * - * @param string $modifier The modifier to add - * - * @return bool - */ - public function hasSelectModifier($modifier) - { - return in_array($modifier, $this->selectModifiers); - } - - /** - * Sets ignore case. - * - * @param boolean $b True if case should be ignored. - * @return Criteria Modified Criteria object (for fluent API) - */ - public function setIgnoreCase($b) - { - $this->ignoreCase = (boolean) $b; - return $this; - } + /** + * Add an AS clause to the select columns. Usage: + * + * + * Criteria myCrit = new Criteria(); + * myCrit->addAsColumn("alias", "ALIAS(".MyPeer::ID.")"); + * + * + * @param string $name Wanted Name of the column (alias). + * @param string $clause SQL clause to select from the table + * + * If the name already exists, it is replaced by the new clause. + * + * @return Criteria A modified Criteria object. + */ + public function addAsColumn($name, $clause) + { + $this->asColumns[$name] = $clause; - /** - * Is ignore case on or off? - * - * @return boolean True if case is ignored. - */ - public function isIgnoreCase() - { - return $this->ignoreCase; - } + return $this; + } - /** - * Set single record? Set this to true if you expect the query - * to result in only a single result record (the default behaviour is to - * throw a PropelException if multiple records are returned when the query - * is executed). This should be used in situations where returning multiple - * rows would indicate an error of some sort. If your query might return - * multiple records but you are only interested in the first one then you - * should be using setLimit(1). - * - * @param boolean $b Set to TRUE if you expect the query to select just one record. - * @return Criteria Modified Criteria object (for fluent API) - */ - public function setSingleRecord($b) - { - $this->singleRecord = (boolean) $b; - return $this; - } + /** + * Get the column aliases. + * + * @return array An assoc array which map the column alias names + * to the alias clauses. + */ + public function getAsColumns() + { + return $this->asColumns; + } - /** - * Is single record? - * - * @return boolean True if a single record is being returned. - */ - public function isSingleRecord() - { - return $this->singleRecord; - } + /** + * Returns the column name associated with an alias (AS-column). + * + * @param string $as + * + * @return string|null $string The name if found, null otherwise. + */ + public function getColumnForAs($as) + { + if (isset($this->asColumns[$as])) { + return $this->asColumns[$as]; + } - /** - * Set limit. - * - * @param limit An int with the value for limit. - * @return Criteria Modified Criteria object (for fluent API) - */ - public function setLimit($limit) - { - // TODO: do we enforce int here? 32bit issue if we do - $this->limit = $limit; - return $this; - } + return null; + } - /** - * Get limit. - * - * @return int An int with the value for limit. - */ - public function getLimit() - { - return $this->limit; - } + /** + * Allows one to specify an alias for a table that can + * be used in various parts of the SQL. + * + * @param string $alias + * @param string $table + * + * @return Criteria A modified Criteria object. + */ + public function addAlias($alias, $table) + { + $this->aliases[$alias] = $table; - /** - * Set offset. - * - * @param int $offset An int with the value for offset. (Note this values is - * cast to a 32bit integer and may result in truncatation) - * @return Criteria Modified Criteria object (for fluent API) - */ - public function setOffset($offset) - { - $this->offset = (int) $offset; - return $this; - } + return $this; + } - /** - * Get offset. - * - * @return An int with the value for offset. - */ - public function getOffset() - { - return $this->offset; - } + /** + * Remove an alias for a table (useful when merging Criterias). + * + * @param string $alias + * + * @return Criteria A modified Criteria object. + */ + public function removeAlias($alias) + { + unset($this->aliases[$alias]); - /** - * Add select column. - * - * @param string $name Name of the select column. - * @return Criteria Modified Criteria object (for fluent API) - */ - public function addSelectColumn($name) - { - $this->selectColumns[] = $name; - return $this; - } - - /** - * Set the query comment, that appears after the first verb in the SQL query - * - * @param string $comment The comment to add to the query, without comment sign - * @return Criteria Modified Criteria object (for fluent API) - */ - public function setComment($comment = null) - { - $this->queryComment = $comment; - - return $this; - } - - /** - * Get the query comment, that appears after the first verb in the SQL query - * - * @return string The comment to add to the query, without comment sign - */ - public function getComment() - { - return $this->queryComment; - } - - /** - * Whether this Criteria has any select columns. - * - * This will include columns added with addAsColumn() method. - * - * @return boolean - * @see addAsColumn() - * @see addSelectColumn() - */ - public function hasSelectClause() - { - return (!empty($this->selectColumns) || !empty($this->asColumns)); - } - - /** - * Get select columns. - * - * @return array An array with the name of the select columns. - */ - public function getSelectColumns() - { - return $this->selectColumns; - } + return $this; + } - /** - * Clears current select columns. - * - * @return Criteria Modified Criteria object (for fluent API) - */ - public function clearSelectColumns() - { - $this->selectColumns = $this->asColumns = array(); - return $this; - } + /** + * Returns the aliases for this Criteria + * + * @return array + */ + public function getAliases() + { + return $this->aliases; + } - /** - * Get select modifiers. - * - * @return An array with the select modifiers. - */ - public function getSelectModifiers() - { - return $this->selectModifiers; - } + /** + * Returns the table name associated with an alias. + * + * @param string $alias + * + * @return string|null $string The name if given, null otherwise. + */ + public function getTableForAlias($alias) + { + if (isset($this->aliases[$alias])) { + return $this->aliases[$alias]; + } - /** - * Add group by column name. - * - * @param string $groupBy The name of the column to group by. - * @return A modified Criteria object. - */ - public function addGroupByColumn($groupBy) - { - $this->groupByColumns[] = $groupBy; - return $this; - } + return null; + } - /** - * Add order by column name, explicitly specifying ascending. - * - * @param name The name of the column to order by. - * @return A modified Criteria object. - */ - public function addAscendingOrderByColumn($name) - { - $this->orderByColumns[] = $name . ' ' . self::ASC; - return $this; - } + /** + * Returns the table name and alias based on a table alias or name. + * Use this method to get the details of a table name that comes in a clause, + * which can be either a table name or an alias name. + * + * @param string $tableAliasOrName + * + * @return array($tableName, $tableAlias) + */ + public function getTableNameAndAlias($tableAliasOrName) + { + if (isset($this->aliases[$tableAliasOrName])) { + return array($this->aliases[$tableAliasOrName], $tableAliasOrName); + } else { + return array($tableAliasOrName, null); + } + } - /** - * Add order by column name, explicitly specifying descending. - * - * @param string $name The name of the column to order by. - * @return Criteria Modified Criteria object (for fluent API) - */ - public function addDescendingOrderByColumn($name) - { - $this->orderByColumns[] = $name . ' ' . self::DESC; - return $this; - } + /** + * Get the keys of the criteria map, i.e. the list of columns bearing a condition + * + * print_r($c->keys()); + * => array('book.price', 'book.title', 'author.first_name') + * + * + * @return array + */ + public function keys() + { + return array_keys($this->map); + } - /** - * Get order by columns. - * - * @return array An array with the name of the order columns. - */ - public function getOrderByColumns() - { - return $this->orderByColumns; - } + /** + * Does this Criteria object contain the specified key? + * + * @param string $column [table.]column + * + * @return boolean True if this Criteria object contain the specified key. + */ + public function containsKey($column) + { + // must use array_key_exists() because the key could + // exist but have a NULL value (that'd be valid). + return array_key_exists($column, $this->map); + } - /** - * Clear the order-by columns. - * - * @return Criteria Modified Criteria object (for fluent API) - */ - public function clearOrderByColumns() - { - $this->orderByColumns = array(); - return $this; - } + /** + * Does this Criteria object contain the specified key and does it have a value set for the key + * + * @param string $column [table.]column + * + * @return boolean True if this Criteria object contain the specified key and a value for that key + */ + public function keyContainsValue($column) + { + // must use array_key_exists() because the key could + // exist but have a NULL value (that'd be valid). + return (array_key_exists($column, $this->map) && ($this->map[$column]->getValue() !== null)); + } - /** - * Clear the group-by columns. - * - * @return Criteria - */ - public function clearGroupByColumns() - { - $this->groupByColumns = array(); - return $this; - } + /** + * Whether this Criteria has any where columns. + * + * This counts conditions added with the add() method. + * + * @return boolean + * @see add() + */ + public function hasWhereClause() + { + return !empty($this->map); + } - /** - * Get group by columns. - * - * @return array - */ - public function getGroupByColumns() - { - return $this->groupByColumns; - } + /** + * Will force the sql represented by this criteria to be executed within + * a transaction. This is here primarily to support the oid type in + * postgresql. Though it can be used to require any single sql statement + * to use a transaction. + * + * @param bool $v + * + * @return void + */ + public function setUseTransaction($v) + { + $this->useTransaction = (boolean) $v; + } - /** - * Get Having Criterion. - * - * @return Criterion A Criterion object that is the having clause. - */ - public function getHaving() - { - return $this->having; - } - - /** - * Remove an object from the criteria. - * - * @param string $key A string with the key to be removed. - * @return mixed The removed value. - */ - public function remove($key) - { - if ( isset ( $this->map[$key] ) ) { - $removed = $this->map[$key]; - unset ( $this->map[$key] ); - if ( $removed instanceof Criterion ) { - return $removed->getValue(); - } - return $removed; - } - } + /** + * Whether the sql command specified by this criteria must be wrapped + * in a transaction. + * + * @return boolean + */ + public function isUseTransaction() + { + return $this->useTransaction; + } - /** - * Build a string representation of the Criteria. - * - * @return string A String with the representation of the Criteria. - */ - public function toString() - { + /** + * Method to return criteria related to columns in a table. + * + * Make sure you call containsKey($column) prior to calling this method, + * since no check on the existence of the $column is made in this method. + * + * @param string $column Column name. + * + * @return Criterion A Criterion object. + */ + public function getCriterion($column) + { + return $this->map[$column]; + } - $sb = "Criteria:"; - try { + /** + * Method to return the latest Criterion in a table. + * + * @return Criterion A Criterion or null no Criterion is added. + */ + public function getLastCriterion() + { + if ($cnt = count($this->map)) { + $map = array_values($this->map); - $params = array(); - $sb .= "\nSQL (may not be complete): " - . BasePeer::createSelectSql($this, $params); + return $map[$cnt - 1]; + } - $sb .= "\nParams: "; - $paramstr = array(); - foreach ($params as $param) { - $paramstr[] = $param['table'] . '.' . $param['column'] . ' => ' . var_export($param['value'], true); - } - $sb .= implode(", ", $paramstr); + return null; + } - } catch (Exception $exc) { - $sb .= "(Error: " . $exc->getMessage() . ")"; - } + /** + * Method to return criterion that is not added automatically + * to this Criteria. This can be used to chain the + * Criterions to form a more complex where clause. + * + * @param string $column Full name of column (for example TABLE.COLUMN). + * @param mixed $value + * @param string $comparison + * + * @return Criterion + */ + public function getNewCriterion($column, $value = null, $comparison = self::EQUAL) + { + return new Criterion($this, $column, $value, $comparison); + } - return $sb; - } + /** + * Method to return a String table name. + * + * @param string $name Name of the key. + * + * @return string The value of the object at key. + */ + public function getColumnName($name) + { + if (isset($this->map[$name])) { + return $this->map[$name]->getColumn(); + } - /** - * Returns the size (count) of this criteria. - * @return int - */ - public function size() - { - return count($this->map); - } + return null; + } - /** - * This method checks another Criteria to see if they contain - * the same attributes and hashtable entries. - * @return boolean - */ - public function equals($crit) - { - if ($crit === null || !($crit instanceof Criteria)) { - return false; - } elseif ($this === $crit) { - return true; - } elseif ($this->size() === $crit->size()) { + /** + * Shortcut method to get an array of columns indexed by table. + * + * print_r($c->getTablesColumns()); + * => array( + * 'book' => array('book.price', 'book.title'), + * 'author' => array('author.first_name') + * ) + * + * + * @return array array(table => array(table.column1, table.column2)) + */ + public function getTablesColumns() + { + $tables = array(); + foreach ($this->keys() as $key) { + $tableName = substr($key, 0, strrpos($key, '.')); + $tables[$tableName][] = $key; + } - // Important: nested criterion objects are checked + return $tables; + } - $criteria = $crit; // alias - if ($this->offset === $criteria->getOffset() - && $this->limit === $criteria->getLimit() - && $this->ignoreCase === $criteria->isIgnoreCase() - && $this->singleRecord === $criteria->isSingleRecord() - && $this->dbName === $criteria->getDbName() - && $this->selectModifiers === $criteria->getSelectModifiers() - && $this->selectColumns === $criteria->getSelectColumns() - && $this->asColumns === $criteria->getAsColumns() - && $this->orderByColumns === $criteria->getOrderByColumns() - && $this->groupByColumns === $criteria->getGroupByColumns() - && $this->aliases === $criteria->getAliases() - ) // what about having ?? - { - foreach ($criteria->keys() as $key) { - if ($this->containsKey($key)) { - $a = $this->getCriterion($key); - $b = $criteria->getCriterion($key); - if (!$a->equals($b)) { - return false; - } - } else { - return false; - } - } - $joins = $criteria->getJoins(); - if (count($joins) != count($this->joins)) { - return false; - } - foreach ($joins as $key => $join) { - if (!$join->equals($this->joins[$key])) { - return false; - } - } - return true; - } else { - return false; - } - } - return false; - } - - /** - * Add the content of a Criteria to the current Criteria - * In case of conflict, the current Criteria keeps its properties - * - * @param Criteria $criteria The criteria to read properties from - * @param string $operator The logical operator used to combine conditions - * Defaults to Criteria::LOGICAL_AND, also accapts Criteria::LOGICAL_OR - * - * @return Criteria The current criteria object - */ - public function mergeWith(Criteria $criteria, $operator = Criteria::LOGICAL_AND) - { - // merge limit - $limit = $criteria->getLimit(); - if($limit != 0 && $this->getLimit() == 0) { - $this->limit = $limit; - } - - // merge offset - $offset = $criteria->getOffset(); - if($offset != 0 && $this->getOffset() == 0) { - $this->offset = $offset; - } - - // merge select modifiers - $selectModifiers = $criteria->getSelectModifiers(); - if ($selectModifiers && ! $this->selectModifiers){ - $this->selectModifiers = $selectModifiers; - } - - // merge select columns - $this->selectColumns = array_merge($this->getSelectColumns(), $criteria->getSelectColumns()); - - // merge as columns - $commonAsColumns = array_intersect_key($this->getAsColumns(), $criteria->getAsColumns()); - if (!empty($commonAsColumns)) { - throw new PropelException('The given criteria contains an AsColumn with an alias already existing in the current object'); - } - $this->asColumns = array_merge($this->getAsColumns(), $criteria->getAsColumns()); - - // merge orderByColumns - $orderByColumns = array_merge($this->getOrderByColumns(), $criteria->getOrderByColumns()); - $this->orderByColumns = array_unique($orderByColumns); + /** + * Method to return a comparison String. + * + * @param string $key String name of the key. + * + * @return string A String with the value of the object at key. + */ + public function getComparison($key) + { + if (isset($this->map[$key])) { + return $this->map[$key]->getComparison(); + } - // merge groupByColumns - $groupByColumns = array_merge($this->getGroupByColumns(), $criteria->getGroupByColumns()); - $this->groupByColumns = array_unique($groupByColumns); - - // merge where conditions - if ($operator == Criteria::LOGICAL_AND) { - foreach ($criteria->getMap() as $key => $criterion) { - if ($this->containsKey($key)) { - $this->addAnd($criterion); - } else { - $this->add($criterion); - } - } - } else { - foreach ($criteria->getMap() as $key => $criterion) { - $this->addOr($criterion); - } - } + return null; + } - - // merge having - if ($having = $criteria->getHaving()) { - if ($this->getHaving()) { - $this->addHaving($this->getHaving()->addAnd($having)); - } else { - $this->addHaving($having); - } - } - - // merge alias - $commonAliases = array_intersect_key($this->getAliases(), $criteria->getAliases()); - if (!empty($commonAliases)) { - throw new PropelException('The given criteria contains an alias already existing in the current object'); - } - $this->aliases = array_merge($this->getAliases(), $criteria->getAliases()); - - // merge join - $this->joins = array_merge($this->getJoins(), $criteria->getJoins()); - - return $this; - } + /** + * Get the Database(Map) name. + * + * @return string A String with the Database(Map) name. + */ + public function getDbName() + { + return $this->dbName; + } - /** - * This method adds a prepared Criterion object to the Criteria as a having clause. - * You can get a new, empty Criterion object with the - * getNewCriterion() method. - * - *

- * - * $crit = new Criteria(); - * $c = $crit->getNewCriterion(BasePeer::ID, 5, Criteria::LESS_THAN); - * $crit->addHaving($c); - * - * - * @param having A Criterion object - * - * @return A modified Criteria object. - */ - public function addHaving(Criterion $having) - { - $this->having = $having; - return $this; - } + /** + * Set the DatabaseMap name. If null is supplied, uses value + * provided by Propel::getDefaultDB(). + * + * @param string $dbName The Database (Map) name. + * + * @return void + */ + public function setDbName($dbName = null) + { + $this->dbName = ($dbName === null ? Propel::getDefaultDB() : $dbName); + } - /** - * If a criterion for the requested column already exists, the condition is "AND"ed to the existing criterion (necessary for Propel 1.4 compatibility). - * If no criterion for the requested column already exists, the condition is "AND"ed to the latest criterion. - * If no criterion exist, the condition is added a new criterion - * - * Any comparison can be used. - * - * Supports a number of different signatures: - * - addAnd(column, value, comparison) - * - addAnd(column, value) - * - addAnd(Criterion) - * - * @return Criteria A modified Criteria object. - */ - public function addAnd($p1, $p2 = null, $p3 = null, $preferColumnCondition = true) - { - $criterion = ($p1 instanceof Criterion) ? $p1 : new Criterion($this, $p1, $p2, $p3); + /** + * Get the primary table for this Criteria. + * + * This is useful for cases where a Criteria may not contain + * any SELECT columns or WHERE columns. This must be explicitly + * set, of course, in order to be useful. + * + * @return string + */ + public function getPrimaryTableName() + { + return $this->primaryTableName; + } - $key = $criterion->getTable() . '.' . $criterion->getColumn(); - if ($preferColumnCondition && $this->containsKey($key)) { - // FIXME: addAnd() operates preferably on existing conditions on the same column - // this may cause unexpected results, but it's there for BC with Propel 14 - $this->getCriterion($key)->addAnd($criterion); - } else { - // simply add the condition to the list - this is the expected behavior - $this->add($criterion); - } + /** + * Sets the primary table for this Criteria. + * + * This is useful for cases where a Criteria may not contain + * any SELECT columns or WHERE columns. This must be explicitly + * set, of course, in order to be useful. + * + * @param string $tableName + */ + public function setPrimaryTableName($tableName) + { + $this->primaryTableName = $tableName; + } - return $this; - } - - /** - * If a criterion for the requested column already exists, the condition is "OR"ed to the existing criterion (necessary for Propel 1.4 compatibility). - * If no criterion for the requested column already exists, the condition is "OR"ed to the latest criterion. - * If no criterion exist, the condition is added a new criterion - * - * Any comparison can be used. - * - * Supports a number of different signatures: - * - addOr(column, value, comparison) - * - addOr(column, value) - * - addOr(Criterion) - * - * @return Criteria A modified Criteria object. - */ - public function addOr($p1, $p2 = null, $p3 = null, $preferColumnCondition = true) - { - $rightCriterion = ($p1 instanceof Criterion) ? $p1 : new Criterion($this, $p1, $p2, $p3); - - $key = $rightCriterion->getTable() . '.' . $rightCriterion->getColumn(); - if ($preferColumnCondition && $this->containsKey($key)) { - // FIXME: addOr() operates preferably on existing conditions on the same column - // this may cause unexpected results, but it's there for BC with Propel 14 - $leftCriterion = $this->getCriterion($key); - } else { - // fallback to the latest condition - this is the expected behavior - $leftCriterion = $this->getLastCriterion(); - } + /** + * Method to return a String table name. + * + * @param string $name The name of the key. + * + * @return string The value of table for criterion at key. + */ + public function getTableName($name) + { + if (isset($this->map[$name])) { + return $this->map[$name]->getTable(); + } - if ($leftCriterion !== null) { - // combine the given criterion with the existing one with an 'OR' - $leftCriterion->addOr($rightCriterion); - } else { - // nothing to do OR / AND with, so make it first condition - $this->add($rightCriterion); - } + return null; + } - return $this; - } + /** + * Method to return the value that was added to Criteria. + * + * @param string $name A String with the name of the key. + * + * @return mixed The value of object at key. + */ + public function getValue($name) + { + if (isset($this->map[$name])) { + return $this->map[$name]->getValue(); + } - // Fluid Conditions + return null; + } - /** - * Returns the current object if the condition is true, - * or a PropelConditionalProxy instance otherwise. - * Allows for conditional statements in a fluid interface. - * - * @param bool $cond - * - * @return PropelConditionalProxy|Criteria - */ - public function _if($cond) - { - if($cond) { - return $this; - } else { - return new PropelConditionalProxy($this); - } - } + /** + * An alias to getValue() -- exposing a Hashtable-like interface. + * + * @param string $key An Object. + * + * @return mixed The value within the Criterion (not the Criterion object). + */ + public function get($key) + { + return $this->getValue($key); + } - /** - * Returns a PropelConditionalProxy instance. - * Allows for conditional statements in a fluid interface. - * - * @param bool $cond ignored - * - * @return PropelConditionalProxy - */ - public function _elseif($cond) - { - return new PropelConditionalProxy($this); - } + /** + * Overrides Hashtable put, so that this object is returned + * instead of the value previously in the Criteria object. + * The reason is so that it more closely matches the behavior + * of the add() methods. If you want to get the previous value + * then you should first Criteria.get() it yourself. Note, if + * you attempt to pass in an Object that is not a String, it will + * throw a NPE. The reason for this is that none of the add() + * methods support adding anything other than a String as a key. + * + * @param string $key + * @param mixed $value + * + * @return Criteria A modified Criteria object. + */ + public function put($key, $value) + { + return $this->add($key, $value); + } - /** - * Returns a PropelConditionalProxy instance. - * Allows for conditional statements in a fluid interface. - * - * @return PropelConditionalProxy - */ - public function _else() - { - return new PropelConditionalProxy($this); - } + /** + * Copies all of the mappings from the specified Map to this Criteria + * These mappings will replace any mappings that this Criteria had for any + * of the keys currently in the specified Map. + * + * if the map was another Criteria, its attributes are copied to this + * Criteria, overwriting previous settings. + * + * @param mixed $t Mappings to be stored in this map. + */ + public function putAll($t) + { + if (is_array($t)) { + foreach ($t as $key => $value) { + if ($value instanceof Criterion) { + $this->map[$key] = $value; + } else { + $this->put($key, $value); + } + } + } elseif ($t instanceof Criteria) { + $this->joins = $t->joins; + } + } - /** - * Returns the current object - * Allows for conditional statements in a fluid interface. - * - * @return Criteria - */ - public function _endif() - { - return $this; - } - - /** - * Ensures deep cloning of attached objects - */ - public function __clone() - { - foreach ($this->map as $key => $criterion) { - $this->map[$key] = clone $criterion; - } - foreach ($this->joins as $key => $join) { - $this->joins[$key] = clone $join; - } - if (null !== $this->having) { - $this->having = clone $this->having; - } - } - + /** + * This method adds a new criterion to the list of criterias. + * If a criterion for the requested column already exists, it is + * replaced. If is used as follow: + * + * + * $crit = new Criteria(); + * $crit->add($column, $value, Criteria::GREATER_THAN); + * + * + * Any comparison can be used. + * + * The name of the table must be used implicitly in the column name, + * so the Column name must be something like 'TABLE.id'. + * + * @param string $critOrColumn The column to run the comparison on, or a Criterion object. + * @param mixed $value + * @param string $comparison A String. + * + * @return Criteria A modified Criteria object. + */ + public function add($critOrColumn, $value = null, $comparison = null) + { + $criterion = $this->getCriterionForCondition($critOrColumn, $value, $comparison); + if ($critOrColumn instanceof Criterion) { + $this->map[$critOrColumn->getTable() . '.' . $critOrColumn->getColumn()] = $criterion; + } else { + $this->map[$critOrColumn] = $criterion; + } + + return $this; + } + + /** + * This method creates a new criterion but keeps it for later use with combine() + * Until combine() is called, the condition is not added to the query + * + * + * $crit = new Criteria(); + * $crit->addCond('cond1', $column1, $value1, Criteria::GREATER_THAN); + * $crit->addCond('cond2', $column2, $value2, Criteria::EQUAL); + * $crit->combine(array('cond1', 'cond2'), Criteria::LOGICAL_OR); + * + * + * Any comparison can be used. + * + * The name of the table must be used implicitly in the column name, + * so the Column name must be something like 'TABLE.id'. + * + * @param string $name name to combine the criterion later + * @param string $p1 The column to run the comparison on, or Criterion object. + * @param mixed $value + * @param string $comparison A String. + * + * @return Criteria A modified Criteria object. + */ + public function addCond($name, $p1, $value = null, $comparison = null) + { + $this->namedCriterions[$name] = $this->getCriterionForCondition($p1, $value, $comparison); + + return $this; + } + + /** + * Combine several named criterions with a logical operator + * + * @param array $criterions array of the name of the criterions to combine + * @param string $operator logical operator, either Criteria::LOGICAL_AND, or Criteria::LOGICAL_OR + * @param string $name optional name to combine the criterion later + * + * @return Criteria + * + * @throws PropelException + */ + public function combine($criterions = array(), $operator = self::LOGICAL_AND, $name = null) + { + $operatorMethod = (strtoupper($operator) == self::LOGICAL_AND) ? 'addAnd' : 'addOr'; + $namedCriterions = array(); + foreach ($criterions as $key) { + if (array_key_exists($key, $this->namedCriterions)) { + $namedCriterions[] = $this->namedCriterions[$key]; + unset($this->namedCriterions[$key]); + } else { + throw new PropelException('Cannot combine unknown condition ' . $key); + } + } + $firstCriterion = array_shift($namedCriterions); + foreach ($namedCriterions as $criterion) { + $firstCriterion->$operatorMethod($criterion); + } + if ($name === null) { + $this->addAnd($firstCriterion, null, null); + } else { + $this->addCond($name, $firstCriterion, null, null); + } + + return $this; + } + + /** + * This is the way that you should add a join of two tables. + * Example usage: + * + * $c->addJoin(ProjectPeer::ID, FooPeer::PROJECT_ID, Criteria::LEFT_JOIN); + * // LEFT JOIN FOO ON (PROJECT.ID = FOO.PROJECT_ID) + * + * + * @param mixed $left A String with the left side of the join, or an array (@see addMultipleJoin). + * @param mixed $right A String with the right side of the join, or an array (@see addMultipleJoin). + * @param mixed $joinType A String with the join operator + * among Criteria::INNER_JOIN, Criteria::LEFT_JOIN, + * and Criteria::RIGHT_JOIN + * + * @return Criteria A modified Criteria object. + */ + public function addJoin($left, $right, $joinType = null) + { + if (is_array($left)) { + $conditions = array(); + foreach ($left as $key => $value) { + $condition = array($value, $right[$key]); + $conditions[] = $condition; + } + + return $this->addMultipleJoin($conditions, $joinType); + } + + $join = new Join(); + + // is the left table an alias ? + $dotpos = strrpos($left, '.'); + $leftTableAlias = substr($left, 0, $dotpos); + $leftColumnName = substr($left, $dotpos + 1); + list($leftTableName, $leftTableAlias) = $this->getTableNameAndAlias($leftTableAlias); + + // is the right table an alias ? + $dotpos = strrpos($right, '.'); + $rightTableAlias = substr($right, 0, $dotpos); + $rightColumnName = substr($right, $dotpos + 1); + list($rightTableName, $rightTableAlias) = $this->getTableNameAndAlias($rightTableAlias); + + $join->addExplicitCondition( + $leftTableName, $leftColumnName, $leftTableAlias, + $rightTableName, $rightColumnName, $rightTableAlias, + Join::EQUAL); + + $join->setJoinType($joinType); + + return $this->addJoinObject($join); + } + + /** + * Add a join with multiple conditions + * + * @deprecated use Join::setJoinCondition($criterion) instead + * + * @see http://propel.phpdb.org/trac/ticket/167, http://propel.phpdb.org/trac/ticket/606 + * + * Example usage: + * $c->addMultipleJoin(array( + * array(LeftPeer::LEFT_COLUMN, RightPeer::RIGHT_COLUMN), // if no third argument, defaults to Criteria::EQUAL + * array(FoldersPeer::alias( 'fo', FoldersPeer::LFT ), FoldersPeer::alias( 'parent', FoldersPeer::RGT ), Criteria::LESS_EQUAL ) + * ), + * Criteria::LEFT_JOIN + * ); + * + * @see addJoin() + * + * @param array $conditions An array of conditions, each condition being an array (left, right, operator) + * @param string $joinType A String with the join operator. Defaults to an implicit join. + * + * @return Criteria A modified Criteria object. + */ + public function addMultipleJoin($conditions, $joinType = null) + { + $join = new Join(); + $joinCondition = null; + foreach ($conditions as $condition) { + $left = $condition[0]; + $right = $condition[1]; + $operator = isset($condition[2]) ? $condition[2] : JOIN::EQUAL; + if ($pos = strrpos($left, '.')) { + $leftTableAlias = substr($left, 0, $pos); + $leftColumnName = substr($left, $pos + 1); + list($leftTableName, $leftTableAlias) = $this->getTableNameAndAlias($leftTableAlias); + } else { + list($leftTableName, $leftTableAlias) = array(null, null); + $leftColumnName = $left; + } + if (is_string($right) && $pos = strrpos($right, '.')) { + $rightTableAlias = substr($right, 0, $pos); + $rightColumnName = substr($right, $pos + 1); + list($rightTableName, $rightTableAlias) = $this->getTableNameAndAlias($rightTableAlias); + $conditionClause = $leftTableAlias ? $leftTableAlias . '.' : ($leftTableName ? $leftTableName . '.' : ''); + $conditionClause .= $leftColumnName; + $conditionClause .= $operator; + $conditionClause .= $rightTableAlias ? $rightTableAlias . '.' : ($rightTableName ? $rightTableName . '.' : ''); + $conditionClause .= $rightColumnName; + $comparison = Criteria::CUSTOM; + } else { + list($rightTableName, $rightTableAlias) = array(null, null); + $conditionClause = $right; + $comparison = $operator; + } + if (!$join->getRightTableName()) { + $join->setRightTableName($rightTableName); + } + if (!$join->getRightTableAlias()) { + $join->setRightTableAlias($rightTableAlias); + } + $criterion = $this->getNewCriterion($leftTableName . '.' . $leftColumnName, $conditionClause, $comparison); + if (null === $joinCondition) { + $joinCondition = $criterion; + } else { + /* @var $joinCondition Criterion */ + $joinCondition = $joinCondition->addAnd($criterion); + } + } + $join->setJoinType($joinType); + $join->setJoinCondition($joinCondition); + + return $this->addJoinObject($join); + } + + /** + * Add a join object to the Criteria + * + * @param Join $join A join object + * + * @return Criteria A modified Criteria object + */ + public function addJoinObject(Join $join) + { + $isAlreadyAdded = false; + foreach ($this->joins as $alreadyAddedJoin) { + if ($join->equals($alreadyAddedJoin)) { + $isAlreadyAdded = true; + break; + } + } + + if (!$isAlreadyAdded) { + $this->joins[] = $join; + } + + return $this; + } + + /** + * Get the array of Joins. + * + * @return array Join[] + */ + public function getJoins() + { + return $this->joins; + } + + /** + * Adds a Criteria as subQuery in the From Clause. + * + * @param Criteria $subQueryCriteria Criteria to build the subquery from + * @param string $alias alias for the subQuery + * + * @return Criteria this modified Criteria object (Fluid API) + */ + public function addSelectQuery(Criteria $subQueryCriteria, $alias = null) + { + if (null === $alias) { + $alias = 'alias_' . ($subQueryCriteria->forgeSelectQueryAlias() + count($this->selectQueries)); + } + $this->selectQueries[$alias] = $subQueryCriteria; + + return $this; + } + + /** + * Checks whether this Criteria has a subquery. + * + * @return boolean + */ + public function hasSelectQueries() + { + return (bool) $this->selectQueries; + } + + /** + * Get the associative array of Criteria for the subQueries per alias. + * + * @return Criteria[] + */ + public function getSelectQueries() + { + return $this->selectQueries; + } + + /** + * Get the Criteria for a specific subQuery. + * + * @param string $alias alias for the subQuery + * + * @return Criteria + */ + public function getSelectQuery($alias) + { + return $this->selectQueries[$alias]; + } + + /** + * checks if the Criteria for a specific subQuery is set. + * + * @param string $alias alias for the subQuery + * + * @return boolean + */ + public function hasSelectQuery($alias) + { + return isset($this->selectQueries[$alias]); + } + + public function forgeSelectQueryAlias() + { + $aliasNumber = 0; + foreach ($this->getSelectQueries() as $c1) { + /* @var $c1 Criteria */ + $aliasNumber += $c1->forgeSelectQueryAlias(); + } + + return ++$aliasNumber; + } + + /** + * Adds "ALL" modifier to the SQL statement. + * + * @return Criteria Modified Criteria object (for fluent API) + */ + public function setAll() + { + $this->removeSelectModifier(self::DISTINCT); + $this->addSelectModifier(self::ALL); + + return $this; + } + + /** + * Adds "DISTINCT" modifier to the SQL statement. + * + * @return Criteria Modified Criteria object (for fluent API) + */ + public function setDistinct() + { + $this->removeSelectModifier(self::ALL); + $this->addSelectModifier(self::DISTINCT); + + return $this; + } + + /** + * Adds a modifier to the SQL statement. + * e.g. self::ALL, self::DISTINCT, 'SQL_CALC_FOUND_ROWS', 'HIGH_PRIORITY', etc. + * + * @param string $modifier The modifier to add + * + * @return Criteria Modified Criteria object (for fluent API) + */ + public function addSelectModifier($modifier) + { + //only allow the keyword once + if (!$this->hasSelectModifier($modifier)) { + $this->selectModifiers[] = $modifier; + } + + return $this; + } + + /** + * Removes a modifier to the SQL statement. + * Checks for existence before removal + * + * @param string $modifier The modifier to add + * + * @return Criteria Modified Criteria object (for fluent API) + */ + public function removeSelectModifier($modifier) + { + $this->selectModifiers = array_values(array_diff($this->selectModifiers, array($modifier))); + + return $this; + } + + /** + * Checks the existence of a SQL select modifier + * + * @param string $modifier The modifier to add + * + * @return bool + */ + public function hasSelectModifier($modifier) + { + return in_array($modifier, $this->selectModifiers); + } + + /** + * Sets ignore case. + * + * @param boolean $b True if case should be ignored. + * + * @return Criteria Modified Criteria object (for fluent API) + */ + public function setIgnoreCase($b) + { + $this->ignoreCase = (boolean) $b; + + return $this; + } + + /** + * Is ignore case on or off? + * + * @return boolean True if case is ignored. + */ + public function isIgnoreCase() + { + return $this->ignoreCase; + } + + /** + * Set single record? Set this to true if you expect the query + * to result in only a single result record (the default behaviour is to + * throw a PropelException if multiple records are returned when the query + * is executed). This should be used in situations where returning multiple + * rows would indicate an error of some sort. If your query might return + * multiple records but you are only interested in the first one then you + * should be using setLimit(1). + * + * @param boolean $b Set to TRUE if you expect the query to select just one record. + * + * @return Criteria Modified Criteria object (for fluent API) + */ + public function setSingleRecord($b) + { + $this->singleRecord = (boolean) $b; + + return $this; + } + + /** + * Is single record? + * + * @return boolean True if a single record is being returned. + */ + public function isSingleRecord() + { + return $this->singleRecord; + } + + /** + * Set limit. + * + * @param int $limit An int with the value for limit. + * + * @return Criteria Modified Criteria object (for fluent API) + */ + public function setLimit($limit) + { + // TODO: do we enforce int here? 32bit issue if we do + $this->limit = $limit; + + return $this; + } + + /** + * Get limit. + * + * @return int An int with the value for limit. + */ + public function getLimit() + { + return $this->limit; + } + + /** + * Set offset. + * + * @param int $offset An int with the value for offset. (Note this values is + * cast to a 32bit integer and may result in truncation) + * + * @return Criteria Modified Criteria object (for fluent API) + */ + public function setOffset($offset) + { + $this->offset = (int) $offset; + + return $this; + } + + /** + * Get offset. + * + * @return int An int with the value for offset. + */ + public function getOffset() + { + return $this->offset; + } + + /** + * Add select column. + * + * @param string $name Name of the select column. + * + * @return Criteria Modified Criteria object (for fluent API) + */ + public function addSelectColumn($name) + { + $this->selectColumns[] = $name; + + return $this; + } + + /** + * Set the query comment, that appears after the first verb in the SQL query + * + * @param string $comment The comment to add to the query, without comment sign + * + * @return Criteria Modified Criteria object (for fluent API) + */ + public function setComment($comment = null) + { + $this->queryComment = $comment; + + return $this; + } + + /** + * Get the query comment, that appears after the first verb in the SQL query + * + * @return string The comment to add to the query, without comment sign + */ + public function getComment() + { + return $this->queryComment; + } + + /** + * Whether this Criteria has any select columns. + * + * This will include columns added with addAsColumn() method. + * + * @return boolean + * @see addAsColumn() + * @see addSelectColumn() + */ + public function hasSelectClause() + { + return (!empty($this->selectColumns) || !empty($this->asColumns)); + } + + /** + * Get select columns. + * + * @return array An array with the name of the select columns. + */ + public function getSelectColumns() + { + return $this->selectColumns; + } + + /** + * Clears current select columns. + * + * @return Criteria Modified Criteria object (for fluent API) + */ + public function clearSelectColumns() + { + $this->selectColumns = $this->asColumns = array(); + + return $this; + } + + /** + * Get select modifiers. + * + * @return array An array with the select modifiers. + */ + public function getSelectModifiers() + { + return $this->selectModifiers; + } + + /** + * Add group by column name. + * + * @param string $groupBy The name of the column to group by. + * + * @return Criteria Modified Criteria object (for fluent API) + */ + public function addGroupByColumn($groupBy) + { + $this->groupByColumns[] = $groupBy; + + return $this; + } + + /** + * Add order by column name, explicitly specifying ascending. + * + * @param string $name The name of the column to order by. + * + * @return Criteria Modified Criteria object (for fluent API) + */ + public function addAscendingOrderByColumn($name) + { + $this->orderByColumns[] = $name . ' ' . self::ASC; + + return $this; + } + + /** + * Add order by column name, explicitly specifying descending. + * + * @param string $name The name of the column to order by. + * + * @return Criteria Modified Criteria object (for fluent API) + */ + public function addDescendingOrderByColumn($name) + { + $this->orderByColumns[] = $name . ' ' . self::DESC; + + return $this; + } + + /** + * Get order by columns. + * + * @return array An array with the name of the order columns. + */ + public function getOrderByColumns() + { + return $this->orderByColumns; + } + + /** + * Clear the order-by columns. + * + * @return Criteria Modified Criteria object (for fluent API) + */ + public function clearOrderByColumns() + { + $this->orderByColumns = array(); + + return $this; + } + + /** + * Clear the group-by columns. + * + * @return Criteria + */ + public function clearGroupByColumns() + { + $this->groupByColumns = array(); + + return $this; + } + + /** + * Get group by columns. + * + * @return array + */ + public function getGroupByColumns() + { + return $this->groupByColumns; + } + + /** + * Get Having Criterion. + * + * @return Criterion A Criterion object that is the having clause. + */ + public function getHaving() + { + return $this->having; + } + + /** + * Remove an object from the criteria. + * + * @param string $key A string with the key to be removed. + * + * @return mixed|null The removed value, null if not set. + */ + public function remove($key) + { + if (isset($this->map[$key])) { + $removed = $this->map[$key]; + unset($this->map[$key]); + if ($removed instanceof Criterion) { + return $removed->getValue(); + } + + return $removed; + } + + return null; + } + + /** + * Build a string representation of the Criteria. + * + * @return string A String with the representation of the Criteria. + */ + public function toString() + { + + $sb = "Criteria:"; + try { + + $params = array(); + $sb .= "\nSQL (may not be complete): " + . BasePeer::createSelectSql($this, $params); + + $sb .= "\nParams: "; + $paramstr = array(); + foreach ($params as $param) { + $paramstr[] = $param['table'] . '.' . $param['column'] . ' => ' . var_export($param['value'], true); + } + $sb .= implode(", ", $paramstr); + } catch (Exception $exc) { + $sb .= "(Error: " . $exc->getMessage() . ")"; + } + + return $sb; + } + + /** + * Returns the size (count) of this criteria. + * + * @return int + */ + public function size() + { + return count($this->map); + } + + /** + * This method checks another Criteria to see if they contain + * the same attributes and hashtable entries. + * + * @param Criteria|null $crit + * + * @return boolean + */ + public function equals($crit) + { + if ($crit === null || !($crit instanceof Criteria)) { + return false; + } elseif ($this === $crit) { + return true; + } elseif ($this->size() === $crit->size()) { + + // Important: nested criterion objects are checked + + $criteria = $crit; // alias + if ($this->offset === $criteria->getOffset() + && $this->limit === $criteria->getLimit() + && $this->ignoreCase === $criteria->isIgnoreCase() + && $this->singleRecord === $criteria->isSingleRecord() + && $this->dbName === $criteria->getDbName() + && $this->selectModifiers === $criteria->getSelectModifiers() + && $this->selectColumns === $criteria->getSelectColumns() + && $this->asColumns === $criteria->getAsColumns() + && $this->orderByColumns === $criteria->getOrderByColumns() + && $this->groupByColumns === $criteria->getGroupByColumns() + && $this->aliases === $criteria->getAliases() + ) // what about having ?? + { + foreach ($criteria->keys() as $key) { + if ($this->containsKey($key)) { + $a = $this->getCriterion($key); + $b = $criteria->getCriterion($key); + if (!$a->equals($b)) { + return false; + } + } else { + return false; + } + } + $joins = $criteria->getJoins(); + if (count($joins) != count($this->joins)) { + return false; + } + foreach ($joins as $key => $join) { + /* @var $join Join */ + if (!$join->equals($this->joins[$key])) { + return false; + } + } + + return true; + } else { + return false; + } + } + + return false; + } + + /** + * Add the content of a Criteria to the current Criteria + * In case of conflict, the current Criteria keeps its properties + * + * @param Criteria $criteria The criteria to read properties from + * @param string $operator The logical operator used to combine conditions + * Defaults to Criteria::LOGICAL_AND, also accepts Criteria::LOGICAL_OR + * This parameter is deprecated, use _or() instead + * + * @return Criteria The current criteria object + * + * @throws PropelException + */ + public function mergeWith(Criteria $criteria, $operator = null) + { + // merge limit + $limit = $criteria->getLimit(); + if ($limit != 0 && $this->getLimit() == 0) { + $this->limit = $limit; + } + + // merge offset + $offset = $criteria->getOffset(); + if ($offset != 0 && $this->getOffset() == 0) { + $this->offset = $offset; + } + + // merge select modifiers + $selectModifiers = $criteria->getSelectModifiers(); + if ($selectModifiers && !$this->selectModifiers) { + $this->selectModifiers = $selectModifiers; + } + + // merge select columns + $this->selectColumns = array_merge($this->getSelectColumns(), $criteria->getSelectColumns()); + + // merge as columns + $commonAsColumns = array_intersect_key($this->getAsColumns(), $criteria->getAsColumns()); + if (!empty($commonAsColumns)) { + throw new PropelException('The given criteria contains an AsColumn with an alias already existing in the current object'); + } + $this->asColumns = array_merge($this->getAsColumns(), $criteria->getAsColumns()); + + // merge orderByColumns + $orderByColumns = array_merge($this->getOrderByColumns(), $criteria->getOrderByColumns()); + $this->orderByColumns = array_unique($orderByColumns); + + // merge groupByColumns + $groupByColumns = array_merge($this->getGroupByColumns(), $criteria->getGroupByColumns()); + $this->groupByColumns = array_unique($groupByColumns); + + // merge where conditions + if ($operator == Criteria::LOGICAL_OR) { + $this->_or(); + } + $isFirstCondition = true; + foreach ($criteria->getMap() as $key => $criterion) { + if ($isFirstCondition && $this->defaultCombineOperator == Criteria::LOGICAL_OR) { + $this->addOr($criterion, null, null, false); + $this->defaultCombineOperator = Criteria::LOGICAL_AND; + } elseif ($this->containsKey($key)) { + $this->addAnd($criterion); + } else { + $this->add($criterion); + } + $isFirstCondition = false; + } + + // merge having + if ($having = $criteria->getHaving()) { + if ($this->getHaving()) { + $this->addHaving($this->getHaving()->addAnd($having)); + } else { + $this->addHaving($having); + } + } + + // merge alias + $commonAliases = array_intersect_key($this->getAliases(), $criteria->getAliases()); + if (!empty($commonAliases)) { + throw new PropelException('The given criteria contains an alias already existing in the current object'); + } + $this->aliases = array_merge($this->getAliases(), $criteria->getAliases()); + + // merge join + $this->joins = array_merge($this->getJoins(), $criteria->getJoins()); + + return $this; + } + + /** + * This method adds a prepared Criterion object to the Criteria as a having clause. + * You can get a new, empty Criterion object with the + * getNewCriterion() method. + * + *

+ * + * $crit = new Criteria(); + * $c = $crit->getNewCriterion(BasePeer::ID, 5, Criteria::LESS_THAN); + * $crit->addHaving($c); + * + * + * @param mixed $p1 A Criterion, or a SQL clause with a question mark placeholder, or a column name + * @param mixed $value The value to bind in the condition + * @param mixed $comparison A Criteria class constant, or a PDO::PARAM_ class constant + * + * @return Criteria Modified Criteria object (for fluent API) + */ + public function addHaving($p1, $value = null, $comparison = null) + { + $this->having = $this->getCriterionForCondition($p1, $value, $comparison); + + return $this; + } + + /** + * Build a Criterion. + * + * This method has multiple signatures, and behaves differently according to it: + * + * - If the first argument is a Criterion, it just returns this Criterion. + * $c->getCriterionForCondition($criterion); // returns $criterion + * + * - If the last argument is a PDO::PARAM_* constant value, create a Criterion + * using Criteria::RAW and $comparison as a type. + * $c->getCriterionForCondition('foo like ?', '%bar%', PDO::PARAM_STR); + * + * - Otherwise, create a classic Criterion based on a column name and a comparison. + * $c->getCriterionForCondition(BookPeer::TITLE, 'War%', Criteria::LIKE); + * + * @param mixed $p1 A Criterion, or a SQL clause with a question mark placeholder, or a column name + * @param mixed $value The value to bind in the condition + * @param mixed $comparison A Criteria class constant, or a PDO::PARAM_ class constant + * + * @return Criterion + */ + protected function getCriterionForCondition($p1, $value = null, $comparison = null) + { + if ($p1 instanceof Criterion) { + // it's already a Criterion, so ignore $value and $comparison + return $p1; + } elseif (is_int($comparison)) { + // $comparison is a PDO::PARAM_* constant value + // something like $c->add('foo like ?', '%bar%', PDO::PARAM_STR); + return new Criterion($this, $p1, $value, Criteria::RAW, $comparison); + } + + // $comparison is one of Criteria's constants + // something like $c->add(BookPeer::TITLE, 'War%', Criteria::LIKE); + return new Criterion($this, $p1, $value, $comparison); + } + + /** + * If a criterion for the requested column already exists, the condition is "AND"ed to the existing criterion (necessary for Propel 1.4 compatibility). + * If no criterion for the requested column already exists, the condition is "AND"ed to the latest criterion. + * If no criterion exist, the condition is added a new criterion + * + * Any comparison can be used. + * + * Supports a number of different signatures: + * - addAnd(column, value, comparison) + * - addAnd(column, value) + * - addAnd(Criterion) + * + * @param mixed $p1 A Criterion, or a SQL clause with a question mark placeholder, or a column name + * @param mixed $value The value to bind in the condition + * @param mixed $comparison A Criteria class constant, or a PDO::PARAM_ class constant + * @param bool $preferColumnCondition + * + * @return Criteria A modified Criteria object. + */ + public function addAnd($p1, $value = null, $comparison = null, $preferColumnCondition = true) + { + $criterion = $this->getCriterionForCondition($p1, $value, $comparison); + + $key = $criterion->getTable() . '.' . $criterion->getColumn(); + if ($preferColumnCondition && $this->containsKey($key)) { + // FIXME: addAnd() operates preferably on existing conditions on the same column + // this may cause unexpected results, but it's there for BC with Propel 14 + $this->getCriterion($key)->addAnd($criterion); + } else { + // simply add the condition to the list - this is the expected behavior + $this->add($criterion); + } + + return $this; + } + + /** + * If a criterion for the requested column already exists, the condition is "OR"ed to the existing criterion (necessary for Propel 1.4 compatibility). + * If no criterion for the requested column already exists, the condition is "OR"ed to the latest criterion. + * If no criterion exist, the condition is added a new criterion + * + * Any comparison can be used. + * + * Supports a number of different signatures: + * - addOr(column, value, comparison) + * - addOr(column, value) + * - addOr(Criterion) + * + * @param mixed $p1 A Criterion, or a SQL clause with a question mark placeholder, or a column name + * @param mixed $value The value to bind in the condition + * @param mixed $comparison A Criteria class constant, or a PDO::PARAM_ class constant + * @param bool $preferColumnCondition + * + * @return Criteria A modified Criteria object. + */ + public function addOr($p1, $value = null, $comparison = null, $preferColumnCondition = true) + { + $rightCriterion = $this->getCriterionForCondition($p1, $value, $comparison); + + $key = $rightCriterion->getTable() . '.' . $rightCriterion->getColumn(); + if ($preferColumnCondition && $this->containsKey($key)) { + // FIXME: addOr() operates preferably on existing conditions on the same column + // this may cause unexpected results, but it's there for BC with Propel 14 + $leftCriterion = $this->getCriterion($key); + } else { + // fallback to the latest condition - this is the expected behavior + $leftCriterion = $this->getLastCriterion(); + } + + if ($leftCriterion !== null) { + // combine the given criterion with the existing one with an 'OR' + $leftCriterion->addOr($rightCriterion); + } else { + // nothing to do OR / AND with, so make it first condition + $this->add($rightCriterion); + } + + return $this; + } + + /** + * Overrides Criteria::add() to use the default combine operator + * + * @see Criteria::add() + * + * @param string|Criterion $p1 The column to run the comparison on (e.g. BookPeer::ID), or Criterion object + * @param mixed $value + * @param string $operator A String, like Criteria::EQUAL. + * @param boolean $preferColumnCondition If true, the condition is combined with an existing condition on the same column + * (necessary for Propel 1.4 compatibility). + * If false, the condition is combined with the last existing condition. + * + * @return Criteria A modified Criteria object. + */ + public function addUsingOperator($p1, $value = null, $operator = null, $preferColumnCondition = true) + { + if ($this->defaultCombineOperator == Criteria::LOGICAL_OR) { + $this->defaultCombineOperator = Criteria::LOGICAL_AND; + + return $this->addOr($p1, $value, $operator, $preferColumnCondition); + } else { + return $this->addAnd($p1, $value, $operator, $preferColumnCondition); + } + } + + // Fluid operators + + /** + * @return Criteria + */ + public function _or() + { + $this->defaultCombineOperator = Criteria::LOGICAL_OR; + + return $this; + } + + /** + * @return Criteria + */ + public function _and() + { + $this->defaultCombineOperator = Criteria::LOGICAL_AND; + + return $this; + } + + // Fluid Conditions + + /** + * Returns the current object if the condition is true, + * or a PropelConditionalProxy instance otherwise. + * Allows for conditional statements in a fluid interface. + * + * @param bool $cond + * + * @return PropelConditionalProxy|Criteria + */ + public function _if($cond) + { + $this->conditionalProxy = new PropelConditionalProxy($this, $cond, $this->conditionalProxy); + + return $this->conditionalProxy->getCriteriaOrProxy(); + } + + /** + * Returns a PropelConditionalProxy instance. + * Allows for conditional statements in a fluid interface. + * + * @param bool $cond ignored + * + * @return PropelConditionalProxy|Criteria + * + * @throws PropelException + */ + public function _elseif($cond) + { + if (!$this->conditionalProxy) { + throw new PropelException('_elseif() must be called after _if()'); + } + + return $this->conditionalProxy->_elseif($cond); + } + + /** + * Returns a PropelConditionalProxy instance. + * Allows for conditional statements in a fluid interface. + * + * @return PropelConditionalProxy|Criteria + * + * @throws PropelException + */ + public function _else() + { + if (!$this->conditionalProxy) { + throw new PropelException('_else() must be called after _if()'); + } + + return $this->conditionalProxy->_else(); + } + + /** + * Returns the current object + * Allows for conditional statements in a fluid interface. + * + * @return Criteria + * + * @throws PropelException + */ + public function _endif() + { + if (!$this->conditionalProxy) { + throw new PropelException('_endif() must be called after _if()'); + } + + $this->conditionalProxy = $this->conditionalProxy->getParentProxy(); + + if ($this->conditionalProxy) { + return $this->conditionalProxy->getCriteriaOrProxy(); + } + + // reached last level + return $this; + } + + /** + * Ensures deep cloning of attached objects + */ + public function __clone() + { + foreach ($this->map as $key => $criterion) { + $this->map[$key] = clone $criterion; + } + foreach ($this->joins as $key => $join) { + $this->joins[$key] = clone $join; + } + if (null !== $this->having) { + $this->having = clone $this->having; + } + } } diff --git a/airtime_mvc/library/propel/runtime/lib/query/Criterion.php b/airtime_mvc/library/propel/runtime/lib/query/Criterion.php index cc412bc05..61e631678 100644 --- a/airtime_mvc/library/propel/runtime/lib/query/Criterion.php +++ b/airtime_mvc/library/propel/runtime/lib/query/Criterion.php @@ -14,530 +14,590 @@ * In Torque this is an inner class of the Criteria class. * * @author Hans Lellelid (Propel) - * @version $Revision: 1740 $ + * @version $Revision$ * @package propel.runtime.query */ class Criterion { - const UND = " AND "; - const ODER = " OR "; + const UND = " AND "; + const ODER = " OR "; - /** Value of the CO. */ - protected $value; + /** Value of the CO. */ + protected $value; - /** Comparison value. - * @var SqlEnum - */ - protected $comparison; + /** Comparison value. + * + * @var string + */ + protected $comparison; - /** Table name. */ - protected $table; + /** Table name. */ + protected $table; - /** Real table name */ - protected $realtable; + /** Real table name */ + protected $realtable; - /** Column name. */ - protected $column; + /** Column name. */ + protected $column; - /** flag to ignore case in comparison */ - protected $ignoreStringCase = false; + /** + * Binding type to be used for Criteria::RAW comparison + * + * @var string any of the PDO::PARAM_ constant values + */ + protected $type; - /** - * The DBAdaptor which might be used to get db specific - * variations of sql. - */ - protected $db; + /** flag to ignore case in comparison */ + protected $ignoreStringCase = false; - /** - * other connected criteria and their conjunctions. - */ - protected $clauses = array(); - protected $conjunctions = array(); + /** + * The DBAdaptor which might be used to get db specific + * variations of sql. + */ + protected $db; - /** "Parent" Criteria class */ - protected $parent; + /** + * other connected criteria and their conjunctions. + * + * @var Criterion[] + */ + protected $clauses = array(); + protected $conjunctions = array(); - /** - * Create a new instance. - * - * @param Criteria $parent The outer class (this is an "inner" class). - * @param string $column TABLE.COLUMN format. - * @param mixed $value - * @param string $comparison - */ - public function __construct(Criteria $outer, $column, $value, $comparison = null) - { - $this->value = $value; - $dotPos = strrpos($column, '.'); - if ($dotPos === false) { - // no dot => aliased column - $this->table = null; - $this->column = $column; - } else { - $this->table = substr($column, 0, $dotPos); - $this->column = substr($column, $dotPos + 1); - } - $this->comparison = ($comparison === null) ? Criteria::EQUAL : $comparison; - $this->init($outer); - } + /** "Parent" Criteria class */ + protected $parent; - /** - * Init some properties with the help of outer class - * @param Criteria $criteria The outer class - */ - public function init(Criteria $criteria) - { - // init $this->db - try { - $db = Propel::getDB($criteria->getDbName()); - $this->setDB($db); - } catch (Exception $e) { - // we are only doing this to allow easier debugging, so - // no need to throw up the exception, just make note of it. - Propel::log("Could not get a DBAdapter, sql may be wrong", Propel::LOG_ERR); - } + /** + * Create a new instance. + * + * @param Criteria $outer The outer class (this is an "inner" class). + * @param string $column TABLE.COLUMN format. + * @param mixed $value + * @param string $comparison + * @param string $type + */ + public function __construct(Criteria $outer, $column, $value, $comparison = null, $type = null) + { + $this->value = $value; + $dotPos = strrpos($column, '.'); + if ($dotPos === false || $comparison == Criteria::RAW) { + // no dot => aliased column + $this->table = null; + $this->column = $column; + } else { + $this->table = substr($column, 0, $dotPos); + $this->column = substr($column, $dotPos + 1); + } + $this->comparison = ($comparison === null) ? Criteria::EQUAL : $comparison; + $this->type = $type; + $this->init($outer); + } - // init $this->realtable - $realtable = $criteria->getTableForAlias($this->table); - $this->realtable = $realtable ? $realtable : $this->table; + /** + * Init some properties with the help of outer class + * + * @param Criteria $criteria The outer class + */ + public function init(Criteria $criteria) + { + // init $this->db + try { + $db = Propel::getDB($criteria->getDbName()); + $this->setDB($db); + } catch (Exception $e) { + // we are only doing this to allow easier debugging, so + // no need to throw up the exception, just make note of it. + Propel::log("Could not get a DBAdapter, sql may be wrong", Propel::LOG_ERR); + } - } + // init $this->realtable + $realtable = $criteria->getTableForAlias($this->table); + $this->realtable = $realtable ? $realtable : $this->table; + } - /** - * Get the column name. - * - * @return string A String with the column name. - */ - public function getColumn() - { - return $this->column; - } + /** + * Get the column name. + * + * @return string A String with the column name. + */ + public function getColumn() + { + return $this->column; + } - /** - * Set the table name. - * - * @param name A String with the table name. - * @return void - */ - public function setTable($name) - { - $this->table = $name; - } + /** + * Set the table name. + * + * @param string $name A String with the table name. + * + * @return void + */ + public function setTable($name) + { + $this->table = $name; + } - /** - * Get the table name. - * - * @return string A String with the table name. - */ - public function getTable() - { - return $this->table; - } + /** + * Get the table name. + * + * @return string A String with the table name. + */ + public function getTable() + { + return $this->table; + } - /** - * Get the comparison. - * - * @return string A String with the comparison. - */ - public function getComparison() - { - return $this->comparison; - } + /** + * Get the comparison. + * + * @return string A String with the comparison. + */ + public function getComparison() + { + return $this->comparison; + } - /** - * Get the value. - * - * @return mixed An Object with the value. - */ - public function getValue() - { - return $this->value; - } + /** + * Get the value. + * + * @return mixed An Object with the value. + */ + public function getValue() + { + return $this->value; + } - /** - * Get the value of db. - * The DBAdapter which might be used to get db specific - * variations of sql. - * @return DBAdapter value of db. - */ - public function getDB() - { - return $this->db; - } + /** + * Get the value of db. + * The DBAdapter which might be used to get db specific + * variations of sql. + * + * @return DBAdapter value of db. + */ + public function getDB() + { + return $this->db; + } - /** - * Set the value of db. - * The DBAdapter might be used to get db specific variations of sql. - * @param DBAdapter $v Value to assign to db. - * @return void - */ - public function setDB(DBAdapter $v) - { - $this->db = $v; - foreach ( $this->clauses as $clause ) { - $clause->setDB($v); - } - } + /** + * Set the value of db. + * The DBAdapter might be used to get db specific variations of sql. + * + * @param DBAdapter $v Value to assign to db. + * + * @return void + */ + public function setDB(DBAdapter $v) + { + $this->db = $v; + foreach ($this->clauses as $clause) { + $clause->setDB($v); + } + } - /** - * Sets ignore case. - * - * @param boolean $b True if case should be ignored. - * @return Criterion A modified Criterion object. - */ - public function setIgnoreCase($b) - { - $this->ignoreStringCase = (boolean) $b; - return $this; - } + /** + * Sets ignore case. + * + * @param boolean $b True if case should be ignored. + * + * @return Criterion A modified Criterion object. + */ + public function setIgnoreCase($b) + { + $this->ignoreStringCase = (boolean) $b; - /** - * Is ignore case on or off? - * - * @return boolean True if case is ignored. - */ - public function isIgnoreCase() - { - return $this->ignoreStringCase; - } + return $this; + } - /** - * Get the list of clauses in this Criterion. - * @return array - */ - private function getClauses() - { - return $this->clauses; - } + /** + * Is ignore case on or off? + * + * @return boolean True if case is ignored. + */ + public function isIgnoreCase() + { + return $this->ignoreStringCase; + } - /** - * Get the list of conjunctions in this Criterion - * @return array - */ - public function getConjunctions() - { - return $this->conjunctions; - } + /** + * Get the list of clauses in this Criterion. + * + * @return array + */ + private function getClauses() + { + return $this->clauses; + } - /** - * Append an AND Criterion onto this Criterion's list. - */ - public function addAnd(Criterion $criterion) - { - $this->clauses[] = $criterion; - $this->conjunctions[] = self::UND; - return $this; - } + /** + * Get the list of conjunctions in this Criterion + * + * @return array + */ + public function getConjunctions() + { + return $this->conjunctions; + } - /** - * Append an OR Criterion onto this Criterion's list. - * @return Criterion - */ - public function addOr(Criterion $criterion) - { - $this->clauses[] = $criterion; - $this->conjunctions[] = self::ODER; - return $this; - } + /** + * Append an AND Criterion onto this Criterion's list. + */ + public function addAnd(Criterion $criterion) + { + $this->clauses[] = $criterion; + $this->conjunctions[] = self::UND; - /** - * Appends a Prepared Statement representation of the Criterion - * onto the buffer. - * - * @param string &$sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended - * @return void - * @throws PropelException - if the expression builder cannot figure out how to turn a specified - * expression into proper SQL. - */ - public function appendPsTo(&$sb, array &$params) - { - $sb .= str_repeat ( '(', count($this->clauses) ); - - $this->dispatchPsHandling($sb, $params); + return $this; + } - foreach ($this->clauses as $key => $clause) { - $sb .= $this->conjunctions[$key]; - $clause->appendPsTo($sb, $params); - $sb .= ')'; - } - } - - /** - * Figure out which Criterion method to use - * to build the prepared statement and parameters using to the Criterion comparison - * and call it to append the prepared statement and the parameters of the current clause - * - * @param string &$sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended - */ - protected function dispatchPsHandling(&$sb, array &$params) - { - switch ($this->comparison) { - case Criteria::CUSTOM: - // custom expression with no parameter binding - $this->appendCustomToPs($sb, $params); - break; - case Criteria::IN: - case Criteria::NOT_IN: - // table.column IN (?, ?) or table.column NOT IN (?, ?) - $this->appendInToPs($sb, $params); - break; - case Criteria::LIKE: - case Criteria::NOT_LIKE: - case Criteria::ILIKE: - case Criteria::NOT_ILIKE: - // table.column LIKE ? or table.column NOT LIKE ? (or ILIKE for Postgres) - $this->appendLikeToPs($sb, $params); - break; - default: - // table.column = ? or table.column >= ? etc. (traditional expressions, the default) - $this->appendBasicToPs($sb, $params); - } - } - - /** - * Appends a Prepared Statement representation of the Criterion onto the buffer - * For custom expressions with no binding, e.g. 'NOW() = 1' - * - * @param string &$sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended - */ - protected function appendCustomToPs(&$sb, array &$params) - { - if ($this->value !== "") { - $sb .= (string) $this->value; - } - } + /** + * Append an OR Criterion onto this Criterion's list. + * + * @param Criterion $criterion + * + * @return Criterion + */ + public function addOr(Criterion $criterion) + { + $this->clauses[] = $criterion; + $this->conjunctions[] = self::ODER; - /** - * Appends a Prepared Statement representation of the Criterion onto the buffer - * For IN expressions, e.g. table.column IN (?, ?) or table.column NOT IN (?, ?) - * - * @param string &$sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended - */ - protected function appendInToPs(&$sb, array &$params) - { - if ($this->value !== "") { - $bindParams = array(); - $index = count($params); // to avoid counting the number of parameters for each element in the array - foreach ((array) $this->value as $value) { - $params[] = array('table' => $this->realtable, 'column' => $this->column, 'value' => $value); - $index++; // increment this first to correct for wanting bind params to start with :p1 - $bindParams[] = ':p' . $index; - } - if (count($bindParams)) { - $field = ($this->table === null) ? $this->column : $this->table . '.' . $this->column; - $sb .= $field . $this->comparison . '(' . implode(',', $bindParams) . ')'; - } else { - $sb .= ($this->comparison === Criteria::IN) ? "1<>1" : "1=1"; - } - } - } + return $this; + } - /** - * Appends a Prepared Statement representation of the Criterion onto the buffer - * For LIKE expressions, e.g. table.column LIKE ? or table.column NOT LIKE ? (or ILIKE for Postgres) - * - * @param string &$sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended - */ - protected function appendLikeToPs(&$sb, array &$params) - { - $field = ($this->table === null) ? $this->column : $this->table . '.' . $this->column; - $db = $this->getDb(); - // If selection is case insensitive use ILIKE for PostgreSQL or SQL - // UPPER() function on column name for other databases. - if ($this->ignoreStringCase) { - if ($db instanceof DBPostgres) { - if ($this->comparison === Criteria::LIKE) { - $this->comparison = Criteria::ILIKE; - } elseif ($this->comparison === Criteria::NOT_LIKE) { - $this->comparison = Criteria::NOT_ILIKE; - } - } else { - $field = $db->ignoreCase($field); - } - } - - $params[] = array('table' => $this->realtable, 'column' => $this->column, 'value' => $this->value); - - $sb .= $field . $this->comparison; + /** + * Appends a Prepared Statement representation of the Criterion + * onto the buffer. + * + * @param string &$sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * + * @return void + * @throws PropelException - if the expression builder cannot figure out how to turn a specified + * expression into proper SQL. + */ + public function appendPsTo(&$sb, array &$params) + { + $sb .= str_repeat('(', count($this->clauses)); - // If selection is case insensitive use SQL UPPER() function - // on criteria or, if Postgres we are using ILIKE, so not necessary. - if ($this->ignoreStringCase && !($db instanceof DBPostgres)) { - $sb .= $db->ignoreCase(':p'.count($params)); - } else { - $sb .= ':p'.count($params); - } - } + $this->dispatchPsHandling($sb, $params); - /** - * Appends a Prepared Statement representation of the Criterion onto the buffer - * For traditional expressions, e.g. table.column = ? or table.column >= ? etc. - * - * @param string &$sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended - */ - protected function appendBasicToPs(&$sb, array &$params) - { - $field = ($this->table === null) ? $this->column : $this->table . '.' . $this->column; - // NULL VALUES need special treatment because the SQL syntax is different - // i.e. table.column IS NULL rather than table.column = null - if ($this->value !== null) { + foreach ($this->clauses as $key => $clause) { + $sb .= $this->conjunctions[$key]; + $clause->appendPsTo($sb, $params); + $sb .= ')'; + } + } - // ANSI SQL functions get inserted right into SQL (not escaped, etc.) - if ($this->value === Criteria::CURRENT_DATE || $this->value === Criteria::CURRENT_TIME || $this->value === Criteria::CURRENT_TIMESTAMP) { - $sb .= $field . $this->comparison . $this->value; - } else { - - $params[] = array('table' => $this->realtable, 'column' => $this->column, 'value' => $this->value); - - // default case, it is a normal col = value expression; value - // will be replaced w/ '?' and will be inserted later using PDO bindValue() - if ($this->ignoreStringCase) { - $sb .= $this->getDb()->ignoreCase($field) . $this->comparison . $this->getDb()->ignoreCase(':p'.count($params)); - } else { - $sb .= $field . $this->comparison . ':p'.count($params); - } - - } - } else { + /** + * Figure out which Criterion method to use + * to build the prepared statement and parameters using to the Criterion comparison + * and call it to append the prepared statement and the parameters of the current clause + * + * @param string &$sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + */ + protected function dispatchPsHandling(&$sb, array &$params) + { + switch ($this->comparison) { + case Criteria::CUSTOM: + // custom expression with no parameter binding + $this->appendCustomToPs($sb, $params); + break; + case Criteria::RAW: + // custom expression with a typed parameter binding + $this->appendRawToPs($sb, $params); + break; + case Criteria::IN: + case Criteria::NOT_IN: + // table.column IN (?, ?) or table.column NOT IN (?, ?) + $this->appendInToPs($sb, $params); + break; + case Criteria::LIKE: + case Criteria::NOT_LIKE: + case Criteria::ILIKE: + case Criteria::NOT_ILIKE: + // table.column LIKE ? or table.column NOT LIKE ? (or ILIKE for Postgres) + $this->appendLikeToPs($sb, $params); + break; + default: + // table.column = ? or table.column >= ? etc. (traditional expressions, the default) + $this->appendBasicToPs($sb, $params); + } + } - // value is null, which means it was either not specified or specifically - // set to null. - if ($this->comparison === Criteria::EQUAL || $this->comparison === Criteria::ISNULL) { - $sb .= $field . Criteria::ISNULL; - } elseif ($this->comparison === Criteria::NOT_EQUAL || $this->comparison === Criteria::ISNOTNULL) { - $sb .= $field . Criteria::ISNOTNULL; - } else { - // for now throw an exception, because not sure how to interpret this - throw new PropelException("Could not build SQL for expression: $field " . $this->comparison . " NULL"); - } + /** + * Appends a Prepared Statement representation of the Criterion onto the buffer + * For custom expressions with no binding, e.g. 'NOW() = 1' + * + * @param string &$sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + */ + protected function appendCustomToPs(&$sb, array &$params) + { + if ($this->value !== "") { + $sb .= (string) $this->value; + } + } - } - } - - /** - * This method checks another Criteria to see if they contain - * the same attributes and hashtable entries. - * @return boolean - */ - public function equals($obj) - { - // TODO: optimize me with early outs - if ($this === $obj) { - return true; - } + /** + * Appends a Prepared Statement representation of the Criterion onto the buffer + * For custom expressions with a typed binding, e.g. 'foobar = ?' + * + * @param string &$sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * + * @throws PropelException + */ + protected function appendRawToPs(&$sb, array &$params) + { + if (substr_count($this->column, '?') != 1) { + throw new PropelException(sprintf('Could not build SQL for expression "%s" because Criteria::RAW works only with a clause containing a single question mark placeholder', $this->column)); + } + $params[] = array('table' => null, 'type' => $this->type, 'value' => $this->value); + $sb .= str_replace('?', ':p' . count($params), $this->column); + } - if (($obj === null) || !($obj instanceof Criterion)) { - return false; - } + /** + * Appends a Prepared Statement representation of the Criterion onto the buffer + * For IN expressions, e.g. table.column IN (?, ?) or table.column NOT IN (?, ?) + * + * @param string &$sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + */ + protected function appendInToPs(&$sb, array &$params) + { + if ($this->value !== "") { + $bindParams = array(); + $index = count($params); // to avoid counting the number of parameters for each element in the array + foreach ((array) $this->value as $value) { + $params[] = array('table' => $this->realtable, 'column' => $this->column, 'value' => $value); + $index++; // increment this first to correct for wanting bind params to start with :p1 + $bindParams[] = ':p' . $index; + } + if (count($bindParams)) { + $field = ($this->table === null) ? $this->column : $this->table . '.' . $this->column; + $sb .= $field . $this->comparison . '(' . implode(',', $bindParams) . ')'; + } else { + $sb .= ($this->comparison === Criteria::IN) ? "1<>1" : "1=1"; + } + } + } - $crit = $obj; + /** + * Appends a Prepared Statement representation of the Criterion onto the buffer + * For LIKE expressions, e.g. table.column LIKE ? or table.column NOT LIKE ? (or ILIKE for Postgres) + * + * @param string &$sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + */ + protected function appendLikeToPs(&$sb, array &$params) + { + $field = ($this->table === null) ? $this->column : $this->table . '.' . $this->column; + $db = $this->getDb(); + // If selection is case insensitive use ILIKE for PostgreSQL or SQL + // UPPER() function on column name for other databases. + if ($this->ignoreStringCase) { + if ($db instanceof DBPostgres) { + if ($this->comparison === Criteria::LIKE) { + $this->comparison = Criteria::ILIKE; + } elseif ($this->comparison === Criteria::NOT_LIKE) { + $this->comparison = Criteria::NOT_ILIKE; + } + } else { + $field = $db->ignoreCase($field); + } + } - $isEquiv = ( ( ($this->table === null && $crit->getTable() === null) - || ( $this->table !== null && $this->table === $crit->getTable() ) - ) - && $this->column === $crit->getColumn() - && $this->comparison === $crit->getComparison()); + $params[] = array('table' => $this->realtable, 'column' => $this->column, 'value' => $this->value); - // check chained criterion + $sb .= $field . $this->comparison; - $clausesLength = count($this->clauses); - $isEquiv &= (count($crit->getClauses()) == $clausesLength); - $critConjunctions = $crit->getConjunctions(); - $critClauses = $crit->getClauses(); - for ($i=0; $i < $clausesLength && $isEquiv; $i++) { - $isEquiv &= ($this->conjunctions[$i] === $critConjunctions[$i]); - $isEquiv &= ($this->clauses[$i] === $critClauses[$i]); - } + // If selection is case insensitive use SQL UPPER() function + // on criteria or, if Postgres we are using ILIKE, so not necessary. + if ($this->ignoreStringCase && !($db instanceof DBPostgres)) { + $sb .= $db->ignoreCase(':p' . count($params)); + } else { + $sb .= ':p' . count($params); + } + } - if ($isEquiv) { - $isEquiv &= $this->value === $crit->getValue(); - } + /** + * Appends a Prepared Statement representation of the Criterion onto the buffer + * For traditional expressions, e.g. table.column = ? or table.column >= ? etc. + * + * @param string &$sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * + * @throws PropelException + */ + protected function appendBasicToPs(&$sb, array &$params) + { + $field = ($this->table === null) ? $this->column : $this->table . '.' . $this->column; + // NULL VALUES need special treatment because the SQL syntax is different + // i.e. table.column IS NULL rather than table.column = null + if ($this->value !== null) { - return $isEquiv; - } + // ANSI SQL functions get inserted right into SQL (not escaped, etc.) + if ($this->value === Criteria::CURRENT_DATE || $this->value === Criteria::CURRENT_TIME || $this->value === Criteria::CURRENT_TIMESTAMP) { + $sb .= $field . $this->comparison . $this->value; + } else { - /** - * Returns a hash code value for the object. - */ - public function hashCode() - { - $h = crc32(serialize($this->value)) ^ crc32($this->comparison); + $params[] = array('table' => $this->realtable, 'column' => $this->column, 'value' => $this->value); - if ($this->table !== null) { - $h ^= crc32($this->table); - } + // default case, it is a normal col = value expression; value + // will be replaced w/ '?' and will be inserted later using PDO bindValue() + if ($this->ignoreStringCase) { + $sb .= $this->getDb()->ignoreCase($field) . $this->comparison . $this->getDb()->ignoreCase(':p' . count($params)); + } else { + $sb .= $field . $this->comparison . ':p' . count($params); + } + } + } else { - if ($this->column !== null) { - $h ^= crc32($this->column); - } + // value is null, which means it was either not specified or specifically + // set to null. + if ($this->comparison === Criteria::EQUAL || $this->comparison === Criteria::ISNULL) { + $sb .= $field . Criteria::ISNULL; + } elseif ($this->comparison === Criteria::NOT_EQUAL || $this->comparison === Criteria::ISNOTNULL) { + $sb .= $field . Criteria::ISNOTNULL; + } else { + // for now throw an exception, because not sure how to interpret this + throw new PropelException("Could not build SQL for expression: $field " . $this->comparison . " NULL"); + } + } + } - foreach ( $this->clauses as $clause ) { - // TODO: i KNOW there is a php incompatibility with the following line - // but i dont remember what it is, someone care to look it up and - // replace it if it doesnt bother us? - // $clause->appendPsTo($sb='',$params=array()); - $sb = ''; - $params = array(); - $clause->appendPsTo($sb,$params); - $h ^= crc32(serialize(array($sb,$params))); - unset ( $sb, $params ); - } + /** + * This method checks another Criteria to see if they contain + * the same attributes and hashtable entries. + * + * @param Criterion|null $obj + * + * @return boolean + */ + public function equals($obj) + { + // TODO: optimize me with early outs + if ($this === $obj) { + return true; + } - return $h; - } + if (($obj === null) || !($obj instanceof Criterion)) { + return false; + } - /** - * Get all tables from nested criterion objects - * @return array - */ - public function getAllTables() - { - $tables = array(); - $this->addCriterionTable($this, $tables); - return $tables; - } + $crit = $obj; - /** - * method supporting recursion through all criterions to give - * us a string array of tables from each criterion - * @return void - */ - private function addCriterionTable(Criterion $c, array &$s) - { - $s[] = $c->getTable(); - foreach ( $c->getClauses() as $clause ) { - $this->addCriterionTable($clause, $s); - } - } - - /** - * get an array of all criterion attached to this - * recursing through all sub criterion - * @return array Criterion[] - */ - public function getAttachedCriterion() - { - $criterions = array($this); - foreach ($this->getClauses() as $criterion) { - $criterions = array_merge($criterions, $criterion->getAttachedCriterion()); - } - return $criterions; - } - - /** - * Ensures deep cloning of attached objects - */ - public function __clone() - { - foreach ($this->clauses as $key => $criterion) { - $this->clauses[$key] = clone $criterion; - } - } -} \ No newline at end of file + $isEquiv = ( ( ($this->table === null && $crit->getTable() === null) + || ( $this->table !== null && $this->table === $crit->getTable() ) + ) + && $this->column === $crit->getColumn() + && $this->comparison === $crit->getComparison()); + + // check chained criterion + + $clausesLength = count($this->clauses); + $isEquiv &= (count($crit->getClauses()) == $clausesLength); + $critConjunctions = $crit->getConjunctions(); + $critClauses = $crit->getClauses(); + for ($i = 0; $i < $clausesLength && $isEquiv; $i++) { + $isEquiv &= ($this->conjunctions[$i] === $critConjunctions[$i]); + $isEquiv &= ($this->clauses[$i] === $critClauses[$i]); + } + + if ($isEquiv) { + $isEquiv &= $this->value === $crit->getValue(); + } + + return $isEquiv; + } + + /** + * Returns a hash code value for the object. + */ + public function hashCode() + { + $h = crc32(serialize($this->value)) ^ crc32($this->comparison); + + if ($this->table !== null) { + $h ^= crc32($this->table); + } + + if ($this->column !== null) { + $h ^= crc32($this->column); + } + + foreach ($this->clauses as $clause) { + // TODO: I KNOW there is a php incompatibility with the following line + // but I don't remember what it is, someone care to look it up and + // replace it if it doesn't bother us? + // $clause->appendPsTo($sb='',$params=array()); + $sb = ''; + $params = array(); + $clause->appendPsTo($sb, $params); + $h ^= crc32(serialize(array($sb, $params))); + unset ($sb, $params); + } + + return $h; + } + + /** + * Get all tables from nested criterion objects + * + * @return array + */ + public function getAllTables() + { + $tables = array(); + $this->addCriterionTable($this, $tables); + + return $tables; + } + + /** + * method supporting recursion through all criterions to give + * us a string array of tables from each criterion + * + * @param Criterion $c + * @param array &$s + * + * @return void + */ + private function addCriterionTable(Criterion $c, array &$s) + { + $s[] = $c->getTable(); + foreach ($c->getClauses() as $clause) { + $this->addCriterionTable($clause, $s); + } + } + + /** + * get an array of all criterion attached to this + * recursing through all sub criterion + * + * @return Criterion[] + */ + public function getAttachedCriterion() + { + $criterions = array($this); + foreach ($this->getClauses() as $criterion) { + /* @var $criterion Criterion */ + $criterions = array_merge($criterions, $criterion->getAttachedCriterion()); + } + + return $criterions; + } + + /** + * Ensures deep cloning of attached objects + */ + public function __clone() + { + foreach ($this->clauses as $key => $criterion) { + $this->clauses[$key] = clone $criterion; + } + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/query/CriterionIterator.php b/airtime_mvc/library/propel/runtime/lib/query/CriterionIterator.php index 12f29ff66..82dc058f3 100644 --- a/airtime_mvc/library/propel/runtime/lib/query/CriterionIterator.php +++ b/airtime_mvc/library/propel/runtime/lib/query/CriterionIterator.php @@ -7,48 +7,53 @@ * * @license MIT License */ - + /** * Class that implements SPL Iterator interface. This allows foreach () to * be used w/ Criteria objects. Probably there is no performance advantage * to doing it this way, but it makes sense -- and simpler code. * * @author Hans Lellelid - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.query */ class CriterionIterator implements Iterator { - private $idx = 0; - private $criteria; - private $criteriaKeys; - private $criteriaSize; + private $idx = 0; + private $criteria; + private $criteriaKeys; + private $criteriaSize; - public function __construct(Criteria $criteria) { - $this->criteria = $criteria; - $this->criteriaKeys = $criteria->keys(); - $this->criteriaSize = count($this->criteriaKeys); - } + public function __construct(Criteria $criteria) + { + $this->criteria = $criteria; + $this->criteriaKeys = $criteria->keys(); + $this->criteriaSize = count($this->criteriaKeys); + } - public function rewind() { - $this->idx = 0; - } + public function rewind() + { + $this->idx = 0; + } - public function valid() { - return $this->idx < $this->criteriaSize; - } + public function valid() + { + return $this->idx < $this->criteriaSize; + } - public function key() { - return $this->criteriaKeys[$this->idx]; - } + public function key() + { + return $this->criteriaKeys[$this->idx]; + } - public function current() { - return $this->criteria->getCriterion($this->criteriaKeys[$this->idx]); - } - - public function next() { - $this->idx++; - } + public function current() + { + return $this->criteria->getCriterion($this->criteriaKeys[$this->idx]); + } + public function next() + { + $this->idx++; + } } diff --git a/airtime_mvc/library/propel/runtime/lib/query/Join.php b/airtime_mvc/library/propel/runtime/lib/query/Join.php index de7b92b5e..bd1b2ba08 100644 --- a/airtime_mvc/library/propel/runtime/lib/query/Join.php +++ b/airtime_mvc/library/propel/runtime/lib/query/Join.php @@ -27,224 +27,562 @@ */ class Join { - // default comparison type - const EQUAL = "="; - - // the left parts of the join condition - protected $left = array(); + // default comparison type + const EQUAL = "="; + const INNER_JOIN = 'INNER JOIN'; - // the right parts of the join condition - protected $right = array(); + // the left parts of the join condition + protected $left = array(); - // the comparison operators for each pair of columns in the join condition - protected $operator = array(); - - // the type of the join (LEFT JOIN, ...), or null for an implicit join - protected $joinType = null; - - // the number of conditions in the join - protected $count = 0; + // the right parts of the join condition + protected $right = array(); - /** - * Constructor - * Use it preferably with no arguments, and then use addCondition() and setJoinType() - * Syntax with arguments used mainly for backwards compatibility - * - * @param string $leftColumn The left column of the join condition - * (may contain an alias name) - * @param string $rightColumn The right column of the join condition - * (may contain an alias name) - * @param string $joinType The type of the join. Valid join types are null (implicit join), - * Criteria::LEFT_JOIN, Criteria::RIGHT_JOIN, and Criteria::INNER_JOIN - */ - public function __construct($leftColumn = null, $rightColumn = null, $joinType = null) - { - if(!is_null($leftColumn)) { - if (!is_array($leftColumn)) { - // simple join - $this->addCondition($leftColumn, $rightColumn); - } else { - // join with multiple conditions - if (count($leftColumn) != count($rightColumn) ) { - throw new PropelException("Unable to create join because the left column count isn't equal to the right column count"); - } - foreach ($leftColumn as $key => $value) - { - $this->addCondition($value, $rightColumn[$key]); - } - } - $this->setJoinType($joinType); - } - } - - /** - * Join condition definition - * - * @param string $left The left column of the join condition - * (may contain an alias name) - * @param string $right The right column of the join condition - * (may contain an alias name) - * @param string $operator The comparison operator of the join condition, default Join::EQUAL - */ - public function addCondition($left, $right, $operator = self::EQUAL) - { - $this->left[] = $left; - $this->right[] = $right; - $this->operator[] = $operator; - $this->count++; - } - - /** - * Retrieve the number of conditions in the join - * - * @return integer The number of conditions in the join - */ - public function countConditions() - { - return $this->count; - } - - /** - * Return an array of the join conditions - * - * @return array An array of arrays representing (left, comparison, right) for each condition - */ - public function getConditions() - { - $conditions = array(); - for ($i=0; $i < $this->count; $i++) { - $conditions[] = array( - 'left' => $this->getLeftColumn($i), - 'operator' => $this->getOperator($i), - 'right' => $this->getRightColumn($i) - ); - } - return $conditions; - } + // the comparison operators for each pair of columns in the join condition + protected $operator = array(); - /** - * @return the comparison operator for the join condition - */ - public function getOperator($index = 0) - { - return $this->operator[$index]; - } - - public function getOperators() - { - return $this->operator; - } - - /** - * Set the join type - * - * @param string $joinType The type of the join. Valid join types are - * null (adding the join condition to the where clause), - * Criteria::LEFT_JOIN(), Criteria::RIGHT_JOIN(), and Criteria::INNER_JOIN() - */ - public function setJoinType($joinType = null) - { - $this->joinType = $joinType; - } - - /** - * Get the join type - * - * @return string The type of the join, i.e. Criteria::LEFT_JOIN(), ..., - * or null for adding the join condition to the where Clause - */ - public function getJoinType() - { - return $this->joinType; - } + // the type of the join (LEFT JOIN, ...) + protected $joinType; - /** - * @return the left column of the join condition - */ - public function getLeftColumn($index = 0) - { - return $this->left[$index]; - } - - /** - * @return all right columns of the join condition - */ - public function getLeftColumns() - { - return $this->left; - } + // the number of conditions in the join + protected $count = 0; + // the database adapter + protected $db; - public function getLeftColumnName($index = 0) - { - return substr($this->left[$index], strrpos($this->left[$index], '.') + 1); - } + protected $leftTableName; + protected $rightTableName; + protected $leftTableAlias; + protected $rightTableAlias; - public function getLeftTableName($index = 0) - { - return substr($this->left[$index], 0, strrpos($this->left[$index], '.')); - } + protected $joinCondition; - /** - * @return the right column of the join condition - */ - public function getRightColumn($index = 0) - { - return $this->right[$index]; - } - - /** - * @return all right columns of the join condition - */ - public function getRightColumns() - { - return $this->right; - } + /** + * Constructor + * Use it preferably with no arguments, and then use addCondition() and setJoinType() + * Syntax with arguments used mainly for backwards compatibility + * + * @param string $leftColumn The left column of the join condition + * (may contain an alias name) + * @param string $rightColumn The right column of the join condition + * (may contain an alias name) + * @param string $joinType The type of the join. Valid join types are null (implicit join), + * Criteria::LEFT_JOIN, Criteria::RIGHT_JOIN, and Criteria::INNER_JOIN + */ + public function __construct($leftColumn = null, $rightColumn = null, $joinType = null) + { + if (null !== $leftColumn) { + if (is_array($leftColumn)) { + // join with multiple conditions + $this->addConditions($leftColumn, $rightColumn); + } else { + // simple join + $this->addCondition($leftColumn, $rightColumn); + } + } + if (null !== $joinType) { + $this->setJoinType($joinType); + } + } - public function getRightColumnName($index = 0) - { - return substr($this->right[$index], strrpos($this->right[$index], '.') + 1); - } + /** + * Join condition definition. + * Warning: doesn't support table aliases. Use the explicit methods to use aliases. + * + * @param string $left The left column of the join condition + * (may contain an alias name) + * @param string $right The right column of the join condition + * (may contain an alias name) + * @param string $operator The comparison operator of the join condition, default Join::EQUAL + */ + public function addCondition($left, $right, $operator = self::EQUAL) + { + if ($pos = strrpos($left, '.')) { + list($this->leftTableName, $this->left[]) = explode('.', $left); + } else { + $this->left[] = $left; + } + if ($pos = strrpos($right, '.')) { + list($this->rightTableName, $this->right[]) = explode('.', $right); + } else { + $this->right[] = $right; + } + $this->operator[] = $operator; + $this->count++; + } - public function getRightTableName($index = 0) - { - return substr($this->right[$index], 0, strrpos($this->right[$index], '.')); - } + /** + * Join condition definition, for several conditions + * + * @param array $lefts The left columns of the join condition + * @param array $rights The right columns of the join condition + * @param array $operators The comparison operators of the join condition, default Join::EQUAL + * + * @throws PropelException + */ + public function addConditions($lefts, $rights, $operators = array()) + { + if (count($lefts) != count($rights)) { + throw new PropelException("Unable to create join because the left column count isn't equal to the right column count"); + } + foreach ($lefts as $key => $left) { + $this->addCondition($left, $rights[$key], isset($operators[$key]) ? $operators[$key] : self::EQUAL); + } + } - public function equals($join) - { - return $join !== null - && $join instanceof Join - && $this->joinType == $join->getJoinType() - && $this->getConditions() == $join->getConditions(); - } - - /** - * returns a String representation of the class, - * mainly for debugging purposes - * - * @return string A String representation of the class - */ - public function toString() - { - $result = ''; - if ($this->joinType !== null) { - $result .= $this->joinType . ' : '; - } - foreach ($this->getConditions() as $index => $condition) { - $result .= implode($condition); - if ($index + 1 < $this->count) { - $result .= ' AND '; - } - } - $result .= '(ignoreCase not considered)'; - - return $result; - } - - public function __toString() - { - return $this->toString(); - } + /** + * Join condition definition. + * + * @example + * + * $join = new Join(); + * $join->setJoinType(Criteria::LEFT_JOIN); + * $join->addExplicitCondition('book', 'AUTHOR_ID', null, 'author', 'ID', 'a', Join::EQUAL); + * echo $join->getClause(); + * // LEFT JOIN author a ON (book.AUTHOR_ID=a.ID) + * + * + * @param string $leftTableName + * @param string $leftColumnName + * @param string $leftTableAlias + * @param string $rightTableName + * @param string $rightColumnName + * @param string $rightTableAlias + * @param string $operator The comparison operator of the join condition, default Join::EQUAL + */ + public function addExplicitCondition($leftTableName, $leftColumnName, $leftTableAlias, $rightTableName, $rightColumnName, $rightTableAlias = null, $operator = self::EQUAL) + { + $this->leftTableName = $leftTableName; + $this->leftTableAlias = $leftTableAlias; + $this->rightTableName = $rightTableName; + $this->rightTableAlias = $rightTableAlias; + $this->left[] = $leftColumnName; + $this->right[] = $rightColumnName; + $this->operator[] = $operator; + $this->count++; + } + + /** + * Retrieve the number of conditions in the join + * + * @return integer The number of conditions in the join + */ + public function countConditions() + { + return $this->count; + } + + /** + * Return an array of the join conditions + * + * @return array An array of arrays representing (left, comparison, right) for each condition + */ + public function getConditions() + { + $conditions = array(); + for ($i = 0; $i < $this->count; $i++) { + $conditions[] = array( + 'left' => $this->getLeftColumn($i), + 'operator' => $this->getOperator($i), + 'right' => $this->getRightColumn($i) + ); + } + + return $conditions; + } + + /** + * @param string $operator the comparison operator for the join condition + */ + public function addOperator($operator = null) + { + $this->operator [] = $operator; + } + + /** + * @param int $index + * + * @return string the comparison operator for the join condition + */ + public function getOperator($index = 0) + { + return $this->operator[$index]; + } + + public function getOperators() + { + return $this->operator; + } + + /** + * Set the join type + * + * @param string $joinType The type of the join. Valid join types are + * null (adding the join condition to the where clause), + * Criteria::LEFT_JOIN(), Criteria::RIGHT_JOIN(), and Criteria::INNER_JOIN() + */ + public function setJoinType($joinType = null) + { + $this->joinType = $joinType; + } + + /** + * Get the join type + * + * @return string The type of the join, i.e. Criteria::LEFT_JOIN() + */ + public function getJoinType() + { + return null === $this->joinType ? self::INNER_JOIN : $this->joinType; + } + + /** + * Add a left column name to the join condition + * + * @example + * + * $join->setLeftTableName('book'); + * $join->addLeftColumnName('AUTHOR_ID'); + * + * + * @param string $left The name of the left column to add + */ + public function addLeftColumnName($left) + { + $this->left[] = $left; + } + + /** + * Get the fully qualified name of the left column of the join condition + * + * @example + * + * $join->addCondition('book.AUTHOR_ID', 'author.ID'); + * echo $join->getLeftColumn(); // 'book.AUTHOR_ID' + * + * + * @param integer $index The number of the condition to use + * + * @return string + */ + public function getLeftColumn($index = 0) + { + $tableName = $this->getLeftTableAliasOrName(); + + return $tableName ? $tableName . '.' . $this->left[$index] : $this->left[$index]; + } + + /** + * Get the left column name of the join condition + * + * @example + * + * $join->addCondition('book.AUTHOR_ID', 'author.ID'); + * echo $join->getLeftColumnName(); // 'AUTHOR_ID' + * + * + * @param integer $index The number of the condition to use + * + * @return string + */ + public function getLeftColumnName($index = 0) + { + return $this->left[$index]; + } + + /** + * Get the list of all the names of left columns of the join condition + * + * @return array + */ + public function getLeftColumns() + { + $columns = array(); + foreach ($this->left as $index => $column) { + $columns[] = $this->getLeftColumn($index); + } + + return $columns; + } + + public function setLeftTableName($leftTableName) + { + $this->leftTableName = $leftTableName; + + return $this; + } + + public function getLeftTableName() + { + return $this->leftTableName; + } + + public function setLeftTableAlias($leftTableAlias) + { + $this->leftTableAlias = $leftTableAlias; + + return $this; + } + + public function getLeftTableAlias() + { + return $this->leftTableAlias; + } + + public function hasLeftTableAlias() + { + return null !== $this->leftTableAlias; + } + + public function getLeftTableAliasOrName() + { + return $this->leftTableAlias ? $this->leftTableAlias : $this->leftTableName; + } + + public function getLeftTableWithAlias() + { + return $this->leftTableAlias ? $this->leftTableName . ' ' . $this->leftTableAlias : $this->leftTableName; + } + + /** + * Add a right column name to the join condition + * + * @example + * + * $join->setRightTableName('author'); + * $join->addRightColumnName('ID'); + * + * + * @param string $right The name of the right column to add + */ + public function addRightColumnName($right) + { + $this->right[] = $right; + } + + /** + * Get the fully qualified name of the right column of the join condition + * + * @example + * + * $join->addCondition('book.AUTHOR_ID', 'author.ID'); + * echo $join->getLeftColumn(); // 'author.ID' + * + * + * @param integer $index The number of the condition to use + * + * @return string + */ + public function getRightColumn($index = 0) + { + $tableName = $this->getRightTableAliasOrName(); + + return $tableName ? $tableName . '.' . $this->right[$index] : $this->right[$index]; + } + + /** + * Get the right column name of the join condition + * + * @example + * + * $join->addCondition('book.AUTHOR_ID', 'author.ID'); + * echo $join->getLeftColumn(); // 'ID' + * + * + * @param integer $index The number of the condition to use + * + * @return string + */ + public function getRightColumnName($index = 0) + { + return $this->right[$index]; + } + + /** + * @return all right columns of the join condition + */ + public function getRightColumns() + { + $columns = array(); + foreach ($this->right as $index => $column) { + $columns[] = $this->getRightColumn($index); + } + + return $columns; + } + + public function setRightTableName($rightTableName) + { + $this->rightTableName = $rightTableName; + + return $this; + } + + public function getRightTableName() + { + return $this->rightTableName; + } + + public function setRightTableAlias($rightTableAlias) + { + $this->rightTableAlias = $rightTableAlias; + + return $this; + } + + public function getRightTableAlias() + { + return $this->rightTableAlias; + } + + public function hasRightTableAlias() + { + return null !== $this->rightTableAlias; + } + + public function getRightTableAliasOrName() + { + return $this->rightTableAlias ? $this->rightTableAlias : $this->rightTableName; + } + + public function getRightTableWithAlias() + { + return $this->rightTableAlias ? $this->rightTableName . ' ' . $this->rightTableAlias : $this->rightTableName; + } + + /** + * Get the value of db. + * The DBAdapter which might be used to get db specific + * variations of sql. + * + * @return DBAdapter value of db. + */ + public function getDB() + { + return $this->db; + } + + /** + * Set the value of db. + * The DBAdapter might be used to get db specific variations of sql. + * + * @param DBAdapter $db Value to assign to db. + * + * @return void + */ + public function setDB(DBAdapter $db) + { + $this->db = $db; + } + + /** + * Set a custom join condition + * + * @param Criterion $joinCondition a Join condition + */ + public function setJoinCondition(Criterion $joinCondition) + { + $this->joinCondition = $joinCondition; + } + + /** + * Get the custom join condition, if previously set + * + * @return Criterion + */ + public function getJoinCondition() + { + return $this->joinCondition; + } + + /** + * Set the custom join condition Criterion based on the conditions of this join + * + * @param Criteria $c A Criteria object to get Criterions from + */ + public function buildJoinCondition(Criteria $c) + { + $joinCondition = null; + for ($i = 0; $i < $this->count; $i++) { + $criterion = $c->getNewCriterion($this->getLeftColumn($i), $this->getLeftColumn($i) . $this->getOperator($i) . $this->getRightColumn($i), Criteria::CUSTOM); + if (null === $joinCondition) { + $joinCondition = $criterion; + } else { + $joinCondition = $joinCondition->addAnd($criterion); + } + } + $this->joinCondition = $joinCondition; + } + + /** + * Get the join clause for this Join. + * If the join condition needs binding, uses the passed params array. + * + * @example + * + * $join = new Join(); + * $join->addExplicitCondition('book', 'AUTHOR_ID', null, 'author', 'ID'); + * $params = array(); + * echo $j->getClause($params); + * // 'LEFT JOIN author ON (book.AUTHOR_ID=author.ID)' + * + * + * @param array &$params + * + * @return string SQL join clause with join condition + */ + public function getClause(&$params) + { + if (null === $this->joinCondition) { + $conditions = array(); + for ($i = 0; $i < $this->count; $i++) { + $conditions [] = $this->getLeftColumn($i) . $this->getOperator($i) . $this->getRightColumn($i); + } + $joinCondition = sprintf('(%s)', implode($conditions, ' AND ')); + } else { + $joinCondition = ''; + $this->getJoinCondition()->appendPsTo($joinCondition, $params); + } + + $rightTableName = $this->getRightTableWithAlias(); + + if (null !== $this->db && $this->db->useQuoteIdentifier()) { + $rightTableName = $this->db->quoteIdentifierTable($rightTableName); + } + + return sprintf('%s %s ON %s', + $this->getJoinType(), + $rightTableName, + $joinCondition + ); + } + + /** + * @param Join $join + * + * @return bool + */ + public function equals($join) + { + return $join !== null + && $join instanceof Join + && $this->getJoinType() == $join->getJoinType() + && $this->getConditions() == $join->getConditions(); + } + + /** + * Returns a String representation of the class, + * + * @return string A String representation of the class + */ + public function toString() + { + $params = array(); + + return $this->getClause($params); + } + + public function __toString() + { + return $this->toString(); + } } - \ No newline at end of file diff --git a/airtime_mvc/library/propel/runtime/lib/query/ModelCriteria.php b/airtime_mvc/library/propel/runtime/lib/query/ModelCriteria.php index 4082133a9..e68c0836b 100644 --- a/airtime_mvc/library/propel/runtime/lib/query/ModelCriteria.php +++ b/airtime_mvc/library/propel/runtime/lib/query/ModelCriteria.php @@ -11,8 +11,8 @@ /** * This class extends the Criteria by adding runtime introspection abilities * in order to ease the building of queries. - * - * A ModelCriteria requires additional information to be initialized. + * + * A ModelCriteria requires additional information to be initialized. * Using a model name and tablemaps, a ModelCriteria can do more powerful things than a simple Criteria * * magic methods: @@ -20,1822 +20,2329 @@ * @method ModelCriteria leftJoin($relation) Adds a LEFT JOIN clause to the query * @method ModelCriteria rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ModelCriteria innerJoin($relation) Adds a INNER JOIN clause to the query + * @method ModelCriteria getSelectQuery($alias) Get the Criteria for a specific subQuery + * @method ModelCriteria _or() + * + * @property ModelJoin[] $joins * * @author François Zaninotto - * @version $Revision: 1799 $ + * @version $Revision$ * @package propel.runtime.query */ class ModelCriteria extends Criteria { - const MODEL_CLAUSE = "MODEL CLAUSE"; - const MODEL_CLAUSE_ARRAY = "MODEL CLAUSE ARRAY"; - const MODEL_CLAUSE_LIKE = "MODEL CLAUSE LIKE"; - const MODEL_CLAUSE_SEVERAL = "MODEL CLAUSE SEVERAL"; + const MODEL_CLAUSE = "MODEL CLAUSE"; + const MODEL_CLAUSE_ARRAY = "MODEL CLAUSE ARRAY"; + const MODEL_CLAUSE_LIKE = "MODEL CLAUSE LIKE"; + const MODEL_CLAUSE_SEVERAL = "MODEL CLAUSE SEVERAL"; + const MODEL_CLAUSE_RAW = "MODEL CLAUSE RAW"; - const FORMAT_STATEMENT = 'PropelStatementFormatter'; - const FORMAT_ARRAY = 'PropelArrayFormatter'; - const FORMAT_OBJECT = 'PropelObjectFormatter'; - const FORMAT_ON_DEMAND = 'PropelOnDemandFormatter'; - - protected $modelName; - protected $modelPeerName; - protected $modelAlias; - protected $useAliasInSQL = false; - protected $tableMap; - protected $primaryCriteria; - protected $formatter; - protected $defaultFormatterClass = ModelCriteria::FORMAT_OBJECT; - protected $with = array(); - protected $isWithOneToMany = false; - protected $previousJoin = null; // this is introduced to prevent useQuery->join from going wrong - protected $isKeepQuery = false; // whether to clone the current object before termination methods - - /** - * Creates a new instance with the default capacity which corresponds to - * the specified database. - * - * @param string $dbName The dabase name - * @param string $modelName The phpName of a model, e.g. 'Book' - * @param string $modelAlias The alias for the model in this query, e.g. 'b' - */ - public function __construct($dbName = null, $modelName, $modelAlias = null) - { - $this->setDbName($dbName); - $this->originalDbName = $dbName; - $this->modelName = $modelName; - $this->modelPeerName = constant($this->modelName . '::PEER'); - $this->modelAlias = $modelAlias; - $this->tableMap = Propel::getDatabaseMap($this->getDbName())->getTableByPhpName($this->modelName); - } - - /** - * Returns the name of the class for this model criteria - * - * @return string - */ - public function getModelName() - { - return $this->modelName; - } - - /** - * Sets the alias for the model in this query - * - * @param string $modelAlias The model alias - * @param boolean $useAliasInSQL Whether to use the alias in the SQL code (false by default) - * - * @return ModelCriteria The current object, for fluid interface - */ - public function setModelAlias($modelAlias, $useAliasInSQL = false) - { - if ($useAliasInSQL) { - $this->addAlias($modelAlias, $this->tableMap->getName()); - $this->useAliasInSQL = true; - } - $this->modelAlias = $modelAlias; - - return $this; - } - - /** - * Returns the alias of the main class for this model criteria - * - * @return string The model alias - */ - public function getModelAlias() - { - return $this->modelAlias; - } - - /** - * Return the string to use in a clause as a model prefix for the main model - * - * @return string The model alias if it exists, the model name if not - */ - public function getModelAliasOrName() - { - return $this->modelAlias ? $this->modelAlias : $this->modelName; - } - - /** - * Returns the name of the Peer class for this model criteria - * - * @return string - */ - public function getModelPeerName() - { - return $this->modelPeerName; - } - - /** - * Returns the TabkleMap object for this Criteria - * - * @return TableMap - */ - public function getTableMap() - { - return $this->tableMap; - } - - /** - * Sets the formatter to use for the find() output - * Formatters must extend PropelFormatter - * Use the ModelCriteria constants for class names: - * - * $c->setFormatter(ModelCriteria::FORMAT_ARRAY); - * - * - * @param string|PropelFormatter $formatter a formatter class name, or a formatter instance - * @return ModelCriteria The current object, for fluid interface - */ - public function setFormatter($formatter) - { - if(is_string($formatter)) { - $formatter = new $formatter(); - } - if (!$formatter instanceof PropelFormatter) { - throw new PropelException('setFormatter() only accepts classes extending PropelFormatter'); - } - $this->formatter = $formatter; - - return $this; - } - - /** - * Gets the formatter to use for the find() output - * Defaults to an instance of ModelCriteria::$defaultFormatterClass, i.e. PropelObjectsFormatter - * - * @return PropelFormatter - */ - public function getFormatter() - { - if (null === $this->formatter) { - $formatterClass = $this->defaultFormatterClass; - $this->formatter = new $formatterClass(); - } - return $this->formatter; - } - - /** - * Adds a condition on a column based on a pseudo SQL clause - * but keeps it for later use with combine() - * Until combine() is called, the condition is not added to the query - * Uses introspection to translate the column phpName into a fully qualified name - * - * $c->condition('cond1', 'b.Title = ?', 'foo'); - * - * - * @see Criteria::add() - * - * @param string $conditionName A name to store the condition for a later combination with combine() - * @param string $clause The pseudo SQL clause, e.g. 'AuthorId = ?' - * @param mixed $value A value for the condition - * - * @return ModelCriteria The current object, for fluid interface - */ - public function condition($conditionName, $clause, $value = null) - { - $this->addCond($conditionName, $this->getCriterionForClause($clause, $value), null, null); - - return $this; - } - - /** - * Adds a condition on a column based on a column phpName and a value - * Uses introspection to translate the column phpName into a fully qualified name - * Warning: recognizes only the phpNames of the main Model (not joined tables) - * - * $c->filterBy('Title', 'foo'); - * - * - * @see Criteria::add() - * - * @param string $column A string representing thecolumn phpName, e.g. 'AuthorId' - * @param mixed $value A value for the condition - * @param string $comparison What to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ModelCriteria The current object, for fluid interface - */ - public function filterBy($column, $value, $comparison = Criteria::EQUAL) - { - return $this->add($this->getRealColumnName($column), $value, $comparison); - } - - /** - * Adds a list of conditions on the columns of the current model - * Uses introspection to translate the column phpName into a fully qualified name - * Warning: recognizes only the phpNames of the main Model (not joined tables) - * - * $c->filterByArray(array( - * 'Title' => 'War And Peace', - * 'Publisher' => $publisher - * )); - * - * - * @see filterBy() - * - * @param mixed $conditions An array of conditions, using column phpNames as key - * - * @return ModelCriteria The current object, for fluid interface - */ - public function filterByArray($conditions) - { - foreach ($conditions as $column => $args) { - call_user_func_array(array($this, 'filterBy' . $column), (array) $args); - } - - return $this; - } - - /** - * Adds a condition on a column based on a pseudo SQL clause - * Uses introspection to translate the column phpName into a fully qualified name - * - * // simple clause - * $c->where('b.Title = ?', 'foo'); - * // named conditions - * $c->condition('cond1', 'b.Title = ?', 'foo'); - * $c->condition('cond2', 'b.ISBN = ?', 12345); - * $c->where(array('cond1', 'cond2'), Criteria::LOGICAL_OR); - * - * - * @see Criteria::add() - * - * @param mixed $clause A string representing the pseudo SQL clause, e.g. 'Book.AuthorId = ?' - * Or an array of condition names - * @param mixed $value A value for the condition - * - * @return ModelCriteria The current object, for fluid interface - */ - public function where($clause, $value = null) - { - if (is_array($clause)) { - // where(array('cond1', 'cond2'), Criteria::LOGICAL_OR) - $criterion = $this->getCriterionForConditions($clause, $value); - } else { - // where('Book.AuthorId = ?', 12) - $criterion = $this->getCriterionForClause($clause, $value); - } - $this->addAnd($criterion, null, null); - - return $this; - } - - /** - * Adds a condition on a column based on a pseudo SQL clause - * Uses introspection to translate the column phpName into a fully qualified name - * - * // simple clause - * $c->orWhere('b.Title = ?', 'foo'); - * // named conditions - * $c->condition('cond1', 'b.Title = ?', 'foo'); - * $c->condition('cond2', 'b.ISBN = ?', 12345); - * $c->orWhere(array('cond1', 'cond2'), Criteria::LOGICAL_OR); - * - * - * @see Criteria::addOr() - * - * @param string $clause The pseudo SQL clause, e.g. 'AuthorId = ?' - * @param mixed $value A value for the condition - * - * @return ModelCriteria The current object, for fluid interface - */ - public function orWhere($clause, $value = null) - { - if (is_array($clause)) { - // orWhere(array('cond1', 'cond2'), Criteria::LOGICAL_OR) - $criterion = $this->getCriterionForConditions($clause, $value); - } else { - // orWhere('Book.AuthorId = ?', 12) - $criterion = $this->getCriterionForClause($clause, $value); - } - $this->addOr($criterion, null, null); - - return $this; - } + const FORMAT_STATEMENT = 'PropelStatementFormatter'; + const FORMAT_ARRAY = 'PropelArrayFormatter'; + const FORMAT_OBJECT = 'PropelObjectFormatter'; + const FORMAT_ON_DEMAND = 'PropelOnDemandFormatter'; - /** - * Adds a having condition on a column based on a pseudo SQL clause - * Uses introspection to translate the column phpName into a fully qualified name - * - * // simple clause - * $c->having('b.Title = ?', 'foo'); - * // named conditions - * $c->condition('cond1', 'b.Title = ?', 'foo'); - * $c->condition('cond2', 'b.ISBN = ?', 12345); - * $c->having(array('cond1', 'cond2'), Criteria::LOGICAL_OR); - * - * - * @see Criteria::addHaving() - * - * @param mixed $clause A string representing the pseudo SQL clause, e.g. 'Book.AuthorId = ?' - * Or an array of condition names - * @param mixed $value A value for the condition - * - * @return ModelCriteria The current object, for fluid interface - */ - public function having($clause, $value = null) - { - if (is_array($clause)) { - // having(array('cond1', 'cond2'), Criteria::LOGICAL_OR) - $criterion = $this->getCriterionForConditions($clause, $value); - } else { - // having('Book.AuthorId = ?', 12) - $criterion = $this->getCriterionForClause($clause, $value); - } - $this->addHaving($criterion); - - return $this; - } - - /** - * Adds an ORDER BY clause to the query - * Usability layer on top of Criteria::addAscendingOrderByColumn() and Criteria::addDescendingOrderByColumn() - * Infers $column and $order from $columnName and some optional arguments - * Examples: - * $c->orderBy('Book.CreatedAt') - * => $c->addAscendingOrderByColumn(BookPeer::CREATED_AT) - * $c->orderBy('Book.CategoryId', 'desc') - * => $c->addDescendingOrderByColumn(BookPeer::CATEGORY_ID) - * - * @param string $columnName The column to order by - * @param string $order The sorting order. Criteria::ASC by default, also accepts Criteria::DESC - * - * @return ModelCriteria The current object, for fluid interface - */ - public function orderBy($columnName, $order = Criteria::ASC) - { - list($column, $realColumnName) = $this->getColumnFromName($columnName, false); - $order = strtoupper($order); - switch ($order) { - case Criteria::ASC: - $this->addAscendingOrderByColumn($realColumnName); - break; - case Criteria::DESC: - $this->addDescendingOrderByColumn($realColumnName); - break; - default: - throw new PropelException('ModelCriteria::orderBy() only accepts Criteria::ASC or Criteria::DESC as argument'); - } - - return $this; - } - - /** - * Adds a GROUB BY clause to the query - * Usability layer on top of Criteria::addGroupByColumn() - * Infers $column $columnName - * Examples: - * $c->groupBy('Book.AuthorId') - * => $c->addGroupByColumn(BookPeer::AUTHOR_ID) - * - * @param string $columnName The column to group by - * - * @return ModelCriteria The current object, for fluid interface - */ - public function groupBy($columnName) - { - list($column, $realColumnName) = $this->getColumnFromName($columnName, false); - $this->addGroupByColumn($realColumnName); - - return $this; - } - - /** - * Adds a DISTINCT clause to the query - * Alias for Criteria::setDistinct() - * - * @return ModelCriteria The current object, for fluid interface - */ - public function distinct() - { - $this->setDistinct(); - - return $this; - } - - /** - * Adds a LIMIT clause (or its subselect equivalent) to the query - * Alias for Criteria:::setLimit() - * - * @param int $limit Maximum number of results to return by the query - * - * @return ModelCriteria The current object, for fluid interface - */ - public function limit($limit) - { - $this->setLimit($limit); - - return $this; - } - - /** - * Adds an OFFSET clause (or its subselect equivalent) to the query - * Alias for of Criteria::setOffset() - * - * @param int $offset Offset of the first result to return - * - * @return ModelCriteria The current object, for fluid interface - */ - public function offset($offset) - { - $this->setOffset($offset); - - return $this; - } - - /** - * This method returns the previousJoin for this ModelCriteria, - * by default this is null, but after useQuery this is set the to the join of that use - * - * @return Join the previousJoin for this ModelCriteria - */ - public function getPreviousJoin() - { - return $this->previousJoin; - } - - /** - * This method sets the previousJoin for this ModelCriteria, - * by default this is null, but after useQuery this is set the to the join of that use - * - * @param Join $previousJoin The previousJoin for this ModelCriteria - */ - public function setPreviousJoin(Join $previousJoin) - { - $this->previousJoin = $previousJoin; - } + protected $modelName; + protected $modelPeerName; + protected $originalModelAlias; + protected $modelAlias; + protected $useAliasInSQL = false; + public $replacedColumns = array(); + /** + * @var DatabaseMap + */ + protected $tableMap; + protected $primaryCriteria = null; + protected $formatter = null; + protected $defaultFormatterClass = ModelCriteria::FORMAT_OBJECT; + protected $with = array(); + protected $isWithOneToMany = false; + protected $previousJoin = null; // this is introduced to prevent useQuery->join from going wrong + protected $isKeepQuery = true; // whether to clone the current object before termination methods + protected $select = null; // this is for the select method + protected $currentAlias = null; + protected $foundMatch = false; - /** - * This method returns an already defined join clause from the query - * - * @param string $name The name of the join clause - * - * @return Join A join object - */ - public function getJoin($name) - { - return $this->joins[$name]; - } - - /** - * Adds a JOIN clause to the query - * Infers the ON clause from a relation name - * Uses the Propel table maps, based on the schema, to guess the related columns - * Beware that the default JOIN operator is INNER JOIN, while Criteria defaults to WHERE - * Examples: - * - * $c->join('Book.Author'); - * => $c->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::INNER_JOIN); - * $c->join('Book.Author', Criteria::RIGHT_JOIN); - * => $c->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::RIGHT_JOIN); - * $c->join('Book.Author a', Criteria::RIGHT_JOIN); - * => $c->addAlias('a', AuthorPeer::TABLE_NAME); - * => $c->addJoin(BookPeer::AUTHOR_ID, 'a.ID', Criteria::RIGHT_JOIN); - * - * - * @param string $relation Relation to use for the join - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ModelCriteria The current object, for fluid interface - */ - public function join($relation, $joinType = Criteria::INNER_JOIN) - { - // relation looks like '$leftName.$relationName $relationAlias' - list($fullName, $relationAlias) = self::getClassAndAlias($relation); - if (strpos($fullName, '.') === false) { - // simple relation name, refers to the current table - $leftName = $this->getModelAliasOrName(); - $relationName = $fullName; - $previousJoin = $this->getPreviousJoin(); - $tableMap = $this->getTableMap(); - } else { - list($leftName, $relationName) = explode('.', $fullName); - // find the TableMap for the left table using the $leftName - if ($leftName == $this->getModelAliasOrName()) { - $previousJoin = $this->getPreviousJoin(); - $tableMap = $this->getTableMap(); - } elseif (isset($this->joins[$leftName])) { - $previousJoin = $this->joins[$leftName]; - $tableMap = $previousJoin->getTableMap(); - } else { - throw new PropelException('Unknown table or alias ' . $leftName); - } - } - $leftTableAlias = isset($this->aliases[$leftName]) ? $leftName : null; - - // find the RelationMap in the TableMap using the $relationName - if(!$tableMap->hasRelation($relationName)) { - throw new PropelException('Unknown relation ' . $relationName . ' on the ' . $leftName .' table'); - } - $relationMap = $tableMap->getRelation($relationName); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - if(null !== $previousJoin) { - $join->setPreviousJoin($previousJoin); - } - $join->setRelationMap($relationMap, $leftTableAlias, $relationAlias); - - // add the ModelJoin to the current object - if($relationAlias !== null) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, $relationName); - } - - return $this; - } + /** + * Creates a new instance with the default capacity which corresponds to + * the specified database. + * + * @param string $dbName The database name + * @param string $modelName The phpName of a model, e.g. 'Book' + * @param string $modelAlias The alias for the model in this query, e.g. 'b' + */ + public function __construct($dbName, $modelName, $modelAlias = null) + { + $this->setDbName($dbName); + $this->originalDbName = $dbName; + $this->modelName = $modelName; + $this->modelPeerName = constant($this->modelName . '::PEER'); + $this->originalModelAlias = $modelAlias; + $this->modelAlias = $modelAlias; + $this->tableMap = Propel::getDatabaseMap($this->getDbName())->getTableByPhpName($this->modelName); + } - /** - * Add a join object to the Criteria - * @see Criteria::addJoinObject() - * @param Join $join A join object - * - * @return ModelCriteria The current object, for fluid interface - */ - public function addJoinObject(Join $join, $name = null) - { - if (!in_array($join, $this->joins)) { // compare equality, NOT identity - $this->joins[$name] = $join; - } - return $this; - } - - /** - * Adds a JOIN clause to the query and hydrates the related objects - * Shortcut for $c->join()->with() - * - * $c->joinWith('Book.Author'); - * => $c->join('Book.Author'); - * => $c->with('Author'); - * $c->joinWith('Book.Author a', Criteria::RIGHT_JOIN); - * => $c->join('Book.Author a', Criteria::RIGHT_JOIN); - * => $c->with('a'); - * - * - * @param string $relation Relation to use for the join - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ModelCriteria The current object, for fluid interface - */ - public function joinWith($relation, $joinType = Criteria::INNER_JOIN) - { - $this->join($relation, $joinType); - $this->with(self::getRelationName($relation)); - - return $this; - } - - /** - * Adds a relation to hydrate together with the main object - * The relation must be initialized via a join() prior to calling with() - * Examples: - * - * $c->join('Book.Author'); - * $c->with('Author'); - * - * $c->join('Book.Author a', Criteria::RIGHT_JOIN); - * $c->with('a'); - * - * WARNING: on a one-to-many relationship, the use of with() combined with limit() - * will return a wrong number of results for the related objects - * - * @param string $relation Relation to use for the join - * - * @return ModelCriteria The current object, for fluid interface - */ - public function with($relation) - { - if (!isset($this->joins[$relation])) { - throw new PropelException('Unknown relation name or alias ' . $relation); - } - $join = $this->joins[$relation]; - if ($join->getRelationMap()->getType() == RelationMap::MANY_TO_MANY) { - throw new PropelException('with() does not allow hydration for many-to-many relationships'); - } elseif ($join->getRelationMap()->getType() == RelationMap::ONE_TO_MANY) { - // For performance reasons, the formatters will use a special routine in this case - $this->isWithOneToMany = true; - } - - // check that the columns of the main class are already added (but only if this isn't a useQuery) - if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) { - $this->addSelfSelectColumns(); - } - // add the columns of the related class - $this->addRelationSelectColumns($relation); - - // list the join for later hydration in the formatter - $this->with[$relation] = $join; - - return $this; - } + /** + * Returns the name of the class for this model criteria + * + * @return string + */ + public function getModelName() + { + return $this->modelName; + } - /** - * Gets the array of ModelWith specifying which objects must be hydrated - * together with the main object. - * - * @see with() - * @return array - */ - public function getWith() - { - return $this->with; - } - - public function isWithOneToMany() - { - return $this->isWithOneToMany; - } - - /** - * Adds a supplementary column to the select clause - * These columns can later be retrieved from the hydrated objects using getVirtualColumn() - * - * @param string $clause The SQL clause with object model column names - * e.g. 'UPPER(Author.FirstName)' - * @param string $name Optional alias for the added column - * If no alias is provided, the clause is used as a column alias - * This alias is used for retrieving the column via BaseObject::getVirtualColumn($alias) - * - * @return ModelCriteria The current object, for fluid interface - */ - public function withColumn($clause, $name = null) - { - if (null === $name) { - $name = str_replace(array('.', '(', ')'), '', $clause); - } - $clause = trim($clause); - $this->replaceNames($clause); - // check that the columns of the main class are already added (if this is the primary ModelCriteria) - if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) { - $this->addSelfSelectColumns(); - } - $this->addAsColumn($name, $clause); - - return $this; - } - - /** - * Initializes a secondary ModelCriteria object, to be later merged with the current object - * - * @see ModelCriteria::endUse() - * @param string $relationName Relation name or alias - * @param string $secondCriteriaClass Classname for the ModelCriteria to be used - * - * @return ModelCriteria The secondary criteria object - */ - public function useQuery($relationName, $secondaryCriteriaClass = null) - { - if (!isset($this->joins[$relationName])) { - throw new PropelException('Unknown class or alias ' . $relationName); - } - $className = $this->joins[$relationName]->getTableMap()->getPhpName(); - if (null === $secondaryCriteriaClass) { - $secondaryCriteria = PropelQuery::from($className); - } else { - $secondaryCriteria = new $secondaryCriteriaClass(); - } - if ($className != $relationName) { - $secondaryCriteria->setModelAlias($relationName, $relationName == $this->joins[$relationName]->getRelationMap()->getName() ? false : true); - } - $secondaryCriteria->setPrimaryCriteria($this, $this->joins[$relationName]); - - return $secondaryCriteria; - } - - /** - * Finalizes a secondary criteria and merges it with its primary Criteria - * - * @see Criteria::mergeWith() - * - * @return ModelCriteria The primary criteria object - */ - public function endUse() - { - if (isset($this->aliases[$this->modelAlias])) { - $this->removeAlias($this->modelAlias); - } - $primaryCriteria = $this->getPrimaryCriteria(); - $primaryCriteria->mergeWith($this); - - return $primaryCriteria; - } - - /** - * Add the content of a Criteria to the current Criteria - * In case of conflict, the current Criteria keeps its properties - * @see Criteria::mergeWith() - * - * @param Criteria $criteria The criteria to read properties from - * @param string $operator The logical operator used to combine conditions - * Defaults to Criteria::LOGICAL_AND, also accapts Criteria::LOGICAL_OR - * - * @return ModelCriteria The primary criteria object - */ - public function mergeWith(Criteria $criteria, $operator = Criteria::LOGICAL_AND) - { - parent::mergeWith($criteria, $operator); - - // merge with - if ($criteria instanceof ModelCriteria) { - $this->with = array_merge($this->getWith(), $criteria->getWith()); - } - - return $this; - } + /** + * Sets the alias for the model in this query + * + * @param string $modelAlias The model alias + * @param boolean $useAliasInSQL Whether to use the alias in the SQL code (false by default) + * + * @return ModelCriteria The current object, for fluid interface + */ + public function setModelAlias($modelAlias, $useAliasInSQL = false) + { + if ($useAliasInSQL) { + $this->addAlias($modelAlias, $this->tableMap->getName()); + $this->useAliasInSQL = true; + } + $this->modelAlias = $modelAlias; - /** - * Clear the conditions to allow the reuse of the query object. - * The ModelCriteria's Model and alias 'all the properties set by construct) will remain. - * - * @return ModelCriteria The primary criteria object - */ - public function clear() - { - parent::clear(); - - $this->with = array(); - $this->primaryCriteria = null; - $this->formatter=null; - - return $this; - } - /** - * Sets the primary Criteria for this secondary Criteria - * - * @param ModelCriteria $criteria The primary criteria - * @param Join $previousJoin The previousJoin for this ModelCriteria - */ - public function setPrimaryCriteria(ModelCriteria $criteria, Join $previousJoin) - { - $this->primaryCriteria = $criteria; - $this->setPreviousJoin($previousJoin); - } + return $this; + } - /** - * Gets the primary criteria for this secondary Criteria - * - * @return ModelCriteria The primary criteria - */ - public function getPrimaryCriteria() - { - return $this->primaryCriteria; - } + /** + * Returns the alias of the main class for this model criteria + * + * @return string The model alias + */ + public function getModelAlias() + { + return $this->modelAlias; + } - /** - * Adds the select columns for a the current table - * - * @return ModelCriteria The current object, for fluid interface - */ - public function addSelfSelectColumns() - { - call_user_func(array($this->modelPeerName, 'addSelectColumns'), $this, $this->useAliasInSQL ? $this->modelAlias : null); - - return $this; - } - - /** - * Adds the select columns for a relation - * - * @param string $relation The relation name or alias, as defined in join() - * - * @return ModelCriteria The current object, for fluid interface - */ - public function addRelationSelectColumns($relation) - { - $join = $this->joins[$relation]; - call_user_func(array($join->getTableMap()->getPeerClassname(), 'addSelectColumns'), $this, $join->getRelationAlias()); - - return $this; - } - - /** - * Returns the class and alias of a string representing a model or a relation - * e.g. 'Book b' => array('Book', 'b') - * e.g. 'Book' => array('Book', null) - * - * @param string $class The classname to explode - * - * @return array list($className, $aliasName) - */ - public static function getClassAndAlias($class) - { - if(strpos($class, ' ') !== false) { - list($class, $alias) = explode(' ', $class); - } else { - $alias = null; - } - return array($class, $alias); - } + /** + * Return the string to use in a clause as a model prefix for the main model + * + * @return string The model alias if it exists, the model name if not + */ + public function getModelAliasOrName() + { + return $this->modelAlias ? $this->modelAlias : $this->modelName; + } - /** - * Returns the name of a relation from a string. - * The input looks like '$leftName.$relationName $relationAlias' - * - * @param string $relation Relation to use for the join - * @return string the relationName used in the join - */ - public static function getRelationName($relation) - { - // get the relationName - list($fullName, $relationAlias) = self::getClassAndAlias($relation); - if ($relationAlias) { - $relationName = $relationAlias; - } elseif (false === strpos($fullName, '.')) { - $relationName = $fullName; - } else { - list($leftName, $relationName) = explode('.', $fullName); - } - - return $relationName; - } - - /** - * Triggers the automated cloning on termination. - * By default, temrination methods don't clone the current object, - * even though they modify it. If the query must be reused after termination, - * you must call this method prior to temrination. - * - * @param boolean $isKeepQuery - * - * @return ModelCriteria The current object, for fluid interface - */ - public function keepQuery($isKeepQuery = true) - { - $this->isKeepQuery = (bool) $isKeepQuery; - - return $this; - } - - /** - * Checks whether the automated cloning on termination is enabled. - * - * @return boolean true if cloning must be done before termination - */ - public function isKeepQuery() - { - return $this->isKeepQuery; - } - - /** - * Code to execute before every SELECT statement - * - * @param PropelPDO $con The connection object used by the query - */ - protected function basePreSelect(PropelPDO $con) - { - return $this->preSelect($con); - } - - protected function preSelect(PropelPDO $con) - { - } + /** + * Returns the name of the Peer class for this model criteria + * + * @return string + */ + public function getModelPeerName() + { + return $this->modelPeerName; + } - /** - * Issue a SELECT query based on the current ModelCriteria - * and format the list of results with the current formatter - * By default, returns an array of model objects - * - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter - */ - public function find($con = null) - { - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria->getSelectStatement($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } + /** + * Returns the TableMap object for this Criteria + * + * @return TableMap + */ + public function getTableMap() + { + return $this->tableMap; + } - /** - * Issue a SELECT ... LIMIT 1 query based on the current ModelCriteria - * and format the result with the current formatter - * By default, returns a model object - * - * @param PropelPDO $con an optional connection object - * - * @return mixed the result, formatted by the current formatter - */ - public function findOne($con = null) - { - $criteria = $this->isKeepQuery() ? clone $this : $this; - $criteria->limit(1); - $stmt = $criteria->getSelectStatement($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } + /** + * Sets the formatter to use for the find() output + * Formatters must extend PropelFormatter + * Use the ModelCriteria constants for class names: + * + * $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + * + * + * @param string|PropelFormatter $formatter a formatter class name, or a formatter instance + * + * @return ModelCriteria The current object, for fluid interface + * + * @throws PropelException + */ + public function setFormatter($formatter) + { + if (is_string($formatter)) { + $formatter = new $formatter(); + } + if (!$formatter instanceof PropelFormatter) { + throw new PropelException('setFormatter() only accepts classes extending PropelFormatter'); + } + $this->formatter = $formatter; - /** - * Issue a SELECT ... LIMIT 1 query based on the current ModelCriteria - * and format the result with the current formatter - * By default, returns a model object - * - * @param PropelPDO $con an optional connection object - * - * @return mixed the result, formatted by the current formatter - */ - public function findOneOrCreate($con = null) - { - $criteria = $this->isKeepQuery() ? clone $this : $this; - $criteria->limit(1); - $stmt = $criteria->getSelectStatement($con); - if (!$ret = $this->findOne($con)) { - $class = $this->getModelName(); - $obj = new $class(); - foreach ($this->keys() as $key) { - $obj->setByName($key, $this->getValue($key), BasePeer::TYPE_COLNAME); - } - $ret = $this->getFormatter()->formatRecord($obj); - } - return $ret; - } - - /** - * Find object by primary key - * Behaves differently if the model has simple or composite primary key - * - * // simple primary key - * $book = $c->findPk(12, $con); - * // composite primary key - * $bookOpinion = $c->findPk(array(34, 634), $con); - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - $pkCols = $this->getTableMap()->getPrimaryKeyColumns(); - if (count($pkCols) == 1) { - // simple primary key - $pkCol = $pkCols[0]; - $this->add($pkCol->getFullyQualifiedName(), $key); - return $this->findOne($con); - } else { - // composite primary key - foreach ($pkCols as $pkCol) { - $keyPart = array_shift($key); - $this->add($pkCol->getFullyQualifiedName(), $keyPart); - } - return $this->findOne($con); - } - } + return $this; + } - /** - * Find objects by primary key - * Behaves differently if the model has simple or composite primary key - * - * // simple primary key - * $books = $c->findPks(array(12, 56, 832), $con); - * // composite primary key - * $bookOpinion = $c->findPks(array(array(34, 634), array(45, 518), array(34, 765)), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - $pkCols = $this->getTableMap()->getPrimaryKeyColumns(); - if (count($pkCols) == 1) { - // simple primary key - $pkCol = array_shift($pkCols); - $this->add($pkCol->getFullyQualifiedName(), $keys, Criteria::IN); - } else { - // composite primary key - throw new PropelException('Multiple object retrieval is not implemented for composite primary keys'); - } - return $this->find($con); - } - - protected function getSelectStatement($con = null) - { - $dbMap = Propel::getDatabaseMap($this->getDbName()); - $db = Propel::getDB($this->getDbName()); - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } + /** + * Gets the formatter to use for the find() output + * Defaults to an instance of ModelCriteria::$defaultFormatterClass, i.e. PropelObjectsFormatter + * + * @return PropelFormatter + */ + public function getFormatter() + { + if (null === $this->formatter) { + $formatterClass = $this->defaultFormatterClass; + $this->formatter = new $formatterClass(); + } - // check that the columns of the main class are already added (if this is the primary ModelCriteria) - if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) { - $this->addSelfSelectColumns(); - } - - $con->beginTransaction(); - try { - $this->basePreSelect($con); - $params = array(); - $sql = BasePeer::createSelectSql($this, $params); - $stmt = $con->prepare($sql); - BasePeer::populateStmtValues($stmt, $params, $dbMap, $db); - $stmt->execute(); - $con->commit(); - } catch (Exception $e) { - if ($stmt) { - $stmt = null; // close - } - $con->rollBack(); - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - - return $stmt; - } + return $this->formatter; + } - /** - * Apply a condition on a column and issues the SELECT query - * - * @see filterBy() - * @see find() - * - * @param string $column A string representing the column phpName, e.g. 'AuthorId' - * @param mixed $value A value for the condition - * @param PropelPDO $con An optional connection object - * - * @return mixed the list of results, formatted by the current formatter - */ - public function findBy($column, $value, $con = null) - { - $method = 'filterBy' . $column; - $this->$method($value); + /** + * Adds a condition on a column based on a pseudo SQL clause + * but keeps it for later use with combine() + * Until combine() is called, the condition is not added to the query + * Uses introspection to translate the column phpName into a fully qualified name + * + * $c->condition('cond1', 'b.Title = ?', 'foo'); + * + * + * @see Criteria::add() + * + * @param string $conditionName A name to store the condition for a later combination with combine() + * @param string $clause The pseudo SQL clause, e.g. 'AuthorId = ?' + * @param mixed $value A value for the condition + * @param mixed $bindingType A value for the condition + * + * @return ModelCriteria The current object, for fluid interface + */ + public function condition($conditionName, $clause, $value = null, $bindingType = null) + { + $this->addCond($conditionName, $this->getCriterionForClause($clause, $value, $bindingType), null, $bindingType); - return $this->find($con); - } + return $this; + } - /** - * Apply a list of conditions on columns and issues the SELECT query - * - * $c->findByArray(array( - * 'Title' => 'War And Peace', - * 'Publisher' => $publisher - * ), $con); - * - * - * @see filterByArray() - * @see find() - * - * @param mixed $conditions An array of conditions, using column phpNames as key - * @param PropelPDO $con an optional connection object - * - * @return mixed the list of results, formatted by the current formatter - */ - public function findByArray($conditions, $con = null) - { - $this->filterByArray($conditions); + /** + * Adds a condition on a column based on a column phpName and a value + * Uses introspection to translate the column phpName into a fully qualified name + * Warning: recognizes only the phpNames of the main Model (not joined tables) + * + * $c->filterBy('Title', 'foo'); + * + * + * @see Criteria::add() + * + * @param string $column A string representing thecolumn phpName, e.g. 'AuthorId' + * @param mixed $value A value for the condition + * @param string $comparison What to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ModelCriteria The current object, for fluid interface + */ + public function filterBy($column, $value, $comparison = Criteria::EQUAL) + { + return $this->add($this->getRealColumnName($column), $value, $comparison); + } - return $this->find($con); - } - - /** - * Apply a condition on a column and issues the SELECT ... LIMIT 1 query - * - * @see filterBy() - * @see findOne() - * - * @param mixed $column A string representing thecolumn phpName, e.g. 'AuthorId' - * @param mixed $value A value for the condition - * @param PropelPDO $con an optional connection object - * - * @return mixed the result, formatted by the current formatter - */ - public function findOneBy($column, $value, $con = null) - { - $method = 'filterBy' . $column; - $this->$method($value); + /** + * Adds a list of conditions on the columns of the current model + * Uses introspection to translate the column phpName into a fully qualified name + * Warning: recognizes only the phpNames of the main Model (not joined tables) + * + * $c->filterByArray(array( + * 'Title' => 'War And Peace', + * 'Publisher' => $publisher + * )); + * + * + * @see filterBy() + * + * @param mixed $conditions An array of conditions, using column phpNames as key + * + * @return ModelCriteria The current object, for fluid interface + */ + public function filterByArray($conditions) + { + foreach ($conditions as $column => $args) { + call_user_func_array(array($this, 'filterBy' . $column), is_array($args) ? $args : array($args)); + } - return $this->findOne($con); - } + return $this; + } - /** - * Apply a list of conditions on columns and issues the SELECT ... LIMIT 1 query - * - * $c->findOneByArray(array( - * 'Title' => 'War And Peace', - * 'Publisher' => $publisher - * ), $con); - * - * - * @see filterByArray() - * @see findOne() - * - * @param mixed $conditions An array of conditions, using column phpNames as key - * @param PropelPDO $con an optional connection object - * - * @return mixed the list of results, formatted by the current formatter - */ - public function findOneByArray($conditions, $con = null) - { - $this->filterByArray($conditions); + /** + * Adds a condition on a column based on a pseudo SQL clause + * Uses introspection to translate the column phpName into a fully qualified name + * + * // simple clause + * $c->where('b.Title = ?', 'foo'); + * // named conditions + * $c->condition('cond1', 'b.Title = ?', 'foo'); + * $c->condition('cond2', 'b.ISBN = ?', 12345); + * $c->where(array('cond1', 'cond2'), Criteria::LOGICAL_OR); + * + * + * @see Criteria::add() + * + * @param mixed $clause A string representing the pseudo SQL clause, e.g. 'Book.AuthorId = ?' + * Or an array of condition names + * @param mixed $value A value for the condition + * @param string $bindingType + * + * @return ModelCriteria The current object, for fluid interface + */ + public function where($clause, $value = null, $bindingType = null) + { + if (is_array($clause)) { + // where(array('cond1', 'cond2'), Criteria::LOGICAL_OR) + $criterion = $this->getCriterionForConditions($clause, $value); + } else { + // where('Book.AuthorId = ?', 12) + $criterion = $this->getCriterionForClause($clause, $value, $bindingType); + } + $this->addUsingOperator($criterion, null, null); - return $this->findOne($con); - } - - /** - * Issue a SELECT COUNT(*) query based on the current ModelCriteria - * - * @param PropelPDO $con an optional connection object - * - * @return integer the number of results - */ - public function count($con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - - $criteria = $this->isKeepQuery() ? clone $this : $this; - $criteria->setDbName($this->getDbName()); // Set the correct dbName - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + return $this; + } - // 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(constant($this->modelPeerName.'::TABLE_NAME')); + /** + * Adds a condition on a column based on a pseudo SQL clause + * Uses introspection to translate the column phpName into a fully qualified name + * + * // simple clause + * $c->orWhere('b.Title = ?', 'foo'); + * // named conditions + * $c->condition('cond1', 'b.Title = ?', 'foo'); + * $c->condition('cond2', 'b.ISBN = ?', 12345); + * $c->orWhere(array('cond1', 'cond2'), Criteria::LOGICAL_OR); + * + * + * @see Criteria::addOr() + * @deprecated Use _or()->where() instead + * + * @param string $clause The pseudo SQL clause, e.g. 'AuthorId = ?' + * @param mixed $value A value for the condition + * @param string $bindingType + * + * @return ModelCriteria The current object, for fluid interface + */ + public function orWhere($clause, $value = null, $bindingType = null) + { + return $this + ->_or() + ->where($clause, $value, $bindingType); + } - $stmt = $criteria->getCountStatement($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; - } - - protected function getCountStatement($con = null) - { - $dbMap = Propel::getDatabaseMap($this->getDbName()); - $db = Propel::getDB($this->getDbName()); - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - - // check that the columns of the main class are already added (if this is the primary ModelCriteria) - if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) { - $this->addSelfSelectColumns(); - } + /** + * Adds a having condition on a column based on a pseudo SQL clause + * Uses introspection to translate the column phpName into a fully qualified name + * + * // simple clause + * $c->having('b.Title = ?', 'foo'); + * // named conditions + * $c->condition('cond1', 'b.Title = ?', 'foo'); + * $c->condition('cond2', 'b.ISBN = ?', 12345); + * $c->having(array('cond1', 'cond2'), Criteria::LOGICAL_OR); + * + * + * @see Criteria::addHaving() + * + * @param mixed $clause A string representing the pseudo SQL clause, e.g. 'Book.AuthorId = ?' + * Or an array of condition names + * @param mixed $value A value for the condition + * @param string $bindingType + * + * @return ModelCriteria The current object, for fluid interface + */ + public function having($clause, $value = null, $bindingType = null) + { + if (is_array($clause)) { + // having(array('cond1', 'cond2'), Criteria::LOGICAL_OR) + $criterion = $this->getCriterionForConditions($clause, $value); + } else { + // having('Book.AuthorId = ?', 12) + $criterion = $this->getCriterionForClause($clause, $value, $bindingType); + } + $this->addHaving($criterion); - $needsComplexCount = $this->getGroupByColumns() - || $this->getOffset() - || $this->getLimit() - || $this->getHaving() - || in_array(Criteria::DISTINCT, $this->getSelectModifiers()); - - $con->beginTransaction(); - try { - $this->basePreSelect($con); - $params = array(); - if ($needsComplexCount) { - if (BasePeer::needsSelectAliases($this)) { - if ($this->getHaving()) { - throw new PropelException('Propel cannot create a COUNT query when using HAVING and duplicate column names in the SELECT part'); - } - BasePeer::turnSelectColumnsToAliases($this); - } - $selectSql = BasePeer::createSelectSql($this, $params); - $sql = 'SELECT COUNT(*) FROM (' . $selectSql . ') propelmatch4cnt'; - } else { - // Replace SELECT columns with COUNT(*) - $this->clearSelectColumns()->addSelectColumn('COUNT(*)'); - $sql = BasePeer::createSelectSql($this, $params); - } - $stmt = $con->prepare($sql); - BasePeer::populateStmtValues($stmt, $params, $dbMap, $db); - $stmt->execute(); - $con->commit(); - } catch (PropelException $e) { - $con->rollback(); - throw $e; - } - - return $stmt; - } - - /** - * Issue a SELECT query based on the current ModelCriteria - * and uses a page and a maximum number of results per page - * to compute an offet and a limit. - * - * @param int $page number of the page to start the pager on. Page 1 means no offset - * @param int $maxPerPage maximum number of results per page. Determines the limit - * @param PropelPDO $con an optional connection object - * - * @return PropelModelPager a pager object, supporting iteration - */ - public function paginate($page = 1, $maxPerPage = 10, $con = null) - { - $criteria = $this->isKeepQuery() ? clone $this : $this; - $pager = new PropelModelPager($criteria, $maxPerPage); - $pager->setPage($page); - $pager->init(); - - return $pager; - } + return $this; + } - /** - * Code to execute before every DELETE statement - * - * @param PropelPDO $con The connection object used by the query - */ - protected function basePreDelete(PropelPDO $con) - { - return $this->preDelete($con); - } - - protected function preDelete(PropelPDO $con) - { - } + /** + * Adds an ORDER BY clause to the query + * Usability layer on top of Criteria::addAscendingOrderByColumn() and Criteria::addDescendingOrderByColumn() + * Infers $column and $order from $columnName and some optional arguments + * Examples: + * $c->orderBy('Book.CreatedAt') + * => $c->addAscendingOrderByColumn(BookPeer::CREATED_AT) + * $c->orderBy('Book.CategoryId', 'desc') + * => $c->addDescendingOrderByColumn(BookPeer::CATEGORY_ID) + * + * @param string $columnName The column to order by + * @param string $order The sorting order. Criteria::ASC by default, also accepts Criteria::DESC + * + * @return ModelCriteria The current object, for fluid interface + * + * @throws PropelException + */ + public function orderBy($columnName, $order = Criteria::ASC) + { + list(, $realColumnName) = $this->getColumnFromName($columnName, false); + $order = strtoupper($order); + switch ($order) { + case Criteria::ASC: + $this->addAscendingOrderByColumn($realColumnName); + break; + case Criteria::DESC: + $this->addDescendingOrderByColumn($realColumnName); + break; + default: + throw new PropelException('ModelCriteria::orderBy() only accepts Criteria::ASC or Criteria::DESC as argument'); + } - /** - * Code to execute after every DELETE statement - * - * @param int $affectedRows the number of deleted rows - * @param PropelPDO $con The connection object used by the query - */ - protected function basePostDelete($affectedRows, PropelPDO $con) - { - return $this->postDelete($affectedRows, $con); - } - - protected function postDelete($affectedRows, PropelPDO $con) - { - } - - /** - * Issue a DELETE query based on the current ModelCriteria - * An optional hook on basePreDelete() can prevent the actual deletion - * - * @param PropelPDO $con an optional connection object - * - * @return integer the number of deleted rows - */ - public function delete($con = null) - { - if (count($this->getMap()) == 0) { - throw new PropelException('delete() expects a Criteria with at least one condition. Use deleteAll() to delete all the rows of a table'); - } - - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - - $criteria = $this->isKeepQuery() ? clone $this : $this; - $criteria->setDbName($this->getDbName()); + return $this; + } - $con->beginTransaction(); - try { - if(!$affectedRows = $criteria->basePreDelete($con)) { - $affectedRows = $criteria->doDelete($con); - } - $criteria->basePostDelete($affectedRows, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollback(); - throw $e; - } - - return $affectedRows; - } + /** + * Adds a GROUB BY clause to the query + * Usability layer on top of Criteria::addGroupByColumn() + * Infers $column $columnName + * Examples: + * $c->groupBy('Book.AuthorId') + * => $c->addGroupByColumn(BookPeer::AUTHOR_ID) + * + * @param string $columnName The column to group by + * + * @return ModelCriteria The current object, for fluid interface + */ + public function groupBy($columnName) + { + list(, $realColumnName) = $this->getColumnFromName($columnName, false); + $this->addGroupByColumn($realColumnName); - /** - * Issue a DELETE query based on the current ModelCriteria - * This method is called by ModelCriteria::delete() inside a transaction - * - * @param PropelPDO $con a connection object - * - * @return integer the number of deleted rows - */ - public function doDelete($con) - { - $affectedRows = call_user_func(array($this->modelPeerName, 'doDelete'), $this, $con); - - return $affectedRows; - } - - /** - * Issue a DELETE query based on the current ModelCriteria deleting all rows in the table - * An optional hook on basePreDelete() can prevent the actual deletion - * - * @param PropelPDO $con an optional connection object - * - * @return integer the number of deleted rows - */ - public function deleteAll($con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_WRITE); - } - $con->beginTransaction(); - try { - if(!$affectedRows = $this->basePreDelete($con)) { - $affectedRows = $this->doDeleteAll($con); - } - $this->basePostDelete($affectedRows, $con); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $affectedRows; - } - - /** - * Issue a DELETE query based on the current ModelCriteria deleting all rows in the table - * This method is called by ModelCriteria::deleteAll() inside a transaction - * - * @param PropelPDO $con a connection object - * - * @return integer the number of deleted rows - */ - public function doDeleteAll($con) - { - $affectedRows = call_user_func(array($this->modelPeerName, 'doDeleteAll'), $con); - - return $affectedRows; - } - - /** - * Code to execute before every UPDATE statement - * - * @param array $values The associatiove array of columns and values for the update - * @param PropelPDO $con The connection object used by the query - * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), ortherwise it is a series of save() calls on all the found objects - */ - protected function basePreUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false) - { - return $this->preUpdate($values, $con, $forceIndividualSaves); - } + return $this; + } - protected function preUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false) - { - } + /** + * Adds a GROUB BY clause for all columns of a model to the query + * Examples: + * $c->groupBy('Book'); + * => $c->addGroupByColumn(BookPeer::ID); + * => $c->addGroupByColumn(BookPeer::TITLE); + * => $c->addGroupByColumn(BookPeer::AUTHOR_ID); + * => $c->addGroupByColumn(BookPeer::PUBLISHER_ID); + * + * @param string $class The class name or alias + * + * @return ModelCriteria The current object, for fluid interface + * + * @throws PropelException + */ + public function groupByClass($class) + { + if ($class == $this->getModelAliasOrName()) { + // column of the Criteria's model + $tableMap = $this->getTableMap(); + } elseif (isset($this->joins[$class])) { + // column of a relations's model + $tableMap = $this->joins[$class]->getTableMap(); + } else { + throw new PropelException('Unknown model or alias ' . $class); + } + foreach ($tableMap->getColumns() as $column) { + if (isset($this->aliases[$class])) { + $this->addGroupByColumn($class . '.' . $column->getName()); + } else { + $this->addGroupByColumn($column->getFullyQualifiedName()); + } + } - /** - * Code to execute after every UPDATE statement - * - * @param int $affectedRows the number of updated rows - * @param PropelPDO $con The connection object used by the query - */ - protected function basePostUpdate($affectedRows, PropelPDO $con) - { - return $this->postUpdate($affectedRows, $con); - } - - protected function postUpdate($affectedRows, PropelPDO $con) - { - } - - /** - * Issue an UPDATE query based the current ModelCriteria and a list of changes. - * An optional hook on basePreUpdate() can prevent the actual update. - * Beware that behaviors based on hooks in the object's save() method - * will only be triggered if you force individual saves, i.e. if you pass true as second argument. - * - * @param array $values Associative array of keys and values to replace - * @param PropelPDO $con an optional connection object - * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), ortherwise it is a series of save() calls on all the found objects - * - * @return Integer Number of updated rows - */ - public function update($values, $con = null, $forceIndividualSaves = false) - { - if (!is_array($values)) { - throw new PropelException('set() expects an array as first argument'); - } - if (count($this->getJoins())) { - throw new PropelException('set() does not support multitable updates, please do not use join()'); - } - - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_WRITE); - } - - $criteria = $this->isKeepQuery() ? clone $this : $this; - $criteria->setPrimaryTableName(constant($this->modelPeerName.'::TABLE_NAME')); - - $con->beginTransaction(); - try { - - if(!$affectedRows = $criteria->basePreUpdate($values, $con, $forceIndividualSaves)) { - $affectedRows = $criteria->doUpdate($values, $con, $forceIndividualSaves); - } - $criteria->basePostUpdate($affectedRows, $con); - - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $affectedRows; - } - - /** - * Issue an UPDATE query based the current ModelCriteria and a list of changes. - * This method is called by ModelCriteria::update() inside a transaction. - * - * @param array $values Associative array of keys and values to replace - * @param PropelPDO $con a connection object - * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), ortherwise it is a series of save() calls on all the found objects - * - * @return Integer Number of updated rows - */ - public function doUpdate($values, $con, $forceIndividualSaves = false) - { - if($forceIndividualSaves) { - - // Update rows one by one - $objects = $this->setFormatter(ModelCriteria::FORMAT_OBJECT)->find($con); - foreach ($objects as $object) { - foreach ($values as $key => $value) { - $object->setByName($key, $value); - } - } - $objects->save($con); - $affectedRows = count($objects); - - } else { - - // update rows in a single query - $set = new Criteria(); - foreach ($values as $columnName => $value) { - $realColumnName = $this->getTableMap()->getColumnByPhpName($columnName)->getFullyQualifiedName(); - $set->add($realColumnName, $value); - } - $affectedRows = BasePeer::doUpdate($this, $set, $con); - call_user_func(array($this->modelPeerName, 'clearInstancePool')); - call_user_func(array($this->modelPeerName, 'clearRelatedInstancePool')); - } - - return $affectedRows; - } - - /** - * Creates a Criterion object based on a list of existing condition names and a comparator - * - * @param array $conditions The list of condition names, e.g. array('cond1', 'cond2') - * @param string $comparator A comparator, Criteria::LOGICAL_AND (default) or Criteria::LOGICAL_OR - * - * @return Criterion a Criterion or ModelCriterion object - */ - protected function getCriterionForConditions($conditions, $comparator = null) - { - $comparator = (null === $comparator) ? Criteria::LOGICAL_AND : $comparator; - $this->combine($conditions, $comparator, 'propel_temp_name'); - $criterion = $this->namedCriterions['propel_temp_name']; - unset($this->namedCriterions['propel_temp_name']); - - return $criterion; - } - - /** - * Creates a Criterion object based on a SQL clause and a value - * Uses introspection to translate the column phpName into a fully qualified name - * - * @param string $clause The pseudo SQL clause, e.g. 'AuthorId = ?' - * @param mixed $value A value for the condition - * - * @return Criterion a Criterion or ModelCriterion object - */ - protected function getCriterionForClause($clause, $value) - { - $clause = trim($clause); - if($this->replaceNames($clause)) { - // at least one column name was found and replaced in the clause - // this is enough to determine the type to bind the parameter to - if (preg_match('/IN \?$/i', $clause) !== 0) { - $operator = ModelCriteria::MODEL_CLAUSE_ARRAY; - } elseif (preg_match('/LIKE \?$/i', $clause) !== 0) { - $operator = ModelCriteria::MODEL_CLAUSE_LIKE; - } elseif (substr_count($clause, '?') > 1) { - $operator = ModelCriteria::MODEL_CLAUSE_SEVERAL; - } else { - $operator = ModelCriteria::MODEL_CLAUSE; - } - $criterion = new ModelCriterion($this, $this->replacedColumns[0], $value, $operator, $clause); - if ($this->currentAlias != '') { - $criterion->setTable($this->currentAlias); - } - } else { - // no column match in clause, must be an expression like '1=1' - if (strpos($clause, '?') !== false) { - throw new PropelException("Cannot determine the column to bind to the parameter in clause '$clause'"); - } - $criterion = new Criterion($this, null, $clause, Criteria::CUSTOM); - } - return $criterion; - } - - /** - * Replaces complete column names (like Article.AuthorId) in an SQL clause - * by their exact Propel column fully qualified name (e.g. article.AUTHOR_ID) - * but ignores the column names inside quotes - * - * Note: if you know a way to do so in one step, and in an efficient way, I'm interested :) - * - * @param string $clause SQL clause to inspect (modified by the method) - * - * @return boolean Whether the method managed to find and replace at least one column name - */ - protected function replaceNames(&$clause) - { - $this->replacedColumns = array(); - $this->currentAlias = ''; - $this->foundMatch = false; - $regexp = <<foundMatch; - } - - /** - * Callback function to replace expressions containing column names with expressions using the real column names - * Handles strings properly - * e.g. 'CONCAT(Book.Title, "Book.Title") = ?' - * => 'CONCAT(book.TITLE, "Book.Title") = ?' - * - * @param array $matches Matches found by preg_replace_callback - * - * @return string the expression replacement - */ - protected function doReplaceName($matches) - { - if(!$matches[0]) { - return ''; - } - // replace names only in expressions, not in strings delimited by quotes - return $matches[1] . preg_replace_callback('/\w+\.\w+/', array($this, 'doReplaceNameInExpression'), $matches[2]); - } - - /** - * Callback function to replace column names by their real name in a clause - * e.g. 'Book.Title IN ?' - * => 'book.TITLE IN ?' - * - * @param array $matches Matches found by preg_replace_callback - * - * @return string the column name replacement - */ - protected function doReplaceNameInExpression($matches) - { - $key = $matches[0]; - list($column, $realColumnName) = $this->getColumnFromName($key); - if ($column instanceof ColumnMap) { - $this->replacedColumns[]= $column; - $this->foundMatch = true; - return $realColumnName; - } else { - return $key; - } - } + return $this; + } - /** - * Finds a column and a SQL translation for a pseudo SQL column name - * Respects table aliases previously registered in a join() or addAlias() - * Examples: - * - * $c->getColumnFromName('Book.Title'); - * => array($bookTitleColumnMap, 'book.TITLE') - * $c->join('Book.Author a') - * ->getColumnFromName('a.FirstName'); - * => array($authorFirstNameColumnMap, 'a.FIRST_NAME') - * - * - * @param string $phpName String representing the column name in a pseudo SQL clause, e.g. 'Book.Title' - * - * @return array List($columnMap, $realColumnName) - */ - protected function getColumnFromName($phpName, $failSilently = true) - { - if (strpos($phpName, '.') === false) { - $class = $this->getModelAliasOrName(); - } else { - list($class, $phpName) = explode('.', $phpName); - } - - if ($class == $this->getModelAliasOrName()) { - // column of the Criteria's model - $tableMap = $this->getTableMap(); - } elseif (isset($this->joins[$class])) { - // column of a relations's model - $tableMap = $this->joins[$class]->getTableMap(); - } else { - if ($failSilently) { - return array(null, null); - } else { - throw new PropelException('Unknown model or alias ' . $class); - } - } - - if ($tableMap->hasColumnByPhpName($phpName)) { - $column = $tableMap->getColumnByPhpName($phpName); - if (isset($this->aliases[$class])) { - $this->currentAlias = $class; - $realColumnName = $class . '.' . $column->getName(); - } else { - $realColumnName = $column->getFullyQualifiedName(); - } - return array($column, $realColumnName); - } elseif (isset($this->asColumns[$phpName])) { - // aliased column - return array(null, $phpName); - } else { - if ($failSilently) { - return array(null, null); - } else { - throw new PropelException('Unknown column ' . $phpName . ' on model or alias ' . $class); - } - } - } - - /** - * Return a fully qualified column name corresponding to a simple column phpName - * Uses model alias if it exists - * Warning: restricted to the columns of the main model - * e.g. => 'Title' => 'book.TITLE' - * - * @param string $columnName the Column phpName, without the table name - * - * @return string the fully qualified column name - */ - protected function getRealColumnName($columnName) - { - if (!$this->getTableMap()->hasColumnByPhpName($columnName)) { - throw new PropelException('Unkown column ' . $columnName . ' in model ' . $this->modelName); - } - if ($this->useAliasInSQL) { - return $this->modelAlias . '.' . $this->getTableMap()->getColumnByPhpName($columnName)->getName(); - } else { - return $this->getTableMap()->getColumnByPhpName($columnName)->getFullyQualifiedName(); - } - } + /** + * Adds a DISTINCT clause to the query + * Alias for Criteria::setDistinct() + * + * @return ModelCriteria The current object, for fluid interface + */ + public function distinct() + { + $this->setDistinct(); - /** - * Changes the table part of a a fully qualified column name if a true model alias exists - * e.g. => 'book.TITLE' => 'b.TITLE' - * This is for use as first argument of Criteria::add() - * - * @param string $colName the fully qualified column name, e.g 'book.TITLE' or BookPeer::TITLE - * - * @return string the fully qualified column name, using table alias if applicatble - */ - public function getAliasedColName($colName) - { - if ($this->useAliasInSQL) { - return $this->modelAlias . substr($colName, strpos($colName, '.')); - } else { - return $colName; - } - } + return $this; + } - /** - * Overrides Criteria::add() to force the use of a true table alias if it exists - * - * @see Criteria::add() - * @param string $column The colName of column to run the comparison on (e.g. BookPeer::ID) - * @param mixed $value - * @param string $comparison A String. - * - * @return ModelCriteria A modified Criteria object. - */ - public function addUsingAlias($p1, $value = null, $comparison = null) - { - $key = $this->getAliasedColName($p1); - return $this->containsKey($key) ? $this->addAnd($key, $value, $comparison) : $this->add($key, $value, $comparison); - } - - /** - * Get all the parameters to bind to this criteria - * Does part of the job of BasePeer::createSelectSql() for the cache - * - * @return array list of parameters, each parameter being an array like - * array('table' => $realtable, 'column' => $column, 'value' => $value) - */ - public function getParams() - { - $params = array(); - $dbMap = Propel::getDatabaseMap($this->getDbName()); + /** + * Adds a LIMIT clause (or its subselect equivalent) to the query + * Alias for Criteria:::setLimit() + * + * @param int $limit Maximum number of results to return by the query + * + * @return ModelCriteria The current object, for fluid interface + */ + public function limit($limit) + { + $this->setLimit($limit); - foreach ($this->getMap() as $criterion) { + return $this; + } - $table = null; - foreach ($criterion->getAttachedCriterion() as $attachedCriterion) { - $tableName = $attachedCriterion->getTable(); + /** + * Adds an OFFSET clause (or its subselect equivalent) to the query + * Alias for of Criteria::setOffset() + * + * @param int $offset Offset of the first result to return + * + * @return ModelCriteria The current object, for fluid interface + */ + public function offset($offset) + { + $this->setOffset($offset); - $table = $this->getTableForAlias($tableName); - if (null === $table) { - $table = $tableName; - } + return $this; + } - if (($this->isIgnoreCase() || $attachedCriterion->isIgnoreCase()) - && $dbMap->getTable($table)->getColumn($attachedCriterion->getColumn())->isText()) { - $attachedCriterion->setIgnoreCase(true); - } - } + /** + * Makes the ModelCriteria return a string, array, or PropelArrayCollection + * Examples: + * ArticleQuery::create()->select('Name')->find(); + * => PropelArrayCollection Object ('Foo', 'Bar') + * + * ArticleQuery::create()->select('Name')->findOne(); + * => string 'Foo' + * + * ArticleQuery::create()->select(array('Id', 'Name'))->find(); + * => PropelArrayCollection Object ( + * array('Id' => 1, 'Name' => 'Foo'), + * array('Id' => 2, 'Name' => 'Bar') + * ) + * + * ArticleQuery::create()->select(array('Id', 'Name'))->findOne(); + * => array('Id' => 1, 'Name' => 'Foo') + * + * @param mixed $columnArray A list of column names (e.g. array('Title', 'Category.Name', 'c.Content')) or a single column name (e.g. 'Name') + * + * @return ModelCriteria The current object, for fluid interface + * + * @throws PropelException + */ + public function select($columnArray) + { + if (!count($columnArray) || $columnArray == '') { + throw new PropelException('You must ask for at least one column'); + } - $sb = ''; - $criterion->appendPsTo($sb, $params); - } + if ($columnArray == '*') { + $columnArray = array(); + foreach (call_user_func(array($this->modelPeerName, 'getFieldNames'), BasePeer::TYPE_PHPNAME) as $column) { + $columnArray[] = $this->modelName . '.' . $column; + } + } - $having = $this->getHaving(); - if ($having !== null) { - $sb = ''; - $having->appendPsTo($sb, $params); - } + $this->select = $columnArray; - return $params; - } + return $this; + } - /** - * Handle the magic - * Supports findByXXX(), findOneByXXX(), filterByXXX(), orderByXXX(), and groupByXXX() methods, - * where XXX is a column phpName. - * Supports XXXJoin(), where XXX is a join direction (in 'left', 'right', 'inner') - */ - public function __call($name, $arguments) - { - // Maybe it's a magic call to one of the methods supporting it, e.g. 'findByTitle' - static $methods = array('findBy', 'findOneBy', 'filterBy', 'orderBy', 'groupBy'); - foreach ($methods as $method) - { - if(strpos($name, $method) === 0) - { - $columns = substr($name, strlen($method)); - if(in_array($method, array('findBy', 'findOneBy')) && strpos($columns, 'And') !== false) { - $method = $method . 'Array'; - $columns = explode('And', $columns); - $conditions = array(); - foreach ($columns as $column) { - $conditions[$column] = array_shift($arguments); - } - array_unshift($arguments, $conditions); - } else { - array_unshift($arguments, $columns); - } - return call_user_func_array(array($this, $method), $arguments); - } - } - - // Maybe it's a magic call to a qualified joinWith method, e.g. 'leftJoinWith' or 'joinWithAuthor' - if(($pos = stripos($name, 'joinWith')) !== false) { - $type = substr($name, 0, $pos); - if(in_array($type, array('left', 'right', 'inner'))) { - $joinType = strtoupper($type) . ' JOIN'; - } else { - $joinType = Criteria::INNER_JOIN; - } - if(!$relation = substr($name, $pos + 8)) { - $relation = $arguments[0]; - } - return $this->joinWith($relation, $joinType); - } - - // Maybe it's a magic call to a qualified join method, e.g. 'leftJoin' - if(($pos = strpos($name, 'Join')) > 0) - { - $type = substr($name, 0, $pos); - if(in_array($type, array('left', 'right', 'inner'))) - { - $joinType = strtoupper($type) . ' JOIN'; - // Test if first argument is suplied, else don't provide an alias to joinXXX (default value) - if (!isset($arguments[0])) { - $arguments[0] = ''; - } - array_push($arguments, $joinType); - $method = substr($name, $pos); - // no lcfirst in php<5.3... - $method[0] = strtolower($method[0]); - return call_user_func_array(array($this, $method), $arguments); - } - } - - throw new PropelException(sprintf('Undefined method %s::%s()', __CLASS__, $name)); - } - - /** - * Ensures deep cloning of attached objects - */ - public function __clone() - { - parent::__clone(); - foreach ($this->with as $key => $join) { - $this->with[$key] = clone $join; - } - if (null !== $this->formatter) { - $this->formatter = clone $this->formatter; - } - } -} \ No newline at end of file + /** + * Retrieves the columns defined by a previous call to select(). + * + * @see select() + * + * @return array|string A list of column names (e.g. array('Title', 'Category.Name', 'c.Content')) or a single column name (e.g. 'Name') + */ + public function getSelect() + { + return $this->select; + } + + protected function configureSelectColumns() + { + if (is_null($this->select)) { + // leave early + return; + } + + // select() needs the PropelSimpleArrayFormatter if no formatter given + if (is_null($this->formatter)) { + $this->setFormatter('PropelSimpleArrayFormatter'); + } + + // clear only the selectColumns, clearSelectColumns() clears asColumns too + $this->selectColumns = array(); + + // 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. + if (!$this->selectQueries) { + $this->setPrimaryTableName(constant($this->modelPeerName . '::TABLE_NAME')); + } + + // Add requested columns which are not withColumns + $columnNames = (array) $this->select; + + // temporary store columns Alias or withColumn + $asColumns = $this->getAsColumns(); + $this->asColumns = array(); + foreach ($columnNames as $columnName) { + // check if the column was added by a withColumn, if not add it + if (!array_key_exists($columnName, $asColumns)) { + $column = $this->getColumnFromName($columnName); + $this->addAsColumn($columnName, $column[1]); + } else { + $this->addAsColumn($columnName, $asColumns[$columnName]); + // remove already added columns + unset($asColumns[$columnName]); + } + } + + // re-add all remaining columns which were not contained in select-columnNames + foreach ($asColumns as $columnName => $columnAlias) { + $this->addAsColumn($columnName, $columnAlias); + } + } + + /** + * This method returns the previousJoin for this ModelCriteria, + * by default this is null, but after useQuery this is set the to the join of that use + * + * @return Join the previousJoin for this ModelCriteria + */ + public function getPreviousJoin() + { + return $this->previousJoin; + } + + /** + * This method sets the previousJoin for this ModelCriteria, + * by default this is null, but after useQuery this is set the to the join of that use + * + * @param Join $previousJoin The previousJoin for this ModelCriteria + */ + public function setPreviousJoin(Join $previousJoin) + { + $this->previousJoin = $previousJoin; + } + + /** + * This method returns an already defined join clause from the query + * + * @param string $name The name of the join clause + * + * @return Join A join object + */ + public function getJoin($name) + { + return $this->joins[$name]; + } + + /** + * Adds a JOIN clause to the query + * Infers the ON clause from a relation name + * Uses the Propel table maps, based on the schema, to guess the related columns + * Beware that the default JOIN operator is INNER JOIN, while Criteria defaults to WHERE + * Examples: + * + * $c->join('Book.Author'); + * => $c->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::INNER_JOIN); + * $c->join('Book.Author', Criteria::RIGHT_JOIN); + * => $c->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::RIGHT_JOIN); + * $c->join('Book.Author a', Criteria::RIGHT_JOIN); + * => $c->addAlias('a', AuthorPeer::TABLE_NAME); + * => $c->addJoin(BookPeer::AUTHOR_ID, 'a.ID', Criteria::RIGHT_JOIN); + * + * + * @param string $relation Relation to use for the join + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ModelCriteria The current object, for fluid interface + * + * @throws PropelException + */ + public function join($relation, $joinType = Criteria::INNER_JOIN) + { + // relation looks like '$leftName.$relationName $relationAlias' + list($fullName, $relationAlias) = self::getClassAndAlias($relation); + if (strpos($fullName, '.') === false) { + // simple relation name, refers to the current table + $leftName = $this->getModelAliasOrName(); + $relationName = $fullName; + $previousJoin = $this->getPreviousJoin(); + $tableMap = $this->getTableMap(); + } else { + list($leftName, $relationName) = explode('.', $fullName); + // find the TableMap for the left table using the $leftName + if ($leftName == $this->getModelAliasOrName()) { + $previousJoin = $this->getPreviousJoin(); + $tableMap = $this->getTableMap(); + } elseif (isset($this->joins[$leftName])) { + $previousJoin = $this->joins[$leftName]; + $tableMap = $previousJoin->getTableMap(); + } else { + throw new PropelException('Unknown table or alias ' . $leftName); + } + } + $leftTableAlias = isset($this->aliases[$leftName]) ? $leftName : null; + + // find the RelationMap in the TableMap using the $relationName + if (!$tableMap->hasRelation($relationName)) { + throw new PropelException('Unknown relation ' . $relationName . ' on the ' . $leftName . ' table'); + } + $relationMap = $tableMap->getRelation($relationName); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + if (null !== $previousJoin) { + $join->setPreviousJoin($previousJoin); + } + $join->setRelationMap($relationMap, $leftTableAlias, $relationAlias); + + // add the ModelJoin to the current object + if ($relationAlias !== null) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, $relationName); + } + + return $this; + } + + /** + * Add another condition to an already added join + * + * @example + * + * $query->join('Book.Author'); + * $query->addJoinCondition('Author', 'Book.Title LIKE ?', 'foo%'); + * + * + * @param string $name The relation name or alias on which the join was created + * @param string $clause SQL clause, may contain column and table phpNames + * @param mixed $value An optional value to bind to the clause + * @param string $operator The operator to use to add the condition. Defaults to 'AND' + * @param string $bindingType + * + * @return ModelCriteria The current object, for fluid interface + * + * @throws PropelException + */ + public function addJoinCondition($name, $clause, $value = null, $operator = null, $bindingType = null) + { + if (!isset($this->joins[$name])) { + throw new PropelException(sprintf('Adding a condition to a nonexistent join, %s. Try calling join() first.', $name)); + } + $join = $this->joins[$name]; + if (!$join->getJoinCondition() instanceof Criterion) { + $join->buildJoinCondition($this); + } + $criterion = $this->getCriterionForClause($clause, $value, $bindingType); + $method = $operator === Criteria::LOGICAL_OR ? 'addOr' : 'addAnd'; + $join->getJoinCondition()->$method($criterion); + + return $this; + } + + /** + * Replace the condition of an already added join + * + * @example + * + * $query->join('Book.Author'); + * $query->condition('cond1', 'Book.AuthorId = Author.Id') + * $query->condition('cond2', 'Book.Title LIKE ?', 'War%') + * $query->combine(array('cond1', 'cond2'), 'and', 'cond3') + * $query->setJoinCondition('Author', 'cond3'); + * + * + * @param string $name The relation name or alias on which the join was created + * @param mixed $condition A Criterion object, or a condition name + * + * @return ModelCriteria The current object, for fluid interface + * + * @throws PropelException + */ + public function setJoinCondition($name, $condition) + { + if (!isset($this->joins[$name])) { + throw new PropelException(sprintf('Setting a condition to a nonexistent join, %s. Try calling join() first.', $name)); + } + if ($condition instanceof Criterion) { + $this->getJoin($name)->setJoinCondition($condition); + } elseif (isset($this->namedCriterions[$condition])) { + $this->getJoin($name)->setJoinCondition($this->namedCriterions[$condition]); + } else { + throw new PropelException(sprintf('Cannot add condition %s on join %s. setJoinCondition() expects either a Criterion, or a condition added by way of condition()', $condition, $name)); + } + + return $this; + } + + /** + * Add a join object to the Criteria + * + * @see Criteria::addJoinObject() + * + * @param Join $join A join object + * @param string $name + * + * @return ModelCriteria The current object, for fluid interface + */ + public function addJoinObject(Join $join, $name = null) + { + $isAlreadyAdded = false; + foreach ($this->joins as $alreadyAddedJoin) { + if ($join->equals($alreadyAddedJoin)) { + $isAlreadyAdded = true; + break; + } + } + + if (!$isAlreadyAdded) { + if (null === $name) { + $this->joins[] = $join; + } else { + $this->joins[$name] = $join; + } + } + + return $this; + } + + /** + * Adds a JOIN clause to the query and hydrates the related objects + * Shortcut for $c->join()->with() + * + * $c->joinWith('Book.Author'); + * => $c->join('Book.Author'); + * => $c->with('Author'); + * $c->joinWith('Book.Author a', Criteria::RIGHT_JOIN); + * => $c->join('Book.Author a', Criteria::RIGHT_JOIN); + * => $c->with('a'); + * + * + * @param string $relation Relation to use for the join + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ModelCriteria The current object, for fluid interface + */ + public function joinWith($relation, $joinType = Criteria::INNER_JOIN) + { + $this->join($relation, $joinType); + $this->with(self::getRelationName($relation)); + + return $this; + } + + /** + * Adds a relation to hydrate together with the main object + * The relation must be initialized via a join() prior to calling with() + * Examples: + * + * $c->join('Book.Author'); + * $c->with('Author'); + * + * $c->join('Book.Author a', Criteria::RIGHT_JOIN); + * $c->with('a'); + * + * WARNING: on a one-to-many relationship, the use of with() combined with limit() + * will return a wrong number of results for the related objects + * + * @param string $relation Relation to use for the join + * + * @return ModelCriteria The current object, for fluid interface + * + * @throws PropelException + */ + public function with($relation) + { + if (!isset($this->joins[$relation])) { + throw new PropelException('Unknown relation name or alias ' . $relation); + } + $join = $this->joins[$relation]; + if ($join->getRelationMap()->getType() == RelationMap::MANY_TO_MANY) { + throw new PropelException('with() does not allow hydration for many-to-many relationships'); + } elseif ($join->getRelationMap()->getType() == RelationMap::ONE_TO_MANY) { + // For performance reasons, the formatters will use a special routine in this case + $this->isWithOneToMany = true; + } + + // check that the columns of the main class are already added (but only if this isn't a useQuery) + if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) { + $this->addSelfSelectColumns(); + } + // add the columns of the related class + $this->addRelationSelectColumns($relation); + + // list the join for later hydration in the formatter + $this->with[$relation] = new ModelWith($join); + + return $this; + } + + /** + * Gets the array of ModelWith specifying which objects must be hydrated + * together with the main object. + * + * @see with() + * @return array + */ + public function getWith() + { + return $this->with; + } + + /** + * Sets the array of ModelWith specifying which objects must be hydrated + * together with the main object. + * + * @param array + * + * @return ModelCriteria The current object, for fluid interface + */ + public function setWith($with) + { + $this->with = $with; + + return $this; + } + + public function isWithOneToMany() + { + return $this->isWithOneToMany; + } + + /** + * Adds a supplementary column to the select clause + * These columns can later be retrieved from the hydrated objects using getVirtualColumn() + * + * @param string $clause The SQL clause with object model column names + * e.g. 'UPPER(Author.FirstName)' + * @param string $name Optional alias for the added column + * If no alias is provided, the clause is used as a column alias + * This alias is used for retrieving the column via BaseObject::getVirtualColumn($alias) + * + * @return ModelCriteria The current object, for fluid interface + */ + public function withColumn($clause, $name = null) + { + if (null === $name) { + $name = str_replace(array('.', '(', ')'), '', $clause); + } + $clause = trim($clause); + $this->replaceNames($clause); + // check that the columns of the main class are already added (if this is the primary ModelCriteria) + if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) { + $this->addSelfSelectColumns(); + } + $this->addAsColumn($name, $clause); + + return $this; + } + + /** + * Initializes a secondary ModelCriteria object, to be later merged with the current object + * + * @see ModelCriteria::endUse() + * + * @param string $relationName Relation name or alias + * @param string $secondaryCriteriaClass Classname for the ModelCriteria to be used + * + * @return ModelCriteria The secondary criteria object + * + * @throws PropelException + */ + public function useQuery($relationName, $secondaryCriteriaClass = null) + { + if (!isset($this->joins[$relationName])) { + throw new PropelException('Unknown class or alias ' . $relationName); + } + $className = $this->joins[$relationName]->getTableMap()->getPhpName(); + if (null === $secondaryCriteriaClass) { + $secondaryCriteria = PropelQuery::from($className); + } else { + $secondaryCriteria = new $secondaryCriteriaClass(); + } + if ($className != $relationName) { + $secondaryCriteria->setModelAlias($relationName, $relationName == $this->joins[$relationName]->getRelationMap()->getName() ? false : true); + } + $secondaryCriteria->setPrimaryCriteria($this, $this->joins[$relationName]); + + return $secondaryCriteria; + } + + /** + * Finalizes a secondary criteria and merges it with its primary Criteria + * + * @see Criteria::mergeWith() + * + * @return ModelCriteria The primary criteria object + */ + public function endUse() + { + if (isset($this->aliases[$this->modelAlias])) { + $this->removeAlias($this->modelAlias); + } + $primaryCriteria = $this->getPrimaryCriteria(); + $primaryCriteria->mergeWith($this); + + return $primaryCriteria; + } + + /** + * Add the content of a Criteria to the current Criteria + * In case of conflict, the current Criteria keeps its properties + * + * @see Criteria::mergeWith() + * + * @param Criteria $criteria The criteria to read properties from + * @param string $operator The logical operator used to combine conditions + * Defaults to Criteria::LOGICAL_AND, also accepts Criteria::LOGICAL_OR + * + * @return ModelCriteria The primary criteria object + */ + public function mergeWith(Criteria $criteria, $operator = null) + { + parent::mergeWith($criteria, $operator); + + // merge with + if ($criteria instanceof ModelCriteria) { + $this->with = array_merge($this->getWith(), $criteria->getWith()); + } + + return $this; + } + + /** + * Clear the conditions to allow the reuse of the query object. + * The ModelCriteria's Model and alias 'all the properties set by construct) will remain. + * + * @return ModelCriteria The primary criteria object + */ + public function clear() + { + parent::clear(); + + $this->with = array(); + $this->primaryCriteria = null; + $this->formatter = null; + $this->select = null; + $this->modelAlias = $this->originalModelAlias; + $this->currentAlias = null; + $this->setDbName($this->originalDbName); + $this->useAliasInSQL = false; + $this->isKeepQuery = true; + $this->previousJoin = null; + $this->isWithOneToMany = false; + $this->replacedColumns = array(); + $this->foundMatch = false; + + return $this; + } + + /** + * Sets the primary Criteria for this secondary Criteria + * + * @param ModelCriteria $criteria The primary criteria + * @param Join $previousJoin The previousJoin for this ModelCriteria + */ + public function setPrimaryCriteria(ModelCriteria $criteria, Join $previousJoin) + { + $this->primaryCriteria = $criteria; + $this->setPreviousJoin($previousJoin); + } + + /** + * Gets the primary criteria for this secondary Criteria + * + * @return ModelCriteria The primary criteria + */ + public function getPrimaryCriteria() + { + return $this->primaryCriteria; + } + + /** + * Adds a Criteria as subQuery in the From Clause. + * + * @see Criteria::addSelectQuery() + * + * @param Criteria $subQueryCriteria Criteria to build the subquery from + * @param string $alias alias for the subQuery + * @param boolean $addAliasAndSelectColumns Set to false if you want to manually add the aliased select columns + * + * @return ModelCriteria The current object, for fluid interface + */ + public function addSelectQuery(Criteria $subQueryCriteria, $alias = null, $addAliasAndSelectColumns = true) + { + /* @var $subQueryCriteria ModelCriteria */ + if (!$subQueryCriteria->hasSelectClause()) { + $subQueryCriteria->addSelfSelectColumns(); + } + parent::addSelectQuery($subQueryCriteria, $alias); + if ($addAliasAndSelectColumns) { + // give this query-model same alias as subquery + if (null === $alias) { + end($this->selectQueries); + $alias = key($this->selectQueries); + } + $this->setModelAlias($alias, true); + // so we can add selfSelectColumns + $this->addSelfSelectColumns(); + } + + return $this; + } + + /** + * Adds the select columns for a the current table + * + * @return ModelCriteria The current object, for fluid interface + */ + public function addSelfSelectColumns() + { + call_user_func(array($this->modelPeerName, 'addSelectColumns'), $this, $this->useAliasInSQL ? $this->modelAlias : null); + + return $this; + } + + /** + * Adds the select columns for a relation + * + * @param string $relation The relation name or alias, as defined in join() + * + * @return ModelCriteria The current object, for fluid interface + */ + public function addRelationSelectColumns($relation) + { + $join = $this->joins[$relation]; + call_user_func(array($join->getTableMap()->getPeerClassname(), 'addSelectColumns'), $this, $join->getRelationAlias()); + + return $this; + } + + /** + * Returns the class and alias of a string representing a model or a relation + * e.g. 'Book b' => array('Book', 'b') + * e.g. 'Book' => array('Book', null) + * + * @param string $class The classname to explode + * + * @return array list($className, $aliasName) + */ + public static function getClassAndAlias($class) + { + if (strpos($class, ' ') !== false) { + list($class, $alias) = explode(' ', $class); + } else { + $alias = null; + } + + return array($class, $alias); + } + + /** + * Returns the name of a relation from a string. + * The input looks like '$leftName.$relationName $relationAlias' + * + * @param string $relation Relation to use for the join + * + * @return string the relationName used in the join + */ + public static function getRelationName($relation) + { + // get the relationName + list($fullName, $relationAlias) = self::getClassAndAlias($relation); + if ($relationAlias) { + $relationName = $relationAlias; + } elseif (false === strpos($fullName, '.')) { + $relationName = $fullName; + } else { + list(, $relationName) = explode('.', $fullName); + } + + return $relationName; + } + + /** + * Triggers the automated cloning on termination. + * By default, termination methods don't clone the current object, + * even though they modify it. If the query must be reused after termination, + * you must call this method prior to termination. + * + * @param boolean $isKeepQuery + * + * @return ModelCriteria The current object, for fluid interface + */ + public function keepQuery($isKeepQuery = true) + { + $this->isKeepQuery = (bool) $isKeepQuery; + + return $this; + } + + /** + * Checks whether the automated cloning on termination is enabled. + * + * @return boolean true if cloning must be done before termination + */ + public function isKeepQuery() + { + return $this->isKeepQuery; + } + + /** + * Code to execute before every SELECT statement + * + * @param PropelPDO $con The connection object used by the query + * @return null + */ + protected function basePreSelect(PropelPDO $con) + { + return $this->preSelect($con); + } + + /** + * @param PropelPDO $con + * @return null + */ + protected function preSelect(PropelPDO $con) + { + } + + /** + * Issue a SELECT query based on the current ModelCriteria + * and format the list of results with the current formatter + * By default, returns an array of model objects + * + * @param PropelPDO $con an optional connection object + * + * @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function find($con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $stmt = $criteria->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($stmt); + } + + /** + * Issue a SELECT ... LIMIT 1 query based on the current ModelCriteria + * and format the result with the current formatter + * By default, returns a model object + * + * @param PropelPDO $con an optional connection object + * + * @return mixed the result, formatted by the current formatter + */ + public function findOne($con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $criteria->limit(1); + $stmt = $criteria->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } + + /** + * Issue a SELECT ... LIMIT 1 query based on the current ModelCriteria + * and format the result with the current formatter + * By default, returns a model object + * + * @param PropelPDO $con an optional connection object + * + * @return mixed the result, formatted by the current formatter + * + * @throws PropelException + */ + public function findOneOrCreate($con = null) + { + if ($this->joins) { + throw new PropelException('findOneOrCreate() cannot be used on a query with a join, because Propel cannot transform a SQL JOIN into a subquery. You should split the query in two queries to avoid joins.'); + } + if (!$ret = $this->findOne($con)) { + $class = $this->getModelName(); + $obj = new $class(); + foreach ($this->keys() as $key) { + $obj->setByName($key, $this->getValue($key), BasePeer::TYPE_COLNAME); + } + $ret = $this->getFormatter()->formatRecord($obj); + } + + return $ret; + } + + /** + * Find object by primary key + * Behaves differently if the model has simple or composite primary key + * + * // simple primary key + * $book = $c->findPk(12, $con); + * // composite primary key + * $bookOpinion = $c->findPk(array(34, 634), $con); + * + * + * @param mixed $key Primary key to use for the query + * @param PropelPDO $con an optional connection object + * + * @return mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + // As the query uses a PK condition, no limit(1) is necessary. + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $pkCols = $this->getTableMap()->getPrimaryKeyColumns(); + if (count($pkCols) == 1) { + // simple primary key + $pkCol = $pkCols[0]; + $criteria->add($pkCol->getFullyQualifiedName(), $key); + } else { + // composite primary key + foreach ($pkCols as $pkCol) { + $keyPart = array_shift($key); + $criteria->add($pkCol->getFullyQualifiedName(), $keyPart); + } + } + $stmt = $criteria->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + } + + /** + * Find objects by primary key + * Behaves differently if the model has simple or composite primary key + * + * // simple primary key + * $books = $c->findPks(array(12, 56, 832), $con); + * // composite primary key + * $bookOpinion = $c->findPks(array(array(34, 634), array(45, 518), array(34, 765)), $con); + * + * + * @param array $keys Primary keys to use for the query + * @param PropelPDO $con an optional connection object + * + * @return mixed the list of results, formatted by the current formatter + * + * @throws PropelException + */ + public function findPks($keys, $con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + // As the query uses a PK condition, no limit(1) is necessary. + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $pkCols = $this->getTableMap()->getPrimaryKeyColumns(); + if (count($pkCols) == 1) { + // simple primary key + $pkCol = array_shift($pkCols); + $criteria->add($pkCol->getFullyQualifiedName(), $keys, Criteria::IN); + } else { + // composite primary key + throw new PropelException('Multiple object retrieval is not implemented for composite primary keys'); + } + $stmt = $criteria->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($stmt); + } + + /** + * Builds, binds and executes a SELECT query based on the current object. + * + * @param PropelPDO $con A connection object + * + * @return PDOStatement A PDO statement executed using the connection, ready to be fetched + * + * @throws PropelException + */ + protected function doSelect($con) + { + // check that the columns of the main class are already added (if this is the primary ModelCriteria) + if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) { + $this->addSelfSelectColumns(); + } + $this->configureSelectColumns(); + + $dbMap = Propel::getDatabaseMap($this->getDbName()); + $db = Propel::getDB($this->getDbName()); + + $params = array(); + $sql = BasePeer::createSelectSql($this, $params); + try { + $stmt = $con->prepare($sql); + $db->bindValues($stmt, $params, $dbMap); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + + return $stmt; + } + + /** + * Apply a condition on a column and issues the SELECT query + * + * @see filterBy() + * @see find() + * + * @param string $column A string representing the column phpName, e.g. 'AuthorId' + * @param mixed $value A value for the condition + * @param PropelPDO $con An optional connection object + * + * @return mixed the list of results, formatted by the current formatter + */ + public function findBy($column, $value, $con = null) + { + $method = 'filterBy' . $column; + $this->$method($value); + + return $this->find($con); + } + + /** + * Apply a list of conditions on columns and issues the SELECT query + * + * $c->findByArray(array( + * 'Title' => 'War And Peace', + * 'Publisher' => $publisher + * ), $con); + * + * + * @see filterByArray() + * @see find() + * + * @param mixed $conditions An array of conditions, using column phpNames as key + * @param PropelPDO $con an optional connection object + * + * @return mixed the list of results, formatted by the current formatter + */ + public function findByArray($conditions, $con = null) + { + $this->filterByArray($conditions); + + return $this->find($con); + } + + /** + * Apply a condition on a column and issues the SELECT ... LIMIT 1 query + * + * @see filterBy() + * @see findOne() + * + * @param mixed $column A string representing thecolumn phpName, e.g. 'AuthorId' + * @param mixed $value A value for the condition + * @param PropelPDO $con an optional connection object + * + * @return mixed the result, formatted by the current formatter + */ + public function findOneBy($column, $value, $con = null) + { + $method = 'filterBy' . $column; + $this->$method($value); + + return $this->findOne($con); + } + + /** + * Apply a list of conditions on columns and issues the SELECT ... LIMIT 1 query + * + * $c->findOneByArray(array( + * 'Title' => 'War And Peace', + * 'Publisher' => $publisher + * ), $con); + * + * + * @see filterByArray() + * @see findOne() + * + * @param mixed $conditions An array of conditions, using column phpNames as key + * @param PropelPDO $con an optional connection object + * + * @return mixed the list of results, formatted by the current formatter + */ + public function findOneByArray($conditions, $con = null) + { + $this->filterByArray($conditions); + + return $this->findOne($con); + } + + /** + * Issue a SELECT COUNT(*) query based on the current ModelCriteria + * + * @param PropelPDO $con an optional connection object + * + * @return integer the number of results + */ + public function count($con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $criteria->setDbName($this->getDbName()); // Set the correct dbName + $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count + + // 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(constant($this->modelPeerName . '::TABLE_NAME')); + + $stmt = $criteria->doCount($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; + } + + /** + * @param $con + * @return PDOStatement + * @throws PropelException + */ + protected function doCount($con) + { + $dbMap = Propel::getDatabaseMap($this->getDbName()); + $db = Propel::getDB($this->getDbName()); + + // check that the columns of the main class are already added (if this is the primary ModelCriteria) + if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) { + $this->addSelfSelectColumns(); + } + + $this->configureSelectColumns(); + + $needsComplexCount = $this->getGroupByColumns() + || $this->getOffset() + || $this->getLimit() + || $this->getHaving() + || in_array(Criteria::DISTINCT, $this->getSelectModifiers()) + || count($this->selectQueries) > 0; + + $params = array(); + if ($needsComplexCount) { + if (BasePeer::needsSelectAliases($this)) { + if ($this->getHaving()) { + throw new PropelException('Propel cannot create a COUNT query when using HAVING and duplicate column names in the SELECT part'); + } + $db->turnSelectColumnsToAliases($this); + } + $selectSql = BasePeer::createSelectSql($this, $params); + $sql = 'SELECT COUNT(*) FROM (' . $selectSql . ') propelmatch4cnt'; + } else { + // Replace SELECT columns with COUNT(*) + $this->clearSelectColumns()->addSelectColumn('COUNT(*)'); + $sql = BasePeer::createSelectSql($this, $params); + } + try { + /* @var $con PDO */ + $stmt = $con->prepare($sql); + $db->bindValues($stmt, $params, $dbMap); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute COUNT statement [%s]', $sql), $e); + } + + return $stmt; + } + + /** + * Issue a SELECT query based on the current ModelCriteria + * and uses a page and a maximum number of results per page + * to compute an offet and a limit. + * + * @param int $page number of the page to start the pager on. Page 1 means no offset + * @param int $maxPerPage maximum number of results per page. Determines the limit + * @param PropelPDO $con an optional connection object + * + * @return PropelModelPager a pager object, supporting iteration + */ + public function paginate($page = 1, $maxPerPage = 10, $con = null) + { + $criteria = $this->isKeepQuery() ? clone $this : $this; + $pager = new PropelModelPager($criteria, $maxPerPage); + $pager->setPage($page); + $pager->init($con); + + return $pager; + } + + /** + * Code to execute before every DELETE statement + * + * @param PropelPDO $con The connection object used by the query + * @return null + */ + protected function basePreDelete(PropelPDO $con) + { + return $this->preDelete($con); + } + + /** + * @param PropelPDO $con + * @return null + */ + protected function preDelete(PropelPDO $con) + { + } + + /** + * Code to execute after every DELETE statement + * + * @param int $affectedRows the number of deleted rows + * @param PropelPDO $con The connection object used by the query + * @return null + */ + protected function basePostDelete($affectedRows, PropelPDO $con) + { + return $this->postDelete($affectedRows, $con); + } + + /** + * @param $affectedRows + * @param PropelPDO $con + * @return null + */ + protected function postDelete($affectedRows, PropelPDO $con) + { + } + + /** + * Issue a DELETE query based on the current ModelCriteria + * An optional hook on basePreDelete() can prevent the actual deletion + * + * @param PropelPDO $con an optional connection object + * + * @return integer the number of deleted rows + * + * @throws PropelException + */ + public function delete($con = null) + { + if (count($this->getMap()) == 0) { + throw new PropelException('delete() expects a Criteria with at least one condition. Use deleteAll() to delete all the rows of a table'); + } + + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_WRITE); + } + + $criteria = $this->isKeepQuery() ? clone $this : $this; + $criteria->setDbName($this->getDbName()); + + $con->beginTransaction(); + try { + if (!$affectedRows = $criteria->basePreDelete($con)) { + $affectedRows = $criteria->doDelete($con); + } + $criteria->basePostDelete($affectedRows, $con); + $con->commit(); + } catch (Exception $e) { + $con->rollback(); + throw $e; + } + + return $affectedRows; + } + + /** + * Issue a DELETE query based on the current ModelCriteria + * This method is called by ModelCriteria::delete() inside a transaction + * + * @param PropelPDO $con a connection object + * + * @return integer the number of deleted rows + */ + public function doDelete($con) + { + $affectedRows = call_user_func(array($this->modelPeerName, 'doDelete'), $this, $con); + + return $affectedRows; + } + + /** + * Issue a DELETE query based on the current ModelCriteria deleting all rows in the table + * An optional hook on basePreDelete() can prevent the actual deletion + * + * @param PropelPDO $con an optional connection object + * + * @return integer the number of deleted rows + * + * @throws Exception|PropelException + */ + public function deleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_WRITE); + } + $con->beginTransaction(); + try { + if (!$affectedRows = $this->basePreDelete($con)) { + $affectedRows = $this->doDeleteAll($con); + } + $this->basePostDelete($affectedRows, $con); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Issue a DELETE query based on the current ModelCriteria deleting all rows in the table + * This method is called by ModelCriteria::deleteAll() inside a transaction + * + * @param PropelPDO $con a connection object + * + * @return integer the number of deleted rows + */ + public function doDeleteAll($con) + { + $affectedRows = call_user_func(array($this->modelPeerName, 'doDeleteAll'), $con); + + return $affectedRows; + } + + /** + * Code to execute before every UPDATE statement + * + * @param array $values The associative array of columns and values for the update + * @param PropelPDO $con The connection object used by the query + * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), otherwise it is a series of save() calls on all the found objects + */ + protected function basePreUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false) + { + return $this->preUpdate($values, $con, $forceIndividualSaves); + } + + protected function preUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false) + { + } + + /** + * Code to execute after every UPDATE statement + * + * @param int $affectedRows the number of updated rows + * @param PropelPDO $con The connection object used by the query + */ + protected function basePostUpdate($affectedRows, PropelPDO $con) + { + return $this->postUpdate($affectedRows, $con); + } + + protected function postUpdate($affectedRows, PropelPDO $con) + { + } + + /** + * Issue an UPDATE query based the current ModelCriteria and a list of changes. + * An optional hook on basePreUpdate() can prevent the actual update. + * Beware that behaviors based on hooks in the object's save() method + * will only be triggered if you force individual saves, i.e. if you pass true as second argument. + * + * @param array $values Associative array of keys and values to replace + * @param PropelPDO $con an optional connection object + * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), otherwise it is a series of save() calls on all the found objects + * + * @return Integer Number of updated rows + * + * @throws PropelException + */ + public function update($values, $con = null, $forceIndividualSaves = false) + { + if (!is_array($values)) { + throw new PropelException('set() expects an array as first argument'); + } + if (count($this->getJoins())) { + throw new PropelException('set() does not support multitable updates, please do not use join()'); + } + + if ($con === null) { + $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_WRITE); + } + + /* @var $criteria ModelCriteria */ + $criteria = $this->isKeepQuery() ? clone $this : $this; + $criteria->setPrimaryTableName(constant($this->modelPeerName . '::TABLE_NAME')); + + $con->beginTransaction(); + try { + + if (!$affectedRows = $criteria->basePreUpdate($values, $con, $forceIndividualSaves)) { + $affectedRows = $criteria->doUpdate($values, $con, $forceIndividualSaves); + } + $criteria->basePostUpdate($affectedRows, $con); + + $con->commit(); + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Issue an UPDATE query based the current ModelCriteria and a list of changes. + * This method is called by ModelCriteria::update() inside a transaction. + * + * @param array $values Associative array of keys and values to replace + * @param PropelPDO $con a connection object + * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), otherwise it is a series of save() calls on all the found objects + * + * @return Integer Number of updated rows + */ + public function doUpdate($values, $con, $forceIndividualSaves = false) + { + if ($forceIndividualSaves) { + + // Update rows one by one + $objects = $this->setFormatter(ModelCriteria::FORMAT_OBJECT)->find($con); + foreach ($objects as $object) { + foreach ($values as $key => $value) { + $object->setByName($key, $value); + } + } + $objects->save($con); + $affectedRows = count($objects); + } else { + + // update rows in a single query + $set = new Criteria($this->getDbName()); + foreach ($values as $columnName => $value) { + $realColumnName = $this->getTableMap()->getColumnByPhpName($columnName)->getFullyQualifiedName(); + $set->add($realColumnName, $value); + } + $affectedRows = BasePeer::doUpdate($this, $set, $con); + call_user_func(array($this->modelPeerName, 'clearInstancePool')); + call_user_func(array($this->modelPeerName, 'clearRelatedInstancePool')); + } + + return $affectedRows; + } + + /** + * Creates a Criterion object based on a list of existing condition names and a comparator + * + * @param array $conditions The list of condition names, e.g. array('cond1', 'cond2') + * @param string $operator An operator, Criteria::LOGICAL_AND (default) or Criteria::LOGICAL_OR + * + * @return Criterion a Criterion or ModelCriterion object + */ + protected function getCriterionForConditions($conditions, $operator = null) + { + $operator = (null === $operator) ? Criteria::LOGICAL_AND : $operator; + $this->combine($conditions, $operator, 'propel_temp_name'); + $criterion = $this->namedCriterions['propel_temp_name']; + unset($this->namedCriterions['propel_temp_name']); + + return $criterion; + } + + /** + * Creates a Criterion object based on a SQL clause and a value + * Uses introspection to translate the column phpName into a fully qualified name + * + * @param string $clause The pseudo SQL clause, e.g. 'AuthorId = ?' + * @param mixed $value A value for the condition + * @param string $bindingType + * + * @return Criterion a Criterion or ModelCriterion object + * + * @throws PropelException + */ + protected function getCriterionForClause($clause, $value, $bindingType = null) + { + $clause = trim($clause); + if ($this->replaceNames($clause)) { + // at least one column name was found and replaced in the clause + // this is enough to determine the type to bind the parameter to + if (null !== $bindingType) { + $operator = ModelCriteria::MODEL_CLAUSE_RAW; + } elseif (preg_match('/IN \?$/i', $clause) !== 0) { + $operator = ModelCriteria::MODEL_CLAUSE_ARRAY; + } elseif (preg_match('/LIKE \?$/i', $clause) !== 0) { + $operator = ModelCriteria::MODEL_CLAUSE_LIKE; + } elseif (substr_count($clause, '?') > 1) { + $operator = ModelCriteria::MODEL_CLAUSE_SEVERAL; + } else { + $operator = ModelCriteria::MODEL_CLAUSE; + } + $colMap = $this->replacedColumns[0]; + $value = $this->convertValueForColumn($value, $colMap); + $criterion = new ModelCriterion($this, $colMap, $value, $operator, $clause, $bindingType); + if ($this->currentAlias != '') { + $criterion->setTable($this->currentAlias); + } + } else { + // no column match in clause, must be an expression like '1=1' + if (strpos($clause, '?') !== false) { + if (null === $bindingType) { + throw new PropelException("Cannot determine the column to bind to the parameter in clause '$clause'"); + } + $criterion = new Criterion($this, $clause, $value, Criteria::RAW, $bindingType); + } else { + $criterion = new Criterion($this, null, $clause, Criteria::CUSTOM); + } + } + + return $criterion; + } + + /** + * Converts value for some column types + * + * @param mixed $value The value to convert + * @param ColumnMap $colMap The ColumnMap object + * + * @return mixed The converted value + */ + protected function convertValueForColumn($value, ColumnMap $colMap) + { + if ($colMap->getType() == 'OBJECT' && is_object($value)) { + if (is_array($value)) { + $value = array_map('serialize', $value); + } else { + $value = serialize($value); + } + } elseif ($colMap->getType() == 'ARRAY' && is_array($value)) { + $value = '| ' . implode(' | ', $value) . ' |'; + } elseif ($colMap->getType() == 'ENUM') { + if (is_array($value)) { + $value = array_map(array($colMap, 'getValueSetKey'), $value); + } else { + $value = $colMap->getValueSetKey($value); + } + } + + return $value; + } + + /** + * Replaces complete column names (like Article.AuthorId) in an SQL clause + * by their exact Propel column fully qualified name (e.g. article.AUTHOR_ID) + * but ignores the column names inside quotes + * e.g. 'CONCAT(Book.Title, "Book.Title") = ?' + * => 'CONCAT(book.TITLE, "Book.Title") = ?' + * + * @param string $clause SQL clause to inspect (modified by the method) + * + * @return boolean Whether the method managed to find and replace at least one column name + */ + protected function replaceNames(&$clause) + { + $this->replacedColumns = array(); + $this->currentAlias = ''; + $this->foundMatch = false; + $isAfterBackslash = false; + $isInString = false; + $stringQuotes = ''; + $parsedString = ''; + $stringToTransform = ''; + $len = strlen($clause); + $pos = 0; + while ($pos < $len) { + $char = $clause[$pos]; + // check flags for strings or escaper + switch ($char) { + case "\\": + $isAfterBackslash = true; + break; + case "'": + case "\"": + if ($isInString && $stringQuotes == $char) { + if (!$isAfterBackslash) { + $isInString = false; + } + } elseif (!$isInString) { + $parsedString .= preg_replace_callback("/[\w\\\]+\.\w+/", array($this, 'doReplaceNameInExpression'), $stringToTransform); + $stringToTransform = ''; + $stringQuotes = $char; + $isInString = true; + } + break; + } + if ($char !== "\\") { + $isAfterBackslash = false; + } + if ($isInString) { + $parsedString .= $char; + } else { + $stringToTransform .= $char; + } + $pos++; + } + if ($stringToTransform) { + $parsedString .= preg_replace_callback("/[\w\\\]+\.\w+/", array($this, 'doReplaceNameInExpression'), $stringToTransform); + } + + $clause = $parsedString; + + return $this->foundMatch; + } + + /** + * Callback function to replace column names by their real name in a clause + * e.g. 'Book.Title IN ?' + * => 'book.TITLE IN ?' + * + * @param array $matches Matches found by preg_replace_callback + * + * @return string the column name replacement + */ + protected function doReplaceNameInExpression($matches) + { + $key = $matches[0]; + list($column, $realColumnName) = $this->getColumnFromName($key); + if ($column instanceof ColumnMap) { + $this->replacedColumns[] = $column; + $this->foundMatch = true; + + return $realColumnName; + } else { + return $key; + } + } + + /** + * Finds a column and a SQL translation for a pseudo SQL column name + * Respects table aliases previously registered in a join() or addAlias() + * Examples: + * + * $c->getColumnFromName('Book.Title'); + * => array($bookTitleColumnMap, 'book.TITLE') + * $c->join('Book.Author a') + * ->getColumnFromName('a.FirstName'); + * => array($authorFirstNameColumnMap, 'a.FIRST_NAME') + * + * + * @param string $phpName String representing the column name in a pseudo SQL clause, e.g. 'Book.Title' + * @param boolean $failSilently + * + * @return array List($columnMap, $realColumnName) + * + * @throws PropelException + */ + protected function getColumnFromName($phpName, $failSilently = true) + { + if (strpos($phpName, '.') === false) { + $prefix = $this->getModelAliasOrName(); + } else { + // $prefix could be either class name or table name + list($prefix, $phpName) = explode('.', $phpName); + } + + if ($prefix == $this->getModelAliasOrName() || $prefix == $this->getTableMap()->getName()) { + // column of the Criteria's model, or column name from Criteria's peer + $tableMap = $this->getTableMap(); + } elseif (isset($this->joins[$prefix])) { + // column of a relations's model + $tableMap = $this->joins[$prefix]->getTableMap(); + } elseif ($this->hasSelectQuery($prefix)) { + return $this->getColumnFromSubQuery($prefix, $phpName, $failSilently); + } elseif ($failSilently) { + return array(null, null); + } else { + throw new PropelException(sprintf('Unknown model, alias or table "%s"', $prefix)); + } + + if ($tableMap->hasColumnByPhpName($phpName)) { + $column = $tableMap->getColumnByPhpName($phpName); + if (isset($this->aliases[$prefix])) { + $this->currentAlias = $prefix; + $realColumnName = $prefix . '.' . $column->getName(); + } else { + $realColumnName = $column->getFullyQualifiedName(); + } + + return array($column, $realColumnName); + } elseif ($tableMap->hasColumn($phpName, false)) { + $column = $tableMap->getColumn($phpName, false); + $realColumnName = $column->getFullyQualifiedName(); + + return array($column, $realColumnName); + } elseif (isset($this->asColumns[$phpName])) { + // aliased column + return array(null, $phpName); + } elseif ($tableMap->hasColumnByInsensitiveCase($phpName)) { + $column = $tableMap->getColumnByInsensitiveCase($phpName); + $realColumnName = $column->getFullyQualifiedName(); + + return array($column, $realColumnName); + } elseif ($failSilently) { + return array(null, null); + } else { + throw new PropelException(sprintf('Unknown column "%s" on model, alias or table "%s"', $phpName, $prefix)); + } + } + + /** + * Special case for subquery columns + * + * @param string $class + * @param string $phpName + * @param boolean $failSilently + * + * @return array List($columnMap, $realColumnName) + * + * @throws PropelException + */ + protected function getColumnFromSubQuery($class, $phpName, $failSilently = true) + { + $subQueryCriteria = $this->getSelectQuery($class); + $tableMap = $subQueryCriteria->getTableMap(); + if ($tableMap->hasColumnByPhpName($phpName)) { + $column = $tableMap->getColumnByPhpName($phpName); + $realColumnName = $class . '.' . $column->getName(); + + return array($column, $realColumnName); + } elseif (isset($subQueryCriteria->asColumns[$phpName])) { + // aliased column + return array(null, $class . '.' . $phpName); + } elseif ($failSilently) { + return array(null, null); + } else { + throw new PropelException(sprintf('Unknown column "%s" in the subQuery with alias "%s"', $phpName, $class)); + } + } + + /** + * Return a fully qualified column name corresponding to a simple column phpName + * Uses model alias if it exists + * Warning: restricted to the columns of the main model + * e.g. => 'Title' => 'book.TITLE' + * + * @param string $columnName the Column phpName, without the table name + * + * @return string the fully qualified column name + * + * @throws PropelException + */ + protected function getRealColumnName($columnName) + { + if (!$this->getTableMap()->hasColumnByPhpName($columnName)) { + throw new PropelException('Unknown column ' . $columnName . ' in model ' . $this->modelName); + } + if ($this->useAliasInSQL) { + return $this->modelAlias . '.' . $this->getTableMap()->getColumnByPhpName($columnName)->getName(); + } else { + return $this->getTableMap()->getColumnByPhpName($columnName)->getFullyQualifiedName(); + } + } + + /** + * Changes the table part of a a fully qualified column name if a true model alias exists + * e.g. => 'book.TITLE' => 'b.TITLE' + * This is for use as first argument of Criteria::add() + * + * @param string $colName the fully qualified column name, e.g 'book.TITLE' or BookPeer::TITLE + * + * @return string the fully qualified column name, using table alias if applicable + */ + public function getAliasedColName($colName) + { + if ($this->useAliasInSQL) { + return $this->modelAlias . substr($colName, strrpos($colName, '.')); + } else { + return $colName; + } + } + + /** + * Overrides Criteria::add() to force the use of a true table alias if it exists + * + * @see Criteria::add() + * + * @param string $column The colName of column to run the condition on (e.g. BookPeer::ID) + * @param mixed $value + * @param string $operator A String, like Criteria::EQUAL. + * + * @return ModelCriteria A modified Criteria object. + */ + public function addUsingAlias($column, $value = null, $operator = null) + { + return $this->addUsingOperator($this->getAliasedColName($column), $value, $operator); + } + + /** + * Get all the parameters to bind to this criteria + * Does part of the job of BasePeer::createSelectSql() for the cache + * + * @return array list of parameters, each parameter being an array like + * array('table' => $realtable, 'column' => $column, 'value' => $value) + */ + public function getParams() + { + $params = array(); + $dbMap = Propel::getDatabaseMap($this->getDbName()); + + foreach ($this->getMap() as $criterion) { + + $table = null; + foreach ($criterion->getAttachedCriterion() as $attachedCriterion) { + $tableName = $attachedCriterion->getTable(); + + $table = $this->getTableForAlias($tableName); + if (null === $table) { + $table = $tableName; + } + + if (($this->isIgnoreCase() || $attachedCriterion->isIgnoreCase()) + && $dbMap->getTable($table)->getColumn($attachedCriterion->getColumn())->isText()) { + $attachedCriterion->setIgnoreCase(true); + } + } + + $sb = ''; + $criterion->appendPsTo($sb, $params); + } + + $having = $this->getHaving(); + if ($having !== null) { + $sb = ''; + $having->appendPsTo($sb, $params); + } + + return $params; + } + + /** + * Handle the magic + * Supports findByXXX(), findOneByXXX(), filterByXXX(), orderByXXX(), and groupByXXX() methods, + * where XXX is a column phpName. + * Supports XXXJoin(), where XXX is a join direction (in 'left', 'right', 'inner') + */ + public function __call($name, $arguments) + { + // Maybe it's a magic call to one of the methods supporting it, e.g. 'findByTitle' + static $methods = array('findBy', 'findOneBy', 'filterBy', 'orderBy', 'groupBy'); + foreach ($methods as $method) { + if (strpos($name, $method) === 0) { + $columns = substr($name, strlen($method)); + if (in_array($method, array('findBy', 'findOneBy')) && strpos($columns, 'And') !== false) { + $method = $method . 'Array'; + $columns = explode('And', $columns); + $conditions = array(); + foreach ($columns as $column) { + $conditions[$column] = array_shift($arguments); + } + array_unshift($arguments, $conditions); + } else { + array_unshift($arguments, $columns); + } + + return call_user_func_array(array($this, $method), $arguments); + } + } + + // Maybe it's a magic call to a qualified joinWith method, e.g. 'leftJoinWith' or 'joinWithAuthor' + if (($pos = stripos($name, 'joinWith')) !== false) { + $type = substr($name, 0, $pos); + if (in_array($type, array('left', 'right', 'inner'))) { + $joinType = strtoupper($type) . ' JOIN'; + } else { + $joinType = Criteria::INNER_JOIN; + } + if (!$relation = substr($name, $pos + 8)) { + $relation = $arguments[0]; + } + + return $this->joinWith($relation, $joinType); + } + + // Maybe it's a magic call to a qualified join method, e.g. 'leftJoin' + if (($pos = strpos($name, 'Join')) > 0) { + $type = substr($name, 0, $pos); + if (in_array($type, array('left', 'right', 'inner'))) { + $joinType = strtoupper($type) . ' JOIN'; + // Test if first argument is supplied, else don't provide an alias to joinXXX (default value) + if (!isset($arguments[0])) { + $arguments[0] = null; + } + array_push($arguments, $joinType); + $method = lcfirst(substr($name, $pos)); + + return call_user_func_array(array($this, $method), $arguments); + } + } + + throw new PropelException(sprintf('Undefined method %s::%s()', __CLASS__, $name)); + } + + /** + * Ensures deep cloning of attached objects + */ + public function __clone() + { + parent::__clone(); + foreach ($this->with as $key => $join) { + $this->with[$key] = clone $join; + } + if (null !== $this->formatter) { + $this->formatter = clone $this->formatter; + } + } + + /** + * Make explain plan of the query + * + * @param PropelPDO $con propel connection + * + * @throws PropelException on error + * @return array array of the explain plan + */ + public function explain($con = null) + { + if ($con === null) { + $con = Propel::getConnection($this->getDbName()); + } + $this->basePreSelect($con); + + // check that the columns of the main class are already added (if this is the primary ModelCriteria) + if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) { + $this->addSelfSelectColumns(); + } + $this->configureSelectColumns(); + + $db = Propel::getDB($this->getDbName()); + try { + $stmt = $db->doExplainPlan($con, $this); + + return $stmt->fetchAll(PDO::FETCH_ASSOC); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException('Unable to execute query explain plan', $e); + } + } + + /** + * @param PropelPDO $con = null + * + * @return boolean + */ + public function exists($con = null) + { + return 0 !== $this->count($con); + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/query/ModelCriterion.php b/airtime_mvc/library/propel/runtime/lib/query/ModelCriterion.php index beeeda79a..c6eb4b6eb 100644 --- a/airtime_mvc/library/propel/runtime/lib/query/ModelCriterion.php +++ b/airtime_mvc/library/propel/runtime/lib/query/ModelCriterion.php @@ -12,272 +12,299 @@ * This is an "inner" class that describes an object in the criteria. * * @author Francois - * @version $Revision: 1630 $ + * @version $Revision$ * @package propel.runtime.query */ class ModelCriterion extends Criterion -{ - protected $clause = ''; +{ + protected $clause = ''; - /** - * Create a new instance. - * - * @param Criteria $parent The outer class (this is an "inner" class). - * @param ColumnMap $column A Column object to help escaping the value - * @param mixed $value - * @param string $comparison, among ModelCriteria::MODEL_CLAUSE - * @param string $clause A simple pseudo-SQL clause, e.g. 'foo.BAR LIKE ?' - */ - public function __construct(Criteria $outer, $column, $value = null, $comparison = ModelCriteria::MODEL_CLAUSE, $clause) - { - $this->value = $value; - if ($column instanceof ColumnMap) { - $this->column = $column->getName(); - $this->table = $column->getTable()->getName(); - } else { - $dotPos = strrpos($column,'.'); - if ($dotPos === false) { - // no dot => aliased column - $this->table = null; - $this->column = $column; - } else { - $this->table = substr($column, 0, $dotPos); - $this->column = substr($column, $dotPos+1, strlen($column)); - } - } - $this->comparison = ($comparison === null ? Criteria::EQUAL : $comparison); - $this->clause = $clause; - $this->init($outer); - } - - public function getClause() - { - return $this->clause; - } - - /** - * Figure out which MocelCriterion method to use - * to build the prepared statement and parameters using to the Criterion comparison - * and call it to append the prepared statement and the parameters of the current clause. - * For performance reasons, this method tests the cases of parent::dispatchPsHandling() - * first, and that is not possible through inheritance ; that's why the parent - * code is duplicated here. - * - * @param string &$sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended - */ - protected function dispatchPsHandling(&$sb, array &$params) - { - switch ($this->comparison) { - case Criteria::CUSTOM: - // custom expression with no parameter binding - $this->appendCustomToPs($sb, $params); - break; - case Criteria::IN: - case Criteria::NOT_IN: - // table.column IN (?, ?) or table.column NOT IN (?, ?) - $this->appendInToPs($sb, $params); - break; - case Criteria::LIKE: - case Criteria::NOT_LIKE: - case Criteria::ILIKE: - case Criteria::NOT_ILIKE: - // table.column LIKE ? or table.column NOT LIKE ? (or ILIKE for Postgres) - $this->appendLikeToPs($sb, $params); - break; - case ModelCriteria::MODEL_CLAUSE: - // regular model clause, e.g. 'book.TITLE = ?' - $this->appendModelClauseToPs($sb, $params); - break; - case ModelCriteria::MODEL_CLAUSE_LIKE: - // regular model clause, e.g. 'book.TITLE = ?' - $this->appendModelClauseLikeToPs($sb, $params); - break; - case ModelCriteria::MODEL_CLAUSE_SEVERAL: - // Ternary model clause, e.G 'book.ID BETWEEN ? AND ?' - $this->appendModelClauseSeveralToPs($sb, $params); - break; - case ModelCriteria::MODEL_CLAUSE_ARRAY: - // IN or NOT IN model clause, e.g. 'book.TITLE NOT IN ?' - $this->appendModelClauseArrayToPs($sb, $params); - break; - default: - // table.column = ? or table.column >= ? etc. (traditional expressions, the default) - $this->appendBasicToPs($sb, $params); - - } - } - - /** - * Appends a Prepared Statement representation of the ModelCriterion onto the buffer - * For regular model clauses, e.g. 'book.TITLE = ?' - * - * @param string &$sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended - */ - public function appendModelClauseToPs(&$sb, array &$params) - { - if ($this->value !== null) { - $params[] = array('table' => $this->realtable, 'column' => $this->column, 'value' => $this->value); - $sb .= str_replace('?', ':p'.count($params), $this->clause); - } else { - $sb .= $this->clause; - } - } - - /** - * Appends a Prepared Statement representation of the ModelCriterion onto the buffer - * For LIKE model clauses, e.g. 'book.TITLE LIKE ?' - * Handles case insensitivity for VARCHAR columns - * - * @param string &$sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended - */ - public function appendModelClauseLikeToPs(&$sb, array &$params) - { - // LIKE is case insensitive in mySQL and SQLite, but not in PostGres - // If the column is case insensitive, use ILIKE / NOT ILIKE instead of LIKE / NOT LIKE - if ($this->ignoreStringCase && $this->getDb() instanceof DBPostgres) { - $this->clause = preg_replace('/LIKE \?$/i', 'ILIKE ?', $this->clause); - } - $this->appendModelClauseToPs($sb, $params); - } - - /** - * Appends a Prepared Statement representation of the ModelCriterion onto the buffer - * For ternary model clauses, e.G 'book.ID BETWEEN ? AND ?' - * - * @param string &$sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended - */ - public function appendModelClauseSeveralToPs(&$sb, array &$params) - { - $clause = $this->clause; - foreach ((array) $this->value as $value) { - if ($value === null) { - // FIXME we eventually need to translate a BETWEEN to - // something like WHERE (col < :p1 OR :p1 IS NULL) AND (col < :p2 OR :p2 IS NULL) - // in order to support null values - throw new PropelException('Null values are not supported inside BETWEEN clauses'); - } - $params[] = array('table' => $this->realtable, 'column' => $this->column, 'value' => $value); - $clause = self::strReplaceOnce('?', ':p'.count($params), $clause); - } - $sb .= $clause; - } - - /** - * Appends a Prepared Statement representation of the ModelCriterion onto the buffer - * For IN or NOT IN model clauses, e.g. 'book.TITLE NOT IN ?' - * - * @param string &$sb The string that will receive the Prepared Statement - * @param array $params A list to which Prepared Statement parameters will be appended - */ - public function appendModelClauseArrayToPs(&$sb, array &$params) - { - $_bindParams = array(); // the param names used in query building - $_idxstart = count($params); - $valuesLength = 0; - foreach ( (array) $this->value as $value ) { - $valuesLength++; // increment this first to correct for wanting bind params to start with :p1 - $params[] = array('table' => $this->realtable, 'column' => $this->column, 'value' => $value); - $_bindParams[] = ':p'.($_idxstart + $valuesLength); - } - if ($valuesLength !== 0) { - $sb .= str_replace('?', '(' . implode(',', $_bindParams) . ')', $this->clause); - } else { - $sb .= (stripos($this->clause, ' NOT IN ') === false) ? "1<>1" : "1=1"; - } - unset ( $value, $valuesLength ); - } - - /** - * This method checks another Criteria to see if they contain - * the same attributes and hashtable entries. - * @return boolean - */ - public function equals($obj) - { - // TODO: optimize me with early outs - if ($this === $obj) { - return true; - } - - if (($obj === null) || !($obj instanceof ModelCriterion)) { - return false; - } - - $crit = $obj; - - $isEquiv = ( ( ($this->table === null && $crit->getTable() === null) - || ( $this->table !== null && $this->table === $crit->getTable() ) - ) - && $this->clause === $crit->getClause() - && $this->column === $crit->getColumn() - && $this->comparison === $crit->getComparison()); - - // check chained criterion - - $clausesLength = count($this->clauses); - $isEquiv &= (count($crit->getClauses()) == $clausesLength); - $critConjunctions = $crit->getConjunctions(); - $critClauses = $crit->getClauses(); - for ($i=0; $i < $clausesLength && $isEquiv; $i++) { - $isEquiv &= ($this->conjunctions[$i] === $critConjunctions[$i]); - $isEquiv &= ($this->clauses[$i] === $critClauses[$i]); - } - - if ($isEquiv) { - $isEquiv &= $this->value === $crit->getValue(); - } - - return $isEquiv; - } - - /** - * Returns a hash code value for the object. - */ - public function hashCode() - { - $h = crc32(serialize($this->value)) ^ crc32($this->comparison) ^ crc32($this->clause); - - if ($this->table !== null) { - $h ^= crc32($this->table); - } - - if ($this->column !== null) { - $h ^= crc32($this->column); - } - - foreach ( $this->clauses as $clause ) { - // TODO: i KNOW there is a php incompatibility with the following line - // but i dont remember what it is, someone care to look it up and - // replace it if it doesnt bother us? - // $clause->appendPsTo($sb='',$params=array()); - $sb = ''; - $params = array(); - $clause->appendPsTo($sb,$params); - $h ^= crc32(serialize(array($sb,$params))); - unset ( $sb, $params ); - } - - return $h; - } - - /** - * Replace only once - * taken from http://www.php.net/manual/en/function.str-replace.php - * - */ - protected static function strReplaceOnce($search, $replace, $subject) - { - $firstChar = strpos($subject, $search); - if($firstChar !== false) { - $beforeStr = substr($subject,0,$firstChar); - $afterStr = substr($subject, $firstChar + strlen($search)); - return $beforeStr.$replace.$afterStr; - } else { - return $subject; + /** + * Create a new instance. + * + * @param Criteria $outer The outer class (this is an "inner" class). + * @param ColumnMap $column A Column object to help escaping the value + * @param mixed $value + * @param string $comparison, among ModelCriteria::MODEL_CLAUSE + * @param string $clause A simple pseudo-SQL clause, e.g. 'foo.BAR LIKE ?' + * @param string $type + */ + public function __construct(Criteria $outer, $column, $value, $comparison, $clause, $type = null) + { + $this->value = $value; + if ($column instanceof ColumnMap) { + $this->column = $column->getName(); + $this->table = $column->getTable()->getName(); + } else { + $dotPos = strrpos($column, '.'); + if ($dotPos === false) { + // no dot => aliased column + $this->table = null; + $this->column = $column; + } else { + $this->table = substr($column, 0, $dotPos); + $this->column = substr($column, $dotPos + 1, strlen($column)); + } + } + $this->comparison = ($comparison === null ? Criteria::EQUAL : $comparison); + $this->clause = $clause; + $this->type = $type; + $this->init($outer); } - } -} \ No newline at end of file + + public function getClause() + { + return $this->clause; + } + + /** + * Figure out which ModelCriterion method to use + * to build the prepared statement and parameters using to the Criterion comparison + * and call it to append the prepared statement and the parameters of the current clause. + * For performance reasons, this method tests the cases of parent::dispatchPsHandling() + * first, and that is not possible through inheritance ; that's why the parent + * code is duplicated here. + * + * @param string &$sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + */ + protected function dispatchPsHandling(&$sb, array &$params) + { + switch ($this->comparison) { + case Criteria::CUSTOM: + // custom expression with no parameter binding + $this->appendCustomToPs($sb, $params); + break; + case Criteria::IN: + case Criteria::NOT_IN: + // table.column IN (?, ?) or table.column NOT IN (?, ?) + $this->appendInToPs($sb, $params); + break; + case Criteria::LIKE: + case Criteria::NOT_LIKE: + case Criteria::ILIKE: + case Criteria::NOT_ILIKE: + // table.column LIKE ? or table.column NOT LIKE ? (or ILIKE for Postgres) + $this->appendLikeToPs($sb, $params); + break; + case ModelCriteria::MODEL_CLAUSE: + // regular model clause, e.g. 'book.TITLE = ?' + $this->appendModelClauseToPs($sb, $params); + break; + case ModelCriteria::MODEL_CLAUSE_LIKE: + // regular model clause, e.g. 'book.TITLE = ?' + $this->appendModelClauseLikeToPs($sb, $params); + break; + case ModelCriteria::MODEL_CLAUSE_SEVERAL: + // Ternary model clause, e.G 'book.ID BETWEEN ? AND ?' + $this->appendModelClauseSeveralToPs($sb, $params); + break; + case ModelCriteria::MODEL_CLAUSE_ARRAY: + // IN or NOT IN model clause, e.g. 'book.TITLE NOT IN ?' + $this->appendModelClauseArrayToPs($sb, $params); + break; + case ModelCriteria::MODEL_CLAUSE_RAW: + // raw model clause, with type, e.g. 'foobar = ?' + $this->appendModelClauseRawToPs($sb, $params); + break; + default: + // table.column = ? or table.column >= ? etc. (traditional expressions, the default) + $this->appendBasicToPs($sb, $params); + } + } + + /** + * Appends a Prepared Statement representation of the ModelCriterion onto the buffer + * For regular model clauses, e.g. 'book.TITLE = ?' + * + * @param string &$sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + */ + public function appendModelClauseToPs(&$sb, array &$params) + { + if ($this->value !== null) { + $params[] = array('table' => $this->realtable, 'column' => $this->column, 'value' => $this->value); + $sb .= str_replace('?', ':p' . count($params), $this->clause); + } else { + $sb .= $this->clause; + } + } + + /** + * Appends a Prepared Statement representation of the ModelCriterion onto the buffer + * For LIKE model clauses, e.g. 'book.TITLE LIKE ?' + * Handles case insensitivity for VARCHAR columns + * + * @param string &$sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + */ + public function appendModelClauseLikeToPs(&$sb, array &$params) + { + // LIKE is case insensitive in mySQL and SQLite, but not in PostGres + // If the column is case insensitive, use ILIKE / NOT ILIKE instead of LIKE / NOT LIKE + if ($this->ignoreStringCase && $this->getDb() instanceof DBPostgres) { + $this->clause = preg_replace('/LIKE \?$/i', 'ILIKE ?', $this->clause); + } + $this->appendModelClauseToPs($sb, $params); + } + + /** + * Appends a Prepared Statement representation of the ModelCriterion onto the buffer + * For ternary model clauses, e.G 'book.ID BETWEEN ? AND ?' + * + * @param string &$sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * + * @throws PropelException + */ + public function appendModelClauseSeveralToPs(&$sb, array &$params) + { + $clause = $this->clause; + foreach ((array) $this->value as $value) { + if ($value === null) { + // FIXME we eventually need to translate a BETWEEN to + // something like WHERE (col < :p1 OR :p1 IS NULL) AND (col < :p2 OR :p2 IS NULL) + // in order to support null values + throw new PropelException('Null values are not supported inside BETWEEN clauses'); + } + $params[] = array('table' => $this->realtable, 'column' => $this->column, 'value' => $value); + $clause = self::strReplaceOnce('?', ':p' . count($params), $clause); + } + $sb .= $clause; + } + + /** + * Appends a Prepared Statement representation of the ModelCriterion onto the buffer + * For IN or NOT IN model clauses, e.g. 'book.TITLE NOT IN ?' + * + * @param string &$sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + */ + public function appendModelClauseArrayToPs(&$sb, array &$params) + { + $_bindParams = array(); // the param names used in query building + $_idxstart = count($params); + $valuesLength = 0; + foreach ((array) $this->value as $value) { + $valuesLength++; // increment this first to correct for wanting bind params to start with :p1 + $params[] = array('table' => $this->realtable, 'column' => $this->column, 'value' => $value); + $_bindParams[] = ':p' . ($_idxstart + $valuesLength); + } + if ($valuesLength !== 0) { + $sb .= str_replace('?', '(' . implode(',', $_bindParams) . ')', $this->clause); + } else { + $sb .= (stripos($this->clause, ' NOT IN ') === false) ? "1<>1" : "1=1"; + } + unset($value, $valuesLength); + } + + /** + * Appends a Prepared Statement representation of the Criterion onto the buffer + * For custom expressions with a typed binding, e.g. 'foobar = ?' + * + * @param string &$sb The string that will receive the Prepared Statement + * @param array $params A list to which Prepared Statement parameters will be appended + * + * @throws PropelException + */ + protected function appendModelClauseRawToPs(&$sb, array &$params) + { + if (substr_count($this->clause, '?') != 1) { + throw new PropelException(sprintf('Could not build SQL for expression "%s" because Criteria::RAW works only with a clause containing a single question mark placeholder', $this->column)); + } + $params[] = array('table' => null, 'type' => $this->type, 'value' => $this->value); + $sb .= str_replace('?', ':p' . count($params), $this->clause); + } + + /** + * This method checks another Criteria to see if they contain + * the same attributes and hashtable entries. + * + * @return boolean + */ + public function equals($obj) + { + // TODO: optimize me with early outs + if ($this === $obj) { + return true; + } + + if (($obj === null) || !($obj instanceof ModelCriterion)) { + return false; + } + + $crit = $obj; + + $isEquiv = ( ( ($this->table === null && $crit->getTable() === null) + || ( $this->table !== null && $this->table === $crit->getTable() ) + ) + && $this->clause === $crit->getClause() + && $this->column === $crit->getColumn() + && $this->comparison === $crit->getComparison()); + + // check chained criterion + + $clausesLength = count($this->clauses); + $isEquiv &= (count($crit->getClauses()) == $clausesLength); + $critConjunctions = $crit->getConjunctions(); + $critClauses = $crit->getClauses(); + for ($i = 0; $i < $clausesLength && $isEquiv; $i++) { + $isEquiv &= ($this->conjunctions[$i] === $critConjunctions[$i]); + $isEquiv &= ($this->clauses[$i] === $critClauses[$i]); + } + + if ($isEquiv) { + $isEquiv &= $this->value === $crit->getValue(); + } + + return $isEquiv; + } + + /** + * Returns a hash code value for the object. + */ + public function hashCode() + { + $h = crc32(serialize($this->value)) ^ crc32($this->comparison) ^ crc32($this->clause); + + if ($this->table !== null) { + $h ^= crc32($this->table); + } + + if ($this->column !== null) { + $h ^= crc32($this->column); + } + + foreach ($this->clauses as $clause) { + // TODO: I KNOW there is a php incompatibility with the following line + // but I don't remember what it is, someone care to look it up and + // replace it if it doesn't bother us? + // $clause->appendPsTo($sb='',$params=array()); + $sb = ''; + $params = array(); + $clause->appendPsTo($sb, $params); + $h ^= crc32(serialize(array($sb, $params))); + unset($sb, $params); + } + + return $h; + } + + /** + * Replace only once + * taken from http://www.php.net/manual/en/function.str-replace.php + * + */ + protected static function strReplaceOnce($search, $replace, $subject) + { + $firstChar = strpos($subject, $search); + if ($firstChar !== false) { + $beforeStr = substr($subject, 0, $firstChar); + $afterStr = substr($subject, $firstChar + strlen($search)); + + return $beforeStr . $replace . $afterStr; + } else { + return $subject; + } + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/query/ModelJoin.php b/airtime_mvc/library/propel/runtime/lib/query/ModelJoin.php index 59bbfce5d..3c9ee32c8 100644 --- a/airtime_mvc/library/propel/runtime/lib/query/ModelJoin.php +++ b/airtime_mvc/library/propel/runtime/lib/query/ModelJoin.php @@ -16,151 +16,157 @@ */ class ModelJoin extends Join { - protected $relationMap; - protected $tableMap; - protected $leftTableAlias; - protected $relationAlias; - protected $previousJoin; - - public function setRelationMap(RelationMap $relationMap, $leftTableAlias = null, $relationAlias = null) - { - $leftCols = $relationMap->getLeftColumns(); - $rightCols = $relationMap->getRightColumns(); - $nbColumns = $relationMap->countColumnMappings(); - for ($i=0; $i < $nbColumns; $i++) { - $leftColName = ($leftTableAlias ? $leftTableAlias : $leftCols[$i]->getTableName()) . '.' . $leftCols[$i]->getName(); - $rightColName = ($relationAlias ? $relationAlias : $rightCols[$i]->getTableName()) . '.' . $rightCols[$i]->getName(); - $this->addCondition($leftColName, $rightColName, Criteria::EQUAL); - } - $this->relationMap = $relationMap; - $this->leftTableAlias = $leftTableAlias; - $this->relationAlias = $relationAlias; - - return $this; - } - - public function getRelationMap() - { - return $this->relationMap; - } + /** + * @var RelationMap + */ + protected $relationMap; - /** - * Sets the right tableMap for this join - * - * @param TableMap $tableMap The table map to use - * - * @return ModelJoin The current join object, for fluid interface - */ - public function setTableMap(TableMap $tableMap) - { - $this->tableMap = $tableMap; - - return $this; - } + /** + * @var TableMap + */ + protected $tableMap; - /** - * Gets the right tableMap for this join - * - * @return TableMap The table map - */ - public function getTableMap() - { - if (null === $this->tableMap && null !== $this->relationMap) - { - $this->tableMap = $this->relationMap->getRightTable(); - } - return $this->tableMap; - } - - public function setPreviousJoin(ModelJoin $join) - { - $this->previousJoin = $join; - - return $this; - } - - public function getPreviousJoin() - { - return $this->previousJoin; - } - - public function isPrimary() - { - return null === $this->previousJoin; - } + /** + * @var ModelJoin + */ + protected $previousJoin; - public function setLeftTableAlias($leftTableAlias) - { - $this->leftTableAlias = $leftTableAlias; - - return $this; - } - - public function getLeftTableAlias() - { - return $this->leftTableAlias; - } - - public function hasLeftTableAlias() - { - return null !== $this->leftTableAlias; - } + public function setRelationMap(RelationMap $relationMap, $leftTableAlias = null, $relationAlias = null) + { + $leftCols = $relationMap->getLeftColumns(); + $rightCols = $relationMap->getRightColumns(); + $nbColumns = $relationMap->countColumnMappings(); + for ($i = 0; $i < $nbColumns; $i++) { + $this->addExplicitCondition( + $leftCols[$i]->getTableName(), $leftCols[$i]->getName(), $leftTableAlias, + $rightCols[$i]->getTableName(), $rightCols[$i]->getName(), $relationAlias, + Criteria::EQUAL); + } + $this->relationMap = $relationMap; - public function setRelationAlias($relationAlias) - { - $this->relationAlias = $relationAlias; - - return $this; - } - - public function getRelationAlias() - { - return $this->relationAlias; - } - - public function hasRelationAlias() - { - return null !== $this->relationAlias; - } + return $this; + } - /** - * This method returns the last related, but already hydrated object up until this join - * Starting from $startObject and continuously calling the getters to get - * to the base object for the current join. - * - * This method only works if PreviousJoin has been defined, - * which only happens when you provide dotted relations when calling join - * - * @param Object $startObject the start object all joins originate from and which has already hydrated - * @return Object the base Object of this join - */ - public function getObjectToRelate($startObject) - { - if($this->isPrimary()) { - return $startObject; - } else { - $previousJoin = $this->getPreviousJoin(); - $previousObject = $previousJoin->getObjectToRelate($startObject); - $method = 'get' . $previousJoin->getRelationMap()->getName(); - return $previousObject->$method(); - } - } + public function getRelationMap() + { + return $this->relationMap; + } - public function equals($join) - { - return parent::equals($join) - && $this->relationMap == $join->getRelationMap() - && $this->previousJoin == $join->getPreviousJoin() - && $this->relationAlias == $join->getRelationAlias(); - } - - public function __toString() - { - return parent::toString() - . ' tableMap: ' . ($this->tableMap ? get_class($this->tableMap) : 'null') - . ' relationMap: ' . $this->relationMap->getName() - . ' previousJoin: ' . ($this->previousJoin ? '(' . $this->previousJoin . ')' : 'null') - . ' relationAlias: ' . $this->relationAlias; - } + /** + * Sets the right tableMap for this join + * + * @param TableMap $tableMap The table map to use + * + * @return ModelJoin The current join object, for fluid interface + */ + public function setTableMap(TableMap $tableMap) + { + $this->tableMap = $tableMap; + + return $this; + } + + /** + * Gets the right tableMap for this join + * + * @return TableMap The table map + */ + public function getTableMap() + { + if (null === $this->tableMap && null !== $this->relationMap) { + $this->tableMap = $this->relationMap->getRightTable(); + } + + return $this->tableMap; + } + + /** + * @param ModelJoin $join + * + * @return ModelJoin + */ + public function setPreviousJoin(ModelJoin $join) + { + $this->previousJoin = $join; + + return $this; + } + + /** + * @return ModelJoin + */ + public function getPreviousJoin() + { + return $this->previousJoin; + } + + /** + * @return bool + */ + public function isPrimary() + { + return null === $this->previousJoin; + } + + public function setRelationAlias($relationAlias) + { + return $this->setRightTableAlias($relationAlias); + } + + public function getRelationAlias() + { + return $this->getRightTableAlias(); + } + + public function hasRelationAlias() + { + return $this->hasRightTableAlias(); + } + + /** + * This method returns the last related, but already hydrated object up until this join + * Starting from $startObject and continuously calling the getters to get + * to the base object for the current join. + * + * This method only works if PreviousJoin has been defined, + * which only happens when you provide dotted relations when calling join + * + * @param Object $startObject the start object all joins originate from and which has already hydrated + * + * @return Object the base Object of this join + */ + public function getObjectToRelate($startObject) + { + if ($this->isPrimary()) { + return $startObject; + } else { + $previousJoin = $this->getPreviousJoin(); + $previousObject = $previousJoin->getObjectToRelate($startObject); + $method = 'get' . $previousJoin->getRelationMap()->getName(); + + return $previousObject->$method(); + } + } + + /** + * @param ModelJoin $join + * + * @return bool + */ + public function equals($join) + { + return parent::equals($join) + && $this->relationMap == $join->getRelationMap() + && $this->previousJoin == $join->getPreviousJoin() + && $this->rightTableAlias == $join->getRightTableAlias(); + } + + public function __toString() + { + return parent::toString() + . ' tableMap: ' . ($this->tableMap ? get_class($this->tableMap) : 'null') + . ' relationMap: ' . $this->relationMap->getName() + . ' previousJoin: ' . ($this->previousJoin ? '(' . $this->previousJoin . ')' : 'null') + . ' relationAlias: ' . $this->rightTableAlias; + } } - \ No newline at end of file diff --git a/airtime_mvc/library/propel/runtime/lib/query/PropelQuery.php b/airtime_mvc/library/propel/runtime/lib/query/PropelQuery.php index 18f93c9b9..37ec96e8f 100644 --- a/airtime_mvc/library/propel/runtime/lib/query/PropelQuery.php +++ b/airtime_mvc/library/propel/runtime/lib/query/PropelQuery.php @@ -10,24 +10,31 @@ /** * Factory for model queries - * + * * @author François Zaninotto - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.query */ class PropelQuery { - public static function from($queryClassAndAlias) - { - list($class, $alias) = ModelCriteria::getClassAndAlias($queryClassAndAlias); - $queryClass = $class . 'Query'; - if (!class_exists($queryClass)) { - throw new PropelException('Cannot find a query class for ' . $class); - } - $query = new $queryClass(); - if ($alias !== null) { - $query->setModelAlias($alias); - } - return $query; - } + /** + * @param string $queryClassAndAlias + * + * @return ModelCriteria + * @throws PropelException + */ + public static function from($queryClassAndAlias) + { + list($class, $alias) = ModelCriteria::getClassAndAlias($queryClassAndAlias); + $queryClass = $class . 'Query'; + if (!class_exists($queryClass)) { + throw new PropelException('Cannot find a query class for ' . $class); + } + $query = new $queryClass(); + if ($alias !== null) { + $query->setModelAlias($alias); + } + + return $query; + } } diff --git a/airtime_mvc/library/propel/runtime/lib/util/BasePeer.php b/airtime_mvc/library/propel/runtime/lib/util/BasePeer.php index 0e6c91254..8b71b88ee 100644 --- a/airtime_mvc/library/propel/runtime/lib/util/BasePeer.php +++ b/airtime_mvc/library/propel/runtime/lib/util/BasePeer.php @@ -24,1076 +24,880 @@ * @author John D. McNally (Torque) * @author Brett McLaughlin (Torque) * @author Stephen Haberman (Torque) - * @version $Revision: 1772 $ + * @version $Revision$ * @package propel.runtime.util */ class BasePeer { - /** Array (hash) that contains the cached mapBuilders. */ - private static $mapBuilders = array(); - - /** Array (hash) that contains cached validators */ - private static $validatorMap = array(); - - /** - * phpname type - * e.g. 'AuthorId' - */ - const TYPE_PHPNAME = 'phpName'; - - /** - * studlyphpname type - * e.g. 'authorId' - */ - const TYPE_STUDLYPHPNAME = 'studlyPhpName'; - - /** - * column (peer) name type - * e.g. 'book.AUTHOR_ID' - */ - const TYPE_COLNAME = 'colName'; - - /** - * column part of the column peer name - * e.g. 'AUTHOR_ID' - */ - const TYPE_RAW_COLNAME = 'rawColName'; - - /** - * column fieldname type - * e.g. 'author_id' - */ - const TYPE_FIELDNAME = 'fieldName'; - - /** - * num type - * simply the numerical array index, e.g. 4 - */ - const TYPE_NUM = 'num'; - - static public function getFieldnames ($classname, $type = self::TYPE_PHPNAME) { - - // TODO we should take care of including the peer class here - - $peerclass = 'Base' . $classname . 'Peer'; // TODO is this always true? - $callable = array($peerclass, 'getFieldnames'); - - return call_user_func($callable, $type); - } - - static public function translateFieldname($classname, $fieldname, $fromType, $toType) { - - // TODO we should take care of including the peer class here - - $peerclass = 'Base' . $classname . 'Peer'; // TODO is this always true? - $callable = array($peerclass, 'translateFieldname'); - $args = array($fieldname, $fromType, $toType); - - return call_user_func_array($callable, $args); - } - - /** - * Method to perform deletes based on values and keys in a - * Criteria. - * - * @param Criteria $criteria The criteria to use. - * @param PropelPDO $con A PropelPDO connection object. - * @return int The number of rows affected by last statement execution. For most - * uses there is only one delete statement executed, so this number - * will correspond to the number of rows affected by the call to this - * method. Note that the return value does require that this information - * is returned (supported) by the PDO driver. - * @throws PropelException - */ - public static function doDelete(Criteria $criteria, PropelPDO $con) - { - $db = Propel::getDB($criteria->getDbName()); - $dbMap = Propel::getDatabaseMap($criteria->getDbName()); - - // Set up a list of required tables (one DELETE statement will - // be executed per table) - $tables = $criteria->getTablesColumns(); - if (empty($tables)) { - throw new PropelException("Cannot delete from an empty Criteria"); - } - - $affectedRows = 0; // initialize this in case the next loop has no iterations. - - foreach ($tables as $tableName => $columns) { - - $whereClause = array(); - $params = array(); - $stmt = null; - try { - $sql = 'DELETE '; - if ($queryComment = $criteria->getComment()) { - $sql .= '/* ' . $queryComment . ' */ '; - } - if ($realTableName = $criteria->getTableForAlias($tableName)) { - if ($db->useQuoteIdentifier()) { - $realTableName = $db->quoteIdentifierTable($realTableName); - } - $sql .= $tableName . ' FROM ' . $realTableName . ' AS ' . $tableName; - } else { - if ($db->useQuoteIdentifier()) { - $tableName = $db->quoteIdentifierTable($tableName); - } - $sql .= 'FROM ' . $tableName; - } - - foreach ($columns as $colName) { - $sb = ""; - $criteria->getCriterion($colName)->appendPsTo($sb, $params); - $whereClause[] = $sb; - } - $sql .= " WHERE " . implode(" AND ", $whereClause); - - $stmt = $con->prepare($sql); - self::populateStmtValues($stmt, $params, $dbMap, $db); - $stmt->execute(); - $affectedRows = $stmt->rowCount(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute DELETE statement [%s]', $sql), $e); - } - - } // for each table - - return $affectedRows; - } - - /** - * Method to deletes all contents of specified table. - * - * This method is invoked from generated Peer classes like this: - * - * public static function doDeleteAll($con = null) - * { - * if ($con === null) $con = Propel::getConnection(self::DATABASE_NAME); - * BasePeer::doDeleteAll(self::TABLE_NAME, $con, self::DATABASE_NAME); - * } - * - * - * @param string $tableName The name of the table to empty. - * @param PropelPDO $con A PropelPDO connection object. - * @param string $databaseName the name of the database. - * @return int The number of rows affected by the statement. Note - * that the return value does require that this information - * is returned (supported) by the Propel db driver. - * @throws PropelException - wrapping SQLException caught from statement execution. - */ - public static function doDeleteAll($tableName, PropelPDO $con, $databaseName = null) - { - try { - $db = Propel::getDB($databaseName); - if ($db->useQuoteIdentifier()) { - $tableName = $db->quoteIdentifierTable($tableName); - } - $sql = "DELETE FROM " . $tableName; - $stmt = $con->prepare($sql); - $stmt->execute(); - return $stmt->rowCount(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute DELETE ALL statement [%s]', $sql), $e); - } - } - - /** - * Method to perform inserts based on values and keys in a - * Criteria. - *

- * If the primary key is auto incremented the data in Criteria - * will be inserted and the auto increment value will be returned. - *

- * If the primary key is included in Criteria then that value will - * be used to insert the row. - *

- * If no primary key is included in Criteria then we will try to - * figure out the primary key from the database map and insert the - * row with the next available id using util.db.IDBroker. - *

- * If no primary key is defined for the table the values will be - * inserted as specified in Criteria and null will be returned. - * - * @param Criteria $criteria Object containing values to insert. - * @param PropelPDO $con A PropelPDO connection. - * @return mixed The primary key for the new row if (and only if!) the primary key - * is auto-generated. Otherwise will return null. - * @throws PropelException - */ - public static function doInsert(Criteria $criteria, PropelPDO $con) { - - // the primary key - $id = null; - - $db = Propel::getDB($criteria->getDbName()); - - // Get the table name and method for determining the primary - // key value. - $keys = $criteria->keys(); - if (!empty($keys)) { - $tableName = $criteria->getTableName( $keys[0] ); - } else { - throw new PropelException("Database insert attempted without anything specified to insert"); - } - - $dbMap = Propel::getDatabaseMap($criteria->getDbName()); - $tableMap = $dbMap->getTable($tableName); - $keyInfo = $tableMap->getPrimaryKeyMethodInfo(); - $useIdGen = $tableMap->isUseIdGenerator(); - //$keyGen = $con->getIdGenerator(); - - $pk = self::getPrimaryKey($criteria); - - // only get a new key value if you need to - // the reason is that a primary key might be defined - // but you are still going to set its value. for example: - // a join table where both keys are primary and you are - // setting both columns with your own values - - // pk will be null if there is no primary key defined for the table - // we're inserting into. - if ($pk !== null && $useIdGen && !$criteria->keyContainsValue($pk->getFullyQualifiedName()) && $db->isGetIdBeforeInsert()) { - try { - $id = $db->getId($con, $keyInfo); - } catch (Exception $e) { - throw new PropelException("Unable to get sequence id.", $e); - } - $criteria->add($pk->getFullyQualifiedName(), $id); - } - - try { - $adapter = Propel::getDB($criteria->getDBName()); - - $qualifiedCols = $criteria->keys(); // we need table.column cols when populating values - $columns = array(); // but just 'column' cols for the SQL - foreach ($qualifiedCols as $qualifiedCol) { - $columns[] = substr($qualifiedCol, strrpos($qualifiedCol, '.') + 1); - } - - // add identifiers - if ($adapter->useQuoteIdentifier()) { - $columns = array_map(array($adapter, 'quoteIdentifier'), $columns); - $tableName = $adapter->quoteIdentifierTable($tableName); - } - - $sql = 'INSERT INTO ' . $tableName - . ' (' . implode(',', $columns) . ')' - . ' VALUES ('; - // . substr(str_repeat("?,", count($columns)), 0, -1) . - for($p=1, $cnt=count($columns); $p <= $cnt; $p++) { - $sql .= ':p'.$p; - if ($p !== $cnt) $sql .= ','; - } - $sql .= ')'; - - $stmt = $con->prepare($sql); - self::populateStmtValues($stmt, self::buildParams($qualifiedCols, $criteria), $dbMap, $db); - $stmt->execute(); - - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - // If the primary key column is auto-incremented, get the id now. - if ($pk !== null && $useIdGen && $db->isGetIdAfterInsert()) { - try { - $id = $db->getId($con, $keyInfo); - } catch (Exception $e) { - throw new PropelException("Unable to get autoincrement id.", $e); - } - } - - return $id; - } - - /** - * Method used to update rows in the DB. Rows are selected based - * on selectCriteria and updated using values in updateValues. - *

- * Use this method for performing an update of the kind: - *

- * WHERE some_column = some value AND could_have_another_column = - * another value AND so on. - * - * @param $selectCriteria A Criteria object containing values used in where - * clause. - * @param $updateValues A Criteria object containing values used in set - * clause. - * @param PropelPDO $con The PropelPDO connection object to use. - * @return int The number of rows affected by last update statement. For most - * uses there is only one update statement executed, so this number - * will correspond to the number of rows affected by the call to this - * method. Note that the return value does require that this information - * is returned (supported) by the Propel db driver. - * @throws PropelException - */ - public static function doUpdate(Criteria $selectCriteria, Criteria $updateValues, PropelPDO $con) { - - $db = Propel::getDB($selectCriteria->getDbName()); - $dbMap = Propel::getDatabaseMap($selectCriteria->getDbName()); - - // Get list of required tables, containing all columns - $tablesColumns = $selectCriteria->getTablesColumns(); - if (empty($tablesColumns)) { - $tablesColumns = array($selectCriteria->getPrimaryTableName() => array()); - } - - // we also need the columns for the update SQL - $updateTablesColumns = $updateValues->getTablesColumns(); - - $affectedRows = 0; // initialize this in case the next loop has no iterations. - - foreach ($tablesColumns as $tableName => $columns) { - - $whereClause = array(); - $params = array(); - $stmt = null; - try { - $sql = 'UPDATE '; - if ($queryComment = $selectCriteria->getComment()) { - $sql .= '/* ' . $queryComment . ' */ '; - } - // is it a table alias? - if ($tableName2 = $selectCriteria->getTableForAlias($tableName)) { - $udpateTable = $tableName2 . ' ' . $tableName; - $tableName = $tableName2; - } else { - $udpateTable = $tableName; - } - if ($db->useQuoteIdentifier()) { - $sql .= $db->quoteIdentifierTable($udpateTable); - } else { - $sql .= $udpateTable; - } - $sql .= " SET "; - $p = 1; - foreach ($updateTablesColumns[$tableName] as $col) { - $updateColumnName = substr($col, strrpos($col, '.') + 1); - // add identifiers for the actual database? - if ($db->useQuoteIdentifier()) { - $updateColumnName = $db->quoteIdentifier($updateColumnName); - } - if ($updateValues->getComparison($col) != Criteria::CUSTOM_EQUAL) { - $sql .= $updateColumnName . '=:p'.$p++.', '; - } else { - $param = $updateValues->get($col); - $sql .= $updateColumnName . ' = '; - if (is_array($param)) { - if (isset($param['raw'])) { - $raw = $param['raw']; - $rawcvt = ''; - // parse the $params['raw'] for ? chars - for($r=0,$len=strlen($raw); $r < $len; $r++) { - if ($raw{$r} == '?') { - $rawcvt .= ':p'.$p++; - } else { - $rawcvt .= $raw{$r}; - } - } - $sql .= $rawcvt . ', '; - } else { - $sql .= ':p'.$p++.', '; - } - if (isset($param['value'])) { - $updateValues->put($col, $param['value']); - } - } else { - $updateValues->remove($col); - $sql .= $param . ', '; - } - } - } - - $params = self::buildParams($updateTablesColumns[$tableName], $updateValues); - - $sql = substr($sql, 0, -2); - if (!empty($columns)) { - foreach ($columns as $colName) { - $sb = ""; - $selectCriteria->getCriterion($colName)->appendPsTo($sb, $params); - $whereClause[] = $sb; - } - $sql .= " WHERE " . implode(" AND ", $whereClause); - } - - $stmt = $con->prepare($sql); - - // Replace ':p?' with the actual values - self::populateStmtValues($stmt, $params, $dbMap, $db); - - $stmt->execute(); - - $affectedRows = $stmt->rowCount(); - - $stmt = null; // close - - } catch (Exception $e) { - if ($stmt) $stmt = null; // close - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute UPDATE statement [%s]', $sql), $e); - } - - } // foreach table in the criteria - - return $affectedRows; - } - - /** - * Executes query build by createSelectSql() and returns the resultset statement. - * - * @param Criteria $criteria A Criteria. - * @param PropelPDO $con A PropelPDO connection to use. - * @return PDOStatement The resultset. - * @throws PropelException - * @see createSelectSql() - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - $dbMap = Propel::getDatabaseMap($criteria->getDbName()); - $db = Propel::getDB($criteria->getDbName()); - $stmt = null; - - if ($con === null) { - $con = Propel::getConnection($criteria->getDbName(), Propel::CONNECTION_READ); - } - - if ($criteria->isUseTransaction()) { - $con->beginTransaction(); - } - - try { - - $params = array(); - $sql = self::createSelectSql($criteria, $params); - - $stmt = $con->prepare($sql); - - self::populateStmtValues($stmt, $params, $dbMap, $db); - - $stmt->execute(); - - if ($criteria->isUseTransaction()) { - $con->commit(); - } - - } catch (Exception $e) { - if ($stmt) { - $stmt = null; // close - } - if ($criteria->isUseTransaction()) { - $con->rollBack(); - } - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - - return $stmt; - } - - /** - * Executes a COUNT query using either a simple SQL rewrite or, for more complex queries, a - * sub-select of the SQL created by createSelectSql() and returns the statement. - * - * @param Criteria $criteria A Criteria. - * @param PropelPDO $con A PropelPDO connection to use. - * @return PDOStatement The resultset statement. - * @throws PropelException - * @see createSelectSql() - */ - public static function doCount(Criteria $criteria, PropelPDO $con = null) - { - $dbMap = Propel::getDatabaseMap($criteria->getDbName()); - $db = Propel::getDB($criteria->getDbName()); - - if ($con === null) { - $con = Propel::getConnection($criteria->getDbName(), Propel::CONNECTION_READ); - } - - $stmt = null; - - if ($criteria->isUseTransaction()) { - $con->beginTransaction(); - } - - $needsComplexCount = $criteria->getGroupByColumns() - || $criteria->getOffset() - || $criteria->getLimit() - || $criteria->getHaving() - || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers()); - - try { - - $params = array(); - - if ($needsComplexCount) { - if (self::needsSelectAliases($criteria)) { - if ($criteria->getHaving()) { - throw new PropelException('Propel cannot create a COUNT query when using HAVING and duplicate column names in the SELECT part'); - } - self::turnSelectColumnsToAliases($criteria); - } - $selectSql = self::createSelectSql($criteria, $params); - $sql = 'SELECT COUNT(*) FROM (' . $selectSql . ') propelmatch4cnt'; - } else { - // Replace SELECT columns with COUNT(*) - $criteria->clearSelectColumns()->addSelectColumn('COUNT(*)'); - $sql = self::createSelectSql($criteria, $params); - } - - $stmt = $con->prepare($sql); - self::populateStmtValues($stmt, $params, $dbMap, $db); - $stmt->execute(); - - if ($criteria->isUseTransaction()) { - $con->commit(); - } - - } catch (Exception $e) { - if ($stmt !== null) { - $stmt = null; - } - if ($criteria->isUseTransaction()) { - $con->rollBack(); - } - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute COUNT statement [%s]', $sql), $e); - } - - return $stmt; - } - - /** - * Populates values in a prepared statement. - * - * This method is designed to work with the createSelectSql() method, which creates - * both the SELECT SQL statement and populates a passed-in array of parameter - * values that should be substituted. - * - * - * $params = array(); - * $sql = BasePeer::createSelectSql($criteria, $params); - * BasePeer::populateStmtValues($stmt, $params, Propel::getDatabaseMap($critera->getDbName()), Propel::getDB($criteria->getDbName())); - * - * - * @param PDOStatement $stmt - * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) - * @param DatabaseMap $dbMap - * @return int The number of params replaced. - * @see createSelectSql() - * @see doSelect() - */ - public static function populateStmtValues(PDOStatement $stmt, array $params, DatabaseMap $dbMap, DBAdapter $db) - { - $i = 1; - foreach ($params as $param) { - $tableName = $param['table']; - $columnName = $param['column']; - $value = $param['value']; - - if (null === $value) { - - $stmt->bindValue(':p'.$i++, null, PDO::PARAM_NULL); - - } elseif (null !== $tableName) { - - $cMap = $dbMap->getTable($tableName)->getColumn($columnName); - $type = $cMap->getType(); - $pdoType = $cMap->getPdoType(); - - // FIXME - This is a temporary hack to get around apparent bugs w/ PDO+MYSQL - // See http://pecl.php.net/bugs/bug.php?id=9919 - if ($pdoType == PDO::PARAM_BOOL && $db instanceof DBMySQL) { - $value = (int) $value; - $pdoType = PDO::PARAM_INT; - } elseif (is_numeric($value) && $cMap->isEpochTemporal()) { // it's a timestamp that needs to be formatted - if ($type == PropelColumnTypes::TIMESTAMP) { - $value = date($db->getTimestampFormatter(), $value); - } else if ($type == PropelColumnTypes::DATE) { - $value = date($db->getDateFormatter(), $value); - } else if ($type == PropelColumnTypes::TIME) { - $value = date($db->getTimeFormatter(), $value); - } - } elseif ($value instanceof DateTime && $cMap->isTemporal()) { // it's a timestamp that needs to be formatted - if ($type == PropelColumnTypes::TIMESTAMP || $type == PropelColumnTypes::BU_TIMESTAMP) { - $value = $value->format($db->getTimestampFormatter()); - } else if ($type == PropelColumnTypes::DATE || $type == PropelColumnTypes::BU_DATE) { - $value = $value->format($db->getDateFormatter()); - } else if ($type == PropelColumnTypes::TIME) { - $value = $value->format($db->getTimeFormatter()); - } - } elseif (is_resource($value) && $cMap->isLob()) { - // we always need to make sure that the stream is rewound, otherwise nothing will - // get written to database. - rewind($value); - } - - $stmt->bindValue(':p'.$i++, $value, $pdoType); - } else { - $stmt->bindValue(':p'.$i++, $value); - } - } // foreach - } - - /** - * Applies any validators that were defined in the schema to the specified columns. - * - * @param string $dbName The name of the database - * @param string $tableName The name of the table - * @param array $columns Array of column names as key and column values as value. - */ - public static function doValidate($dbName, $tableName, $columns) - { - $dbMap = Propel::getDatabaseMap($dbName); - $tableMap = $dbMap->getTable($tableName); - $failureMap = array(); // map of ValidationFailed objects - foreach ($columns as $colName => $colValue) { - if ($tableMap->containsColumn($colName)) { - $col = $tableMap->getColumn($colName); - foreach ($col->getValidators() as $validatorMap) { - $validator = BasePeer::getValidator($validatorMap->getClass()); - if ($validator && ($col->isNotNull() || $colValue !== null) && $validator->isValid($validatorMap, $colValue) === false) { - if (!isset($failureMap[$colName])) { // for now we do one ValidationFailed per column, not per rule - $failureMap[$colName] = new ValidationFailed($colName, $validatorMap->getMessage(), $validator); - } - } - } - } - } - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Helper method which returns the primary key contained - * in the given Criteria object. - * - * @param Criteria $criteria A Criteria. - * @return ColumnMap If the Criteria object contains a primary - * key, or null if it doesn't. - * @throws PropelException - */ - private static function getPrimaryKey(Criteria $criteria) - { - // Assume all the keys are for the same table. - $keys = $criteria->keys(); - $key = $keys[0]; - $table = $criteria->getTableName($key); - - $pk = null; - - if (!empty($table)) { - - $dbMap = Propel::getDatabaseMap($criteria->getDbName()); - - $pks = $dbMap->getTable($table)->getPrimaryKeys(); - if (!empty($pks)) { - $pk = array_shift($pks); - } - } - return $pk; - } - - /** - * Checks whether the Criteria needs to use column aliasing - * This is implemented in a service class rather than in Criteria itself - * in order to avoid doing the tests when it's not necessary (e.g. for SELECTs) - */ - public static function needsSelectAliases(Criteria $criteria) - { - $columnNames = array(); - foreach ($criteria->getSelectColumns() as $fullyQualifiedColumnName) { - if ($pos = strrpos($fullyQualifiedColumnName, '.')) { - $columnName = substr($fullyQualifiedColumnName, $pos); - if (isset($columnNames[$columnName])) { - // more than one column with the same name, so aliasing is required - return true; - } - $columnNames[$columnName] = true; - } - } - return false; - } - - /** - * Ensures uniqueness of select column names by turning them all into aliases - * This is necessary for queries on more than one table when the tables share a column name - * @see http://propel.phpdb.org/trac/ticket/795 - * - * @param Criteria $criteria - * - * @return Criteria The input, with Select columns replaced by aliases - */ - public static function turnSelectColumnsToAliases(Criteria $criteria) - { - $selectColumns = $criteria->getSelectColumns(); - // clearSelectColumns also clears the aliases, so get them too - $asColumns = $criteria->getAsColumns(); - $criteria->clearSelectColumns(); - $columnAliases = $asColumns; - // add the select columns back - foreach ($selectColumns as $clause) { - // Generate a unique alias - $baseAlias = preg_replace('/\W/', '_', $clause); - $alias = $baseAlias; - // If it already exists, add a unique suffix - $i = 0; - while (isset($columnAliases[$alias])) { - $i++; - $alias = $baseAlias . '_' . $i; - } - // Add it as an alias - $criteria->addAsColumn($alias, $clause); - $columnAliases[$alias] = $clause; - } - // Add the aliases back, don't modify them - foreach ($asColumns as $name => $clause) { - $criteria->addAsColumn($name, $clause); - } - - return $criteria; - } - - /** - * Method to create an SQL query based on values in a Criteria. - * - * This method creates only prepared statement SQL (using ? where values - * will go). The second parameter ($params) stores the values that need - * to be set before the statement is executed. The reason we do it this way - * is to let the PDO layer handle all escaping & value formatting. - * - * @param Criteria $criteria Criteria for the SELECT query. - * @param array &$params Parameters that are to be replaced in prepared statement. - * @return string - * @throws PropelException Trouble creating the query string. - */ - public static function createSelectSql(Criteria $criteria, &$params) - { - $db = Propel::getDB($criteria->getDbName()); - $dbMap = Propel::getDatabaseMap($criteria->getDbName()); - - $fromClause = array(); - $joinClause = array(); - $joinTables = array(); - $whereClause = array(); - $orderByClause = array(); - - $orderBy = $criteria->getOrderByColumns(); - $groupBy = $criteria->getGroupByColumns(); - $ignoreCase = $criteria->isIgnoreCase(); - - // get the first part of the SQL statement, the SELECT part - $selectSql = self::createSelectSqlPart($criteria, $fromClause); - - // add the criteria to WHERE clause - // this will also add the table names to the FROM clause if they are not already - // included via a LEFT JOIN - foreach ($criteria->keys() as $key) { - - $criterion = $criteria->getCriterion($key); - $table = null; - foreach ($criterion->getAttachedCriterion() as $attachedCriterion) { - $tableName = $attachedCriterion->getTable(); - - $table = $criteria->getTableForAlias($tableName); - if ($table !== null) { - $fromClause[] = $table . ' ' . $tableName; - } else { - $fromClause[] = $tableName; - $table = $tableName; - } - - if (($criteria->isIgnoreCase() || $attachedCriterion->isIgnoreCase()) - && $dbMap->getTable($table)->getColumn($attachedCriterion->getColumn())->isText()) { - $attachedCriterion->setIgnoreCase(true); - } - } - - $criterion->setDB($db); - - $sb = ''; - $criterion->appendPsTo($sb, $params); - $whereClause[] = $sb; - } - - // Handle joins - // joins with a null join type will be added to the FROM clause and the condition added to the WHERE clause. - // joins of a specified type: the LEFT side will be added to the fromClause and the RIGHT to the joinClause - foreach ($criteria->getJoins() as $join) { - // The join might have been established using an alias name - $leftTable = $join->getLeftTableName(); - if ($realTable = $criteria->getTableForAlias($leftTable)) { - $leftTableForFrom = $realTable . ' ' . $leftTable; - $leftTable = $realTable; - } else { - $leftTableForFrom = $leftTable; - } - - $rightTable = $join->getRightTableName(); - if ($realTable = $criteria->getTableForAlias($rightTable)) { - $rightTableForFrom = $realTable . ' ' . $rightTable; - $rightTable = $realTable; - } else { - $rightTableForFrom = $rightTable; - } - - // determine if casing is relevant. - if ($ignoreCase = $criteria->isIgnoreCase()) { - $leftColType = $dbMap->getTable($leftTable)->getColumn($join->getLeftColumnName())->getType(); - $rightColType = $dbMap->getTable($rightTable)->getColumn($join->getRightColumnName())->getType(); - $ignoreCase = ($leftColType == 'string' || $rightColType == 'string'); - } - - // build the condition - $condition = ''; - foreach ($join->getConditions() as $index => $conditionDesc) { - if ($ignoreCase) { - $condition .= $db->ignoreCase($conditionDesc['left']) . $conditionDesc['operator'] . $db->ignoreCase($conditionDesc['right']); - } else { - $condition .= implode($conditionDesc); - } - if ($index + 1 < $join->countConditions()) { - $condition .= ' AND '; - } - } - - // add 'em to the queues.. - if ($joinType = $join->getJoinType()) { - // real join - if (!$fromClause) { - $fromClause[] = $leftTableForFrom; - } - $joinTables[] = $rightTableForFrom; - $joinClause[] = $join->getJoinType() . ' ' . $rightTableForFrom . " ON ($condition)"; - } else { - // implicit join, translates to a where - $fromClause[] = $leftTableForFrom; - $fromClause[] = $rightTableForFrom; - $whereClause[] = $condition; - } - } - - // Unique from clause elements - $fromClause = array_unique($fromClause); - $fromClause = array_diff($fromClause, array('')); - - // tables should not exist in both the from and join clauses - if ($joinTables && $fromClause) { - foreach ($fromClause as $fi => $ftable) { - if (in_array($ftable, $joinTables)) { - unset($fromClause[$fi]); - } - } - } - - // Add the GROUP BY columns - $groupByClause = $groupBy; - - $having = $criteria->getHaving(); - $havingString = null; - if ($having !== null) { - $sb = ''; - $having->appendPsTo($sb, $params); - $havingString = $sb; - } - - if (!empty($orderBy)) { - - foreach ($orderBy as $orderByColumn) { - - // Add function expression as-is. - - if (strpos($orderByColumn, '(') !== false) { - $orderByClause[] = $orderByColumn; - continue; - } - - // Split orderByColumn (i.e. "table.column DESC") - - $dotPos = strrpos($orderByColumn, '.'); - - if ($dotPos !== false) { - $tableName = substr($orderByColumn, 0, $dotPos); - $columnName = substr($orderByColumn, $dotPos + 1); - } else { - $tableName = ''; - $columnName = $orderByColumn; - } - - $spacePos = strpos($columnName, ' '); - - if ($spacePos !== false) { - $direction = substr($columnName, $spacePos); - $columnName = substr($columnName, 0, $spacePos); - } else { - $direction = ''; - } - - $tableAlias = $tableName; - if ($aliasTableName = $criteria->getTableForAlias($tableName)) { - $tableName = $aliasTableName; - } - - $columnAlias = $columnName; - if ($asColumnName = $criteria->getColumnForAs($columnName)) { - $columnName = $asColumnName; - } - - $column = $tableName ? $dbMap->getTable($tableName)->getColumn($columnName) : null; - - if ($criteria->isIgnoreCase() && $column && $column->isText()) { - $ignoreCaseColumn = $db->ignoreCaseInOrderBy("$tableAlias.$columnAlias"); - $orderByClause[] = $ignoreCaseColumn . $direction; - $selectSql .= ', ' . $ignoreCaseColumn; - } else { - $orderByClause[] = $orderByColumn; - } - } - } - - if (empty($fromClause) && $criteria->getPrimaryTableName()) { - $fromClause[] = $criteria->getPrimaryTableName(); - } - - // from / join tables quoted if it is necessary - if ($db->useQuoteIdentifier()) { - $fromClause = array_map(array($db, 'quoteIdentifierTable'), $fromClause); - $joinClause = $joinClause ? $joinClause : array_map(array($db, 'quoteIdentifierTable'), $joinClause); - } - - // build from-clause - $from = ''; - if (!empty($joinClause) && count($fromClause) > 1) { - $from .= implode(" CROSS JOIN ", $fromClause); - } else { - $from .= implode(", ", $fromClause); - } - - $from .= $joinClause ? ' ' . implode(' ', $joinClause) : ''; - - // Build the SQL from the arrays we compiled - $sql = $selectSql - ." FROM " . $from - .($whereClause ? " WHERE ".implode(" AND ", $whereClause) : "") - .($groupByClause ? " GROUP BY ".implode(",", $groupByClause) : "") - .($havingString ? " HAVING ".$havingString : "") - .($orderByClause ? " ORDER BY ".implode(",", $orderByClause) : ""); - - // APPLY OFFSET & LIMIT to the query. - if ($criteria->getLimit() || $criteria->getOffset()) { - $db->applyLimit($sql, $criteria->getOffset(), $criteria->getLimit(), $criteria); - } - - return $sql; - } - - /** - * Builds the SELECT part of a SQL statement based on a Criteria - * taking into account select columns and 'as' columns (i.e. columns aliases) - */ - public static function createSelectSqlPart(Criteria $criteria, &$fromClause, $aliasAll = false) - { - $selectClause = array(); - - if ($aliasAll) { - self::turnSelectColumnsToAliases($criteria); - // no select columns after that, they are all aliases - } else { - foreach ($criteria->getSelectColumns() as $columnName) { - - // expect every column to be of "table.column" formation - // it could be a function: e.g. MAX(books.price) - - $tableName = null; - - $selectClause[] = $columnName; // the full column name: e.g. MAX(books.price) - - $parenPos = strrpos($columnName, '('); - $dotPos = strrpos($columnName, '.', ($parenPos !== false ? $parenPos : 0)); - - if ($dotPos !== false) { - if ($parenPos === false) { // table.column - $tableName = substr($columnName, 0, $dotPos); - } else { // FUNC(table.column) - // functions may contain qualifiers so only take the last - // word as the table name. - // COUNT(DISTINCT books.price) - $lastSpace = strpos($tableName, ' '); - if ($lastSpace !== false) { // COUNT(DISTINCT books.price) - $tableName = substr($tableName, $lastSpace + 1); - } else { - $tableName = substr($columnName, $parenPos + 1, $dotPos - ($parenPos + 1)); - } - } - // is it a table alias? - $tableName2 = $criteria->getTableForAlias($tableName); - if ($tableName2 !== null) { - $fromClause[] = $tableName2 . ' ' . $tableName; - } else { - $fromClause[] = $tableName; - } - } // if $dotPost !== false - } - } - - // set the aliases - foreach ($criteria->getAsColumns() as $alias => $col) { - $selectClause[] = $col . ' AS ' . $alias; - } - - $selectModifiers = $criteria->getSelectModifiers(); - $queryComment = $criteria->getComment(); - - // Build the SQL from the arrays we compiled - $sql = "SELECT " - . ($queryComment ? '/* ' . $queryComment . ' */ ' : '') - . ($selectModifiers ? (implode(' ', $selectModifiers) . ' ') : '') - . implode(", ", $selectClause); - - return $sql; - } - - /** - * Builds a params array, like the kind populated by Criterion::appendPsTo(). - * This is useful for building an array even when it is not using the appendPsTo() method. - * @param array $columns - * @param Criteria $values - * @return array params array('column' => ..., 'table' => ..., 'value' => ...) - */ - private static function buildParams($columns, Criteria $values) - { - $params = array(); - foreach ($columns as $key) { - if ($values->containsKey($key)) { - $crit = $values->getCriterion($key); - $params[] = array('column' => $crit->getColumn(), 'table' => $crit->getTable(), 'value' => $crit->getValue()); - } - } - return $params; - } - - /** - * This function searches for the given validator $name under propel/validator/$name.php, - * imports and caches it. - * - * @param string $classname The dot-path name of class (e.g. myapp.propel.MyValidator) - * @return Validator object or null if not able to instantiate validator class (and error will be logged in this case) - */ - public static function getValidator($classname) - { - try { - $v = isset(self::$validatorMap[$classname]) ? self::$validatorMap[$classname] : null; - if ($v === null) { - $cls = Propel::importClass($classname); - $v = new $cls(); - self::$validatorMap[$classname] = $v; - } - return $v; - } catch (Exception $e) { - Propel::log("BasePeer::getValidator(): failed trying to instantiate " . $classname . ": ".$e->getMessage(), Propel::LOG_ERR); - } - } - + /** Array (hash) that contains the cached mapBuilders. */ + private static $mapBuilders = array(); + + /** Array (hash) that contains cached validators */ + private static $validatorMap = array(); + + /** + * phpname type + * e.g. 'AuthorId' + */ + const TYPE_PHPNAME = 'phpName'; + + /** + * studlyphpname type + * e.g. 'authorId' + */ + const TYPE_STUDLYPHPNAME = 'studlyPhpName'; + + /** + * column (peer) name type + * e.g. 'book.AUTHOR_ID' + */ + const TYPE_COLNAME = 'colName'; + + /** + * column part of the column peer name + * e.g. 'AUTHOR_ID' + */ + const TYPE_RAW_COLNAME = 'rawColName'; + + /** + * column fieldname type + * e.g. 'author_id' + */ + const TYPE_FIELDNAME = 'fieldName'; + + /** + * num type + * simply the numerical array index, e.g. 4 + */ + const TYPE_NUM = 'num'; + + public static function getFieldnames($classname, $type = self::TYPE_PHPNAME) + { + // TODO we should take care of including the peer class here + + $peerclass = 'Base' . $classname . 'Peer'; // TODO is this always true? + $callable = array($peerclass, 'getFieldnames'); + + return call_user_func($callable, $type); + } + + public static function translateFieldname($classname, $fieldname, $fromType, $toType) + { + // TODO we should take care of including the peer class here + + $peerclass = 'Base' . $classname . 'Peer'; // TODO is this always true? + $callable = array($peerclass, 'translateFieldname'); + $args = array($fieldname, $fromType, $toType); + + return call_user_func_array($callable, $args); + } + + /** + * Method to perform deletes based on values and keys in a + * Criteria. + * + * @param Criteria $criteria The criteria to use. + * @param PropelPDO $con A PropelPDO connection object. + * + * @return int The number of rows affected by last statement execution. For most + * uses there is only one delete statement executed, so this number + * will correspond to the number of rows affected by the call to this + * method. Note that the return value does require that this information + * is returned (supported) by the PDO driver. + * @throws PropelException + */ + public static function doDelete(Criteria $criteria, PropelPDO $con) + { + $db = Propel::getDB($criteria->getDbName()); + $dbMap = Propel::getDatabaseMap($criteria->getDbName()); + + //join are not supported with DELETE statement + if (count($criteria->getJoins())) { + throw new PropelException('Delete does not support join'); + } + + // Set up a list of required tables (one DELETE statement will + // be executed per table) + $tables = $criteria->getTablesColumns(); + if (empty($tables)) { + throw new PropelException("Cannot delete from an empty Criteria"); + } + + $affectedRows = 0; // initialize this in case the next loop has no iterations. + + foreach ($tables as $tableName => $columns) { + + $whereClause = array(); + $params = array(); + $stmt = null; + try { + $sql = $db->getDeleteFromClause($criteria, $tableName); + + foreach ($columns as $colName) { + $sb = ""; + $criteria->getCriterion($colName)->appendPsTo($sb, $params); + $whereClause[] = $sb; + } + $sql .= " WHERE " . implode(" AND ", $whereClause); + + $stmt = $con->prepare($sql); + $db->bindValues($stmt, $params, $dbMap); + $stmt->execute(); + $affectedRows = $stmt->rowCount(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute DELETE statement [%s]', $sql), $e); + } + } // for each table + + return $affectedRows; + } + + /** + * Method to deletes all contents of specified table. + * + * This method is invoked from generated Peer classes like this: + * + * public static function doDeleteAll($con = null) + * { + * if ($con === null) $con = Propel::getConnection(self::DATABASE_NAME); + * BasePeer::doDeleteAll(self::TABLE_NAME, $con, self::DATABASE_NAME); + * } + * + * + * @param string $tableName The name of the table to empty. + * @param PropelPDO $con A PropelPDO connection object. + * @param string $databaseName the name of the database. + * + * @return int The number of rows affected by the statement. Note + * that the return value does require that this information + * is returned (supported) by the Propel db driver. + * @throws PropelException - wrapping SQLException caught from statement execution. + */ + public static function doDeleteAll($tableName, PropelPDO $con, $databaseName = null) + { + try { + $db = Propel::getDB($databaseName); + if ($db->useQuoteIdentifier()) { + $tableName = $db->quoteIdentifierTable($tableName); + } + $sql = "DELETE FROM " . $tableName; + $stmt = $con->prepare($sql); + $stmt->execute(); + + return $stmt->rowCount(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute DELETE ALL statement [%s]', $sql), $e); + } + } + + /** + * Method to perform inserts based on values and keys in a + * Criteria. + *

+ * If the primary key is auto incremented the data in Criteria + * will be inserted and the auto increment value will be returned. + *

+ * If the primary key is included in Criteria then that value will + * be used to insert the row. + *

+ * If no primary key is included in Criteria then we will try to + * figure out the primary key from the database map and insert the + * row with the next available id using util.db.IDBroker. + *

+ * If no primary key is defined for the table the values will be + * inserted as specified in Criteria and null will be returned. + * + * @param Criteria $criteria Object containing values to insert. + * @param PropelPDO $con A PropelPDO connection. + * + * @return mixed The primary key for the new row if (and only if!) the primary key + * is auto-generated. Otherwise will return null. + * @throws PropelException + */ + public static function doInsert(Criteria $criteria, PropelPDO $con) + { + // the primary key + $id = null; + + $db = Propel::getDB($criteria->getDbName()); + + // Get the table name and method for determining the primary + // key value. + $keys = $criteria->keys(); + if (!empty($keys)) { + $tableName = $criteria->getTableName($keys[0]); + } else { + throw new PropelException("Database insert attempted without anything specified to insert"); + } + + $dbMap = Propel::getDatabaseMap($criteria->getDbName()); + $tableMap = $dbMap->getTable($tableName); + $keyInfo = $tableMap->getPrimaryKeyMethodInfo(); + $useIdGen = $tableMap->isUseIdGenerator(); + //$keyGen = $con->getIdGenerator(); + + $pk = self::getPrimaryKey($criteria); + + // only get a new key value if you need to + // the reason is that a primary key might be defined + // but you are still going to set its value. for example: + // a join table where both keys are primary and you are + // setting both columns with your own values + + // pk will be null if there is no primary key defined for the table + // we're inserting into. + if ($pk !== null && $useIdGen && !$criteria->keyContainsValue($pk->getFullyQualifiedName()) && $db->isGetIdBeforeInsert()) { + try { + $id = $db->getId($con, $keyInfo); + } catch (Exception $e) { + throw new PropelException("Unable to get sequence id.", $e); + } + $criteria->add($pk->getFullyQualifiedName(), $id); + } + + try { + $adapter = Propel::getDB($criteria->getDBName()); + + $qualifiedCols = $criteria->keys(); // we need table.column cols when populating values + $columns = array(); // but just 'column' cols for the SQL + foreach ($qualifiedCols as $qualifiedCol) { + $columns[] = substr($qualifiedCol, strrpos($qualifiedCol, '.') + 1); + } + + // add identifiers + if ($adapter->useQuoteIdentifier()) { + $columns = array_map(array($adapter, 'quoteIdentifier'), $columns); + $tableName = $adapter->quoteIdentifierTable($tableName); + } + + $sql = 'INSERT INTO ' . $tableName + . ' (' . implode(',', $columns) . ')' + . ' VALUES ('; + // . substr(str_repeat("?,", count($columns)), 0, -1) . + for ($p = 1, $cnt = count($columns); $p <= $cnt; $p++) { + $sql .= ':p' . $p; + + if ($p !== $cnt) { + $sql .= ','; + } + } + $sql .= ')'; + + $params = self::buildParams($qualifiedCols, $criteria); + + $db->cleanupSQL($sql, $params, $criteria, $dbMap); + + $stmt = $con->prepare($sql); + $db->bindValues($stmt, $params, $dbMap, $db); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + } + + // If the primary key column is auto-incremented, get the id now. + if ($pk !== null && $useIdGen && $db->isGetIdAfterInsert()) { + try { + $id = $db->getId($con, $keyInfo); + } catch (Exception $e) { + throw new PropelException("Unable to get autoincrement id.", $e); + } + } + + return $id; + } + + /** + * Method used to update rows in the DB. Rows are selected based + * on selectCriteria and updated using values in updateValues. + *

+ * Use this method for performing an update of the kind: + *

+ * WHERE some_column = some value AND could_have_another_column = + * another value AND so on. + * + * @param $selectCriteria A Criteria object containing values used in where clause. + * @param $updateValues A Criteria object containing values used in set clause. + * @param PropelPDO $con The PropelPDO connection object to use. + * + * @return int The number of rows affected by last update statement. For most + * uses there is only one update statement executed, so this number + * will correspond to the number of rows affected by the call to this + * method. Note that the return value does require that this information + * is returned (supported) by the Propel db driver. + * @throws PropelException + */ + public static function doUpdate(Criteria $selectCriteria, Criteria $updateValues, PropelPDO $con) + { + $db = Propel::getDB($selectCriteria->getDbName()); + $dbMap = Propel::getDatabaseMap($selectCriteria->getDbName()); + + // Get list of required tables, containing all columns + $tablesColumns = $selectCriteria->getTablesColumns(); + if (empty($tablesColumns) && ($table = $selectCriteria->getPrimaryTableName())) { + $tablesColumns = array($table => array()); + } + + // we also need the columns for the update SQL + $updateTablesColumns = $updateValues->getTablesColumns(); + + // If no columns are changing values, we may get here with + // an empty array in $updateTablesColumns. In that case, + // there is nothing to do, so we return the rows affected, + // which is 0. Fixes a bug in which an UPDATE statement + // would fail in this instance. + + if (empty($updateTablesColumns)) { + return 0; + } + + $affectedRows = 0; // initialize this in case the next loop has no iterations. + + foreach ($tablesColumns as $tableName => $columns) { + + $whereClause = array(); + $params = array(); + $stmt = null; + try { + $sql = 'UPDATE '; + if ($queryComment = $selectCriteria->getComment()) { + $sql .= '/* ' . $queryComment . ' */ '; + } + // is it a table alias? + if ($tableName2 = $selectCriteria->getTableForAlias($tableName)) { + $updateTable = $tableName2 . ' ' . $tableName; + $tableName = $tableName2; + } else { + $updateTable = $tableName; + } + if ($db->useQuoteIdentifier()) { + $sql .= $db->quoteIdentifierTable($updateTable); + } else { + $sql .= $updateTable; + } + $sql .= " SET "; + $p = 1; + foreach ($updateTablesColumns[$tableName] as $col) { + $updateColumnName = substr($col, strrpos($col, '.') + 1); + // add identifiers for the actual database? + if ($db->useQuoteIdentifier()) { + $updateColumnName = $db->quoteIdentifier($updateColumnName); + } + if ($updateValues->getComparison($col) != Criteria::CUSTOM_EQUAL) { + $sql .= $updateColumnName . '=:p' . $p++ . ', '; + } else { + $param = $updateValues->get($col); + $sql .= $updateColumnName . ' = '; + if (is_array($param)) { + if (isset($param['raw'])) { + $raw = $param['raw']; + $rawcvt = ''; + // parse the $params['raw'] for ? chars + for ($r = 0, $len = strlen($raw); $r < $len; $r++) { + if ($raw{$r} == '?') { + $rawcvt .= ':p' . $p++; + } else { + $rawcvt .= $raw{$r}; + } + } + $sql .= $rawcvt . ', '; + } else { + $sql .= ':p' . $p++ . ', '; + } + if (isset($param['value'])) { + $updateValues->put($col, $param['value']); + } + } else { + $updateValues->remove($col); + $sql .= $param . ', '; + } + } + } + + $params = self::buildParams($updateTablesColumns[$tableName], $updateValues); + + $sql = substr($sql, 0, -2); + if (!empty($columns)) { + foreach ($columns as $colName) { + $sb = ""; + $selectCriteria->getCriterion($colName)->appendPsTo($sb, $params); + $whereClause[] = $sb; + } + $sql .= " WHERE " . implode(" AND ", $whereClause); + } + + $db->cleanupSQL($sql, $params, $updateValues, $dbMap); + + $stmt = $con->prepare($sql); + + // Replace ':p?' with the actual values + $db->bindValues($stmt, $params, $dbMap, $db); + + $stmt->execute(); + + $affectedRows = $stmt->rowCount(); + + $stmt = null; // close + + } catch (Exception $e) { + if ($stmt) { + $stmt = null; + } // close + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute UPDATE statement [%s]', $sql), $e); + } + } // foreach table in the criteria + + return $affectedRows; + } + + /** + * Executes query build by createSelectSql() and returns the resultset statement. + * + * @param Criteria $criteria A Criteria. + * @param PropelPDO $con A PropelPDO connection to use. + * + * @return PDOStatement The resultset. + * @throws PropelException + * @see createSelectSql() + */ + public static function doSelect(Criteria $criteria, PropelPDO $con = null) + { + $dbMap = Propel::getDatabaseMap($criteria->getDbName()); + $db = Propel::getDB($criteria->getDbName()); + $stmt = null; + + if ($con === null) { + $con = Propel::getConnection($criteria->getDbName(), Propel::CONNECTION_READ); + } + + try { + + $params = array(); + $sql = self::createSelectSql($criteria, $params); + + $stmt = $con->prepare($sql); + + $db->bindValues($stmt, $params, $dbMap); + + $stmt->execute(); + } catch (Exception $e) { + if ($stmt) { + $stmt = null; // close + } + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + } + + return $stmt; + } + + /** + * Executes a COUNT query using either a simple SQL rewrite or, for more complex queries, a + * sub-select of the SQL created by createSelectSql() and returns the statement. + * + * @param Criteria $criteria A Criteria. + * @param PropelPDO $con A PropelPDO connection to use. + * + * @return PDOStatement The resultset statement. + * @throws PropelException + * @see createSelectSql() + */ + public static function doCount(Criteria $criteria, PropelPDO $con = null) + { + $dbMap = Propel::getDatabaseMap($criteria->getDbName()); + $db = Propel::getDB($criteria->getDbName()); + + if ($con === null) { + $con = Propel::getConnection($criteria->getDbName(), Propel::CONNECTION_READ); + } + + $stmt = null; + + $needsComplexCount = $criteria->getGroupByColumns() + || $criteria->getOffset() + || $criteria->getLimit() + || $criteria->getHaving() + || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers()); + + try { + + $params = array(); + + if ($needsComplexCount) { + if (self::needsSelectAliases($criteria)) { + if ($criteria->getHaving()) { + throw new PropelException('Propel cannot create a COUNT query when using HAVING and duplicate column names in the SELECT part'); + } + $db->turnSelectColumnsToAliases($criteria); + } + $selectSql = self::createSelectSql($criteria, $params); + $sql = 'SELECT COUNT(*) FROM (' . $selectSql . ') propelmatch4cnt'; + } else { + // Replace SELECT columns with COUNT(*) + $criteria->clearSelectColumns()->addSelectColumn('COUNT(*)'); + $sql = self::createSelectSql($criteria, $params); + } + + $stmt = $con->prepare($sql); + $db->bindValues($stmt, $params, $dbMap); + $stmt->execute(); + } catch (Exception $e) { + if ($stmt !== null) { + $stmt = null; + } + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute COUNT statement [%s]', $sql), $e); + } + + return $stmt; + } + + /** + * Applies any validators that were defined in the schema to the specified columns. + * + * @param string $dbName The name of the database + * @param string $tableName The name of the table + * @param array $columns Array of column names as key and column values as value. + * + * @return ValidationFailed[]|bool A list of validation failures, true if valid. + */ + public static function doValidate($dbName, $tableName, $columns) + { + $dbMap = Propel::getDatabaseMap($dbName); + $tableMap = $dbMap->getTable($tableName); + $failureMap = array(); // map of ValidationFailed objects + foreach ($columns as $colName => $colValue) { + if ($tableMap->hasColumn($colName)) { + $col = $tableMap->getColumn($colName); + foreach ($col->getValidators() as $validatorMap) { + $validator = BasePeer::getValidator($validatorMap->getClass()); + if ($validator && ($col->isNotNull() || $colValue !== null) && $validator->isValid($validatorMap, $colValue) === false) { + // for now we do one ValidationFailed per column, not per rule + if (!isset($failureMap[$colName])) { + $failureMap[$colName] = new ValidationFailed($colName, $validatorMap->getMessage(), $validator); + break; + } + } + } + } + } + + return (!empty($failureMap) ? $failureMap : true); + } + + /** + * Helper method which returns the primary key contained + * in the given Criteria object. + * + * @param Criteria $criteria A Criteria. + * + * @return ColumnMap If the Criteria object contains a primary key, or null if it doesn't. + * @throws PropelException + */ + private static function getPrimaryKey(Criteria $criteria) + { + // Assume all the keys are for the same table. + $keys = $criteria->keys(); + $key = $keys[0]; + $table = $criteria->getTableName($key); + + $pk = null; + + if (!empty($table)) { + + $dbMap = Propel::getDatabaseMap($criteria->getDbName()); + + $pks = $dbMap->getTable($table)->getPrimaryKeys(); + if (!empty($pks)) { + $pk = array_shift($pks); + } + } + + return $pk; + } + + /** + * Checks whether the Criteria needs to use column aliasing + * This is implemented in a service class rather than in Criteria itself + * in order to avoid doing the tests when it's not necessary (e.g. for SELECTs) + */ + public static function needsSelectAliases(Criteria $criteria) + { + $columnNames = array(); + foreach ($criteria->getSelectColumns() as $fullyQualifiedColumnName) { + if ($pos = strrpos($fullyQualifiedColumnName, '.')) { + $columnName = substr($fullyQualifiedColumnName, $pos); + if (isset($columnNames[$columnName])) { + // more than one column with the same name, so aliasing is required + return true; + } + $columnNames[$columnName] = true; + } + } + + return false; + } + + /** + * Method to create an SQL query based on values in a Criteria. + * + * This method creates only prepared statement SQL (using ? where values + * will go). The second parameter ($params) stores the values that need + * to be set before the statement is executed. The reason we do it this way + * is to let the PDO layer handle all escaping & value formatting. + * + * @param Criteria $criteria Criteria for the SELECT query. + * @param array &$params Parameters that are to be replaced in prepared statement. + * + * @return string + * @throws PropelException Trouble creating the query string. + */ + public static function createSelectSql(Criteria $criteria, &$params) + { + $db = Propel::getDB($criteria->getDbName()); + $dbMap = Propel::getDatabaseMap($criteria->getDbName()); + + $fromClause = array(); + $joinClause = array(); + $joinTables = array(); + $whereClause = array(); + $orderByClause = array(); + + $orderBy = $criteria->getOrderByColumns(); + $groupBy = $criteria->getGroupByColumns(); + $ignoreCase = $criteria->isIgnoreCase(); + + // get the first part of the SQL statement, the SELECT part + $selectSql = $db->createSelectSqlPart($criteria, $fromClause); + + // Handle joins + // joins with a null join type will be added to the FROM clause and the condition added to the WHERE clause. + // joins of a specified type: the LEFT side will be added to the fromClause and the RIGHT to the joinClause + foreach ($criteria->getJoins() as $join) { + + $join->setDB($db); + + // add 'em to the queues.. + if (!$fromClause) { + $fromClause[] = $join->getLeftTableWithAlias(); + } + $joinTables[] = $join->getRightTableWithAlias(); + $joinClause[] = $join->getClause($params); + } + + // add the criteria to WHERE clause + // this will also add the table names to the FROM clause if they are not already + // included via a LEFT JOIN + foreach ($criteria->keys() as $key) { + + $criterion = $criteria->getCriterion($key); + $table = null; + foreach ($criterion->getAttachedCriterion() as $attachedCriterion) { + $tableName = $attachedCriterion->getTable(); + + $table = $criteria->getTableForAlias($tableName); + if ($table !== null) { + $fromClause[] = $table . ' ' . $tableName; + } else { + $fromClause[] = $tableName; + $table = $tableName; + } + + if (($criteria->isIgnoreCase() || $attachedCriterion->isIgnoreCase()) + && $dbMap->getTable($table)->getColumn($attachedCriterion->getColumn())->isText()) { + $attachedCriterion->setIgnoreCase(true); + } + } + + $criterion->setDB($db); + + $sb = ''; + $criterion->appendPsTo($sb, $params); + $whereClause[] = $sb; + } + + // Unique from clause elements + $fromClause = array_unique($fromClause); + $fromClause = array_diff($fromClause, array('')); + + // tables should not exist in both the from and join clauses + if ($joinTables && $fromClause) { + foreach ($fromClause as $fi => $ftable) { + if (in_array($ftable, $joinTables)) { + unset($fromClause[$fi]); + } + } + } + + // Add the GROUP BY columns + $groupByClause = $groupBy; + + $having = $criteria->getHaving(); + $havingString = null; + if ($having !== null) { + $sb = ''; + $having->appendPsTo($sb, $params); + $havingString = $sb; + } + + if (!empty($orderBy)) { + + foreach ($orderBy as $orderByColumn) { + + // Add function expression as-is. + + if (strpos($orderByColumn, '(') !== false) { + $orderByClause[] = $orderByColumn; + continue; + } + + // Split orderByColumn (i.e. "table.column DESC") + + $dotPos = strrpos($orderByColumn, '.'); + + if ($dotPos !== false) { + $tableName = substr($orderByColumn, 0, $dotPos); + $columnName = substr($orderByColumn, $dotPos + 1); + } else { + $tableName = ''; + $columnName = $orderByColumn; + } + + $spacePos = strpos($columnName, ' '); + + if ($spacePos !== false) { + $direction = substr($columnName, $spacePos); + $columnName = substr($columnName, 0, $spacePos); + } else { + $direction = ''; + } + + $tableAlias = $tableName; + if ($aliasTableName = $criteria->getTableForAlias($tableName)) { + $tableName = $aliasTableName; + } + + $columnAlias = $columnName; + if ($asColumnName = $criteria->getColumnForAs($columnName)) { + $columnName = $asColumnName; + } + + $column = $tableName ? $dbMap->getTable($tableName)->getColumn($columnName) : null; + + if ($criteria->isIgnoreCase() && $column && $column->isText()) { + $ignoreCaseColumn = $db->ignoreCaseInOrderBy("$tableAlias.$columnAlias"); + $orderByClause[] = $ignoreCaseColumn . $direction; + $selectSql .= ', ' . $ignoreCaseColumn; + } else { + $orderByClause[] = $orderByColumn; + } + } + } + + if (empty($fromClause) && $criteria->getPrimaryTableName()) { + $fromClause[] = $criteria->getPrimaryTableName(); + } + + // tables should not exist as alias of subQuery + if ($criteria->hasSelectQueries()) { + foreach ($fromClause as $key => $ftable) { + if (strpos($ftable, ' ') !== false) { + list($realtable, $tableName) = explode(' ', $ftable); + } else { + $tableName = $ftable; + } + if ($criteria->hasSelectQuery($tableName)) { + unset($fromClause[$key]); + } + } + } + + // from / join tables quoted if it is necessary + if ($db->useQuoteIdentifier()) { + $fromClause = array_map(array($db, 'quoteIdentifierTable'), $fromClause); + $joinClause = $joinClause ? $joinClause : array_map(array($db, 'quoteIdentifierTable'), $joinClause); + } + + // add subQuery to From after adding quotes + foreach ($criteria->getSelectQueries() as $subQueryAlias => $subQueryCriteria) { + $fromClause[] = '(' . BasePeer::createSelectSql($subQueryCriteria, $params) . ') AS ' . $subQueryAlias; + } + + // build from-clause + $from = ''; + if (!empty($joinClause) && count($fromClause) > 1) { + $from .= implode(" CROSS JOIN ", $fromClause); + } else { + $from .= implode(", ", $fromClause); + } + + $from .= $joinClause ? ' ' . implode(' ', $joinClause) : ''; + + // Build the SQL from the arrays we compiled + $sql = $selectSql + ." FROM " . $from + .($whereClause ? " WHERE ".implode(" AND ", $whereClause) : "") + .($groupByClause ? " GROUP BY ".implode(",", $groupByClause) : "") + .($havingString ? " HAVING ".$havingString : "") + .($orderByClause ? " ORDER BY ".implode(",", $orderByClause) : ""); + + // APPLY OFFSET & LIMIT to the query. + if ($criteria->getLimit() || $criteria->getOffset()) { + $db->applyLimit($sql, $criteria->getOffset(), $criteria->getLimit(), $criteria); + } + + return $sql; + } + + /** + * Builds a params array, like the kind populated by Criterion::appendPsTo(). + * This is useful for building an array even when it is not using the appendPsTo() method. + * + * @param array $columns + * @param Criteria $values + * + * @return array params array('column' => ..., 'table' => ..., 'value' => ...) + */ + private static function buildParams($columns, Criteria $values) + { + $params = array(); + foreach ($columns as $key) { + if ($values->containsKey($key)) { + $crit = $values->getCriterion($key); + $params[] = array('column' => $crit->getColumn(), 'table' => $crit->getTable(), 'value' => $crit->getValue()); + } + } + + return $params; + } + + /** + * This function searches for the given validator $name under propel/validator/$name.php, + * imports and caches it. + * + * @param string $classname The dot-path name of class (e.g. myapp.propel.MyValidator) + * + * @return Validator|null object or null if not able to instantiate validator class (and error will be logged in this case) + */ + public static function getValidator($classname) + { + try { + $v = isset(self::$validatorMap[$classname]) ? self::$validatorMap[$classname] : null; + if ($v === null) { + $cls = Propel::importClass($classname); + $v = new $cls(); + self::$validatorMap[$classname] = $v; + } + + return $v; + } catch (Exception $e) { + Propel::log("BasePeer::getValidator(): failed trying to instantiate " . $classname . ": " . $e->getMessage(), Propel::LOG_ERR); + } + + return null; + } } diff --git a/airtime_mvc/library/propel/runtime/lib/util/NodePeer.php b/airtime_mvc/library/propel/runtime/lib/util/NodePeer.php index d40b7642a..b72c6a94c 100644 --- a/airtime_mvc/library/propel/runtime/lib/util/NodePeer.php +++ b/airtime_mvc/library/propel/runtime/lib/util/NodePeer.php @@ -12,358 +12,390 @@ * This is a utility interface for all generated NodePeer classes in the system. * * @author Heltem (Propel) - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.util */ interface NodePeer { - /** - * Creates the supplied node as the root node. - * - * @param object $node Propel object for model - * @return object Inserted propel object for model - */ - public static function createRoot(NodeObject $node); + /** + * Creates the supplied node as the root node. + * + * @param NodeObject $node Propel object for model + * + * @return object Inserted propel object for model + */ + public static function createRoot(NodeObject $node); - /** - * Returns the root node for a given scope id - * - * @param int $scopeId Scope id to determine which root node to return - * @param PropelPDO $con Connection to use. - * @return object Propel object for root node - */ - public static function retrieveRoot($scopeId = 1, PropelPDO $con = null); + /** + * Returns the root node for a given scope id + * + * @param int $scopeId Scope id to determine which root node to return + * @param PropelPDO $con Connection to use. + * + * @return object Propel object for root node + */ + public static function retrieveRoot($scopeId = 1, PropelPDO $con = null); - /** - * Inserts $child as first child of destination node $parent - * - * @param object $child Propel object for child node - * @param object $parent Propel object for parent node - * @param PropelPDO $con Connection to use. - * @return void - */ - public static function insertAsFirstChildOf(NodeObject $child, NodeObject $parent, PropelPDO $con = null); + /** + * Inserts $child as first child of destination node $parent + * + * @param object $child Propel object for child node + * @param object $parent Propel object for parent node + * @param PropelPDO $con Connection to use. + * + * @return void + */ + public static function insertAsFirstChildOf(NodeObject $child, NodeObject $parent, PropelPDO $con = null); - /** - * Inserts $child as last child of destination node $parent - * - * @param object $child Propel object for child node - * @param object $parent Propel object for parent node - * @param PropelPDO $con Connection to use. - * @return void - */ - public static function insertAsLastChildOf(NodeObject $child, NodeObject $parent, PropelPDO $con = null); + /** + * Inserts $child as last child of destination node $parent + * + * @param object $child Propel object for child node + * @param object $parent Propel object for parent node + * @param PropelPDO $con Connection to use. + * + * @return void + */ + public static function insertAsLastChildOf(NodeObject $child, NodeObject $parent, PropelPDO $con = null); - /** - * Inserts $sibling as previous sibling to destination node $node - * - * @param object $node Propel object for destination node - * @param object $sibling Propel object for source node - * @param PropelPDO $con Connection to use. - * @return void - */ - public static function insertAsPrevSiblingOf(NodeObject $node, NodeObject $sibling, PropelPDO $con = null); + /** + * Inserts $sibling as previous sibling to destination node $node + * + * @param object $node Propel object for destination node + * @param object $sibling Propel object for source node + * @param PropelPDO $con Connection to use. + * + * @return void + */ + public static function insertAsPrevSiblingOf(NodeObject $node, NodeObject $sibling, PropelPDO $con = null); - /** - * Inserts $sibling as next sibling to destination node $node - * - * @param object $node Propel object for destination node - * @param object $sibling Propel object for source node - * @param PropelPDO $con Connection to use. - * @return void - */ - public static function insertAsNextSiblingOf(NodeObject $node, NodeObject $sibling, PropelPDO $con = null); + /** + * Inserts $sibling as next sibling to destination node $node + * + * @param object $node Propel object for destination node + * @param object $sibling Propel object for source node + * @param PropelPDO $con Connection to use. + * + * @return void + */ + public static function insertAsNextSiblingOf(NodeObject $node, NodeObject $sibling, PropelPDO $con = null); - /** - * Inserts $parent as parent of given $node. - * - * @param object $parent Propel object for given parent node - * @param object $node Propel object for given destination node - * @param PropelPDO $con Connection to use. - * @return void - * @throws Exception When trying to insert node as parent of a root node - */ - public static function insertAsParentOf(NodeObject $parent, NodeObject $node, PropelPDO $con = null); + /** + * Inserts $parent as parent of given $node. + * + * @param object $parent Propel object for given parent node + * @param object $node Propel object for given destination node + * @param PropelPDO $con Connection to use. + * + * @return void + * @throws Exception When trying to insert node as parent of a root node + */ + public static function insertAsParentOf(NodeObject $parent, NodeObject $node, PropelPDO $con = null); - /** - * Inserts $node as root node - * - * @param object $node Propel object as root node - * @param PropelPDO $con Connection to use. - * @return void - */ - public static function insertRoot(NodeObject $node, PropelPDO $con = null); + /** + * Inserts $node as root node + * + * @param object $node Propel object as root node + * @param PropelPDO $con Connection to use. + * + * @return void + */ + public static function insertRoot(NodeObject $node, PropelPDO $con = null); - /** - * Delete root node - * - * @param int $scopeId Scope id to determine which root node to delete - * @param PropelPDO $con Connection to use. - * @return boolean Deletion status - */ - public static function deleteRoot($scopeId = 1, PropelPDO $con = null); + /** + * Delete root node + * + * @param int $scopeId Scope id to determine which root node to delete + * @param PropelPDO $con Connection to use. + * + * @return boolean Deletion status + */ + public static function deleteRoot($scopeId = 1, PropelPDO $con = null); - /** - * Delete $dest node - * - * @param object $dest Propel object node to delete - * @param PropelPDO $con Connection to use. - * @return boolean Deletion status - */ - public static function deleteNode(NodeObject $dest, PropelPDO $con = null); + /** + * Delete $dest node + * + * @param object $dest Propel object node to delete + * @param PropelPDO $con Connection to use. + * + * @return boolean Deletion status + */ + public static function deleteNode(NodeObject $dest, PropelPDO $con = null); - /** - * Moves $child to be first child of $parent - * - * @param object $parent Propel object for parent node - * @param object $child Propel object for child node - * @param PropelPDO $con Connection to use. - * @return void - */ - public static function moveToFirstChildOf(NodeObject $parent, NodeObject $child, PropelPDO $con = null); + /** + * Moves $child to be first child of $parent + * + * @param object $parent Propel object for parent node + * @param object $child Propel object for child node + * @param PropelPDO $con Connection to use. + * + * @return void + */ + public static function moveToFirstChildOf(NodeObject $parent, NodeObject $child, PropelPDO $con = null); - /** - * Moves $node to be last child of $dest - * - * @param object $dest Propel object for destination node - * @param object $node Propel object for source node - * @param PropelPDO $con Connection to use. - * @return void - */ - public static function moveToLastChildOf(NodeObject $dest, NodeObject $node, PropelPDO $con = null); + /** + * Moves $node to be last child of $dest + * + * @param object $dest Propel object for destination node + * @param object $node Propel object for source node + * @param PropelPDO $con Connection to use. + * + * @return void + */ + public static function moveToLastChildOf(NodeObject $dest, NodeObject $node, PropelPDO $con = null); - /** - * Moves $node to be prev sibling to $dest - * - * @param object $dest Propel object for destination node - * @param object $node Propel object for source node - * @param PropelPDO $con Connection to use. - * @return void - */ - public static function moveToPrevSiblingOf(NodeObject $dest, NodeObject $node, PropelPDO $con = null); + /** + * Moves $node to be prev sibling to $dest + * + * @param object $dest Propel object for destination node + * @param object $node Propel object for source node + * @param PropelPDO $con Connection to use. + * + * @return void + */ + public static function moveToPrevSiblingOf(NodeObject $dest, NodeObject $node, PropelPDO $con = null); - /** - * Moves $node to be next sibling to $dest - * - * @param object $dest Propel object for destination node - * @param object $node Propel object for source node - * @param PropelPDO $con Connection to use. - * @return void - */ - public static function moveToNextSiblingOf(NodeObject $dest, NodeObject $node, PropelPDO $con = null); + /** + * Moves $node to be next sibling to $dest + * + * @param object $dest Propel object for destination node + * @param object $node Propel object for source node + * @param PropelPDO $con Connection to use. + * + * @return void + */ + public static function moveToNextSiblingOf(NodeObject $dest, NodeObject $node, PropelPDO $con = null); - /** - * Gets first child for the given node if it exists - * - * @param object $node Propel object for src node - * @param PropelPDO $con Connection to use. - * @return mixed Propel object if exists else false - */ - public static function retrieveFirstChild(NodeObject $node, PropelPDO $con = null); + /** + * Gets first child for the given node if it exists + * + * @param object $node Propel object for src node + * @param PropelPDO $con Connection to use. + * + * @return mixed Propel object if exists else false + */ + public static function retrieveFirstChild(NodeObject $node, PropelPDO $con = null); - /** - * Gets last child for the given node if it exists - * - * @param object $node Propel object for src node - * @param PropelPDO $con Connection to use. - * @return mixed Propel object if exists else false - */ - public static function retrieveLastChild(NodeObject $node, PropelPDO $con = null); + /** + * Gets last child for the given node if it exists + * + * @param object $node Propel object for src node + * @param PropelPDO $con Connection to use. + * + * @return mixed Propel object if exists else false + */ + public static function retrieveLastChild(NodeObject $node, PropelPDO $con = null); - /** - * Gets prev sibling for the given node if it exists - * - * @param object $node Propel object for src node - * @param PropelPDO $con Connection to use. - * @return mixed Propel object if exists else false - */ - public static function retrievePrevSibling(NodeObject $node, PropelPDO $con = null); + /** + * Gets prev sibling for the given node if it exists + * + * @param object $node Propel object for src node + * @param PropelPDO $con Connection to use. + * + * @return mixed Propel object if exists else false + */ + public static function retrievePrevSibling(NodeObject $node, PropelPDO $con = null); - /** - * Gets next sibling for the given node if it exists - * - * @param object $node Propel object for src node - * @param PropelPDO $con Connection to use. - * @return mixed Propel object if exists else false - */ - public static function retrieveNextSibling(NodeObject $node, PropelPDO $con = null); + /** + * Gets next sibling for the given node if it exists + * + * @param object $node Propel object for src node + * @param PropelPDO $con Connection to use. + * + * @return mixed Propel object if exists else false + */ + public static function retrieveNextSibling(NodeObject $node, PropelPDO $con = null); - /** - * Retrieves the entire tree from root - * - * @param int $scopeId Scope id to determine which scope tree to return - * @param PropelPDO $con Connection to use. - */ - public static function retrieveTree($scopeId = 1, PropelPDO $con = null); + /** + * Retrieves the entire tree from root + * + * @param int $scopeId Scope id to determine which scope tree to return + * @param PropelPDO $con Connection to use. + */ + public static function retrieveTree($scopeId = 1, PropelPDO $con = null); - /** - * Retrieves the entire tree from parent $node - * - * @param PropelPDO $con Connection to use. - */ - public static function retrieveBranch(NodeObject $node, PropelPDO $con = null); + /** + * Retrieves the entire tree from parent $node + * + * @param PropelPDO $con Connection to use. + */ + public static function retrieveBranch(NodeObject $node, PropelPDO $con = null); - /** - * Gets direct children for the node - * - * @param object $node Propel object for parent node - * @param PropelPDO $con Connection to use. - */ - public static function retrieveChildren(NodeObject $node, PropelPDO $con = null); + /** + * Gets direct children for the node + * + * @param object $node Propel object for parent node + * @param PropelPDO $con Connection to use. + */ + public static function retrieveChildren(NodeObject $node, PropelPDO $con = null); - /** - * Gets all descendants for the node - * - * @param object $node Propel object for parent node - * @param PropelPDO $con Connection to use. - */ - public static function retrieveDescendants(NodeObject $node, PropelPDO $con = null); + /** + * Gets all descendants for the node + * + * @param object $node Propel object for parent node + * @param PropelPDO $con Connection to use. + */ + public static function retrieveDescendants(NodeObject $node, PropelPDO $con = null); - /** - * Gets all siblings for the node - * - * @param object $node Propel object for src node - * @param PropelPDO $con Connection to use. - */ - public static function retrieveSiblings(NodeObject $node, PropelPDO $con = null); + /** + * Gets all siblings for the node + * + * @param object $node Propel object for src node + * @param PropelPDO $con Connection to use. + */ + public static function retrieveSiblings(NodeObject $node, PropelPDO $con = null); - /** - * Gets ancestor for the given node if it exists - * - * @param object $node Propel object for src node - * @param PropelPDO $con Connection to use. - * @return mixed Propel object if exists else false - */ - public static function retrieveParent(NodeObject $node, PropelPDO $con = null); + /** + * Gets ancestor for the given node if it exists + * + * @param object $node Propel object for src node + * @param PropelPDO $con Connection to use. + * + * @return mixed Propel object if exists else false + */ + public static function retrieveParent(NodeObject $node, PropelPDO $con = null); - /** - * Gets level for the given node - * - * @param object $node Propel object for src node - * @param PropelPDO $con Connection to use. - * @return int Level for the given node - */ - public static function getLevel(NodeObject $node, PropelPDO $con = null); + /** + * Gets level for the given node + * + * @param object $node Propel object for src node + * @param PropelPDO $con Connection to use. + * + * @return int Level for the given node + */ + public static function getLevel(NodeObject $node, PropelPDO $con = null); - /** - * Gets number of direct children for given node - * - * @param object $node Propel object for src node - * @param PropelPDO $con Connection to use. - * @return int Level for the given node - */ - public static function getNumberOfChildren(NodeObject $node, PropelPDO $con = null); + /** + * Gets number of direct children for given node + * + * @param object $node Propel object for src node + * @param PropelPDO $con Connection to use. + * + * @return int Level for the given node + */ + public static function getNumberOfChildren(NodeObject $node, PropelPDO $con = null); - /** - * Gets number of descendants for given node - * - * @param object $node Propel object for src node - * @param PropelPDO $con Connection to use. - * @return int Level for the given node - */ - public static function getNumberOfDescendants(NodeObject $node, PropelPDO $con = null); + /** + * Gets number of descendants for given node + * + * @param object $node Propel object for src node + * @param PropelPDO $con Connection to use. + * + * @return int Level for the given node + */ + public static function getNumberOfDescendants(NodeObject $node, PropelPDO $con = null); - /** - * Returns path to a specific node as an array, useful to create breadcrumbs - * - * @param object $node Propel object of node to create path to - * @param PropelPDO $con Connection to use. - * @return array Array in order of heirarchy - */ - public static function getPath(NodeObject $node, PropelPDO $con = null); + /** + * Returns path to a specific node as an array, useful to create breadcrumbs + * + * @param object $node Propel object of node to create path to + * @param PropelPDO $con Connection to use. + * + * @return array Array in order of hierarchy + */ + public static function getPath(NodeObject $node, PropelPDO $con = null); - /** - * Tests if node is valid - * - * @param object $node Propel object for src node - * @return bool - */ - public static function isValid(NodeObject $node = null); + /** + * Tests if node is valid + * + * @param object $node Propel object for src node + * + * @return bool + */ + public static function isValid(NodeObject $node = null); - /** - * Tests if node is a root - * - * @param object $node Propel object for src node - * @return bool - */ - public static function isRoot(NodeObject $node); + /** + * Tests if node is a root + * + * @param object $node Propel object for src node + * + * @return bool + */ + public static function isRoot(NodeObject $node); - /** - * Tests if node is a leaf - * - * @param object $node Propel object for src node - * @return bool - */ - public static function isLeaf(NodeObject $node); + /** + * Tests if node is a leaf + * + * @param object $node Propel object for src node + * + * @return bool + */ + public static function isLeaf(NodeObject $node); - /** - * Tests if $child is a child of $parent - * - * @param object $child Propel object for node - * @param object $parent Propel object for node - * @return bool - */ - public static function isChildOf(NodeObject $child, NodeObject $parent); + /** + * Tests if $child is a child of $parent + * + * @param object $child Propel object for node + * @param object $parent Propel object for node + * + * @return bool + */ + public static function isChildOf(NodeObject $child, NodeObject $parent); - /** - * Tests if $node1 is equal to $node2 - * - * @param object $node1 Propel object for node - * @param object $node2 Propel object for node - * @return bool - */ - public static function isEqualTo(NodeObject $node1, NodeObject $node2); + /** + * Tests if $node1 is equal to $node2 + * + * @param object $node1 Propel object for node + * @param object $node2 Propel object for node + * + * @return bool + */ + public static function isEqualTo(NodeObject $node1, NodeObject $node2); - /** - * Tests if $node has an ancestor - * - * @param object $node Propel object for node - * @param PropelPDO $con Connection to use. - * @return bool - */ - public static function hasParent(NodeObject $node, PropelPDO $con = null); + /** + * Tests if $node has an ancestor + * + * @param object $node Propel object for node + * @param PropelPDO $con Connection to use. + * + * @return bool + */ + public static function hasParent(NodeObject $node, PropelPDO $con = null); - /** - * Tests if $node has prev sibling - * - * @param object $node Propel object for node - * @param PropelPDO $con Connection to use. - * @return bool - */ - public static function hasPrevSibling(NodeObject $node, PropelPDO $con = null); + /** + * Tests if $node has prev sibling + * + * @param object $node Propel object for node + * @param PropelPDO $con Connection to use. + * + * @return bool + */ + public static function hasPrevSibling(NodeObject $node, PropelPDO $con = null); - /** - * Tests if $node has next sibling - * - * @param object $node Propel object for node - * @param PropelPDO $con Connection to use. - * @return bool - */ - public static function hasNextSibling(NodeObject $node, PropelPDO $con = null); + /** + * Tests if $node has next sibling + * + * @param object $node Propel object for node + * @param PropelPDO $con Connection to use. + * + * @return bool + */ + public static function hasNextSibling(NodeObject $node, PropelPDO $con = null); - /** - * Tests if $node has children - * - * @param object $node Propel object for node - * @return bool - */ - public static function hasChildren(NodeObject $node); + /** + * Tests if $node has children + * + * @param object $node Propel object for node + * + * @return bool + */ + public static function hasChildren(NodeObject $node); - /** - * Deletes $node and all of its descendants - * - * @param object $node Propel object for source node - * @param PropelPDO $con Connection to use. - */ - public static function deleteDescendants(NodeObject $node, PropelPDO $con = null); - - /** - * Returns a node given its primary key or the node itself - * - * @param int/object $node Primary key/instance of required node - * @param PropelPDO $con Connection to use. - * @return object Propel object for model - */ - public static function getNode($node, PropelPDO $con = null); + /** + * Deletes $node and all of its descendants + * + * @param object $node Propel object for source node + * @param PropelPDO $con Connection to use. + */ + public static function deleteDescendants(NodeObject $node, PropelPDO $con = null); + /** + * Returns a node given its primary key or the node itself + * + * @param int/object $node Primary key/instance of required node + * @param PropelPDO $con Connection to use. + * + * @return object Propel object for model + */ + public static function getNode($node, PropelPDO $con = null); } // NodePeer diff --git a/airtime_mvc/library/propel/runtime/lib/util/PropelAutoloader.php b/airtime_mvc/library/propel/runtime/lib/util/PropelAutoloader.php index 1bba65cec..573dc0a50 100644 --- a/airtime_mvc/library/propel/runtime/lib/util/PropelAutoloader.php +++ b/airtime_mvc/library/propel/runtime/lib/util/PropelAutoloader.php @@ -14,100 +14,110 @@ * * @author Prancois Zaninotto * @author Fabien Potencier - * @version $Revision: 1773 $ + * @version $Revision$ * @package propel.util */ class PropelAutoloader { - static protected $instance = null; + protected static $instance = null; - protected $classes = array(); + protected $classes = array(); - /** - * Retrieves the singleton instance of this class. - * - * @return PropelAutoloader A PropelAutoloader instance. - */ - static public function getInstance() - { - if (!isset(self::$instance)) { - self::$instance = new PropelAutoloader(); - } + /** + * Retrieves the singleton instance of this class. + * + * @return PropelAutoloader A PropelAutoloader instance. + */ + public static function getInstance() + { + if (!isset(self::$instance)) { + self::$instance = new PropelAutoloader(); + } - return self::$instance; - } + return self::$instance; + } - /** - * Register PropelAutoloader in spl autoloader. - * - * @return void - */ - static public function register() - { - ini_set('unserialize_callback_func', 'spl_autoload_call'); + /** + * Register PropelAutoloader in spl autoloader. + * + * @return void + * + * @throws Exception + */ + public static function register() + { + ini_set('unserialize_callback_func', 'spl_autoload_call'); - if (false === spl_autoload_register(array(self::getInstance(), 'autoload'))) { - throw new Exception(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance()))); - } - } + if (false === spl_autoload_register(array(self::getInstance(), 'autoload'))) { + throw new Exception(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance()))); + } + } - /** - * Unregister PropelAutoloader from spl autoloader. - * - * @return void - */ - static public function unregister() - { - spl_autoload_unregister(array(self::getInstance(), 'autoload')); - } + /** + * Unregister PropelAutoloader from spl autoloader. + * + * @return void + */ + public static function unregister() + { + spl_autoload_unregister(array(self::getInstance(), 'autoload')); + } - /** - * Sets the path for a list of classes. - * - * @param array $classMap An associative array $className => $classPath - */ - public function addClassPaths($classMap) - { - $this->classes = array_merge($this->classes, $classMap); - } - - /** - * Sets the path for a particular class. - * - * @param string $class A PHP class name - * @param string $path A path (absolute or relative to the include path) - */ - public function addClassPath($class, $path) - { - $this->classes[$class] = $path; - } + /** + * Sets the path for a list of classes. + * + * @param array $classMap An associative array $className => $classPath + */ + public function addClassPaths($classMap) + { + $this->classes = array_merge($this->classes, $classMap); + } - /** - * Returns the path where a particular class can be found. - * - * @param string $class A PHP class name - * - * @return string|null A path (absolute or relative to the include path) - */ - public function getClassPath($class) - { - return isset($this->classes[$class]) ? $this->classes[$class] : null; - } + /** + * Sets the path for a particular class. + * + * @param string $class A PHP class name + * @param string $path A path (absolute or relative to the include path) + */ + public function addClassPath($class, $path) + { + $this->classes[$class] = $path; + } - /** - * Handles autoloading of classes that have been registered in this instance - * - * @param string $class A class name. - * - * @return boolean Returns true if the class has been loaded - */ - public function autoload($class) - { - if (isset($this->classes[$class])) { - require $this->classes[$class]; - return true; - } - return false; - } + /** + * Returns the path where a particular class can be found. + * + * @param string $class A PHP class name + * + * @return string|null A path (absolute or relative to the include path) + */ + public function getClassPath($class) + { + return isset($this->classes[$class]) ? $this->classes[$class] : null; + } + + /** + * Handles autoloading of classes that have been registered in this instance + * + * @param string $class A class name. + * + * @return boolean Returns true if the class has been loaded + */ + public function autoload($class) + { + if (isset($this->classes[$class])) { + require $this->classes[$class]; + + return true; + } + // fallback for classes defined with leading backslash + if (strpos($class, '\\') === 0) { + $class = substr($class, 1); + + return $this->autoload($class); + } + + return false; + } } diff --git a/airtime_mvc/library/propel/runtime/lib/util/PropelColumnTypes.php b/airtime_mvc/library/propel/runtime/lib/util/PropelColumnTypes.php index e23c6f350..046a90b10 100644 --- a/airtime_mvc/library/propel/runtime/lib/util/PropelColumnTypes.php +++ b/airtime_mvc/library/propel/runtime/lib/util/PropelColumnTypes.php @@ -14,75 +14,82 @@ * THIS CLASS MUST BE KEPT UP-TO-DATE WITH THE MORE EXTENSIVE GENERATOR VERSION OF THIS CLASS. * * @author Hans Lellelid (Propel) - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.util */ class PropelColumnTypes { - const - CHAR = "CHAR", - VARCHAR = "VARCHAR", - LONGVARCHAR = "LONGVARCHAR", - CLOB = "CLOB", - CLOB_EMU = "CLOB_EMU", - NUMERIC = "NUMERIC", - DECIMAL = "DECIMAL", - TINYINT = "TINYINT", - SMALLINT = "SMALLINT", - INTEGER = "INTEGER", - BIGINT = "BIGINT", - REAL = "REAL", - FLOAT = "FLOAT", - DOUBLE = "DOUBLE", - BINARY = "BINARY", - VARBINARY = "VARBINARY", - LONGVARBINARY = "LONGVARBINARY", - BLOB = "BLOB", - DATE = "DATE", - TIME = "TIME", - TIMESTAMP = "TIMESTAMP", - BU_DATE = "BU_DATE", - BU_TIMESTAMP = "BU_TIMESTAMP", - BOOLEAN = "BOOLEAN", - BOOLEAN_EMU = "BOOLEAN_EMU"; + const + CHAR = "CHAR", + VARCHAR = "VARCHAR", + LONGVARCHAR = "LONGVARCHAR", + CLOB = "CLOB", + CLOB_EMU = "CLOB_EMU", + NUMERIC = "NUMERIC", + DECIMAL = "DECIMAL", + TINYINT = "TINYINT", + SMALLINT = "SMALLINT", + INTEGER = "INTEGER", + BIGINT = "BIGINT", + REAL = "REAL", + FLOAT = "FLOAT", + DOUBLE = "DOUBLE", + BINARY = "BINARY", + VARBINARY = "VARBINARY", + LONGVARBINARY = "LONGVARBINARY", + BLOB = "BLOB", + DATE = "DATE", + TIME = "TIME", + TIMESTAMP = "TIMESTAMP", + BU_DATE = "BU_DATE", + BU_TIMESTAMP = "BU_TIMESTAMP", + BOOLEAN = "BOOLEAN", + BOOLEAN_EMU = "BOOLEAN_EMU", + OBJECT = "OBJECT", + PHP_ARRAY = "ARRAY", + ENUM = "ENUM"; - private static $propelToPdoMap = array( - self::CHAR => PDO::PARAM_STR, - self::VARCHAR => PDO::PARAM_STR, - self::LONGVARCHAR => PDO::PARAM_STR, - self::CLOB => PDO::PARAM_LOB, - self::CLOB_EMU => PDO::PARAM_STR, - self::NUMERIC => PDO::PARAM_STR, - self::DECIMAL => PDO::PARAM_STR, - self::TINYINT => PDO::PARAM_INT, - self::SMALLINT => PDO::PARAM_INT, - self::INTEGER => PDO::PARAM_INT, - self::BIGINT => PDO::PARAM_STR, - self::REAL => PDO::PARAM_STR, - self::FLOAT => PDO::PARAM_STR, - self::DOUBLE => PDO::PARAM_STR, - self::BINARY => PDO::PARAM_STR, - self::VARBINARY => PDO::PARAM_STR, - self::LONGVARBINARY => PDO::PARAM_STR, - self::BLOB => PDO::PARAM_LOB, - self::DATE => PDO::PARAM_STR, - self::TIME => PDO::PARAM_STR, - self::TIMESTAMP => PDO::PARAM_STR, - self::BU_DATE => PDO::PARAM_STR, - self::BU_TIMESTAMP => PDO::PARAM_STR, - self::BOOLEAN => PDO::PARAM_BOOL, - self::BOOLEAN_EMU => PDO::PARAM_INT, - ); - - /** - * Resturns the PDO type (PDO::PARAM_* constant) value for the Propel type provided. - * @param string $propelType - * @return int - */ - public static function getPdoType($propelType) - { - return self::$propelToPdoMap[$propelType]; - } + private static $propelToPdoMap = array( + self::CHAR => PDO::PARAM_STR, + self::VARCHAR => PDO::PARAM_STR, + self::LONGVARCHAR => PDO::PARAM_STR, + self::CLOB => PDO::PARAM_LOB, + self::CLOB_EMU => PDO::PARAM_STR, + self::NUMERIC => PDO::PARAM_STR, + self::DECIMAL => PDO::PARAM_STR, + self::TINYINT => PDO::PARAM_INT, + self::SMALLINT => PDO::PARAM_INT, + self::INTEGER => PDO::PARAM_INT, + self::BIGINT => PDO::PARAM_STR, + self::REAL => PDO::PARAM_STR, + self::FLOAT => PDO::PARAM_STR, + self::DOUBLE => PDO::PARAM_STR, + self::BINARY => PDO::PARAM_STR, + self::VARBINARY => PDO::PARAM_STR, + self::LONGVARBINARY => PDO::PARAM_STR, + self::BLOB => PDO::PARAM_LOB, + self::DATE => PDO::PARAM_STR, + self::TIME => PDO::PARAM_STR, + self::TIMESTAMP => PDO::PARAM_STR, + self::BU_DATE => PDO::PARAM_STR, + self::BU_TIMESTAMP => PDO::PARAM_STR, + self::BOOLEAN => PDO::PARAM_BOOL, + self::BOOLEAN_EMU => PDO::PARAM_INT, + self::OBJECT => PDO::PARAM_STR, + self::PHP_ARRAY => PDO::PARAM_STR, + self::ENUM => PDO::PARAM_INT, + ); + /** + * Returns the PDO type (PDO::PARAM_* constant) value for the Propel type provided. + * + * @param string $propelType + * + * @return int + */ + public static function getPdoType($propelType) + { + return self::$propelToPdoMap[$propelType]; + } } diff --git a/airtime_mvc/library/propel/runtime/lib/util/PropelConditionalProxy.php b/airtime_mvc/library/propel/runtime/lib/util/PropelConditionalProxy.php index e153760fe..dada7bd5a 100644 --- a/airtime_mvc/library/propel/runtime/lib/util/PropelConditionalProxy.php +++ b/airtime_mvc/library/propel/runtime/lib/util/PropelConditionalProxy.php @@ -28,44 +28,111 @@ * @see Criteria * * @author Francois Zaninotto - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.util */ class PropelConditionalProxy { - protected $mainObject; - - public function __construct($mainObject) - { - $this->mainObject = $mainObject; - } - - public function _if() - { - throw new PropelException('_if() statements cannot be nested'); - } - - public function _elseif($cond) - { - if($cond) { - return $this->mainObject; - } else { - return $this; - } - } - - public function _else() - { - return $this->mainObject; - } - - public function _endif() - { - return $this->mainObject; - } - - public function __call($name, $arguments) - { - return $this; - } -} \ No newline at end of file + protected $criteria; + protected $parent; + protected $state; + protected $wasTrue; + protected $parentState; + + public function __construct($criteria, $cond, $proxy = null) + { + $this->criteria = $criteria; + $this->wasTrue = false; + $this->setConditionalState($cond); + $this->parent = $proxy; + + if (is_null($proxy)) { + $this->parentState = true; + } else { + $this->parentState = $proxy->getConditionalState(); + } + } + + /** + * Returns a new level PropelConditionalProxy instance. + * Allows for conditional statements in a fluid interface. + * + * @param bool $cond + * + * @return PropelConditionalProxy + */ + public function _if($cond) + { + return $this->criteria->_if($cond); + } + + /** + * Allows for conditional statements in a fluid interface. + * + * @param bool $cond ignored + * + * @return PropelConditionalProxy + */ + public function _elseif($cond) + { + return $this->setConditionalState(!$this->wasTrue && $cond); + } + + /** + * Allows for conditional statements in a fluid interface. + * + * @return PropelConditionalProxy + */ + public function _else() + { + return $this->setConditionalState(!$this->state && !$this->wasTrue); + } + + /** + * Returns the parent object + * Allows for conditional statements in a fluid interface. + * + * @return PropelConditionalProxy|Criteria + */ + public function _endif() + { + return $this->criteria->_endif(); + } + + /** + * return the current conditional status + * + * @return boolean + */ + protected function getConditionalState() + { + return $this->state && $this->parentState; + } + + protected function setConditionalState($cond) + { + $this->state = (bool) $cond; + $this->wasTrue = $this->wasTrue || $this->state; + + return $this->getCriteriaOrProxy(); + } + + public function getParentProxy() + { + return $this->parent; + } + + public function getCriteriaOrProxy() + { + if ($this->state && $this->parentState) { + return $this->criteria; + } + + return $this; + } + + public function __call($name, $arguments) + { + return $this; + } +} diff --git a/airtime_mvc/library/propel/runtime/lib/util/PropelDateTime.php b/airtime_mvc/library/propel/runtime/lib/util/PropelDateTime.php index cfa1276dd..90f9629ae 100644 --- a/airtime_mvc/library/propel/runtime/lib/util/PropelDateTime.php +++ b/airtime_mvc/library/propel/runtime/lib/util/PropelDateTime.php @@ -12,7 +12,7 @@ * DateTime subclass which supports serialization. * * Currently Propel is not using this for storing date/time objects - * within model objeects; however, we are keeping it in the repository + * within model objects; however, we are keeping it in the repository * because it is useful if you want to store a DateTime object in a session. * * @author Alan Pinstein @@ -23,54 +23,104 @@ class PropelDateTime extends DateTime { - /** - * A string representation of the date, for serialization. - * @var string - */ - private $dateString; + /** + * A string representation of the date, for serialization. + * + * @var string + */ + private $dateString; - /** - * A string representation of the time zone, for serialization. - * @var string - */ - private $tzString; + /** + * A string representation of the time zone, for serialization. + * + * @var string + */ + private $tzString; - /** - * Convenience method to enable a more fluent API. - * @param string $date Date/time value. - * @param DateTimeZone $tz (optional) timezone - */ - public static function newInstance($date, DateTimeZone $tz = null) - { - if ($tz) { - return new DateTime($date, $tz); - } else { - return new DateTime($date); - } - } + /** + * Factory method to get a DateTime object from a temporal input + * + * @param mixed $value The value to convert (can be a string, a timestamp, or another DateTime) + * @param DateTimeZone $timeZone (optional) timezone + * @param string $dateTimeClass The class of the object to create, defaults to DateTime + * + * @return mixed null, or an instance of $dateTimeClass + * + * @throws PropelException + */ + public static function newInstance($value, DateTimeZone $timeZone = null, $dateTimeClass = 'DateTime') + { + if ($value instanceof DateTime) { + return $value; + } + if ($value === null || $value === '') { + // '' is seen as NULL for temporal objects + // because DateTime('') == DateTime('now') -- which is unexpected + return null; + } + try { + if (self::isTimestamp($value)) { // if it's a unix timestamp + $dateTimeObject = new $dateTimeClass('@' . $value, new DateTimeZone('UTC')); + // timezone must be explicitly specified and then changed + // because of a DateTime bug: http://bugs.php.net/bug.php?id=43003 + $dateTimeObject->setTimeZone(new DateTimeZone(date_default_timezone_get())); + } else { + if ($timeZone === null) { + // stupid DateTime constructor signature + $dateTimeObject = new $dateTimeClass($value); + } else { + $dateTimeObject = new $dateTimeClass($value, $timeZone); + } + } + } catch (Exception $e) { + throw new PropelException('Error parsing date/time value: ' . var_export($value, true), $e); + } - /** - * PHP "magic" function called when object is serialized. - * Sets an internal property with the date string and returns properties - * of class that should be serialized. - * @return array string[] - */ - function __sleep() - { - // We need to use a string without a time zone, due to - // PHP bug: http://bugs.php.net/bug.php?id=40743 - $this->dateString = $this->format('Y-m-d H:i:s'); - $this->tzString = $this->getTimeZone()->getName(); - return array('dateString', 'tzString'); - } + return $dateTimeObject; + } - /** - * PHP "magic" function called when object is restored from serialized state. - * Calls DateTime constructor with previously stored string value of date. - */ - function __wakeup() - { - parent::__construct($this->dateString, new DateTimeZone($this->tzString)); - } + public static function isTimestamp($value) + { + if (!is_numeric($value)) { + return false; + } + $stamp = strtotime($value); + + if (false === $stamp) { + return true; + } + + $month = date('m', $value); + $day = date('d', $value); + $year = date('Y', $value); + + return checkdate($month, $day, $year); + } + + /** + * PHP "magic" function called when object is serialized. + * Sets an internal property with the date string and returns properties + * of class that should be serialized. + * + * @return array string[] + */ + public function __sleep() + { + // We need to use a string without a time zone, due to + // PHP bug: http://bugs.php.net/bug.php?id=40743 + $this->dateString = $this->format('Y-m-d H:i:s'); + $this->tzString = $this->getTimeZone()->getName(); + + return array('dateString', 'tzString'); + } + + /** + * PHP "magic" function called when object is restored from serialized state. + * Calls DateTime constructor with previously stored string value of date. + */ + public function __wakeup() + { + parent::__construct($this->dateString, new DateTimeZone($this->tzString)); + } } diff --git a/airtime_mvc/library/propel/runtime/lib/util/PropelModelPager.php b/airtime_mvc/library/propel/runtime/lib/util/PropelModelPager.php index 5236ebbd5..e632ab6e9 100644 --- a/airtime_mvc/library/propel/runtime/lib/util/PropelModelPager.php +++ b/airtime_mvc/library/propel/runtime/lib/util/PropelModelPager.php @@ -11,339 +11,400 @@ /** * Implements a pager based on a ModelCriteria * The code from this class heavily borrows from symfony's sfPager class - * + * * @author Fabien Potencier * @author François Zaninotto - * @version $Revision: 1665 $ + * @version $Revision$ * @package propel.runtime.query */ class PropelModelPager implements IteratorAggregate, Countable { - protected - $query = null, - $page = 1, - $maxPerPage = 10, - $lastPage = 1, - $nbResults = 0, - $objects = null, - $parameters = array(), - $currentMaxLink = 1, - $parameterHolder = null, - $maxRecordLimit = false, - $results = null, - $resultsCounter = 0; + protected + $query = null, + $page = 1, + $maxPerPage = 10, + $lastPage = 1, + $nbResults = 0, + $objects = null, + $parameters = array(), + $currentMaxLink = 1, + $parameterHolder = null, + $maxRecordLimit = false, + $results = null, + $resultsCounter = 0, + $con = null; - public function __construct(Criteria $query, $maxPerPage = 10) - { - $this->setQuery($query); - $this->setMaxPerPage($maxPerPage); - } - - public function setQuery(Criteria $query) - { - $this->query = $query; - } - - public function getQuery() - { - return $this->query; - } + public function __construct(ModelCriteria $query, $maxPerPage = 10) + { + $this->setQuery($query); + $this->setMaxPerPage($maxPerPage); + } - public function init() - { - $hasMaxRecordLimit = ($this->getMaxRecordLimit() !== false); - $maxRecordLimit = $this->getMaxRecordLimit(); + public function setQuery(ModelCriteria $query) + { + $this->query = $query; + } - $qForCount = clone $this->getQuery(); - $count = $qForCount - ->offset(0) - ->limit(0) - ->count(); + public function getQuery() + { + return $this->query; + } - $this->setNbResults($hasMaxRecordLimit ? min($count, $maxRecordLimit) : $count); + public function init($con = null) + { + $this->con = $con; + $hasMaxRecordLimit = ($this->getMaxRecordLimit() !== false); + $maxRecordLimit = $this->getMaxRecordLimit(); - $q = $this->getQuery() - ->offset(0) - ->limit(0); + $qForCount = clone $this->getQuery(); + $count = $qForCount + ->offset(0) + ->limit(0) + ->count($this->con); - if (($this->getPage() == 0 || $this->getMaxPerPage() == 0)) { - $this->setLastPage(0); - } else { - $this->setLastPage(ceil($this->getNbResults() / $this->getMaxPerPage())); + $this->setNbResults($hasMaxRecordLimit ? min($count, $maxRecordLimit) : $count); - $offset = ($this->getPage() - 1) * $this->getMaxPerPage(); - $q->offset($offset); + $q = $this->getQuery() + ->offset(0) + ->limit(0); - if ($hasMaxRecordLimit) { - $maxRecordLimit = $maxRecordLimit - $offset; - if ($maxRecordLimit > $this->getMaxPerPage()) { - $q->limit($this->getMaxPerPage()); - } else { - $q->limit($maxRecordLimit); - } - } else { - $q->limit($this->getMaxPerPage()); - } - } - } + if (($this->getPage() == 0 || $this->getMaxPerPage() == 0)) { + $this->setLastPage(0); + } else { + $this->setLastPage((int) ceil($this->getNbResults() / $this->getMaxPerPage())); - /** - * Get the collection of results in the page - * - * @return PropelObjectCollection A collection of results - */ - public function getResults() - { - if (null === $this->results) { - $this->results = $this->getQuery() - ->setFormatter(ModelCriteria::FORMAT_OBJECT) - ->find(); - } - return $this->results; - } + $offset = ($this->getPage() - 1) * $this->getMaxPerPage(); + $q->offset($offset); - public function getCurrentMaxLink() - { - return $this->currentMaxLink; - } + if ($hasMaxRecordLimit) { + $maxRecordLimit = $maxRecordLimit - $offset; + if ($maxRecordLimit > $this->getMaxPerPage()) { + $q->limit($this->getMaxPerPage()); + } else { + $q->limit($maxRecordLimit); + } + } else { + $q->limit($this->getMaxPerPage()); + } + } + } - public function getMaxRecordLimit() - { - return $this->maxRecordLimit; - } + /** + * Get the collection of results in the page + * + * @return PropelCollection A collection of results + */ + public function getResults() + { + if (null === $this->results) { + $this->results = $this->getQuery() + ->find($this->con); + } - public function setMaxRecordLimit($limit) - { - $this->maxRecordLimit = $limit; - } + return $this->results; + } - public function getLinks($nb_links = 5) - { - $links = array(); - $tmp = $this->page - floor($nb_links / 2); - $check = $this->lastPage - $nb_links + 1; - $limit = ($check > 0) ? $check : 1; - $begin = ($tmp > 0) ? (($tmp > $limit) ? $limit : $tmp) : 1; + public function getCurrentMaxLink() + { + return $this->currentMaxLink; + } - $i = (int) $begin; - while (($i < $begin + $nb_links) && ($i <= $this->lastPage)) { - $links[] = $i++; - } + public function getMaxRecordLimit() + { + return $this->maxRecordLimit; + } - $this->currentMaxLink = count($links) ? $links[count($links) - 1] : 1; + public function setMaxRecordLimit($limit) + { + $this->maxRecordLimit = $limit; + } - return $links; - } - - /** - * Test whether the number of results exceeds the max number of results per page - * - * @return boolean true if the pager displays only a subset of the results - */ - public function haveToPaginate() - { - return (($this->getMaxPerPage() != 0) && ($this->getNbResults() > $this->getMaxPerPage())); - } + public function getLinks($nb_links = 5) + { + $links = array(); + $tmp = $this->page - floor($nb_links / 2); + $check = $this->lastPage - $nb_links + 1; + $limit = ($check > 0) ? $check : 1; + $begin = ($tmp > 0) ? (($tmp > $limit) ? $limit : $tmp) : 1; - /** - * Get the index of the first element in the page - * Returns 1 on the first page, $maxPerPage +1 on the second page, etc - * - * @return int - */ - public function getFirstIndex() - { - if ($this->page == 0) { - return 1; - } else { - return ($this->page - 1) * $this->maxPerPage + 1; - } - } + $i = (int) $begin; + while (($i < $begin + $nb_links) && ($i <= $this->lastPage)) { + $links[] = $i++; + } - /** - * Get the index of the last element in the page - * Always less than or eaqual to $maxPerPage - * - * @return int - */ - public function getLastIndex() - { - if ($this->page == 0) { - return $this->nbResults; - } else { - if (($this->page * $this->maxPerPage) >= $this->nbResults) { - return $this->nbResults; - } else { - return ($this->page * $this->maxPerPage); - } - } - } + $this->currentMaxLink = count($links) ? $links[count($links) - 1] : 1; - /** - * Get the total number of results of the query - * This can be greater than $maxPerPage - * - * @return int - */ - public function getNbResults() - { - return $this->nbResults; - } + return $links; + } - /** - * Set the total number of results of the query - * - * @param int $nb - */ - protected function setNbResults($nb) - { - $this->nbResults = $nb; - } + /** + * Test whether the number of results exceeds the max number of results per page + * + * @return boolean true if the pager displays only a subset of the results + */ + public function haveToPaginate() + { + return (($this->getMaxPerPage() != 0) && ($this->getNbResults() > $this->getMaxPerPage())); + } - /** - * Check whether the current page is the first page - * - * @return boolean true if the current page is the first page - */ - public function isFirstPage() - { - return $this->getPage() == $this->getFirstPage(); - } + /** + * Get the index of the first element in the page + * Returns 1 on the first page, $maxPerPage +1 on the second page, etc + * + * @return int + */ + public function getFirstIndex() + { + if ($this->page == 0) { + return 1; + } else { + return ($this->page - 1) * $this->maxPerPage + 1; + } + } - /** - * Get the number of the first page - * - * @return int Always 1 - */ - public function getFirstPage() - { - return 1; - } + /** + * Get the index of the last element in the page + * Always less than or equal to $maxPerPage + * + * @return int + */ + public function getLastIndex() + { + if ($this->page == 0) { + return $this->nbResults; + } else { + if (($this->page * $this->maxPerPage) >= $this->nbResults) { + return $this->nbResults; + } else { + return ($this->page * $this->maxPerPage); + } + } + } - /** - * Check whether the current page is the last page - * - * @return boolean true if the current page is the last page - */ - public function isLastPage() - { - return $this->getPage() == $this->getLastPage(); - } + /** + * Get the total number of results of the query + * This can be greater than $maxPerPage + * + * @return int + */ + public function getNbResults() + { + return $this->nbResults; + } - /** - * Get the number of the last page - * - * @return int - */ - public function getLastPage() - { - return $this->lastPage; - } + /** + * Set the total number of results of the query + * + * @param int $nb + */ + protected function setNbResults($nb) + { + $this->nbResults = $nb; + } - /** - * Set the number of the first page - * - * @param int $page - */ - protected function setLastPage($page) - { - $this->lastPage = $page; - if ($this->getPage() > $page) { - $this->setPage($page); - } - } + /** + * Check whether the current page is the first page + * + * @return boolean true if the current page is the first page + */ + public function isFirstPage() + { + return $this->getPage() == $this->getFirstPage(); + } - /** - * Get the number of the current page - * - * @return int - */ - public function getPage() - { - return $this->page; - } + /** + * Get the number of the first page + * + * @return int Always 1 + */ + public function getFirstPage() + { + return 1; + } - /** - * Set the number of the current page - * - * @param int $page - */ - public function setPage($page) - { - $this->page = intval($page); - if ($this->page <= 0) { - // set first page, which depends on a maximum set - $this->page = $this->getMaxPerPage() ? 1 : 0; - } - } - - /** - * Get the number of the next page - * - * @return int - */ - public function getNextPage() - { - return min($this->getPage() + 1, $this->getLastPage()); - } + /** + * Check whether the current page is the last page + * + * @return boolean true if the current page is the last page + */ + public function isLastPage() + { + return $this->getPage() == $this->getLastPage(); + } - /** - * Get the number of the previous page - * - * @return int - */ - public function getPreviousPage() - { - return max($this->getPage() - 1, $this->getFirstPage()); - } + /** + * Get the number of the last page + * + * @return int + */ + public function getLastPage() + { + return $this->lastPage; + } - /** - * Get the maximum number results per page - * - * @return int - */ - public function getMaxPerPage() - { - return $this->maxPerPage; - } + /** + * Set the number of the first page + * + * @param int $page + */ + protected function setLastPage($page) + { + $this->lastPage = $page; + if ($this->getPage() > $page) { + $this->setPage($page); + } + } - /** - * Set the maximum number results per page - * - * @param int $max - */ - public function setMaxPerPage($max) - { - if ($max > 0) { - $this->maxPerPage = $max; - if ($this->page == 0) { - $this->page = 1; - } - } else if ($max == 0) { - $this->maxPerPage = 0; - $this->page = 0; - } else { - $this->maxPerPage = 1; - if ($this->page == 0) { - $this->page = 1; - } - } - } - - public function getIterator() - { - return $this->getResults()->getIterator(); - } + /** + * Get the number of the current page + * + * @return int + */ + public function getPage() + { + return $this->page; + } - /** - * Returns the total number of results. - * - * @see Countable - * @return int - */ - public function count() - { - return $this->getNbResults(); - } + /** + * Set the number of the current page + * + * @param int $page + */ + public function setPage($page) + { + $this->page = intval($page); + if ($this->page <= 0) { + // set first page, which depends on a maximum set + $this->page = $this->getMaxPerPage() ? 1 : 0; + } + } + /** + * Get the number of the next page + * + * @return int + */ + public function getNextPage() + { + return min($this->getPage() + 1, $this->getLastPage()); + } + + /** + * Get the number of the previous page + * + * @return int + */ + public function getPreviousPage() + { + return max($this->getPage() - 1, $this->getFirstPage()); + } + + /** + * Get the maximum number results per page + * + * @return int + */ + public function getMaxPerPage() + { + return $this->maxPerPage; + } + + /** + * Set the maximum number results per page + * + * @param int $max + */ + public function setMaxPerPage($max) + { + if ($max > 0) { + $this->maxPerPage = $max; + if ($this->page == 0) { + $this->page = 1; + } + } elseif ($max == 0) { + $this->maxPerPage = 0; + $this->page = 0; + } else { + $this->maxPerPage = 1; + if ($this->page == 0) { + $this->page = 1; + } + } + } + + /** + * Check whether the internal pointer is at the beginning of the list + * + * @see PropelCollection + * + * @return boolean + */ + public function isFirst() + { + return $this->getResults()->isFirst(); + } + + /** + * Check whether the internal pointer is at the end of the list + * + * @see PropelCollection + * + * @return boolean + */ + public function isLast() + { + return $this->getResults()->isLast(); + } + + /** + * Check if the collection is empty + * + * @see PropelCollection + * + * @return boolean + */ + public function isEmpty() + { + return $this->getResults()->isEmpty(); + } + + /** + * Check if the current index is an odd integer + * + * @see PropelCollection + * + * @return boolean + */ + public function isOdd() + { + return $this->getResults()->isOdd(); + } + + /** + * Check if the current index is an even integer + * + * @see PropelCollection + * + * @return boolean + */ + public function isEven() + { + return $this->getResults()->isEven(); + } + + public function getIterator() + { + return $this->getResults()->getIterator(); + } + + /** + * Returns the total number of results. + * + * @see Countable + * @return int + */ + public function count() + { + return $this->getNbResults(); + } } diff --git a/airtime_mvc/library/propel/runtime/lib/util/PropelPager.php b/airtime_mvc/library/propel/runtime/lib/util/PropelPager.php index 8fefdbc0a..4c6909853 100644 --- a/airtime_mvc/library/propel/runtime/lib/util/PropelPager.php +++ b/airtime_mvc/library/propel/runtime/lib/util/PropelPager.php @@ -86,512 +86,540 @@ * * @author Rob Halff * @author Niklas Närhinen - * @version $Revision: 1612 $ + * @version $Revision$ * @copyright Copyright (c) 2004 Rob Halff: LGPL - See LICENCE * @package propel.runtime.util */ class PropelPager implements Countable, Iterator { - private $recordCount; - private $pages; - private $peerClass; - private $peerSelectMethod; - private $peerCountMethod; - private $criteria; - private $countCriteria; - private $page; - private $rs = null; - - //Iterator vars - private $currentKey = 0; + private $recordCount; + private $pages; + private $peerClass; + private $peerSelectMethod; + private $peerCountMethod; + private $criteria; + private $countCriteria; + private $page; + private $rs = null; - /** @var int Start row (offset) */ - protected $start = 0; + //Iterator vars + private $currentKey = 0; - /** @var int Max rows to return (0 means all) */ - protected $max = 0; + /** @var int Start row (offset) */ + protected $start = 0; - /** - * Create a new Propel Pager. - * @param Criteria $c - * @param string $peerClass The name of the static Peer class. - * @param string $peerSelectMethod The name of the static method for selecting content from the Peer class. - * @param int $page The current page (1-based). - * @param int $rowsPerPage The number of rows that should be displayed per page. - */ - public function __construct($c = null, $peerClass = null, $peerSelectMethod = null, $page = 1, $rowsPerPage = 25) - { - if (!isset($c)) { - $c = new Criteria(); - } - $this->setCriteria($c); - $this->setPeerClass($peerClass); - $this->setPeerSelectMethod($peerSelectMethod); - $this->guessPeerCountMethod(); - $this->setPage($page); - $this->setRowsPerPage($rowsPerPage); - } + /** @var int Max rows to return (0 means all) */ + protected $max = 0; - /** - * Set the criteria for this pager. - * @param Criteria $c - * @return void - */ - public function setCriteria(Criteria $c) - { - $this->criteria = $c; - } + /** + * Create a new Propel Pager. + * + * @param Criteria $c + * @param string $peerClass The name of the static Peer class. + * @param string $peerSelectMethod The name of the static method for selecting content from the Peer class. + * @param int $page The current page (1-based). + * @param int $rowsPerPage The number of rows that should be displayed per page. + */ + public function __construct($c = null, $peerClass = null, $peerSelectMethod = null, $page = 1, $rowsPerPage = 25) + { + if (!isset($c)) { + $c = new Criteria(); + } + $this->setCriteria($c); + $this->setPeerClass($peerClass); + $this->setPeerSelectMethod($peerSelectMethod); + $this->guessPeerCountMethod(); + $this->setPage($page); + $this->setRowsPerPage($rowsPerPage); + } - /** - * Return the Criteria object for this pager. - * @return Criteria - */ - public function getCriteria() - { - return $this->criteria; - } + /** + * Set the criteria for this pager. + * + * @param Criteria $c + * + * @return void + */ + public function setCriteria(Criteria $c) + { + $this->criteria = $c; + } - /** - * Set the Peer Classname - * - * @param string $class - * @return void - */ - public function setPeerClass($class) - { - $this->peerClass = $class; - } + /** + * Return the Criteria object for this pager. + * + * @return Criteria + */ + public function getCriteria() + { + return $this->criteria; + } - /** - * Return the Peer Classname. - * @return string - */ - public function getPeerClass() - { - return $this->peerClass; - } + /** + * Set the Peer Classname + * + * @param string $class + * + * @return void + */ + public function setPeerClass($class) + { + $this->peerClass = $class; + } - /** - * Set the Peer select method. - * This exists for legacy support, please use setPeerSelectMethod(). - * @param string $method The name of the static method to call on the Peer class. - * @return void - * @see setPeerSelectMethod() - * @deprecated - */ - public function setPeerMethod($method) - { - $this->setPeerSelectMethod($method); - } + /** + * Return the Peer Classname. + * + * @return string + */ + public function getPeerClass() + { + return $this->peerClass; + } - /** - * Return the Peer select method. - * This exists for legacy support, please use getPeerSelectMethod(). - * @return string - * @see getPeerSelectMethod() - * @deprecated - */ - public function getPeerMethod() - { - return $this->getPeerSelectMethod(); - } + /** + * Set the Peer select method. + * This exists for legacy support, please use setPeerSelectMethod(). + * + * @param string $method The name of the static method to call on the Peer class. + * + * @return void + * @see setPeerSelectMethod() + * @deprecated + */ + public function setPeerMethod($method) + { + $this->setPeerSelectMethod($method); + } - /** - * Set the Peer select method. - * - * @param string $method The name of the static method to call on the Peer class. - * @return void - */ - public function setPeerSelectMethod($method) - { - $this->peerSelectMethod = $method; - } + /** + * Return the Peer select method. + * This exists for legacy support, please use getPeerSelectMethod(). + * + * @return string + * @see getPeerSelectMethod() + * @deprecated + */ + public function getPeerMethod() + { + return $this->getPeerSelectMethod(); + } - /** - * Return the Peer select method. - * @return string - */ - public function getPeerSelectMethod() - { - return $this->peerSelectMethod; - } + /** + * Set the Peer select method. + * + * @param string $method The name of the static method to call on the Peer class. + * + * @return void + */ + public function setPeerSelectMethod($method) + { + $this->peerSelectMethod = $method; + } - /** - * Sets the Count method. - * This is set based on the Peer method, for example if Peer method is doSelectJoin*() then the - * count method will be doCountJoin*(). - * @param string $method The name of the static method to call on the Peer class. - */ - public function setPeerCountMethod($method) - { - $this->peerCountMethod = $method; - } + /** + * Return the Peer select method. + * + * @return string + */ + public function getPeerSelectMethod() + { + return $this->peerSelectMethod; + } - /** - * Return the Peer count method. - */ - public function getPeerCountMethod() - { - return $this->peerCountMethod; - } + /** + * Sets the Count method. + * This is set based on the Peer method, for example if Peer method is doSelectJoin*() then the + * count method will be doCountJoin*(). + * + * @param string $method The name of the static method to call on the Peer class. + */ + public function setPeerCountMethod($method) + { + $this->peerCountMethod = $method; + } - /** - * Guesses the Peer count method based on the select method. - */ - private function guessPeerCountMethod() - { - $selectMethod = $this->getPeerSelectMethod(); - if ($selectMethod == 'doSelect') { - $countMethod = 'doCount'; - } elseif ( ($pos = stripos($selectMethod, 'doSelectJoin')) === 0) { - $countMethod = 'doCount' . substr($selectMethod, strlen('doSelect')); - } else { - // we will fall back to doCount() if we don't understand the join - // method; however, it probably won't be accurate. Maybe triggering an error would - // be appropriate ... - $countMethod = 'doCount'; - } - $this->setPeerCountMethod($countMethod); - } + /** + * Return the Peer count method. + */ + public function getPeerCountMethod() + { + return $this->peerCountMethod; + } - /** - * Get the paged resultset - * - * @return mixed $rs - */ - public function getResult() - { - if (!isset($this->rs)) { - $this->doRs(); - } + /** + * Guesses the Peer count method based on the select method. + */ + private function guessPeerCountMethod() + { + $selectMethod = $this->getPeerSelectMethod(); + if ($selectMethod == 'doSelect') { + $countMethod = 'doCount'; + } elseif (($pos = stripos($selectMethod, 'doSelectJoin')) === 0) { + $countMethod = 'doCount' . substr($selectMethod, strlen('doSelect')); + } else { + // we will fall back to doCount() if we don't understand the join + // method; however, it probably won't be accurate. Maybe triggering an error would + // be appropriate ... + $countMethod = 'doCount'; + } + $this->setPeerCountMethod($countMethod); + } - return $this->rs; - } + /** + * Get the paged resultset + * + * @return mixed $rs + */ + public function getResult() + { + if (!isset($this->rs)) { + $this->doRs(); + } - /** - * Get the paged resultset - * - * Main method which creates a paged result set based on the criteria - * and the requested peer select method. - * - */ - private function doRs() - { - $this->criteria->setOffset($this->start); - $this->criteria->setLimit($this->max); - $this->rs = call_user_func(array($this->getPeerClass(), $this->getPeerSelectMethod()), $this->criteria); - } + return $this->rs; + } - /** - * Get the first page - * - * For now I can only think of returning 1 always. - * It should probably return 0 if there are no pages - * - * @return int 1 - */ - public function getFirstPage() - { - return '1'; - } + /** + * Get the paged resultset + * + * Main method which creates a paged result set based on the criteria + * and the requested peer select method. + * + */ + private function doRs() + { + $this->criteria->setOffset($this->start); + $this->criteria->setLimit($this->max); + $this->rs = call_user_func(array($this->getPeerClass(), $this->getPeerSelectMethod()), $this->criteria); + } - /** - * Convenience method to indicate whether current page is the first page. - * - * @return boolean - */ - public function atFirstPage() - { - return $this->getPage() == $this->getFirstPage(); - } + /** + * Get the first page + * + * For now I can only think of returning 1 always. + * It should probably return 0 if there are no pages + * + * @return int 1 + */ + public function getFirstPage() + { + return '1'; + } - /** - * Get last page - * - * @return int $lastPage - */ - public function getLastPage() - { - $totalPages = $this->getTotalPages(); - if ($totalPages == 0) { - return 1; - } else { - return $totalPages; - } - } + /** + * Convenience method to indicate whether current page is the first page. + * + * @return boolean + */ + public function atFirstPage() + { + return $this->getPage() == $this->getFirstPage(); + } - /** - * Convenience method to indicate whether current page is the last page. - * - * @return boolean - */ - public function atLastPage() - { - return $this->getPage() == $this->getLastPage(); - } + /** + * Get last page + * + * @return int $lastPage + */ + public function getLastPage() + { + $totalPages = $this->getTotalPages(); + if ($totalPages == 0) { + return 1; + } else { + return $totalPages; + } + } - /** - * get total pages - * - * @return int $this->pages - */ - public function getTotalPages() { - if (!isset($this->pages)) { - $recordCount = $this->getTotalRecordCount(); - if ($this->max > 0) { - $this->pages = ceil($recordCount/$this->max); - } else { - $this->pages = 0; - } - } - return $this->pages; - } + /** + * Convenience method to indicate whether current page is the last page. + * + * @return boolean + */ + public function atLastPage() + { + return $this->getPage() == $this->getLastPage(); + } - /** - * get an array of previous id's - * - * @param int $range - * @return array $links - */ - public function getPrevLinks($range = 5) - { - $total = $this->getTotalPages(); - $start = $this->getPage() - 1; - $end = $this->getPage() - $range; - $first = $this->getFirstPage(); - $links = array(); - for ($i=$start; $i>$end; $i--) { - if ($i < $first) { - break; - } - $links[] = $i; - } + /** + * get total pages + * + * @return int $this->pages + */ + public function getTotalPages() + { + if (!isset($this->pages)) { + $recordCount = $this->getTotalRecordCount(); + if ($this->max > 0) { + $this->pages = ceil($recordCount / $this->max); + } else { + $this->pages = 0; + } + } - return array_reverse($links); - } + return $this->pages; + } - /** - * get an array of next id's - * - * @param int $range - * @return array $links - */ - public function getNextLinks($range = 5) - { - $total = $this->getTotalPages(); - $start = $this->getPage() + 1; - $end = $this->getPage() + $range; - $last = $this->getLastPage(); - $links = array(); - for ($i=$start; $i<$end; $i++) { - if ($i > $last) { - break; - } - $links[] = $i; - } + /** + * get an array of previous id's + * + * @param int $range + * + * @return array $links + */ + public function getPrevLinks($range = 5) + { + $total = $this->getTotalPages(); + $start = $this->getPage() - 1; + $end = $this->getPage() - $range; + $first = $this->getFirstPage(); + $links = array(); + for ($i = $start; $i > $end; $i--) { + if ($i < $first) { + break; + } + $links[] = $i; + } - return $links; - } + return array_reverse($links); + } - /** - * Returns whether last page is complete - * - * @return bool Last page complete or not - */ - public function isLastPageComplete() - { - return !($this->getTotalRecordCount() % $this->max); - } + /** + * get an array of next id's + * + * @param int $range + * + * @return array $links + */ + public function getNextLinks($range = 5) + { + $total = $this->getTotalPages(); + $start = $this->getPage() + 1; + $end = $this->getPage() + $range; + $last = $this->getLastPage(); + $links = array(); + for ($i = $start; $i < $end; $i++) { + if ($i > $last) { + break; + } + $links[] = $i; + } - /** - * get previous id - * - * @return mixed $prev - */ - public function getPrev() { - if ($this->getPage() != $this->getFirstPage()) { - $prev = $this->getPage() - 1; - } else { - $prev = false; - } - return $prev; - } + return $links; + } - /** - * get next id - * - * @return mixed $next - */ - public function getNext() { - if ($this->getPage() != $this->getLastPage()) { - $next = $this->getPage() + 1; - } else { - $next = false; - } - return $next; - } + /** + * Returns whether last page is complete + * + * @return bool Last page complete or not + */ + public function isLastPageComplete() + { + return !($this->getTotalRecordCount() % $this->max); + } - /** - * Set the current page number (First page is 1). - * @param int $page - * @return void - */ - public function setPage($page) - { - $this->page = $page; - // (re-)calculate start rec - $this->calculateStart(); - } + /** + * get previous id + * + * @return mixed $prev + */ + public function getPrev() + { + if ($this->getPage() != $this->getFirstPage()) { + $prev = $this->getPage() - 1; + } else { + $prev = false; + } - /** - * Get current page. - * @return int - */ - public function getPage() - { - return $this->page; - } + return $prev; + } - /** - * Set the number of rows per page. - * @param int $r - */ - public function setRowsPerPage($r) - { - $this->max = $r; - // (re-)calculate start rec - $this->calculateStart(); - } + /** + * get next id + * + * @return mixed $next + */ + public function getNext() + { + if ($this->getPage() != $this->getLastPage()) { + $next = $this->getPage() + 1; + } else { + $next = false; + } - /** - * Get number of rows per page. - * @return int - */ - public function getRowsPerPage() - { - return $this->max; - } + return $next; + } - /** - * Calculate startrow / max rows based on current page and rows-per-page. - * @return void - */ - private function calculateStart() - { - $this->start = ( ($this->page - 1) * $this->max ); - } + /** + * Set the current page number (First page is 1). + * + * @param int $page + * + * @return void + */ + public function setPage($page) + { + $this->page = $page; + // (re-)calculate start rec + $this->calculateStart(); + } - /** - * Gets the total number of (un-LIMITed) records. - * - * This method will perform a query that executes un-LIMITed query. - * - * @return int Total number of records - disregarding page, maxrows, etc. - */ - public function getTotalRecordCount() - { + /** + * Get current page. + * + * @return int + */ + public function getPage() + { + return $this->page; + } - if (!isset($this->rs)) { - $this->doRs(); - } + /** + * Set the number of rows per page. + * + * @param int $r + */ + public function setRowsPerPage($r) + { + $this->max = $r; + // (re-)calculate start rec + $this->calculateStart(); + } - if (empty($this->recordCount)) { - $this->countCriteria = clone $this->criteria; - $this->countCriteria->setLimit(0); - $this->countCriteria->setOffset(0); + /** + * Get number of rows per page. + * + * @return int + */ + public function getRowsPerPage() + { + return $this->max; + } - $this->recordCount = call_user_func( - array( - $this->getPeerClass(), - $this->getPeerCountMethod() - ), - $this->countCriteria - ); + /** + * Calculate startrow / max rows based on current page and rows-per-page. + * + * @return void + */ + private function calculateStart() + { + $this->start = (($this->page - 1) * $this->max); + } - } + /** + * Gets the total number of (un-LIMITed) records. + * + * This method will perform a query that executes un-LIMITed query. + * + * @return int Total number of records - disregarding page, maxrows, etc. + */ + public function getTotalRecordCount() + { - return $this->recordCount; + if (!isset($this->rs)) { + $this->doRs(); + } - } + if (empty($this->recordCount)) { + $this->countCriteria = clone $this->criteria; + $this->countCriteria->setLimit(0); + $this->countCriteria->setOffset(0); - /** - * Sets the start row or offset. - * @param int $v - */ - public function setStart($v) - { - $this->start = $v; - } + $this->recordCount = call_user_func(array($this->getPeerClass(), $this->getPeerCountMethod()), $this->countCriteria); + } - /** - * Sets max rows (limit). - * @param int $v - * @return void - */ - public function setMax($v) - { - $this->max = $v; - } - - /** - * Returns the count of the current page's records - * @return int - */ - public function count() - { - return count($this->getResult()); - } - - /** - * Returns the current element of the iterator - * @return mixed - */ - public function current() - { - if (!isset($this->rs)) { - $this->doRs(); - } - return $this->rs[$this->currentKey]; - } - - /** - * Returns the current key of the iterator - * @return int - */ - public function key() - { - return $this->currentKey; - } - - /** - * Advances the iterator to the next element - * @return void - */ - public function next() - { - $this->currentKey++; - } - - /** - * Resets the iterator to the first element - * @return void - */ - public function rewind() - { - $this->currentKey = 0; - } - - /** - * Checks if the current key exists in the container - * @return boolean - */ - public function valid() - { - if (!isset($this->rs)) { - $this->doRs(); - } - return in_array($this->currentKey, array_keys($this->rs)); - } + return $this->recordCount; + } + /** + * Sets the start row or offset. + * + * @param int $v + */ + public function setStart($v) + { + $this->start = $v; + } + + /** + * Sets max rows (limit). + * + * @param int $v + * + * @return void + */ + public function setMax($v) + { + $this->max = $v; + } + + /** + * Returns the count of the current page's records + * + * @return int + */ + public function count() + { + return count($this->getResult()); + } + + /** + * Returns the current element of the iterator + * + * @return mixed + */ + public function current() + { + if (!isset($this->rs)) { + $this->doRs(); + } + + return $this->rs[$this->currentKey]; + } + + /** + * Returns the current key of the iterator + * + * @return int + */ + public function key() + { + return $this->currentKey; + } + + /** + * Advances the iterator to the next element + * + * @return void + */ + public function next() + { + $this->currentKey++; + } + + /** + * Resets the iterator to the first element + * + * @return void + */ + public function rewind() + { + $this->currentKey = 0; + } + + /** + * Checks if the current key exists in the container + * + * @return boolean + */ + public function valid() + { + if (!isset($this->rs)) { + $this->doRs(); + } + + return in_array($this->currentKey, array_keys($this->rs)); + } } diff --git a/airtime_mvc/library/propel/runtime/lib/validator/BasicValidator.php b/airtime_mvc/library/propel/runtime/lib/validator/BasicValidator.php index 5733e0bf8..a88d21591 100644 --- a/airtime_mvc/library/propel/runtime/lib/validator/BasicValidator.php +++ b/airtime_mvc/library/propel/runtime/lib/validator/BasicValidator.php @@ -16,20 +16,18 @@ * is valid. * * @author Michael Aichler - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.validator */ interface BasicValidator { - - /** - * Determine whether a value meets the criteria specified - * - * @param ValidatorMap $map A column map object for the column to be validated. - * @param string $str a String to be tested - * - * @return mixed TRUE if valid, error message otherwise - */ - public function isValid(ValidatorMap $map, $str); - + /** + * Determine whether a value meets the criteria specified + * + * @param ValidatorMap $map A column map object for the column to be validated. + * @param string $str a String to be tested + * + * @return mixed TRUE if valid, error message otherwise + */ + public function isValid(ValidatorMap $map, $str); } diff --git a/airtime_mvc/library/propel/runtime/lib/validator/MatchValidator.php b/airtime_mvc/library/propel/runtime/lib/validator/MatchValidator.php index a2890e9b5..924e6b845 100644 --- a/airtime_mvc/library/propel/runtime/lib/validator/MatchValidator.php +++ b/airtime_mvc/library/propel/runtime/lib/validator/MatchValidator.php @@ -34,35 +34,42 @@ * * @author Michael Aichler * @author Hans Lellelid - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.validator */ class MatchValidator implements BasicValidator { - /** - * Prepares the regular expression entered in the XML - * for use with preg_match(). - * @param string $exp - * @return string Prepared regular expession. - */ - private function prepareRegexp($exp) - { - // remove surrounding '/' marks so that they don't get escaped in next step - if ($exp{0} !== '/' || $exp{strlen($exp)-1} !== '/' ) { - $exp = '/' . $exp . '/'; - } + /** + * Prepares the regular expression entered in the XML + * for use with preg_match(). + * + * @param string $exp + * + * @return string Prepared regular expression. + */ + private function prepareRegexp($exp) + { + // remove surrounding '/' marks so that they don't get escaped in next step + if ($exp{0} !== '/' || $exp{strlen($exp) - 1} !== '/') { + $exp = '/' . $exp . '/'; + } - // if they did not escape / chars; we do that for them - $exp = preg_replace('/([^\\\])\/([^$])/', '$1\/$2', $exp); + // if they did not escape / chars; we do that for them + $exp = preg_replace('/([^\\\])\/([^$])/', '$1\/$2', $exp); - return $exp; - } + return $exp; + } - /** - * Whether the passed string matches regular expression. - */ - public function isValid (ValidatorMap $map, $str) - { - return (preg_match($this->prepareRegexp($map->getValue()), $str) != 0); - } + /** + * Whether the passed string matches regular expression. + * + * @param ValidatorMap $map + * @param string $str + * + * @return boolean + */ + public function isValid(ValidatorMap $map, $str) + { + return (preg_match($this->prepareRegexp($map->getValue()), $str) != 0); + } } diff --git a/airtime_mvc/library/propel/runtime/lib/validator/MaxLengthValidator.php b/airtime_mvc/library/propel/runtime/lib/validator/MaxLengthValidator.php index 286c82c7e..4e1f0f3c4 100644 --- a/airtime_mvc/library/propel/runtime/lib/validator/MaxLengthValidator.php +++ b/airtime_mvc/library/propel/runtime/lib/validator/MaxLengthValidator.php @@ -21,19 +21,26 @@ * * * - * + * * * * * @author Michael Aichler - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.validator */ class MaxLengthValidator implements BasicValidator { + /** + * @param ValidatorMap $map + * @param string $str + * + * @return boolean + */ + public function isValid(ValidatorMap $map, $str) + { + $len = function_exists('mb_strlen') ? mb_strlen($str) : strlen($str); - public function isValid (ValidatorMap $map, $str) - { - return strlen($str) <= intval($map->getValue()); - } + return $len <= intval($map->getValue()); + } } diff --git a/airtime_mvc/library/propel/runtime/lib/validator/MaxValueValidator.php b/airtime_mvc/library/propel/runtime/lib/validator/MaxValueValidator.php index b71294043..82a86ffac 100644 --- a/airtime_mvc/library/propel/runtime/lib/validator/MaxValueValidator.php +++ b/airtime_mvc/library/propel/runtime/lib/validator/MaxValueValidator.php @@ -23,21 +23,25 @@ * * * @author Michael Aichler - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.validator */ class MaxValueValidator implements BasicValidator { + /** + * @see BasicValidator::isValid() + * + * @param ValidatorMap $map + * @param mixed $value + * + * @return boolean + */ + public function isValid(ValidatorMap $map, $value) + { + if (is_null($value) == false && is_numeric($value) == true) { + return intval($value) <= intval($map->getValue()); + } - /** - * @see BasicValidator::isValid() - */ - public function isValid (ValidatorMap $map, $value) - { - if (is_null($value) == false && is_numeric($value) == true) { - return intval($value) <= intval($map->getValue()); - } - - return false; - } + return false; + } } diff --git a/airtime_mvc/library/propel/runtime/lib/validator/MinLengthValidator.php b/airtime_mvc/library/propel/runtime/lib/validator/MinLengthValidator.php index e5c034596..57875f33c 100644 --- a/airtime_mvc/library/propel/runtime/lib/validator/MinLengthValidator.php +++ b/airtime_mvc/library/propel/runtime/lib/validator/MinLengthValidator.php @@ -15,22 +15,28 @@ * * * - * + * * * * * @author Michael Aichler - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.validator */ class MinLengthValidator implements BasicValidator { + /** + * @see BasicValidator::isValid() + * + * @param ValidatorMap $map + * @param string $str + * + * @return boolean + */ + public function isValid(ValidatorMap $map, $str) + { + $len = function_exists('mb_strlen') ? mb_strlen($str) : strlen($str); - /** - * @see BasicValidator::isValid() - */ - public function isValid (ValidatorMap $map, $str) - { - return strlen($str) >= intval($map->getValue()); - } + return $len >= intval($map->getValue()); + } } diff --git a/airtime_mvc/library/propel/runtime/lib/validator/MinValueValidator.php b/airtime_mvc/library/propel/runtime/lib/validator/MinValueValidator.php index d58894663..bd73e69b5 100644 --- a/airtime_mvc/library/propel/runtime/lib/validator/MinValueValidator.php +++ b/airtime_mvc/library/propel/runtime/lib/validator/MinValueValidator.php @@ -23,21 +23,25 @@ * * * @author Michael Aichler - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.validator */ class MinValueValidator implements BasicValidator { + /** + * @see BasicValidator::isValid() + * + * @param ValidatorMap $map + * @param mixed $value + * + * @return boolean + */ + public function isValid(ValidatorMap $map, $value) + { + if (is_null($value) == false && is_numeric($value)) { + return intval($value) >= intval($map->getValue()); + } - /** - * @see BasicValidator::isValid() - */ - public function isValid (ValidatorMap $map, $value) - { - if (is_null($value) == false && is_numeric($value)) { - return intval($value) >= intval($map->getValue()); - } - - return false; - } + return false; + } } diff --git a/airtime_mvc/library/propel/runtime/lib/validator/NotMatchValidator.php b/airtime_mvc/library/propel/runtime/lib/validator/NotMatchValidator.php index f0f72998d..1adb6047f 100644 --- a/airtime_mvc/library/propel/runtime/lib/validator/NotMatchValidator.php +++ b/airtime_mvc/library/propel/runtime/lib/validator/NotMatchValidator.php @@ -26,41 +26,48 @@ * + * message="Please enter a valid email address." /> * * * * @author Michael Aichler * @author Hans Lellelid - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.validator */ class NotMatchValidator implements BasicValidator { - /** - * Prepares the regular expression entered in the XML - * for use with preg_match(). - * @param string $exp - * @return string Prepared regular expession. - */ - private function prepareRegexp($exp) - { - // remove surrounding '/' marks so that they don't get escaped in next step - if ($exp{0} !== '/' || $exp{strlen($exp)-1} !== '/' ) { - $exp = '/' . $exp . '/'; - } + /** + * Prepares the regular expression entered in the XML + * for use with preg_match(). + * + * @param string $exp + * + * @return string + */ + private function prepareRegexp($exp) + { + // remove surrounding '/' marks so that they don't get escaped in next step + if ($exp{0} !== '/' || $exp{strlen($exp) - 1} !== '/') { + $exp = '/' . $exp . '/'; + } - // if they did not escape / chars; we do that for them - $exp = preg_replace('/([^\\\])\/([^$])/', '$1\/$2', $exp); + // if they did not escape / chars; we do that for them + $exp = preg_replace('/([^\\\])\/([^$])/', '$1\/$2', $exp); - return $exp; - } + return $exp; + } - /** - * Whether the passed string matches regular expression. - */ - public function isValid (ValidatorMap $map, $str) - { - return (preg_match($this->prepareRegexp($map->getValue()), $str) == 0); - } + /** + * @see BasicValidator::isValid() + * + * @param ValidatorMap $map + * @param string $str + * + * @return boolean + */ + public function isValid(ValidatorMap $map, $str) + { + return (preg_match($this->prepareRegexp($map->getValue()), $str) == 0); + } } diff --git a/airtime_mvc/library/propel/runtime/lib/validator/RequiredValidator.php b/airtime_mvc/library/propel/runtime/lib/validator/RequiredValidator.php index 57ab63a6f..d125fb48c 100644 --- a/airtime_mvc/library/propel/runtime/lib/validator/RequiredValidator.php +++ b/airtime_mvc/library/propel/runtime/lib/validator/RequiredValidator.php @@ -22,17 +22,21 @@ * * * @author Michael Aichler - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.validator */ class RequiredValidator implements BasicValidator { - - /** - * @see BasicValidator::isValid() - */ - public function isValid (ValidatorMap $map, $str) - { - return ($str !== null && $str !== ""); - } + /** + * @see BasicValidator::isValid() + * + * @param ValidatorMap $map + * @param string $str + * + * @return boolean + */ + public function isValid(ValidatorMap $map, $str) + { + return ($str !== null && $str !== ""); + } } diff --git a/airtime_mvc/library/propel/runtime/lib/validator/TypeValidator.php b/airtime_mvc/library/propel/runtime/lib/validator/TypeValidator.php index 141760f0a..3314a097c 100644 --- a/airtime_mvc/library/propel/runtime/lib/validator/TypeValidator.php +++ b/airtime_mvc/library/propel/runtime/lib/validator/TypeValidator.php @@ -20,49 +20,59 @@ * * * @author Hans Lellelid - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.validator */ class TypeValidator implements BasicValidator { - public function isValid(ValidatorMap $map, $value) - { - switch ($map->getValue()) { - case 'array': - return is_array($value); - break; - case 'bool': - case 'boolean': - return is_bool($value); - break; - case 'float': - return is_float($value); - break; - case 'int': - case 'integer': - return is_int($value); - break; - case 'numeric': - return is_numeric($value); - break; - case 'object': - return is_object($value); - break; - case 'resource': - return is_resource($value); - break; - case 'scalar': - return is_scalar($value); - break; - case 'string': - return is_string($value); - break; - case 'function': - return function_exists($value); - break; - default: - throw new PropelException('Unkonwn type ' . $map->getValue()); - break; - } - } + /** + * @see BasicValidator::isValid() + * + * @param ValidatorMap $map + * @param mixed $value + * + * @return boolean + * + * @throws PropelException + */ + public function isValid(ValidatorMap $map, $value) + { + switch ($map->getValue()) { + case 'array': + return is_array($value); + break; + case 'bool': + case 'boolean': + return is_bool($value); + break; + case 'float': + return is_float($value); + break; + case 'int': + case 'integer': + return is_int($value); + break; + case 'numeric': + return is_numeric($value); + break; + case 'object': + return is_object($value); + break; + case 'resource': + return is_resource($value); + break; + case 'scalar': + return is_scalar($value); + break; + case 'string': + return is_string($value); + break; + case 'function': + return function_exists($value); + break; + default: + throw new PropelException('Unknown type ' . $map->getValue()); + break; + } + } } diff --git a/airtime_mvc/library/propel/runtime/lib/validator/UniqueValidator.php b/airtime_mvc/library/propel/runtime/lib/validator/UniqueValidator.php index 49cc91d34..061c05664 100644 --- a/airtime_mvc/library/propel/runtime/lib/validator/UniqueValidator.php +++ b/airtime_mvc/library/propel/runtime/lib/validator/UniqueValidator.php @@ -20,29 +20,33 @@ * * * @author Michael Aichler - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.validator */ class UniqueValidator implements BasicValidator { + /** + * @see BasicValidator::isValid() + * + * @param ValidatorMap $map + * @param string $str + * + * @return boolean + */ + public function isValid(ValidatorMap $map, $str) + { + $column = $map->getColumn(); - /** - * @see BasicValidator::isValid() - */ - public function isValid (ValidatorMap $map, $str) - { - $column = $map->getColumn(); + $c = new Criteria(); + $c->add($column->getFullyQualifiedName(), $str, Criteria::EQUAL); - $c = new Criteria(); - $c->add($column->getFullyQualifiedName(), $str, Criteria::EQUAL); + $table = $column->getTable()->getClassName(); - $table = $column->getTable()->getClassName(); + $clazz = $table . 'Peer'; + $count = call_user_func(array($clazz, 'doCount'), $c); - $clazz = $table . 'Peer'; - $count = call_user_func(array($clazz, 'doCount'), $c); + $isValid = ($count === 0); - $isValid = ($count === 0); - - return $isValid; - } + return $isValid; + } } diff --git a/airtime_mvc/library/propel/runtime/lib/validator/ValidValuesValidator.php b/airtime_mvc/library/propel/runtime/lib/validator/ValidValuesValidator.php index d680108e9..9879fca04 100644 --- a/airtime_mvc/library/propel/runtime/lib/validator/ValidValuesValidator.php +++ b/airtime_mvc/library/propel/runtime/lib/validator/ValidValuesValidator.php @@ -20,14 +20,21 @@ * * * @author Michael Aichler - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.validator */ class ValidValuesValidator implements BasicValidator { - - public function isValid (ValidatorMap $map, $str) - { - return in_array($str, preg_split("/[|,]/", $map->getValue())); - } + /** + * @see BasicValidator::isValid() + * + * @param ValidatorMap $map + * @param string $str + * + * @return boolean + */ + public function isValid(ValidatorMap $map, $str) + { + return in_array($str, preg_split("/[|,]/", $map->getValue())); + } } diff --git a/airtime_mvc/library/propel/runtime/lib/validator/ValidationFailed.php b/airtime_mvc/library/propel/runtime/lib/validator/ValidationFailed.php index ed3472074..c26ef3d7d 100644 --- a/airtime_mvc/library/propel/runtime/lib/validator/ValidationFailed.php +++ b/airtime_mvc/library/propel/runtime/lib/validator/ValidationFailed.php @@ -8,7 +8,6 @@ * @license MIT License */ - /** * Simple class that serves as a container for any information about a failed validation. * @@ -19,97 +18,104 @@ * failed. * * @author Hans Lellelid - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.runtime.validator * @see BasePeer::doValidate() */ -class ValidationFailed { +class ValidationFailed +{ + /** Column name in tablename.COLUMN_NAME format */ + private $colname; - /** Column name in tablename.COLUMN_NAME format */ - private $colname; + /** Message to display to user. */ + private $message; - /** Message to display to user. */ - private $message; + /** Validator object that caused this to fail. */ + private $validator; - /** Validator object that caused this to fail. */ - private $validator; + /** + * Construct a new ValidationFailed object. + * + * @param string $colname Column name. + * @param string $message Message to display to user. + * @param object $validator The Validator that caused this column to fail. + */ + public function __construct($colname, $message, $validator = null) + { + $this->colname = $colname; + $this->message = $message; + $this->validator = $validator; + } - /** - * Construct a new ValidationFailed object. - * @param string $colname Column name. - * @param string $message Message to display to user. - * @param object $validator The Validator that caused this column to fail. - */ - public function __construct($colname, $message, $validator = null) - { - $this->colname = $colname; - $this->message = $message; - $this->validator = $validator; - } + /** + * Set the column name. + * + * @param string $v + */ + public function setColumn($v) + { + $this->colname = $v; + } - /** - * Set the column name. - * @param string $v - */ - public function setColumn($v) - { - $this->colname = $v; - } + /** + * Gets the column name. + * + * @return string Qualified column name (tablename.COLUMN_NAME) + */ + public function getColumn() + { + return $this->colname; + } - /** - * Gets the column name. - * @return string Qualified column name (tablename.COLUMN_NAME) - */ - public function getColumn() - { - return $this->colname; - } + /** + * Set the message for the validation failure. + * + * @param string $v + */ + public function setMessage($v) + { + $this->message = $v; + } - /** - * Set the message for the validation failure. - * @param string $v - */ - public function setMessage($v) - { - $this->message = $v; - } + /** + * Gets the message for the validation failure. + * + * @return string + */ + public function getMessage() + { + return $this->message; + } - /** - * Gets the message for the validation failure. - * @return string - */ - public function getMessage() - { - return $this->message; - } + /** + * Set the validator object that caused this to fail. + * + * @param object $v + */ + public function setValidator($v) + { + $this->validator = $v; + } - /** - * Set the validator object that caused this to fail. - * @param object $v - */ - public function setValidator($v) - { - $this->validator = $v; - } - - /** - * Gets the validator object that caused this to fail. - * @return object - */ - public function getValidator() - { - return $this->validator; - } - - /** - * "magic" method to get string represenation of object. - * Maybe someday PHP5 will support the invoking this method automatically - * on (string) cast. Until then it's pretty useless. - * @return string - */ - public function __toString() - { - return $this->getMessage(); - } + /** + * Gets the validator object that caused this to fail. + * + * @return object + */ + public function getValidator() + { + return $this->validator; + } + /** + * "magic" method to get string representation of object. + * Maybe someday PHP5 will support the invoking this method automatically + * on (string) cast. Until then it's pretty useless. + * + * @return string + */ + public function __toString() + { + return $this->getMessage(); + } } diff --git a/airtime_mvc/library/propel/runtime/pear/BuildPropelPEARPackageTask.php b/airtime_mvc/library/propel/runtime/pear/BuildPropelPEARPackageTask.php index 023820fc4..354be9b8b 100644 --- a/airtime_mvc/library/propel/runtime/pear/BuildPropelPEARPackageTask.php +++ b/airtime_mvc/library/propel/runtime/pear/BuildPropelPEARPackageTask.php @@ -16,190 +16,202 @@ include_once 'phing/tasks/ext/pearpackage/Fileset.php'; * * @author Hans Lellelid * @package phing.tasks.ext - * @version $Revision: 1681 $ + * @version $Revision$ */ class BuildPropelPEARPackageTask extends MatchingTask { - /** Base directory for reading files. */ - private $dir; + /** Base directory for reading files. */ + private $dir; - private $version; - private $state = 'stable'; - private $notes; + private $version; + private $state = 'stable'; + private $notes; - private $filesets = array(); + private $filesets = array(); - /** Package file */ - private $packageFile; + /** Package file */ + private $packageFile; - public function init() - { - include_once 'PEAR/PackageFileManager2.php'; - if (!class_exists('PEAR_PackageFileManager2')) { - throw new BuildException("You must have installed PEAR_PackageFileManager2 (PEAR_PackageFileManager >= 1.6.0) in order to create a PEAR package.xml file."); - } - } + public function init() + { + include_once 'PEAR/PackageFileManager2.php'; + if (!class_exists('PEAR_PackageFileManager2')) { + throw new BuildException("You must have installed PEAR_PackageFileManager2 (PEAR_PackageFileManager >= 1.6.0) in order to create a PEAR package.xml file."); + } + } - private function setOptions($pkg) - { - $options['baseinstalldir'] = 'propel'; - $options['packagedirectory'] = $this->dir->getAbsolutePath(); + private function setOptions($pkg) + { + $options['baseinstalldir'] = 'propel'; + $options['packagedirectory'] = $this->dir->getAbsolutePath(); - if (empty($this->filesets)) { - throw new BuildException("You must use a tag to specify the files to include in the package.xml"); - } + if (empty($this->filesets)) { + throw new BuildException("You must use a tag to specify the files to include in the package.xml"); + } - $options['filelistgenerator'] = 'Fileset'; + $options['filelistgenerator'] = 'Fileset'; - // Some PHING-specific options needed by our Fileset reader - $options['phing_project'] = $this->getProject(); - $options['phing_filesets'] = $this->filesets; + // Some PHING-specific options needed by our Fileset reader + $options['phing_project'] = $this->getProject(); + $options['phing_filesets'] = $this->filesets; - if ($this->packageFile !== null) { - // create one w/ full path - $f = new PhingFile($this->packageFile->getAbsolutePath()); - $options['packagefile'] = $f->getName(); - // must end in trailing slash - $options['outputdirectory'] = $f->getParent() . DIRECTORY_SEPARATOR; - $this->log("Creating package file: " . $f->getPath(), Project::MSG_INFO); - } else { - $this->log("Creating [default] package.xml file in base directory.", Project::MSG_INFO); - } + if ($this->packageFile !== null) { + // create one w/ full path + $f = new PhingFile($this->packageFile->getAbsolutePath()); + $options['packagefile'] = $f->getName(); + // must end in trailing slash + $options['outputdirectory'] = $f->getParent() . DIRECTORY_SEPARATOR; + $this->log("Creating package file: " . $f->getPath(), Project::MSG_INFO); + } else { + $this->log("Creating [default] package.xml file in base directory.", Project::MSG_INFO); + } - $pkg->setOptions($options); + $pkg->setOptions($options); + } - } + /** + * Main entry point. + * + * @return void + * + * @throws BuildException + */ + public function main() + { + if ($this->dir === null) { + throw new BuildException("You must specify the \"dir\" attribute for PEAR package task."); + } - /** - * Main entry point. - * @return void - */ - public function main() - { - if ($this->dir === null) { - throw new BuildException("You must specify the \"dir\" attribute for PEAR package task."); - } + if ($this->version === null) { + throw new BuildException("You must specify the \"version\" attribute for PEAR package task."); + } - if ($this->version === null) { - throw new BuildException("You must specify the \"version\" attribute for PEAR package task."); - } + $package = new PEAR_PackageFileManager2(); - $package = new PEAR_PackageFileManager2(); + $this->setOptions($package); - $this->setOptions($package); + // the hard-coded stuff + $package->setPackage('propel_runtime'); + $package->setSummary('Runtime component of the Propel PHP object persistence layer'); + $package->setDescription('Propel is an object persistence layer for PHP5 based on Apache Torque. This package provides the runtime engine that transparently handles object persistence and retrieval.'); + $package->setChannel('pear.propelorm.org'); + $package->setPackageType('php'); - // the hard-coded stuff - $package->setPackage('propel_runtime'); - $package->setSummary('Runtime component of the Propel PHP object persistence layer'); - $package->setDescription('Propel is an object persistence layer for PHP5 based on Apache Torque. This package provides the runtime engine that transparently handles object persistence and retrieval.'); - $package->setChannel('pear.propelorm.org'); - $package->setPackageType('php'); + $package->setReleaseVersion($this->version); + $package->setAPIVersion($this->version); - $package->setReleaseVersion($this->version); - $package->setAPIVersion($this->version); + $package->setReleaseStability($this->state); + $package->setAPIStability($this->state); - $package->setReleaseStability($this->state); - $package->setAPIStability($this->state); + $package->setNotes($this->notes); - $package->setNotes($this->notes); + $package->setLicense('MIT', 'http://www.opensource.org/licenses/mit-license.php'); - $package->setLicense('MIT', 'http://www.opensource.org/licenses/mit-license.php'); + // Add package maintainers + $package->addMaintainer('lead', 'hans', 'Hans Lellelid', 'hans@xmpl.org'); + $package->addMaintainer('lead', 'david', 'David Zuelke', 'dz@bitxtender.com'); + $package->addMaintainer('lead', 'francois', 'Francois Zaninotto', 'fzaninotto@[gmail].com'); + $package->addMaintainer('lead', 'couac', 'William Durand', 'william.durand1@[gmail].com'); - // Add package maintainers - $package->addMaintainer('lead', 'hans', 'Hans Lellelid', 'hans@xmpl.org'); - $package->addMaintainer('lead', 'david', 'David Zuelke', 'dz@bitxtender.com'); - $package->addMaintainer('lead', 'francois', 'Francois Zaninotto', 'fzaninotto@[gmail].com'); + // "core" dependencies + $package->setPhpDep('5.2.0'); + $package->setPearinstallerDep('1.4.0'); - // "core" dependencies - $package->setPhpDep('5.2.0'); - $package->setPearinstallerDep('1.4.0'); + // "package" dependencies + $package->addExtensionDep('required', 'pdo'); + $package->addExtensionDep('required', 'spl'); - // "package" dependencies - $package->addExtensionDep('required', 'pdo'); - $package->addExtensionDep('required', 'spl'); + // now we run this weird generateContents() method that apparently + // is necessary before we can add replacements ... ? + $package->generateContents(); - // now we run this weird generateContents() method that apparently - // is necessary before we can add replacements ... ? - $package->generateContents(); + $e = $package->writePackageFile(); - $e = $package->writePackageFile(); + if (PEAR::isError($e)) { + throw new BuildException("Unable to write package file.", new Exception($e->getMessage())); + } + } - if (PEAR::isError($e)) { - throw new BuildException("Unable to write package file.", new Exception($e->getMessage())); - } + /** + * Used by the PEAR_PackageFileManager_PhingFileSet lister. + * + * @return array FileSet[] + */ + public function getFileSets() + { + return $this->filesets; + } - } + // ------------------------------- + // Set properties from XML + // ------------------------------- - /** - * Used by the PEAR_PackageFileManager_PhingFileSet lister. - * @return array FileSet[] - */ - public function getFileSets() - { - return $this->filesets; - } + /** + * Nested creator, creates a FileSet for this task + * + * @return FileSet The created fileset object + */ + public function createFileSet() + { + $num = array_push($this->filesets, new FileSet()); - // ------------------------------- - // Set properties from XML - // ------------------------------- + return $this->filesets[$num - 1]; + } - /** - * Nested creator, creates a FileSet for this task - * - * @return FileSet The created fileset object - */ - function createFileSet() - { - $num = array_push($this->filesets, new FileSet()); - return $this->filesets[$num-1]; - } + /** + * Set the version we are building. + * + * @param string $v + * + * @return void + */ + public function setVersion($v) + { + $this->version = $v; + } - /** - * Set the version we are building. - * @param string $v - * @return void - */ - public function setVersion($v) - { - $this->version = $v; - } + /** + * Set the state we are building. + * + * @param string $v + * + * @return void + */ + public function setState($v) + { + $this->state = $v; + } - /** - * Set the state we are building. - * @param string $v - * @return void - */ - public function setState($v) - { - $this->state = $v; - } + /** + * Sets release notes field. + * + * @param string $v + * + * @return void + */ + public function setNotes($v) + { + $this->notes = $v; + } - /** - * Sets release notes field. - * @param string $v - * @return void - */ - public function setNotes($v) - { - $this->notes = $v; - } - /** - * Sets "dir" property from XML. - * @param PhingFile $f - * @return void - */ - public function setDir(PhingFile $f) - { - $this->dir = $f; - } - - /** - * Sets the file to use for generated package.xml - */ - public function setDestFile(PhingFile $f) - { - $this->packageFile = $f; - } + /** + * Sets "dir" property from XML. + * + * @param PhingFile $f + * + * @return void + */ + public function setDir(PhingFile $f) + { + $this->dir = $f; + } + /** + * Sets the file to use for generated package.xml + */ + public function setDestFile(PhingFile $f) + { + $this->packageFile = $f; + } } diff --git a/airtime_mvc/library/propel/runtime/pear/build-pear-package.xml b/airtime_mvc/library/propel/runtime/pear/build-pear-package.xml index 31a741530..c81e391ba 100644 --- a/airtime_mvc/library/propel/runtime/pear/build-pear-package.xml +++ b/airtime_mvc/library/propel/runtime/pear/build-pear-package.xml @@ -8,114 +8,114 @@ - - - - + + + + - - + - + - + - - - + + + - - - - - - + + + + + + - - - - - - - - - - Propel version for package + + + + + + + + + + Propel version for package - - + + - + - - - ----------------------------- - | Creating directory layout | - ----------------------------- + + + ----------------------------- + | Creating directory layout | + ----------------------------- - - + + - - - + + + - + - - + + - ----------------------------- - | Creating PEAR package.xml | - ----------------------------- - + ----------------------------- + | Creating PEAR package.xml | + ----------------------------- + - + - - - + + + - + - + - - - ----------------------------- - | Creating tar.gz package | - ----------------------------- - - - - + + + ----------------------------- + | Creating tar.gz package | + ----------------------------- + + + + - \ No newline at end of file + diff --git a/airtime_mvc/library/propel/runtime/stubs/functions.php b/airtime_mvc/library/propel/runtime/stubs/functions.php new file mode 100644 index 000000000..2c44363a2 --- /dev/null +++ b/airtime_mvc/library/propel/runtime/stubs/functions.php @@ -0,0 +1,10 @@ + pear channel-discover pear.phpunit.de -> pear install phpunit/PHPUnit-3.3.9 -}}} - -{{{ -> pear channel-discover pear.phing.info -> pear install phing/phing-2.3.3 -}}} - -{{{ -> pear install log -}}} - -Tip: The latest release of PHPUnit (3.4) is not totally BC with the 3.3, and doesn't have a Phing adapter yet. That's why the Propel unit tests still use PHPUnit version 3.3. - -== Configure the Database to be Used in the Tests == - -You must configure both the generator and the runtime connection settings. -{{{ -// in test/fixtures/bookstore/build.properties -propel.database = mysql -propel.database.url = mysql:dbname=test -propel.mysqlTableType = InnoDB -propel.disableIdentifierQuoting=true -# For MySQL or Oracle, you also need to specify username & password -propel.database.user = myusername -propel.database.password = p@ssw0rd -}}} - -{{{ -// in test/fixtures/bookstore/runtime-conf.xml - - - mysql - - - DebugPDO - mysql:dbname=test - myusername - p@ssw0rd - - - - - - - - - - utf8 - - - -}}} - -== Build the Propel Model and Initialize the Database == - -{{{ -> cd /path/to/propel/test -> ../generator/bin/propel-gen fixtures/bookstore main -> mysqladmin create test -> ../generator/bin/propel-gen fixtures/bookstore insert-sql -}}} - -**Tip**: To run the unit tests for the namespace support in PHP 5.3, you must also build the `fixtures/namespaced` project. - -== Run the Unit Tests == - -Run all the unit tests at once using Phing: -{{{ -> cd /path/to/propel/test -> phing -f test.xml -verbose -}}} - -'''Tip''': The `-verbose` option will force the display of PHP notices, which are hidden by default. - -To run a single test, specify the classname (minus 'Test' ending) on the commandline, using the `test` property. For example to run only GeneratedObjectTest: - -{{{ -> phing -f test.xml -verbose -Dtest=GeneratedObject -}}} - -Tip: If you want to set up custom Phing properties for your unit tests, create a `test.properties` file inside the main `test/` directory. Phing will automatically try to load it if it exists. - -== How the Tests Work == - -Every method in the test classes that begins with 'test' is run as a test case by PHPUnit. All tests are run in isolation; the `setUp()` method is called at the beginning of ''each'' test and the `tearDown()` method is called at the end. - -The [browser:branches/1.4/test/tools/helpers/bookstore/BookstoreTestBase.php BookstoreTestBase] class specifies `setUp()` and `tearDown()` methods which populate and depopulate, respectively, the database. This means that every unit test is run with a cleanly populated database. To see the sample data that is populated, take a look at the [browser:branches/1.4/test/tools/helpers/bookstore/BookstoreDataPopulator.php BookstoreDataPopulator] class. You can also add data to this class, if needed by your tests; however, proceed cautiously when changing existing data in there as there may be unit tests that depend on it. More typically, you can simply create the data you need from within your test method. It will be deleted by the `tearDown()` method, so no need to clean up after yourself. - -== Writing Tests == - -If you've made a change to a template or to Propel behavior, the right thing to do is write a unit test that ensures that it works properly -- and continues to work in the future. - -Writing a unit test often means adding a method to one of the existing test classes. For example, let's test a feature in the Propel templates that supports saving of objects when only default values have been specified. Just add a `testSaveWithDefaultValues()` method to the [browser:branches/1.4/test/testsuite/generator/engine/builder/om/php5/GeneratedObjectTest.php GeneratedObjectTest] class, as follows: - -{{{ -#!php -setName('Penguin'); - // in the past this wouldn't have marked object as modified - // since 'Penguin' is the value that's already set for that attrib - $pub->save(); - - // if getId() returns the new ID, then we know save() worked. - $this->assertTrue($pub->getId() !== null, "Expect Publisher->save() to work with only default values."); -} -?> -}}} - -Run the test again using the command line to check that it passes: - -{{{ -> phing -f test.xml -Dtest=GeneratedObject -}}} - -You can also write additional unit test classes to any of the directories in `test/testsuite/` (or add new directories if needed). The Phing task will find these files automatically and run them. \ No newline at end of file diff --git a/airtime_mvc/library/propel/test/bookstore-packaged-test.php b/airtime_mvc/library/propel/test/bookstore-packaged-test.php deleted file mode 100644 index 7455e9011..000000000 --- a/airtime_mvc/library/propel/test/bookstore-packaged-test.php +++ /dev/null @@ -1,811 +0,0 @@ - - * @version $Revision: 1612 $ - */ - -// Setup configuration. It is expected that the bookstore-conf.php file exists in ../build/conf -// - -error_reporting(E_ALL); - -$conf_path = realpath(dirname(__FILE__) . '/../projects/bookstore-packaged/build/conf/bookstore-packaged-conf.php'); -if (!file_exists($conf_path)) { - print "Make sure that you specify properties in conf/bookstore-packaged.properties and " - ."build propel before running this script."; - exit; -} - -// Add PHP_CLASSPATH, if set -if (getenv("PHP_CLASSPATH")) { - set_include_path(getenv("PHP_CLASSPATH") . PATH_SEPARATOR . get_include_path()); -} - - // Add build/classes/ and classes/ to path -set_include_path( - realpath(dirname(__FILE__) . '/../projects/bookstore-packaged/build/classes') . PATH_SEPARATOR . - dirname(__FILE__) . '/../../runtime/classes' . PATH_SEPARATOR . - get_include_path() -); - - - // Require classes. - require_once 'propel/Propel.php'; - require_once 'author/Author.php'; - require_once 'publisher/Publisher.php'; - require_once 'book/Book.php'; - require_once 'review/Review.php'; - include_once 'media/Media.php'; - include_once 'log/BookstoreLog.php'; - include_once 'book_club_list/BookClubList.php'; - include_once 'book_club_list/BookListRel.php'; - - include_once 'Benchmark/Timer.php'; - - $timer = new Benchmark_Timer; - - $timer->start(); - - // Some utility functions - function boolTest($cond) { - if ($cond) { - return "[OK]\n"; - } else { - return "[FAILED]\n"; - } - } - - try { - // Initialize Propel - Propel::init($conf_path); - } catch (Exception $e) { - die("Error initializing propel: ". $e->__toString()); - } - -function check_tables_empty() { - try { - - print "\nChecking to see that tables are empty\n"; - print "-------------------------------------\n\n"; - - print "Ensuring that there are no records in [author] table: "; - $res = AuthorPeer::doSelect(new Criteria()); - print boolTest(empty($res)); - - print "Ensuring that there are no records in [publisher] table: "; - $res2 = PublisherPeer::doSelect(new Criteria()); - print boolTest(empty($res2)); - - print "Ensuring that there are no records in [book] table: "; - $res3 = AuthorPeer::doSelect(new Criteria()); - print boolTest(empty($res3)); - - print "Ensuring that there are no records in [review] table: "; - $res4 = ReviewPeer::doSelect(new Criteria()); - print boolTest(empty($res4)); - - print "Ensuring that there are no records in [media] table: "; - $res5 = MediaPeer::doSelect(new Criteria()); - print boolTest(empty($res5)); - - print "Ensuring that there are no records in [book_club_list] table: "; - $res6 = BookClubListPeer::doSelect(new Criteria()); - print boolTest(empty($res6)); - - print "Ensuring that there are no records in [book_x_list] table: "; - $res7 = BookListRelPeer::doSelect(new Criteria()); - print boolTest(empty($res7)); - - return (empty($res) && empty($res2) && empty($res3) && empty($res4) && empty($res5)); - - } catch (Exception $e) { - die("Error ensuring tables were empty: " . $e->__toString()); - } -} - -// Check to see if records already exist in any of the three tables. If so, display an error -// and exit. - -if (!check_tables_empty()) { - die("Tables must be empty to perform these tests."); -} - -// Add publisher records -// --------------------- - -try { - print "\nAdding some new publishers to the list\n"; - print "--------------------------------------\n\n"; - - $scholastic = new Publisher(); - $scholastic->setName("Scholastic"); - // do not save, will do later to test cascade - print "Added publisher \"Scholastic\" [not saved yet].\n"; - - $morrow = new Publisher(); - $morrow->setName("William Morrow"); - $morrow->save(); - $morrow_id = $morrow->getId(); - print "Added publisher \"William Morrow\" [id = $morrow_id].\n"; - - $penguin = new Publisher(); - $penguin->setName("Penguin"); - $penguin->save(); - $penguin_id = $penguin->getId(); - print "Added publisher \"Penguin\" [id = $penguin_id].\n"; - - $vintage = new Publisher(); - $vintage->setName("Vintage"); - $vintage->save(); - $vintage_id = $vintage->getId(); - print "Added publisher \"Vintage\" [id = $vintage_id].\n"; - -} catch (Exception $e) { - die("Error adding publisher: " . $e->__toString()); -} - -// Add author records -// ------------------ - -try { - print "\nAdding some new authors to the list\n"; - print "--------------------------------------\n\n"; - - $rowling = new Author(); - $rowling->setFirstName("J.K."); - $rowling->setLastName("Rowling"); - // no save() - print "Added author \"J.K. Rowling\" [not saved yet].\n"; - - $stephenson = new Author(); - $stephenson->setFirstName("Neal"); - $stephenson->setLastName("Stephenson"); - $stephenson->save(); - $stephenson_id = $stephenson->getId(); - print "Added author \"Neal Stephenson\" [id = $stephenson_id].\n"; - - $byron = new Author(); - $byron->setFirstName("George"); - $byron->setLastName("Byron"); - $byron->save(); - $byron_id = $byron->getId(); - print "Added author \"George Byron\" [id = $byron_id].\n"; - - - $grass = new Author(); - $grass->setFirstName("Gunter"); - $grass->setLastName("Grass"); - $grass->save(); - $grass_id = $grass->getId(); - print "Added author \"Gunter Grass\" [id = $grass_id].\n"; - -} catch (Exception $e) { - die("Error adding author: " . $e->__toString()); -} - -// Add book records -// ---------------- - -try { - - print "\nAdding some new books to the list\n"; - print "-------------------------------------\n\n"; - - $phoenix = new Book(); - $phoenix->setTitle("Harry Potter and the Order of the Phoenix"); - $phoenix->setISBN("043935806X"); - - print "Trying cascading save (Harry Potter): "; - $phoenix->setAuthor($rowling); - $phoenix->setPublisher($scholastic); - $phoenix->save(); - $phoenix_id = $phoenix->getId(); - print boolTest(true); - print "Added book \"Harry Potter and the Order of the Phoenix\" [id = $phoenix_id].\n"; - - $qs = new Book(); - $qs->setISBN("0380977427"); - $qs->setTitle("Quicksilver"); - $qs->setAuthor($stephenson); - $qs->setPublisher($morrow); - $qs->save(); - $qs_id = $qs->getId(); - print "Added book \"Quicksilver\" [id = $qs_id].\n"; - - $dj = new Book(); - $dj->setISBN("0140422161"); - $dj->setTitle("Don Juan"); - $dj->setAuthor($byron); - $dj->setPublisher($penguin); - $dj->save(); - $dj_id = $qs->getId(); - print "Added book \"Don Juan\" [id = $dj_id].\n"; - - $td = new Book(); - $td->setISBN("067972575X"); - $td->setTitle("The Tin Drum"); - $td->setAuthor($grass); - $td->setPublisher($vintage); - $td->save(); - $td_id = $td->getId(); - print "Added book \"The Tin Drum\" [id = $dj_id].\n"; - -} catch (Exception $e) { - die("Error saving book: " . $e->__toString()); -} - -// Add review records -// ------------------ - -try { - - print "\nAdding some book reviews to the list\n"; - print "------------------------------------\n\n"; - - $r1 = new Review(); - $r1->setBook($phoenix); - $r1->setReviewedBy("Washington Post"); - $r1->setRecommended(true); - $r1->setReviewDate(time()); - $r1->save(); - $r1_id = $r1->getId(); - print "Added Washington Post book review [id = $r1_id].\n"; - - $r2 = new Review(); - $r2->setBook($phoenix); - $r2->setReviewedBy("New York Times"); - $r2->setRecommended(false); - $r2->setReviewDate(time()); - $r2->save(); - $r2_id = $r2->getId(); - print "Added New York Times book review [id = $r2_id].\n"; - -} catch (Exception $e) { - die("Error saving book review: " . $e->__toString()); -} - -// Perform a "complex" search -// -------------------------- - -try { - - print "\nDoing complex search on books\n"; - print "-----------------------------\n\n"; - - $crit = new Criteria(); - $crit->add(BookPeer::TITLE, 'Harry%', Criteria::LIKE); - - print "Looking for \"Harry%\": "; - $results = BookPeer::doSelect($crit); - print boolTest(count($results) === 1); - - - $crit2 = new Criteria(); - $crit2->add(BookPeer::ISBN, array("0380977427", "0140422161"), Criteria::IN); - $results = BookPeer::doSelect($crit2); - print "Looking for ISBN IN (\"0380977427\", \"0140422161\"): "; - print boolTest(count($results) === 2); - -} catch (Exception $e) { - die("Error while performing complex query: " . $e->__toString()); -} - - -// Perform a "limit" search -// ------------------------ - -try { - - print "\nDoing LIMITed search on books\n"; - print "-----------------------------\n\n"; - - $crit = new Criteria(); - $crit->setLimit(2); - $crit->setOffset(1); - $crit->addAscendingOrderByColumn(BookPeer::TITLE); - - print "Checking to make sure correct number returned: "; - $results = BookPeer::doSelect($crit); - print boolTest(count($results) === 2); - - print "Checking to make sure correct books returned: "; - // we ordered on book title, so we expect to get - print boolTest( $results[0]->getTitle() == "Harry Potter and the Order of the Phoenix" && $results[1]->getTitle() == "Quicksilver" ); - - -} catch (Exception $e) { - die("Error while performing LIMIT query: " . $e->__toString()); -} - - - -// Perform a lookup & update! -// -------------------------- - -try { - - print "\nUpdating just-created book title\n"; - print "--------------------------------\n\n"; - - print "First finding book by PK (=$qs_id) .... "; - - try { - $qs_lookup = BookPeer::retrieveByPk($qs_id); - } catch (Exception $e) { - print "ERROR!\n"; - die("Error retrieving by pk: " . $e->__toString()); - } - - if ($qs_lookup) { - print "FOUND!\n"; - } else { - print "NOT FOUND :(\n"; - die("Couldn't find just-created book: book_id = $qs_id"); - } - - try { - $new_title = "Quicksilver (".crc32(uniqid(rand())).")"; - print "Attempting to update found object (".$qs_lookup->getTitle()." -> ".$new_title."): "; - $qs_lookup->setTitle($new_title); - $qs_lookup->save(); - print boolTest(true); - } catch (Exception $e) { - die("Error saving (updating) book: " . $e->__toString()); - } - - print "Making sure object was correctly updated: "; - $qs_lookup2 = BookPeer::retrieveByPk($qs_id); - print boolTest($qs_lookup2->getTitle() == $new_title); - -} catch (Exception $e) { - die("Error updating book: " . $e->__toString()); -} - - -// Test some basic DATE / TIME stuff -// --------------------------------- - -try { - print "\nTesting the DATE/TIME columns\n"; - print "-----------------------------\n\n"; - - // that's the control timestamp. - $control = strtotime('2004-02-29 00:00:00'); - - // should be two in the db - $r = ReviewPeer::doSelectOne(new Criteria()); - $r_id = $r->getId(); - $r->setReviewDate($control); - $r->save(); - - $r2 = ReviewPeer::retrieveByPk($r_id); - - print "Checking ability to fetch native unix timestamp: "; - print boolTest($r2->getReviewDate(null) === $control); - - print "Checking ability to use date() formatter: "; - print boolTest($r2->getReviewDate('n-j-Y') === '2-29-2004'); - - print "[FYI] Here's the strftime() formatter for current locale: " . $r2->getReviewDate('%x') . "\n"; - -} catch (Exception $e) { - die("Error test date/time: " . $e->__toString()); -} - -// Handle BLOB/CLOB Columns -// ------------------------ - -try { - print "\nTesting the BLOB/CLOB columns\n"; - print "-------------------------------\n\n"; - - $blob_path = dirname(__FILE__) . '/etc/lob/tin_drum.gif'; - $blob2_path = dirname(__FILE__) . '/etc/lob/propel.gif'; - $clob_path = dirname(__FILE__) . '/etc/lob/tin_drum.txt'; - - $m1 = new Media(); - $m1->setBook($phoenix); - $m1->setCoverImage(file_get_contents($blob_path)); - $m1->setExcerpt(file_get_contents($clob_path)); - $m1->save(); - $m1_id = $m1->getId(); - print "Added Media collection [id = $m1_id].\n"; - - print "Looking for just-created mediat by PK (=$m1_id) .... "; - - try { - $m1_lookup = MediaPeer::retrieveByPk($m1_id); - } catch (Exception $e) { - print "ERROR!\n"; - die("Error retrieving media by pk: " . $e->__toString()); - } - - if ($m1_lookup) { - print "FOUND!\n"; - } else { - print "NOT FOUND :(\n"; - die("Couldn't find just-created media item: media_id = $m1_id"); - } - - print "Making sure BLOB was correctly updated: "; - print boolTest( $m1_lookup->getCoverImage()->getContents() === file_get_contents($blob_path)); - print "Making sure CLOB was correctly updated: "; - print boolTest((string) $m1_lookup->getExcerpt()->getContents() === file_get_contents($clob_path)); - - - // now update the BLOB column and save it & check the results - - $b = $m1_lookup->getCoverImage(); - $b->setContents(file_get_contents($blob2_path)); - $m1_lookup->setCoverImage($b); - $m1_lookup->save(); - - try { - $m2_lookup = MediaPeer::retrieveByPk($m1_id); - } catch (Exception $e) { - print "ERROR!\n"; - die("Error retrieving media by pk: " . $e->__toString()); - } - - print "Making sure BLOB was correctly overwritten: "; - print boolTest($m2_lookup->getCoverImage()->getContents() === file_get_contents($blob2_path)); - -} catch (Exception $e) { - die("Error doing blob/clob updates: " . $e->__toString()); -} - -// Test Validators -// --------------- - -try { - - print "\nTesting the column validators\n"; - print "-----------------------------\n\n"; - - $bk1 = new Book(); - $bk1->setTitle("12345"); // min length is 10 - $ret = $bk1->validate(); - - print "Making sure validation failed: "; - print boolTest($ret !== true); - - print "Making sure 1 validation message was returned: "; - print boolTest(count($ret) === 1); - - print "Making sure expected validation message was returned: "; - $el = array_shift($ret); - print boolTest(stripos($el->getMessage(), "must be more than") !== false); - - print "\n(Unique validator)\n"; - - $bk2 = new Book(); - $bk2->setTitle("Don Juan"); - $ret = $bk2->validate(); - - print "Making sure validation failed: "; - print boolTest($ret !== true); - - print "Making sure 1 validation message was returned: "; - print boolTest(count($ret) === 1); - - print "Making sure expected validation message was returned: "; - $el = array_shift($ret); - print boolTest(stripos($el->getMessage(), "Book title already in database.") !== false); - - print "\n(Now trying some more complex validation.)\n"; - $auth1 = new Author(); - $auth1->setFirstName("Hans"); - // last name required; will fail - - $bk1->setAuthor($auth1); - - $rev1 = new Review(); - $rev1->setReviewDate("08/09/2001"); - // will fail: reviewed_by column required - - $bk1->addReview($rev1); - - $ret2 = $bk1->validate(); - - print "Making sure 6 validation messages were returned: "; - print boolTest(count($ret2) === 6); - - print "Making sure correct columns failed: "; - print boolTest(array_keys($ret2) === array( - AuthorPeer::LAST_NAME, - AuthorPeer::EMAIL, - AuthorPeer::AGE, - BookPeer::TITLE, - ReviewPeer::REVIEWED_BY, - ReviewPeer::STATUS - )); - - - $bk2 = new Book(); - $bk2->setTitle("12345678901"); // passes - - $auth2 = new Author(); - $auth2->setLastName("Blah"); //passes - $auth2->setEmail("some@body.com"); //passes - $auth2->setAge(50); //passes - $bk2->setAuthor($auth2); - - $rev2 = new Review(); - $rev2->setReviewedBy("Me!"); // passes - $rev2->setStatus("new"); // passes - $bk2->addReview($rev2); - - $ret3 = $bk2->validate(); - - print "Making sure complex validation can pass: "; - print boolTest($ret3 === true); - -} catch (Exception $e) { - die("Error doing validation tests: " . $e->__toString()); -} - - -// Test doCount() -// -try { - - print "\nTesting doCount() functionality\n"; - print "-------------------------------\n\n"; - - $c = new Criteria(); - $records = BookPeer::doSelect($c); - $count = BookPeer::doCount($c); - - print "Making sure correct number of results: "; - print boolTest(count($records) === $count); - -} catch (Exception $e) { - die("Error deleting book: " . $e->__toString()); -} - -// Test many-to-many relationships -// --------------- - -try { - - print "\nTesting many-to-many relationships\n"; - print "-----------------------------\n\n"; - - // init book club list 1 with 2 books - - $blc1 = new BookClubList(); - $blc1->setGroupLeader("Crazyleggs"); - $blc1->setTheme("Happiness"); - - $brel1 = new BookListRel(); - $brel1->setBook($phoenix); - - $brel2 = new BookListRel(); - $brel2->setBook($dj); - - $blc1->addBookListRel($brel1); - $blc1->addBookListRel($brel2); - - $blc1->save(); - - print "Making sure BookClubList 1 was saved: "; - print boolTest(!is_null($blc1->getId())); - - // init book club list 2 with 1 book - - $blc2 = new BookClubList(); - $blc2->setGroupLeader("John Foo"); - $blc2->setTheme("Default"); - - $brel3 = new BookListRel(); - $brel3->setBook($phoenix); - - $blc2->addBookListRel($brel3); - - $blc2->save(); - - print "Making sure BookClubList 2 was saved: "; - print boolTest(!is_null($blc2->getId())); - - // re-fetch books and lists from db to be sure that nothing is cached - - $crit = new Criteria(); - $crit->add(BookPeer::ID, $phoenix->getId()); - $phoenix = BookPeer::doSelectOne($crit); - print "Making sure book 'phoenix' has been re-fetched from db: "; - print boolTest(!empty($phoenix)); - - $crit = new Criteria(); - $crit->add(BookClubListPeer::ID, $blc1->getId()); - $blc1 = BookClubListPeer::doSelectOne($crit); - print "Making sure BookClubList 1 has been re-fetched from db: "; - print boolTest(!empty($blc1)); - - $crit = new Criteria(); - $crit->add(BookClubListPeer::ID, $blc2->getId()); - $blc2 = BookClubListPeer::doSelectOne($crit); - print "Making sure BookClubList 2 has been re-fetched from db: "; - print boolTest(!empty($blc2)); - - $relCount = $phoenix->countBookListRels(); - print "Making sure book 'phoenix' has 2 BookListRels: "; - print boolTest($relCount == 2); - - $relCount = $blc1->countBookListRels(); - print "Making sure BookClubList 1 has 2 BookListRels: "; - print boolTest($relCount == 2); - - $relCount = $blc2->countBookListRels(); - print "Making sure BookClubList 2 has 1 BookListRel: "; - print boolTest($relCount == 1); - - -} catch (Exception $e) { - die("Error doing many-to-many relationships tests: " . $e->__toString()); -} - -// Test multiple databases -// --------------- - -try { - - print "\nTesting multiple databases\n"; - print "-----------------------------\n\n"; - - $line = new BookstoreLog(); - $line->setIdent('bookstore-packaged-test'); - $line->setTime(time()); - $line->setMessage('We are testing to write something to the log database ...'); - $line->setPriority('debug'); - $line->save(); - - $line_id = $line->getId(); - print "Making sure BookstoreLog was saved: "; - print boolTest(!empty($line_id)); - -} catch (Exception $e) { - die("Error doing multiple databases tests: " . $e->__toString()); -} - -// Cleanup (tests DELETE) -// ---------------------- - -try { - - print "\nRemoving books that were just created\n"; - print "-------------------------------------\n\n"; - - print "First finding book by PK (=$phoenix_id) .... "; - try { - $hp = BookPeer::retrieveByPk($phoenix_id); - } catch (Exception $e) { - print "ERROR!\n"; - die("Error retrieving by pk: " . $e->__toString()); - } - - if ($hp) { - print "FOUND!\n"; - } else { - print "NOT FOUND :(\n"; - die("Couldn't find just-created book: book_id = $phoenix_id"); - } - - print "Attempting to delete [multi-table] by found pk: "; - $c = new Criteria(); - $c->add(BookPeer::ID, $hp->getId()); - // The only way for cascading to work currently - // is to specify the author_id and publisher_id (i.e. the fkeys - // have to be in the criteria). - $c->add(AuthorPeer::ID, $hp->getId()); - $c->add(PublisherPeer::ID, $hp->getId()); - $c->setSingleRecord(true); - BookPeer::doDelete($c); - print boolTest(true); - - print "Checking to make sure correct records were removed.\n"; - print "\tFrom author table: "; - $res = AuthorPeer::doSelect(new Criteria()); - print boolTest(count($res) === 3); - print "\tFrom publisher table: "; - $res2 = PublisherPeer::doSelect(new Criteria()); - print boolTest(count($res2) === 3); - print "\tFrom book table: "; - $res3 = BookPeer::doSelect(new Criteria()); - print boolTest(count($res3) === 3); - - print "Attempting to delete books by complex criteria: "; - $c = new Criteria(); - $cn = $c->getNewCriterion(BookPeer::ISBN, "043935806X"); - $cn->addOr($c->getNewCriterion(BookPeer::ISBN, "0380977427")); - $cn->addOr($c->getNewCriterion(BookPeer::ISBN, "0140422161")); - $c->add($cn); - BookPeer::doDelete($c); - print boolTest(true); - - print "Attempting to delete book [id = $td_id]: "; - $td->delete(); - print boolTest(true); - - print "Attempting to delete author [id = $stephenson_id]: "; - AuthorPeer::doDelete($stephenson_id); - print boolTest(true); - - print "Attempting to delete author [id = $byron_id]: "; - AuthorPeer::doDelete($byron_id); - print boolTest(true); - - print "Attempting to delete author [id = $grass_id]: "; - $grass->delete(); - print boolTest(true); - - print "Attempting to delete publisher [id = $morrow_id]: "; - PublisherPeer::doDelete($morrow_id); - print boolTest(true); - - print "Attempting to delete publisher [id = $penguin_id]: "; - PublisherPeer::doDelete($penguin_id); - print boolTest(true); - - print "Attempting to delete publisher [id = $vintage_id]: "; - $vintage->delete(); - print boolTest(true); - - // These have to be deleted manually also since we have onDelete - // set to SETNULL in the foreign keys in book. Is this correct? - print "Attempting to delete author [lastname = 'Rowling']: "; - $rowling->delete(); - print boolTest(true); - - print "Attempting to delete publisher [lastname = 'Scholastic']: "; - $scholastic->delete(); - print boolTest(true); - - print "Attempting to delete BookClubList 1: "; - $blc1->delete(); - print boolTest(true); - - print "Attempting to delete BookClubList 2: "; - $blc2->delete(); - print boolTest(true); - -} catch (Exception $e) { - die("Error deleting book: " . $e->__toString()); -} - - -// Check again to make sure that tables are empty -// ---------------------------------------------- - -check_tables_empty(); - - - - - -$timer->stop(); -print $timer->display(); diff --git a/airtime_mvc/library/propel/test/bootstrap.php b/airtime_mvc/library/propel/test/bootstrap.php new file mode 100644 index 000000000..14676a5bc --- /dev/null +++ b/airtime_mvc/library/propel/test/bootstrap.php @@ -0,0 +1,7 @@ + - - - - -

- - - -
- - - - -
- - -
- diff --git a/airtime_mvc/library/propel/test/etc/xsl/coverage-frames.xsl b/airtime_mvc/library/propel/test/etc/xsl/coverage-frames.xsl index edfcf2983..a6d5af1ca 100644 --- a/airtime_mvc/library/propel/test/etc/xsl/coverage-frames.xsl +++ b/airtime_mvc/library/propel/test/etc/xsl/coverage-frames.xsl @@ -2,635 +2,633 @@ xmlns:exsl="http://exslt.org/common" xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="exsl date"> - - - - ---> + - + Sample stylesheet to be used with Xdebug/Phing code coverage output. + Based on JProbe stylesheets from Apache Ant. - + + + + + - - - - - + + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - + + + - - - - Coverage Results. - - - - - - - - - <h2>Frame Alert</h2> - <p> - This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. - </p> - - - + + + Coverage Results. + + + + + + + + + <h2>Frame Alert</h2> + <p> + This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. + </p> + + + - - - - .bannercell { - border: 0px; - padding: 0px; - } - body { - margin-left: 10; - margin-right: 10; - background-color:#FFFFFF; - font-family: verdana,arial,sanserif; - color:#000000; - } - a { - color: #003399; - } - a:hover { - color: #888888; - } - .a td { - background: #efefef; - } - .b td { - background: #fff; - } - th, td { - text-align: left; - vertical-align: top; - } - th { - font-weight:bold; - background: #ccc; - color: black; - } - table, th, td { - font-size: 12px; - border: none - } - table.log tr td, tr th { - } - h2 { - font-weight:bold; - font-size: 12px; - margin-bottom: 5; - } - h3 { - font-size:100%; - font-weight: 12px; - background: #DFDFDF - color: white; - text-decoration: none; - padding: 5px; - margin-right: 2px; - margin-left: 2px; - margin-bottom: 0; - } - .small { - font-size: 9px; - } -TD.empty { - FONT-SIZE: 2px; BACKGROUND: #c0c0c0; BORDER:#9c9c9c 1px solid; - color: #c0c0c0; -} -TD.fullcover { - FONT-SIZE: 2px; BACKGROUND: #00df00; BORDER:#9c9c9c 1px solid; - color: #00df00; -} -TD.covered { - FONT-SIZE: 2px; BACKGROUND: #00df00; BORDER-LEFT:#9c9c9c 1px solid;BORDER-TOP:#9c9c9c 1px solid;BORDER-BOTTOM:#9c9c9c 1px solid; - color: #00df00; -} -TD.uncovered { - FONT-SIZE: 2px; BACKGROUND: #df0000; BORDER:#9c9c9c 1px solid; - color: #df0000; -} -PRE.srcLine { - BACKGROUND: #ffffff; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; -} -td.lineCount, td.coverageCount { - BACKGROUND: #F0F0F0; PADDING-RIGHT: 3px; - text-align: right; -} -td.lineCountHighlight { - background: #C8C8F0; PADDING-RIGHT: 3px; - text-align: right; -} -td.coverageCountHighlight { - background: #F0C8C8; PADDING-RIGHT: 3px; - text-align: right; -} -span.srcLineHighlight { - background: #F0C8C8; -} -span.srcLine { - background: #C8C8F0; -} -TD.srcLineClassStart { - WIDTH: 100%; BORDER-TOP:#dcdcdc 1px solid; FONT-WEIGHT: bold; -} -.srcLine , .srcLine ol, .srcLine ol li {margin: 0;} -.srcLine .de1, .srcLine .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;} -.srcLine .imp {font-weight: bold; color: red;} -.srcLine .kw1 {color: #b1b100;} -.srcLine .kw2 {color: #000000; font-weight: bold;} -.srcLine .kw3 {color: #000066;} -.srcLine .co1 {color: #808080; font-style: italic;} -.srcLine .co2 {color: #808080; font-style: italic;} -.srcLine .coMULTI {color: #808080; font-style: italic;} -.srcLine .es0 {color: #000099; font-weight: bold;} -.srcLine .br0 {color: #66cc66;} -.srcLine .st0 {color: #ff0000;} -.srcLine .nu0 {color: #cc66cc;} -.srcLine .me1 {color: #006600;} -.srcLine .me2 {color: #006600;} -.srcLine .re0 {color: #0000ff;} - + + + .bannercell { + border: 0px; + padding: 0px; + } + body { + margin-left: 10; + margin-right: 10; + background-color:#FFFFFF; + font-family: verdana,arial,sanserif; + color:#000000; + } + a { + color: #003399; + } + a:hover { + color: #888888; + } + .a td { + background: #efefef; + } + .b td { + background: #fff; + } + th, td { + text-align: left; + vertical-align: top; + } + th { + font-weight:bold; + background: #ccc; + color: black; + } + table, th, td { + font-size: 12px; + border: none + } + table.log tr td, tr th { + } + h2 { + font-weight:bold; + font-size: 12px; + margin-bottom: 5; + } + h3 { + font-size:100%; + font-weight: 12px; + background: #DFDFDF + color: white; + text-decoration: none; + padding: 5px; + margin-right: 2px; + margin-left: 2px; + margin-bottom: 0; + } + .small { + font-size: 9px; + } + TD.empty { + FONT-SIZE: 2px; BACKGROUND: #c0c0c0; BORDER:#9c9c9c 1px solid; + color: #c0c0c0; + } + TD.fullcover { + FONT-SIZE: 2px; BACKGROUND: #00df00; BORDER:#9c9c9c 1px solid; + color: #00df00; + } + TD.covered { + FONT-SIZE: 2px; BACKGROUND: #00df00; BORDER-LEFT:#9c9c9c 1px solid;BORDER-TOP:#9c9c9c 1px solid;BORDER-BOTTOM:#9c9c9c 1px solid; + color: #00df00; + } + TD.uncovered { + FONT-SIZE: 2px; BACKGROUND: #df0000; BORDER:#9c9c9c 1px solid; + color: #df0000; + } + PRE.srcLine { + BACKGROUND: #ffffff; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; + } + td.lineCount, td.coverageCount { + BACKGROUND: #F0F0F0; PADDING-RIGHT: 3px; + text-align: right; + } + td.lineCountHighlight { + background: #C8C8F0; PADDING-RIGHT: 3px; + text-align: right; + } + td.coverageCountHighlight { + background: #F0C8C8; PADDING-RIGHT: 3px; + text-align: right; + } + span.srcLineHighlight { + background: #F0C8C8; + } + span.srcLine { + background: #C8C8F0; + } + TD.srcLineClassStart { + WIDTH: 100%; BORDER-TOP:#dcdcdc 1px solid; FONT-WEIGHT: bold; + } + .srcLine , .srcLine ol, .srcLine ol li {margin: 0;} + .srcLine .de1, .srcLine .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;} + .srcLine .imp {font-weight: bold; color: red;} + .srcLine .kw1 {color: #b1b100;} + .srcLine .kw2 {color: #000000; font-weight: bold;} + .srcLine .kw3 {color: #000066;} + .srcLine .co1 {color: #808080; font-style: italic;} + .srcLine .co2 {color: #808080; font-style: italic;} + .srcLine .coMULTI {color: #808080; font-style: italic;} + .srcLine .es0 {color: #000099; font-weight: bold;} + .srcLine .br0 {color: #66cc66;} + .srcLine .st0 {color: #ff0000;} + .srcLine .nu0 {color: #cc66cc;} + .srcLine .me1 {color: #006600;} + .srcLine .me2 {color: #006600;} + .srcLine .re0 {color: #0000ff;} + - - - - - - - -

All Classes

- - - - - - - / - .html - - - - - -
- - - - (-) - - - () - - -
- - -
- - - - - - - - -

Overview

-

All Packages

- - - - - - - -
- - - -
- - -
- - - - - - - - - - - - - - - - -
Packages: Classes: Methods: LOC:
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Methods covered
Total coverage

PackagesMethods covered
- - + + + + + + +

All Classes

+ + + + + + + / + .html + + + + + +
+ + + + (-) + + + () + + +
+ -
+
- - - - - . - + + + + + + + +

Overview

+

All Packages

+ + + + + + + +
+ + + +
+ + +
- - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
-

-
- -

Classes

- - - - - + + + + + + + + +
- - - - (-) - - - () - - -
+ + + + + - -
Packages: Classes: Methods: LOC:
- - -
+ +
- - - - - - - - - - - - - - - - - -
Classes: Methods: LOC:
-
- - - - - - - - - +
PackageMethods covered
+ + + + + + + + - + - + + - - -
Methods covered
Total coverage

ClassesPackages Methods covered
- - - -
+ + + + + + + + + + + - - - - - - - - - - - - - - - - -
Methods: LOC:
-
+ + + + + . + - - - - - - - - - - - -
Source fileMethods covered
- - -
-
- - - + + + + -
+ + + + - - - - - - - - + + + + + + + + + + + + + + + + + +
- - http://phing.info/ - -

Source Code Coverage

+ + + +
+

+
+ +

Classes

+ + + + + + + +
+ + + + (-) + + + () + + +
+ + +
+ + + + + + + + + + + + + + + + + + +
Classes: Methods: LOC:
+
+ + + + + + + + + + + + + + + + + + + + +
PackageMethods covered

ClassesMethods covered
+ + + +
+ + + + + + + + + + + + + + + + + +
Methods: LOC:
+
+ + + + + + + + + + + + +
Source fileMethods covered
+ + +
+
+ + + + +
+ + + + + + + + + + + + +
+ + http://phing.info/ + +

Source Code Coverage

Designed for use with PHPUnit2, Xdebug and Phing.
+
+
+ + + + + + +

Report generated at
+
+ + - Designed for use with PHPUnit2, Xdebug and Phing. + + + - -
-
+
- - - - - -

Report generated at
-
+ + + + + + + - - - - - - - + + + + - + + + + + +
 
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
   
+ +
+
+
- - - - - - - - - - - - - - - - - - -
 
- -
- - - - - - - - - - - - - - - - - - - - - - - -
   
- -
-
-
- - - - - - - - - - 0 - - - - - - - - srcLineClassStart - + + - -
-
+ +
- -
-
+ + 0
-
+ +
- - -
+ + + srcLineClassStart + + + +
+
+
+ + +
+
+
+ +
+
+ + +
- - - - - ../ - - - - - - ../ - - + --> + + + + ../ + + + + + + ../ + + - - - - stylesheet.css - + + + + stylesheet.css + - - - - a - b - - + + + + a + b + + - - diff --git a/airtime_mvc/library/propel/test/etc/xsl/log.xsl b/airtime_mvc/library/propel/test/etc/xsl/log.xsl index a460b667c..42da8acc3 100644 --- a/airtime_mvc/library/propel/test/etc/xsl/log.xsl +++ b/airtime_mvc/library/propel/test/etc/xsl/log.xsl @@ -2,29 +2,29 @@ - + @@ -75,10 +75,10 @@ color:#FFFFFF; font-weight: bold } - .a td { + .a td { background: #efefef; } - .b td { + .b td { background: #fff; } th, td { @@ -124,7 +124,7 @@ - +

@@ -153,7 +153,7 @@ - Build Failed + Build Failed Build Complete diff --git a/airtime_mvc/library/propel/test/etc/xsl/phpunit2-noframes.xsl b/airtime_mvc/library/propel/test/etc/xsl/phpunit-noframes.xsl similarity index 97% rename from airtime_mvc/library/propel/test/etc/xsl/phpunit2-noframes.xsl rename to airtime_mvc/library/propel/test/etc/xsl/phpunit-noframes.xsl index 20b96a707..76fa46029 100644 --- a/airtime_mvc/library/propel/test/etc/xsl/phpunit2-noframes.xsl +++ b/airtime_mvc/library/propel/test/etc/xsl/phpunit-noframes.xsl @@ -22,19 +22,19 @@ See the License for the specific language governing permissions and limitations under the License. --> - + @@ -108,36 +108,36 @@ - - + + - +
- +
- + - - + +
- - - + + + - + @@ -149,7 +149,7 @@ - + @@ -171,10 +171,10 @@ -
+
- - + + @@ -187,25 +187,25 @@

Package

- + - +

- - + +

Test Cases

TestCase

- +

Unit Test Results

@@ -338,7 +338,7 @@ Error - +
diff --git a/airtime_mvc/library/propel/test/etc/xsl/str.replace.function.xsl b/airtime_mvc/library/propel/test/etc/xsl/str.replace.function.xsl index 626e5498c..96433a4ad 100644 --- a/airtime_mvc/library/propel/test/etc/xsl/str.replace.function.xsl +++ b/airtime_mvc/library/propel/test/etc/xsl/str.replace.function.xsl @@ -84,7 +84,7 @@ - + diff --git a/airtime_mvc/library/propel/test/fixtures/bookstore-packaged/build.properties b/airtime_mvc/library/propel/test/fixtures/bookstore-packaged/build.properties index 3113ded43..0c2b9e579 100644 --- a/airtime_mvc/library/propel/test/fixtures/bookstore-packaged/build.properties +++ b/airtime_mvc/library/propel/test/fixtures/bookstore-packaged/build.properties @@ -1,19 +1,19 @@ -# $Id: build.properties 1756 2010-05-10 08:54:06Z francois $ -# +# $Id$ +# # This is a project-specific build.properties file. The properties # in this file override anything set in Propel's top-level build.properties # file when *this* project is being built. # -# See top-level build.properties-sample for explanation of configuration +# See top-level build.properties-sample for explanation of configuration # options. # -# Because this file is included before the top-level build.properties file, +# Because this file is included before the top-level build.properties file, # you cannot refer to any properties set therein. propel.project = bookstore-packaged propel.database = sqlite -propel.database.url = sqlite://localhost/./test/@DB@.db -# propel.database.createUrl = (doesn't aply for SQLite, since db is auto-created) +propel.database.url = sqlite:/var/tmp/test.db +# propel.database.createUrl = (doesn't apply for SQLite, since db is auto-created) propel.targetPackage = bookstore-packaged propel.packageObjectModel = true \ No newline at end of file diff --git a/airtime_mvc/library/propel/test/fixtures/bookstore-packaged/runtime-conf.xml b/airtime_mvc/library/propel/test/fixtures/bookstore-packaged/runtime-conf.xml index be7a2bd42..225340f94 100644 --- a/airtime_mvc/library/propel/test/fixtures/bookstore-packaged/runtime-conf.xml +++ b/airtime_mvc/library/propel/test/fixtures/bookstore-packaged/runtime-conf.xml @@ -42,11 +42,7 @@ sqlite - sqlite - localhost - ./bookstore.db - - + sqlite:/var/tmp/test.db @@ -54,13 +50,9 @@ sqlite - sqlite - localhost - ./bookstore-log.db - - + sqlite:/var/tmp/test.db - \ No newline at end of file + diff --git a/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-add-class-schema.xml b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-add-class-schema.xml new file mode 100644 index 000000000..a4dff3e70 --- /dev/null +++ b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-add-class-schema.xml @@ -0,0 +1,10 @@ + + + +
+ + + +
+ +
diff --git a/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-auto-add-pk-schema.xml b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-auto-add-pk-schema.xml index 881b4d536..2f49eb071 100644 --- a/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-auto-add-pk-schema.xml +++ b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-auto-add-pk-schema.xml @@ -1,6 +1,6 @@ - + @@ -24,5 +24,5 @@
- +
diff --git a/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-concrete-inheritance-one-to-one-schema.xml b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-concrete-inheritance-one-to-one-schema.xml new file mode 100644 index 000000000..cb70e7126 --- /dev/null +++ b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-concrete-inheritance-one-to-one-schema.xml @@ -0,0 +1,25 @@ + + + + + + +
+ + + + + + +
+ + + + + + + + +
+ +
diff --git a/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-concrete-inheritance-schema.xml b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-concrete-inheritance-schema.xml index e54760333..69e67e0a7 100644 --- a/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-concrete-inheritance-schema.xml +++ b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-concrete-inheritance-schema.xml @@ -4,6 +4,13 @@ + +
+ + + + +
@@ -52,7 +59,7 @@
- + @@ -63,7 +70,15 @@ -
- + + + + + + + + +
+
diff --git a/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-nested-set-schema.xml b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-nested-set-schema.xml index c89acd437..44389247b 100644 --- a/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-nested-set-schema.xml +++ b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-nested-set-schema.xml @@ -1,6 +1,6 @@ - + diff --git a/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-schema.xml b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-schema.xml index 191b54bd1..1c98c4026 100644 --- a/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-schema.xml +++ b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-schema.xml @@ -4,7 +4,7 @@ - +
diff --git a/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-sluggable-schema.xml b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-sluggable-schema.xml index 29f962670..7eb02d253 100644 --- a/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-sluggable-schema.xml +++ b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-sluggable-schema.xml @@ -20,4 +20,25 @@
+ + + + + + + + + + +
+ + + + + + + + +
+
diff --git a/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-soft-delete-schema.xml b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-soft-delete-schema.xml index 3b9f464bf..354163241 100644 --- a/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-soft-delete-schema.xml +++ b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-soft-delete-schema.xml @@ -15,5 +15,5 @@
- +
diff --git a/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-sortable-schema.xml b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-sortable-schema.xml index 1f08c7172..42a78e779 100644 --- a/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-sortable-schema.xml +++ b/airtime_mvc/library/propel/test/fixtures/bookstore/behavior-sortable-schema.xml @@ -18,4 +18,46 @@
+ + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+
diff --git a/airtime_mvc/library/propel/test/fixtures/bookstore/build.properties b/airtime_mvc/library/propel/test/fixtures/bookstore/build.properties index 1981cc4b6..23b1d04c2 100644 --- a/airtime_mvc/library/propel/test/fixtures/bookstore/build.properties +++ b/airtime_mvc/library/propel/test/fixtures/bookstore/build.properties @@ -1,5 +1,5 @@ -# $Id: build.properties 1688 2010-04-19 20:23:27Z francois $ -# +# $Id$ +# # This is a project-specific build.properties file. The properties # in this file override anything set in Propel's top-level build.properties # file when *this* project is being built. @@ -11,17 +11,18 @@ # you cannot refer to any properties set therein. propel.project = bookstore -propel.database = mysql +propel.database = mysql propel.database.url = mysql:dbname=test -propel.mysqlTableType = InnoDB -propel.disableIdentifierQuoting=true +propel.mysql.tableType = InnoDB +propel.disableIdentifierQuoting = true +propel.schema.autoPrefix = true -# For MySQL or Oracle, you also need to specify username & password -#propel.database.user = [db username] +# For MySQL or Oracle, you also need to specify username & password +propel.database.user = root #propel.database.password = [db password] # Note that if you do not wish to specify the database (e.g. if you -# are using multiple databses) you can use the @DB@ token which +# are using multiple databases) you can use the @DB@ token which # will be replaced with a database at runtime. # E.g.: propel.database.url = sqlite://localhost/./test/@DB@.db # This will work for the datadump and the insert-sql tasks. @@ -32,4 +33,5 @@ propel.targetPackage = bookstore # We need to test behavior hooks propel.behavior.test_all_hooks.class = ../test.tools.helpers.bookstore.behavior.Testallhooksbehavior -propel.behavior.do_nothing.class = ../test.tools.helpers.bookstore.behavior.DonothingBehavior \ No newline at end of file +propel.behavior.do_nothing.class = ../test.tools.helpers.bookstore.behavior.DonothingBehavior +propel.behavior.add_class.class = ../test.tools.helpers.bookstore.behavior.AddClassBehavior diff --git a/airtime_mvc/library/propel/test/fixtures/bookstore/runtime-conf.xml b/airtime_mvc/library/propel/test/fixtures/bookstore/runtime-conf.xml index e38b7bf9f..f3fa856a8 100644 --- a/airtime_mvc/library/propel/test/fixtures/bookstore/runtime-conf.xml +++ b/airtime_mvc/library/propel/test/fixtures/bookstore/runtime-conf.xml @@ -1,34 +1,5 @@ - - - propel-bookstore - propel.log - 7 - mysql @@ -48,21 +19,21 @@ mysql:dbname=test + root + - + - + utf8 @@ -75,7 +46,7 @@ - + mysql @@ -83,9 +54,9 @@ mysql:dbname=test + root + @@ -105,9 +76,9 @@ mysql:dbname=test + root + diff --git a/airtime_mvc/library/propel/test/fixtures/bookstore/schema.xml b/airtime_mvc/library/propel/test/fixtures/bookstore/schema.xml index c55066ceb..d8d886df3 100644 --- a/airtime_mvc/library/propel/test/fixtures/bookstore/schema.xml +++ b/airtime_mvc/library/propel/test/fixtures/bookstore/schema.xml @@ -6,7 +6,7 @@ - + @@ -26,7 +26,7 @@
- +
@@ -49,13 +49,24 @@ + + + + + + + + +
+ + - + - + @@ -66,7 +77,7 @@
- + @@ -107,8 +118,8 @@ -
+ @@ -116,7 +127,7 @@
- + @@ -133,6 +144,7 @@ +
+ + + + + + + + + +
+ + + + + + + + + + +
+ @@ -155,6 +191,7 @@ + @@ -185,23 +222,31 @@
- + - + + + + + + + + +
- +
- + @@ -220,7 +265,7 @@
- + @@ -231,12 +276,12 @@ - + - +
@@ -317,4 +362,46 @@ + + + + + +
+ + + + + + + + + + + + + + +
+ + + + +
+ + + + + +
+ + + + + + + +
+ + diff --git a/airtime_mvc/library/propel/test/fixtures/generator/behavior/Foobar.php b/airtime_mvc/library/propel/test/fixtures/generator/behavior/Foobar.php new file mode 100644 index 000000000..3026c1cd3 --- /dev/null +++ b/airtime_mvc/library/propel/test/fixtures/generator/behavior/Foobar.php @@ -0,0 +1,10 @@ + - - - propel-bookstore - propel.log - 7 - mysql @@ -48,21 +19,21 @@ mysql:dbname=test + root + - + - + utf8 diff --git a/airtime_mvc/library/propel/test/fixtures/namespaced/schema.xml b/airtime_mvc/library/propel/test/fixtures/namespaced/schema.xml index 0951482aa..20e27c848 100644 --- a/airtime_mvc/library/propel/test/fixtures/namespaced/schema.xml +++ b/airtime_mvc/library/propel/test/fixtures/namespaced/schema.xml @@ -54,6 +54,7 @@ + @@ -84,4 +85,15 @@
+ + + +
+ + + + + + +
diff --git a/airtime_mvc/library/propel/test/fixtures/nestedset/build.properties b/airtime_mvc/library/propel/test/fixtures/nestedset/build.properties index 7105e18ab..085d0335c 100644 --- a/airtime_mvc/library/propel/test/fixtures/nestedset/build.properties +++ b/airtime_mvc/library/propel/test/fixtures/nestedset/build.properties @@ -1,5 +1,5 @@ -# $Id: build.properties 1260 2009-10-26 20:43:51Z francois $ -# +# $Id$ +# # This is a project-specific build.properties file. The properties # in this file override anything set in Propel's top-level build.properties # file when *this* project is being built. @@ -13,17 +13,17 @@ propel.project = nestedset propel.database = sqlite propel.database.url = sqlite:/var/tmp/nestedset.db -# For MySQL or Oracle, you also need to specify username & password +# For MySQL or Oracle, you also need to specify username & password # propel.database.user = [db username] # propel.database.password = [db password] # Note that if you do not wish to specify the database (e.g. if you -# are using multiple databses) you can use the @DB@ token which +# are using multiple databases) you can use the @DB@ token which # will be replaced with a database at runtime. # E.g.: propel.database.url = sqlite://localhost/./test/@DB@.db # This will work for the datadump and the insert-sql tasks. -# propel.database.createUrl = (doesn't aply for SQLite, since db is auto-created) +# propel.database.createUrl = (doesn't apply for SQLite, since db is auto-created) propel.targetPackage = nestedset diff --git a/airtime_mvc/library/propel/test/fixtures/nestedset/runtime-conf.xml b/airtime_mvc/library/propel/test/fixtures/nestedset/runtime-conf.xml index 8cc8fca13..5ec3bbce1 100644 --- a/airtime_mvc/library/propel/test/fixtures/nestedset/runtime-conf.xml +++ b/airtime_mvc/library/propel/test/fixtures/nestedset/runtime-conf.xml @@ -1,14 +1,14 @@ - - + - sqlite + sqlite sqlite sqlite:/var/tmp/nestedset.db - -
- + + +
diff --git a/airtime_mvc/library/propel/test/fixtures/reverse/mysql/build.properties b/airtime_mvc/library/propel/test/fixtures/reverse/mysql/build.properties new file mode 100644 index 000000000..05aaad78a --- /dev/null +++ b/airtime_mvc/library/propel/test/fixtures/reverse/mysql/build.properties @@ -0,0 +1,25 @@ +# $Id: build.properties 1968 2010-09-22 22:08:23Z francois $ +# +# This is a project-specific build.properties file. The properties +# in this file override anything set in Propel's top-level build.properties +# file when *this* project is being built. +# +# See top-level build.properties-sample for explanation of configuration +# options. +# +# Because this file is included before the top-level build.properties file, +# you cannot refer to any properties set therein. + +propel.project = reverse_bookstore + +propel.database = mysql +propel.database.url = mysql:dbname=reverse_bookstore + +# For MySQL or Oracle, you also need to specify username & password +propel.database.user = root +#propel.database.password = [db password] + +propel.mysql.tableType = InnoDB + +propel.disableIdentifierQuoting = true +propel.schema.autoPrefix = true diff --git a/airtime_mvc/library/propel/test/fixtures/reverse/mysql/build/sql/schema.sql b/airtime_mvc/library/propel/test/fixtures/reverse/mysql/build/sql/schema.sql new file mode 100644 index 000000000..4d4349b8f --- /dev/null +++ b/airtime_mvc/library/propel/test/fixtures/reverse/mysql/build/sql/schema.sql @@ -0,0 +1,19 @@ +DROP TABLE IF EXISTS book; +DROP VIEW IF EXISTS view_book_titles; + +CREATE TABLE book +( + id INTEGER NOT NULL AUTO_INCREMENT COMMENT 'Book Id', + title VARCHAR(255) NOT NULL COMMENT 'Book Title', + isbn VARCHAR(24) NOT NULL COMMENT 'ISBN Number', + price FLOAT COMMENT 'Price of the book.', + PRIMARY KEY (id) +) ENGINE=InnoDB COMMENT='Book Table'; + +CREATE VIEW view_book_titles AS SELECT title FROM book; + +DROP TABLE IF EXISTS foo; + +CREATE TABLE foo ( + `longitude` decimal(10,7) NOT NULL +) ENGINE=InnoDB; diff --git a/airtime_mvc/library/propel/test/fixtures/reverse/mysql/build/sql/sqldb.map b/airtime_mvc/library/propel/test/fixtures/reverse/mysql/build/sql/sqldb.map new file mode 100644 index 000000000..b0a32c850 --- /dev/null +++ b/airtime_mvc/library/propel/test/fixtures/reverse/mysql/build/sql/sqldb.map @@ -0,0 +1 @@ +schema.sql=reverse_bookstore diff --git a/airtime_mvc/library/propel/test/fixtures/reverse/mysql/runtime-conf.xml b/airtime_mvc/library/propel/test/fixtures/reverse/mysql/runtime-conf.xml new file mode 100644 index 000000000..c328761a3 --- /dev/null +++ b/airtime_mvc/library/propel/test/fixtures/reverse/mysql/runtime-conf.xml @@ -0,0 +1,37 @@ + + + + + + + + mysql + + DebugPDO + mysql:dbname=reverse_bookstore + + root + + + + + + + + + utf8 + + + + + + + diff --git a/airtime_mvc/library/propel/test/fixtures/reverse/pgsql/runtime-conf.xml b/airtime_mvc/library/propel/test/fixtures/reverse/pgsql/runtime-conf.xml new file mode 100644 index 000000000..d060ce54a --- /dev/null +++ b/airtime_mvc/library/propel/test/fixtures/reverse/pgsql/runtime-conf.xml @@ -0,0 +1,37 @@ + + + + + + + + pgsql + + DebugPDO + pgsql:dbname=reverse_bookstore + + + + + + + + + utf8 + + + + + + + diff --git a/airtime_mvc/library/propel/test/fixtures/schemas/build.properties b/airtime_mvc/library/propel/test/fixtures/schemas/build.properties new file mode 100644 index 000000000..545840036 --- /dev/null +++ b/airtime_mvc/library/propel/test/fixtures/schemas/build.properties @@ -0,0 +1,19 @@ +# $Id: build.properties 1968 2010-09-22 22:08:23Z francois $ +# +# This is a project-specific build.properties file. The properties +# in this file override anything set in Propel's top-level build.properties +# file when *this* project is being built. +# +# See top-level build.properties-sample for explanation of configuration +# options. +# +# Because this file is included before the top-level build.properties file, +# you cannot refer to any properties set therein. + +propel.project = bookstore +propel.database = mysql +propel.database.url = mysql:dbname=test +propel.database.user = root +propel.mysql.tableType = InnoDB +propel.disableIdentifierQuoting = true +propel.schema.autoPrefix = true diff --git a/airtime_mvc/library/propel/test/fixtures/schemas/runtime-conf.xml b/airtime_mvc/library/propel/test/fixtures/schemas/runtime-conf.xml new file mode 100644 index 000000000..76f894101 --- /dev/null +++ b/airtime_mvc/library/propel/test/fixtures/schemas/runtime-conf.xml @@ -0,0 +1,37 @@ + + + + + + + + mysql + + DebugPDO + mysql:dbname=test + + root + + + + + + + + + utf8 + + + + + + + diff --git a/airtime_mvc/library/propel/test/fixtures/schemas/schema.xml b/airtime_mvc/library/propel/test/fixtures/schemas/schema.xml new file mode 100644 index 000000000..e3bf4a881 --- /dev/null +++ b/airtime_mvc/library/propel/test/fixtures/schemas/schema.xml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + +
+ + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ +
diff --git a/airtime_mvc/library/propel/test/fixtures/treetest/build.properties b/airtime_mvc/library/propel/test/fixtures/treetest/build.properties index eca0fdfcf..1d97a2d15 100644 --- a/airtime_mvc/library/propel/test/fixtures/treetest/build.properties +++ b/airtime_mvc/library/propel/test/fixtures/treetest/build.properties @@ -1,13 +1,13 @@ -# $Id: build.properties 1260 2009-10-26 20:43:51Z francois $ -# +# $Id$ +# # This is a project-specific build.properties file. The properties # in this file override anything set in Propel's top-level build.properties # file when *this* project is being built. # -# See top-level build.properties-sample for explanation of configuration +# See top-level build.properties-sample for explanation of configuration # options. # -# Because this file is included before the top-level build.properties file, +# Because this file is included before the top-level build.properties file, # you cannot refer to any properties set therein. propel.targetPackage = treetest diff --git a/airtime_mvc/library/propel/test/fixtures/treetest/runtime-conf.xml b/airtime_mvc/library/propel/test/fixtures/treetest/runtime-conf.xml index c20f28ae4..0996495e0 100644 --- a/airtime_mvc/library/propel/test/fixtures/treetest/runtime-conf.xml +++ b/airtime_mvc/library/propel/test/fixtures/treetest/runtime-conf.xml @@ -1,14 +1,14 @@ - - + - + - sqlite + sqlite sqlite sqlite:/var/tmp/treetest.db - - - + + + diff --git a/airtime_mvc/library/propel/test/fixtures/unique-column/column-schema.xml b/airtime_mvc/library/propel/test/fixtures/unique-column/column-schema.xml deleted file mode 100644 index 6c0dcf725..000000000 --- a/airtime_mvc/library/propel/test/fixtures/unique-column/column-schema.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - -
-
diff --git a/airtime_mvc/library/propel/test/fixtures/unique-column/table-schema.xml b/airtime_mvc/library/propel/test/fixtures/unique-column/table-schema.xml deleted file mode 100644 index 0fb6b26f2..000000000 --- a/airtime_mvc/library/propel/test/fixtures/unique-column/table-schema.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - -
- - - - -
-
diff --git a/airtime_mvc/library/propel/test/reset_tests.sh b/airtime_mvc/library/propel/test/reset_tests.sh new file mode 100755 index 000000000..9d72223b6 --- /dev/null +++ b/airtime_mvc/library/propel/test/reset_tests.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# Reset Propel tests fixtures +# 2011 - William Durand + +CURRENT=`pwd` + +function rebuild +{ + local dir=$1 + + echo "[ $dir ]" + + if [ -d "$dir/build" ] ; then + rm -rf "$dir/build" + fi + + $ROOT/generator/bin/propel-gen $FIXTURES_DIR/$dir main > /dev/null + $ROOT/generator/bin/propel-gen $FIXTURES_DIR/$dir insert-sql > /dev/null +} + +ROOT_DIR="" +FIXTURES_DIR="" + +if [ -d "$CURRENT/fixtures" ] ; then + ROOT=".." + FIXTURES_DIR="$CURRENT/fixtures" +elif [ -d "$CURRENT/test/fixtures" ] ; then + ROOT="." + FIXTURES_DIR="$CURRENT/test/fixtures" +else + echo "ERROR: No 'test/fixtures/' directory found !" + exit 1 +fi + +DIRS=`ls $FIXTURES_DIR` + +for dir in $DIRS ; do + rebuild $dir +done + +# Special case for reverse fixtures + +REVERSE_DIRS=`ls $FIXTURES_DIR/reverse` + +for dir in $REVERSE_DIRS ; do + if [ -f "$FIXTURES_DIR/reverse/$dir/build.properties" ] ; then + echo "[ $dir ]" + $ROOT/generator/bin/propel-gen $FIXTURES_DIR/reverse/$dir insert-sql > /dev/null + fi +done diff --git a/airtime_mvc/library/propel/test/speed.php b/airtime_mvc/library/propel/test/speed.php deleted file mode 100644 index c013f18f5..000000000 --- a/airtime_mvc/library/propel/test/speed.php +++ /dev/null @@ -1,401 +0,0 @@ -iterations = $iterations; - } - - public function run() - { - $timers = array(); - fwrite(STDOUT, "Running scenario"); - // perform tests - for ($i=0; $i < $this->iterations; $i++) { - fwrite(STDOUT, '.'); - $this->setUp(); - $t = microtime(true); - $this->testSpeed(); - $timers[]= microtime(true) - $t; - $this->tearDown(); - } - fwrite(STDOUT, " done\n"); - // sort tests - sort($timers); - - // eliminate first and last - array_shift($timers); - array_pop($timers); - - return array_sum($timers) / count($timers); - } - - protected function emptyTables() - { - $res1 = AuthorPeer::doDeleteAll(); - $res2 = PublisherPeer::doDeleteAll(); - $res3 = AuthorPeer::doDeleteAll(); - $res4 = ReviewPeer::doDeleteAll(); - $res5 = MediaPeer::doDeleteAll(); - $res6 = BookClubListPeer::doDeleteAll(); - $res7 = BookListRelPeer::doDeleteAll(); - } - - public function setUp() - { - $this->con = Propel::getConnection(BookPeer::DATABASE_NAME); - $this->con->beginTransaction(); - $this->emptyTables(); - } - - public function tearDown() - { - $this->emptyTables(); - $this->con->commit(); - } - - public function testSpeed() - { - // Add publisher records - // --------------------- - - $scholastic = new Publisher(); - $scholastic->setName("Scholastic"); - // do not save, will do later to test cascade - - $morrow = new Publisher(); - $morrow->setName("William Morrow"); - $morrow->save(); - $morrow_id = $morrow->getId(); - - $penguin = new Publisher(); - $penguin->setName("Penguin"); - $penguin->save(); - $penguin_id = $penguin->getId(); - - $vintage = new Publisher(); - $vintage->setName("Vintage"); - $vintage->save(); - $vintage_id = $vintage->getId(); - - // Add author records - // ------------------ - - $rowling = new Author(); - $rowling->setFirstName("J.K."); - $rowling->setLastName("Rowling"); - // no save() - - $stephenson = new Author(); - $stephenson->setFirstName("Neal"); - $stephenson->setLastName("Stephenson"); - $stephenson->save(); - $stephenson_id = $stephenson->getId(); - - $byron = new Author(); - $byron->setFirstName("George"); - $byron->setLastName("Byron"); - $byron->save(); - $byron_id = $byron->getId(); - - $grass = new Author(); - $grass->setFirstName("Gunter"); - $grass->setLastName("Grass"); - $grass->save(); - $grass_id = $grass->getId(); - - // Add book records - // ---------------- - - $phoenix = new Book(); - $phoenix->setTitle("Harry Potter and the Order of the Phoenix"); - $phoenix->setISBN("043935806X"); - - // cascading save (Harry Potter) - $phoenix->setAuthor($rowling); - $phoenix->setPublisher($scholastic); - $phoenix->save(); - $phoenix_id = $phoenix->getId(); - - $qs = new Book(); - $qs->setISBN("0380977427"); - $qs->setTitle("Quicksilver"); - $qs->setAuthor($stephenson); - $qs->setPublisher($morrow); - $qs->save(); - $qs_id = $qs->getId(); - - $dj = new Book(); - $dj->setISBN("0140422161"); - $dj->setTitle("Don Juan"); - $dj->setAuthor($byron); - $dj->setPublisher($penguin); - $dj->save(); - $dj_id = $qs->getId(); - - $td = new Book(); - $td->setISBN("067972575X"); - $td->setTitle("The Tin Drum"); - $td->setAuthor($grass); - $td->setPublisher($vintage); - $td->save(); - $td_id = $td->getId(); - - // Add review records - // ------------------ - - $r1 = new Review(); - $r1->setBook($phoenix); - $r1->setReviewedBy("Washington Post"); - $r1->setRecommended(true); - $r1->setReviewDate(time()); - $r1->save(); - $r1_id = $r1->getId(); - - $r2 = new Review(); - $r2->setBook($phoenix); - $r2->setReviewedBy("New York Times"); - $r2->setRecommended(false); - $r2->setReviewDate(time()); - $r2->save(); - $r2_id = $r2->getId(); - - // Perform a "complex" search - // -------------------------- - - $results = BookQuery::create() - ->filterByTitle('Harry%') - ->find(); - - $results = BookQuery::create() - ->where('Book.ISBN IN ?', array("0380977427", "0140422161")) - ->find(); - - // Perform a "limit" search - // ------------------------ - - $results = BookQuery::create() - ->limit(2) - ->offset(1) - ->orderByTitle() - ->find(); - - // Perform a lookup & update! - // -------------------------- - - $qs_lookup = BookQuery::create()->findPk($qs_id); - $new_title = "Quicksilver (".crc32(uniqid(rand())).")"; - $qs_lookup->setTitle($new_title); - $qs_lookup->save(); - - $qs_lookup2 = BookQuery::create()->findPk($qs_id); - - // Test some basic DATE / TIME stuff - // --------------------------------- - - // that's the control timestamp. - $control = strtotime('2004-02-29 00:00:00'); - - // should be two in the db - $r = ReviewQuery::create()->findOne(); - $r_id = $r->getId(); - $r->setReviewDate($control); - $r->save(); - - $r2 = ReviewQuery::create()->findPk($r_id); - - // Testing the DATE/TIME columns - // ----------------------------- - - // that's the control timestamp. - $control = strtotime('2004-02-29 00:00:00'); - - // should be two in the db - $r = ReviewQuery::create()->findOne(); - $r_id = $r->getId(); - $r->setReviewDate($control); - $r->save(); - - $r2 = ReviewQuery::create()->findPk($r_id); - - // Testing the column validators - // ----------------------------- - - $bk1 = new Book(); - $bk1->setTitle("12345"); // min length is 10 - $ret = $bk1->validate(); - - // Unique validator - $bk2 = new Book(); - $bk2->setTitle("Don Juan"); - $ret = $bk2->validate(); - - // Now trying some more complex validation. - $auth1 = new Author(); - $auth1->setFirstName("Hans"); - // last name required; will fail - - $bk1->setAuthor($auth1); - - $rev1 = new Review(); - $rev1->setReviewDate("08/09/2001"); - // will fail: reviewed_by column required - - $bk1->addReview($rev1); - - $ret2 = $bk1->validate(); - - $bk2 = new Book(); - $bk2->setTitle("12345678901"); // passes - - $auth2 = new Author(); - $auth2->setLastName("Blah"); //passes - $auth2->setEmail("some@body.com"); //passes - $auth2->setAge(50); //passes - $bk2->setAuthor($auth2); - - $rev2 = new Review(); - $rev2->setReviewedBy("Me!"); // passes - $rev2->setStatus("new"); // passes - $bk2->addReview($rev2); - - $ret3 = $bk2->validate(); - - // Testing doCount() functionality - // ------------------------------- - - $count = BookQuery::create()->count(); - - // Testing many-to-many relationships - // ---------------------------------- - - // init book club list 1 with 2 books - - $blc1 = new BookClubList(); - $blc1->setGroupLeader("Crazyleggs"); - $blc1->setTheme("Happiness"); - - $brel1 = new BookListRel(); - $brel1->setBook($phoenix); - - $brel2 = new BookListRel(); - $brel2->setBook($dj); - - $blc1->addBookListRel($brel1); - $blc1->addBookListRel($brel2); - - $blc1->save(); - - // init book club list 2 with 1 book - - $blc2 = new BookClubList(); - $blc2->setGroupLeader("John Foo"); - $blc2->setTheme("Default"); - - $brel3 = new BookListRel(); - $brel3->setBook($phoenix); - - $blc2->addBookListRel($brel3); - - $blc2->save(); - - // re-fetch books and lists from db to be sure that nothing is cached - - $phoenix = BookQuery::create() - ->filterById($phoenix->getId()) - ->findOne(); - - $blc1 = BookClubListQuery::create() - ->filterById($blc1->getId()) - ->findOne(); - - $blc2 = BookClubListQuery::create() - ->filterbyId($blc2->getId()) - ->findOne(); - - $relCount = $phoenix->countBookListRels(); - - $relCount = $blc1->countBookListRels(); - - $relCount = $blc2->countBookListRels(); - - // Removing books that were just created - // ------------------------------------- - - $hp = BookQuery::create()->findPk($phoenix_id); - $c = new Criteria(); - $c->add(BookPeer::ID, $hp->getId()); - // The only way for cascading to work currently - // is to specify the author_id and publisher_id (i.e. the fkeys - // have to be in the criteria). - $c->add(AuthorPeer::ID, $hp->getId()); - $c->add(PublisherPeer::ID, $hp->getId()); - $c->setSingleRecord(true); - BookPeer::doDelete($c); - - // Attempting to delete books by complex criteria - BookQuery::create() - ->filterByISBN("043935806X") - ->orWhere('Book.ISBN = ?', "0380977427") - ->orWhere('Book.ISBN = ?', "0140422161") - ->delete(); - - $td->delete(); - - AuthorQuery::create()->filterById($stephenson_id)->delete(); - - AuthorQuery::create()->filterById($byron_id)->delete(); - - $grass->delete(); - - PublisherQuery::create()->filterById($morrow_id)->delete(); - - PublisherQuery::create()->filterById($penguin_id)->delete(); - - $vintage->delete(); - - // These have to be deleted manually also since we have onDelete - // set to SETNULL in the foreign keys in book. Is this correct? - $rowling->delete(); - - $scholastic->delete(); - - $blc1->delete(); - - $blc2->delete(); - } -} - -$test = new PropelSpeedTest(100); -echo "Test speed: {$test->run()} ({$test->iterations} iterations)\n"; diff --git a/airtime_mvc/library/propel/test/test.xml b/airtime_mvc/library/propel/test/test.xml index e97215e7f..f6c95abe9 100644 --- a/airtime_mvc/library/propel/test/test.xml +++ b/airtime_mvc/library/propel/test/test.xml @@ -5,8 +5,8 @@ ========================================================================================= Global Properties ~~~~~~~~~~~~~~~~~ - - ========================================================================================= + + ========================================================================================= --> @@ -25,8 +25,8 @@ ========================================================================================= PHPUnit Targets ~~~~~~~~~~~~~~~~ - - ========================================================================================= + + ========================================================================================= --> @@ -63,14 +63,14 @@ - + - - + + diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/AddClassBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/AddClassBehaviorTest.php new file mode 100644 index 000000000..1e9e38689 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/AddClassBehaviorTest.php @@ -0,0 +1,26 @@ +assertTrue($t instanceof AddClassTableFooClass, 'behaviors can generate classes that are autoloaded'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/AlternativeCodingStandardsBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/AlternativeCodingStandardsBehaviorTest.php new file mode 100644 index 000000000..10c8df1ba --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/AlternativeCodingStandardsBehaviorTest.php @@ -0,0 +1,64 @@ +filter($input); + $this->assertEquals($output, $input); + } +} + +class TestableAlternativeCodingStandardsBehavior extends AlternativeCodingStandardsBehavior +{ + public function filter(&$script) + { + return parent::filter($script); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/AutoAddPkBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/AutoAddPkBehaviorTest.php index a59f84575..0ffc18bfd 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/AutoAddPkBehaviorTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/AutoAddPkBehaviorTest.php @@ -1,7 +1,7 @@ assertEquals(count($table6->getColumns()), 2, 'auto_add_pk adds one column by default'); - $pks = $table6->getPrimaryKeys(); - $this->assertEquals(count($pks), 1, 'auto_add_pk adds a simple primary key by default'); - $pk = array_pop($pks); - $this->assertEquals($pk->getName(), 'ID', 'auto_add_pk adds an id column by default'); - $this->assertEquals($pk->getType(), 'INTEGER', 'auto_add_pk adds an integer column by default'); - $this->assertTrue($pk->isPrimaryKey(), 'auto_add_pk adds a primary key column by default'); - $this->assertTrue($table6->isUseIdGenerator(), 'auto_add_pk adds an autoIncrement column by default'); - } + public function testDefault() + { + $table6 = Table6Peer::getTableMap(); + $this->assertEquals(count($table6->getColumns()), 2, 'auto_add_pk adds one column by default'); + $pks = $table6->getPrimaryKeys(); + $this->assertEquals(count($pks), 1, 'auto_add_pk adds a simple primary key by default'); + $pk = array_pop($pks); + $this->assertEquals($pk->getName(), 'id', 'auto_add_pk adds an id column by default'); + $this->assertEquals($pk->getType(), 'INTEGER', 'auto_add_pk adds an integer column by default'); + $this->assertTrue($pk->isPrimaryKey(), 'auto_add_pk adds a primary key column by default'); + $this->assertTrue($table6->isUseIdGenerator(), 'auto_add_pk adds an autoIncrement column by default'); + } - public function testNoTrigger() - { - $table7 = Table7Peer::getTableMap(); - $this->assertEquals(count($table7->getColumns()), 2, 'auto_add_pk does not add a column when the table already has a primary key'); - $this->assertFalse(method_exists('Table7', 'getId'), 'auto_add_pk does not add an id column when the table already has a primary key'); - $pks = $table7->getPrimaryKeys(); - $pk = array_pop($pks); - $this->assertEquals($pk->getName(), 'FOO', 'auto_add_pk does not change an existing primary key'); - } + public function testNoTrigger() + { + $table7 = Table7Peer::getTableMap(); + $this->assertEquals(count($table7->getColumns()), 2, 'auto_add_pk does not add a column when the table already has a primary key'); + $this->assertFalse(method_exists('Table7', 'getId'), 'auto_add_pk does not add an id column when the table already has a primary key'); + $pks = $table7->getPrimaryKeys(); + $pk = array_pop($pks); + $this->assertEquals($pk->getName(), 'foo', 'auto_add_pk does not change an existing primary key'); + } - public function testParameters() - { - $table8 = Table8Peer::getTableMap(); - $this->assertEquals(count($table8->getColumns()), 3, 'auto_add_pk adds one column with custom parameters'); - $pks = $table8->getPrimaryKeys(); - $pk = array_pop($pks); - $this->assertEquals($pk->getName(), 'IDENTIFIER', 'auto_add_pk accepts customization of pk column name'); - $this->assertEquals($pk->getType(), 'BIGINT', 'auto_add_pk accepts customization of pk column type'); - $this->assertTrue($pk->isPrimaryKey(), 'auto_add_pk adds a primary key column with custom parameters'); - $this->assertFalse($table8->isUseIdGenerator(), 'auto_add_pk accepts customization of pk column autoIncrement'); - } + public function testParameters() + { + $table8 = Table8Peer::getTableMap(); + $this->assertEquals(count($table8->getColumns()), 3, 'auto_add_pk adds one column with custom parameters'); + $pks = $table8->getPrimaryKeys(); + $pk = array_pop($pks); + $this->assertEquals($pk->getName(), 'identifier', 'auto_add_pk accepts customization of pk column name'); + $this->assertEquals($pk->getType(), 'BIGINT', 'auto_add_pk accepts customization of pk column type'); + $this->assertTrue($pk->isPrimaryKey(), 'auto_add_pk adds a primary key column with custom parameters'); + $this->assertFalse($table8->isUseIdGenerator(), 'auto_add_pk accepts customization of pk column autoIncrement'); + } - public function testForeignKey() - { - $t6 = new Table6(); - $t6->setTitle('foo'); - $t6->save(); - $t8 = new Table8(); - $t8->setIdentifier(1); - $t8->setTable6($t6); - $t8->save(); - $this->assertEquals($t8->getFooId(), $t6->getId(), 'Auto added pkeys can be used in relations'); - $t8->delete(); - $t6->delete(); - } -} \ No newline at end of file + public function testForeignKey() + { + $t6 = new Table6(); + $t6->setTitle('foo'); + $t6->save(); + $t8 = new Table8(); + $t8->setIdentifier(1); + $t8->setTable6($t6); + $t8->save(); + $this->assertEquals($t8->getFooId(), $t6->getId(), 'Auto added pkeys can be used in relations'); + $t8->delete(); + $t6->delete(); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/DelegateBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/DelegateBehaviorTest.php new file mode 100644 index 000000000..a0d814755 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/DelegateBehaviorTest.php @@ -0,0 +1,270 @@ + + + + + + + + + + + + +
+ + + +
+ + + + + + + +
+ + + +
+ + + + + +
+ + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + +
+ + +EOF; + PropelQuickBuilder::buildSchema($schema); + } + } + + public function testModifyTableRelatesOneToOneDelegate() + { + $delegateTable = DelegateDelegatePeer::getTableMap(); + $this->assertEquals(2, count($delegateTable->getColumns())); + $this->assertEquals(1, count($delegateTable->getRelations())); + $this->assertTrue(method_exists('DelegateMain', 'getDelegateDelegate')); + $this->assertTrue(method_exists('DelegateDelegate', 'getDelegateMain')); + } + + public function testOneToOneDelegationCreatesANewDelegateIfNoneExists() + { + $main = new DelegateMain(); + $main->setSubtitle('foo'); + $delegate = $main->getDelegateDelegate(); + $this->assertInstanceOf('DelegateDelegate', $delegate); + $this->assertTrue($delegate->isNew()); + $this->assertEquals('foo', $delegate->getSubtitle()); + $this->assertEquals('foo', $main->getSubtitle()); + } + + public function testManyToOneDelegationCreatesANewDelegateIfNoneExists() + { + $main = new DelegateMain(); + $main->setSummary('foo'); + $delegate = $main->getSecondDelegateDelegate(); + $this->assertInstanceOf('SecondDelegateDelegate', $delegate); + $this->assertTrue($delegate->isNew()); + $this->assertEquals('foo', $delegate->getSummary()); + $this->assertEquals('foo', $main->getSummary()); + } + + public function testOneToOneDelegationUsesExistingDelegateIfExists() + { + $main = new DelegateMain(); + $delegate = new DelegateDelegate(); + $delegate->setSubtitle('bar'); + $main->setDelegateDelegate($delegate); + $this->assertEquals('bar', $main->getSubtitle()); + } + + public function testManyToOneDelegationUsesExistingDelegateIfExists() + { + $main = new DelegateMain(); + $delegate = new SecondDelegateDelegate(); + $delegate->setSummary('bar'); + $main->setSecondDelegateDelegate($delegate); + $this->assertEquals('bar', $main->getSummary()); + } + + public function testAModelCanHaveSeveralDelegates() + { + $main = new DelegateMain(); + $main->setSubtitle('foo'); + $main->setSummary('bar'); + $delegate = $main->getDelegateDelegate(); + $this->assertInstanceOf('DelegateDelegate', $delegate); + $this->assertTrue($delegate->isNew()); + $this->assertEquals('foo', $delegate->getSubtitle()); + $this->assertEquals('foo', $main->getSubtitle()); + $delegate = $main->getSecondDelegateDelegate(); + $this->assertInstanceOf('SecondDelegateDelegate', $delegate); + $this->assertTrue($delegate->isNew()); + $this->assertEquals('bar', $delegate->getSummary()); + $this->assertEquals('bar', $main->getSummary()); + } + + /** + * @expectedException PropelException + */ + public function testAModelCannotHaveCascadingDelegates() + { + $main = new DelegateMain(); + $main->setSummary('bar'); + $main->setBody('baz'); + } + + public function testOneToOneDelegatesCanBePersisted() + { + $main = new DelegateMain(); + $main->setSubtitle('foo'); + $main->save(); + $this->assertFalse($main->isNew()); + $this->assertFalse($main->getDelegateDelegate()->isNew()); + $this->assertNull($main->getSecondDelegateDelegate()); + } + + public function testManyToOneDelegatesCanBePersisted() + { + $main = new DelegateMain(); + $main->setSummary('foo'); + $main->save(); + $this->assertFalse($main->isNew()); + $this->assertFalse($main->getSecondDelegateDelegate()->isNew()); + $this->assertNull($main->getDelegateDelegate()); + } + + public function testDelegateSimulatesClassTableInheritance() + { + $basketballer = new DelegateBasketballer(); + $basketballer->setPoints(101); + $basketballer->setFieldGoals(47); + $this->assertNull($basketballer->getDelegatePlayer()); + $basketballer->setFirstName('Michael'); + $basketballer->setLastName('Giordano'); + $this->assertNotNull($basketballer->getDelegatePlayer()); + $this->assertEquals('Michael', $basketballer->getDelegatePlayer()->getFirstName()); + $this->assertEquals('Michael', $basketballer->getFirstName()); + $basketballer->save(); // should not throw exception + } + + public function testDelegateSimulatesMultipleClassTableInheritance() + { + $footballer = new DelegateFootballer(); + $footballer->setGoalsScored(43); + $footballer->setFoulsCommitted(4); + $this->assertNull($footballer->getDelegatePlayer()); + $this->assertNull($footballer->getDelegateTeam()); + $footballer->setFirstName('Michael'); + $footballer->setLastName('Giordano'); + $this->assertNotNull($footballer->getDelegatePlayer()); + $this->assertEquals('Michael', $footballer->getDelegatePlayer()->getFirstName()); + $this->assertEquals('Michael', $footballer->getFirstName()); + $footballer->setName('Saint Etienne'); + $this->assertNotNull($footballer->getDelegateTeam()); + $this->assertEquals('Saint Etienne', $footballer->getDelegateTeam()->getName()); + $this->assertEquals('Saint Etienne', $footballer->getName()); + $footballer->save(); // should not throw exception + } + + public function testTablePrefixSameDatabase() + { + $schema = << + + + + + + + + + + + +
+ + + + +
+ + +EOF; + PropelQuickBuilder::buildSchema($schema); + $main = new TestTablePrefixSameDatabaseMain(); + $main->setSubtitle('bar'); + $delegate = $main->getTestTablePrefixSameDatabaseDelegate(); + $this->assertInstanceOf('TestTablePrefixSameDatabaseDelegate', $delegate); + $this->assertTrue($delegate->isNew()); + $this->assertEquals('bar', $delegate->getSubtitle()); + $this->assertEquals('bar', $main->getSubtitle()); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/NamespacedBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/NamespacedBehaviorTest.php new file mode 100644 index 000000000..b9d58caf7 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/NamespacedBehaviorTest.php @@ -0,0 +1,32 @@ + + + + + +
+ +SCHEMA; + + $generatorConfig = new \QuickGeneratorConfig(); + $generatorConfig->setBuildProperty('behaviorFoobarClass','Foobar\\Behavior\\Foobar'); + $builder = new \PropelQuickBuilder(); + $builder->setConfig($generatorConfig); + $builder->setSchema($schema); + $builder->build(); + + $this->assertTrue(class_exists('DummyTable'),'dummy table class is correctly generated'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/ObjectBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/ObjectBehaviorTest.php index f42c8e9c2..5255b898d 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/ObjectBehaviorTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/ObjectBehaviorTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; /** * Tests the generated Object behavior hooks. @@ -23,7 +23,7 @@ class ObjectBehaviorTest extends BookstoreTestBase $t = new Table3(); $this->assertEquals($t->customAttribute, 1, 'objectAttributes hook is called when adding attributes'); } - + public function testPreSave() { $t = new Table3(); @@ -37,7 +37,7 @@ class ObjectBehaviorTest extends BookstoreTestBase $t->save(); $this->assertEquals($t->preSave, 1, 'preSave hook is called on object modification'); } - + public function testPostSave() { $t = new Table3(); @@ -51,7 +51,7 @@ class ObjectBehaviorTest extends BookstoreTestBase $t->save(); $this->assertEquals($t->postSave, 1, 'postSave hook is called on object modification'); } - + public function testPreInsert() { $t = new Table3(); @@ -65,7 +65,7 @@ class ObjectBehaviorTest extends BookstoreTestBase $t->save(); $this->assertEquals($t->preInsert, 0, 'preInsert hook is not called on object modification'); } - + public function testPostInsert() { $t = new Table3(); @@ -79,7 +79,7 @@ class ObjectBehaviorTest extends BookstoreTestBase $t->save(); $this->assertEquals($t->postInsert, 0, 'postInsert hook is not called on object modification'); } - + public function testPreUpdate() { $t = new Table3(); @@ -93,7 +93,7 @@ class ObjectBehaviorTest extends BookstoreTestBase $this->assertEquals($t->preUpdateBuilder, 'PHP5ObjectBuilder', 'preUpdate hook is called with the object builder as parameter'); $this->assertFalse($t->preUpdateIsAfterSave, 'preUpdate hook is called before save'); } - + public function testPostUpdate() { $t = new Table3(); @@ -107,7 +107,7 @@ class ObjectBehaviorTest extends BookstoreTestBase $this->assertEquals($t->postUpdateBuilder, 'PHP5ObjectBuilder', 'postUpdate hook is called with the object builder as parameter'); $this->assertTrue($t->postUpdateIsAfterSave, 'postUpdate hook is called after save'); } - + public function testPreDelete() { $t = new Table3(); @@ -118,7 +118,7 @@ class ObjectBehaviorTest extends BookstoreTestBase $this->assertEquals($t->preDeleteBuilder, 'PHP5ObjectBuilder', 'preDelete hook is called with the object builder as parameter'); $this->assertTrue($t->preDeleteIsBeforeDelete, 'preDelete hook is called before deletion'); } - + public function testPostDelete() { $t = new Table3(); @@ -129,20 +129,30 @@ class ObjectBehaviorTest extends BookstoreTestBase $this->assertEquals($t->postDeleteBuilder, 'PHP5ObjectBuilder', 'postDelete hook is called with the object builder as parameter'); $this->assertFalse($t->postDeleteIsBeforeDelete, 'postDelete hook is called before deletion'); } - + + public function testPostHydrate() + { + $t = new Table3(); + $t->postHydrate = 0; + $t->hydrate(array(1, 'Title', 'Test')); + $this->assertEquals($t->postHydrate, 1, 'postHydrate hook is called on object hydration'); + $this->assertEquals($t->postHydrateBuilder, 'PHP5ObjectBuilder', 'postHydrate hook is called with the object builder as parameter'); + $this->assertTrue($t->postHydrateIsAfterHydrate, 'postHydrate hook is called after hydrate'); + } + public function testObjectMethods() { $t = new Table3(); $this->assertTrue(method_exists($t, 'hello'), 'objectMethods hook is called when adding methods'); $this->assertEquals($t->hello(), 'PHP5ObjectBuilder', 'objectMethods hook is called with the object builder as parameter'); } - + public function testObjectCall() { - $t = new Table3(); - $this->assertEquals('bar', $t->foo(), 'objectCall hook is called when building the magic __call()'); + $t = new Table3(); + $this->assertEquals('bar', $t->foo(), 'objectCall hook is called when building the magic __call()'); } - + public function testObjectFilter() { $t = new Table3(); diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/PeerBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/PeerBehaviorTest.php index 5e968f2c4..4c1e78cbb 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/PeerBehaviorTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/PeerBehaviorTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; /** * Tests the generated Peer behavior hooks. @@ -23,13 +23,13 @@ class PeerBehaviorTest extends BookstoreTestBase $this->assertEquals(Table3Peer::$customStaticAttribute, 1, 'staticAttributes hook is called when adding attributes'); $this->assertEquals(Table3Peer::$staticAttributeBuilder, 'PHP5PeerBuilder', 'staticAttributes hook is called with the peer builder as parameter'); } - + public function testStaticMethods() { $this->assertTrue(method_exists('Table3Peer', 'hello'), 'staticMethods hook is called when adding methods'); $this->assertEquals(Table3Peer::hello(), 'PHP5PeerBuilder', 'staticMethods hook is called with the peer builder as parameter'); } - + public function testPreSelect() { $con = Propel::getConnection(Table3Peer::DATABASE_NAME, Propel::CONNECTION_READ); @@ -51,7 +51,7 @@ class PeerBehaviorTest extends BookstoreTestBase Table3Peer::doSelect(new Criteria, $con); $this->assertEquals($con->preSelect, 'PHP5PeerBuilder', 'preSelect hook is called with the peer builder as parameter'); } - + public function testPeerFilter() { Table3Peer::TABLE_NAME; diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/SoftDeleteBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/SoftDeleteBehaviorTest.php index 2f3fecb97..45bd5410e 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/SoftDeleteBehaviorTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/SoftDeleteBehaviorTest.php @@ -1,7 +1,7 @@ assertEquals(count($table2->getColumns()), 3, 'SoftDelete adds one columns by default'); - $this->assertTrue(method_exists('Table4', 'getDeletedAt'), 'SoftDelete adds an updated_at column by default'); - $table1 = Table5Peer::getTableMap(); - $this->assertEquals(count($table1->getColumns()), 3, 'SoftDelete does not add a column when it already exists'); - $this->assertTrue(method_exists('Table5', 'getDeletedOn'), 'SoftDelete allows customization of deleted_column name'); - } - - public function testStaticSoftDeleteStatus() - { - $this->assertTrue(Table4Peer::isSoftDeleteEnabled(), 'The static soft delete is enabled by default'); - Table4Peer::disableSoftDelete(); - $this->assertFalse(Table4Peer::isSoftDeleteEnabled(), 'disableSoftDelete() disables the static soft delete'); - Table4Peer::enableSoftDelete(); - $this->assertTrue(Table4Peer::isSoftDeleteEnabled(), 'enableSoftDelete() enables the static soft delete'); - } - - public function testInstancePoolingAndSoftDelete() - { - Table4Peer::doForceDeleteAll($this->con); - $t = new Table4(); - $t->save($this->con); - Table4Peer::enableSoftDelete(); - $t->delete($this->con); - $t2 = Table4Peer::retrieveByPk($t->getPrimaryKey(), $this->con); - $this->assertNull($t2, 'An object is removed from the instance pool on soft deletion'); - Table4Peer::disableSoftDelete(); - $t2 = Table4Peer::retrieveByPk($t->getPrimaryKey(), $this->con); - $this->assertNotNull($t2); - Table4Peer::enableSoftDelete(); - $t2 = Table4Peer::retrieveByPk($t->getPrimaryKey(), $this->con); - $this->assertNull($t2, 'A soft deleted object is removed from the instance pool when the soft delete behavior is enabled'); - } - - public function testStaticDoForceDelete() - { - $t1 = new Table4(); - $t1->save(); - Table4Peer::doForceDelete($t1); - Table4Peer::disableSoftDelete(); - $this->assertEquals(0, Table4Peer::doCount(new Criteria()), 'doForceDelete() actually deletes records'); - } - - public function testStaticDoSoftDelete() - { - $t1 = new Table4(); - $t1->save(); - $t2 = new Table4(); - $t2->save(); - $t3 = new Table4(); - $t3->save(); - // softDelete with a criteria - $c = new Criteria(); - $c->add(Table4Peer::ID, $t1->getId()); - Table4Peer::doSoftDelete($c); - Table4Peer::disableSoftDelete(); - $this->assertEquals(3, Table4Peer::doCount(new Criteria()), 'doSoftDelete() keeps deleted record in the database'); - Table4Peer::enableSoftDelete(); - $this->assertEquals(2, Table4Peer::doCount(new Criteria()), 'doSoftDelete() marks deleted record as deleted'); - // softDelete with a value - Table4Peer::doSoftDelete(array($t2->getId())); - Table4Peer::disableSoftDelete(); - $this->assertEquals(3, Table4Peer::doCount(new Criteria()), 'doSoftDelete() keeps deleted record in the database'); - Table4Peer::enableSoftDelete(); - $this->assertEquals(1, Table4Peer::doCount(new Criteria()), 'doSoftDelete() marks deleted record as deleted'); - // softDelete with an object - Table4Peer::doSoftDelete($t3); - Table4Peer::disableSoftDelete(); - $this->assertEquals(3, Table4Peer::doCount(new Criteria()), 'doSoftDelete() keeps deleted record in the database'); - Table4Peer::enableSoftDelete(); - $this->assertEquals(0, Table4Peer::doCount(new Criteria()), 'doSoftDelete() marks deleted record as deleted'); - } - - public function testStaticDoDelete() - { - $t1 = new Table4(); - $t1->save(); - $t2 = new Table4(); - $t2->save(); - Table4Peer::disableSoftDelete(); - Table4Peer::doDelete($t1); - Table4Peer::disableSoftDelete(); - $this->assertEquals(1, Table4Peer::doCount(new Criteria()), 'doDelete() calls doForceDelete() when soft delete is disabled'); - Table4Peer::enableSoftDelete(); - Table4Peer::doDelete($t2); - Table4Peer::disableSoftDelete(); - $this->assertEquals(1, Table4Peer::doCount(new Criteria()), 'doDelete() calls doSoftDelete() when soft delete is enabled'); - Table4Peer::enableSoftDelete(); - $this->assertEquals(0, Table4Peer::doCount(new Criteria()), 'doDelete() calls doSoftDelete() when soft delete is enabled'); - } - - public function testStaticDoForceDeleteAll() - { - $t1 = new Table4(); - $t1->save(); - Table4Peer::doForceDeleteAll(); - Table4Peer::disableSoftDelete(); - $this->assertEquals(0, Table4Peer::doCount(new Criteria()), 'doForceDeleteAll() actually deletes records'); - } - - public function testStaticDoSoftDeleteAll() - { - $t1 = new Table4(); - $t1->save(); - $t2 = new Table4(); - $t2->save(); - Table4Peer::enableSoftDelete(); - Table4Peer::doSoftDeleteAll(); - Table4Peer::disableSoftDelete(); - $this->assertEquals(2, Table4Peer::doCount(new Criteria()), 'doSoftDeleteAll() keeps deleted record in the database'); - Table4Peer::enableSoftDelete(); - $this->assertEquals(0, Table4Peer::doCount(new Criteria()), 'doSoftDeleteAll() marks deleted record as deleted'); - } - - public function testStaticDoDeleteAll() - { - $t1 = new Table4(); - $t1->save(); - $t2 = new Table4(); - $t2->save(); - Table4Peer::disableSoftDelete(); - Table4Peer::doDeleteAll(); - Table4Peer::disableSoftDelete(); - $this->assertEquals(0, Table4Peer::doCount(new Criteria()), 'doDeleteAll() calls doForceDeleteAll() when soft delete is disabled'); - $t1 = new Table4(); - $t1->save(); - $t2 = new Table4(); - $t2->save(); - Table4Peer::enableSoftDelete(); - Table4Peer::doDeleteAll(); - Table4Peer::disableSoftDelete(); - $this->assertEquals(2, Table4Peer::doCount(new Criteria()), 'doDeleteAll() calls doSoftDeleteAll() when soft delete is disabled'); - Table4Peer::enableSoftDelete(); - $this->assertEquals(0, Table4Peer::doCount(new Criteria()), 'doDeleteAll() calls doSoftDeleteAll() when soft delete is disabled'); - } - - public function testSelect() - { - $t = new Table4(); - $t->setDeletedAt(123); - $t->save(); - Table4Peer::enableSoftDelete(); - $this->assertEquals(0, Table4Peer::doCount(new Criteria), 'rows with a deleted_at date are hidden for select queries'); - Table4Peer::disableSoftDelete(); - $this->assertEquals(1, Table4Peer::doCount(new Criteria), 'rows with a deleted_at date are visible for select queries once the static soft_delete is enabled'); - $this->assertTrue(Table4Peer::isSoftDeleteEnabled(), 'Executing a select query enables the static soft delete again'); - } - - public function testDelete() - { - $t = new Table4(); - $t->save(); - $this->assertNull($t->getDeletedAt(), 'deleted_column is null by default'); - $t->delete(); - $this->assertNotNull($t->getDeletedAt(), 'deleted_column is not null after a soft delete'); - $this->assertEquals(0, Table4Peer::doCount(new Criteria), 'soft deleted rows are hidden for select queries'); - Table4Peer::disableSoftDelete(); - $this->assertEquals(1, Table4Peer::doCount(new Criteria), 'soft deleted rows are still present in the database'); - } - public function testDeleteUndeletable() - { - $t = new UndeletableTable4(); - $t->save(); - $t->delete(); - $this->assertNull($t->getDeletedAt(), 'soft_delete is not triggered for objects wit ha preDelete hook returning false'); - $this->assertEquals(1, Table4Peer::doCount(new Criteria), 'soft_delete is not triggered for objects wit ha preDelete hook returning false'); - } + protected function setUp() + { + parent::setUp(); + Table4Peer::disableSoftDelete(); + Table4Peer::doDeleteAll(); + Table4Peer::enableSoftDelete(); + } - public function testUnDelete() - { - $t = new Table4(); - $t->save(); - $t->delete(); - $t->undelete(); - $this->assertNull($t->getDeletedAt(), 'deleted_column is null again after an undelete'); - $this->assertEquals(1, Table4Peer::doCount(new Criteria), 'undeleted rows are visible for select queries'); - } - - public function testForceDelete() - { - $t = new Table4(); - $t->save(); - $t->forceDelete(); - $this->assertTrue($t->isDeleted(), 'forceDelete() actually deletes a row'); - Table4Peer::disableSoftDelete(); - $this->assertEquals(0, Table4Peer::doCount(new Criteria), 'forced deleted rows are not present in the database'); - } - - public function testQueryIncludeDeleted() - { - $t = new Table4(); - $t->setDeletedAt(123); - $t->save(); - Table4Peer::enableSoftDelete(); - $this->assertEquals(0, Table4Query::create()->count(), 'rows with a deleted_at date are hidden for select queries'); - $this->assertEquals(1, Table4Query::create()->includeDeleted()->count(), 'rows with a deleted_at date are visible for select queries using includeDeleted()'); - } - - public function testQueryForceDelete() - { - $t1 = new Table4(); - $t1->save(); - Table4Query::create()->filterById($t1->getId())->forceDelete(); - Table4Peer::disableSoftDelete(); - $this->assertEquals(0, Table4Query::create()->count(), 'forceDelete() actually deletes records'); - } + public function testParameters() + { + $table2 = Table4Peer::getTableMap(); + $this->assertEquals(count($table2->getColumns()), 3, 'SoftDelete adds one columns by default'); + $this->assertTrue(method_exists('Table4', 'getDeletedAt'), 'SoftDelete adds an updated_at column by default'); + $table1 = Table5Peer::getTableMap(); + $this->assertEquals(count($table1->getColumns()), 3, 'SoftDelete does not add a column when it already exists'); + $this->assertTrue(method_exists('Table5', 'getDeletedOn'), 'SoftDelete allows customization of deleted_column name'); + } - public function testQuerySoftDelete() - { - $t1 = new Table4(); - $t1->save(); - $t2 = new Table4(); - $t2->save(); - $t3 = new Table4(); - $t3->save(); - - Table4Query::create() - ->filterById($t1->getId()) - ->softDelete(); - Table4Peer::disableSoftDelete(); - $this->assertEquals(3, Table4Query::create()->count(), 'softDelete() keeps deleted record in the database'); - Table4Peer::enableSoftDelete(); - $this->assertEquals(2, Table4Query::create()->count(), 'softDelete() marks deleted record as deleted'); - } - - public function testQueryDelete() - { - $t1 = new Table4(); - $t1->save(); - $t2 = new Table4(); - $t2->save(); - - Table4Peer::disableSoftDelete(); - Table4Query::create()->filterById($t1->getId())->delete(); - Table4Peer::disableSoftDelete(); - $this->assertEquals(1, Table4Query::create()->count(), 'delete() calls forceDelete() when soft delete is disabled'); - Table4Peer::enableSoftDelete(); - Table4Query::create()->filterById($t2->getId())->delete(); - Table4Peer::disableSoftDelete(); - $this->assertEquals(1, Table4Query::create()->count(), 'delete() calls softDelete() when soft delete is enabled'); - Table4Peer::enableSoftDelete(); - $this->assertEquals(0, Table4Query::create()->count(), 'delete() calls softDelete() when soft delete is enabled'); - } - - public function testQueryForceDeleteAll() - { - $t1 = new Table4(); - $t1->save(); - Table4Query::create()->forceDeleteAll(); - Table4Peer::disableSoftDelete(); - $this->assertEquals(0, Table4Query::create()->count(), 'forceDeleteAll() actually deletes records'); - } + public function testStaticSoftDeleteStatus() + { + $this->assertTrue(Table4Peer::isSoftDeleteEnabled(), 'The static soft delete is enabled by default'); + Table4Peer::disableSoftDelete(); + $this->assertFalse(Table4Peer::isSoftDeleteEnabled(), 'disableSoftDelete() disables the static soft delete'); + Table4Peer::enableSoftDelete(); + $this->assertTrue(Table4Peer::isSoftDeleteEnabled(), 'enableSoftDelete() enables the static soft delete'); + } - public function testQuerySoftDeleteAll() - { - $t1 = new Table4(); - $t1->save(); - $t2 = new Table4(); - $t2->save(); - Table4Peer::enableSoftDelete(); - Table4Query::create()->softDelete(); - Table4Peer::disableSoftDelete(); - $this->assertEquals(2, Table4Query::create()->count(), 'softDelete() keeps deleted record in the database'); - Table4Peer::enableSoftDelete(); - $this->assertEquals(0, Table4Query::create()->count(), 'softDelete() marks deleted record as deleted'); - } + public function testInstancePoolingAndSoftDelete() + { + Table4Peer::doForceDeleteAll($this->con); + $t = new Table4(); + $t->save($this->con); + Table4Peer::enableSoftDelete(); + $t->delete($this->con); + $t2 = Table4Peer::retrieveByPk($t->getPrimaryKey(), $this->con); + $this->assertNull($t2, 'An object is removed from the instance pool on soft deletion'); + Table4Peer::disableSoftDelete(); + $t2 = Table4Peer::retrieveByPk($t->getPrimaryKey(), $this->con); + $this->assertNotNull($t2); + Table4Peer::enableSoftDelete(); + $t2 = Table4Peer::retrieveByPk($t->getPrimaryKey(), $this->con); + $this->assertNull($t2, 'A soft deleted object is removed from the instance pool when the soft delete behavior is enabled'); + } - public function testQueryDeleteAll() - { - $t1 = new Table4(); - $t1->save(); - $t2 = new Table4(); - $t2->save(); - Table4Peer::disableSoftDelete(); - Table4Query::create()->deleteAll(); - Table4Peer::disableSoftDelete(); - $this->assertEquals(0, Table4Query::create()->count(), 'deleteAll() calls forceDeleteAll() when soft delete is disabled'); - - $t1 = new Table4(); - $t1->save(); - $t2 = new Table4(); - $t2->save(); - Table4Peer::enableSoftDelete(); - Table4Query::create()->deleteAll(); - Table4Peer::disableSoftDelete(); - $this->assertEquals(2, Table4Query::create()->count(), 'deleteAll() calls softDeleteAll() when soft delete is disabled'); - Table4Peer::enableSoftDelete(); - $this->assertEquals(0, Table4Query::create()->count(), 'deleteAll() calls softDeleteAll() when soft delete is disabled'); - } + public function testStaticDoForceDelete() + { + $t1 = new Table4(); + $t1->save(); + Table4Peer::doForceDelete($t1); + Table4Peer::disableSoftDelete(); + $this->assertEquals(0, Table4Peer::doCount(new Criteria()), 'doForceDelete() actually deletes records'); + } - public function testQuerySelect() - { - $t = new Table4(); - $t->setDeletedAt(123); - $t->save(); - Table4Peer::enableSoftDelete(); - $this->assertEquals(0, Table4Query::create()->count(), 'rows with a deleted_at date are hidden for select queries'); - Table4Peer::disableSoftDelete(); - $this->assertEquals(1, Table4Query::create()->count(), 'rows with a deleted_at date are visible for select queries once the static soft_delete is enabled'); - $this->assertTrue(Table4Peer::isSoftDeleteEnabled(), 'Executing a select query enables the static soft delete again'); - } - - public function testCustomization() - { - Table5Peer::disableSoftDelete(); - Table5Peer::doDeleteAll(); - Table5Peer::enableSoftDelete(); - $t = new Table5(); - $t->save(); - $this->assertNull($t->getDeletedOn(), 'deleted_column is null by default'); - $t->delete(); - $this->assertNotNull($t->getDeletedOn(), 'deleted_column is not null after a soft delete'); - $this->assertEquals(0, Table5Peer::doCount(new Criteria), 'soft deleted rows are hidden for select queries'); - Table5Peer::disableSoftDelete(); - $this->assertEquals(1, Table5Peer::doCount(new Criteria), 'soft deleted rows are still present in the database'); - } + public function testStaticDoSoftDelete() + { + $t1 = new Table4(); + $t1->save(); + $t2 = new Table4(); + $t2->save(); + $t3 = new Table4(); + $t3->save(); + // softDelete with a criteria + $c = new Criteria(); + $c->add(Table4Peer::ID, $t1->getId()); + Table4Peer::doSoftDelete($c); + Table4Peer::disableSoftDelete(); + $this->assertEquals(3, Table4Peer::doCount(new Criteria()), 'doSoftDelete() keeps deleted record in the database'); + Table4Peer::enableSoftDelete(); + $this->assertEquals(2, Table4Peer::doCount(new Criteria()), 'doSoftDelete() marks deleted record as deleted'); + // softDelete with a value + Table4Peer::doSoftDelete(array($t2->getId())); + Table4Peer::disableSoftDelete(); + $this->assertEquals(3, Table4Peer::doCount(new Criteria()), 'doSoftDelete() keeps deleted record in the database'); + Table4Peer::enableSoftDelete(); + $this->assertEquals(1, Table4Peer::doCount(new Criteria()), 'doSoftDelete() marks deleted record as deleted'); + // softDelete with an object + Table4Peer::doSoftDelete($t3); + Table4Peer::disableSoftDelete(); + $this->assertEquals(3, Table4Peer::doCount(new Criteria()), 'doSoftDelete() keeps deleted record in the database'); + Table4Peer::enableSoftDelete(); + $this->assertEquals(0, Table4Peer::doCount(new Criteria()), 'doSoftDelete() marks deleted record as deleted'); + } + + public function testStaticDoDelete() + { + $t1 = new Table4(); + $t1->save(); + $t2 = new Table4(); + $t2->save(); + Table4Peer::disableSoftDelete(); + Table4Peer::doDelete($t1); + Table4Peer::disableSoftDelete(); + $this->assertEquals(1, Table4Peer::doCount(new Criteria()), 'doDelete() calls doForceDelete() when soft delete is disabled'); + Table4Peer::enableSoftDelete(); + Table4Peer::doDelete($t2); + Table4Peer::disableSoftDelete(); + $this->assertEquals(1, Table4Peer::doCount(new Criteria()), 'doDelete() calls doSoftDelete() when soft delete is enabled'); + Table4Peer::enableSoftDelete(); + $this->assertEquals(0, Table4Peer::doCount(new Criteria()), 'doDelete() calls doSoftDelete() when soft delete is enabled'); + } + + public function testStaticDoForceDeleteAll() + { + $t1 = new Table4(); + $t1->save(); + Table4Peer::doForceDeleteAll(); + Table4Peer::disableSoftDelete(); + $this->assertEquals(0, Table4Peer::doCount(new Criteria()), 'doForceDeleteAll() actually deletes records'); + } + + public function testStaticDoSoftDeleteAll() + { + $t1 = new Table4(); + $t1->save(); + $t2 = new Table4(); + $t2->save(); + Table4Peer::enableSoftDelete(); + Table4Peer::doSoftDeleteAll(); + Table4Peer::disableSoftDelete(); + $this->assertEquals(2, Table4Peer::doCount(new Criteria()), 'doSoftDeleteAll() keeps deleted record in the database'); + Table4Peer::enableSoftDelete(); + $this->assertEquals(0, Table4Peer::doCount(new Criteria()), 'doSoftDeleteAll() marks deleted record as deleted'); + } + + public function testStaticDoDeleteAll() + { + $t1 = new Table4(); + $t1->save(); + $t2 = new Table4(); + $t2->save(); + Table4Peer::disableSoftDelete(); + Table4Peer::doDeleteAll(); + Table4Peer::disableSoftDelete(); + $this->assertEquals(0, Table4Peer::doCount(new Criteria()), 'doDeleteAll() calls doForceDeleteAll() when soft delete is disabled'); + $t1 = new Table4(); + $t1->save(); + $t2 = new Table4(); + $t2->save(); + Table4Peer::enableSoftDelete(); + Table4Peer::doDeleteAll(); + Table4Peer::disableSoftDelete(); + $this->assertEquals(2, Table4Peer::doCount(new Criteria()), 'doDeleteAll() calls doSoftDeleteAll() when soft delete is disabled'); + Table4Peer::enableSoftDelete(); + $this->assertEquals(0, Table4Peer::doCount(new Criteria()), 'doDeleteAll() calls doSoftDeleteAll() when soft delete is disabled'); + } + + public function testSelect() + { + $t = new Table4(); + $t->setDeletedAt(123); + $t->save(); + Table4Peer::enableSoftDelete(); + $this->assertEquals(0, Table4Peer::doCount(new Criteria), 'rows with a deleted_at date are hidden for select queries'); + Table4Peer::disableSoftDelete(); + $this->assertEquals(1, Table4Peer::doCount(new Criteria), 'rows with a deleted_at date are visible for select queries once the static soft_delete is enabled'); + $this->assertTrue(Table4Peer::isSoftDeleteEnabled(), 'Executing a select query enables the static soft delete again'); + } + + public function testDelete() + { + $t = new Table4(); + $t->save(); + $this->assertNull($t->getDeletedAt(), 'deleted_column is null by default'); + $t->delete(); + $this->assertNotNull($t->getDeletedAt(), 'deleted_column is not null after a soft delete'); + $this->assertEquals(0, Table4Peer::doCount(new Criteria), 'soft deleted rows are hidden for select queries'); + Table4Peer::disableSoftDelete(); + $this->assertEquals(1, Table4Peer::doCount(new Criteria), 'soft deleted rows are still present in the database'); + } + + public function testDeleteUndeletable() + { + $t = new UndeletableTable4(); + $t->save(); + $t->delete(); + $this->assertNull($t->getDeletedAt(), 'soft_delete is not triggered for objects wit ha preDelete hook returning false'); + $this->assertEquals(1, Table4Peer::doCount(new Criteria), 'soft_delete is not triggered for objects wit ha preDelete hook returning false'); + } + + public function testUnDelete() + { + $t = new Table4(); + $t->save(); + $t->delete(); + $t->undelete(); + $this->assertNull($t->getDeletedAt(), 'deleted_column is null again after an undelete'); + $this->assertEquals(1, Table4Peer::doCount(new Criteria), 'undeleted rows are visible for select queries'); + } + + public function testForceDelete() + { + $t = new Table4(); + $t->save(); + $t->forceDelete(); + $this->assertTrue($t->isDeleted(), 'forceDelete() actually deletes a row'); + Table4Peer::disableSoftDelete(); + $this->assertEquals(0, Table4Peer::doCount(new Criteria), 'forced deleted rows are not present in the database'); + } + + public function testForceDeleteDoesNotDisableSoftDelete() + { + $t1 = new Table4(); + $t1->save(); + $t2 = new Table4(); + $t2->save(); + $t1->forceDelete(); + $t2->delete(); + $this->assertTrue($t1->isDeleted(), 'forceDelete() actually deletes a row'); + $this->assertFalse($t2->isDeleted(), 'forceDelete() does not affect further delete() calls'); + Table4Peer::disableSoftDelete(); + $this->assertEquals(1, Table4Peer::doCount(new Criteria), 'forced deleted rows are not present in the database'); + } + + public function testForceDeleteReEnablesSoftDelete() + { + $t = new Table4(); + $t->save(); + $t->forceDelete(); + $this->assertTrue(Table4Peer::isSoftDeleteEnabled(), 'forceDelete() reenables soft delete'); + } + + public function testForceDeleteDoesNotReEnableSoftDeleteIfDisabled() + { + Table4Peer::disableSoftDelete(); + $t = new Table4(); + $t->save(); + $t->forceDelete(); + $this->assertFalse(Table4Peer::isSoftDeleteEnabled(), 'forceDelete() does not reenable soft delete if previously disabled'); + } + + public function testQueryIncludeDeleted() + { + $t = new Table4(); + $t->setDeletedAt(123); + $t->save(); + Table4Peer::enableSoftDelete(); + $this->assertEquals(0, Table4Query::create()->count(), 'rows with a deleted_at date are hidden for select queries'); + $this->assertEquals(1, Table4Query::create()->includeDeleted()->count(), 'rows with a deleted_at date are visible for select queries using includeDeleted()'); + } + + public function testQueryForceDelete() + { + $t1 = new Table4(); + $t1->save(); + Table4Query::create()->filterById($t1->getId())->forceDelete(); + Table4Peer::disableSoftDelete(); + $this->assertEquals(0, Table4Query::create()->count(), 'forceDelete() actually deletes records'); + } + + public function testQuerySoftDelete() + { + $t1 = new Table4(); + $t1->save(); + $t2 = new Table4(); + $t2->save(); + $t3 = new Table4(); + $t3->save(); + + Table4Query::create() + ->filterById($t1->getId()) + ->softDelete(); + Table4Peer::disableSoftDelete(); + $this->assertEquals(3, Table4Query::create()->count(), 'softDelete() keeps deleted record in the database'); + Table4Peer::enableSoftDelete(); + $this->assertEquals(2, Table4Query::create()->count(), 'softDelete() marks deleted record as deleted'); + } + + public function testQueryDelete() + { + $t1 = new Table4(); + $t1->save(); + $t2 = new Table4(); + $t2->save(); + + Table4Peer::disableSoftDelete(); + Table4Query::create()->filterById($t1->getId())->delete(); + Table4Peer::disableSoftDelete(); + $this->assertEquals(1, Table4Query::create()->count(), 'delete() calls forceDelete() when soft delete is disabled'); + Table4Peer::enableSoftDelete(); + Table4Query::create()->filterById($t2->getId())->delete(); + Table4Peer::disableSoftDelete(); + $this->assertEquals(1, Table4Query::create()->count(), 'delete() calls softDelete() when soft delete is enabled'); + Table4Peer::enableSoftDelete(); + $this->assertEquals(0, Table4Query::create()->count(), 'delete() calls softDelete() when soft delete is enabled'); + } + + public function testQueryForceDeleteAll() + { + $t1 = new Table4(); + $t1->save(); + Table4Query::create()->forceDeleteAll(); + Table4Peer::disableSoftDelete(); + $this->assertEquals(0, Table4Query::create()->count(), 'forceDeleteAll() actually deletes records'); + } + + public function testQuerySoftDeleteAll() + { + $t1 = new Table4(); + $t1->save(); + $t2 = new Table4(); + $t2->save(); + Table4Peer::enableSoftDelete(); + Table4Query::create()->softDelete(); + Table4Peer::disableSoftDelete(); + $this->assertEquals(2, Table4Query::create()->count(), 'softDelete() keeps deleted record in the database'); + Table4Peer::enableSoftDelete(); + $this->assertEquals(0, Table4Query::create()->count(), 'softDelete() marks deleted record as deleted'); + } + + public function testQueryDeleteAll() + { + $t1 = new Table4(); + $t1->save(); + $t2 = new Table4(); + $t2->save(); + Table4Peer::disableSoftDelete(); + Table4Query::create()->deleteAll(); + Table4Peer::disableSoftDelete(); + $this->assertEquals(0, Table4Query::create()->count(), 'deleteAll() calls forceDeleteAll() when soft delete is disabled'); + + $t1 = new Table4(); + $t1->save(); + $t2 = new Table4(); + $t2->save(); + Table4Peer::enableSoftDelete(); + Table4Query::create()->deleteAll(); + Table4Peer::disableSoftDelete(); + $this->assertEquals(2, Table4Query::create()->count(), 'deleteAll() calls softDeleteAll() when soft delete is disabled'); + Table4Peer::enableSoftDelete(); + $this->assertEquals(0, Table4Query::create()->count(), 'deleteAll() calls softDeleteAll() when soft delete is disabled'); + } + + public function testQuerySelect() + { + $t = new Table4(); + $t->setDeletedAt(123); + $t->save(); + Table4Peer::enableSoftDelete(); + $this->assertEquals(0, Table4Query::create()->count(), 'rows with a deleted_at date are hidden for select queries'); + Table4Peer::disableSoftDelete(); + $this->assertEquals(1, Table4Query::create()->count(), 'rows with a deleted_at date are visible for select queries once the static soft_delete is enabled'); + $this->assertTrue(Table4Peer::isSoftDeleteEnabled(), 'Executing a select query enables the static soft delete again'); + } + + public function testCustomization() + { + Table5Peer::disableSoftDelete(); + Table5Peer::doDeleteAll(); + Table5Peer::enableSoftDelete(); + $t = new Table5(); + $t->save(); + $this->assertNull($t->getDeletedOn(), 'deleted_column is null by default'); + $t->delete(); + $this->assertNotNull($t->getDeletedOn(), 'deleted_column is not null after a soft delete'); + $this->assertEquals(0, Table5Peer::doCount(new Criteria), 'soft deleted rows are hidden for select queries'); + Table5Peer::disableSoftDelete(); + $this->assertEquals(1, Table5Peer::doCount(new Criteria), 'soft deleted rows are still present in the database'); + } + + public function testPostDelete() + { + $t = new PostdeletehookedTable4(); + $t->setTitle('not post-deleted'); + $t->save(); + $this->assertNull($t->getDeletedAt(), 'deleted_column is null before a soft delete'); + $t->delete(); + $this->assertNotNull($t->getDeletedAt(), 'deleted_column is not null after a soft delete'); + $this->assertEquals('post-deleted', $t->getTitle(), 'postDelete hook did not set new title as expected'); + } } -class UndeletableTable4 extends Table4 +class UndeletableTable4 extends Table4 { - public function preDelete(PropelPDO $con = null) - { - parent::preDelete($con); - $this->setTitle('foo'); - return false; - } -} \ No newline at end of file + public function preDelete(PropelPDO $con = null) + { + parent::preDelete($con); + $this->setTitle('foo'); + + return false; + } +} + +class PostdeletehookedTable4 extends Table4 +{ + public function postDelete(PropelPDO $con = null) + { + parent::postDelete($con); + $this->setTitle('post-deleted'); + $this->save($con); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/TableBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/TableBehaviorTest.php index 25e534f7e..c12a7bee7 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/TableBehaviorTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/TableBehaviorTest.php @@ -8,8 +8,6 @@ * @license MIT License */ -require_once 'PHPUnit/Framework/TestCase.php'; - /** * Tests the table structure behavior hooks. * @@ -18,13 +16,13 @@ require_once 'PHPUnit/Framework/TestCase.php'; */ class TableBehaviorTest extends PHPUnit_Framework_TestCase { - protected function setUp() - { - parent::setUp(); - set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes"); - require_once 'behavior/alternative_coding_standards/map/Table3TableMap.php'; - require_once 'behavior/alternative_coding_standards/Table3Peer.php'; - } + protected function setUp() + { + parent::setUp(); + set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes"); + require_once 'behavior/alternative_coding_standards/map/Table3TableMap.php'; + require_once 'behavior/alternative_coding_standards/Table3Peer.php'; + } public function testModifyTable() { diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/TimestampableBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/TimestampableBehaviorTest.php index ba80d64f8..c03bef6c3 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/TimestampableBehaviorTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/TimestampableBehaviorTest.php @@ -1,7 +1,6 @@ assertEquals(count($table2->getColumns()), 4, 'Timestampable adds two columns by default'); - $this->assertTrue(method_exists('Table2', 'getCreatedAt'), 'Timestamplable adds a created_at column by default'); - $this->assertTrue(method_exists('Table2', 'getUpdatedAt'), 'Timestamplable adds an updated_at column by default'); - $table1 = Table1Peer::getTableMap(); - $this->assertEquals(count($table1->getColumns()), 4, 'Timestampable does not add two columns when they already exist'); - $this->assertTrue(method_exists('Table1', 'getCreatedOn'), 'Timestamplable allows customization of create_column name'); - $this->assertTrue(method_exists('Table1', 'getUpdatedOn'), 'Timestamplable allows customization of update_column name'); - } - - public function testPreSave() - { - $t1 = new Table2(); - $this->assertNull($t1->getUpdatedAt()); - $tsave = time(); - $t1->save(); - $this->assertEquals($t1->getUpdatedAt('U'), $tsave, 'Timestampable sets updated_column to time() on creation'); - sleep(1); - $t1->setTitle('foo'); - $tupdate = time(); - $t1->save(); - $this->assertEquals($t1->getUpdatedAt('U'), $tupdate, 'Timestampable changes updated_column to time() on update'); - } + public function testParameters() + { + $table2 = Table2Peer::getTableMap(); + $this->assertEquals(count($table2->getColumns()), 4, 'Timestampable adds two columns by default'); + $this->assertTrue(method_exists('Table2', 'getCreatedAt'), 'Timestamplable adds a created_at column by default'); + $this->assertTrue(method_exists('Table2', 'getUpdatedAt'), 'Timestamplable adds an updated_at column by default'); + $table1 = Table1Peer::getTableMap(); + $this->assertEquals(count($table1->getColumns()), 4, 'Timestampable does not add two columns when they already exist'); + $this->assertTrue(method_exists('Table1', 'getCreatedOn'), 'Timestamplable allows customization of create_column name'); + $this->assertTrue(method_exists('Table1', 'getUpdatedOn'), 'Timestamplable allows customization of update_column name'); + } - public function testPreSaveNoChange() - { - $t1 = new Table2(); - $this->assertNull($t1->getUpdatedAt()); - $tsave = time(); - $t1->save(); - $this->assertEquals($t1->getUpdatedAt('U'), $tsave, 'Timestampable sets updated_column to time() on creation'); - sleep(1); - $tupdate = time(); - $t1->save(); - $this->assertEquals($t1->getUpdatedAt('U'), $tsave, 'Timestampable only changes updated_column if the object was modified'); - } + public function testPreSave() + { + $t1 = new Table2(); + $this->assertNull($t1->getUpdatedAt()); - public function testPreSaveManuallyUpdated() - { - $t1 = new Table2(); - $t1->setUpdatedAt(time() - 10); - $tsave = time(); - $t1->save(); - $this->assertNotEquals($t1->getUpdatedAt('U'), $tsave, 'Timestampable does not set updated_column to time() on creation when it is set by the user'); - // tip: if I set it to time()-10 a second time, the object sees that I want to change it to the same value - // and skips the update, therefore the updated_at is not in the list of modified columns, - // and the behavior changes it to the current date... let's say it's an edge case - $t1->setUpdatedAt(time() - 15); - $tupdate = time(); - $t1->save(); - $this->assertNotEquals($t1->getUpdatedAt('U'), $tupdate, 'Timestampable does not change updated_column to time() on update when it is set by the user'); - } + $tsave = time(); + $t1->save(); - public function testPreInsert() - { - $t1 = new Table2(); - $this->assertNull($t1->getCreatedAt()); - $tsave = time(); - $t1->save(); - $this->assertEquals($t1->getCreatedAt('U'), $tsave, 'Timestampable sets created_column to time() on creation'); - sleep(1); - $t1->setTitle('foo'); - $tupdate = time(); - $t1->save(); - $this->assertEquals($t1->getCreatedAt('U'), $tsave, 'Timestampable does not update created_column on update'); - } + // Do not use assertEquals or similar, the second may have just changed! + // If both are integers, the update_at has been set. + $this->assertGreaterThanOrEqual($tsave, $t1->getUpdatedAt('U'), 'Timestampable sets updated_column to time() on creation'); - public function testPreInsertManuallyUpdated() - { - $t1 = new Table2(); - $t1->setCreatedAt(time() - 10); - $tsave = time(); - $t1->save(); - $this->assertNotEquals($t1->getCreatedAt('U'), $tsave, 'Timestampable does not set created_column to time() on creation when it is set by the user'); - } - - public function testObjectKeepUpdateDateUnchanged() - { - $t1 = new Table2(); - $t1->setUpdatedAt(time() - 10); - $tsave = time(); - $t1->save(); - $this->assertNotEquals($t1->getUpdatedAt('U'), $tsave); - // let's save it a second time; the updated_at should be changed - $t1->setTitle('foo'); - $tsave = time(); - $t1->save(); - $this->assertEquals($t1->getUpdatedAt('U'), $tsave); - - // now let's do this a second time - $t1 = new Table2(); - $t1->setUpdatedAt(time() - 10); - $tsave = time(); - $t1->save(); - $this->assertNotEquals($t1->getUpdatedAt('U'), $tsave); - // let's save it a second time; the updated_at should be changed - $t1->keepUpdateDateUnchanged(); - $t1->setTitle('foo'); - $tsave = time(); - $t1->save(); - $this->assertNotEquals($t1->getUpdatedAt('U'), $tsave, 'keepUpdateDateUnchanged() prevents the behavior from updating the update date'); - - } + // Ensure the timestamp will change. + sleep(1); - protected function populateUpdatedAt() - { - Table2Query::create()->deleteAll(); - $ts = new PropelObjectCollection(); - $ts->setModel('Table2'); - for ($i=0; $i < 10; $i++) { - $t = new Table2(); - $t->setTitle('UpdatedAt' . $i); - $t->setUpdatedAt(time() - $i * 24 * 60 * 60); - $ts[]= $t; - } - $ts->save(); - } + $t1->setTitle('foo'); + $t1->save(); - protected function populateCreatedAt() - { - Table2Query::create()->deleteAll(); - $ts = new PropelObjectCollection(); - $ts->setModel('Table2'); - for ($i=0; $i < 10; $i++) { - $t = new Table2(); - $t->setTitle('CreatedAt' . $i); - $t->setCreatedAt(time() - $i * 24 * 60 * 60); - $ts[]= $t; - } - $ts->save(); - } + // Do not use assertEquals or similar, time goes by, here too! + $this->assertGreaterThan($tsave, $t1->getUpdatedAt('U'), 'Timestampable changes updated_column to time() on update'); + } - public function testQueryRecentlyUpdated() - { - $q = Table2Query::create()->recentlyUpdated(); - $this->assertTrue($q instanceof Table2Query, 'recentlyUpdated() returns the current Query object'); - $this->populateUpdatedAt(); - $ts = Table2Query::create()->recentlyUpdated()->count(); - $this->assertEquals(8, $ts, 'recentlyUpdated() returns the elements updated in the last 7 days by default'); - $ts = Table2Query::create()->recentlyUpdated(5)->count(); - $this->assertEquals(6, $ts, 'recentlyUpdated() accepts a number of days as parameter'); - } - - public function testQueryRecentlyCreated() - { - $q = Table2Query::create()->recentlyCreated(); - $this->assertTrue($q instanceof Table2Query, 'recentlyCreated() returns the current Query object'); - $this->populateCreatedAt(); - $ts = Table2Query::create()->recentlyCreated()->count(); - $this->assertEquals(8, $ts, 'recentlyCreated() returns the elements created in the last 7 days by default'); - $ts = Table2Query::create()->recentlyCreated(5)->count(); - $this->assertEquals(6, $ts, 'recentlyCreated() accepts a number of days as parameter'); - } - - public function testQueryLastUpdatedFirst() - { - $q = Table2Query::create()->lastUpdatedFirst(); - $this->assertTrue($q instanceof Table2Query, 'lastUpdatedFirst() returns the current Query object'); - $this->populateUpdatedAt(); - $t = Table2Query::create()->lastUpdatedFirst()->findOne(); - $this->assertEquals('UpdatedAt0', $t->getTitle(), 'lastUpdatedFirst() returns element with most recent update date first'); - } + public function testPreSaveNoChange() + { + $t1 = new Table2(); + $t1->save(); - public function testQueryFirstUpdatedFirst() - { - $q = Table2Query::create()->firstUpdatedFirst(); - $this->assertTrue($q instanceof Table2Query, 'firstUpdatedFirst() returns the current Query object'); - $this->populateUpdatedAt(); - $t = Table2Query::create()->firstUpdatedFirst()->findOne(); - $this->assertEquals('UpdatedAt9', $t->getTitle(), 'firstUpdatedFirst() returns the element with oldest updated date first'); - } + $date = $t1->getUpdatedAt('U'); - public function testQueryLastCreatedFirst() - { - $q = Table2Query::create()->lastCreatedFirst(); - $this->assertTrue($q instanceof Table2Query, 'lastCreatedFirst() returns the current Query object'); - $this->populateCreatedAt(); - $t = Table2Query::create()->lastCreatedFirst()->findOne(); - $this->assertEquals('CreatedAt0', $t->getTitle(), 'lastCreatedFirst() returns element with most recent create date first'); - } + // Ensure the timestamp will change. + sleep(1); - public function testQueryFirstCreatedFirst() - { - $q = Table2Query::create()->firstCreatedFirst(); - $this->assertTrue($q instanceof Table2Query, 'firstCreatedFirst() returns the current Query object'); - $this->populateCreatedAt(); - $t = Table2Query::create()->firstCreatedFirst()->findOne(); - $this->assertEquals('CreatedAt9', $t->getTitle(), 'firstCreatedFirst() returns the element with oldest create date first'); - } + $t1->save(); + $this->assertEquals($date, $t1->getUpdatedAt('U'), 'Timestampable only changes updated_column if the object was modified'); + } + + public function testPreSaveManuallyUpdated() + { + $t1 = new Table2(); + $t1->setUpdatedAt(time() - 10); + $tsave = time(); + $t1->save(); + $this->assertNotEquals($t1->getUpdatedAt('U'), $tsave, 'Timestampable does not set updated_column to time() on creation when it is set by the user'); + // tip: if I set it to time()-10 a second time, the object sees that I want to change it to the same value + // and skips the update, therefore the updated_at is not in the list of modified columns, + // and the behavior changes it to the current date... let's say it's an edge case + $t1->setUpdatedAt(time() - 15); + $tupdate = time(); + $t1->save(); + $this->assertNotEquals($t1->getUpdatedAt('U'), $tupdate, 'Timestampable does not change updated_column to time() on update when it is set by the user'); + } + + public function testPreInsert() + { + $t1 = new Table2(); + $this->assertNull($t1->getCreatedAt()); + + $tsave = time(); + $t1->save(); + + // Do not use assertEquals or similar, the second may have just changed! + // If both are integers, the created_at has been set. + $this->assertGreaterThanOrEqual($tsave, $t1->getCreatedAt('U'), 'Timestampable sets created_column to time() on creation'); + + $tcreated = $t1->getCreatedAt('U'); + + // Ensure the timestamp will change. + sleep(1); + + $t1->setTitle('foo'); + $t1->save(); + + $this->assertEquals($tcreated, $t1->getCreatedAt('U'), 'Timestampable does not update created_column on update'); + } + + public function testPreInsertManuallyUpdated() + { + $tcreated = time() - 10; + + $t1 = new Table2(); + $t1->setCreatedAt($tcreated); + $t1->save(); + + $this->assertEquals($tcreated, $t1->getCreatedAt('U'), 'Timestampable does not set created_column to time() on creation when it is set by the user'); + } + + /** + * @depends testPreSave + * @depends testPreSaveManuallyUpdated + */ + public function testObjectKeepUpdateDateUnchanged() + { + $tsave = time() - 10; + + $t1 = new Table2(); + $t1->setUpdatedAt($tsave); + $t1->save(); + + $t1->keepUpdateDateUnchanged(); + $t1->setTitle('foo'); + $t1->save(); + + $this->assertEquals($tsave, $t1->getUpdatedAt('U'), 'keepUpdateDateUnchanged() prevents the behavior from updating the update date'); + } + + protected function populateUpdatedAt() + { + Table2Query::create()->deleteAll(); + $ts = new PropelObjectCollection(); + $ts->setModel('Table2'); + for ($i=0; $i < 10; $i++) { + $t = new Table2(); + $t->setTitle('UpdatedAt' . $i); + /* additional -30 in case the check is done in the same second (which we can't guarantee, so no assert(8 ...) below).*/ + $t->setUpdatedAt(time() - $i * 24 * 60 * 60 - 30); + $ts[]= $t; + } + $ts->save(); + } + + protected function populateCreatedAt() + { + Table2Query::create()->deleteAll(); + $ts = new PropelObjectCollection(); + $ts->setModel('Table2'); + for ($i=0; $i < 10; $i++) { + $t = new Table2(); + $t->setTitle('CreatedAt' . $i); + $t->setCreatedAt(time() - $i * 24 * 60 * 60 - 30); + $ts[]= $t; + } + $ts->save(); + } + + public function testQueryRecentlyUpdated() + { + $q = Table2Query::create()->recentlyUpdated(); + $this->assertTrue($q instanceof Table2Query, 'recentlyUpdated() returns the current Query object'); + $this->populateUpdatedAt(); + $ts = Table2Query::create()->recentlyUpdated()->count(); + $this->assertEquals(7, $ts, 'recentlyUpdated() returns the elements updated in the last 7 days by default'); + $ts = Table2Query::create()->recentlyUpdated(5)->count(); + $this->assertEquals(5, $ts, 'recentlyUpdated() accepts a number of days as parameter'); + } + + public function testQueryRecentlyCreated() + { + $q = Table2Query::create()->recentlyCreated(); + $this->assertTrue($q instanceof Table2Query, 'recentlyCreated() returns the current Query object'); + $this->populateCreatedAt(); + $ts = Table2Query::create()->recentlyCreated()->count(); + $this->assertEquals(7, $ts, 'recentlyCreated() returns the elements created in the last 7 days by default'); + $ts = Table2Query::create()->recentlyCreated(5)->count(); + $this->assertEquals(5, $ts, 'recentlyCreated() accepts a number of days as parameter'); + } + + public function testQueryLastUpdatedFirst() + { + $q = Table2Query::create()->lastUpdatedFirst(); + $this->assertTrue($q instanceof Table2Query, 'lastUpdatedFirst() returns the current Query object'); + $this->populateUpdatedAt(); + $t = Table2Query::create()->lastUpdatedFirst()->findOne(); + $this->assertEquals('UpdatedAt0', $t->getTitle(), 'lastUpdatedFirst() returns element with most recent update date first'); + } + + public function testQueryFirstUpdatedFirst() + { + $q = Table2Query::create()->firstUpdatedFirst(); + $this->assertTrue($q instanceof Table2Query, 'firstUpdatedFirst() returns the current Query object'); + $this->populateUpdatedAt(); + $t = Table2Query::create()->firstUpdatedFirst()->findOne(); + $this->assertEquals('UpdatedAt9', $t->getTitle(), 'firstUpdatedFirst() returns the element with oldest updated date first'); + } + + public function testQueryLastCreatedFirst() + { + $q = Table2Query::create()->lastCreatedFirst(); + $this->assertTrue($q instanceof Table2Query, 'lastCreatedFirst() returns the current Query object'); + $this->populateCreatedAt(); + $t = Table2Query::create()->lastCreatedFirst()->findOne(); + $this->assertEquals('CreatedAt0', $t->getTitle(), 'lastCreatedFirst() returns element with most recent create date first'); + } + + public function testQueryFirstCreatedFirst() + { + $q = Table2Query::create()->firstCreatedFirst(); + $this->assertTrue($q instanceof Table2Query, 'firstCreatedFirst() returns the current Query object'); + $this->populateCreatedAt(); + $t = Table2Query::create()->firstCreatedFirst()->findOne(); + $this->assertEquals('CreatedAt9', $t->getTitle(), 'firstCreatedFirst() returns the element with oldest create date first'); + } + + public function testDisableUpdatedAt() + { + $schema = << + + + + + + +
+ +EOF; + + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $builder->build(); + + $this->assertTrue(method_exists('TableWithoutUpdatedAt', 'getCreatedAt')); + $this->assertTrue(method_exists('TableWithoutUpdatedAt', 'setCreatedAt')); + $this->assertFalse(method_exists('TableWithoutUpdatedAt', 'getUpdatedAt')); + $this->assertFalse(method_exists('TableWithoutUpdatedAt', 'setUpdatedAt')); + + $obj = new TableWithoutUpdatedAt(); + $this->assertNull($obj->getCreatedAt()); + $this->assertEquals(1, $obj->save()); + $this->assertNotNull($obj->getCreatedAt()); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/aggregate_column/AggregateColumnBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/aggregate_column/AggregateColumnBehaviorTest.php index 3019727c5..ac32bff3a 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/aggregate_column/AggregateColumnBehaviorTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/aggregate_column/AggregateColumnBehaviorTest.php @@ -9,246 +9,328 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/BookstoreTestBase.php'; + /** * Tests for AggregateColumnBehavior class * * @author François Zaninotto - * @version $Revision: 1779 $ + * @version $Revision$ * @package generator.behavior.aggregate_column */ -class AggregateColumnBehaviorTest extends BookstoreTestBase +class AggregateColumnBehaviorTest extends BookstoreTestBase { - - public function testParameters() - { - $postTable = AggregatePostPeer::getTableMap(); - $this->assertEquals(count($postTable->getColumns()), 2, 'AggregateColumn adds one column by default'); - $this->assertTrue(method_exists('AggregatePost', 'getNbComments')); - } - - public function testCompute() - { - AggregateCommentQuery::create()->deleteAll($this->con); - AggregatePostQuery::create()->deleteAll($this->con); - $post = new AggregatePost(); - $post->save($this->con); - $this->assertEquals(0, $post->computeNbComments($this->con), 'The compute method returns 0 for objects with no related objects'); - $comment1 = new AggregateComment(); - $comment1->setAggregatePost($post); - $comment1->save($this->con); - $this->assertEquals(1, $post->computeNbComments($this->con), 'The compute method computes the aggregate function on related objects'); - $comment2 = new AggregateComment(); - $comment2->setAggregatePost($post); - $comment2->save($this->con); - $this->assertEquals(2, $post->computeNbComments($this->con), 'The compute method computes the aggregate function on related objects'); - $comment1->delete($this->con); - $this->assertEquals(1, $post->computeNbComments($this->con), 'The compute method computes the aggregate function on related objects'); - } + public function testParameters() + { + $postTable = AggregatePostPeer::getTableMap(); + $this->assertEquals(count($postTable->getColumns()), 2, 'AggregateColumn adds one column by default'); + $this->assertTrue(method_exists('AggregatePost', 'getNbComments')); + } - public function testUpdate() - { - AggregateCommentQuery::create()->deleteAll($this->con); - AggregatePostQuery::create()->deleteAll($this->con); - $post = new AggregatePost(); - $post->save($this->con); - $comment = new TestableComment(); - $comment->setAggregatePost($post); - $comment->save($this->con); - $this->assertNull($post->getNbComments()); - $post->updateNbComments($this->con); - $this->assertEquals(1, $post->getNbComments(), 'The update method updates the aggregate column'); - $comment->delete($this->con); - $this->assertEquals(1, $post->getNbComments()); - $post->updateNbComments($this->con); - $this->assertEquals(0, $post->getNbComments(), 'The update method updates the aggregate column'); - } - - public function testCreateRelated() - { - AggregateCommentQuery::create()->deleteAll($this->con); - AggregatePostQuery::create()->deleteAll($this->con); - $post = new AggregatePost(); - $post->save($this->con); - $comment1 = new AggregateComment(); - $comment1->save($this->con); - $this->assertNull($post->getNbComments(), 'Adding a new foreign object does not update the aggregate column'); - $comment2 = new AggregateComment(); - $comment2->setAggregatePost($post); - $comment2->save($this->con); - $this->assertEquals(1, $post->getNbComments(), 'Adding a new related object updates the aggregate column'); - $comment3 = new AggregateComment(); - $comment3->setAggregatePost($post); - $comment3->save($this->con); - $this->assertEquals(2, $post->getNbComments(), 'Adding a new related object updates the aggregate column'); - } - - public function testUpdateRelated() - { - list($poll, $item1, $item2) = $this->populatePoll(); - $this->assertEquals(19, $poll->getTotalScore()); - $item1->setScore(10); - $item1->save($this->con); - $this->assertEquals(17, $poll->getTotalScore(), 'Updating a related object updates the aggregate column'); - } + public function testCompute() + { + AggregateCommentQuery::create()->deleteAll($this->con); + AggregatePostQuery::create()->deleteAll($this->con); + $post = new AggregatePost(); + $post->save($this->con); + $this->assertEquals(0, $post->computeNbComments($this->con), 'The compute method returns 0 for objects with no related objects'); + $comment1 = new AggregateComment(); + $comment1->setAggregatePost($post); + $comment1->save($this->con); + $this->assertEquals(1, $post->computeNbComments($this->con), 'The compute method computes the aggregate function on related objects'); + $comment2 = new AggregateComment(); + $comment2->setAggregatePost($post); + $comment2->save($this->con); + $this->assertEquals(2, $post->computeNbComments($this->con), 'The compute method computes the aggregate function on related objects'); + $comment1->delete($this->con); + $this->assertEquals(1, $post->computeNbComments($this->con), 'The compute method computes the aggregate function on related objects'); + } - public function testDeleteRelated() - { - list($poll, $item1, $item2) = $this->populatePoll(); - $this->assertEquals(19, $poll->getTotalScore()); - $item1->delete($this->con); - $this->assertEquals(7, $poll->getTotalScore(), 'Deleting a related object updates the aggregate column'); - $item2->delete($this->con); - $this->assertNull($poll->getTotalScore(), 'Deleting a related object updates the aggregate column'); - } - - public function testUpdateRelatedWithQuery() - { - list($poll, $item1, $item2) = $this->populatePoll(); - $this->assertEquals(19, $poll->getTotalScore()); - AggregateItemQuery::create() - ->update(array('Score' => 4), $this->con); - $this->assertEquals(8, $poll->getTotalScore(), 'Updating related objects with a query updates the aggregate column'); - } + public function testUpdate() + { + AggregateCommentQuery::create()->deleteAll($this->con); + AggregatePostQuery::create()->deleteAll($this->con); + $post = new AggregatePost(); + $post->save($this->con); + $comment = new TestableComment(); + $comment->setAggregatePost($post); + $comment->save($this->con); + $this->assertNull($post->getNbComments()); + $post->updateNbComments($this->con); + $this->assertEquals(1, $post->getNbComments(), 'The update method updates the aggregate column'); + $comment->delete($this->con); + $this->assertEquals(1, $post->getNbComments()); + $post->updateNbComments($this->con); + $this->assertEquals(0, $post->getNbComments(), 'The update method updates the aggregate column'); + } - public function testUpdateRelatedWithQueryUsingAlias() - { - list($poll, $item1, $item2) = $this->populatePoll(); - $this->assertEquals(19, $poll->getTotalScore()); - AggregateItemQuery::create() - ->setModelAlias('foo', true) - ->update(array('Score' => 4), $this->con); - $this->assertEquals(8, $poll->getTotalScore(), 'Updating related objects with a query using alias updates the aggregate column'); - } + public function testCreateRelated() + { + AggregateCommentQuery::create()->deleteAll($this->con); + AggregatePostQuery::create()->deleteAll($this->con); + $post = new AggregatePost(); + $post->save($this->con); + $comment1 = new AggregateComment(); + $comment1->save($this->con); + $this->assertNull($post->getNbComments(), 'Adding a new foreign object does not update the aggregate column'); + $comment2 = new AggregateComment(); + $comment2->setAggregatePost($post); + $comment2->save($this->con); + $this->assertEquals(1, $post->getNbComments(), 'Adding a new related object updates the aggregate column'); + $comment3 = new AggregateComment(); + $comment3->setAggregatePost($post); + $comment3->save($this->con); + $this->assertEquals(2, $post->getNbComments(), 'Adding a new related object updates the aggregate column'); + } - public function testDeleteRelatedWithQuery() - { - list($poll, $item1, $item2) = $this->populatePoll(); - $this->assertEquals(19, $poll->getTotalScore()); - AggregateItemQuery::create() - ->deleteAll($this->con); - $this->assertNull($poll->getTotalScore(), 'Deleting related objects with a query updates the aggregate column'); - } + public function testUpdateRelated() + { + list($poll, $item1, $item2) = $this->populatePoll(); + $this->assertEquals(19, $poll->getTotalScore()); + $item1->setScore(10); + $item1->save($this->con); + $this->assertEquals(17, $poll->getTotalScore(), 'Updating a related object updates the aggregate column'); + } - public function testDeleteRelatedWithQueryUsingAlias() - { - list($poll, $item1, $item2) = $this->populatePoll(); - $this->assertEquals(19, $poll->getTotalScore()); - AggregateItemQuery::create() - ->setModelAlias('foo', true) - ->filterById($item1->getId()) - ->delete($this->con); - $this->assertEquals(7, $poll->getTotalScore(), 'Deleting related objects with a query using alias updates the aggregate column'); - } - - public function testRemoveRelation() - { - AggregateCommentQuery::create()->deleteAll($this->con); - AggregatePostQuery::create()->deleteAll($this->con); - $post = new AggregatePost(); - $post->save($this->con); - $comment1 = new AggregateComment(); - $comment1->setAggregatePost($post); - $comment1->save($this->con); - $comment2 = new AggregateComment(); - $comment2->setAggregatePost($post); - $comment2->save($this->con); - $this->assertEquals(2, $post->getNbComments()); - $comment2->setAggregatePost(null); - $comment2->save($this->con); - $this->assertEquals(1, $post->getNbComments(), 'Removing a relation changes the related object aggregate column'); - } - - public function testReplaceRelation() - { - AggregateCommentQuery::create()->deleteAll($this->con); - AggregatePostQuery::create()->deleteAll($this->con); - $post1 = new AggregatePost(); - $post1->save($this->con); - $post2 = new AggregatePost(); - $post2->save($this->con); - $comment = new AggregateComment(); - $comment->setAggregatePost($post1); - $comment->save($this->con); - $this->assertEquals(1, $post1->getNbComments()); - $this->assertNull($post2->getNbComments()); - $comment->setAggregatePost($post2); - $comment->save($this->con); - $this->assertEquals(0, $post1->getNbComments(), 'Replacing a relation changes the related object aggregate column'); - $this->assertEquals(1, $post2->getNbComments(), 'Replacing a relation changes the related object aggregate column'); - } - - protected function populatePoll() - { - AggregateItemQuery::create()->deleteAll($this->con); - AggregatePollQuery::create()->deleteAll($this->con); - $poll = new AggregatePoll(); - $poll->save($this->con); - $item1 = new AggregateItem(); - $item1->setScore(12); - $item1->setAggregatePoll($poll); - $item1->save($this->con); - $item2 = new AggregateItem(); - $item2->setScore(7); - $item2->setAggregatePoll($poll); - $item2->save($this->con); - return array($poll, $item1, $item2); - } + public function testDeleteRelated() + { + list($poll, $item1, $item2) = $this->populatePoll(); + $this->assertEquals(19, $poll->getTotalScore()); + $item1->delete($this->con); + $this->assertEquals(7, $poll->getTotalScore(), 'Deleting a related object updates the aggregate column'); + $item2->delete($this->con); + $this->assertNull($poll->getTotalScore(), 'Deleting a related object updates the aggregate column'); + } + + public function testUpdateRelatedWithQuery() + { + list($poll, $item1, $item2) = $this->populatePoll(); + $this->assertEquals(19, $poll->getTotalScore()); + AggregateItemQuery::create() + ->update(array('Score' => 4), $this->con); + $this->assertEquals(8, $poll->getTotalScore(), 'Updating related objects with a query updates the aggregate column'); + } + + public function testUpdateRelatedWithQueryUsingAlias() + { + list($poll, $item1, $item2) = $this->populatePoll(); + $this->assertEquals(19, $poll->getTotalScore()); + AggregateItemQuery::create() + ->setModelAlias('foo', true) + ->update(array('Score' => 4), $this->con); + $this->assertEquals(8, $poll->getTotalScore(), 'Updating related objects with a query using alias updates the aggregate column'); + } + + public function testDeleteRelatedWithQuery() + { + list($poll, $item1, $item2) = $this->populatePoll(); + $this->assertEquals(19, $poll->getTotalScore()); + AggregateItemQuery::create() + ->deleteAll($this->con); + $this->assertNull($poll->getTotalScore(), 'Deleting related objects with a query updates the aggregate column'); + } + + public function testDeleteRelatedWithQueryUsingAlias() + { + list($poll, $item1, $item2) = $this->populatePoll(); + $this->assertEquals(19, $poll->getTotalScore()); + AggregateItemQuery::create() + ->setModelAlias('foo', true) + ->filterById($item1->getId()) + ->delete($this->con); + $this->assertEquals(7, $poll->getTotalScore(), 'Deleting related objects with a query using alias updates the aggregate column'); + } + + public function testRemoveRelation() + { + AggregateCommentQuery::create()->deleteAll($this->con); + AggregatePostQuery::create()->deleteAll($this->con); + $post = new AggregatePost(); + $post->save($this->con); + $comment1 = new AggregateComment(); + $comment1->setAggregatePost($post); + $comment1->save($this->con); + $comment2 = new AggregateComment(); + $comment2->setAggregatePost($post); + $comment2->save($this->con); + $this->assertEquals(2, $post->getNbComments()); + $comment2->setAggregatePost(null); + $comment2->save($this->con); + $this->assertEquals(1, $post->getNbComments(), 'Removing a relation changes the related object aggregate column'); + } + + public function testReplaceRelation() + { + AggregateCommentQuery::create()->deleteAll($this->con); + AggregatePostQuery::create()->deleteAll($this->con); + $post1 = new AggregatePost(); + $post1->save($this->con); + $post2 = new AggregatePost(); + $post2->save($this->con); + $comment = new AggregateComment(); + $comment->setAggregatePost($post1); + $comment->save($this->con); + $this->assertEquals(1, $post1->getNbComments()); + $this->assertNull($post2->getNbComments()); + $comment->setAggregatePost($post2); + $comment->save($this->con); + $this->assertEquals(0, $post1->getNbComments(), 'Replacing a relation changes the related object aggregate column'); + $this->assertEquals(1, $post2->getNbComments(), 'Replacing a relation changes the related object aggregate column'); + } + + public function testAddMultipleComments() + { + AggregateCommentQuery::create()->deleteAll($this->con); + AggregatePostQuery::create()->deleteAll($this->con); + + $post1 = new AggregatePost(); + + $comment = new AggregateComment(); + $comment->setAggregatePost($post1); + + $comment2 = new AggregateComment(); + $comment2->setAggregatePost($post1); + + $comment3 = new AggregateComment(); + $comment3->setAggregatePost($post1); + + $this->assertNull($post1->getNbComments(), 'The post start with null aggregate column'); + + $post1->save($this->con); + + $this->assertEquals(3, $post1->getNbComments(), 'the post has 3 comments'); + } + + public function testQueryCountOnUpdate() + { + AggregateCommentQuery::create()->deleteAll($this->con); + AggregatePostQuery::create()->deleteAll($this->con); + + $post1 = new TestablePost(); + $comment = new AggregateComment(); + $comment->setAggregatePost($post1); + $comment2 = new AggregateComment(); + $comment2->setAggregatePost($post1); + $comment3 = new AggregateComment(); + $comment3->setAggregatePost($post1); + $post1->save($this->con); + $this->assertEquals(3, $post1->getNbComments(), 'the post has 3 comments'); + $this->assertEquals(2, $post1->countComputeCall, 'Only two call to count nbComment'); + + $post1->countComputeCall = 0; + + $comment4 = new AggregateComment(); + $comment4->setAggregatePost($post1); + $comment4->save($this->con); + + $this->assertEquals(4, $post1->getNbComments(), 'the post has 4 comments'); + $this->assertEquals(2, $post1->countComputeCall, 'Only two call to count nbComment'); + + $post1->countComputeCall = 0; + + $comment5 = new AggregateComment(); + $comment5->setAggregatePost($post1); + $post1->save($this->con); + + $this->assertEquals(5, $post1->getNbComments(), 'the post has 5 comments'); + $this->assertEquals(2, $post1->countComputeCall, 'Only two call to count nbComment'); + + $post1->countComputeCall = 0; + $post1->save($this->con); + + $this->assertEquals(5, $post1->getNbComments(), 'the post has 5 comments'); + $this->assertEquals(1, $post1->countComputeCall, 'Only one call to count nbComment'); + } + + protected function populatePoll() + { + AggregateItemQuery::create()->deleteAll($this->con); + AggregatePollQuery::create()->deleteAll($this->con); + $poll = new AggregatePoll(); + $poll->save($this->con); + $item1 = new AggregateItem(); + $item1->setScore(12); + $item1->setAggregatePoll($poll); + $item1->save($this->con); + $item2 = new AggregateItem(); + $item2->setScore(7); + $item2->setAggregatePoll($poll); + $item2->save($this->con); + + return array($poll, $item1, $item2); + } } class TestableComment extends AggregateComment { - // overrides the parent save() to bypass behavior hooks - public function save(PropelPDO $con = null) - { - $con->beginTransaction(); - try { - $affectedRows = $this->doSave($con); - AggregateCommentPeer::addInstanceToPool($this); - $con->commit(); - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - // overrides the parent delete() to bypass behavior hooks - public function delete(PropelPDO $con = null) - { - $con->beginTransaction(); - try { - TestableAggregateCommentQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()) - ->delete($con); - $con->commit(); - $this->setDeleted(true); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - + // overrides the parent save() to bypass behavior hooks + public function save(PropelPDO $con = null) + { + $con->beginTransaction(); + try { + $affectedRows = $this->doSave($con); + AggregateCommentPeer::addInstanceToPool($this); + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + // overrides the parent delete() to bypass behavior hooks + public function delete(PropelPDO $con = null) + { + $con->beginTransaction(); + try { + TestableAggregateCommentQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()) + ->delete($con); + $con->commit(); + $this->setDeleted(true); + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + +} + +class TestablePost extends AggregatePost +{ + public $countComputeCall = 0; + /** + * @param PropelPDO $con + * @return string + */ + public function computeNbComments(PropelPDO $con) + { + $this->countComputeCall++; + + return parent::computeNbComments($con); + } + } class TestableAggregateCommentQuery extends AggregateCommentQuery { - public static function create($modelAlias = null, $criteria = null) - { - return new TestableAggregateCommentQuery(); - } - - // overrides the parent basePreDelete() to bypass behavior hooks - protected function basePreDelete(PropelPDO $con) - { - return $this->preDelete($con); - } + public static function create($modelAlias = null, $criteria = null) + { + return new TestableAggregateCommentQuery(); + } - // overrides the parent basePostDelete() to bypass behavior hooks - protected function basePostDelete($affectedRows, PropelPDO $con) - { - return $this->postDelete($affectedRows, $con); - } - -} \ No newline at end of file + // overrides the parent basePreDelete() to bypass behavior hooks + protected function basePreDelete(PropelPDO $con) + { + return $this->preDelete($con); + } + + // overrides the parent basePostDelete() to bypass behavior hooks + protected function basePostDelete($affectedRows, PropelPDO $con) + { + return $this->postDelete($affectedRows, $con); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/aggregate_column/AggregateColumnBehaviorWithSchemaTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/aggregate_column/AggregateColumnBehaviorWithSchemaTest.php new file mode 100644 index 000000000..50edd6a86 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/aggregate_column/AggregateColumnBehaviorWithSchemaTest.php @@ -0,0 +1,82 @@ +con = Propel::getConnection(BookstoreSchemasBookstorePeer::DATABASE_NAME); + $this->con->beginTransaction(); + } + + protected function tearDown() + { + $this->con->commit(); + parent::tearDown(); + } + + public function testParametersWithSchema() + { + $storeTable = BookstoreSchemasBookstorePeer::getTableMap(); + $this->assertEquals(count($storeTable->getColumns()), 8, 'AggregateColumn adds one column by default'); + $this->assertTrue(method_exists('BookstoreSchemasBookstore', 'getTotalContestEntries')); + } + + public function testComputeWithSchema() + { + ContestBookstoreContestEntryQuery::create()->deleteAll($this->con); + BookstoreSchemasBookstoreQuery::create()->deleteAll($this->con); + BookstoreSchemasCustomerQuery::create()->deleteAll($this->con); + ContestBookstoreContestQuery::create()->deleteAll($this->con); + + $store = new BookstoreSchemasBookstore(); + $store->setStoreName('A Name'); + $store->save($this->con); + $this->assertEquals(0, $store->computeTotalContestEntries($this->con), 'The compute method returns 0 for objects with no related objects'); + + $contest = new ContestBookstoreContest(); + $contest->setBookstoreSchemasBookstore($store); + $contest->save($this->con); + $customer1 = new BookstoreSchemasCustomer(); + $customer1->save($this->con); + + $entry1 = new ContestBookstoreContestEntry(); + $entry1->setBookstoreSchemasBookstore($store); + $entry1->setContestBookstoreContest($contest); + $entry1->setBookstoreSchemasCustomer($customer1); + $entry1->save($this->con, true); // skip reload to avoid #1151 for now + + $this->assertEquals(1, $store->computeTotalContestEntries($this->con), 'The compute method computes the aggregate function on related objects'); + + $customer2 = new BookstoreSchemasCustomer(); + $customer2->save($this->con); + + $entry2 = new ContestBookstoreContestEntry(); + $entry2->setBookstoreSchemasBookstore($store); + $entry2->setContestBookstoreContest($contest); + $entry2->setBookstoreSchemasCustomer($customer2); + $entry2->save($this->con, true); // skip reload to avoid #1151 for now + + $this->assertEquals(2, $store->computeTotalContestEntries($this->con), 'The compute method computes the aggregate function on related objects'); + $entry1->delete($this->con); + $this->assertEquals(1, $store->computeTotalContestEntries($this->con), 'The compute method computes the aggregate function on related objects'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/archivable/ArchivableAndConcreteInheritanceBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/archivable/ArchivableAndConcreteInheritanceBehaviorTest.php new file mode 100644 index 000000000..1987a7eb7 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/archivable/ArchivableAndConcreteInheritanceBehaviorTest.php @@ -0,0 +1,65 @@ + + + + + + +
+ + + + + + + +
+ +EOF; + PropelQuickBuilder::buildSchema($schema); + } + + ArchivableConcretePagePeer::doDeleteAll(); + ArchivableConcretePageArchivePeer::doDeleteAll(); + } + + public function testPopulateFromArchive() + { + $page = new ArchivableConcretePage(); + $page->fromArray(array( + 'Content' => 'Test content', + 'Paragraph' => 'Test', + )); + $page->save(); + $page->archive(); + + $archived_page = ArchivableConcretePageArchivePeer::doSelectOne(new Criteria()); + $new_page = new ArchivableConcretePage(); + $new_page->populateFromArchive($archived_page); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/archivable/ArchivableBehaviorObjectBuilderModifierTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/archivable/ArchivableBehaviorObjectBuilderModifierTest.php new file mode 100644 index 000000000..c2fbc66ec --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/archivable/ArchivableBehaviorObjectBuilderModifierTest.php @@ -0,0 +1,454 @@ + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + +
+ + +EOF; + PropelQuickBuilder::buildSchema($schema); + } + } + + public function testHasGetArchiveMethod() + { + $this->assertTrue(method_exists('ArchivableTest10', 'getArchive')); + } + + public function testGetArchiveReturnsNullOnNewObjects() + { + $a = new ArchivableTest10(); + $this->assertNull($a->getArchive()); + } + + public function testGetArchiveReturnsNullWhenNoArchiveIsFound() + { + $a = new ArchivableTest10(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + $this->assertNull($a->getArchive()); + } + + public function testGetArchiveReturnsExistingArchive() + { + $a = new ArchivableTest10(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + $archive = new ArchivableTest10Archive(); + $archive->setId($a->getId()); + $archive->setTitle('bar'); + $archive->save(); + $this->assertSame($archive, $a->getArchive()); + } + + public function testHasArchiveMethod() + { + $this->assertTrue(method_exists('ArchivableTest10', 'archive')); + } + + public function testArchiveCreatesACopyByDefault() + { + ArchivableTest10ArchiveQuery::create()->deleteAll(); + $a = new ArchivableTest10(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + $a->archive(); + $archive = ArchivableTest10ArchiveQuery::create() + ->filterById($a->getId()) + ->findOne(); + $this->assertInstanceOf('ArchivableTest10Archive', $archive); + $this->assertEquals('foo', $archive->getTitle()); + $this->assertEquals(12, $archive->getAge()); + } + + public function testArchiveUpdatesExistingArchive() + { + ArchivableTest10ArchiveQuery::create()->deleteAll(); + $a = new ArchivableTest10(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + $b = new ArchivableTest10Archive(); + $b->setId($a->getId()); + $b->setTitle('bar'); + $b->save(); + $a->archive(); + $this->assertEquals(1, ArchivableTest10ArchiveQuery::create()->count()); + $this->assertEquals('foo', $b->getTitle()); + } + + public function testArchiveUsesArchiveClassIfSpecified() + { + $a = new ArchivableTest40(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + $a->archive(); + $archive = FooArchiveCollection::getArchiveSingleton(); + $this->assertEquals($a->getId(), $archive->id); + $this->assertEquals('foo', $archive->title); + $this->assertEquals(12, $archive->age); + } + + public function testArchiveReturnsArchivedObject() + { + $a = new ArchivableTest10(); + $a->setTitle('foo'); + $a->save(); + $ret = $a->archive(); + $this->assertInstanceOf('ArchivableTest10Archive', $ret); + $this->assertEquals($a->getPrimaryKey(), $ret->getPrimaryKey()); + $this->assertEquals($a->getTitle(), $ret->getTitle()); + } + + /** + * @expectedException PropelException + */ + public function testArchiveThrowsExceptionOnNewObjects() + { + $a = new ArchivableTest10(); + $a->archive(); + } + + public function testHasRestoreFromArchiveMethod() + { + $this->assertTrue(method_exists('ArchivableTest10', 'restoreFromArchive')); + } + + /** + * @expectedException PropelException + */ + public function testRestoreFromArchiveThrowsExceptionOnUnarchivedObjects() + { + $a = new ArchivableTest10(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + $a->restoreFromArchive(); + } + + public function testRestoreFromArchiveChangesStateToTheArchiveState() + { + $a = new ArchivableTest10(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + $archive = new ArchivableTest10Archive(); + $archive->setId($a->getId()); + $archive->setTitle('bar'); + $archive->setAge(15); + $archive->save(); + $a->restoreFromArchive(); + $this->assertEquals('bar', $a->getTitle()); + $this->assertEquals(15, $a->getAge()); + } + + public function testHasPopulateFromArchiveMethod() + { + $this->assertTrue(method_exists('ArchivableTest10', 'populateFromArchive')); + } + + public function testPopulateFromArchiveReturnsCurrentObject() + { + $archive = new ArchivableTest10Archive(); + $a = new ArchivableTest10(); + $ret = $a->populateFromArchive($archive); + $this->assertSame($ret, $a); + } + + public function testPopulateFromArchive() + { + ArchivableTest10ArchiveQuery::create()->deleteAll(); + ArchivableTest10Query::create()->deleteAllWithoutArchive(); + $archive = new ArchivableTest10Archive(); + $archive->setId(123); // not autoincremented + $archive->setTitle('foo'); + $archive->setAge(12); + $archive->save(); + $a = new ArchivableTest10(); + $a->populateFromArchive($archive); + $this->assertNotEquals(123, $a->getId()); + $this->assertEquals('foo', $a->getTitle()); + $this->assertEquals(12, $a->getAge()); + $b = new ArchivableTest10(); + $b->populateFromArchive($archive, true); + $this->assertEquals(123, $b->getId()); + } + + public function testInsertDoesNotCreateArchiveByDefault() + { + $a = new ArchivableTest10(); + $a->setTitle('foo'); + $a->setAge(12); + ArchivableTest10ArchiveQuery::create()->deleteAll(); + $a->save(); + $this->assertEquals(0, ArchivableTest10ArchiveQuery::create()->count()); + } + + public function testInsertCreatesArchiveIfSpecified() + { + $a = new ArchivableTest30(); + $a->setTitle('foo'); + $a->setAge(12); + MyOldArchivableTest30Query::create()->deleteAll(); + $a->save(); + $this->assertEquals(1, MyOldArchivableTest30Query::create()->count()); + $archive = MyOldArchivableTest30Query::create() + ->filterById($a->getId()) + ->findOne(); + $this->assertInstanceOf('MyOldArchivableTest30', $archive); + $this->assertEquals('foo', $archive->getTitle()); + $this->assertEquals(12, $archive->getAge()); + } + + public function testUpdateDoesNotCreateArchiveByDefault() + { + $a = new ArchivableTest10(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + $a->setTitle('bar'); + ArchivableTest10ArchiveQuery::create()->deleteAll(); + $a->save(); + $this->assertEquals(0, ArchivableTest10ArchiveQuery::create()->count()); + } + + public function testUpdateCreatesArchiveIfSpecified() + { + $a = new ArchivableTest30(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + $a->setTitle('bar'); + MyOldArchivableTest30Query::create()->deleteAll(); + $a->save(); + $this->assertEquals(1, MyOldArchivableTest30Query::create()->count()); + $archive = MyOldArchivableTest30Query::create() + ->filterById($a->getId()) + ->findOne(); + $this->assertInstanceOf('MyOldArchivableTest30', $archive); + $this->assertEquals('bar', $archive->getTitle()); + $this->assertEquals(12, $archive->getAge()); + } + + public function testDeleteCreatesArchiveByDefault() + { + $a = new ArchivableTest10(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + ArchivableTest10ArchiveQuery::create()->deleteAll(); + $a->delete(); + $this->assertEquals(1, ArchivableTest10ArchiveQuery::create()->count()); + $archive = ArchivableTest10ArchiveQuery::create() + ->filterById($a->getId()) + ->findOne(); + $this->assertInstanceOf('ArchivableTest10Archive', $archive); + $this->assertEquals('foo', $archive->getTitle()); + $this->assertEquals(12, $archive->getAge()); + } + + public function testDeleteDoesNotCreateArchiveIfSpecified() + { + $a = new ArchivableTest30(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + MyOldArchivableTest30Query::create()->deleteAll(); + $a->delete(); + $this->assertEquals(0, MyOldArchivableTest30Query::create()->count()); + } + + public function testHasSaveWithoutArchiveMethod() + { + $this->assertTrue(method_exists('ArchivableTest30', 'saveWithoutArchive')); + } + + public function testSaveWithoutArchiveDoesNotCreateArchiveOnInsert() + { + $a = new ArchivableTest30(); + $a->setTitle('foo'); + $a->setAge(12); + MyOldArchivableTest30Query::create()->deleteAll(); + $a->saveWithoutArchive(); + $this->assertEquals(0, MyOldArchivableTest30Query::create()->count()); + } + + public function testSaveWithoutArchiveDoesNotCreateArchiveOnUpdate() + { + $a = new ArchivableTest30(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + $a->setTitle('bar'); + MyOldArchivableTest30Query::create()->deleteAll(); + $a->saveWithoutArchive(); + $this->assertEquals(0, MyOldArchivableTest30Query::create()->count()); + } + + public function testHasDeleteWithoutArchiveMethod() + { + $this->assertTrue(method_exists('ArchivableTest10', 'deleteWithoutArchive')); + } + + public function testDeleteWithoutArchiveDoesNotCreateArchive() + { + $a = new ArchivableTest10(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + ArchivableTest10ArchiveQuery::create()->deleteAll(); + $a->deleteWithoutArchive(); + $this->assertEquals(0, ArchivableTest10ArchiveQuery::create()->count()); + } + + public function testArchiveSetArchivedAtToTheCurrentTime() + { + $a = new ArchivableTest10(); + $a->setTitle('foo'); + $a->save(); + $ret = $a->archive(); + // time without seconds + $this->assertEquals(date('Y-m-d H:i'), $ret->getArchivedAt('Y-m-d H:i')); + } +} + +class FooArchiveQuery +{ + protected $pk; + + public static function create() + { + return new self(); + } + + public function filterByPrimaryKey($pk) + { + $this->pk = $pk; + + return $this; + } + + public function findOne() + { + $archive = FooArchiveCollection::getArchiveSingleton(); + $archive->setId($this->pk); + + return $archive; + } +} + +class FooArchive +{ + public $id, $title, $age; + + public function setId($value) + { + $this->id = $value; + } + + public function setTitle($value) + { + $this->title = $value; + } + + public function setAge($value) + { + $this->age = $value; + } + + public function save() + { + return $this; + } +} + +class FooArchiveCollection +{ + protected static $instance; + + public static function getArchiveSingleton() + { + if (null === self::$instance) { + self::$instance = new FooArchive(); + } + + return self::$instance; + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/archivable/ArchivableBehaviorQueryBuilderModifierTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/archivable/ArchivableBehaviorQueryBuilderModifierTest.php new file mode 100644 index 000000000..e605080f4 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/archivable/ArchivableBehaviorQueryBuilderModifierTest.php @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + +
+ + +EOF; + PropelQuickBuilder::buildSchema($schema); + } + } + + public function testHasArchiveMethod() + { + $this->assertTrue(method_exists('ArchivableTest100Query', 'archive')); + } + + public function testArchiveCreatesACopyByDefault() + { + ArchivableTest100Query::create()->deleteAllWithoutArchive(); + $a = new ArchivableTest100(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + ArchivableTest100ArchiveQuery::create()->deleteAll(); + ArchivableTest100Query::create() + ->filterById($a->getId()) + ->archive(); + $archive = ArchivableTest100ArchiveQuery::create() + ->filterById($a->getId()) + ->findOne(); + $this->assertInstanceOf('ArchivableTest100Archive', $archive); + $this->assertEquals('foo', $archive->getTitle()); + $this->assertEquals(12, $archive->getAge()); + } + + public function testArchiveUpdatesExistingArchive() + { + ArchivableTest100ArchiveQuery::create()->deleteAll(); + $a = new ArchivableTest100(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + ArchivableTest100ArchiveQuery::create()->deleteAll(); + $b = new ArchivableTest100Archive(); + $b->setId($a->getId()); + $b->setTitle('bar'); + $b->save(); + ArchivableTest100Query::create() + ->filterById($a->getId()) + ->archive(null, false); + $this->assertEquals(1, ArchivableTest100ArchiveQuery::create()->count()); + $this->assertEquals('foo', $b->getTitle()); + } + + public function testArchiveReturnsNumberOfArchivedObjectsObject() + { + ArchivableTest100Query::create()->deleteAllWithoutArchive(); + $this->assertEquals(0, ArchivableTest100Query::create()->archive()); + $a = new ArchivableTest100(); + $a->save(); + $this->assertEquals(1, ArchivableTest100Query::create()->archive()); + } + + public function testUpdateDoesNotCreateArchivesByDefault() + { + ArchivableTest100Query::create()->deleteAllWithoutArchive(); + $a = new ArchivableTest100(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + ArchivableTest100ArchiveQuery::create()->deleteAll(); + ArchivableTest100Query::create() + ->filterById($a->getId()) + ->update(array('Title' => 'bar')); + $this->assertEquals(1, ArchivableTest100Query::create()->filterByTitle('bar')->count()); + $this->assertEquals(0, ArchivableTest100ArchiveQuery::create()->count()); + } + + public function testUpdateCreatesArchivesIfSpecified() + { + ArchivableTest300Query::create()->deleteAll(); + $a = new ArchivableTest300(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + MyOldArchivableTest300Query::create()->deleteAll(); + ArchivableTest300Query::create() + ->filterById($a->getId()) + ->update(array('Title' => 'bar')); + $this->assertEquals(1, ArchivableTest300Query::create()->filterByTitle('bar')->count()); + $this->assertEquals(1, MyOldArchivableTest300Query::create()->count()); + } + + public function testDeleteCreatesArchivesByDefault() + { + ArchivableTest100Query::create()->deleteAllWithoutArchive(); + $a = new ArchivableTest100(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + ArchivableTest100ArchiveQuery::create()->deleteAll(); + ArchivableTest100Query::create() + ->filterById($a->getId()) + ->delete(); + $this->assertEquals(0, ArchivableTest100Query::create()->count()); + $this->assertEquals(1, ArchivableTest100ArchiveQuery::create()->count()); + } + + public function testDeleteAllCreatesArchivesByDefault() + { + ArchivableTest100Query::create()->deleteAllWithoutArchive(); + $a = new ArchivableTest100(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + ArchivableTest100ArchiveQuery::create()->deleteAll(); + ArchivableTest100Query::create() + ->deleteAll(); + $this->assertEquals(0, ArchivableTest100Query::create()->count()); + $this->assertEquals(1, ArchivableTest100ArchiveQuery::create()->count()); + } + + public function testDeleteDoesNotCreateArchivesIfSpecified() + { + ArchivableTest300Query::create()->deleteAll(); + $a = new ArchivableTest300(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + MyOldArchivableTest300Query::create()->deleteAll(); + ArchivableTest300Query::create() + ->filterById($a->getId()) + ->delete(); + $this->assertEquals(0, ArchivableTest300Query::create()->count()); + $this->assertEquals(0, MyOldArchivableTest300Query::create()->count()); + } + + public function testDeleteAllDoesNotCreateArchivesIfSpecified() + { + ArchivableTest300Query::create()->deleteAll(); + $a = new ArchivableTest300(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + MyOldArchivableTest300Query::create()->deleteAll(); + ArchivableTest300Query::create() + ->deleteAll(); + $this->assertEquals(0, ArchivableTest300Query::create()->count()); + $this->assertEquals(0, MyOldArchivableTest300Query::create()->count()); + } + + public function testHasUpdateWithoutArchiveMethod() + { + $this->assertTrue(method_exists('ArchivableTest300Query', 'updateWithoutArchive')); + } + + public function testUpdateWithoutArchiveDoesNotCreateArchives() + { + ArchivableTest300Query::create()->deleteAll(); + $a = new ArchivableTest300(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + MyOldArchivableTest300Query::create()->deleteAll(); + ArchivableTest300Query::create() + ->filterById($a->getId()) + ->updateWithoutArchive(array('Title' => 'bar')); + $this->assertEquals(1, ArchivableTest300Query::create()->filterByTitle('bar')->count()); + $this->assertEquals(0, MyOldArchivableTest300Query::create()->count()); + } + + public function testHasDeleteWithoutArchiveMethods() + { + $this->assertTrue(method_exists('ArchivableTest100Query', 'deleteWithoutArchive')); + $this->assertTrue(method_exists('ArchivableTest100Query', 'deleteAllWithoutArchive')); + } + + public function testDeleteWithoutArchiveDoesNotCreateArchivesByDefault() + { + ArchivableTest100Query::create()->deleteAllWithoutArchive(); + $a = new ArchivableTest100(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + ArchivableTest100ArchiveQuery::create()->deleteAll(); + ArchivableTest100Query::create() + ->filterById($a->getId()) + ->deleteWithoutArchive(); + $this->assertEquals(0, ArchivableTest100Query::create()->count()); + $this->assertEquals(0, ArchivableTest100ArchiveQuery::create()->count()); + } + + public function testDeleteAllWithoutArchiveDoesNotCreateArchivesByDefault() + { + ArchivableTest100Query::create()->deleteAllWithoutArchive(); + $a = new ArchivableTest100(); + $a->setTitle('foo'); + $a->setAge(12); + $a->save(); + ArchivableTest100ArchiveQuery::create()->deleteAll(); + ArchivableTest100Query::create() + ->deleteAllWithoutArchive(); + $this->assertEquals(0, ArchivableTest100Query::create()->count()); + $this->assertEquals(0, ArchivableTest100ArchiveQuery::create()->count()); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/archivable/ArchivableBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/archivable/ArchivableBehaviorTest.php new file mode 100644 index 000000000..651e9cb76 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/archivable/ArchivableBehaviorTest.php @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + +
+ + +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + self::$generatedSQL = $builder->getSQL(); + $builder->build(); + } + } + + public function testCreatesArchiveTable() + { + $table = ArchivableTest1Peer::getTableMap(); + $this->assertTrue($table->getDatabaseMap()->hasTable('archivable_test_1_archive')); + $this->assertSame("ArchivableTest1Archive", $table->getDatabaseMap()->getTable('archivable_test_1_archive')->getPhpName()); + } + + public function testDoesNotCreateCustomArchiveTableIfExists() + { + $table = ArchivableTest2Peer::getTableMap(); + $this->assertTrue($table->getDatabaseMap()->hasTable('archivable_test_2_archive')); + } + + public function testCanCreateCustomArchiveTableName() + { + $table = ArchivableTest3Peer::getTableMap(); + $this->assertTrue($table->getDatabaseMap()->hasTable('my_old_archivable_test_3')); + $this->assertSame("MyOldArchivableTest3", $table->getDatabaseMap()->getTable('my_old_archivable_test_3')->getPhpName()); + } + + public function testDoesNotCreateCustomArchiveTableIfArchiveClassIsSpecified() + { + $table = ArchivableTest4Peer::getTableMap(); + $this->assertFalse($table->getDatabaseMap()->hasTable('archivable_test_4_archive')); + } + + public function testCanCreateCustomArchiveTableNameAndPhpName() + { + $table = ArchivableTest5Peer::getTableMap(); + $this->assertTrue($table->getDatabaseMap()->hasTable('archivable_test_5_backup')); + $this->assertSame("ArchivableTest5MyBackup", $table->getDatabaseMap()->getTable('archivable_test_5_backup')->getPhpName()); + } + + public function testCopiesColumnsToArchiveTable() + { + $table = ArchivableTest1ArchivePeer::getTableMap(); + $this->assertTrue($table->hasColumn('id')); + $this->assertContains('[id] INTEGER NOT NULL,', self::$generatedSQL, 'copied columns are not autoincremented'); + $this->assertTrue($table->hasColumn('title')); + $this->assertTrue($table->hasColumn('age')); + $this->assertTrue($table->hasColumn('foo_id')); + } + + public function testDoesNotCopyForeignKeys() + { + $table = ArchivableTest1ArchivePeer::getTableMap(); + $this->assertEquals(array(), $table->getRelations()); + } + + public function testCopiesIndices() + { + $table = ArchivableTest1ArchivePeer::getTableMap(); + + $expected = "CREATE INDEX [archivable_test_1_archive_I_1] ON [archivable_test_1_archive] ([title],[age]);"; + $this->assertContains($expected, self::$generatedSQL); + } + + public function testCopiesUniquesToIndices() + { + $table = ArchivableTest2ArchivePeer::getTableMap(); + + $expected = "CREATE INDEX [my_old_archivable_test_3_I_1] ON [my_old_archivable_test_3] ([title]);"; + $this->assertContains($expected, self::$generatedSQL); + } + + public function testAddsArchivedAtColumnToArchiveTableByDefault() + { + $table = ArchivableTest1ArchivePeer::getTableMap(); + $this->assertTrue($table->hasColumn('archived_at')); + } + + public function testDoesNotAddArchivedAtColumnToArchiveTableIfSpecified() + { + $table = MyOldArchivableTest3Peer::getTableMap(); + $this->assertFalse($table->hasColumn('archived_at')); + } + + public function testDatabaseLevelBehavior() + { + $schema = << + + + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $builder->getSQL(); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceBehaviorNamespacedTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceBehaviorNamespacedTest.php new file mode 100644 index 000000000..86357a543 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceBehaviorNamespacedTest.php @@ -0,0 +1,41 @@ +setTitle('Foo'); + $concreteArticle->setBody('Bar'); + $parent = $concreteArticle->getParentOrCreate(); + $this->assertEquals('Foo\Bar\NamespacedConcreteArticle', $parent->getDescendantClass(), 'getDescendantClass() will return Foo\Bar\NamespacedConcreteArticle'); + } + + public function testgetParentOrCreateWithPrimaryKeyNotNull() + { + $concreteArticle = new \Foo\Bar\NamespacedConcreteArticle(); + $concreteArticle->setPrimaryKey(1); + $concreteArticle->setTitle('Foo'); + $concreteArticle->setBody('Bar'); + $parent = $concreteArticle->getParentOrCreate(); + $this->assertEquals('Foo\Bar\NamespacedConcreteArticle', $parent->getDescendantClass(), 'getDescendantClass() will return Foo\Bar\NamespacedConcreteArticle'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceBehaviorTest.php index 8c86fa122..70610079d 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceBehaviorTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceBehaviorTest.php @@ -9,194 +9,337 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../../../runtime/lib/Propel.php'; +require_once dirname(__FILE__) . '/../../../../../generator/lib/util/PropelQuickBuilder.php'; +require_once dirname(__FILE__) . '/../../../../../generator/lib/behavior/concrete_inheritance/ConcreteInheritanceBehavior.php'; /** * Tests for ConcreteInheritanceBehavior class * * @author François Zaniontto - * @version $Revision: 1774 $ + * @version $Revision$ * @package generator.behavior.concrete_inheritance */ class ConcreteInheritanceBehaviorTest extends BookstoreTestBase { - public function testParentBehavior() - { - $behaviors = ConcreteContentPeer::getTableMap()->getBehaviors(); - $this->assertTrue(array_key_exists('concrete_inheritance_parent', $behaviors), 'modifyTable() gives the parent table the concrete_inheritance_parent behavior'); - $this->assertEquals('descendant_class', $behaviors['concrete_inheritance_parent']['descendant_column'], 'modifyTable() passed the descendent_column parameter to the parent behavior'); - } - - public function testModifyTableAddsParentColumn() - { - $contentColumns = array('id', 'title', 'category_id'); - $article = ConcreteArticlePeer::getTableMap(); - foreach ($contentColumns as $column) { - $this->assertTrue($article->containsColumn($column), 'modifyTable() adds the columns of the parent table'); - } - $quizz = ConcreteQuizzPeer::getTableMap(); - $this->assertEquals(3, count($quizz->getColumns()), 'modifyTable() does not add a column of the parent table if a similar column exists'); - } - - public function testModifyTableCopyDataAddsOneToOneRelationships() - { - $article = ConcreteArticlePeer::getTableMap(); - $this->assertTrue($article->hasRelation('ConcreteContent'), 'modifyTable() adds a relationship to the parent'); - $relation = $article->getRelation('ConcreteContent'); - $this->assertEquals(RelationMap::MANY_TO_ONE, $relation->getType(), 'modifyTable adds a one-to-one relationship'); - $content = ConcreteContentPeer::getTableMap(); - $relation = $content->getRelation('ConcreteArticle'); - $this->assertEquals(RelationMap::ONE_TO_ONE, $relation->getType(), 'modifyTable adds a one-to-one relationship'); - } + public function setUp() + { + parent::setUp(); - public function testModifyTableNoCopyDataNoParentRelationship() - { - $quizz = ConcreteQuizzPeer::getTableMap(); - $this->assertFalse($quizz->hasRelation('ConcreteContent'), 'modifyTable() does not add a relationship to the parent when copy_data is false'); - } - - public function testModifyTableCopyDataRemovesAutoIncrement() - { - $content = new ConcreteContent(); - $content->save(); - $c = new Criteria; - $c->add(ConcreteArticlePeer::ID, $content->getId()); - try { - ConcreteArticlePeer::doInsert($c); - $this->assertTrue(true, 'modifyTable() removed autoIncrement from copied Primary keys'); - } catch (PropelException $e) { - $this->fail('modifyTable() removed autoIncrement from copied Primary keys'); - } - } + if (!class_exists('ConcreteContentSetPkQuery')) { + $schema = << + + + + + + - /** - * @expectedException PropelException - */ - public function testModifyTableNoCopyDataKeepsAutoIncrement() - { - $content = new ConcreteContent(); - $content->save(); - $c = new Criteria; - $c->add(ConcreteQuizzPeer::ID, $content->getId()); - ConcreteQuizzPeer::doInsert($c); - } - - public function testModifyTableAddsForeignKeys() - { - $article = ConcreteArticlePeer::getTableMap(); - $this->assertTrue($article->hasRelation('ConcreteCategory'), 'modifyTable() copies relationships from parent table'); - } +
+ + + + + + +
+ +EOF; - public function testModifyTableAddsForeignKeysWithoutDuplicates() - { - $article = ConcreteAuthorPeer::getTableMap(); - $this->assertTrue($article->hasRelation('ConcreteNews'), 'modifyTable() copies relationships from parent table and removes hardcoded refPhpName'); - } + PropelQuickBuilder::buildSchema($schema); + } + if (!class_exists('ConcretePageQuery')) { + $schema = << + + + + +
+ + + + + +
+ +EOF; - public function testModifyTableAddsValidators() - { - $article = ConcreteArticlePeer::getTableMap(); - $this->assertTrue($article->getColumn('title')->hasValidators(), 'modifyTable() copies validators from parent table'); - } - - // no way to test copying of indices and uniques, except by reverse engineering the db... - - public function testParentObjectClass() - { - $article = new ConcreteArticle(); // to autoload the BaseConcreteArticle class - $r = new ReflectionClass('BaseConcreteArticle'); - $this->assertEquals('ConcreteContent', $r->getParentClass()->getName(), 'concrete_inheritance changes the parent class of the Model Object to the parent object class'); - $quizz = new ConcreteQuizz(); // to autoload the BaseConcreteQuizz class - $r = new ReflectionClass('BaseConcreteQuizz'); - $this->assertEquals('ConcreteContent', $r->getParentClass()->getName(), 'concrete_inheritance changes the parent class of the Model Object to the parent object class'); - } - - public function testParentQueryClass() - { - $q = new ConcreteArticleQuery(); // to autoload the BaseConcreteArticleQuery class - $r = new ReflectionClass('BaseConcreteArticleQuery'); - $this->assertEquals('ConcreteContentQuery', $r->getParentClass()->getName(), 'concrete_inheritance changes the parent class of the Query Object to the parent object class'); - $q = new ConcreteQuizzQuery(); // to autoload the BaseConcreteQuizzQuery class - $r = new ReflectionClass('BaseConcreteQuizzQuery'); - $this->assertEquals('ConcreteContentQuery', $r->getParentClass()->getName(), 'concrete_inheritance changes the parent class of the Query Object to the parent object class'); - } - - public function testPreSaveCopyData() - { - ConcreteArticleQuery::create()->deleteAll(); - ConcreteQuizzQuery::create()->deleteAll(); - ConcreteContentQuery::create()->deleteAll(); - ConcreteCategoryQuery::create()->deleteAll(); - $category = new ConcreteCategory(); - $category->setName('main'); - $article = new ConcreteArticle(); - $article->setConcreteCategory($category); - $article->save(); - $this->assertNotNull($article->getId()); - $this->assertNotNull($category->getId()); - $content = ConcreteContentQuery::create()->findPk($article->getId()); - $this->assertNotNull($content); - $this->assertEquals($category->getId(), $content->getCategoryId()); - } + PropelQuickBuilder::buildSchema($schema); + } + } - public function testPreSaveNoCopyData() - { - ConcreteArticleQuery::create()->deleteAll(); - ConcreteQuizzQuery::create()->deleteAll(); - ConcreteContentQuery::create()->deleteAll(); - $quizz = new ConcreteQuizz(); - $quizz->save(); - $this->assertNotNull($quizz->getId()); - $content = ConcreteContentQuery::create()->findPk($quizz->getId()); - $this->assertNull($content); - } - - public function testGetParentOrCreateNew() - { - $article = new ConcreteArticle(); - $content = $article->getParentOrCreate(); - $this->assertTrue($content instanceof ConcreteContent, 'getParentOrCreate() returns an instance of the parent class'); - $this->assertTrue($content->isNew(), 'getParentOrCreate() returns a new instance of the parent class if the object is new'); - $this->assertEquals('ConcreteArticle', $content->getDescendantClass(), 'getParentOrCreate() correctly sets the descendant_class of the parent object'); - } + public function testParentBehavior() + { + $behaviors = ConcreteContentPeer::getTableMap()->getBehaviors(); + $this->assertTrue(array_key_exists('concrete_inheritance_parent', $behaviors), 'modifyTable() gives the parent table the concrete_inheritance_parent behavior'); + $this->assertEquals('descendant_class', $behaviors['concrete_inheritance_parent']['descendant_column'], 'modifyTable() passed the descendent_column parameter to the parent behavior'); + } - public function testGetParentOrCreateExisting() - { - $article = new ConcreteArticle(); - $article->save(); - ConcreteContentPeer::clearInstancePool(); - $content = $article->getParentOrCreate(); - $this->assertTrue($content instanceof ConcreteContent, 'getParentOrCreate() returns an instance of the parent class'); - $this->assertFalse($content->isNew(), 'getParentOrCreate() returns an existing instance of the parent class if the object is persisted'); - $this->assertEquals($article->getId(), $content->getId(), 'getParentOrCreate() returns the parent object related to the current object'); - } - - public function testGetSyncParent() - { - $category = new ConcreteCategory(); - $category->setName('main'); - $article = new ConcreteArticle(); - $article->setTitle('FooBar'); - $article->setConcreteCategory($category); - $content = $article->getSyncParent(); - $this->assertEquals('FooBar', $content->getTitle(), 'getSyncParent() returns a synchronized parent object'); - $this->assertEquals($category, $content->getConcreteCategory(), 'getSyncParent() returns a synchronized parent object'); - } - - public function testPostDeleteCopyData() - { - ConcreteArticleQuery::create()->deleteAll(); - ConcreteQuizzQuery::create()->deleteAll(); - ConcreteContentQuery::create()->deleteAll(); - ConcreteCategoryQuery::create()->deleteAll(); - $category = new ConcreteCategory(); - $category->setName('main'); - $article = new ConcreteArticle(); - $article->setConcreteCategory($category); - $article->save(); - $id = $article->getId(); + public function testModifyTableAddsParentColumn() + { + $contentColumns = array('id', 'title', 'category_id'); + $article = ConcreteArticlePeer::getTableMap(); + foreach ($contentColumns as $column) { + $this->assertTrue($article->containsColumn($column), 'modifyTable() adds the columns of the parent table'); + } + $quizz = ConcreteQuizzPeer::getTableMap(); + $this->assertEquals(3, count($quizz->getColumns()), 'modifyTable() does not add a column of the parent table if a similar column exists'); + } + + public function testModifyTableCopyDataAddsOneToOneRelationships() + { + $article = ConcreteArticlePeer::getTableMap(); + $this->assertTrue($article->hasRelation('ConcreteContent'), 'modifyTable() adds a relationship to the parent'); + $relation = $article->getRelation('ConcreteContent'); + $this->assertEquals(RelationMap::MANY_TO_ONE, $relation->getType(), 'modifyTable adds a one-to-one relationship'); + $content = ConcreteContentPeer::getTableMap(); + $relation = $content->getRelation('ConcreteArticle'); + $this->assertEquals(RelationMap::ONE_TO_ONE, $relation->getType(), 'modifyTable adds a one-to-one relationship'); + } + + public function testModifyTableNoCopyDataNoParentRelationship() + { + $quizz = ConcreteQuizzPeer::getTableMap(); + $this->assertFalse($quizz->hasRelation('ConcreteContent'), 'modifyTable() does not add a relationship to the parent when copy_data is false'); + } + + public function testModifyTableCopyDataRemovesAutoIncrement() + { + $content = new ConcreteContent(); + $content->save(); + $c = new Criteria; + $c->add(ConcreteArticlePeer::ID, $content->getId()); + try { + ConcreteArticlePeer::doInsert($c); + $this->assertTrue(true, 'modifyTable() removed autoIncrement from copied Primary keys'); + } catch (PropelException $e) { + $this->fail('modifyTable() removed autoIncrement from copied Primary keys'); + } + } + + /** + * @expectedException PropelException + */ + public function testModifyTableNoCopyDataKeepsAutoIncrement() + { + $content = new ConcreteContent(); + $content->save(); + $c = new Criteria; + $c->add(ConcreteQuizzPeer::ID, $content->getId()); + ConcreteQuizzPeer::doInsert($c); + } + + public function testModifyTableAddsForeignKeys() + { + $article = ConcreteArticlePeer::getTableMap(); + $this->assertTrue($article->hasRelation('ConcreteCategory'), 'modifyTable() copies relationships from parent table'); + } + + public function testModifyTableAddsForeignKeysWithoutDuplicates() + { + $article = ConcreteAuthorPeer::getTableMap(); + $this->assertTrue($article->hasRelation('ConcreteNews'), 'modifyTable() copies relationships from parent table and removes hardcoded refPhpName'); + } + + public function testModifyTableAddsValidators() + { + $article = ConcreteArticlePeer::getTableMap(); + $this->assertTrue($article->getColumn('title')->hasValidators(), 'modifyTable() copies validators from parent table'); + } + + // no way to test copying of indices and uniques, except by reverse engineering the db... + + public function testParentObjectClass() + { + $article = new ConcreteArticle(); // to autoload the BaseConcreteArticle class + $r = new ReflectionClass('BaseConcreteArticle'); + $this->assertEquals('ConcreteContent', $r->getParentClass()->getName(), 'concrete_inheritance changes the parent class of the Model Object to the parent object class'); + $quizz = new ConcreteQuizz(); // to autoload the BaseConcreteQuizz class + $r = new ReflectionClass('BaseConcreteQuizz'); + $this->assertEquals('ConcreteContent', $r->getParentClass()->getName(), 'concrete_inheritance changes the parent class of the Model Object to the parent object class'); + } + + public function testParentQueryClass() + { + $q = new ConcreteArticleQuery(); // to autoload the BaseConcreteArticleQuery class + $r = new ReflectionClass('BaseConcreteArticleQuery'); + $this->assertEquals('ConcreteContentQuery', $r->getParentClass()->getName(), 'concrete_inheritance changes the parent class of the Query Object to the parent object class'); + $q = new ConcreteQuizzQuery(); // to autoload the BaseConcreteQuizzQuery class + $r = new ReflectionClass('BaseConcreteQuizzQuery'); + $this->assertEquals('ConcreteContentQuery', $r->getParentClass()->getName(), 'concrete_inheritance changes the parent class of the Query Object to the parent object class'); + } + + /** + * @link http://www.propelorm.org/ticket/1262 + */ + public function testParentPeerClass() + { + $q = new ConcreteArticlePeer(); // to autoload the BaseConcreteArticlePeer class + $r = new ReflectionClass('BaseConcreteArticlePeer'); + $this->assertEquals('ConcreteContentPeer', $r->getParentClass()->getName(), 'concrete_inheritance changes the parent class of the Peer Object to the parent object class'); + $q = new ConcreteQuizzPeer(); // to autoload the BaseConcreteQuizzPeer class + $r = new ReflectionClass('BaseConcreteQuizzPeer'); + $this->assertEquals('ConcreteContentPeer', $r->getParentClass()->getName(), 'concrete_inheritance changes the parent class of the Peer Object to the parent object class'); + } + + public function testPreSaveCopyData() + { + ConcreteArticleQuery::create()->deleteAll(); + ConcreteQuizzQuery::create()->deleteAll(); + ConcreteContentQuery::create()->deleteAll(); + ConcreteCategoryQuery::create()->deleteAll(); + $category = new ConcreteCategory(); + $category->setName('main'); + $article = new ConcreteArticle(); + $article->setConcreteCategory($category); + $article->save(); + $this->assertNotNull($article->getId()); + $this->assertNotNull($category->getId()); + $content = ConcreteContentQuery::create()->findPk($article->getId()); + $this->assertNotNull($content); + $this->assertEquals($category->getId(), $content->getCategoryId()); + } + + public function testPreSaveNoCopyData() + { + ConcreteArticleQuery::create()->deleteAll(); + ConcreteQuizzQuery::create()->deleteAll(); + ConcreteContentQuery::create()->deleteAll(); + $quizz = new ConcreteQuizz(); + $quizz->save(); + $this->assertNotNull($quizz->getId()); + $content = ConcreteContentQuery::create()->findPk($quizz->getId()); + $this->assertNull($content); + } + + public function testGetParentOrCreateNew() + { + $article = new ConcreteArticle(); + $content = $article->getParentOrCreate(); + $this->assertTrue($content instanceof ConcreteContent, 'getParentOrCreate() returns an instance of the parent class'); + $this->assertTrue($content->isNew(), 'getParentOrCreate() returns a new instance of the parent class if the object is new'); + $this->assertEquals('ConcreteArticle', $content->getDescendantClass(), 'getParentOrCreate() correctly sets the descendant_class of the parent object'); + } + + public function testGetParentOrCreateExisting() + { + $article = new ConcreteArticle(); + $article->save(); + ConcreteContentPeer::clearInstancePool(); + $content = $article->getParentOrCreate(); + $this->assertTrue($content instanceof ConcreteContent, 'getParentOrCreate() returns an instance of the parent class'); + $this->assertFalse($content->isNew(), 'getParentOrCreate() returns an existing instance of the parent class if the object is persisted'); + $this->assertEquals($article->getId(), $content->getId(), 'getParentOrCreate() returns the parent object related to the current object'); + } + + public function testGetParentOrCreateExistingParent() + { + ConcreteContentQuery::create()->deleteAll(); + ConcreteArticleQuery::create()->deleteAll(); + $content = new ConcreteContent(); + $content->save(); + $id = $content->getId(); + ConcreteContentPeer::clearInstancePool(); + $article = new ConcreteArticle(); + $article->setId($id); + $article->save(); + $this->assertEquals($id, $article->getId(), 'getParentOrCreate() keeps manually set pk'); + $this->assertEquals(1, ConcreteContentQuery::create()->count(), 'getParentOrCreate() creates no new parent entry'); + } + + public function testGetSyncParent() + { + $category = new ConcreteCategory(); + $category->setName('main'); + $article = new ConcreteArticle(); + $article->setTitle('FooBar'); + $article->setConcreteCategory($category); + $content = $article->getSyncParent(); + $this->assertEquals('FooBar', $content->getTitle(), 'getSyncParent() returns a synchronized parent object'); + $this->assertEquals($category, $content->getConcreteCategory(), 'getSyncParent() returns a synchronized parent object'); + } + + public function testPostDeleteCopyData() + { + ConcreteArticleQuery::create()->deleteAll(); + ConcreteQuizzQuery::create()->deleteAll(); + ConcreteContentQuery::create()->deleteAll(); + ConcreteCategoryQuery::create()->deleteAll(); + $category = new ConcreteCategory(); + $category->setName('main'); + $article = new ConcreteArticle(); + $article->setConcreteCategory($category); + $article->save(); + $id = $article->getId(); $article->delete(); $this->assertNull(ConcreteContentQuery::create()->findPk($id), 'delete() removes the parent record as well'); - } - + } + + public function testGetParentOrCreateNewWithPK() + { + ConcreteContentSetPkQuery::create()->deleteAll(); + ConcreteArticleSetPkQuery::create()->deleteAll(); + $article = new ConcreteArticleSetPk(); + $article->setId(5); + $content = $article->getParentOrCreate(); + $this->assertEquals(5, $article->getId(), 'getParentOrCreate() keeps manually set pk'); + $this->assertTrue($content instanceof ConcreteContentSetPk, 'getParentOrCreate() returns an instance of the parent class'); + $this->assertTrue($content->isNew(), 'getParentOrCreate() returns a new instance of the parent class if the object is new'); + $this->assertEquals(5,$content->getId(), 'getParentOrCreate() returns a instance of the parent class with pk set'); + $this->assertEquals('ConcreteArticleSetPk', $content->getDescendantClass(), 'getParentOrCreate() correctly sets the descendant_class of the parent object'); + } + + public function testSetPKOnNewObject() + { + ConcreteContentSetPkQuery::create()->deleteAll(); + ConcreteArticleSetPkQuery::create()->deleteAll(); + $article = new ConcreteArticleSetPk(); + $article->setId(2); + $article->save(); + $this->assertEquals(2, $article->getId(), 'getParentOrCreate() keeps manually set pk after save'); + $this->assertEquals(1, ConcreteContentSetPkQuery::create()->count(), 'getParentOrCreate() creates a parent entry'); + $articledb = ConcreteArticleSetPkQuery::create()->findOneById(2); + $this->assertEquals(2, $articledb->getId(), 'getParentOrCreate() keeps manually set pk after save and reload from db'); + } + + public function testSetPKOnNewObjectWithPkAlreadyInParentTable() + { + ConcreteContentSetPkQuery::create()->deleteAll(); + ConcreteArticleSetPkQuery::create()->deleteAll(); + try { + $article = new ConcreteArticleSetPk(); + $article->setId(4); + $article->save(); + $article = new ConcreteArticleSetPk(); + $article->setId(4); + $article->save(); + $this->fail('getParentOrCreate() returns a new parent object on new child objects with pk set'); + } catch (PropelException $e) { + $this->assertTrue(true, 'getParentOrCreate() returns a new parent object on new child objects with pk set'); + } + } + + public function testSetPkAllowPkInsertIsFalse() + { + ConcreteContentQuery::create()->deleteAll(); + ConcreteArticleQuery::create()->deleteAll(); + try { + $article = new ConcreteArticle(); + $article->setId(4); + $article->save(); + $this->fail('SetPk fails when allowPkInsert is false'); + } catch (PropelException $e) { + $this->assertTrue(true, 'SetPk fails when allowPkInsert is false'); + } + } + + public function testTranslateFieldNameWithPhpName() + { + $this->assertEquals('id', ConcreteSubPagePeer::translateFieldName('tab_concrete_subpage.id', BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME)); + $this->assertEquals('id', ConcretePagePeer::translateFieldName('tab_concrete_page.id', BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME)); + } + } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceBehaviorWithSchemaTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceBehaviorWithSchemaTest.php new file mode 100644 index 000000000..83809dee0 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceBehaviorWithSchemaTest.php @@ -0,0 +1,39 @@ +getBehaviors(); + $this->assertTrue(array_key_exists('concrete_inheritance_parent', $behaviors), 'modifyTable() gives the parent table the concrete_inheritance_parent behavior'); + $this->assertEquals('descendant_class', $behaviors['concrete_inheritance_parent']['descendant_column'], 'modifyTable() passed the descendent_column parameter to the parent behavior'); + } + + public function testGetParentOrCreateNewWithSchemas() + { + $second_hand_book = new SecondHandBooksSecondHandBook(); + $book = $second_hand_book->getParentOrCreate(); + $this->assertTrue($book instanceof BookStoreSchemasBook, 'getParentOrCreate() returns an instance of the parent class'); + $this->assertTrue($book->isNew(), 'getParentOrCreate() returns a new instance of the parent class if the object is new'); + $this->assertEquals('SecondHandBooksSecondHandBook', $book->getDescendantClass(), 'getParentOrCreate() correctly sets the descendant_class of the parent object'); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceExcludedParentBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceExcludedParentBehaviorTest.php new file mode 100644 index 000000000..6a6be079c --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceExcludedParentBehaviorTest.php @@ -0,0 +1,39 @@ +getMethod('addChild')->getParameters(); + $this->assertEquals('ConcreteCategory', $p[0]->getClass()->getName(), 'concrete_inheritance does not generate addChild method child object class'); + } + + public function testHasChildPeerIsValidMethod() + { + $r = new ReflectionClass('BaseConcreteTagPeer'); + $p =$r->getMethod('isValid')->getParameters(); + $this->assertEquals('ConcreteCategory', $p[0]->getClass()->getName(), 'concrete_inheritance does not generate isValid method child peer class'); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceParentBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceParentBehaviorTest.php index b62cd3d00..1ed6ce163 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceParentBehaviorTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/concrete_inheritance/ConcreteInheritanceParentBehaviorTest.php @@ -9,45 +9,45 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/BookstoreTestBase.php'; /** * Tests for ConcreteInheritanceParentBehavior class * * @author François Zaniontto - * @version $Revision: 1612 $ + * @version $Revision$ * @package generator.behavior.concrete_inheritance */ class ConcreteInheritanceParentBehaviorTest extends BookstoreTestBase { - public function testHasChildObject() - { - ConcreteArticleQuery::create()->deleteAll(); - ConcreteQuizzQuery::create()->deleteAll(); - ConcreteContentQuery::create()->deleteAll(); - $content = new ConcreteContent(); - $content->save(); - $this->assertFalse($content->hasChildObject()); - - $article = new ConcreteArticle(); - $article->save(); - $content = $article->getConcreteContent(); - $this->assertTrue($content->hasChildObject()); - } - - public function testGetChildObject() - { - ConcreteArticleQuery::create()->deleteAll(); - ConcreteQuizzQuery::create()->deleteAll(); - ConcreteContentQuery::create()->deleteAll(); - $content = new ConcreteContent(); - $content->save(); - $this->assertNull($content->getChildObject()); - - $article = new ConcreteArticle(); - $article->save(); - $content = $article->getConcreteContent(); - $this->assertEquals($article, $content->getChildObject()); - } - + public function testHasChildObject() + { + ConcreteArticleQuery::create()->deleteAll(); + ConcreteQuizzQuery::create()->deleteAll(); + ConcreteContentQuery::create()->deleteAll(); + $content = new ConcreteContent(); + $content->save(); + $this->assertFalse($content->hasChildObject()); + + $article = new ConcreteArticle(); + $article->save(); + $content = $article->getConcreteContent(); + $this->assertTrue($content->hasChildObject()); + } + + public function testGetChildObject() + { + ConcreteArticleQuery::create()->deleteAll(); + ConcreteQuizzQuery::create()->deleteAll(); + ConcreteContentQuery::create()->deleteAll(); + $content = new ConcreteContent(); + $content->save(); + $this->assertNull($content->getChildObject()); + + $article = new ConcreteArticle(); + $article->save(); + $content = $article->getConcreteContent(); + $this->assertEquals($article, $content->getChildObject()); + } + } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/i18n/I18nBehaviorObjectBuilderModifierTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/i18n/I18nBehaviorObjectBuilderModifierTest.php new file mode 100644 index 000000000..7a6cd8e82 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/i18n/I18nBehaviorObjectBuilderModifierTest.php @@ -0,0 +1,410 @@ + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + +
+ +EOF; + PropelQuickBuilder::buildSchema($schema); + } + } + + public function testPostDeleteEmulatesOnDeleteCascade() + { + I18nBehaviorTest1Query::create()->deleteAll(); + I18nBehaviorTest1I18nQuery::create()->deleteAll(); + $o = new I18nBehaviorTest1(); + $o->setFoo(123); + $o->setLocale('en_US'); + $o->setBar('hello'); + $o->setLocale('fr_FR'); + $o->setBar('bonjour'); + $o->save(); + $this->assertEquals(2, I18nBehaviorTest1I18nQuery::create()->count()); + $o->clearI18nBehaviorTest1I18ns(); + $o->delete(); + $this->assertEquals(0, I18nBehaviorTest1I18nQuery::create()->count()); + } + + public function testGetTranslationReturnsTranslationObject() + { + $o = new I18nBehaviorTest1(); + $translation = $o->getTranslation(); + $this->assertTrue($translation instanceof I18nBehaviorTest1I18n); + } + + public function testGetTranslationOnNewObjectReturnsNewTranslation() + { + $o = new I18nBehaviorTest1(); + $translation = $o->getTranslation(); + $this->assertTrue($translation->isNew()); + } + + public function testGetTranslationOnPersistedObjectReturnsNewTranslation() + { + $o = new I18nBehaviorTest1(); + $o->save(); + $translation = $o->getTranslation(); + $this->assertTrue($translation->isNew()); + } + + public function testGetTranslationOnPersistedObjectWithTranslationReturnsExistingTranslation() + { + $o = new I18nBehaviorTest1(); + $translation = new I18nBehaviorTest1I18n(); + $o->addI18nBehaviorTest1I18n($translation); + $o->save(); + $translation = $o->getTranslation(); + $this->assertFalse($translation->isNew()); + } + + public function testGetTranslationAcceptsALocaleParameter() + { + $o = new I18nBehaviorTest1(); + $translation1 = new I18nBehaviorTest1I18n(); + $translation1->setLocale('en_US'); + $o->addI18nBehaviorTest1I18n($translation1); + $translation2 = new I18nBehaviorTest1I18n(); + $translation2->setLocale('fr_FR'); + $o->addI18nBehaviorTest1I18n($translation2); + $o->save(); + $this->assertEquals($translation1, $o->getTranslation('en_US')); + $this->assertEquals($translation2, $o->getTranslation('fr_FR')); + } + + public function testGetTranslationSetsTheLocaleOnTheTranslation() + { + $o = new I18nBehaviorTest1(); + $o->save(); + $translation = $o->getTranslation(); + $this->assertEquals('en_US', $translation->getLocale()); + $o = new I18nBehaviorTest2(); + $o->save(); + $translation = $o->getTranslation(); + $this->assertEquals('fr_FR', $translation->getLocale()); + } + + public function testGetTranslationUsesInternalCollectionIfAvailable() + { + $o = new I18nBehaviorTest1(); + $translation1 = new I18nBehaviorTest1I18n(); + $translation1->setLocale('en_US'); + $o->addI18nBehaviorTest1I18n($translation1); + $translation2 = new I18nBehaviorTest1I18n(); + $translation2->setLocale('fr_FR'); + $o->addI18nBehaviorTest1I18n($translation2); + $translation = $o->getTranslation('en_US'); + $this->assertEquals($translation1, $translation); + } + + public function testRemoveTranslation() + { + $o = new I18nBehaviorTest1(); + $translation1 = new I18nBehaviorTest1I18n(); + $translation1->setLocale('en_US'); + $o->addI18nBehaviorTest1I18n($translation1); + $translation2 = new I18nBehaviorTest1I18n(); + $translation2->setLocale('fr_FR'); + $translation2->setBar('bonjour'); + $o->addI18nBehaviorTest1I18n($translation2); + $o->save(); + $this->assertEquals(2, $o->countI18nBehaviorTest1I18ns()); + $o->removeTranslation('fr_FR'); + $this->assertEquals(1, $o->countI18nBehaviorTest1I18ns()); + $translation = $o->getTranslation('fr_FR'); + $this->assertNotEquals($translation->getBar(), $translation2->getBar()); + } + + public function testLocaleSetterAndGetterExist() + { + $this->assertTrue(method_exists('I18nBehaviorTest1', 'setLocale')); + $this->assertTrue(method_exists('I18nBehaviorTest1', 'getLocale')); + } + + public function testGetLocaleReturnsDefaultLocale() + { + $o = new I18nBehaviorTest1(); + $this->assertEquals('en_US', $o->getLocale()); + $o = new I18nBehaviorTest2(); + $this->assertEquals('fr_FR', $o->getLocale()); + } + + public function testSetLocale() + { + $o = new I18nBehaviorTest1(); + $o->setLocale('fr_FR'); + $this->assertEquals('fr_FR', $o->getLocale()); + } + + public function testSetLocaleUsesDefaultLocale() + { + $o = new I18nBehaviorTest1(); + $o->setLocale('fr_FR'); + $o->setLocale(); + $this->assertEquals('en_US', $o->getLocale()); + } + + public function testLocaleSetterAndGetterAliasesExist() + { + $this->assertTrue(method_exists('I18nBehaviorTest2', 'setCulture')); + $this->assertTrue(method_exists('I18nBehaviorTest2', 'getCulture')); + } + + public function testGetLocaleAliasReturnsDefaultLocale() + { + $o = new I18nBehaviorTest2(); + $this->assertEquals('fr_FR', $o->getCulture()); + } + + public function testSetLocaleAlias() + { + $o = new I18nBehaviorTest2(); + $o->setCulture('en_US'); + $this->assertEquals('en_US', $o->getCulture()); + } + + public function testGetCurrentTranslationUsesDefaultLocale() + { + $o = new I18nBehaviorTest1(); + $t = $o->getCurrentTranslation(); + $this->assertEquals('en_US', $t->getLocale()); + $o = new I18nBehaviorTest2(); + $t = $o->getCurrentTranslation(); + $this->assertEquals('fr_FR', $t->getLocale()); + } + + public function testGetCurrentTranslationUsesCurrentLocale() + { + $o = new I18nBehaviorTest1(); + $o->setLocale('fr_FR'); + $this->assertEquals('fr_FR', $o->getCurrentTranslation()->getLocale()); + $o->setLocale('pt_PT'); + $this->assertEquals('pt_PT', $o->getCurrentTranslation()->getLocale()); + } + + public function testI18nColumnGetterUsesCurrentTranslation() + { + $o = new I18nBehaviorTest1(); + $t1 = $o->getCurrentTranslation(); + $t1->setBar('hello'); + $o->setLocale('fr_FR'); + $t2 = $o->getCurrentTranslation(); + $t2->setBar('bonjour'); + //$o->save(); + $o->setLocale('en_US'); + $this->assertEquals('hello', $o->getBar()); + $o->setLocale('fr_FR'); + $this->assertEquals('bonjour', $o->getBar()); + } + + public function testI18nColumnSetterUsesCurrentTranslation() + { + $o = new I18nBehaviorTest1(); + $o->setBar('hello'); + $o->setLocale('fr_FR'); + $o->setBar('bonjour'); + $o->setLocale('en_US'); + $this->assertEquals('hello', $o->getBar()); + $o->setLocale('fr_FR'); + $this->assertEquals('bonjour', $o->getBar()); + } + + public function testTranslationsArePersisted() + { + $o = new I18nBehaviorTest1(); + $o->save(); + $count = I18nBehaviorTest1I18nQuery::create() + ->filterById($o->getId()) + ->count(); + $this->assertEquals(0, $count); + $o->setBar('hello'); + $o->setLocale('fr_FR'); + $o->setBar('bonjour'); + $o->save(); + $count = I18nBehaviorTest1I18nQuery::create() + ->filterById($o->getId()) + ->count(); + $this->assertEquals(2, $count); + } + + public function testClearRemovesExistingTranslations() + { + $o = new I18nBehaviorTest1(); + $translation1 = new I18nBehaviorTest1I18n(); + $translation1->setBar('baz'); + $translation1->setLocale('fr_FR'); + $o->addI18nBehaviorTest1I18n($translation1); + $o->clear(); + $this->assertEquals('en_US', $o->getLocale()); + $t1 = $o->getTranslation('fr_FR'); + $this->assertEquals('', $t1->getBar()); + } + + public function testI18nWithRelations() + { + MovieQuery::create()->deleteAll(); + $count = MovieQuery::create()->count(); + $this->assertEquals(0, $count, 'No movie before the test'); + ToyQuery::create()->deleteAll(); + $count = ToyQuery::create()->count(); + $this->assertEquals(0, $count, 'No toy before the test'); + MovieI18nQuery::create()->deleteAll(); + $count = MovieI18nQuery::create()->count(); + $this->assertEquals(0, $count, 'No i18n movies before the test'); + + $m = new Movie(); + $m->setLocale('en'); + $m->setTitle('V For Vendetta'); + $m->setLocale('fr'); + $m->setTitle('V Pour Vendetta'); + + $m->setLocale('en'); + $this->assertEquals('V For Vendetta', $m->getTitle()); + $m->setLocale('fr'); + $this->assertEquals('V Pour Vendetta', $m->getTitle()); + + $t = new Toy(); + $t->setMovie($m); + $t->save(); + + $count = MovieQuery::create()->count(); + $this->assertEquals(1, $count, '1 movie'); + $count = ToyQuery::create()->count(); + $this->assertEquals(1, $count, '1 toy'); + $count = MovieI18nQuery::create()->count(); + $this->assertEquals(2, $count, '2 i18n movies'); + $count = ToyI18nQuery::create()->count(); + $this->assertEquals(0, $count, '0 i18n toys'); + } + + public function testI18nWithRelations2() + { + MovieQuery::create()->deleteAll(); + $count = MovieQuery::create()->count(); + $this->assertEquals(0, $count, 'No movie before the test'); + ToyQuery::create()->deleteAll(); + $count = ToyQuery::create()->count(); + $this->assertEquals(0, $count, 'No toy before the test'); + ToyI18nQuery::create()->deleteAll(); + $count = ToyI18nQuery::create()->count(); + $this->assertEquals(0, $count, 'No i18n toys before the test'); + MovieI18nQuery::create()->deleteAll(); + $count = MovieI18nQuery::create()->count(); + $this->assertEquals(0, $count, 'No i18n movies before the test'); + + $t = new Toy(); + $t->setLocale('en'); + $t->setName('My Name'); + $t->setLocale('fr'); + $t->setName('Mon Nom'); + + $t->setLocale('en'); + $this->assertEquals('My Name', $t->getName()); + $t->setLocale('fr'); + $this->assertEquals('Mon Nom', $t->getName()); + + $m = new Movie(); + $m->addToy($t); + $m->save(); + + $count = MovieQuery::create()->count(); + $this->assertEquals(1, $count, '1 movie'); + $count = ToyQuery::create()->count(); + $this->assertEquals(1, $count, '1 toy'); + $count = ToyI18nQuery::create()->count(); + $this->assertEquals(2, $count, '2 i18n toys'); + $count = MovieI18nQuery::create()->count(); + $this->assertEquals(0, $count, '0 i18n movies'); + } + + public function testUseLocalColumnParameter() + { + $o = new I18nBehaviorTestLocalColumn(); + $translation1 = new I18nBehaviorTestLocalColumnI18n(); + $translation1->setMyLang('en_US'); + $o->addI18nBehaviorTestLocalColumnI18n($translation1); + $translation2 = new I18nBehaviorTestLocalColumnI18n(); + $translation2->setMyLang('fr_FR'); + $o->addI18nBehaviorTestLocalColumnI18n($translation2); + $o->save(); + $this->assertEquals($translation1, $o->getTranslation('en_US')); + $this->assertEquals($translation2, $o->getTranslation('fr_FR')); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/i18n/I18nBehaviorPeerBuilderModifierTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/i18n/I18nBehaviorPeerBuilderModifierTest.php new file mode 100644 index 000000000..d1dc7af61 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/i18n/I18nBehaviorPeerBuilderModifierTest.php @@ -0,0 +1,65 @@ + + + + +
+ + + + + +
+ +EOF; + PropelQuickBuilder::buildSchema($schema); + $this->assertEquals('en_US', I18nBehaviorTest01Peer::DEFAULT_LOCALE); + $this->assertEquals('fr_FR', I18nBehaviorTest02Peer::DEFAULT_LOCALE); + } + + public function testFieldKeys() + { + $schema = << + + + + + + + + +
+ +EOF; + PropelQuickBuilder::buildSchema($schema); + $this->assertEquals(array(0, 1, 2), I18nBehaviorTest03Peer::getFieldNames(BasePeer::TYPE_NUM)); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/i18n/I18nBehaviorQueryBuilderModifierTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/i18n/I18nBehaviorQueryBuilderModifierTest.php new file mode 100644 index 000000000..c471b39d9 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/i18n/I18nBehaviorQueryBuilderModifierTest.php @@ -0,0 +1,273 @@ + + + + + + + + +
+ + + + + + + + + + + + +
+ +EOF; + //PropelQuickBuilder::debugClassesForTable($schema, 'i18n_behavior_test_11'); + PropelQuickBuilder::buildSchema($schema); + } + } + + public function testJoinI18nUsesDefaultLocaleInJoinCondition() + { + $q = I18nBehaviorTest11Query::create() + ->joinI18n(); + $params = array(); + $sql = BasePeer::createSelectSQL($q, $params); + $expectedSQL = 'SELECT FROM i18n_behavior_test_11 LEFT JOIN i18n_behavior_test_11_i18n ON (i18n_behavior_test_11.id=i18n_behavior_test_11_i18n.id AND i18n_behavior_test_11_i18n.locale = :p1)'; + $this->assertEquals($expectedSQL, $sql); + $this->assertEquals('en_US', $params[0]['value']); + } + + public function testJoinI18nUsesLocaleInJoinCondition() + { + $q = I18nBehaviorTest11Query::create() + ->joinI18n('fr_FR'); + $params = array(); + $sql = BasePeer::createSelectSQL($q, $params); + $expectedSQL = 'SELECT FROM i18n_behavior_test_11 LEFT JOIN i18n_behavior_test_11_i18n ON (i18n_behavior_test_11.id=i18n_behavior_test_11_i18n.id AND i18n_behavior_test_11_i18n.locale = :p1)'; + $this->assertEquals($expectedSQL, $sql); + $this->assertEquals('fr_FR', $params[0]['value']); + } + + public function testJoinI18nAcceptsARelationAlias() + { + $q = I18nBehaviorTest11Query::create() + ->joinI18n('en_US', 'I18n'); + $params = array(); + $sql = BasePeer::createSelectSQL($q, $params); + $expectedSQL = 'SELECT FROM i18n_behavior_test_11 LEFT JOIN i18n_behavior_test_11_i18n I18n ON (i18n_behavior_test_11.id=I18n.id AND I18n.locale = :p1)'; + $this->assertEquals($expectedSQL, $sql); + $this->assertEquals('en_US', $params[0]['value']); + } + + public function testJoinI18nAcceptsAJoinType() + { + $q = I18nBehaviorTest11Query::create() + ->joinI18n('en_US', null, Criteria::INNER_JOIN); + $params = array(); + $sql = BasePeer::createSelectSQL($q, $params); + $expectedSQL = 'SELECT FROM i18n_behavior_test_11 INNER JOIN i18n_behavior_test_11_i18n ON (i18n_behavior_test_11.id=i18n_behavior_test_11_i18n.id AND i18n_behavior_test_11_i18n.locale = :p1)'; + $this->assertEquals($expectedSQL, $sql); + $this->assertEquals('en_US', $params[0]['value']); + } + + public function testJoinI18nCreatesACorrectQuery() + { + $con = Propel::getConnection(I18nBehaviorTest11Peer::DATABASE_NAME); + $con->useDebug(true); + I18nBehaviorTest11Query::create() + ->joinI18n('fr_FR') + ->find($con); + $expected = "SELECT i18n_behavior_test_11.id, i18n_behavior_test_11.foo FROM i18n_behavior_test_11 LEFT JOIN i18n_behavior_test_11_i18n ON (i18n_behavior_test_11.id=i18n_behavior_test_11_i18n.id AND i18n_behavior_test_11_i18n.locale = 'fr_FR')"; + $this->assertEquals($expected, $con->getLastExecutedQuery()); + $con->useDebug(false); + } + + public function testUseI18nQueryAddsTheProperJoin() + { + $q = I18nBehaviorTest11Query::create() + ->useI18nQuery('fr_FR') + ->filterByBar('bar') + ->endUse(); + $params = array(); + $sql = BasePeer::createSelectSQL($q, $params); + $expectedSQL = 'SELECT FROM i18n_behavior_test_11 LEFT JOIN i18n_behavior_test_11_i18n ON (i18n_behavior_test_11.id=i18n_behavior_test_11_i18n.id AND i18n_behavior_test_11_i18n.locale = :p1) WHERE i18n_behavior_test_11_i18n.bar=:p2'; + $this->assertEquals($expectedSQL, $sql); + $this->assertEquals('fr_FR', $params[0]['value']); + $this->assertEquals('bar', $params[1]['value']); + } + + public function testUseI18nQueryAcceptsARelationAlias() + { + $q = I18nBehaviorTest11Query::create() + ->useI18nQuery('fr_FR', 'I18n') + ->filterByBar('bar') + ->endUse(); + $params = array(); + $sql = BasePeer::createSelectSQL($q, $params); + $expectedSQL = 'SELECT FROM i18n_behavior_test_11 LEFT JOIN i18n_behavior_test_11_i18n I18n ON (i18n_behavior_test_11.id=I18n.id AND I18n.locale = :p1) WHERE I18n.bar=:p2'; + $this->assertEquals($expectedSQL, $sql); + $this->assertEquals('fr_FR', $params[0]['value']); + $this->assertEquals('bar', $params[1]['value']); + } + + public function testUseI18nQueryCreatesACorrectQuery() + { + $con = Propel::getConnection(I18nBehaviorTest11Peer::DATABASE_NAME); + $con->useDebug(true); + I18nBehaviorTest11Query::create() + ->useI18nQuery('fr_FR') + ->filterByBar('bar') + ->endUse() + ->find($con); + $expected = "SELECT i18n_behavior_test_11.id, i18n_behavior_test_11.foo FROM i18n_behavior_test_11 LEFT JOIN i18n_behavior_test_11_i18n ON (i18n_behavior_test_11.id=i18n_behavior_test_11_i18n.id AND i18n_behavior_test_11_i18n.locale = 'fr_FR') WHERE i18n_behavior_test_11_i18n.bar='bar'"; + $this->assertEquals($expected, $con->getLastExecutedQuery()); + $con->useDebug(false); + } + + public function testJoinWithI18nAddsTheI18nColumns() + { + $q = I18nBehaviorTest11Query::create() + ->joinWithI18n(); + $params = array(); + $sql = BasePeer::createSelectSQL($q, $params); + $expectedSQL = 'SELECT i18n_behavior_test_11.id, i18n_behavior_test_11.foo, i18n_behavior_test_11_i18n.id, i18n_behavior_test_11_i18n.locale, i18n_behavior_test_11_i18n.bar FROM i18n_behavior_test_11 LEFT JOIN i18n_behavior_test_11_i18n ON (i18n_behavior_test_11.id=i18n_behavior_test_11_i18n.id AND i18n_behavior_test_11_i18n.locale = :p1)'; + $this->assertEquals($expectedSQL, $sql); + $this->assertEquals('en_US', $params[0]['value']); + } + + public function testJoinWithI18nDoesNotPruneResultsWithoutTranslation() + { + I18nBehaviorTest11Query::create()->deleteAll(); + I18nBehaviorTest11I18nQuery::create()->deleteAll(); + $o = new I18nBehaviorTest11(); + $o->setFoo(123); + $o->save(); + $res = I18nBehaviorTest11Query::create() + ->joinWithI18n('en_US') + ->findOne(); + $this->assertEquals($o, $res); + } + + public function testJoinWithI18nPrunesResultsWithoutTranslationWhenUsingInnerJoin() + { + I18nBehaviorTest11Query::create()->deleteAll(); + I18nBehaviorTest11I18nQuery::create()->deleteAll(); + $o = new I18nBehaviorTest11(); + $o->setFoo(123); + $o->save(); + $res = I18nBehaviorTest11Query::create() + ->joinWithI18n('en_US', Criteria::INNER_JOIN) + ->findOne(); + $this->assertNull($res); + } + + public function testJoinWithI18nHydratesRelatedObject() + { + $con = Propel::getConnection(I18nBehaviorTest11Peer::DATABASE_NAME); + $con->useDebug(true); + I18nBehaviorTest11Query::create()->deleteAll(); + I18nBehaviorTest11I18nQuery::create()->deleteAll(); + $o = new I18nBehaviorTest11(); + $o->setFoo(123); + $o->setLocale('en_US'); + $o->setBar('hello'); + $o->setLocale('fr_FR'); + $o->setBar('bonjour'); + $o->save(); + I18nBehaviorTest11Peer::clearInstancePool(); + I18nBehaviorTest11I18nPeer::clearInstancePool(); + $o = I18nBehaviorTest11Query::create() + ->joinWithI18n('en_US') + ->findOne($con); + $count = $con->getQueryCount(); + $translation = $o->getTranslation('en_US', $con); + $this->assertEquals($count, $con->getQueryCount()); + $this->assertEquals('hello', $translation->getBar()); + } + + public function testJoinWithI18nSetsTheLocaleOnResults() + { + I18nBehaviorTest11Query::create()->deleteAll(); + I18nBehaviorTest11I18nQuery::create()->deleteAll(); + $o = new I18nBehaviorTest11(); + $o->setFoo(123); + $o->setLocale('en_US'); + $o->setBar('hello'); + $o->setLocale('fr_FR'); + $o->setBar('bonjour'); + $o->save(); + $o1 = I18nBehaviorTest11Query::create() + ->joinWithI18n('en_US') + ->findOne(); + $this->assertEquals('en_US', $o1->getLocale()); + $o2 = I18nBehaviorTest11Query::create() + ->joinWithI18n('fr_FR') + ->findOne(); + $this->assertEquals('fr_FR', $o2->getLocale()); + } + + public function testJoinWithI18nAndLimitDoesNotThrowException() + { + $res = I18nBehaviorTest11Query::create() + ->joinWithI18n('en_US') + ->limit(2) + ->find(); + $this->assertInstanceOf('PropelObjectCollection', $res); + } + + // This is not a desired behavior, but there is no way to overcome it + // because if we don't issue a database query when the collection exists + // then there is no way to avoid duplicates when adding translations. + // use case: + // $o = new Object(); + // $t1 = new Translation(); + // $o->setTranslation($t2, 'en_US'); // this is what happens during joined hydration + // now the translation collection exists + // $t2 = $o->getTranslation('fr_FR'); // we MUST issue a query here + public function testJoinWithI18nDoesNotExecuteAdditionalQueryWhenNoTranslationIsFound() + { + $this->markTestSkipped(); + $con = Propel::getConnection(I18nBehaviorTest11Peer::DATABASE_NAME); + $con->useDebug(true); + I18nBehaviorTest11Query::create()->deleteAll(); + I18nBehaviorTest11I18nQuery::create()->deleteAll(); + $o = new I18nBehaviorTest11(); + $o->save(); + $o = I18nBehaviorTest11Query::create() + ->joinWithI18n('en_US') + ->findOne($con); + $count = $con->getQueryCount(); + $translation = $o->getTranslation('en_US', $con); + $this->assertEquals($count, $con->getQueryCount()); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/i18n/I18nBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/i18n/I18nBehaviorTest.php new file mode 100644 index 000000000..eb4fd190f --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/i18n/I18nBehaviorTest.php @@ -0,0 +1,428 @@ + + + + + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + public function testModifyDatabaseDoesNotOverrideTableLocale() + { + $schema = << + + + + + + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + public function schemaDataProvider() + { + $schema1 = << + + + + + + + +
+ +EOF; + $schema2 = << + + + + +
+ + + + + + + +
+ +EOF; + + return array(array($schema1), array($schema2)); + } + + /** + * @dataProvider schemaDataProvider + */ + public function testModifyTableAddsI18nTable($schema) + { + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + /** + * @dataProvider schemaDataProvider + */ + public function testModifyTableRelatesI18nTableToMainTable($schema) + { + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + /** + * @dataProvider schemaDataProvider + */ + public function testModifyTableAddsLocaleColumnToI18n($schema) + { + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + /** + * @dataProvider schemaDataProvider + */ + public function testModifyTableMovesI18nColumns($schema) + { + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + /** + * @dataProvider schemaDataProvider + */ + public function testModifyTableDoesNotMoveNonI18nColumns($schema) + { + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + public function testModifyTableMovesValidatorsOnI18nColumns() + { + $schema = << + + + + + + + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $table = $builder->getDatabase()->getTable('i18n_behavior_test_0'); + $this->assertEquals(array(), $table->getValidators()); + $i18nTable = $builder->getDatabase()->getTable('i18n_behavior_test_0_i18n'); + $validators = $i18nTable->getValidators(); + $this->assertEquals(1, count($validators)); + $this->assertEquals('title', $validators[0]->getColumnName()); + } + + public function testModiFyTableDoesNotMoveValidatorsOnNonI18nColumns() + { + $schema = << + + + + + + + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $table = $builder->getDatabase()->getTable('i18n_behavior_test_0'); + $this->assertEquals(1, count($table->getValidators())); + $i18nTable = $builder->getDatabase()->getTable('i18n_behavior_test_0_i18n'); + $this->assertEquals(array(), $i18nTable->getValidators()); + } + + public function testModifyTableUsesCustomI18nTableName() + { + $schema = << + + + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + public function testModiFyTableUsesCustomLocaleColumnName() + { + $schema = << + + + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + public function testModiFyTableUsesCustomLocaleDefault() + { + $schema = << + + + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + /** + * tests if i18n_pk_name options sets the right pk name in i18n table + */ + public function testModifyTableUseCustomPkName() + { + $schema = << + + + + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + + // checks id in base table + $table = $builder->getDatabase()->getTable('i18n_behavior_test_0'); + $this->assertTrue($table->hasColumn('id')); + + // checks id in i18n table + $i18nTable = $builder->getDatabase()->getTable('i18n_behavior_test_0_i18n'); + $this->assertTrue($i18nTable->hasColumn('custom_id')); + + // checks foreign key + $fkList = $i18nTable->getColumnForeignKeys('custom_id'); + $this->assertEquals(count($fkList), 1); + $fk = array_pop($fkList); + $this->assertEquals($fk->getForeignTableName(), 'i18n_behavior_test_0'); + $this->assertEquals($fk->getForeignColumnNames(), '[id]'); + + $expected = <<assertContains($expected, $builder->getSQL()); + } + + + public function testTableWithPrefix() + { + $schema = << + + + + + + + + +
+ +EOF; + + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + + $this->assertTrue($builder->getDatabase()->hasTable('plop_group')); + $this->assertFalse($builder->getDatabase()->hasTable('plop_plop_group_i18n')); + $this->assertTrue($builder->getDatabase()->hasTable('plop_group_i18n')); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorObjectBuilderModifierTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorObjectBuilderModifierTest.php index 2abb542d1..cf36b755c 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorObjectBuilderModifierTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorObjectBuilderModifierTest.php @@ -1,7 +1,7 @@ setTreeLeft('123'); - $this->assertEquals($t->getLeftValue(), '123', 'nested_set adds a getLeftValue() method'); - $t->setTreeRight('456'); - $this->assertEquals($t->getRightValue(), '456', 'nested_set adds a getRightValue() method'); - $t->setLevel('789'); - $this->assertEquals($t->getLevel(), '789', 'nested_set adds a getLevel() method'); - } - - public function testParameters() - { - $t = new Table10(); - $t->setMyLeftColumn('123'); - $this->assertEquals($t->getLeftValue(), '123', 'nested_set adds a getLeftValue() method'); - $t->setMyRightColumn('456'); - $this->assertEquals($t->getRightValue(), '456', 'nested_set adds a getRightValue() method'); - $t->setMyLevelColumn('789'); - $this->assertEquals($t->getLevel(), '789', 'nested_set adds a getLevel() method'); - $t->setMyScopeColumn('012'); - $this->assertEquals($t->getScopeValue(), '012', 'nested_set adds a getScopeValue() method'); - } - - public function testObjectAttributes() - { - $expectedAttributes = array('nestedSetQueries'); - foreach ($expectedAttributes as $attribute) { - $this->assertClassHasAttribute($attribute, 'Table9'); - } - } - - public function testSaveOutOfTree() - { - Table9Peer::doDeleteAll(); - $t1 = new Table9(); - $t1->setTitle('t1'); - try { - $t1->save(); - $this->assertTrue(true, 'A node can be saved without valid tree information'); - } catch (Exception $e) { - $this->fail('A node can be saved without valid tree information'); - } - try { - $t1->makeRoot(); - $this->assertTrue(true, 'A saved node can be turned into root'); - } catch (Exception $e) { - $this->fail('A saved node can be turned into root'); - } - $t1->save(); - $t2 = new Table9(); - $t2->setTitle('t1'); - $t2->save(); - try { - $t2->insertAsFirstChildOf($t1); - $this->assertTrue(true, 'A saved node can be inserted into the tree'); - } catch (Exception $e) { - $this->fail('A saved node can be inserted into the tree'); - } - try { - $t2->save(); - $this->assertTrue(true, 'A saved node can be inserted into the tree'); - } catch (Exception $e) { - $this->fail('A saved node can be inserted into the tree'); - } - } - - public function testPreUpdate() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - $t3->setLeftValue(null); - try { - $t3->save(); - $this->fail('Trying to save a node incorrectly updated throws an exception'); - } catch (Exception $e) { - $this->assertTrue(true, 'Trying to save a node incorrectly updated throws an exception'); - } - } - - public function testDelete() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $t5->delete(); - $this->assertEquals(13, $t3->getRightValue(), 'delete() does not update existing nodes (because delete() clears the instance cache)'); - $expected = array( - 't1' => array(1, 8, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 7, 1), - 't4' => array(5, 6, 2), - ); - $this->assertEquals($expected, $this->dumpTree(), 'delete() deletes all descendants and shifts the entire subtree correctly'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - try { - $t1->delete(); - $this->fail('delete() throws an exception when called on a root node'); - } catch (PropelException $e) { - $this->assertTrue(true, 'delete() throws an exception when called on a root node'); - } - $this->assertNotEquals(array(), Table9Peer::doSelect(new Criteria()), 'delete() called on the root node does not delete the whole tree'); - } - - public function testMakeRoot() - { - $t = new Table9(); - $t->makeRoot(); - $this->assertEquals($t->getLeftValue(), 1, 'makeRoot() initializes left_column to 1'); - $this->assertEquals($t->getRightValue(), 2, 'makeRoot() initializes right_column to 2'); - $this->assertEquals($t->getLevel(), 0, 'makeRoot() initializes right_column to 0'); - $t = new Table9(); - $t->setLeftValue(12); - try { - $t->makeRoot(); - $this->fail('makeRoot() throws an exception when called on an object with a left_column value'); - } catch (PropelException $e) { - $this->assertTrue(true, 'makeRoot() throws an exception when called on an object with a left_column value'); - } - } + public function testDefault() + { + $t = new Table9(); + $t->setTreeLeft('123'); + $this->assertEquals($t->getLeftValue(), '123', 'nested_set adds a getLeftValue() method'); + $t->setTreeRight('456'); + $this->assertEquals($t->getRightValue(), '456', 'nested_set adds a getRightValue() method'); + $t->setLevel('789'); + $this->assertEquals($t->getLevel(), '789', 'nested_set adds a getLevel() method'); + } - public function testIsInTree() - { - $t1 = new Table9(); - $this->assertFalse($t1->isInTree(), 'inInTree() returns false for nodes with no left and right value'); - $t1->save(); - $this->assertFalse($t1->isInTree(), 'inInTree() returns false for saved nodes with no left and right value'); - $t1->setLeftValue(1)->setRightValue(0); - $this->assertFalse($t1->isInTree(), 'inInTree() returns false for nodes with zero left value'); - $t1->setLeftValue(0)->setRightValue(1); - $this->assertFalse($t1->isInTree(), 'inInTree() returns false for nodes with zero right value'); - $t1->setLeftValue(1)->setRightValue(1); - $this->assertFalse($t1->isInTree(), 'inInTree() returns false for nodes with equal left and right value'); - $t1->setLeftValue(1)->setRightValue(2); - $this->assertTrue($t1->isInTree(), 'inInTree() returns true for nodes with left < right value'); - $t1->setLeftValue(2)->setRightValue(1); - $this->assertFalse($t1->isInTree(), 'inInTree() returns false for nodes with left > right value'); - } + public function testParameters() + { + $t = new Table10(); + $t->setMyLeftColumn('123'); + $this->assertEquals($t->getLeftValue(), '123', 'nested_set adds a getLeftValue() method'); + $t->setMyRightColumn('456'); + $this->assertEquals($t->getRightValue(), '456', 'nested_set adds a getRightValue() method'); + $t->setMyLevelColumn('789'); + $this->assertEquals($t->getLevel(), '789', 'nested_set adds a getLevel() method'); + $t->setMyScopeColumn('012'); + $this->assertEquals($t->getScopeValue(), '012', 'nested_set adds a getScopeValue() method'); + } - public function testIsRoot() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $this->assertTrue($t1->isRoot(), 'root is seen as root'); - $this->assertFalse($t2->isRoot(), 'leaf is not seen as root'); - $this->assertFalse($t3->isRoot(), 'node is not seen as root'); - } - - public function testIsLeaf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $this->assertFalse($t1->isLeaf(), 'root is not seen as leaf'); - $this->assertTrue($t2->isLeaf(), 'leaf is seen as leaf'); - $this->assertFalse($t3->isLeaf(), 'node is not seen as leaf'); - } + public function testObjectAttributes() + { + $expectedAttributes = array('nestedSetQueries'); + foreach ($expectedAttributes as $attribute) { + $this->assertClassHasAttribute($attribute, 'Table9'); + } + } - public function testIsDescendantOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $this->assertFalse($t1->isDescendantOf($t1), 'root is not seen as a descendant of root'); - $this->assertTrue($t2->isDescendantOf($t1), 'direct child is seen as a descendant of root'); - $this->assertFalse($t1->isDescendantOf($t2), 'root is not seen as a descendant of leaf'); - $this->assertTrue($t5->isDescendantOf($t1), 'grandchild is seen as a descendant of root'); - $this->assertTrue($t5->isDescendantOf($t3), 'direct child is seen as a descendant of node'); - $this->assertFalse($t3->isDescendantOf($t5), 'node is not seen as a descendant of its parent'); - } - - public function testIsAncestorOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $this->assertFalse($t1->isAncestorOf($t1), 'root is not seen as an ancestor of root'); - $this->assertTrue($t1->isAncestorOf($t2), 'root is seen as an ancestor of direct child'); - $this->assertFalse($t2->isAncestorOf($t1), 'direct child is not seen as an ancestor of root'); - $this->assertTrue($t1->isAncestorOf($t5), 'root is seen as an ancestor of grandchild'); - $this->assertTrue($t3->isAncestorOf($t5), 'parent is seen as an ancestor of node'); - $this->assertFalse($t5->isAncestorOf($t3), 'child is not seen as an ancestor of its parent'); - } - - public function testHasParent() - { - Table9Peer::doDeleteAll(); - $t0 = new Table9(); - $t1 = new Table9(); - $t1->setTitle('t1')->setLeftValue(1)->setRightValue(6)->setLevel(0)->save(); - $t2 = new Table9(); - $t2->setTitle('t2')->setLeftValue(2)->setRightValue(5)->setLevel(1)->save(); - $t3 = new Table9(); - $t3->setTitle('t3')->setLeftValue(3)->setRightValue(4)->setLevel(2)->save(); - $this->assertFalse($t0->hasParent(), 'empty node has no parent'); - $this->assertFalse($t1->hasParent(), 'root node has no parent'); - $this->assertTrue($t2->hasParent(), 'not root node has a parent'); - $this->assertTrue($t3->hasParent(), 'leaf node has a parent'); - } - - public function testGetParent() - { - Table9Peer::doDeleteAll(); - $t0 = new Table9(); - $this->assertFalse($t0->hasParent(), 'empty node has no parent'); - $t1 = new Table9(); - $t1->setTitle('t1')->setLeftValue(1)->setRightValue(8)->setLevel(0)->save(); - $t2 = new Table9(); - $t2->setTitle('t2')->setLeftValue(2)->setRightValue(7)->setLevel(1)->save(); - $t3 = new Table9(); - $t3->setTitle('t3')->setLeftValue(3)->setRightValue(4)->setLevel(2)->save(); - $t4 = new Table9(); - $t4->setTitle('t4')->setLeftValue(5)->setRightValue(6)->setLevel(2)->save(); - $this->assertNull($t1->getParent($this->con), 'getParent() return null for root nodes'); - $this->assertEquals($t2->getParent($this->con), $t1, 'getParent() correctly retrieves parent for nodes'); - $this->assertEquals($t3->getParent($this->con), $t2, 'getParent() correctly retrieves parent for leafs'); - $this->assertEquals($t4->getParent($this->con), $t2, 'getParent() retrieves the same parent for two siblings'); - } + public function testSaveOutOfTree() + { + Table9Peer::doDeleteAll(); + $t1 = new Table9(); + $t1->setTitle('t1'); + try { + $t1->save(); + $this->assertTrue(true, 'A node can be saved without valid tree information'); + } catch (Exception $e) { + $this->fail('A node can be saved without valid tree information'); + } + try { + $t1->makeRoot(); + $this->assertTrue(true, 'A saved node can be turned into root'); + } catch (Exception $e) { + $this->fail('A saved node can be turned into root'); + } + $t1->save(); + $t2 = new Table9(); + $t2->setTitle('t1'); + $t2->save(); + try { + $t2->insertAsFirstChildOf($t1); + $this->assertTrue(true, 'A saved node can be inserted into the tree'); + } catch (Exception $e) { + $this->fail('A saved node can be inserted into the tree'); + } + try { + $t2->save(); + $this->assertTrue(true, 'A saved node can be inserted into the tree'); + } catch (Exception $e) { + $this->fail('A saved node can be inserted into the tree'); + } + } - public function testGetParentCache() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $con = Propel::getConnection(); - $count = $con->getQueryCount(); - $parent = $t5->getParent($con); - $parent = $t5->getParent($con); - $this->assertEquals($count + 1, $con->getQueryCount(), 'getParent() only issues a query once'); - $this->assertEquals('t3', $parent->getTitle(), 'getParent() returns the parent Node'); - } + /** + * @expectedException PropelException + */ + public function testSaveRootInTreeWithExistingRoot() + { + Table9Peer::doDeleteAll(); + $t1 = new Table9(); + $t1->makeRoot(); + $t1->save(); + $t2 = new Table9(); + $t2->makeRoot(); + $t2->save(); + } - public function testHasPrevSibling() - { - Table9Peer::doDeleteAll(); - $t0 = new Table9(); - $t1 = new Table9(); - $t1->setTitle('t1')->setLeftValue(1)->setRightValue(6)->save(); - $t2 = new Table9(); - $t2->setTitle('t2')->setLeftValue(2)->setRightValue(3)->save(); - $t3 = new Table9(); - $t3->setTitle('t3')->setLeftValue(4)->setRightValue(5)->save(); - $this->assertFalse($t0->hasPrevSibling(), 'empty node has no previous sibling'); - $this->assertFalse($t1->hasPrevSibling(), 'root node has no previous sibling'); - $this->assertFalse($t2->hasPrevSibling(), 'first sibling has no previous sibling'); - $this->assertTrue($t3->hasPrevSibling(), 'not first sibling has a previous siblingt'); - } - - public function testGetPrevSibling() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $this->assertNull($t1->getPrevSibling($this->con), 'getPrevSibling() returns null for root nodes'); - $this->assertNull($t2->getPrevSibling($this->con), 'getPrevSibling() returns null for first siblings'); - $this->assertEquals($t3->getPrevSibling($this->con), $t2, 'getPrevSibling() correctly retrieves prev sibling'); - $this->assertNull($t6->getPrevSibling($this->con), 'getPrevSibling() returns null for first siblings'); - $this->assertEquals($t7->getPrevSibling($this->con), $t6, 'getPrevSibling() correctly retrieves prev sibling'); - } + public function testPreUpdate() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + $t3->setLeftValue(null); + try { + $t3->save(); + $this->fail('Trying to save a node incorrectly updated throws an exception'); + } catch (Exception $e) { + $this->assertTrue(true, 'Trying to save a node incorrectly updated throws an exception'); + } + } - public function testHasNextSibling() - { - Table9Peer::doDeleteAll(); - $t0 = new Table9(); - $t1 = new Table9(); - $t1->setTitle('t1')->setLeftValue(1)->setRightValue(6)->save(); - $t2 = new Table9(); - $t2->setTitle('t2')->setLeftValue(2)->setRightValue(3)->save(); - $t3 = new Table9(); - $t3->setTitle('t3')->setLeftValue(4)->setRightValue(5)->save(); - $this->assertFalse($t0->hasNextSibling(), 'empty node has no next sibling'); - $this->assertFalse($t1->hasNextSibling(), 'root node has no next sibling'); - $this->assertTrue($t2->hasNextSibling(), 'not last sibling has a next sibling'); - $this->assertFalse($t3->hasNextSibling(), 'last sibling has no next sibling'); - } - - public function testGetNextSibling() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $this->assertNull($t1->getNextSibling($this->con), 'getNextSibling() returns null for root nodes'); - $this->assertEquals($t2->getNextSibling($this->con), $t3, 'getNextSibling() correctly retrieves next sibling'); - $this->assertNull($t3->getNextSibling($this->con), 'getNextSibling() returns null for last siblings'); - $this->assertEquals($t6->getNextSibling($this->con), $t7, 'getNextSibling() correctly retrieves next sibling'); - $this->assertNull($t7->getNextSibling($this->con), 'getNextSibling() returns null for last siblings'); - } - - public function testAddNestedSetChildren() - { - $t0 = new Table9(); - $t1 = new Table9(); - $t2 = new Table9(); - $t0->addNestedSetChild($t1); - $t0->addNestedSetChild($t2); - $this->assertEquals(2, $t0->countChildren(), 'addNestedSetChild() adds the object to the internal children collection'); - $this->assertEquals($t0, $t1->getParent(), 'addNestedSetChild() sets the object as th parent of the parameter'); - $this->assertEquals($t0, $t2->getParent(), 'addNestedSetChild() sets the object as th parent of the parameter'); - } - - public function testHasChildren() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $this->assertTrue($t1->hasChildren(), 'root has children'); - $this->assertFalse($t2->hasChildren(), 'leaf has no children'); - $this->assertTrue($t3->hasChildren(), 'node has children'); - } + public function testDelete() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $t5->delete(); + $this->assertEquals(13, $t3->getRightValue(), 'delete() does not update existing nodes (because delete() clears the instance cache)'); + $expected = array( + 't1' => array(1, 8, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 7, 1), + 't4' => array(5, 6, 2), + ); + $this->assertEquals($expected, $this->dumpTree(), 'delete() deletes all descendants and shifts the entire subtree correctly'); + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + try { + $t1->delete(); + $this->fail('delete() throws an exception when called on a root node'); + } catch (PropelException $e) { + $this->assertTrue(true, 'delete() throws an exception when called on a root node'); + } + $this->assertNotEquals(array(), Table9Peer::doSelect(new Criteria()), 'delete() called on the root node does not delete the whole tree'); + } - public function testGetChildren() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $this->assertTrue($t2->getChildren() instanceof PropelObjectCollection, 'getChildren() returns a collection'); - $this->assertEquals(0, count($t2->getChildren()), 'getChildren() returns an empty collection for leafs'); - $children = $t3->getChildren(); - $expected = array( - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - ); - $this->assertEquals($expected, $this->dumpNodes($children, true), 'getChildren() returns a collection of children'); - $c = new Criteria(); - $c->add(Table9Peer::TITLE, 't5'); - $children = $t3->getChildren($c); - $expected = array( - 't5' => array(7, 12, 2), - ); - $this->assertEquals($expected, $this->dumpNodes($children, true), 'getChildren() accepts a criteria as parameter'); - } + public function testDeleteNotInTree() + { + $t1 = new Table9(); + $t1->save(); + $t1->delete(); + $this->assertTrue($t1->isDeleted()); + } - public function testGetChildrenCache() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - $con = Propel::getConnection(); - $count = $con->getQueryCount(); - $children = $t3->getChildren(null, $con); - $children = $t3->getChildren(null, $con); - $this->assertEquals($count + 1, $con->getQueryCount(), 'getChildren() only issues a query once'); - $expected = array( - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - ); - $this->assertEquals($expected, $this->dumpNodes($children, true), 'getChildren() returns a collection of children'); - // when using criteria, cache is not used - $c = new Criteria(); - $c->add(Table9Peer::TITLE, 't5'); - $children = $t3->getChildren($c, $con); - $this->assertEquals($count + 2, $con->getQueryCount(), 'getChildren() issues a new query when âssed a non-null Criteria'); - $expected = array( - 't5' => array(7, 12, 2), - ); - $this->assertEquals($expected, $this->dumpNodes($children, true), 'getChildren() accepts a criteria as parameter'); - // but not erased either - $children = $t3->getChildren(null, $con); - $this->assertEquals($count + 2, $con->getQueryCount(), 'getChildren() keeps its internal cache after being called with a Criteria'); - $expected = array( - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - ); - $this->assertEquals($expected, $this->dumpNodes($children, true), 'getChildren() returns a collection of children'); - } - - public function testCountChildren() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $this->assertEquals(0, $t2->countChildren(), 'countChildren() returns 0 for leafs'); - $this->assertEquals(2, $t3->countChildren(), 'countChildren() returns the number of children'); - $c = new Criteria(); - $c->add(Table9Peer::TITLE, 't5'); - $this->assertEquals(1, $t3->countChildren($c), 'countChildren() accepts a criteria as parameter'); - } + public function testMakeRoot() + { + $t = new Table9(); + $t->makeRoot(); + $this->assertEquals($t->getLeftValue(), 1, 'makeRoot() initializes left_column to 1'); + $this->assertEquals($t->getRightValue(), 2, 'makeRoot() initializes right_column to 2'); + $this->assertEquals($t->getLevel(), 0, 'makeRoot() initializes right_column to 0'); + $t = new Table9(); + $t->setLeftValue(12); + try { + $t->makeRoot(); + $this->fail('makeRoot() throws an exception when called on an object with a left_column value'); + } catch (PropelException $e) { + $this->assertTrue(true, 'makeRoot() throws an exception when called on an object with a left_column value'); + } + } - public function testCountChildrenCache() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $con = Propel::getConnection(); - $count = $con->getQueryCount(); - $children = $t3->getChildren(null, $con); - $nbChildren = $t3->countChildren(null, $con); - $this->assertEquals($count + 1, $con->getQueryCount(), 'countChildren() uses the internal collection when passed no Criteria'); - $nbChildren = $t3->countChildren(new Criteria(), $con); - $this->assertEquals($count + 2, $con->getQueryCount(), 'countChildren() issues a new query when passed a Criteria'); - } - - public function testGetFirstChild() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - $t5->moveToNextSiblingOf($t3); - /* Results in - t1 - | \ \ - t2 t3 t5 - | | \ - t4 t6 t7 - */ - $this->assertEquals($t2, $t1->getFirstChild(), 'getFirstChild() returns the first child'); - } + public function testIsInTree() + { + $t1 = new Table9(); + $this->assertFalse($t1->isInTree(), 'inInTree() returns false for nodes with no left and right value'); + $t1->save(); + $this->assertFalse($t1->isInTree(), 'inInTree() returns false for saved nodes with no left and right value'); + $t1->setLeftValue(1)->setRightValue(0); + $this->assertFalse($t1->isInTree(), 'inInTree() returns false for nodes with zero left value'); + $t1->setLeftValue(0)->setRightValue(1); + $this->assertFalse($t1->isInTree(), 'inInTree() returns false for nodes with zero right value'); + $t1->setLeftValue(1)->setRightValue(1); + $this->assertFalse($t1->isInTree(), 'inInTree() returns false for nodes with equal left and right value'); + $t1->setLeftValue(1)->setRightValue(2); + $this->assertTrue($t1->isInTree(), 'inInTree() returns true for nodes with left < right value'); + $t1->setLeftValue(2)->setRightValue(1); + $this->assertFalse($t1->isInTree(), 'inInTree() returns false for nodes with left > right value'); + } - public function testGetLastChild() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - $t5->moveToNextSiblingOf($t3); - /* Results in - t1 - | \ \ - t2 t3 t5 - | | \ - t4 t6 t7 - */ - $this->assertEquals($t5, $t1->getLastChild(), 'getLastChild() returns the last child'); - } - - public function testGetSiblings() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $this->assertEquals(array(), $t1->getSiblings(), 'getSiblings() returns an empty array for root'); - $descendants = $t5->getSiblings(); - $expected = array( - 't4' => array(5, 6, 2), - ); - $this->assertEquals($expected, $this->dumpNodes($descendants), 'getSiblings() returns an array of siblings'); - $descendants = $t5->getSiblings(true); - $expected = array( - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - ); - $this->assertEquals($expected, $this->dumpNodes($descendants), 'getSiblings(true) includes the current node'); - $t5->moveToNextSiblingOf($t3); - /* Results in - t1 - | \ \ - t2 t3 t5 - | | \ - t4 t6 t7 - */ - $this->assertEquals(0, count($t4->getSiblings()), 'getSiblings() returns an empty colleciton for lone children'); - $descendants = $t3->getSiblings(); - $expected = array( - 't2' => array(2, 3, 1), - 't5' => array(8, 13, 1), - ); - $this->assertEquals($expected, $this->dumpNodes($descendants), 'getSiblings() returns all siblings'); - } - - public function testGetDescendants() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $this->assertEquals(array(), $t2->getDescendants(), 'getDescendants() returns an empty array for leafs'); - $descendants = $t3->getDescendants(); - $expected = array( - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - 't6' => array(8, 9, 3), - 't7' => array(10, 11, 3), - ); - $this->assertEquals($expected, $this->dumpNodes($descendants), 'getDescendants() returns an array of descendants'); - $c = new Criteria(); - $c->add(Table9Peer::TITLE, 't5'); - $descendants = $t3->getDescendants($c); - $expected = array( - 't5' => array(7, 12, 2), - ); - $this->assertEquals($expected, $this->dumpNodes($descendants), 'getDescendants() accepts a criteria as parameter'); - } - - public function testCountDescendants() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $this->assertEquals(0, $t2->countDescendants(), 'countDescendants() returns 0 for leafs'); - $this->assertEquals(4, $t3->countDescendants(), 'countDescendants() returns the number of descendants'); - $c = new Criteria(); - $c->add(Table9Peer::TITLE, 't5'); - $this->assertEquals(1, $t3->countDescendants($c), 'countDescendants() accepts a criteria as parameter'); - } - - public function testGetBranch() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $this->assertEquals(array($t2), $t2->getBranch()->getArrayCopy(), 'getBranch() returns the current node for leafs'); - $descendants = $t3->getBranch(); - $expected = array( - 't3' => array(4, 13, 1), - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - 't6' => array(8, 9, 3), - 't7' => array(10, 11, 3), - ); - $this->assertEquals($expected, $this->dumpNodes($descendants), 'getBranch() returns an array of descendants, uncluding the current node'); - $c = new Criteria(); - $c->add(Table9Peer::TITLE, 't3', Criteria::NOT_EQUAL); - $descendants = $t3->getBranch($c); - unset($expected['t3']); - $this->assertEquals($expected, $this->dumpNodes($descendants), 'getBranch() accepts a criteria as first parameter'); - } - - public function testGetAncestors() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $this->assertEquals(array(), $t1->getAncestors(), 'getAncestors() returns an empty array for roots'); - $ancestors = $t5->getAncestors(); - $expected = array( - 't1' => array(1, 14, 0), - 't3' => array(4, 13, 1), - ); - $this->assertEquals($expected, $this->dumpNodes($ancestors), 'getAncestors() returns an array of ancestors'); - $c = new Criteria(); - $c->add(Table9Peer::TITLE, 't3'); - $ancestors = $t5->getAncestors($c); - $expected = array( - 't3' => array(4, 13, 1), - ); - $this->assertEquals($expected, $this->dumpNodes($ancestors), 'getAncestors() accepts a criteria as parameter'); - } - - public function testAddChild() - { - Table9Peer::doDeleteAll(); - $t1 = new Table9(); - $t1->setTitle('t1'); - $t1->makeRoot(); - $t1->save(); - $t2 = new Table9(); - $t2->setTitle('t2'); - $t1->addChild($t2); - $t2->save(); - $t3 = new Table9(); - $t3->setTitle('t3'); - $t1->addChild($t3); - $t3->save(); - $t4 = new Table9(); - $t4->setTitle('t4'); - $t2->addChild($t4); - $t4->save(); - $expected = array( - 't1' => array(1, 8, 0), - 't2' => array(4, 7, 1), - 't3' => array(2, 3, 1), - 't4' => array(5, 6, 2), - ); - $this->assertEquals($expected, $this->dumpTree(), 'addChild() adds the child and saves it'); - } - - public function testInsertAsFirstChildOf() - { - $this->assertTrue(method_exists('Table9', 'insertAsFirstChildOf'), 'nested_set adds a insertAsFirstChildOf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $t8 = new PublicTable9(); - $t8->setTitle('t8'); - $t = $t8->insertAsFirstChildOf($t3); - $this->assertEquals($t8, $t, 'insertAsFirstChildOf() returns the object it was called on'); - $this->assertEquals(5, $t4->getLeftValue(), 'insertAsFirstChildOf() does not modify the tree until the object is saved'); - $t8->save(); - $this->assertEquals(5, $t8->getLeftValue(), 'insertAsFirstChildOf() sets the left value correctly'); - $this->assertEquals(6, $t8->getRightValue(), 'insertAsFirstChildOf() sets the right value correctly'); - $this->assertEquals(2, $t8->getLevel(), 'insertAsFirstChildOf() sets the level correctly'); - $expected = array( - 't1' => array(1, 16, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 15, 1), - 't4' => array(7, 8, 2), - 't5' => array(9, 14, 2), - 't6' => array(10, 11, 3), - 't7' => array(12, 13, 3), - 't8' => array(5, 6, 2) - ); - $this->assertEquals($expected, $this->dumpTree(), 'insertAsFirstChildOf() shifts the other nodes correctly'); - try { - $t8->insertAsFirstChildOf($t4); - $this->fail('insertAsFirstChildOf() throws an exception when called on a saved object'); - } catch (PropelException $e) { - $this->assertTrue(true, 'insertAsFirstChildOf() throws an exception when called on a saved object'); - } - } - - public function testInsertAsLastChildOf() - { - $this->assertTrue(method_exists('Table9', 'insertAsLastChildOf'), 'nested_set adds a insertAsLastChildOf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $t8 = new PublicTable9(); - $t8->setTitle('t8'); - $t = $t8->insertAsLastChildOf($t3); - $this->assertEquals($t8, $t, 'insertAsLastChildOf() returns the object it was called on'); - $this->assertEquals(13, $t3->getRightValue(), 'insertAsLastChildOf() does not modify the tree until the object is saved'); - $t8->save(); - $this->assertEquals(13, $t8->getLeftValue(), 'insertAsLastChildOf() sets the left value correctly'); - $this->assertEquals(14, $t8->getRightValue(), 'insertAsLastChildOf() sets the right value correctly'); - $this->assertEquals(2, $t8->getLevel(), 'insertAsLastChildOf() sets the level correctly'); - $expected = array( - 't1' => array(1, 16, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 15, 1), - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - 't6' => array(8, 9, 3), - 't7' => array(10, 11, 3), - 't8' => array(13, 14, 2) - ); - $this->assertEquals($expected, $this->dumpTree(), 'insertAsLastChildOf() shifts the other nodes correctly'); - try { - $t8->insertAsLastChildOf($t4); - $this->fail('insertAsLastChildOf() throws an exception when called on a saved object'); - } catch (PropelException $e) { - $this->assertTrue(true, 'insertAsLastChildOf() throws an exception when called on a saved object'); - } - } - - public function testInsertAsPrevSiblingOf() - { - $this->assertTrue(method_exists('Table9', 'insertAsPrevSiblingOf'), 'nested_set adds a insertAsPrevSiblingOf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $t8 = new PublicTable9(); - $t8->setTitle('t8'); - $t = $t8->insertAsPrevSiblingOf($t3); - $this->assertEquals($t8, $t, 'insertAsPrevSiblingOf() returns the object it was called on'); - $this->assertEquals(4, $t3->getLeftValue(), 'insertAsPrevSiblingOf() does not modify the tree until the object is saved'); - $t8->save(); - $this->assertEquals(4, $t8->getLeftValue(), 'insertAsPrevSiblingOf() sets the left value correctly'); - $this->assertEquals(5, $t8->getRightValue(), 'insertAsPrevSiblingOf() sets the right value correctly'); - $this->assertEquals(1, $t8->getLevel(), 'insertAsPrevSiblingOf() sets the level correctly'); - $expected = array( - 't1' => array(1, 16, 0), - 't2' => array(2, 3, 1), - 't3' => array(6, 15, 1), - 't4' => array(7, 8, 2), - 't5' => array(9, 14, 2), - 't6' => array(10, 11, 3), - 't7' => array(12, 13, 3), - 't8' => array(4, 5, 1) - ); - $this->assertEquals($expected, $this->dumpTree(), 'insertAsPrevSiblingOf() shifts the other nodes correctly'); - try { - $t8->insertAsPrevSiblingOf($t4); - $this->fail('insertAsPrevSiblingOf() throws an exception when called on a saved object'); - } catch (PropelException $e) { - $this->assertTrue(true, 'insertAsPrevSiblingOf() throws an exception when called on a saved object'); - } - } + public function testIsRoot() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $this->assertTrue($t1->isRoot(), 'root is seen as root'); + $this->assertFalse($t2->isRoot(), 'leaf is not seen as root'); + $this->assertFalse($t3->isRoot(), 'node is not seen as root'); + } - public function testInsertAsNextSiblingOf() - { - $this->assertTrue(method_exists('Table9', 'insertAsNextSiblingOf'), 'nested_set adds a insertAsNextSiblingOf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $t8 = new PublicTable9(); - $t8->setTitle('t8'); - $t = $t8->insertAsNextSiblingOf($t3); - $this->assertEquals($t8, $t, 'insertAsNextSiblingOf() returns the object it was called on'); - $this->assertEquals(14, $t1->getRightValue(), 'insertAsNextSiblingOf() does not modify the tree until the object is saved'); - $t8->save(); - $this->assertEquals(14, $t8->getLeftValue(), 'insertAsNextSiblingOf() sets the left value correctly'); - $this->assertEquals(15, $t8->getRightValue(), 'insertAsNextSiblingOf() sets the right value correctly'); - $this->assertEquals(1, $t8->getLevel(), 'insertAsNextSiblingOf() sets the level correctly'); - $expected = array( - 't1' => array(1, 16, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 13, 1), - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - 't6' => array(8, 9, 3), - 't7' => array(10, 11, 3), - 't8' => array(14, 15, 1) - ); - $this->assertEquals($expected, $this->dumpTree(), 'insertAsNextSiblingOf() shifts the other nodes correctly'); - try { - $t8->insertAsNextSiblingOf($t4); - $this->fail('insertAsNextSiblingOf() throws an exception when called on a saved object'); - } catch (PropelException $e) { - $this->assertTrue(true, 'insertAsNextSiblingOf() throws an exception when called on a saved object'); - } - } - - public function testMoveToFirstChildOf() - { - $this->assertTrue(method_exists('Table9', 'moveToFirstChildOf'), 'nested_set adds a moveToFirstChildOf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - try { - $t3->moveToFirstChildOf($t5); - $this->fail('moveToFirstChildOf() throws an exception when the target is a child node'); - } catch (PropelException $e) { - $this->assertTrue(true, 'moveToFirstChildOf() throws an exception when the target is a child node'); - } - // moving down - $t = $t3->moveToFirstChildOf($t2); - $this->assertEquals($t3, $t, 'moveToFirstChildOf() returns the object it was called on'); - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 13, 1), - 't3' => array(3, 12, 2), - 't4' => array(4, 5, 3), - 't5' => array(6, 11, 3), - 't6' => array(7, 8, 4), - 't7' => array(9, 10, 4), - ); - $this->assertEquals($expected, $this->dumpTree(), 'moveToFirstChildOf() moves the entire subtree down correctly'); - // moving up - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - $t5->moveToFirstChildOf($t1); - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(8, 9, 1), - 't3' => array(10, 13, 1), - 't4' => array(11, 12, 2), - 't5' => array(2, 7, 1), - 't6' => array(3, 4, 2), - 't7' => array(5, 6, 2), - ); - $this->assertEquals($expected, $this->dumpTree(), 'moveToFirstChildOf() moves the entire subtree up correctly'); - // moving to the same level - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - $t5->moveToFirstChildOf($t3); - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 13, 1), - 't4' => array(11, 12, 2), - 't5' => array(5, 10, 2), - 't6' => array(6, 7, 3), - 't7' => array(8, 9, 3), - ); - $this->assertEquals($expected, $this->dumpTree(), 'moveToFirstChildOf() moves the entire subtree to the same level correctly'); - } + public function testIsLeaf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $this->assertFalse($t1->isLeaf(), 'root is not seen as leaf'); + $this->assertTrue($t2->isLeaf(), 'leaf is seen as leaf'); + $this->assertFalse($t3->isLeaf(), 'node is not seen as leaf'); + } - public function testMoveToFirstChildOfAndChildrenCache() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - // fill children cache - $t3->getChildren(); - $t1->getChildren(); - // move - $t5->moveToFirstChildOf($t1); - $children = $t3->getChildren(); - $expected = array( - 't4' => array(11, 12, 2), - ); - $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToFirstChildOf() reinitializes the child collection of all concerned nodes'); - $children = $t1->getChildren(); - $expected = array( - 't5' => array(2, 7, 1), - 't2' => array(8, 9, 1), - 't3' => array(10, 13, 1), - ); - $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToFirstChildOf() reinitializes the child collection of all concerned nodes'); - } - - public function testMoveToLastChildOf() - { - $this->assertTrue(method_exists('Table9', 'moveToLastChildOf'), 'nested_set adds a moveToLastChildOf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - try { - $t3->moveToLastChildOf($t5); - $this->fail('moveToLastChildOf() throws an exception when the target is a child node'); - } catch (PropelException $e) { - $this->assertTrue(true, 'moveToLastChildOf() throws an exception when the target is a child node'); - } - // moving up - $t = $t5->moveToLastChildOf($t1); - $this->assertEquals($t5, $t, 'moveToLastChildOf() returns the object it was called on'); - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 7, 1), - 't4' => array(5, 6, 2), - 't5' => array(8, 13, 1), - 't6' => array(9, 10, 2), - 't7' => array(11, 12, 2), - ); - $this->assertEquals($expected, $this->dumpTree(), 'moveToLastChildOf() moves the entire subtree up correctly'); - // moving down - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - $t3->moveToLastChildOf($t2); - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 13, 1), - 't3' => array(3, 12, 2), - 't4' => array(4, 5, 3), - 't5' => array(6, 11, 3), - 't6' => array(7, 8, 4), - 't7' => array(9, 10, 4), - ); - $this->assertEquals($expected, $this->dumpTree(), 'moveToLastChildOf() moves the entire subtree down correctly'); - // moving to the same level - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - $t4->moveToLastChildOf($t3); - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 13, 1), - 't4' => array(11, 12, 2), - 't5' => array(5, 10, 2), - 't6' => array(6, 7, 3), - 't7' => array(8, 9, 3), - ); - $this->assertEquals($expected, $this->dumpTree(), 'moveToLastChildOf() moves the entire subtree to the same level correctly'); - } + public function testIsDescendantOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $this->assertFalse($t1->isDescendantOf($t1), 'root is not seen as a descendant of root'); + $this->assertTrue($t2->isDescendantOf($t1), 'direct child is seen as a descendant of root'); + $this->assertFalse($t1->isDescendantOf($t2), 'root is not seen as a descendant of leaf'); + $this->assertTrue($t5->isDescendantOf($t1), 'grandchild is seen as a descendant of root'); + $this->assertTrue($t5->isDescendantOf($t3), 'direct child is seen as a descendant of node'); + $this->assertFalse($t3->isDescendantOf($t5), 'node is not seen as a descendant of its parent'); + } - public function testMoveToLastChildOfAndChildrenCache() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - // fill children cache - $t3->getChildren(); - $t1->getChildren(); - // move - $t5->moveToLastChildOf($t1); - $children = $t3->getChildren(); - $expected = array( - 't4' => array(5, 6, 2), - ); - $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToLastChildOf() reinitializes the child collection of all concerned nodes'); - $children = $t1->getChildren(); - $expected = array( - 't2' => array(2, 3, 1), - 't3' => array(4, 7, 1), - 't5' => array(8, 13, 1), - ); - $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToLastChildOf() reinitializes the child collection of all concerned nodes'); - } + public function testIsAncestorOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $this->assertFalse($t1->isAncestorOf($t1), 'root is not seen as an ancestor of root'); + $this->assertTrue($t1->isAncestorOf($t2), 'root is seen as an ancestor of direct child'); + $this->assertFalse($t2->isAncestorOf($t1), 'direct child is not seen as an ancestor of root'); + $this->assertTrue($t1->isAncestorOf($t5), 'root is seen as an ancestor of grandchild'); + $this->assertTrue($t3->isAncestorOf($t5), 'parent is seen as an ancestor of node'); + $this->assertFalse($t5->isAncestorOf($t3), 'child is not seen as an ancestor of its parent'); + } - public function testMoveToPrevSiblingOf() - { - $this->assertTrue(method_exists('Table9', 'moveToPrevSiblingOf'), 'nested_set adds a moveToPrevSiblingOf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - try { - $t5->moveToPrevSiblingOf($t1); - $this->fail('moveToPrevSiblingOf() throws an exception when the target is a root node'); - } catch (PropelException $e) { - $this->assertTrue(true, 'moveToPrevSiblingOf() throws an exception when the target is a root node'); - } - try { - $t5->moveToPrevSiblingOf($t6); - $this->fail('moveToPrevSiblingOf() throws an exception when the target is a child node'); - } catch (PropelException $e) { - $this->assertTrue(true, 'moveToPrevSiblingOf() throws an exception when the target is a child node'); - } - // moving up - $t = $t5->moveToPrevSiblingOf($t3); - /* Results in - t1 - | \ \ - t2 t5 t3 - | \ | - t6 t7 t4 - */ - $this->assertEquals($t5, $t, 'moveToPrevSiblingOf() returns the object it was called on'); - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(10, 13, 1), - 't4' => array(11, 12, 2), - 't5' => array(4, 9, 1), - 't6' => array(5, 6, 2), - 't7' => array(7, 8, 2), - ); - $this->assertEquals($expected, $this->dumpTree(), 'moveToPrevSiblingOf() moves the entire subtree up correctly'); - // moving down - $t5->moveToPrevSiblingOf($t4); - /* Results in - t1 - | \ - t2 t3 - | \ - t5 t4 - | \ - t6 t7 - */ - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 13, 1), - 't4' => array(11, 12, 2), - 't5' => array(5, 10, 2), - 't6' => array(6, 7, 3), - 't7' => array(8, 9, 3), - ); - $this->assertEquals($expected, $this->dumpTree(), 'moveToPrevSiblingOf() moves the entire subtree down correctly'); - // moving at the same level - $t4->moveToPrevSiblingOf($t5); - /* Results in - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 13, 1), - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - 't6' => array(8, 9, 3), - 't7' => array(10, 11, 3), - ); - $this->assertEquals($expected, $this->dumpTree(), 'moveToPrevSiblingOf() moves the entire subtree at the same level correctly'); - } + public function testHasParent() + { + Table9Peer::doDeleteAll(); + $t0 = new Table9(); + $t1 = new Table9(); + $t1->setTitle('t1')->setLeftValue(1)->setRightValue(6)->setLevel(0)->save(); + $t2 = new Table9(); + $t2->setTitle('t2')->setLeftValue(2)->setRightValue(5)->setLevel(1)->save(); + $t3 = new Table9(); + $t3->setTitle('t3')->setLeftValue(3)->setRightValue(4)->setLevel(2)->save(); + $this->assertFalse($t0->hasParent(), 'empty node has no parent'); + $this->assertFalse($t1->hasParent(), 'root node has no parent'); + $this->assertTrue($t2->hasParent(), 'not root node has a parent'); + $this->assertTrue($t3->hasParent(), 'leaf node has a parent'); + } - public function testMoveToPrevSiblingOfAndChildrenCache() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - // fill children cache - $t3->getChildren(); - $t1->getChildren(); - // move - $t5->moveToPrevSiblingOf($t2); - $children = $t3->getChildren(); - $expected = array( - 't4' => array(11, 12, 2), - ); - $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToPrevSiblingOf() reinitializes the child collection of all concerned nodes'); - $children = $t1->getChildren(); - $expected = array( - 't5' => array(2, 7, 1), - 't2' => array(8, 9, 1), - 't3' => array(10, 13, 1), - ); - $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToPrevSiblingOf() reinitializes the child collection of all concerned nodes'); - } + public function testGetParent() + { + Table9Peer::doDeleteAll(); + $t0 = new Table9(); + $this->assertFalse($t0->hasParent(), 'empty node has no parent'); + $t1 = new Table9(); + $t1->setTitle('t1')->setLeftValue(1)->setRightValue(8)->setLevel(0)->save(); + $t2 = new Table9(); + $t2->setTitle('t2')->setLeftValue(2)->setRightValue(7)->setLevel(1)->save(); + $t3 = new Table9(); + $t3->setTitle('t3')->setLeftValue(3)->setRightValue(4)->setLevel(2)->save(); + $t4 = new Table9(); + $t4->setTitle('t4')->setLeftValue(5)->setRightValue(6)->setLevel(2)->save(); + $this->assertNull($t1->getParent($this->con), 'getParent() return null for root nodes'); + $this->assertEquals($t2->getParent($this->con), $t1, 'getParent() correctly retrieves parent for nodes'); + $this->assertEquals($t3->getParent($this->con), $t2, 'getParent() correctly retrieves parent for leafs'); + $this->assertEquals($t4->getParent($this->con), $t2, 'getParent() retrieves the same parent for two siblings'); + } - public function testMoveToNextSiblingOfAndChildrenCache() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - // fill children cache - $t3->getChildren(); - $t1->getChildren(); - // move - $t5->moveToNextSiblingOf($t3); - $children = $t3->getChildren(); - $expected = array( - 't4' => array(5, 6, 2), - ); - $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToNextSiblingOf() reinitializes the child collection of all concerned nodes'); - $children = $t1->getChildren(); - $expected = array( - 't2' => array(2, 3, 1), - 't3' => array(4, 7, 1), - 't5' => array(8, 13, 1), - ); - $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToNextSiblingOf() reinitializes the child collection of all concerned nodes'); - } + public function testGetParentCache() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $con = Propel::getConnection(); + $count = $con->getQueryCount(); + $parent = $t5->getParent($con); + $parent = $t5->getParent($con); + $this->assertEquals($count + 1, $con->getQueryCount(), 'getParent() only issues a query once'); + $this->assertEquals('t3', $parent->getTitle(), 'getParent() returns the parent Node'); + } - public function testMoveToNextSiblingOf() - { - $this->assertTrue(method_exists('Table9', 'moveToNextSiblingOf'), 'nested_set adds a moveToNextSiblingOf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - try { - $t5->moveToNextSiblingOf($t1); - $this->fail('moveToNextSiblingOf() throws an exception when the target is a root node'); - } catch (PropelException $e) { - $this->assertTrue(true, 'moveToNextSiblingOf() throws an exception when the target is a root node'); - } - try { - $t5->moveToNextSiblingOf($t6); - $this->fail('moveToNextSiblingOf() throws an exception when the target is a child node'); - } catch (PropelException $e) { - $this->assertTrue(true, 'moveToNextSiblingOf() throws an exception when the target is a child node'); - } - // moving up - $t = $t5->moveToNextSiblingOf($t3); - /* Results in - t1 - | \ \ - t2 t3 t5 - | | \ - t4 t6 t7 - */ - $this->assertEquals($t5, $t, 'moveToPrevSiblingOf() returns the object it was called on'); - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 7, 1), - 't4' => array(5, 6, 2), - 't5' => array(8, 13, 1), - 't6' => array(9, 10, 2), - 't7' => array(11, 12, 2), - ); - $this->assertEquals($expected, $this->dumpTree(), 'moveToNextSiblingOf() moves the entire subtree up correctly'); - // moving down - $t = $t5->moveToNextSiblingOf($t4); - /* Results in - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 13, 1), - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - 't6' => array(8, 9, 3), - 't7' => array(10, 11, 3), - ); - $this->assertEquals($expected, $this->dumpTree(), 'moveToNextSiblingOf() moves the entire subtree down correctly'); - // moving at the same level - $t = $t4->moveToNextSiblingOf($t5); - /* Results in - t1 - | \ - t2 t3 - | \ - t5 t4 - | \ - t6 t7 - */ - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 13, 1), - 't4' => array(11, 12, 2), - 't5' => array(5, 10, 2), - 't6' => array(6, 7, 3), - 't7' => array(8, 9, 3), - ); - $this->assertEquals($expected, $this->dumpTree(), 'moveToNextSiblingOf() moves the entire subtree at the same level correctly'); - } - - public function testDeleteDescendants() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $this->assertNull($t2->deleteDescendants(), 'deleteDescendants() returns null leafs'); - $this->assertEquals(4, $t3->deleteDescendants(), 'deleteDescendants() returns the number of deleted nodes'); - $this->assertEquals(5, $t3->getRightValue(), 'deleteDescendants() updates the current node'); - $this->assertEquals(5, $t4->getLeftValue(), 'deleteDescendants() does not update existing nodes (because delete() clears the instance cache)'); - $expected = array( - 't1' => array(1, 6, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 5, 1), - ); - $this->assertEquals($expected, $this->dumpTree(), 'deleteDescendants() shifts the entire subtree correctly'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $this->assertEquals(6, $t1->deleteDescendants(), 'deleteDescendants() can be called on the root node'); - $expected = array( - 't1' => array(1, 2, 0), - ); - $this->assertEquals($expected, $this->dumpTree(), 'deleteDescendants() can delete all descendants of the root node'); - } - - public function testGetIterator() - { - $fixtures = $this->initTree(); - $this->assertTrue(method_exists('Table9', 'getIterator'), 'nested_set adds a getIterator() method'); - $root = Table9Peer::retrieveRoot(); - $iterator = $root->getIterator(); - $this->assertTrue($iterator instanceof NestedSetRecursiveIterator, 'getIterator() returns a NestedSetRecursiveIterator'); - foreach ($iterator as $node) { - $expected = array_shift($fixtures); - $this->assertEquals($expected, $node, 'getIterator returns an iterator parsing the tree order by left column'); - } - } - - public function testCompatibilityProxies() - { - $proxies = array('createRoot', 'retrieveParent', 'setParentNode', 'getNumberOfDescendants', 'getNumberOfChildren', 'retrievePrevSibling', 'retrieveNextSibling', 'retrieveFirstChild', 'retrieveLastChild', 'getPath'); - foreach ($proxies as $method) { - $this->assertFalse(method_exists('Table9', $method), 'proxies are not enabled by default'); - $this->assertTrue(method_exists('Table10', $method), 'setting method_proxies to true adds compatibility proxies'); - } - $t = new Table10(); - $t->createRoot(); - $this->assertEquals($t->getLeftValue(), 1, 'createRoot() is an alias for makeRoot()'); - $this->assertEquals($t->getRightValue(), 2, 'createRoot() is an alias for makeRoot()'); - $this->assertEquals($t->getLevel(), 0, 'createRoot() is an alias for makeRoot()'); - } -} \ No newline at end of file + public function testHasPrevSibling() + { + Table9Peer::doDeleteAll(); + $t0 = new Table9(); + $t1 = new Table9(); + $t1->setTitle('t1')->setLeftValue(1)->setRightValue(6)->save(); + $t2 = new Table9(); + $t2->setTitle('t2')->setLeftValue(2)->setRightValue(3)->save(); + $t3 = new Table9(); + $t3->setTitle('t3')->setLeftValue(4)->setRightValue(5)->save(); + $this->assertFalse($t0->hasPrevSibling(), 'empty node has no previous sibling'); + $this->assertFalse($t1->hasPrevSibling(), 'root node has no previous sibling'); + $this->assertFalse($t2->hasPrevSibling(), 'first sibling has no previous sibling'); + $this->assertTrue($t3->hasPrevSibling(), 'not first sibling has a previous sibling'); + } + + public function testGetPrevSibling() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $this->assertNull($t1->getPrevSibling($this->con), 'getPrevSibling() returns null for root nodes'); + $this->assertNull($t2->getPrevSibling($this->con), 'getPrevSibling() returns null for first siblings'); + $this->assertEquals($t3->getPrevSibling($this->con), $t2, 'getPrevSibling() correctly retrieves prev sibling'); + $this->assertNull($t6->getPrevSibling($this->con), 'getPrevSibling() returns null for first siblings'); + $this->assertEquals($t7->getPrevSibling($this->con), $t6, 'getPrevSibling() correctly retrieves prev sibling'); + } + + public function testHasNextSibling() + { + Table9Peer::doDeleteAll(); + $t0 = new Table9(); + $t1 = new Table9(); + $t1->setTitle('t1')->setLeftValue(1)->setRightValue(6)->save(); + $t2 = new Table9(); + $t2->setTitle('t2')->setLeftValue(2)->setRightValue(3)->save(); + $t3 = new Table9(); + $t3->setTitle('t3')->setLeftValue(4)->setRightValue(5)->save(); + $this->assertFalse($t0->hasNextSibling(), 'empty node has no next sibling'); + $this->assertFalse($t1->hasNextSibling(), 'root node has no next sibling'); + $this->assertTrue($t2->hasNextSibling(), 'not last sibling has a next sibling'); + $this->assertFalse($t3->hasNextSibling(), 'last sibling has no next sibling'); + } + + public function testGetNextSibling() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $this->assertNull($t1->getNextSibling($this->con), 'getNextSibling() returns null for root nodes'); + $this->assertEquals($t2->getNextSibling($this->con), $t3, 'getNextSibling() correctly retrieves next sibling'); + $this->assertNull($t3->getNextSibling($this->con), 'getNextSibling() returns null for last siblings'); + $this->assertEquals($t6->getNextSibling($this->con), $t7, 'getNextSibling() correctly retrieves next sibling'); + $this->assertNull($t7->getNextSibling($this->con), 'getNextSibling() returns null for last siblings'); + } + + public function testAddNestedSetChildren() + { + $t0 = new Table9(); + $t1 = new Table9(); + $t2 = new Table9(); + $t0->addNestedSetChild($t1); + $t0->addNestedSetChild($t2); + $this->assertEquals(2, $t0->countChildren(), 'addNestedSetChild() adds the object to the internal children collection'); + $this->assertEquals($t0, $t1->getParent(), 'addNestedSetChild() sets the object as th parent of the parameter'); + $this->assertEquals($t0, $t2->getParent(), 'addNestedSetChild() sets the object as th parent of the parameter'); + } + + public function testHasChildren() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $this->assertTrue($t1->hasChildren(), 'root has children'); + $this->assertFalse($t2->hasChildren(), 'leaf has no children'); + $this->assertTrue($t3->hasChildren(), 'node has children'); + } + + public function testGetChildren() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $this->assertTrue($t2->getChildren() instanceof PropelObjectCollection, 'getChildren() returns a collection'); + $this->assertEquals(0, count($t2->getChildren()), 'getChildren() returns an empty collection for leafs'); + $children = $t3->getChildren(); + $expected = array( + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + ); + $this->assertEquals($expected, $this->dumpNodes($children, true), 'getChildren() returns a collection of children'); + $c = new Criteria(); + $c->add(Table9Peer::TITLE, 't5'); + $children = $t3->getChildren($c); + $expected = array( + 't5' => array(7, 12, 2), + ); + $this->assertEquals($expected, $this->dumpNodes($children, true), 'getChildren() accepts a criteria as parameter'); + } + + public function testGetChildrenCache() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + $con = Propel::getConnection(); + $count = $con->getQueryCount(); + $children = $t3->getChildren(null, $con); + $children = $t3->getChildren(null, $con); + $this->assertEquals($count + 1, $con->getQueryCount(), 'getChildren() only issues a query once'); + $expected = array( + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + ); + $this->assertEquals($expected, $this->dumpNodes($children, true), 'getChildren() returns a collection of children'); + // when using criteria, cache is not used + $c = new Criteria(); + $c->add(Table9Peer::TITLE, 't5'); + $children = $t3->getChildren($c, $con); + $this->assertEquals($count + 2, $con->getQueryCount(), 'getChildren() issues a new query when âssed a non-null Criteria'); + $expected = array( + 't5' => array(7, 12, 2), + ); + $this->assertEquals($expected, $this->dumpNodes($children, true), 'getChildren() accepts a criteria as parameter'); + // but not erased either + $children = $t3->getChildren(null, $con); + $this->assertEquals($count + 2, $con->getQueryCount(), 'getChildren() keeps its internal cache after being called with a Criteria'); + $expected = array( + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + ); + $this->assertEquals($expected, $this->dumpNodes($children, true), 'getChildren() returns a collection of children'); + } + + public function testCountChildren() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $this->assertEquals(0, $t2->countChildren(), 'countChildren() returns 0 for leafs'); + $this->assertEquals(2, $t3->countChildren(), 'countChildren() returns the number of children'); + $c = new Criteria(); + $c->add(Table9Peer::TITLE, 't5'); + $this->assertEquals(1, $t3->countChildren($c), 'countChildren() accepts a criteria as parameter'); + } + + public function testCountChildrenCache() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $con = Propel::getConnection(); + $count = $con->getQueryCount(); + $children = $t3->getChildren(null, $con); + $nbChildren = $t3->countChildren(null, $con); + $this->assertEquals($count + 1, $con->getQueryCount(), 'countChildren() uses the internal collection when passed no Criteria'); + $nbChildren = $t3->countChildren(new Criteria(), $con); + $this->assertEquals($count + 2, $con->getQueryCount(), 'countChildren() issues a new query when passed a Criteria'); + } + + public function testGetFirstChild() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + $t5->moveToNextSiblingOf($t3); + /* Results in + t1 + | \ \ + t2 t3 t5 + | | \ + t4 t6 t7 + */ + $this->assertEquals($t2, $t1->getFirstChild(), 'getFirstChild() returns the first child'); + } + + public function testGetLastChild() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + $t5->moveToNextSiblingOf($t3); + /* Results in + t1 + | \ \ + t2 t3 t5 + | | \ + t4 t6 t7 + */ + $this->assertEquals($t5, $t1->getLastChild(), 'getLastChild() returns the last child'); + } + + public function testGetSiblings() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $this->assertEquals(array(), $t1->getSiblings(), 'getSiblings() returns an empty array for root'); + $siblings = $t5->getSiblings(); + $expected = array( + 't4' => array(5, 6, 2), + ); + $this->assertEquals($expected, $this->dumpNodes($siblings), 'getSiblings() returns an array of siblings'); + $siblings = $t5->getSiblings(true); + $expected = array( + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2) + ); + $this->assertEquals($expected, $this->dumpNodes($siblings), 'getSiblings(true) includes the current node'); + $t5->moveToNextSiblingOf($t3); + /* Results in + t1 + | \ \ + t2 t3 t5 + | | \ + t4 t6 t7 + */ + $this->assertEquals(0, count($t4->getSiblings()), 'getSiblings() returns an empty colleciton for lone children'); + $siblings = $t3->getSiblings(); + $expected = array( + 't2' => array(2, 3, 1), + 't5' => array(8, 13, 1), + ); + $this->assertEquals($expected, $this->dumpNodes($siblings), 'getSiblings() returns all siblings'); + $this->assertEquals('t2', $siblings[0]->getTitle(), 'getSiblings() returns siblings in natural order'); + $this->assertEquals('t5', $siblings[1]->getTitle(), 'getSiblings() returns siblings in natural order'); + } + + public function testGetDescendants() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $this->assertEquals(array(), $t2->getDescendants(), 'getDescendants() returns an empty array for leafs'); + $descendants = $t3->getDescendants(); + $expected = array( + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + 't6' => array(8, 9, 3), + 't7' => array(10, 11, 3), + ); + $this->assertEquals($expected, $this->dumpNodes($descendants), 'getDescendants() returns an array of descendants'); + $c = new Criteria(); + $c->add(Table9Peer::TITLE, 't5'); + $descendants = $t3->getDescendants($c); + $expected = array( + 't5' => array(7, 12, 2), + ); + $this->assertEquals($expected, $this->dumpNodes($descendants), 'getDescendants() accepts a criteria as parameter'); + } + + public function testCountDescendants() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $this->assertEquals(0, $t2->countDescendants(), 'countDescendants() returns 0 for leafs'); + $this->assertEquals(4, $t3->countDescendants(), 'countDescendants() returns the number of descendants'); + $c = new Criteria(); + $c->add(Table9Peer::TITLE, 't5'); + $this->assertEquals(1, $t3->countDescendants($c), 'countDescendants() accepts a criteria as parameter'); + } + + public function testGetBranch() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $this->assertEquals(array($t2), $t2->getBranch()->getArrayCopy(), 'getBranch() returns the current node for leafs'); + $descendants = $t3->getBranch(); + $expected = array( + 't3' => array(4, 13, 1), + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + 't6' => array(8, 9, 3), + 't7' => array(10, 11, 3), + ); + $this->assertEquals($expected, $this->dumpNodes($descendants), 'getBranch() returns an array of descendants, uncluding the current node'); + $c = new Criteria(); + $c->add(Table9Peer::TITLE, 't3', Criteria::NOT_EQUAL); + $descendants = $t3->getBranch($c); + unset($expected['t3']); + $this->assertEquals($expected, $this->dumpNodes($descendants), 'getBranch() accepts a criteria as first parameter'); + } + + public function testGetAncestors() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $this->assertEquals(array(), $t1->getAncestors(), 'getAncestors() returns an empty array for roots'); + $ancestors = $t5->getAncestors(); + $expected = array( + 't1' => array(1, 14, 0), + 't3' => array(4, 13, 1), + ); + $this->assertEquals($expected, $this->dumpNodes($ancestors), 'getAncestors() returns an array of ancestors'); + $c = new Criteria(); + $c->add(Table9Peer::TITLE, 't3'); + $ancestors = $t5->getAncestors($c); + $expected = array( + 't3' => array(4, 13, 1), + ); + $this->assertEquals($expected, $this->dumpNodes($ancestors), 'getAncestors() accepts a criteria as parameter'); + } + + public function testAddChild() + { + Table9Peer::doDeleteAll(); + $t1 = new Table9(); + $t1->setTitle('t1'); + $t1->makeRoot(); + $t1->save(); + $t2 = new Table9(); + $t2->setTitle('t2'); + $t1->addChild($t2); + $t2->save(); + $t3 = new Table9(); + $t3->setTitle('t3'); + $t1->addChild($t3); + $t3->save(); + $t4 = new Table9(); + $t4->setTitle('t4'); + $t2->addChild($t4); + $t4->save(); + $expected = array( + 't1' => array(1, 8, 0), + 't2' => array(4, 7, 1), + 't3' => array(2, 3, 1), + 't4' => array(5, 6, 2), + ); + $this->assertEquals($expected, $this->dumpTree(), 'addChild() adds the child and saves it'); + } + + public function testInsertAsFirstChildOf() + { + $this->assertTrue(method_exists('Table9', 'insertAsFirstChildOf'), 'nested_set adds a insertAsFirstChildOf() method'); + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $t8 = new PublicTable9(); + $t8->setTitle('t8'); + $t = $t8->insertAsFirstChildOf($t3); + $this->assertEquals($t8, $t, 'insertAsFirstChildOf() returns the object it was called on'); + $this->assertEquals(5, $t4->getLeftValue(), 'insertAsFirstChildOf() does not modify the tree until the object is saved'); + $t8->save(); + $this->assertEquals(5, $t8->getLeftValue(), 'insertAsFirstChildOf() sets the left value correctly'); + $this->assertEquals(6, $t8->getRightValue(), 'insertAsFirstChildOf() sets the right value correctly'); + $this->assertEquals(2, $t8->getLevel(), 'insertAsFirstChildOf() sets the level correctly'); + $expected = array( + 't1' => array(1, 16, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 15, 1), + 't4' => array(7, 8, 2), + 't5' => array(9, 14, 2), + 't6' => array(10, 11, 3), + 't7' => array(12, 13, 3), + 't8' => array(5, 6, 2) + ); + $this->assertEquals($expected, $this->dumpTree(), 'insertAsFirstChildOf() shifts the other nodes correctly'); + try { + $t8->insertAsFirstChildOf($t4); + $this->fail('insertAsFirstChildOf() throws an exception when called on a saved object'); + } catch (PropelException $e) { + $this->assertTrue(true, 'insertAsFirstChildOf() throws an exception when called on a saved object'); + } + } + + public function testInsertAsFirstChildOfExistingObject() + { + Table9Query::create()->deleteAll(); + $t = new Table9(); + $t->makeRoot(); + $t->save(); + $this->assertEquals(1, $t->getLeftValue()); + $this->assertEquals(2, $t->getRightValue()); + $this->assertEquals(0, $t->getLevel()); + $t1 = new Table9(); + $t1->save(); + $t1->insertAsFirstChildOf($t); + $this->assertEquals(2, $t1->getLeftValue()); + $this->assertEquals(3, $t1->getRightValue()); + $this->assertEquals(1, $t1->getLevel()); + $t1->save(); + $this->assertEquals(1, $t->getLeftValue()); + $this->assertEquals(4, $t->getRightValue()); + $this->assertEquals(0, $t->getLevel()); + $this->assertEquals(2, $t1->getLeftValue()); + $this->assertEquals(3, $t1->getRightValue()); + $this->assertEquals(1, $t1->getLevel()); + } + + public function testInsertAsLastChildOf() + { + $this->assertTrue(method_exists('Table9', 'insertAsLastChildOf'), 'nested_set adds a insertAsLastChildOf() method'); + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $t8 = new PublicTable9(); + $t8->setTitle('t8'); + $t = $t8->insertAsLastChildOf($t3); + $this->assertEquals($t8, $t, 'insertAsLastChildOf() returns the object it was called on'); + $this->assertEquals(13, $t3->getRightValue(), 'insertAsLastChildOf() does not modify the tree until the object is saved'); + $t8->save(); + $this->assertEquals(13, $t8->getLeftValue(), 'insertAsLastChildOf() sets the left value correctly'); + $this->assertEquals(14, $t8->getRightValue(), 'insertAsLastChildOf() sets the right value correctly'); + $this->assertEquals(2, $t8->getLevel(), 'insertAsLastChildOf() sets the level correctly'); + $expected = array( + 't1' => array(1, 16, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 15, 1), + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + 't6' => array(8, 9, 3), + 't7' => array(10, 11, 3), + 't8' => array(13, 14, 2) + ); + $this->assertEquals($expected, $this->dumpTree(), 'insertAsLastChildOf() shifts the other nodes correctly'); + try { + $t8->insertAsLastChildOf($t4); + $this->fail('insertAsLastChildOf() throws an exception when called on a saved object'); + } catch (PropelException $e) { + $this->assertTrue(true, 'insertAsLastChildOf() throws an exception when called on a saved object'); + } + } + + public function testInsertAsLastChildOfExistingObject() + { + Table9Query::create()->deleteAll(); + $t = new Table9(); + $t->makeRoot(); + $t->save(); + $this->assertEquals(1, $t->getLeftValue()); + $this->assertEquals(2, $t->getRightValue()); + $this->assertEquals(0, $t->getLevel()); + $t1 = new Table9(); + $t1->save(); + $t1->insertAsLastChildOf($t); + $this->assertEquals(2, $t1->getLeftValue()); + $this->assertEquals(3, $t1->getRightValue()); + $this->assertEquals(1, $t1->getLevel()); + $t1->save(); + $this->assertEquals(1, $t->getLeftValue()); + $this->assertEquals(4, $t->getRightValue()); + $this->assertEquals(0, $t->getLevel()); + $this->assertEquals(2, $t1->getLeftValue()); + $this->assertEquals(3, $t1->getRightValue()); + $this->assertEquals(1, $t1->getLevel()); + } + + public function testInsertAsPrevSiblingOf() + { + $this->assertTrue(method_exists('Table9', 'insertAsPrevSiblingOf'), 'nested_set adds a insertAsPrevSiblingOf() method'); + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $t8 = new PublicTable9(); + $t8->setTitle('t8'); + $t = $t8->insertAsPrevSiblingOf($t3); + $this->assertEquals($t8, $t, 'insertAsPrevSiblingOf() returns the object it was called on'); + $this->assertEquals(4, $t3->getLeftValue(), 'insertAsPrevSiblingOf() does not modify the tree until the object is saved'); + $t8->save(); + $this->assertEquals(4, $t8->getLeftValue(), 'insertAsPrevSiblingOf() sets the left value correctly'); + $this->assertEquals(5, $t8->getRightValue(), 'insertAsPrevSiblingOf() sets the right value correctly'); + $this->assertEquals(1, $t8->getLevel(), 'insertAsPrevSiblingOf() sets the level correctly'); + $expected = array( + 't1' => array(1, 16, 0), + 't2' => array(2, 3, 1), + 't3' => array(6, 15, 1), + 't4' => array(7, 8, 2), + 't5' => array(9, 14, 2), + 't6' => array(10, 11, 3), + 't7' => array(12, 13, 3), + 't8' => array(4, 5, 1) + ); + $this->assertEquals($expected, $this->dumpTree(), 'insertAsPrevSiblingOf() shifts the other nodes correctly'); + try { + $t8->insertAsPrevSiblingOf($t4); + $this->fail('insertAsPrevSiblingOf() throws an exception when called on a saved object'); + } catch (PropelException $e) { + $this->assertTrue(true, 'insertAsPrevSiblingOf() throws an exception when called on a saved object'); + } + } + + public function testInsertAsPrevSiblingOfExistingObject() + { + Table9Query::create()->deleteAll(); + $t = new Table9(); + $t->makeRoot(); + $t->save(); + $t1 = new Table9(); + $t1->insertAsFirstChildOf($t); + $t1->save(); + $this->assertEquals(1, $t->getLeftValue()); + $this->assertEquals(4, $t->getRightValue()); + $this->assertEquals(0, $t->getLevel()); + $this->assertEquals(2, $t1->getLeftValue()); + $this->assertEquals(3, $t1->getRightValue()); + $this->assertEquals(1, $t1->getLevel()); + $t2 = new Table9(); + $t2->save(); + $t2->insertAsPrevSiblingOf($t1); + $this->assertEquals(2, $t2->getLeftValue()); + $this->assertEquals(3, $t2->getRightValue()); + $this->assertEquals(1, $t2->getLevel()); + $t2->save(); + $this->assertEquals(1, $t->getLeftValue()); + $this->assertEquals(6, $t->getRightValue()); + $this->assertEquals(0, $t->getLevel()); + $this->assertEquals(4, $t1->getLeftValue()); + $this->assertEquals(5, $t1->getRightValue()); + $this->assertEquals(1, $t1->getLevel()); + $this->assertEquals(2, $t2->getLeftValue()); + $this->assertEquals(3, $t2->getRightValue()); + $this->assertEquals(1, $t2->getLevel()); + } + + public function testInsertAsNextSiblingOf() + { + $this->assertTrue(method_exists('Table9', 'insertAsNextSiblingOf'), 'nested_set adds a insertAsNextSiblingOf() method'); + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $t8 = new PublicTable9(); + $t8->setTitle('t8'); + $t = $t8->insertAsNextSiblingOf($t3); + $this->assertEquals($t8, $t, 'insertAsNextSiblingOf() returns the object it was called on'); + $this->assertEquals(14, $t1->getRightValue(), 'insertAsNextSiblingOf() does not modify the tree until the object is saved'); + $t8->save(); + $this->assertEquals(14, $t8->getLeftValue(), 'insertAsNextSiblingOf() sets the left value correctly'); + $this->assertEquals(15, $t8->getRightValue(), 'insertAsNextSiblingOf() sets the right value correctly'); + $this->assertEquals(1, $t8->getLevel(), 'insertAsNextSiblingOf() sets the level correctly'); + $expected = array( + 't1' => array(1, 16, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 13, 1), + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + 't6' => array(8, 9, 3), + 't7' => array(10, 11, 3), + 't8' => array(14, 15, 1) + ); + $this->assertEquals($expected, $this->dumpTree(), 'insertAsNextSiblingOf() shifts the other nodes correctly'); + try { + $t8->insertAsNextSiblingOf($t4); + $this->fail('insertAsNextSiblingOf() throws an exception when called on a saved object'); + } catch (PropelException $e) { + $this->assertTrue(true, 'insertAsNextSiblingOf() throws an exception when called on a saved object'); + } + } + + public function testInsertAsNextSiblingOfExistingObject() + { + Table9Query::create()->deleteAll(); + $t = new Table9(); + $t->makeRoot(); + $t->save(); + $t1 = new Table9(); + $t1->insertAsFirstChildOf($t); + $t1->save(); + $this->assertEquals(1, $t->getLeftValue()); + $this->assertEquals(4, $t->getRightValue()); + $this->assertEquals(0, $t->getLevel()); + $this->assertEquals(2, $t1->getLeftValue()); + $this->assertEquals(3, $t1->getRightValue()); + $this->assertEquals(1, $t1->getLevel()); + $t2 = new Table9(); + $t2->save(); + $t2->insertAsNextSiblingOf($t1); + $this->assertEquals(4, $t2->getLeftValue()); + $this->assertEquals(5, $t2->getRightValue()); + $this->assertEquals(1, $t2->getLevel()); + $t2->save(); + $this->assertEquals(1, $t->getLeftValue()); + $this->assertEquals(6, $t->getRightValue()); + $this->assertEquals(0, $t->getLevel()); + $this->assertEquals(2, $t1->getLeftValue()); + $this->assertEquals(3, $t1->getRightValue()); + $this->assertEquals(1, $t1->getLevel()); + $this->assertEquals(4, $t2->getLeftValue()); + $this->assertEquals(5, $t2->getRightValue()); + $this->assertEquals(1, $t2->getLevel()); + } + + public function testMoveToFirstChildOf() + { + $this->assertTrue(method_exists('Table9', 'moveToFirstChildOf'), 'nested_set adds a moveToFirstChildOf() method'); + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + try { + $t3->moveToFirstChildOf($t5); + $this->fail('moveToFirstChildOf() throws an exception when the target is a child node'); + } catch (PropelException $e) { + $this->assertTrue(true, 'moveToFirstChildOf() throws an exception when the target is a child node'); + } + // moving down + $t = $t3->moveToFirstChildOf($t2); + $this->assertEquals($t3, $t, 'moveToFirstChildOf() returns the object it was called on'); + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 13, 1), + 't3' => array(3, 12, 2), + 't4' => array(4, 5, 3), + 't5' => array(6, 11, 3), + 't6' => array(7, 8, 4), + 't7' => array(9, 10, 4), + ); + $this->assertEquals($expected, $this->dumpTree(), 'moveToFirstChildOf() moves the entire subtree down correctly'); + // moving up + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + $t5->moveToFirstChildOf($t1); + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(8, 9, 1), + 't3' => array(10, 13, 1), + 't4' => array(11, 12, 2), + 't5' => array(2, 7, 1), + 't6' => array(3, 4, 2), + 't7' => array(5, 6, 2), + ); + $this->assertEquals($expected, $this->dumpTree(), 'moveToFirstChildOf() moves the entire subtree up correctly'); + // moving to the same level + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + $t5->moveToFirstChildOf($t3); + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 13, 1), + 't4' => array(11, 12, 2), + 't5' => array(5, 10, 2), + 't6' => array(6, 7, 3), + 't7' => array(8, 9, 3), + ); + $this->assertEquals($expected, $this->dumpTree(), 'moveToFirstChildOf() moves the entire subtree to the same level correctly'); + } + + public function testMoveToFirstChildOfAndChildrenCache() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + // fill children cache + $t3->getChildren(); + $t1->getChildren(); + // move + $t5->moveToFirstChildOf($t1); + $children = $t3->getChildren(); + $expected = array( + 't4' => array(11, 12, 2), + ); + $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToFirstChildOf() reinitializes the child collection of all concerned nodes'); + $children = $t1->getChildren(); + $expected = array( + 't5' => array(2, 7, 1), + 't2' => array(8, 9, 1), + 't3' => array(10, 13, 1), + ); + $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToFirstChildOf() reinitializes the child collection of all concerned nodes'); + } + + public function testMoveToLastChildOf() + { + $this->assertTrue(method_exists('Table9', 'moveToLastChildOf'), 'nested_set adds a moveToLastChildOf() method'); + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + try { + $t3->moveToLastChildOf($t5); + $this->fail('moveToLastChildOf() throws an exception when the target is a child node'); + } catch (PropelException $e) { + $this->assertTrue(true, 'moveToLastChildOf() throws an exception when the target is a child node'); + } + // moving up + $t = $t5->moveToLastChildOf($t1); + $this->assertEquals($t5, $t, 'moveToLastChildOf() returns the object it was called on'); + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 7, 1), + 't4' => array(5, 6, 2), + 't5' => array(8, 13, 1), + 't6' => array(9, 10, 2), + 't7' => array(11, 12, 2), + ); + $this->assertEquals($expected, $this->dumpTree(), 'moveToLastChildOf() moves the entire subtree up correctly'); + // moving down + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + $t3->moveToLastChildOf($t2); + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 13, 1), + 't3' => array(3, 12, 2), + 't4' => array(4, 5, 3), + 't5' => array(6, 11, 3), + 't6' => array(7, 8, 4), + 't7' => array(9, 10, 4), + ); + $this->assertEquals($expected, $this->dumpTree(), 'moveToLastChildOf() moves the entire subtree down correctly'); + // moving to the same level + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + $t4->moveToLastChildOf($t3); + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 13, 1), + 't4' => array(11, 12, 2), + 't5' => array(5, 10, 2), + 't6' => array(6, 7, 3), + 't7' => array(8, 9, 3), + ); + $this->assertEquals($expected, $this->dumpTree(), 'moveToLastChildOf() moves the entire subtree to the same level correctly'); + } + + public function testMoveToLastChildOfAndChildrenCache() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + // fill children cache + $t3->getChildren(); + $t1->getChildren(); + // move + $t5->moveToLastChildOf($t1); + $children = $t3->getChildren(); + $expected = array( + 't4' => array(5, 6, 2), + ); + $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToLastChildOf() reinitializes the child collection of all concerned nodes'); + $children = $t1->getChildren(); + $expected = array( + 't2' => array(2, 3, 1), + 't3' => array(4, 7, 1), + 't5' => array(8, 13, 1), + ); + $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToLastChildOf() reinitializes the child collection of all concerned nodes'); + } + + public function testMoveToPrevSiblingOf() + { + $this->assertTrue(method_exists('Table9', 'moveToPrevSiblingOf'), 'nested_set adds a moveToPrevSiblingOf() method'); + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + try { + $t5->moveToPrevSiblingOf($t1); + $this->fail('moveToPrevSiblingOf() throws an exception when the target is a root node'); + } catch (PropelException $e) { + $this->assertTrue(true, 'moveToPrevSiblingOf() throws an exception when the target is a root node'); + } + try { + $t5->moveToPrevSiblingOf($t6); + $this->fail('moveToPrevSiblingOf() throws an exception when the target is a child node'); + } catch (PropelException $e) { + $this->assertTrue(true, 'moveToPrevSiblingOf() throws an exception when the target is a child node'); + } + // moving up + $t = $t5->moveToPrevSiblingOf($t3); + /* Results in + t1 + | \ \ + t2 t5 t3 + | \ | + t6 t7 t4 + */ + $this->assertEquals($t5, $t, 'moveToPrevSiblingOf() returns the object it was called on'); + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(10, 13, 1), + 't4' => array(11, 12, 2), + 't5' => array(4, 9, 1), + 't6' => array(5, 6, 2), + 't7' => array(7, 8, 2), + ); + $this->assertEquals($expected, $this->dumpTree(), 'moveToPrevSiblingOf() moves the entire subtree up correctly'); + // moving down + $t5->moveToPrevSiblingOf($t4); + /* Results in + t1 + | \ + t2 t3 + | \ + t5 t4 + | \ + t6 t7 + */ + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 13, 1), + 't4' => array(11, 12, 2), + 't5' => array(5, 10, 2), + 't6' => array(6, 7, 3), + 't7' => array(8, 9, 3), + ); + $this->assertEquals($expected, $this->dumpTree(), 'moveToPrevSiblingOf() moves the entire subtree down correctly'); + // moving at the same level + $t4->moveToPrevSiblingOf($t5); + /* Results in + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 13, 1), + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + 't6' => array(8, 9, 3), + 't7' => array(10, 11, 3), + ); + $this->assertEquals($expected, $this->dumpTree(), 'moveToPrevSiblingOf() moves the entire subtree at the same level correctly'); + } + + public function testMoveToPrevSiblingOfAndChildrenCache() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + // fill children cache + $t3->getChildren(); + $t1->getChildren(); + // move + $t5->moveToPrevSiblingOf($t2); + $children = $t3->getChildren(); + $expected = array( + 't4' => array(11, 12, 2), + ); + $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToPrevSiblingOf() reinitializes the child collection of all concerned nodes'); + $children = $t1->getChildren(); + $expected = array( + 't5' => array(2, 7, 1), + 't2' => array(8, 9, 1), + 't3' => array(10, 13, 1), + ); + $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToPrevSiblingOf() reinitializes the child collection of all concerned nodes'); + } + + public function testMoveToNextSiblingOfAndChildrenCache() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + // fill children cache + $t3->getChildren(); + $t1->getChildren(); + // move + $t5->moveToNextSiblingOf($t3); + $children = $t3->getChildren(); + $expected = array( + 't4' => array(5, 6, 2), + ); + $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToNextSiblingOf() reinitializes the child collection of all concerned nodes'); + $children = $t1->getChildren(); + $expected = array( + 't2' => array(2, 3, 1), + 't3' => array(4, 7, 1), + 't5' => array(8, 13, 1), + ); + $this->assertEquals($expected, $this->dumpNodes($children, true), 'moveToNextSiblingOf() reinitializes the child collection of all concerned nodes'); + } + + public function testMoveToNextSiblingOf() + { + $this->assertTrue(method_exists('Table9', 'moveToNextSiblingOf'), 'nested_set adds a moveToNextSiblingOf() method'); + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + try { + $t5->moveToNextSiblingOf($t1); + $this->fail('moveToNextSiblingOf() throws an exception when the target is a root node'); + } catch (PropelException $e) { + $this->assertTrue(true, 'moveToNextSiblingOf() throws an exception when the target is a root node'); + } + try { + $t5->moveToNextSiblingOf($t6); + $this->fail('moveToNextSiblingOf() throws an exception when the target is a child node'); + } catch (PropelException $e) { + $this->assertTrue(true, 'moveToNextSiblingOf() throws an exception when the target is a child node'); + } + // moving up + $t = $t5->moveToNextSiblingOf($t3); + /* Results in + t1 + | \ \ + t2 t3 t5 + | | \ + t4 t6 t7 + */ + $this->assertEquals($t5, $t, 'moveToPrevSiblingOf() returns the object it was called on'); + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 7, 1), + 't4' => array(5, 6, 2), + 't5' => array(8, 13, 1), + 't6' => array(9, 10, 2), + 't7' => array(11, 12, 2), + ); + $this->assertEquals($expected, $this->dumpTree(), 'moveToNextSiblingOf() moves the entire subtree up correctly'); + // moving down + $t = $t5->moveToNextSiblingOf($t4); + /* Results in + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 13, 1), + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + 't6' => array(8, 9, 3), + 't7' => array(10, 11, 3), + ); + $this->assertEquals($expected, $this->dumpTree(), 'moveToNextSiblingOf() moves the entire subtree down correctly'); + // moving at the same level + $t = $t4->moveToNextSiblingOf($t5); + /* Results in + t1 + | \ + t2 t3 + | \ + t5 t4 + | \ + t6 t7 + */ + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 13, 1), + 't4' => array(11, 12, 2), + 't5' => array(5, 10, 2), + 't6' => array(6, 7, 3), + 't7' => array(8, 9, 3), + ); + $this->assertEquals($expected, $this->dumpTree(), 'moveToNextSiblingOf() moves the entire subtree at the same level correctly'); + } + + public function testDeleteDescendants() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $this->assertNull($t2->deleteDescendants(), 'deleteDescendants() returns null leafs'); + $this->assertEquals(4, $t3->deleteDescendants(), 'deleteDescendants() returns the number of deleted nodes'); + $this->assertEquals(5, $t3->getRightValue(), 'deleteDescendants() updates the current node'); + $this->assertEquals(5, $t4->getLeftValue(), 'deleteDescendants() does not update existing nodes (because delete() clears the instance cache)'); + $expected = array( + 't1' => array(1, 6, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 5, 1), + ); + $this->assertEquals($expected, $this->dumpTree(), 'deleteDescendants() shifts the entire subtree correctly'); + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $this->assertEquals(6, $t1->deleteDescendants(), 'deleteDescendants() can be called on the root node'); + $expected = array( + 't1' => array(1, 2, 0), + ); + $this->assertEquals($expected, $this->dumpTree(), 'deleteDescendants() can delete all descendants of the root node'); + } + + public function testGetIterator() + { + $fixtures = $this->initTree(); + $this->assertTrue(method_exists('Table9', 'getIterator'), 'nested_set adds a getIterator() method'); + $root = Table9Peer::retrieveRoot(); + $iterator = $root->getIterator(); + $this->assertTrue($iterator instanceof NestedSetRecursiveIterator, 'getIterator() returns a NestedSetRecursiveIterator'); + foreach ($iterator as $node) { + $expected = array_shift($fixtures); + $this->assertEquals($expected, $node, 'getIterator returns an iterator parsing the tree order by left column'); + } + } + + public function testCompatibilityProxies() + { + $proxies = array('createRoot', 'retrieveParent', 'setParentNode', 'getNumberOfDescendants', 'getNumberOfChildren', 'retrievePrevSibling', 'retrieveNextSibling', 'retrieveFirstChild', 'retrieveLastChild', 'getPath'); + foreach ($proxies as $method) { + $this->assertFalse(method_exists('Table9', $method), 'proxies are not enabled by default'); + $this->assertTrue(method_exists('Table10', $method), 'setting method_proxies to true adds compatibility proxies'); + } + } + + public function testCreateRoot() + { + $t = new Table10(); + $t->createRoot(); + $this->assertEquals($t->getLeftValue(), 1, 'createRoot() is an alias for makeRoot()'); + $this->assertEquals($t->getRightValue(), 2, 'createRoot() is an alias for makeRoot()'); + $this->assertEquals($t->getLevel(), 0, 'createRoot() is an alias for makeRoot()'); + } + + public function testGetPath() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $this->assertEquals(array($t1), $t1->getPath(), 'getPath() returns the current object for roots'); + $path = $t5->getPath(); + $expected = array( + 't1' => array(1, 14, 0), + 't3' => array(4, 13, 1), + 't5' => array(7, 12, 2), + ); + $this->assertEquals($expected, $this->dumpNodes($path), 'getPath() returns path from the current scope only'); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php index 439ff588f..6b78c99c5 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorObjectBuilderModifierWithScopeTest.php @@ -1,7 +1,7 @@ add(Table10Peer::TITLE, $title); - return Table10Peer::doSelectOne($c); - } +class NestedSetBehaviorObjectBuilderModifierWithScopeTest extends BookstoreNestedSetTestBase +{ + protected function getByTitle($title) + { + $c = new Criteria(); + $c->add(Table10Peer::TITLE, $title); - public function testDelete() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $t5->delete(); - $expected = array( - 't1' => array(1, 8, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 7, 1), - 't4' => array(5, 6, 2), - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'delete() deletes all descendants and shifts the entire subtree correctly'); - $expected = array( - 't8' => array(1, 6, 0), - 't9' => array(2, 3, 1), - 't10' => array(4, 5, 1), - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'delete() does not delete anything out of the scope'); - } - - public function testIsDescendantOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $this->assertFalse($t8->isDescendantOf($t9), 'root is not seen as a child of root'); - $this->assertTrue($t9->isDescendantOf($t8), 'direct child is seen as a child of root'); - try { - $t2->isDescendantOf($t8); - $this->fail('isDescendantOf() throws an exception when comparing two nodes of different trees'); - } catch (PropelException $e) { - $this->assertTrue(true, 'isDescendantOf() throws an exception when comparing two nodes of different trees'); - } - } - - public function testGetParent() - { - $this->initTreeWithScope(); - $t1 = $this->getByTitle('t1'); - $this->assertNull($t1->getParent($this->con), 'getParent() return null for root nodes'); - $t2 = $this->getByTitle('t2'); - $this->assertEquals($t2->getParent($this->con), $t1, 'getParent() correctly retrieves parent for leafs'); - $t3 = $this->getByTitle('t3'); - $this->assertEquals($t3->getParent($this->con), $t1, 'getParent() correctly retrieves parent for nodes'); - $t4 = $this->getByTitle('t4'); - $this->assertEquals($t4->getParent($this->con), $t3, 'getParent() retrieves the same parent for nodes'); - } - - public function testGetPrevSibling() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $this->assertNull($t1->getPrevSibling($this->con), 'getPrevSibling() returns null for root nodes'); - $this->assertNull($t2->getPrevSibling($this->con), 'getPrevSibling() returns null for first siblings'); - $this->assertEquals($t3->getPrevSibling($this->con), $t2, 'getPrevSibling() correctly retrieves prev sibling'); - $this->assertNull($t6->getPrevSibling($this->con), 'getPrevSibling() returns null for first siblings'); - $this->assertEquals($t7->getPrevSibling($this->con), $t6, 'getPrevSibling() correctly retrieves prev sibling'); - } - - public function testGetNextSibling() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $this->assertNull($t1->getNextSibling($this->con), 'getNextSibling() returns null for root nodes'); - $this->assertEquals($t2->getNextSibling($this->con), $t3, 'getNextSibling() correctly retrieves next sibling'); - $this->assertNull($t3->getNextSibling($this->con), 'getNextSibling() returns null for last siblings'); - $this->assertEquals($t6->getNextSibling($this->con), $t7, 'getNextSibling() correctly retrieves next sibling'); - $this->assertNull($t7->getNextSibling($this->con), 'getNextSibling() returns null for last siblings'); - } - - public function testGetDescendants() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $descendants = $t3->getDescendants(); - $expected = array( - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - 't6' => array(8, 9, 3), - 't7' => array(10, 11, 3), - ); - $this->assertEquals($expected, $this->dumpNodes($descendants), 'getDescendants() returns descendants from the current scope only'); - } - - public function testGetAncestors() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $this->assertEquals(array(), $t1->getAncestors(), 'getAncestors() returns an empty array for roots'); - $ancestors = $t5->getAncestors(); - $expected = array( - 't1' => array(1, 14, 0), - 't3' => array(4, 13, 1), - ); - $this->assertEquals($expected, $this->dumpNodes($ancestors), 'getAncestors() returns ancestors from the current scope only'); - } - - public function testInsertAsFirstChildOf() - { - $this->assertTrue(method_exists('Table10', 'insertAsFirstChildOf'), 'nested_set adds a insertAsFirstChildOf() method'); - $fixtures = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $t11 = new PublicTable10(); - $t11->setTitle('t11'); - $t11->insertAsFirstChildOf($fixtures[2]); // first child of t3 - $this->assertEquals(1, $t11->getScopeValue(), 'insertAsFirstChildOf() sets the scope value correctly'); - $t11->save(); - $expected = array( - 't1' => array(1, 16, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 15, 1), - 't4' => array(7, 8, 2), - 't5' => array(9, 14, 2), - 't6' => array(10, 11, 3), - 't7' => array(12, 13, 3), - 't11' => array(5, 6, 2) - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'insertAsFirstChildOf() shifts the other nodes correctly'); - $expected = array( - 't8' => array(1, 6, 0), - 't9' => array(2, 3, 1), - 't10' => array(4, 5, 1), - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'insertAsFirstChildOf() does not shift anything out of the scope'); - } + return Table10Peer::doSelectOne($c); + } - public function testInsertAsLastChildOf() - { - $this->assertTrue(method_exists('Table10', 'insertAsLastChildOf'), 'nested_set adds a insertAsLastChildOf() method'); - $fixtures = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $t11 = new PublicTable10(); - $t11->setTitle('t11'); - $t11->insertAsLastChildOf($fixtures[2]); // last child of t3 - $this->assertEquals(1, $t11->getScopeValue(), 'insertAsLastChildOf() sets the scope value correctly'); - $t11->save(); - $expected = array( - 't1' => array(1, 16, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 15, 1), - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - 't6' => array(8, 9, 3), - 't7' => array(10, 11, 3), - 't11' => array(13, 14, 2) - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'insertAsLastChildOf() shifts the other nodes correctly'); - $expected = array( - 't8' => array(1, 6, 0), - 't9' => array(2, 3, 1), - 't10' => array(4, 5, 1), - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'insertAsLastChildOf() does not shift anything out of the scope'); - } + /** + * @expectedException PropelException + */ + public function testSaveRootInTreeWithExistingRootWithSameScope() + { + Table10Peer::doDeleteAll(); + $t1 = new Table10(); + $t1->setScopeValue(1); + $t1->makeRoot(); + $t1->save(); + $t2 = new Table10(); + $t2->setScopeValue(1); + $t2->makeRoot(); + $t2->save(); + } - public function testInsertAsPrevSiblingOf() - { - $this->assertTrue(method_exists('Table10', 'insertAsPrevSiblingOf'), 'nested_set adds a insertAsPrevSiblingOf() method'); - $fixtures = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $t11 = new PublicTable10(); - $t11->setTitle('t11'); - $t11->insertAsPrevSiblingOf($fixtures[2]); // prev sibling of t3 - $this->assertEquals(1, $t11->getScopeValue(), 'insertAsPrevSiblingOf() sets the scope value correctly'); - $t11->save(); - $expected = array( - 't1' => array(1, 16, 0), - 't2' => array(2, 3, 1), - 't3' => array(6, 15, 1), - 't4' => array(7, 8, 2), - 't5' => array(9, 14, 2), - 't6' => array(10, 11, 3), - 't7' => array(12, 13, 3), - 't11' => array(4, 5, 1) - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'insertAsPrevSiblingOf() shifts the other nodes correctly'); - $expected = array( - 't8' => array(1, 6, 0), - 't9' => array(2, 3, 1), - 't10' => array(4, 5, 1), - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'insertAsPrevSiblingOf() does not shift anything out of the scope'); - } + public function testSaveRootInTreeWithExistingRootWithDifferentScope() + { + Table10Peer::doDeleteAll(); + $t1 = new Table10(); + $t1->setScopeValue(1); + $t1->makeRoot(); + $t1->save(); + $t2 = new Table10(); + $t2->setScopeValue(2); + $t2->makeRoot(); + $t2->save(); + $this->assertTrue(!$t2->isNew()); + } - public function testInsertAsNextSiblingOf() - { - $this->assertTrue(method_exists('Table10', 'insertAsNextSiblingOf'), 'nested_set adds a insertAsNextSiblingOf() method'); - $fixtures = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $t11 = new PublicTable10(); - $t11->setTitle('t11'); - $t11->insertAsNextSiblingOf($fixtures[2]); // next sibling of t3 - $this->assertEquals(1, $t11->getScopeValue(), 'insertAsNextSiblingOf() sets the scope value correctly'); - $t11->save(); - $expected = array( - 't1' => array(1, 16, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 13, 1), - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - 't6' => array(8, 9, 3), - 't7' => array(10, 11, 3), - 't11' => array(14, 15, 1) - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'insertAsNextSiblingOf() shifts the other nodes correctly'); - $expected = array( - 't8' => array(1, 6, 0), - 't9' => array(2, 3, 1), - 't10' => array(4, 5, 1), - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'insertAsNextSiblingOf() does not shift anything out of the scope'); - } - - public function testMoveToFirstChildOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - try { - $t8->moveToFirstChildOf($t3); - $this->fail('moveToFirstChildOf() throws an exception when the target is in a different tree'); - } catch (PropelException $e) { - $this->assertTrue(true, 'moveToFirstChildOf() throws an exception when the target is in a different tree'); - } - try { - $t5->moveToLastChildOf($t2); - $this->assertTrue(true, 'moveToFirstChildOf() does not throw an exception when the target is in the same tree'); - } catch (PropelException $e) { - $this->fail('moveToFirstChildOf() does not throw an exception when the target is in the same tree'); - } - $expected = array( - 't8' => array(1, 6, 0), - 't9' => array(2, 3, 1), - 't10' => array(4, 5, 1), - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'moveToFirstChildOf() does not shift anything out of the scope'); - } - - public function testMoveToLastChildOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - try { - $t8->moveToLastChildOf($t3); - $this->fail('moveToLastChildOf() throws an exception when the target is in a different tree'); - } catch (PropelException $e) { - $this->assertTrue(true, 'moveToLastChildOf() throws an exception when the target is in a different tree'); - } - try { - $t5->moveToLastChildOf($t2); - $this->assertTrue(true, 'moveToLastChildOf() does not throw an exception when the target is in the same tree'); - } catch (PropelException $e) { - $this->fail('moveToLastChildOf() does not throw an exception when the target is in the same tree'); - } - $expected = array( - 't8' => array(1, 6, 0), - 't9' => array(2, 3, 1), - 't10' => array(4, 5, 1), - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'moveToLastChildOf() does not shift anything out of the scope'); - } + public function testDelete() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $t5->delete(); + $expected = array( + 't1' => array(1, 8, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 7, 1), + 't4' => array(5, 6, 2), + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'delete() deletes all descendants and shifts the entire subtree correctly'); + $expected = array( + 't8' => array(1, 6, 0), + 't9' => array(2, 3, 1), + 't10' => array(4, 5, 1), + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'delete() does not delete anything out of the scope'); + } - public function testMoveToPrevSiblingOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - try { - $t8->moveToPrevSiblingOf($t3); - $this->fail('moveToPrevSiblingOf() throws an exception when the target is in a different tree'); - } catch (PropelException $e) { - $this->assertTrue(true, 'moveToPrevSiblingOf() throws an exception when the target is in a different tree'); - } - try { - $t5->moveToPrevSiblingOf($t2); - $this->assertTrue(true, 'moveToPrevSiblingOf() does not throw an exception when the target is in the same tree'); - } catch (PropelException $e) { - $this->fail('moveToPrevSiblingOf() does not throw an exception when the target is in the same tree'); - } - $expected = array( - 't8' => array(1, 6, 0), - 't9' => array(2, 3, 1), - 't10' => array(4, 5, 1), - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'moveToPrevSiblingOf() does not shift anything out of the scope'); - } + public function testIsDescendantOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $this->assertFalse($t8->isDescendantOf($t9), 'root is not seen as a child of root'); + $this->assertTrue($t9->isDescendantOf($t8), 'direct child is seen as a child of root'); + $this->assertFalse($t2->isDescendantOf($t8), 'is false, since both are in different scopes'); + } - public function testMoveToNextSiblingOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - try { - $t8->moveToNextSiblingOf($t3); - $this->fail('moveToNextSiblingOf() throws an exception when the target is in a different tree'); - } catch (PropelException $e) { - $this->assertTrue(true, 'moveToNextSiblingOf() throws an exception when the target is in a different tree'); - } - try { - $t5->moveToNextSiblingOf($t2); - $this->assertTrue(true, 'moveToNextSiblingOf() does not throw an exception when the target is in the same tree'); - } catch (PropelException $e) { - $this->fail('moveToNextSiblingOf() does not throw an exception when the target is in the same tree'); - } - $expected = array( - 't8' => array(1, 6, 0), - 't9' => array(2, 3, 1), - 't10' => array(4, 5, 1), - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'moveToNextSiblingOf() does not shift anything out of the scope'); - } + public function testGetParent() + { + $this->initTreeWithScope(); + $t1 = $this->getByTitle('t1'); + $this->assertNull($t1->getParent($this->con), 'getParent() return null for root nodes'); + $t2 = $this->getByTitle('t2'); + $this->assertEquals($t2->getParent($this->con), $t1, 'getParent() correctly retrieves parent for leafs'); + $t3 = $this->getByTitle('t3'); + $this->assertEquals($t3->getParent($this->con), $t1, 'getParent() correctly retrieves parent for nodes'); + $t4 = $this->getByTitle('t4'); + $this->assertEquals($t4->getParent($this->con), $t3, 'getParent() retrieves the same parent for nodes'); + } - public function testDeleteDescendants() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $this->assertEquals(4, $t3->deleteDescendants(), 'deleteDescendants() returns the number of deleted nodes'); - $expected = array( - 't1' => array(1, 6, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 5, 1), - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'deleteDescendants() shifts the entire subtree correctly'); - $expected = array( - 't8' => array(1, 6, 0), - 't9' => array(2, 3, 1), - 't10' => array(4, 5, 1), - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'deleteDescendants() does not delete anything out of the scope'); - } -} \ No newline at end of file + public function testGetPrevSibling() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $this->assertNull($t1->getPrevSibling($this->con), 'getPrevSibling() returns null for root nodes'); + $this->assertNull($t2->getPrevSibling($this->con), 'getPrevSibling() returns null for first siblings'); + $this->assertEquals($t3->getPrevSibling($this->con), $t2, 'getPrevSibling() correctly retrieves prev sibling'); + $this->assertNull($t6->getPrevSibling($this->con), 'getPrevSibling() returns null for first siblings'); + $this->assertEquals($t7->getPrevSibling($this->con), $t6, 'getPrevSibling() correctly retrieves prev sibling'); + } + + public function testGetNextSibling() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $this->assertNull($t1->getNextSibling($this->con), 'getNextSibling() returns null for root nodes'); + $this->assertEquals($t2->getNextSibling($this->con), $t3, 'getNextSibling() correctly retrieves next sibling'); + $this->assertNull($t3->getNextSibling($this->con), 'getNextSibling() returns null for last siblings'); + $this->assertEquals($t6->getNextSibling($this->con), $t7, 'getNextSibling() correctly retrieves next sibling'); + $this->assertNull($t7->getNextSibling($this->con), 'getNextSibling() returns null for last siblings'); + } + + public function testGetDescendants() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $descendants = $t3->getDescendants(); + $expected = array( + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + 't6' => array(8, 9, 3), + 't7' => array(10, 11, 3), + ); + $this->assertEquals($expected, $this->dumpNodes($descendants), 'getDescendants() returns descendants from the current scope only'); + } + + public function testGetAncestors() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $this->assertEquals(array(), $t1->getAncestors(), 'getAncestors() returns an empty array for roots'); + $ancestors = $t5->getAncestors(); + $expected = array( + 't1' => array(1, 14, 0), + 't3' => array(4, 13, 1), + ); + $this->assertEquals($expected, $this->dumpNodes($ancestors), 'getAncestors() returns ancestors from the current scope only'); + } + + public function testInsertAsFirstChildOf() + { + $this->assertTrue(method_exists('Table10', 'insertAsFirstChildOf'), 'nested_set adds a insertAsFirstChildOf() method'); + $fixtures = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $t11 = new PublicTable10(); + $t11->setTitle('t11'); + $t11->insertAsFirstChildOf($fixtures[2]); // first child of t3 + $this->assertEquals(1, $t11->getScopeValue(), 'insertAsFirstChildOf() sets the scope value correctly'); + $t11->save(); + $expected = array( + 't1' => array(1, 16, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 15, 1), + 't4' => array(7, 8, 2), + 't5' => array(9, 14, 2), + 't6' => array(10, 11, 3), + 't7' => array(12, 13, 3), + 't11' => array(5, 6, 2) + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'insertAsFirstChildOf() shifts the other nodes correctly'); + $expected = array( + 't8' => array(1, 6, 0), + 't9' => array(2, 3, 1), + 't10' => array(4, 5, 1), + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'insertAsFirstChildOf() does not shift anything out of the scope'); + } + + public function testInsertAsFirstChildOfExistingObject() + { + Table10Query::create()->deleteAll(); + $t = new Table10(); + $t->setScopeValue(34); + $t->makeRoot(); + $t->save(); + $this->assertEquals(1, $t->getLeftValue()); + $this->assertEquals(2, $t->getRightValue()); + $this->assertEquals(0, $t->getLevel()); + $t1 = new Table10(); + $t1->save(); + $t1->insertAsFirstChildOf($t); + $this->assertEquals(2, $t1->getLeftValue()); + $this->assertEquals(3, $t1->getRightValue()); + $this->assertEquals(34, $t1->getScopeValue()); + $this->assertEquals(1, $t1->getLevel()); + $t1->save(); + $this->assertEquals(1, $t->getLeftValue()); + $this->assertEquals(4, $t->getRightValue()); + $this->assertEquals(0, $t->getLevel()); + $this->assertEquals(2, $t1->getLeftValue()); + $this->assertEquals(3, $t1->getRightValue()); + $this->assertEquals(34, $t1->getScopeValue()); + $this->assertEquals(1, $t1->getLevel()); + } + + public function testInsertAsLastChildOf() + { + $this->assertTrue(method_exists('Table10', 'insertAsLastChildOf'), 'nested_set adds a insertAsLastChildOf() method'); + $fixtures = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $t11 = new PublicTable10(); + $t11->setTitle('t11'); + $t11->insertAsLastChildOf($fixtures[2]); // last child of t3 + $this->assertEquals(1, $t11->getScopeValue(), 'insertAsLastChildOf() sets the scope value correctly'); + $t11->save(); + $expected = array( + 't1' => array(1, 16, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 15, 1), + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + 't6' => array(8, 9, 3), + 't7' => array(10, 11, 3), + 't11' => array(13, 14, 2) + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'insertAsLastChildOf() shifts the other nodes correctly'); + $expected = array( + 't8' => array(1, 6, 0), + 't9' => array(2, 3, 1), + 't10' => array(4, 5, 1), + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'insertAsLastChildOf() does not shift anything out of the scope'); + } + + public function testInsertAsLastChildOfExistingObject() + { + Table10Query::create()->deleteAll(); + $t = new Table10(); + $t->setScopeValue(34); + $t->makeRoot(); + $t->save(); + $this->assertEquals(1, $t->getLeftValue()); + $this->assertEquals(2, $t->getRightValue()); + $this->assertEquals(0, $t->getLevel()); + $t1 = new Table10(); + $t1->save(); + $t1->insertAsLastChildOf($t); + $this->assertEquals(2, $t1->getLeftValue()); + $this->assertEquals(3, $t1->getRightValue()); + $this->assertEquals(34, $t1->getScopeValue()); + $this->assertEquals(1, $t1->getLevel()); + $t1->save(); + $this->assertEquals(1, $t->getLeftValue()); + $this->assertEquals(4, $t->getRightValue()); + $this->assertEquals(0, $t->getLevel()); + $this->assertEquals(2, $t1->getLeftValue()); + $this->assertEquals(3, $t1->getRightValue()); + $this->assertEquals(34, $t1->getScopeValue()); + $this->assertEquals(1, $t1->getLevel()); + } + + public function testInsertAsPrevSiblingOf() + { + $this->assertTrue(method_exists('Table10', 'insertAsPrevSiblingOf'), 'nested_set adds a insertAsPrevSiblingOf() method'); + $fixtures = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $t11 = new PublicTable10(); + $t11->setTitle('t11'); + $t11->insertAsPrevSiblingOf($fixtures[2]); // prev sibling of t3 + $this->assertEquals(1, $t11->getScopeValue(), 'insertAsPrevSiblingOf() sets the scope value correctly'); + $t11->save(); + $expected = array( + 't1' => array(1, 16, 0), + 't2' => array(2, 3, 1), + 't3' => array(6, 15, 1), + 't4' => array(7, 8, 2), + 't5' => array(9, 14, 2), + 't6' => array(10, 11, 3), + 't7' => array(12, 13, 3), + 't11' => array(4, 5, 1) + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'insertAsPrevSiblingOf() shifts the other nodes correctly'); + $expected = array( + 't8' => array(1, 6, 0), + 't9' => array(2, 3, 1), + 't10' => array(4, 5, 1), + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'insertAsPrevSiblingOf() does not shift anything out of the scope'); + } + + public function testInsertAsPrevSiblingOfExistingObject() + { + Table10Query::create()->deleteAll(); + $t = new Table10(); + $t->setScopeValue(34); + $t->makeRoot(); + $t->save(); + $t1 = new Table10(); + $t1->insertAsFirstChildOf($t); + $t1->save(); + $this->assertEquals(1, $t->getLeftValue()); + $this->assertEquals(4, $t->getRightValue()); + $this->assertEquals(0, $t->getLevel()); + $this->assertEquals(2, $t1->getLeftValue()); + $this->assertEquals(3, $t1->getRightValue()); + $this->assertEquals(34, $t1->getScopeValue()); + $this->assertEquals(1, $t1->getLevel()); + $t2 = new Table10(); + $t2->save(); + $t2->insertAsPrevSiblingOf($t1); + $this->assertEquals(2, $t2->getLeftValue()); + $this->assertEquals(3, $t2->getRightValue()); + $this->assertEquals(34, $t2->getScopeValue()); + $this->assertEquals(1, $t2->getLevel()); + $t2->save(); + $this->assertEquals(1, $t->getLeftValue()); + $this->assertEquals(6, $t->getRightValue()); + $this->assertEquals(0, $t->getLevel()); + $this->assertEquals(4, $t1->getLeftValue()); + $this->assertEquals(5, $t1->getRightValue()); + $this->assertEquals(34, $t1->getScopeValue()); + $this->assertEquals(1, $t1->getLevel()); + $this->assertEquals(2, $t2->getLeftValue()); + $this->assertEquals(3, $t2->getRightValue()); + $this->assertEquals(34, $t2->getScopeValue()); + $this->assertEquals(1, $t2->getLevel()); + } + + public function testInsertAsNextSiblingOf() + { + $this->assertTrue(method_exists('Table10', 'insertAsNextSiblingOf'), 'nested_set adds a insertAsNextSiblingOf() method'); + $fixtures = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $t11 = new PublicTable10(); + $t11->setTitle('t11'); + $t11->insertAsNextSiblingOf($fixtures[2]); // next sibling of t3 + $this->assertEquals(1, $t11->getScopeValue(), 'insertAsNextSiblingOf() sets the scope value correctly'); + $t11->save(); + $expected = array( + 't1' => array(1, 16, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 13, 1), + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + 't6' => array(8, 9, 3), + 't7' => array(10, 11, 3), + 't11' => array(14, 15, 1) + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'insertAsNextSiblingOf() shifts the other nodes correctly'); + $expected = array( + 't8' => array(1, 6, 0), + 't9' => array(2, 3, 1), + 't10' => array(4, 5, 1), + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'insertAsNextSiblingOf() does not shift anything out of the scope'); + } + + public function testInsertAsNextSiblingOfExistingObject() + { + Table10Query::create()->deleteAll(); + $t = new Table10(); + $t->setScopeValue(34); + $t->makeRoot(); + $t->save(); + $t1 = new Table10(); + $t1->insertAsFirstChildOf($t); + $t1->save(); + $this->assertEquals(1, $t->getLeftValue()); + $this->assertEquals(4, $t->getRightValue()); + $this->assertEquals(0, $t->getLevel()); + $this->assertEquals(2, $t1->getLeftValue()); + $this->assertEquals(3, $t1->getRightValue()); + $this->assertEquals(34, $t1->getScopeValue()); + $this->assertEquals(1, $t1->getLevel()); + $t2 = new Table10(); + $t2->save(); + $t2->insertAsNextSiblingOf($t1); + $this->assertEquals(4, $t2->getLeftValue()); + $this->assertEquals(5, $t2->getRightValue()); + $this->assertEquals(34, $t2->getScopeValue()); + $this->assertEquals(1, $t2->getLevel()); + $t2->save(); + $this->assertEquals(1, $t->getLeftValue()); + $this->assertEquals(6, $t->getRightValue()); + $this->assertEquals(0, $t->getLevel()); + $this->assertEquals(2, $t1->getLeftValue()); + $this->assertEquals(3, $t1->getRightValue()); + $this->assertEquals(34, $t1->getScopeValue()); + $this->assertEquals(1, $t1->getLevel()); + $this->assertEquals(4, $t2->getLeftValue()); + $this->assertEquals(5, $t2->getRightValue()); + $this->assertEquals(34, $t2->getScopeValue()); + $this->assertEquals(1, $t2->getLevel()); + } + + public function testMoveToFirstChildOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + + $this->assertEquals(13, $t3->getRightValue(), 't3 left has 13 per init'); + $this->assertEquals(1, $t10->getLevel(), 'Init level is 1'); + + $t10->moveToFirstChildOf($t2); + + $this->assertEquals(2, $t2->getLeftValue(), 'As before'); + $this->assertEquals(5, $t2->getRightValue(), 'Extended by 2'); + + $this->assertEquals(3, $t10->getLeftValue(), 'Moved into t2'); + $this->assertEquals(4, $t10->getRightValue(), 'Moved into t2'); + + $this->assertEquals(2, $t10->getLevel(), 'New level is 2'); + + $this->assertEquals($t2->getScopeValue(), $t10->getScopeValue(), 'Should have now the same scope'); + + $expected = array( + 't8' => array(1, 4, 0), + 't9' => array(2, 3, 1) + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(2), 't10 removed from scope 2, therefore t8 `right` has been changed'); + $this->assertEquals(15, $t3->getRightValue(), 't3 has shifted by one item, so from 13 to 15'); + + //move t7 into t9, from scope 1 to scope 2 + $t7->moveToFirstChildOf($t9); + + $this->assertEquals(13, $t3->getRightValue(), 't3 `right` has now 15-2 => 13'); + $this->assertEquals(2, $t7->getScopeValue(), 't7 is now in scope 2'); + $this->assertEquals(6, $t8->getRightValue(), 't8 extended by 1 item, 4+2 => 6'); + $this->assertEquals(2, $t7->getLevel(), 'New level is 2'); + + //dispose scope 2 + $oldt4Left = $t4->getLeftValue(); + + $t8->moveToFirstChildOf($t3); + + $this->assertEquals($t3->getLeftValue()+1, $t8->getLeftValue(), 't8 has been moved to first children of t3'); + $this->assertEquals(19, $t3->getRightValue(), 't3 was extended for 3 more children, from 13+(3*2) to 19'); + $this->assertEquals($oldt4Left+(2*3), $t4->getLeftValue(), 't4 was moved by 3 items before it'); + $this->assertEquals(3, $t9->getLevel(), 'New level is 3'); + + $expected = array(); + $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'root of scope 2 to scope 1, therefore scope 2 is empty'); + + } + + public function testMoveToLastChildOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + + $this->assertEquals(13, $t3->getRightValue(), 't3 left has 13 per init'); + + $t10->moveToLastChildOf($t2); + + $this->assertEquals(2, $t2->getLeftValue(), 'As before'); + $this->assertEquals(5, $t2->getRightValue(), 'Extended by 2'); + + $this->assertEquals(3, $t10->getLeftValue(), 'Moved into t2'); + $this->assertEquals(4, $t10->getRightValue(), 'Moved into t2'); + $this->assertEquals(2, $t10->getLevel(), 'New level is 2'); + + $this->assertEquals($t2->getScopeValue(), $t10->getScopeValue(), 'Should have now the same scope'); + + $expected = array( + 't8' => array(1, 4, 0), + 't9' => array(2, 3, 1) + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(2), 't10 removed from scope 2, therefore t8 `right` has been changed'); + $this->assertEquals(15, $t3->getRightValue(), 't3 has shifted by one item, so from 13 to 15'); + + //move t7 into t9, from scope 1 to scope 2 + $t7->moveToLastChildOf($t9); + + $this->assertEquals(13, $t3->getRightValue(), 't3 `right` has now 15-2 => 13'); + $this->assertEquals(2, $t7->getScopeValue(), 't7 is now in scope 2'); + $this->assertEquals(6, $t8->getRightValue(), 't8 extended by 1 item, 4+2 => 6'); + $this->assertEquals(2, $t7->getLevel(), 'New level is 2'); + + //dispose scope 2 + $t8->moveToLastChildOf($t3); + + $this->assertEquals(13, $t8->getLeftValue(), 't8 has been moved to last children of t3'); + $this->assertEquals(19, $t3->getRightValue(), 't3 was extended for 3 more children, from 13+(3*2) to 19'); + $this->assertEquals(3, $t9->getLevel(), 'New level is 3'); + + $expected = array(); + $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'root of scope 2 to scope 1, therefore scope 2 is empty'); + + } + + public function testMoveToPrevSiblingOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + + $this->assertEquals(13, $t3->getRightValue(), 't3 left has 13 per init'); + $this->assertEquals(2, $t2->getLeftValue(), 'Init'); + $this->assertEquals(3, $t2->getRightValue(), 'Init'); + + $t10->moveToPrevSiblingOf($t2); + + $this->assertEquals(4, $t2->getLeftValue(), 'Move by one item, +2'); + $this->assertEquals(5, $t2->getRightValue(), 'Move by one item, +2'); + $this->assertEquals(1, $t10->getLevel(), 'Level is 1 as old'); + + $this->assertEquals(2, $t10->getLeftValue(), 'Moved before t2'); + $this->assertEquals(3, $t10->getRightValue(), 'Moved before t2'); + + $this->assertEquals($t2->getScopeValue(), $t10->getScopeValue(), 'Should have now the same scope'); + + $expected = array( + 't8' => array(1, 4, 0), + 't9' => array(2, 3, 1) + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(2), 't10 removed from scope 2, therefore t8 `right` has been changed'); + $this->assertEquals(15, $t3->getRightValue(), 't3 has shifted by one item, so from 13 to 15'); + + //move t7 before t9, from scope 1 to scope 2 + $t7->moveToPrevSiblingOf($t9); + + $this->assertEquals(13, $t3->getRightValue(), 't3 `right` has now 15-2 => 13'); + $this->assertEquals(2, $t7->getScopeValue(), 't7 is now in scope 2'); + $this->assertEquals(6, $t8->getRightValue(), 't8 extended by 1 item, 4+2 => 6'); + $this->assertEquals(1, $t7->getLevel(), 'New level is 1'); + + //dispose scope 2 + $t8->moveToPrevSiblingOf($t3); + + $this->assertEquals(6, $t8->getLeftValue(), 't8 has been moved to last children of t3'); + $this->assertEquals(19, $t3->getRightValue(), 't3 was moved for 3 item before it, so from 13+(3*2) to 19'); + $this->assertEquals(2, $t9->getLevel(), 'New level is 2'); + $this->assertEquals(1, $t8->getLevel(), 'New level is 1'); + + $expected = array(); + $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'root of scope 2 to scope 1, therefore scope 2 is empty'); + + } + + public function testMoveToNextSiblingOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + + $this->assertEquals(13, $t3->getRightValue(), 't3 left has 13 per init'); + $this->assertEquals(2, $t2->getLeftValue(), 'Init'); + $this->assertEquals(3, $t2->getRightValue(), 'Init'); + + $t10->moveToNextSiblingOf($t2); + + $this->assertEquals(2, $t2->getLeftValue(), 'Same as before'); + $this->assertEquals(3, $t2->getRightValue(), 'Same as before'); + $this->assertEquals(1, $t10->getLevel(), 'Level is 1 as before'); + + $this->assertEquals(6, $t3->getLeftValue(), 'Move by one item, +2'); + $this->assertEquals(15, $t3->getRightValue(), 'Move by one item, +2'); + + $this->assertEquals(4, $t10->getLeftValue(), 'Moved after t2'); + $this->assertEquals(5, $t10->getRightValue(), 'Moved after t2'); + + $this->assertEquals($t2->getScopeValue(), $t10->getScopeValue(), 'Should have now the same scope'); + + $expected = array( + 't8' => array(1, 4, 0), + 't9' => array(2, 3, 1) + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(2), 't10 removed from scope 2, therefore t8 `right` has been changed'); + $this->assertEquals(15, $t3->getRightValue(), 't3 has shifted by one item, so from 13 to 15'); + + //move t7 after t9, from scope 1 to scope 2 + $t7->moveToNextSiblingOf($t9); + + $this->assertEquals(13, $t3->getRightValue(), 't3 `right` has now 15-2 => 13'); + $this->assertEquals(2, $t7->getScopeValue(), 't7 is now in scope 2'); + $this->assertEquals(6, $t8->getRightValue(), 't8 extended by 1 item, 4+2 => 6'); + $this->assertEquals(1, $t7->getLevel(), 'New level is 1'); + + $this->assertEquals($t9->getRightValue()+1, $t7->getLeftValue(), 'Moved after t9, so we have t9.right+1 as left'); + + //dispose scope 2 + $oldT1Right = $t1->getRightValue(); + $t8->moveToNextSiblingOf($t3); + + $this->assertEquals($oldT1Right+(2*3), $t1->getRightValue(), 't1 has been extended by 3 items'); + $this->assertEquals(13, $t3->getRightValue(), 't3 has no change.'); + $this->assertEquals(1, $t8->getLevel(), 'New level is 1'); + $this->assertEquals(2, $t9->getLevel(), 'New level is 2'); + + $expected = array(); + $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'root of scope 2 to scope 1, therefore scope 2 is empty'); + + } + + public function testDeleteDescendants() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $this->assertEquals(4, $t3->deleteDescendants(), 'deleteDescendants() returns the number of deleted nodes'); + $expected = array( + 't1' => array(1, 6, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 5, 1), + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'deleteDescendants() shifts the entire subtree correctly'); + $expected = array( + 't8' => array(1, 6, 0), + 't9' => array(2, 3, 1), + 't10' => array(4, 5, 1), + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'deleteDescendants() does not delete anything out of the scope'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorPeerBuilderModifierTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorPeerBuilderModifierTest.php index 24555b3cd..46164c180 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorPeerBuilderModifierTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorPeerBuilderModifierTest.php @@ -1,7 +1,7 @@ assertEquals(Table9Peer::LEFT_COL, 'table9.TREE_LEFT', 'nested_set adds a LEFT_COL constant'); - $this->assertEquals(Table9Peer::RIGHT_COL, 'table9.TREE_RIGHT', 'nested_set adds a RIGHT_COL constant'); - $this->assertEquals(Table9Peer::LEVEL_COL, 'table9.TREE_LEVEL', 'nested_set adds a LEVEL_COL constant'); - } - - public function testRetrieveRoot() - { - $this->assertTrue(method_exists('Table9Peer', 'retrieveRoot'), 'nested_set adds a retrieveRoot() method'); - Table9Peer::doDeleteAll(); - $this->assertNull(Table9Peer::retrieveRoot(), 'retrieveRoot() returns null as long as no root node is defined'); - $t1 = new Table9(); - $t1->setLeftValue(123); - $t1->setRightValue(456); - $t1->save(); - $this->assertNull(Table9Peer::retrieveRoot(), 'retrieveRoot() returns null as long as no root node is defined'); - $t2 = new Table9(); - $t2->setLeftValue(1); - $t2->setRightValue(2); - $t2->save(); - $this->assertEquals(Table9Peer::retrieveRoot(), $t2, 'retrieveRoot() retrieves the root node'); - } - - public function testRetrieveTree() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - $tree = Table9Peer::retrieveTree(); - $this->assertEquals(array($t1, $t2, $t3, $t4, $t5, $t6, $t7), $tree, 'retrieveTree() retrieves the whole tree'); - $c = new Criteria(); - $c->add(Table9Peer::LEFT_COL, 4, Criteria::GREATER_EQUAL); - $tree = Table9Peer::retrieveTree($c); - $this->assertEquals(array($t3, $t4, $t5, $t6, $t7), $tree, 'retrieveTree() accepts a Criteria as first parameter'); - } - - public function testIsValid() - { - $this->assertTrue(method_exists('Table9Peer', 'isValid'), 'nested_set adds an isValid() method'); - $this->assertFalse(Table9Peer::isValid(null), 'isValid() returns false when passed null '); - $t1 = new Table9(); - $this->assertFalse(Table9Peer::isValid($t1), 'isValid() returns false when passed an empty node object'); - $t2 = new Table9(); - $t2->setLeftValue(5)->setRightValue(2); - $this->assertFalse(Table9Peer::isValid($t2), 'isValid() returns false when passed a node object with left > right'); - $t3 = new Table9(); - $t3->setLeftValue(5)->setRightValue(5); - $this->assertFalse(Table9Peer::isValid($t3), 'isValid() returns false when passed a node object with left = right'); - $t4 = new Table9(); - $t4->setLeftValue(2)->setRightValue(5); - $this->assertTrue(Table9Peer::isValid($t4), 'isValid() returns true when passed a node object with left < right'); - } - - public function testDeleteTree() - { - $this->initTree(); - Table9Peer::deleteTree(); - $this->assertEquals(array(), Table9Peer::doSelect(new Criteria()), 'deleteTree() deletes the whole tree'); - } - - public function testShiftRLValuesDelta() - { - $this->initTree(); - Table9Peer::shiftRLValues($delta = 1, $left = 1); - Table9Peer::clearInstancePool(); - $expected = array( - 't1' => array(2, 15, 0), - 't2' => array(3, 4, 1), - 't3' => array(5, 14, 1), - 't4' => array(6, 7, 2), - 't5' => array(8, 13, 2), - 't6' => array(9, 10, 3), - 't7' => array(11, 12, 3), - ); - $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts all nodes with a positive amount'); - $this->initTree(); - Table9Peer::shiftRLValues($delta = -1, $left = 1); - Table9Peer::clearInstancePool(); - $expected = array( - 't1' => array(0, 13, 0), - 't2' => array(1, 2, 1), - 't3' => array(3, 12, 1), - 't4' => array(4, 5, 2), - 't5' => array(6, 11, 2), - 't6' => array(7, 8, 3), - 't7' => array(9, 10, 3), - ); - $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues can shift all nodes with a negative amount'); - $this->initTree(); - Table9Peer::shiftRLValues($delta = 3, $left = 1); - Table9Peer::clearInstancePool(); - $expected = array( - 't1'=> array(4, 17, 0), - 't2' => array(5, 6, 1), - 't3' => array(7, 16, 1), - 't4' => array(8, 9, 2), - 't5' => array(10, 15, 2), - 't6' => array(11, 12, 3), - 't7' => array(13, 14, 3), - ); - $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts all nodes several units to the right'); - Table9Peer::shiftRLValues($delta = -3, $left = 1); - Table9Peer::clearInstancePool(); - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 13, 1), - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - 't6' => array(8, 9, 3), - 't7' => array(10, 11, 3), - ); - $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts all nodes several units to the left'); - } - - public function testShiftRLValuesLeftLimit() - { - $this->initTree(); - Table9Peer::shiftRLValues($delta = 1, $left = 15); - Table9Peer::clearInstancePool(); - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 13, 1), - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - 't6' => array(8, 9, 3), - 't7' => array(10, 11, 3), - ); - $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues does not shift anything when the left parameter is higher than the highest right value'); - $this->initTree(); - Table9Peer::shiftRLValues($delta = 1, $left = 5); - Table9Peer::clearInstancePool(); - $expected = array( - 't1' => array(1, 15, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 14, 1), - 't4' => array(6, 7, 2), - 't5' => array(8, 13, 2), - 't6' => array(9, 10, 3), - 't7' => array(11, 12, 3), - ); - $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts only the nodes having a LR value higher than the given left parameter'); - $this->initTree(); - Table9Peer::shiftRLValues($delta = 1, $left = 1); - Table9Peer::clearInstancePool(); - $expected = array( - 't1'=> array(2, 15, 0), - 't2' => array(3, 4, 1), - 't3' => array(5, 14, 1), - 't4' => array(6, 7, 2), - 't5' => array(8, 13, 2), - 't6' => array(9, 10, 3), - 't7' => array(11, 12, 3), - ); - $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts all nodes when the left parameter is 1'); - } - - public function testShiftRLValuesRightLimit() - { - $this->initTree(); - Table9Peer::shiftRLValues($delta = 1, $left = 1, $right = 0); - Table9Peer::clearInstancePool(); - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 13, 1), - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - 't6' => array(8, 9, 3), - 't7' => array(10, 11, 3), - ); - $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues does not shift anything when the right parameter is 0'); - $this->initTree(); - Table9Peer::shiftRLValues($delta = 1, $left = 1, $right = 5); - Table9Peer::clearInstancePool(); - $expected = array( - 't1' => array(2, 14, 0), - 't2' => array(3, 4, 1), - 't3' => array(5, 13, 1), - 't4' => array(6, 6, 2), - 't5' => array(7, 12, 2), - 't6' => array(8, 9, 3), - 't7' => array(10, 11, 3), - ); - $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shiftRLValues shifts only the nodes having a LR value lower than the given right parameter'); - $this->initTree(); - Table9Peer::shiftRLValues($delta = 1, $left = 1, $right = 15); - Table9Peer::clearInstancePool(); - $expected = array( - 't1'=> array(2, 15, 0), - 't2' => array(3, 4, 1), - 't3' => array(5, 14, 1), - 't4' => array(6, 7, 2), - 't5' => array(8, 13, 2), - 't6' => array(9, 10, 3), - 't7' => array(11, 12, 3), - ); - $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts all nodes when the right parameter is higher than the highest right value'); - } +class NestedSetBehaviorPeerBuilderModifierTest extends BookstoreNestedSetTestBase +{ + public function testConstants() + { + $this->assertEquals(Table9Peer::LEFT_COL, 'table9.tree_left', 'nested_set adds a LEFT_COL constant'); + $this->assertEquals(Table9Peer::RIGHT_COL, 'table9.tree_right', 'nested_set adds a RIGHT_COL constant'); + $this->assertEquals(Table9Peer::LEVEL_COL, 'table9.tree_level', 'nested_set adds a LEVEL_COL constant'); + } - public function testShiftLevel() - { - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $this->initTree(); - Table9Peer::shiftLevel($delta = 1, $first = 7, $last = 12); - Table9Peer::clearInstancePool(); - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 13, 1), - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 3), - 't6' => array(8, 9, 4), - 't7' => array(10, 11, 4), - ); - $this->assertEquals($this->dumpTree(), $expected, 'shiftLevel shifts all nodes with a left value between the first and last'); - $this->initTree(); - Table9Peer::shiftLevel($delta = -1, $first = 7, $last = 12); - Table9Peer::clearInstancePool(); - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 13, 1), - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 1), - 't6' => array(8, 9, 2), - 't7' => array(10, 11, 2), - ); - $this->assertEquals($this->dumpTree(), $expected, 'shiftLevel shifts all nodes wit ha negative amount'); - } - - public function testUpdateLoadedNodes() - { - $this->assertTrue(method_exists('Table9Peer', 'updateLoadedNodes'), 'nested_set adds a updateLoadedNodes() method'); - $fixtures = $this->initTree(); - Table9Peer::shiftRLValues(1, 5); - $expected = array( - 't1' => array(1, 14), - 't2' => array(2, 3), - 't3' => array(4, 13), - 't4' => array(5, 6), - 't5' => array(7, 12), - 't6' => array(8, 9), - 't7' => array(10, 11), - ); - $actual = array(); - foreach ($fixtures as $t) { - $actual[$t->getTitle()] = array($t->getLeftValue(), $t->getRightValue()); - } - $this->assertEquals($actual, $expected, 'Loaded nodes are not in sync before calling updateLoadedNodes()'); - Table9Peer::updateLoadedNodes(); - $expected = array( - 't1' => array(1, 15), - 't2' => array(2, 3), - 't3' => array(4, 14), - 't4' => array(6, 7), - 't5' => array(8, 13), - 't6' => array(9, 10), - 't7' => array(11, 12), - ); - $actual = array(); - foreach ($fixtures as $t) { - $actual[$t->getTitle()] = array($t->getLeftValue(), $t->getRightValue()); - } - $this->assertEquals($actual, $expected, 'Loaded nodes are in sync after calling updateLoadedNodes()'); - } + public function testRetrieveRoot() + { + $this->assertTrue(method_exists('Table9Peer', 'retrieveRoot'), 'nested_set adds a retrieveRoot() method'); + Table9Peer::doDeleteAll(); + $this->assertNull(Table9Peer::retrieveRoot(), 'retrieveRoot() returns null as long as no root node is defined'); + $t1 = new Table9(); + $t1->setLeftValue(123); + $t1->setRightValue(456); + $t1->save(); + $this->assertNull(Table9Peer::retrieveRoot(), 'retrieveRoot() returns null as long as no root node is defined'); + $t2 = new Table9(); + $t2->setLeftValue(1); + $t2->setRightValue(2); + $t2->save(); + $this->assertEquals(Table9Peer::retrieveRoot(), $t2, 'retrieveRoot() retrieves the root node'); + } - public function testMakeRoomForLeaf() - { - $this->assertTrue(method_exists('Table9Peer', 'makeRoomForLeaf'), 'nested_set adds a makeRoomForLeaf() method'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $t = Table9Peer::makeRoomForLeaf(5); // first child of t3 - $expected = array( - 't1' => array(1, 16, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 15, 1), - 't4' => array(7, 8, 2), - 't5' => array(9, 14, 2), - 't6' => array(10, 11, 3), - 't7' => array(12, 13, 3), - ); - $this->assertEquals($expected, $this->dumpTree(), 'makeRoomForLeaf() shifts the other nodes correctly'); - foreach ($expected as $key => $values) - { - $this->assertEquals($values, array($$key->getLeftValue(), $$key->getRightValue(), $$key->getLevel()), 'makeRoomForLeaf() updates nodes already in memory'); - } - } - - public function testFixLevels() - { - $fixtures = $this->initTree(); - // reset the levels - foreach ($fixtures as $node) { - $node->setLevel(null)->save(); - } - // fix the levels - Table9Peer::fixLevels(); - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 13, 1), - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - 't6' => array(8, 9, 3), - 't7' => array(10, 11, 3), - ); - $this->assertEquals($expected, $this->dumpTree(), 'fixLevels() fixes the levels correctly'); - Table9Peer::fixLevels(); - $this->assertEquals($expected, $this->dumpTree(), 'fixLevels() can be called several times'); - } + public function testRetrieveTree() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + $tree = Table9Peer::retrieveTree(); + $this->assertEquals(array($t1, $t2, $t3, $t4, $t5, $t6, $t7), $tree, 'retrieveTree() retrieves the whole tree'); + $c = new Criteria(); + $c->add(Table9Peer::LEFT_COL, 4, Criteria::GREATER_EQUAL); + $tree = Table9Peer::retrieveTree($c); + $this->assertEquals(array($t3, $t4, $t5, $t6, $t7), $tree, 'retrieveTree() accepts a Criteria as first parameter'); + } + + public function testIsValid() + { + $this->assertTrue(method_exists('Table9Peer', 'isValid'), 'nested_set adds an isValid() method'); + $this->assertFalse(Table9Peer::isValid(null), 'isValid() returns false when passed null '); + $t1 = new Table9(); + $this->assertFalse(Table9Peer::isValid($t1), 'isValid() returns false when passed an empty node object'); + $t2 = new Table9(); + $t2->setLeftValue(5)->setRightValue(2); + $this->assertFalse(Table9Peer::isValid($t2), 'isValid() returns false when passed a node object with left > right'); + $t3 = new Table9(); + $t3->setLeftValue(5)->setRightValue(5); + $this->assertFalse(Table9Peer::isValid($t3), 'isValid() returns false when passed a node object with left = right'); + $t4 = new Table9(); + $t4->setLeftValue(2)->setRightValue(5); + $this->assertTrue(Table9Peer::isValid($t4), 'isValid() returns true when passed a node object with left < right'); + } + + public function testDeleteTree() + { + $this->initTree(); + Table9Peer::deleteTree(); + $this->assertEquals(array(), Table9Peer::doSelect(new Criteria()), 'deleteTree() deletes the whole tree'); + } + + public function testShiftRLValuesDelta() + { + $this->initTree(); + Table9Peer::shiftRLValues($delta = 1, $left = 1); + Table9Peer::clearInstancePool(); + $expected = array( + 't1' => array(2, 15, 0), + 't2' => array(3, 4, 1), + 't3' => array(5, 14, 1), + 't4' => array(6, 7, 2), + 't5' => array(8, 13, 2), + 't6' => array(9, 10, 3), + 't7' => array(11, 12, 3), + ); + $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts all nodes with a positive amount'); + $this->initTree(); + Table9Peer::shiftRLValues($delta = -1, $left = 1); + Table9Peer::clearInstancePool(); + $expected = array( + 't1' => array(0, 13, 0), + 't2' => array(1, 2, 1), + 't3' => array(3, 12, 1), + 't4' => array(4, 5, 2), + 't5' => array(6, 11, 2), + 't6' => array(7, 8, 3), + 't7' => array(9, 10, 3), + ); + $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues can shift all nodes with a negative amount'); + $this->initTree(); + Table9Peer::shiftRLValues($delta = 3, $left = 1); + Table9Peer::clearInstancePool(); + $expected = array( + 't1'=> array(4, 17, 0), + 't2' => array(5, 6, 1), + 't3' => array(7, 16, 1), + 't4' => array(8, 9, 2), + 't5' => array(10, 15, 2), + 't6' => array(11, 12, 3), + 't7' => array(13, 14, 3), + ); + $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts all nodes several units to the right'); + Table9Peer::shiftRLValues($delta = -3, $left = 1); + Table9Peer::clearInstancePool(); + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 13, 1), + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + 't6' => array(8, 9, 3), + 't7' => array(10, 11, 3), + ); + $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts all nodes several units to the left'); + } + + public function testShiftRLValuesLeftLimit() + { + $this->initTree(); + Table9Peer::shiftRLValues($delta = 1, $left = 15); + Table9Peer::clearInstancePool(); + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 13, 1), + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + 't6' => array(8, 9, 3), + 't7' => array(10, 11, 3), + ); + $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues does not shift anything when the left parameter is higher than the highest right value'); + $this->initTree(); + Table9Peer::shiftRLValues($delta = 1, $left = 5); + Table9Peer::clearInstancePool(); + $expected = array( + 't1' => array(1, 15, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 14, 1), + 't4' => array(6, 7, 2), + 't5' => array(8, 13, 2), + 't6' => array(9, 10, 3), + 't7' => array(11, 12, 3), + ); + $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts only the nodes having a LR value higher than the given left parameter'); + $this->initTree(); + Table9Peer::shiftRLValues($delta = 1, $left = 1); + Table9Peer::clearInstancePool(); + $expected = array( + 't1'=> array(2, 15, 0), + 't2' => array(3, 4, 1), + 't3' => array(5, 14, 1), + 't4' => array(6, 7, 2), + 't5' => array(8, 13, 2), + 't6' => array(9, 10, 3), + 't7' => array(11, 12, 3), + ); + $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts all nodes when the left parameter is 1'); + } + + public function testShiftRLValuesRightLimit() + { + $this->initTree(); + Table9Peer::shiftRLValues($delta = 1, $left = 1, $right = 0); + Table9Peer::clearInstancePool(); + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 13, 1), + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + 't6' => array(8, 9, 3), + 't7' => array(10, 11, 3), + ); + $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues does not shift anything when the right parameter is 0'); + $this->initTree(); + Table9Peer::shiftRLValues($delta = 1, $left = 1, $right = 5); + Table9Peer::clearInstancePool(); + $expected = array( + 't1' => array(2, 14, 0), + 't2' => array(3, 4, 1), + 't3' => array(5, 13, 1), + 't4' => array(6, 6, 2), + 't5' => array(7, 12, 2), + 't6' => array(8, 9, 3), + 't7' => array(10, 11, 3), + ); + $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shiftRLValues shifts only the nodes having a LR value lower than the given right parameter'); + $this->initTree(); + Table9Peer::shiftRLValues($delta = 1, $left = 1, $right = 15); + Table9Peer::clearInstancePool(); + $expected = array( + 't1'=> array(2, 15, 0), + 't2' => array(3, 4, 1), + 't3' => array(5, 14, 1), + 't4' => array(6, 7, 2), + 't5' => array(8, 13, 2), + 't6' => array(9, 10, 3), + 't7' => array(11, 12, 3), + ); + $this->assertEquals($this->dumpTree(), $expected, 'shiftRLValues shifts all nodes when the right parameter is higher than the highest right value'); + } + + public function testShiftLevel() + { + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $this->initTree(); + Table9Peer::shiftLevel($delta = 1, $first = 7, $last = 12); + Table9Peer::clearInstancePool(); + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 13, 1), + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 3), + 't6' => array(8, 9, 4), + 't7' => array(10, 11, 4), + ); + $this->assertEquals($this->dumpTree(), $expected, 'shiftLevel shifts all nodes with a left value between the first and last'); + $this->initTree(); + Table9Peer::shiftLevel($delta = -1, $first = 7, $last = 12); + Table9Peer::clearInstancePool(); + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 13, 1), + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 1), + 't6' => array(8, 9, 2), + 't7' => array(10, 11, 2), + ); + $this->assertEquals($this->dumpTree(), $expected, 'shiftLevel shifts all nodes wit ha negative amount'); + } + + public function testUpdateLoadedNodes() + { + $this->assertTrue(method_exists('Table9Peer', 'updateLoadedNodes'), 'nested_set adds a updateLoadedNodes() method'); + $fixtures = $this->initTree(); + Table9Peer::shiftRLValues(1, 5); + $expected = array( + 't1' => array(1, 14), + 't2' => array(2, 3), + 't3' => array(4, 13), + 't4' => array(5, 6), + 't5' => array(7, 12), + 't6' => array(8, 9), + 't7' => array(10, 11), + ); + $actual = array(); + foreach ($fixtures as $t) { + $actual[$t->getTitle()] = array($t->getLeftValue(), $t->getRightValue()); + } + $this->assertEquals($actual, $expected, 'Loaded nodes are not in sync before calling updateLoadedNodes()'); + Table9Peer::updateLoadedNodes(); + $expected = array( + 't1' => array(1, 15), + 't2' => array(2, 3), + 't3' => array(4, 14), + 't4' => array(6, 7), + 't5' => array(8, 13), + 't6' => array(9, 10), + 't7' => array(11, 12), + ); + $actual = array(); + foreach ($fixtures as $t) { + $actual[$t->getTitle()] = array($t->getLeftValue(), $t->getRightValue()); + } + $this->assertEquals($actual, $expected, 'Loaded nodes are in sync after calling updateLoadedNodes()'); + } + + public function testMakeRoomForLeaf() + { + $this->assertTrue(method_exists('Table9Peer', 'makeRoomForLeaf'), 'nested_set adds a makeRoomForLeaf() method'); + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $t = Table9Peer::makeRoomForLeaf(5); // first child of t3 + $expected = array( + 't1' => array(1, 16, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 15, 1), + 't4' => array(7, 8, 2), + 't5' => array(9, 14, 2), + 't6' => array(10, 11, 3), + 't7' => array(12, 13, 3), + ); + $this->assertEquals($expected, $this->dumpTree(), 'makeRoomForLeaf() shifts the other nodes correctly'); + foreach ($expected as $key => $values) { + $this->assertEquals($values, array($$key->getLeftValue(), $$key->getRightValue(), $$key->getLevel()), 'makeRoomForLeaf() updates nodes already in memory'); + } + } + + public function testFixLevels() + { + $fixtures = $this->initTree(); + // reset the levels + foreach ($fixtures as $node) { + $node->setLevel(null)->save(); + } + // fix the levels + Table9Peer::fixLevels(); + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 13, 1), + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + 't6' => array(8, 9, 3), + 't7' => array(10, 11, 3), + ); + $this->assertEquals($expected, $this->dumpTree(), 'fixLevels() fixes the levels correctly'); + Table9Peer::fixLevels(); + $this->assertEquals($expected, $this->dumpTree(), 'fixLevels() can be called several times'); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorPeerBuilderModifierWithScopeTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorPeerBuilderModifierWithScopeTest.php index 87026d348..122ed96bc 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorPeerBuilderModifierWithScopeTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorPeerBuilderModifierWithScopeTest.php @@ -1,7 +1,7 @@ assertEquals(Table10Peer::LEFT_COL, 'table10.MY_LEFT_COLUMN', 'nested_set adds a LEFT_COL constant using the custom left_column parameter'); - $this->assertEquals(Table10Peer::RIGHT_COL, 'table10.MY_RIGHT_COLUMN', 'nested_set adds a RIGHT_COL constant using the custom right_column parameter'); - $this->assertEquals(Table10Peer::LEVEL_COL, 'table10.MY_LEVEL_COLUMN', 'nested_set adds a LEVEL_COL constant using the custom level_column parameter'); - $this->assertEquals(Table10Peer::SCOPE_COL, 'table10.MY_SCOPE_COLUMN', 'nested_set adds a SCOPE_COL constant when the use_scope parameter is true'); - } + public function testConstants() + { + $this->assertEquals(Table10Peer::LEFT_COL, 'table10.my_left_column', 'nested_set adds a LEFT_COL constant using the custom left_column parameter'); + $this->assertEquals(Table10Peer::RIGHT_COL, 'table10.my_right_column', 'nested_set adds a RIGHT_COL constant using the custom right_column parameter'); + $this->assertEquals(Table10Peer::LEVEL_COL, 'table10.my_level_column', 'nested_set adds a LEVEL_COL constant using the custom level_column parameter'); + $this->assertEquals(Table10Peer::SCOPE_COL, 'table10.my_scope_column', 'nested_set adds a SCOPE_COL constant when the use_scope parameter is true'); + } - public function testRetrieveRoots() - { - $this->assertTrue(method_exists('Table10Peer', 'retrieveRoots'), 'nested_set adds a retrieveRoots() method for trees that use scope'); - $this->assertFalse(method_exists('Table9Peer', 'retrieveRoots'), 'nested_set does not add a retrieveRoots() method for trees that don\'t use scope'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $this->assertEquals(array($t1, $t8), Table10Peer::retrieveRoots(), 'retrieveRoots() returns the tree roots'); - $c = new Criteria(); - $c->add(Table10Peer::TITLE, 't1'); - $this->assertEquals(array($t1), Table10Peer::retrieveRoots($c), 'retrieveRoots() accepts a Criteria as first parameter'); - } + public function testRetrieveRoots() + { + $this->assertTrue(method_exists('Table10Peer', 'retrieveRoots'), 'nested_set adds a retrieveRoots() method for trees that use scope'); + $this->assertFalse(method_exists('Table9Peer', 'retrieveRoots'), 'nested_set does not add a retrieveRoots() method for trees that don\'t use scope'); + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $this->assertEquals(array($t1, $t8), Table10Peer::retrieveRoots(), 'retrieveRoots() returns the tree roots'); + $c = new Criteria(); + $c->add(Table10Peer::TITLE, 't1'); + $this->assertEquals(array($t1), Table10Peer::retrieveRoots($c), 'retrieveRoots() accepts a Criteria as first parameter'); + } public function testRetrieveRoot() - { - $this->assertTrue(method_exists('Table10Peer', 'retrieveRoot'), 'nested_set adds a retrieveRoot() method'); - Table10Peer::doDeleteAll(); - $t1 = new Table10(); - $t1->setLeftValue(1); - $t1->setRightValue(2); - $t1->setScopeValue(2); - $t1->save(); - $this->assertNull(Table10Peer::retrieveRoot(1), 'retrieveRoot() returns null as long as no root node is defined in the required scope'); - $t2 = new Table10(); - $t2->setLeftValue(1); - $t2->setRightValue(2); - $t2->setScopeValue(1); - $t2->save(); - $this->assertEquals(Table10Peer::retrieveRoot(1), $t2, 'retrieveRoot() retrieves the root node in the required scope'); - } - - public function testRetrieveTree() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $tree = Table10Peer::retrieveTree(1); - $this->assertEquals(array($t1, $t2, $t3, $t4, $t5, $t6, $t7), $tree, 'retrieveTree() retrieves the scoped tree'); - $tree = Table10Peer::retrieveTree(2); - $this->assertEquals(array($t8, $t9, $t10), $tree, 'retrieveTree() retrieves the scoped tree'); - $c = new Criteria(); - $c->add(Table10Peer::LEFT_COL, 4, Criteria::GREATER_EQUAL); - $tree = Table10Peer::retrieveTree(1, $c); - $this->assertEquals(array($t3, $t4, $t5, $t6, $t7), $tree, 'retrieveTree() accepts a Criteria as first parameter'); - } - - public function testDeleteTree() - { - $this->initTreeWithScope(); - Table10Peer::deleteTree(1); - $expected = array( - 't8' => array(1, 6, 0), - 't9' => array(2, 3, 1), - 't10' => array(4, 5, 1), - ); - $this->assertEquals($this->dumpTreeWithScope(2), $expected, 'deleteTree() does not delete anything out of the scope'); - } + { + $this->assertTrue(method_exists('Table10Peer', 'retrieveRoot'), 'nested_set adds a retrieveRoot() method'); + Table10Peer::doDeleteAll(); + $t1 = new Table10(); + $t1->setLeftValue(1); + $t1->setRightValue(2); + $t1->setScopeValue(2); + $t1->save(); + $this->assertNull(Table10Peer::retrieveRoot(1), 'retrieveRoot() returns null as long as no root node is defined in the required scope'); + $t2 = new Table10(); + $t2->setLeftValue(1); + $t2->setRightValue(2); + $t2->setScopeValue(1); + $t2->save(); + $this->assertEquals(Table10Peer::retrieveRoot(1), $t2, 'retrieveRoot() retrieves the root node in the required scope'); + } - public function testShiftRLValues() - { - $this->assertTrue(method_exists('Table10Peer', 'shiftRLValues'), 'nested_set adds a shiftRLValues() method'); - $this->initTreeWithScope(); - Table10Peer::shiftRLValues(1, 100, null, 1); - Table10Peer::clearInstancePool(); - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 13, 1), - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - 't6' => array(8, 9, 3), - 't7' => array(10, 11, 3), - ); - $this->assertEquals($this->dumpTreeWithScope(1), $expected, 'shiftRLValues does not shift anything when the first parameter is higher than the highest right value'); - $expected = array( - 't8' => array(1, 6, 0), - 't9' => array(2, 3, 1), - 't10' => array(4, 5, 1), - ); - $this->assertEquals($this->dumpTreeWithScope(2), $expected, 'shiftRLValues does not shift anything out of the scope'); - $this->initTreeWithScope(); - Table10Peer::shiftRLValues(1, 1, null, 1); - Table10Peer::clearInstancePool(); - $expected = array( - 't1' => array(2, 15, 0), - 't2' => array(3, 4, 1), - 't3' => array(5, 14, 1), - 't4' => array(6, 7, 2), - 't5' => array(8, 13, 2), - 't6' => array(9, 10, 3), - 't7' => array(11, 12, 3), - ); - $this->assertEquals($this->dumpTreeWithScope(1), $expected, 'shiftRLValues can shift all nodes to the right'); - $expected = array( - 't8' => array(1, 6, 0), - 't9' => array(2, 3, 1), - 't10' => array(4, 5, 1), - ); - $this->assertEquals($this->dumpTreeWithScope(2), $expected, 'shiftRLValues does not shift anything out of the scope'); - $this->initTreeWithScope(); - Table10Peer::shiftRLValues(-1, 1, null, 1); - Table10Peer::clearInstancePool(); - $expected = array( - 't1' => array(0, 13, 0), - 't2' => array(1, 2, 1), - 't3' => array(3, 12, 1), - 't4' => array(4, 5, 2), - 't5' => array(6, 11, 2), - 't6' => array(7, 8, 3), - 't7' => array(9, 10, 3), - ); - $this->assertEquals($this->dumpTreeWithScope(1), $expected, 'shiftRLValues can shift all nodes to the left'); - $expected = array( - 't8' => array(1, 6, 0), - 't9' => array(2, 3, 1), - 't10' => array(4, 5, 1), - ); - $this->assertEquals($this->dumpTreeWithScope(2), $expected, 'shiftRLValues does not shift anything out of the scope'); - $this->initTreeWithScope(); - Table10Peer::shiftRLValues(1, 5, null, 1); - Table10Peer::clearInstancePool(); - $expected = array( - 't1' => array(1, 15, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 14, 1), - 't4' => array(6, 7, 2), - 't5' => array(8, 13, 2), - 't6' => array(9, 10, 3), - 't7' => array(11, 12, 3), - ); - $this->assertEquals($this->dumpTreeWithScope(1), $expected, 'shiftRLValues can shift some nodes to the right'); - $expected = array( - 't8' => array(1, 6, 0), - 't9' => array(2, 3, 1), - 't10' => array(4, 5, 1), - ); - $this->assertEquals($this->dumpTreeWithScope(2), $expected, 'shiftRLValues does not shift anything out of the scope'); - } - - public function testShiftLevel() - { - $this->initTreeWithScope(); - Table10Peer::shiftLevel($delta = 1, $first = 7, $last = 12, $scope = 1); - Table10Peer::clearInstancePool(); - $expected = array( - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 13, 1), - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 3), - 't6' => array(8, 9, 4), - 't7' => array(10, 11, 4), - ); - $this->assertEquals($this->dumpTreeWithScope(1), $expected, 'shiftLevel can shift level whith a scope'); - $expected = array( - 't8' => array(1, 6, 0), - 't9' => array(2, 3, 1), - 't10' => array(4, 5, 1), - ); - $this->assertEquals($this->dumpTreeWithScope(2), $expected, 'shiftLevel does not shift anything out of the scope'); - } + public function testRetrieveTree() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $tree = Table10Peer::retrieveTree(1); + $this->assertEquals(array($t1, $t2, $t3, $t4, $t5, $t6, $t7), $tree, 'retrieveTree() retrieves the scoped tree'); + $tree = Table10Peer::retrieveTree(2); + $this->assertEquals(array($t8, $t9, $t10), $tree, 'retrieveTree() retrieves the scoped tree'); + $c = new Criteria(); + $c->add(Table10Peer::LEFT_COL, 4, Criteria::GREATER_EQUAL); + $tree = Table10Peer::retrieveTree(1, $c); + $this->assertEquals(array($t3, $t4, $t5, $t6, $t7), $tree, 'retrieveTree() accepts a Criteria as first parameter'); + } - public function testMakeRoomForLeaf() - { - $this->assertTrue(method_exists('Table10Peer', 'makeRoomForLeaf'), 'nested_set adds a makeRoomForLeaf() method'); - $fixtures = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $t = Table10Peer::makeRoomForLeaf(5, 1); // first child of t3 - $expected = array( - 't1' => array(1, 16, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 15, 1), - 't4' => array(7, 8, 2), - 't5' => array(9, 14, 2), - 't6' => array(10, 11, 3), - 't7' => array(12, 13, 3), - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'makeRoomForLeaf() shifts the other nodes correctly'); - $expected = array( - 't8' => array(1, 6, 0), - 't9' => array(2, 3, 1), - 't10' => array(4, 5, 1), - ); - $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'makeRoomForLeaf() does not shift anything out of the scope'); - } -} \ No newline at end of file + public function testDeleteTree() + { + $this->initTreeWithScope(); + Table10Peer::deleteTree(1); + $expected = array( + 't8' => array(1, 6, 0), + 't9' => array(2, 3, 1), + 't10' => array(4, 5, 1), + ); + $this->assertEquals($this->dumpTreeWithScope(2), $expected, 'deleteTree() does not delete anything out of the scope'); + } + + public function testShiftRLValues() + { + $this->assertTrue(method_exists('Table10Peer', 'shiftRLValues'), 'nested_set adds a shiftRLValues() method'); + $this->initTreeWithScope(); + Table10Peer::shiftRLValues(1, 100, null, 1); + Table10Peer::clearInstancePool(); + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 13, 1), + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + 't6' => array(8, 9, 3), + 't7' => array(10, 11, 3), + ); + $this->assertEquals($this->dumpTreeWithScope(1), $expected, 'shiftRLValues does not shift anything when the first parameter is higher than the highest right value'); + $expected = array( + 't8' => array(1, 6, 0), + 't9' => array(2, 3, 1), + 't10' => array(4, 5, 1), + ); + $this->assertEquals($this->dumpTreeWithScope(2), $expected, 'shiftRLValues does not shift anything out of the scope'); + $this->initTreeWithScope(); + Table10Peer::shiftRLValues(1, 1, null, 1); + Table10Peer::clearInstancePool(); + $expected = array( + 't1' => array(2, 15, 0), + 't2' => array(3, 4, 1), + 't3' => array(5, 14, 1), + 't4' => array(6, 7, 2), + 't5' => array(8, 13, 2), + 't6' => array(9, 10, 3), + 't7' => array(11, 12, 3), + ); + $this->assertEquals($this->dumpTreeWithScope(1), $expected, 'shiftRLValues can shift all nodes to the right'); + $expected = array( + 't8' => array(1, 6, 0), + 't9' => array(2, 3, 1), + 't10' => array(4, 5, 1), + ); + $this->assertEquals($this->dumpTreeWithScope(2), $expected, 'shiftRLValues does not shift anything out of the scope'); + $this->initTreeWithScope(); + Table10Peer::shiftRLValues(-1, 1, null, 1); + Table10Peer::clearInstancePool(); + $expected = array( + 't1' => array(0, 13, 0), + 't2' => array(1, 2, 1), + 't3' => array(3, 12, 1), + 't4' => array(4, 5, 2), + 't5' => array(6, 11, 2), + 't6' => array(7, 8, 3), + 't7' => array(9, 10, 3), + ); + $this->assertEquals($this->dumpTreeWithScope(1), $expected, 'shiftRLValues can shift all nodes to the left'); + $expected = array( + 't8' => array(1, 6, 0), + 't9' => array(2, 3, 1), + 't10' => array(4, 5, 1), + ); + $this->assertEquals($this->dumpTreeWithScope(2), $expected, 'shiftRLValues does not shift anything out of the scope'); + $this->initTreeWithScope(); + Table10Peer::shiftRLValues(1, 5, null, 1); + Table10Peer::clearInstancePool(); + $expected = array( + 't1' => array(1, 15, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 14, 1), + 't4' => array(6, 7, 2), + 't5' => array(8, 13, 2), + 't6' => array(9, 10, 3), + 't7' => array(11, 12, 3), + ); + $this->assertEquals($this->dumpTreeWithScope(1), $expected, 'shiftRLValues can shift some nodes to the right'); + $expected = array( + 't8' => array(1, 6, 0), + 't9' => array(2, 3, 1), + 't10' => array(4, 5, 1), + ); + $this->assertEquals($this->dumpTreeWithScope(2), $expected, 'shiftRLValues does not shift anything out of the scope'); + } + + public function testShiftLevel() + { + $this->initTreeWithScope(); + Table10Peer::shiftLevel($delta = 1, $first = 7, $last = 12, $scope = 1); + Table10Peer::clearInstancePool(); + $expected = array( + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 13, 1), + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 3), + 't6' => array(8, 9, 4), + 't7' => array(10, 11, 4), + ); + $this->assertEquals($this->dumpTreeWithScope(1), $expected, 'shiftLevel can shift level with a scope'); + $expected = array( + 't8' => array(1, 6, 0), + 't9' => array(2, 3, 1), + 't10' => array(4, 5, 1), + ); + $this->assertEquals($this->dumpTreeWithScope(2), $expected, 'shiftLevel does not shift anything out of the scope'); + } + + public function testMakeRoomForLeaf() + { + $this->assertTrue(method_exists('Table10Peer', 'makeRoomForLeaf'), 'nested_set adds a makeRoomForLeaf() method'); + $fixtures = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $t = Table10Peer::makeRoomForLeaf(5, 1); // first child of t3 + $expected = array( + 't1' => array(1, 16, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 15, 1), + 't4' => array(7, 8, 2), + 't5' => array(9, 14, 2), + 't6' => array(10, 11, 3), + 't7' => array(12, 13, 3), + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(1), 'makeRoomForLeaf() shifts the other nodes correctly'); + $expected = array( + 't8' => array(1, 6, 0), + 't9' => array(2, 3, 1), + 't10' => array(4, 5, 1), + ); + $this->assertEquals($expected, $this->dumpTreeWithScope(2), 'makeRoomForLeaf() does not shift anything out of the scope'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorQueryBuilderModifierTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorQueryBuilderModifierTest.php index 8a6f5729b..01f054830 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorQueryBuilderModifierTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorQueryBuilderModifierTest.php @@ -9,275 +9,275 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/behavior/BookstoreNestedSetTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/behavior/BookstoreNestedSetTestBase.php'; /** * Tests for NestedSetBehaviorQueryBuilderModifier class * * @author François Zaninotto - * @version $Revision: 1612 $ + * @version $Revision$ * @package generator.behavior.nestedset */ -class NestedSetBehaviorQueryBuilderModifierTest extends BookstoreNestedSetTestBase +class NestedSetBehaviorQueryBuilderModifierTest extends BookstoreNestedSetTestBase { - public function testDescendantsOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $objs = Table9Query::create() - ->descendantsOf($t7) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array()); - $this->assertEquals($coll, $objs, 'decendantsOf() filters by descendants'); - $objs = Table9Query::create() - ->descendantsOf($t3) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t4, $t5, $t6, $t7)); - $this->assertEquals($coll, $objs, 'decendantsOf() filters by descendants'); - } + public function testDescendantsOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $objs = Table9Query::create() + ->descendantsOf($t7) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array()); + $this->assertEquals($coll, $objs, 'descendantsOf() filters by descendants'); + $objs = Table9Query::create() + ->descendantsOf($t3) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t4, $t5, $t6, $t7)); + $this->assertEquals($coll, $objs, 'descendantsOf() filters by descendants'); + } - public function testBranchOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $objs = Table9Query::create() - ->branchOf($t7) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t7)); - $this->assertEquals($coll, $objs, 'branchOf() filters by descendants and includes object passed as parameter'); - $objs = Table9Query::create() - ->branchOf($t3) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t3, $t4, $t5, $t6, $t7)); - $this->assertEquals($coll, $objs, 'branchOf() filters by descendants and includes object passed as parameter'); - $objs = Table9Query::create() - ->branchOf($t1) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t1, $t2, $t3, $t4, $t5, $t6, $t7)); - $this->assertEquals($coll, $objs, 'branchOf() returns the whole tree for the root node'); - } + public function testBranchOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $objs = Table9Query::create() + ->branchOf($t7) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t7)); + $this->assertEquals($coll, $objs, 'branchOf() filters by descendants and includes object passed as parameter'); + $objs = Table9Query::create() + ->branchOf($t3) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t3, $t4, $t5, $t6, $t7)); + $this->assertEquals($coll, $objs, 'branchOf() filters by descendants and includes object passed as parameter'); + $objs = Table9Query::create() + ->branchOf($t1) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t1, $t2, $t3, $t4, $t5, $t6, $t7)); + $this->assertEquals($coll, $objs, 'branchOf() returns the whole tree for the root node'); + } - public function testChildrenOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $objs = Table9Query::create() - ->childrenOf($t6) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array()); - $this->assertEquals($coll, $objs, 'childrenOf() returns empty collection for leaf nodes'); - $objs = Table9Query::create() - ->childrenOf($t5) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t6, $t7)); - $this->assertEquals($coll, $objs, 'childrenOf() filters by children'); - $objs = Table9Query::create() - ->childrenOf($t3) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t4, $t5)); - $this->assertEquals($coll, $objs, 'childrenOf() filters by children and not by descendants'); - } + public function testChildrenOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $objs = Table9Query::create() + ->childrenOf($t6) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array()); + $this->assertEquals($coll, $objs, 'childrenOf() returns empty collection for leaf nodes'); + $objs = Table9Query::create() + ->childrenOf($t5) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t6, $t7)); + $this->assertEquals($coll, $objs, 'childrenOf() filters by children'); + $objs = Table9Query::create() + ->childrenOf($t3) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t4, $t5)); + $this->assertEquals($coll, $objs, 'childrenOf() filters by children and not by descendants'); + } - public function testSiblingsOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $desc = Table9Query::create() - ->siblingsOf($t1) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array()); - $this->assertEquals($coll, $desc, 'siblingsOf() returns empty collection for the root node'); - $desc = Table9Query::create() - ->siblingsOf($t3) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t2)); - $this->assertEquals($coll, $desc, 'siblingsOf() filters by siblings'); - } + public function testSiblingsOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $desc = Table9Query::create() + ->siblingsOf($t1) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array()); + $this->assertEquals($coll, $desc, 'siblingsOf() returns empty collection for the root node'); + $desc = Table9Query::create() + ->siblingsOf($t3) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t2)); + $this->assertEquals($coll, $desc, 'siblingsOf() filters by siblings'); + } - public function testAncestorsOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $objs = Table9Query::create() - ->ancestorsOf($t1) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array()); - $this->assertEquals($coll, $objs, 'ancestorsOf() returns empty collection for root node'); - $objs = Table9Query::create() - ->ancestorsOf($t3) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t1)); - $this->assertEquals($coll, $objs, 'ancestorsOf() filters by ancestors'); - $objs = Table9Query::create() - ->ancestorsOf($t7) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t1, $t3, $t5)); - $this->assertEquals($coll, $objs, 'childrenOf() filters by ancestors'); - } + public function testAncestorsOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $objs = Table9Query::create() + ->ancestorsOf($t1) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array()); + $this->assertEquals($coll, $objs, 'ancestorsOf() returns empty collection for root node'); + $objs = Table9Query::create() + ->ancestorsOf($t3) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t1)); + $this->assertEquals($coll, $objs, 'ancestorsOf() filters by ancestors'); + $objs = Table9Query::create() + ->ancestorsOf($t7) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t1, $t3, $t5)); + $this->assertEquals($coll, $objs, 'childrenOf() filters by ancestors'); + } - public function testRootsOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - /* Tree used for tests - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - */ - $objs = Table9Query::create() - ->rootsOf($t1) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t1)); - $this->assertEquals($coll, $objs, 'rootsOf() returns the root node for root node'); - $objs = Table9Query::create() - ->rootsOf($t3) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t1, $t3)); - $this->assertEquals($coll, $objs, 'rootsOf() filters by ancestors and includes the node passed as parameter'); - $objs = Table9Query::create() - ->rootsOf($t7) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t1, $t3, $t5, $t7)); - $this->assertEquals($coll, $objs, 'rootsOf() filters by ancestors and includes the node passed as parameter'); - } - - public function testOrderByBranch() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - $t5->moveToPrevSiblingOf($t4); - /* Results in - t1 - | \ - t2 t3 - | \ - t5 t4 - | \ - t6 t7 - */ - $objs = Table9Query::create() - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t1, $t2, $t3, $t5, $t6, $t7, $t4), 'orderByBranch() orders by branch left to right'); - $objs = Table9Query::create() - ->orderByBranch(true) - ->find(); - $coll = $this->buildCollection(array($t4, $t7, $t6, $t5, $t3, $t2, $t1), 'orderByBranch(true) orders by branch right to left'); - } + public function testRootsOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + /* Tree used for tests + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + */ + $objs = Table9Query::create() + ->rootsOf($t1) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t1)); + $this->assertEquals($coll, $objs, 'rootsOf() returns the root node for root node'); + $objs = Table9Query::create() + ->rootsOf($t3) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t1, $t3)); + $this->assertEquals($coll, $objs, 'rootsOf() filters by ancestors and includes the node passed as parameter'); + $objs = Table9Query::create() + ->rootsOf($t7) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t1, $t3, $t5, $t7)); + $this->assertEquals($coll, $objs, 'rootsOf() filters by ancestors and includes the node passed as parameter'); + } + + public function testOrderByBranch() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + $t5->moveToPrevSiblingOf($t4); + /* Results in + t1 + | \ + t2 t3 + | \ + t5 t4 + | \ + t6 t7 + */ + $objs = Table9Query::create() + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t1, $t2, $t3, $t5, $t6, $t7, $t4), 'orderByBranch() orders by branch left to right'); + $objs = Table9Query::create() + ->orderByBranch(true) + ->find(); + $coll = $this->buildCollection(array($t4, $t7, $t6, $t5, $t3, $t2, $t1), 'orderByBranch(true) orders by branch right to left'); + } + + public function testOrderByLevel() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + $t5->moveToPrevSiblingOf($t4); + /* Results in + t1 + | \ + t2 t3 + | \ + t5 t4 + | \ + t6 t7 + */ + $objs = Table9Query::create() + ->orderByLevel() + ->find(); + $coll = $this->buildCollection(array($t1, $t2, $t5, $t4, $t6, $t7), 'orderByLevel() orders by level, from the root to the leaf'); + $objs = Table9Query::create() + ->orderByLevel(true) + ->find(); + $coll = $this->buildCollection(array($t7, $t6, $t4, $t5, $t2, $t1), 'orderByLevel(true) orders by level, from the leaf to the root'); + } + + public function testFindRoot() + { + $this->assertTrue(method_exists('Table9Query', 'findRoot'), 'nested_set adds a findRoot() method'); + Table9Query::create()->deleteAll(); + $this->assertNull(Table9Query::create()->findRoot(), 'findRoot() returns null as long as no root node is defined'); + $t1 = new Table9(); + $t1->setLeftValue(123); + $t1->setRightValue(456); + $t1->save(); + $this->assertNull(Table9Query::create()->findRoot(), 'findRoot() returns null as long as no root node is defined'); + $t2 = new Table9(); + $t2->setLeftValue(1); + $t2->setRightValue(2); + $t2->save(); + $this->assertEquals(Table9Query::create()->findRoot(), $t2, 'findRoot() retrieves the root node'); + } + + public function testfindTree() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); + $tree = Table9Query::create()->findTree(); + $coll = $this->buildCollection(array($t1, $t2, $t3, $t4, $t5, $t6, $t7)); + $this->assertEquals($coll, $tree, 'findTree() retrieves the whole tree, ordered by branch'); + } + + protected function buildCollection($arr) + { + $coll = new PropelObjectCollection(); + $coll->setData($arr); + $coll->setModel('Table9'); + + return $coll; + } - public function testOrderByLevel() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - $t5->moveToPrevSiblingOf($t4); - /* Results in - t1 - | \ - t2 t3 - | \ - t5 t4 - | \ - t6 t7 - */ - $objs = Table9Query::create() - ->orderByLevel() - ->find(); - $coll = $this->buildCollection(array($t1, $t2, $t5, $t4, $t6, $t7), 'orderByLevel() orders by level, from the root to the leaf'); - $objs = Table9Query::create() - ->orderByLevel(true) - ->find(); - $coll = $this->buildCollection(array($t7, $t6, $t4, $t5, $t2, $t1), 'orderByLevel(true) orders by level, from the leaf to the root'); - } - - public function testFindRoot() - { - $this->assertTrue(method_exists('Table9Query', 'findRoot'), 'nested_set adds a findRoot() method'); - Table9Query::create()->deleteAll(); - $this->assertNull(Table9Query::create()->findRoot(), 'findRoot() returns null as long as no root node is defined'); - $t1 = new Table9(); - $t1->setLeftValue(123); - $t1->setRightValue(456); - $t1->save(); - $this->assertNull(Table9Query::create()->findRoot(), 'findRoot() returns null as long as no root node is defined'); - $t2 = new Table9(); - $t2->setLeftValue(1); - $t2->setRightValue(2); - $t2->save(); - $this->assertEquals(Table9Query::create()->findRoot(), $t2, 'findRoot() retrieves the root node'); - } - - public function testfindTree() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7) = $this->initTree(); - $tree = Table9Query::create()->findTree(); - $coll = $this->buildCollection(array($t1, $t2, $t3, $t4, $t5, $t6, $t7)); - $this->assertEquals($coll, $tree, 'findTree() retrieves the whole tree, ordered by branch'); - } - - protected function buildCollection($arr) - { - $coll = new PropelObjectCollection(); - $coll->setData($arr); - $coll->setModel('Table9'); - - return $coll; - } - } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorQueryBuilderModifierWithScopeTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorQueryBuilderModifierWithScopeTest.php index a7c283628..fc968edca 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorQueryBuilderModifierWithScopeTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorQueryBuilderModifierWithScopeTest.php @@ -9,277 +9,300 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/behavior/BookstoreNestedSetTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/behavior/BookstoreNestedSetTestBase.php'; /** * Tests for NestedSetBehaviorQueryBuilderModifier class with scope enabled * * @author François Zaninotto - * @version $Revision: 1612 $ + * @version $Revision$ * @package generator.behavior.nestedset */ -class NestedSetBehaviorQueryBuilderModifierWithScopeTest extends BookstoreNestedSetTestBase +class NestedSetBehaviorQueryBuilderModifierWithScopeTest extends BookstoreNestedSetTestBase { - public function testTreeRoots() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $objs = Table10Query::create() - ->treeRoots() - ->find(); - $coll = $this->buildCollection(array($t1, $t8)); - $this->assertEquals($coll, $objs, 'treeRoots() filters by roots'); - } + public function testTreeRoots() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $objs = Table10Query::create() + ->treeRoots() + ->find(); + $coll = $this->buildCollection(array($t1, $t8)); + $this->assertEquals($coll, $objs, 'treeRoots() filters by roots'); + } - public function testInTree() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $tree = Table10Query::create() - ->inTree(1) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t1, $t2, $t3, $t4, $t5, $t6, $t7)); - $this->assertEquals($coll, $tree, 'inTree() filters by node'); - $tree = Table10Query::create() - ->inTree(2) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t8, $t9, $t10)); - $this->assertEquals($coll, $tree, 'inTree() filters by node'); - } - - public function testDescendantsOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $objs = Table10Query::create() - ->descendantsOf($t1) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t2, $t3, $t4, $t5, $t6, $t7)); - $this->assertEquals($coll, $objs, 'decendantsOf() filters by descendants of the same scope'); - } + public function testInTree() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $tree = Table10Query::create() + ->inTree(1) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t1, $t2, $t3, $t4, $t5, $t6, $t7)); + $this->assertEquals($coll, $tree, 'inTree() filters by node'); + $tree = Table10Query::create() + ->inTree(2) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t8, $t9, $t10)); + $this->assertEquals($coll, $tree, 'inTree() filters by node'); + } - public function testBranchOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $objs = Table10Query::create() - ->branchOf($t1) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t1, $t2, $t3, $t4, $t5, $t6, $t7)); - $this->assertEquals($coll, $objs, 'branchOf() filters by branch of the same scope'); + public function testDescendantsOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $objs = Table10Query::create() + ->descendantsOf($t1) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t2, $t3, $t4, $t5, $t6, $t7)); + $this->assertEquals($coll, $objs, 'descendantsOf() filters by descendants of the same scope'); + } - } + public function testBranchOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $objs = Table10Query::create() + ->branchOf($t1) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t1, $t2, $t3, $t4, $t5, $t6, $t7)); + $this->assertEquals($coll, $objs, 'branchOf() filters by branch of the same scope'); - public function testChildrenOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $objs = Table10Query::create() - ->childrenOf($t1) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t2, $t3)); - $this->assertEquals($coll, $objs, 'childrenOf() filters by children of the same scope'); - } + } - public function testSiblingsOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $desc = Table10Query::create() - ->siblingsOf($t3) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t2)); - $this->assertEquals($coll, $desc, 'siblingsOf() returns filters by siblings of the same scope'); - } + public function testChildrenOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $objs = Table10Query::create() + ->childrenOf($t1) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t2, $t3)); + $this->assertEquals($coll, $objs, 'childrenOf() filters by children of the same scope'); + } - public function testAncestorsOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $objs = Table10Query::create() - ->ancestorsOf($t5) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t1, $t3), 'ancestorsOf() filters by ancestors of the same scope'); - } + public function testSiblingsOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $desc = Table10Query::create() + ->siblingsOf($t3) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t2)); + $this->assertEquals($coll, $desc, 'siblingsOf() returns filters by siblings of the same scope'); + } + + public function testAncestorsOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $objs = Table10Query::create() + ->ancestorsOf($t5) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t1, $t3), 'ancestorsOf() filters by ancestors of the same scope'); + } + + public function testRootsOf() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $objs = Table10Query::create() + ->rootsOf($t5) + ->orderByBranch() + ->find(); + $coll = $this->buildCollection(array($t1, $t3, $t5), 'rootsOf() filters by ancestors of the same scope'); + } + + public function testFindRoot() + { + $this->assertTrue(method_exists('Table10Query', 'findRoot'), 'nested_set adds a findRoot() method'); + Table10Query::create()->deleteAll(); + $this->assertNull(Table10Query::create()->findRoot(1), 'findRoot() returns null as long as no root node is defined'); + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $this->assertEquals($t1, Table10Query::create()->findRoot(1), 'findRoot() returns a tree root'); + $this->assertEquals($t8, Table10Query::create()->findRoot(2), 'findRoot() returns a tree root'); + } + + public function testFindRoots() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $objs = Table10Query::create() + ->findRoots(); + $coll = $this->buildCollection(array($t1, $t8)); + $this->assertEquals($coll, $objs, 'findRoots() returns all root objects'); + } + + public function testFindTree() + { + list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); + /* Tree used for tests + Scope 1 + t1 + | \ + t2 t3 + | \ + t4 t5 + | \ + t6 t7 + Scope 2 + t8 + | \ + t9 t10 + */ + $tree = Table10Query::create()->findTree(1); + $coll = $this->buildCollection(array($t1, $t2, $t3, $t4, $t5, $t6, $t7)); + $this->assertEquals($coll, $tree, 'findTree() retrieves the tree of a scope, ordered by branch'); + $tree = Table10Query::create()->findTree(2); + $coll = $this->buildCollection(array($t8, $t9, $t10)); + $this->assertEquals($coll, $tree, 'findTree() retrieves the tree of a scope, ordered by branch'); + } + + protected function buildCollection($arr) + { + $coll = new PropelObjectCollection(); + $coll->setData($arr); + $coll->setModel('Table10'); + + return $coll; + } - public function testRootsOf() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $objs = Table10Query::create() - ->rootsOf($t5) - ->orderByBranch() - ->find(); - $coll = $this->buildCollection(array($t1, $t3, $t5), 'rootsOf() filters by ancestors of the same scope'); - } - - public function testFindRoot() - { - $this->assertTrue(method_exists('Table10Query', 'findRoot'), 'nested_set adds a findRoot() method'); - Table10Query::create()->deleteAll(); - $this->assertNull(Table10Query::create()->findRoot(1), 'findRoot() returns null as long as no root node is defined'); - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $this->assertEquals($t1, Table10Query::create()->findRoot(1), 'findRoot() returns a tree root'); - $this->assertEquals($t8, Table10Query::create()->findRoot(2), 'findRoot() returns a tree root'); - } - - public function testFindTree() - { - list($t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->initTreeWithScope(); - /* Tree used for tests - Scope 1 - t1 - | \ - t2 t3 - | \ - t4 t5 - | \ - t6 t7 - Scope 2 - t8 - | \ - t9 t10 - */ - $tree = Table10Query::create()->findTree(1); - $coll = $this->buildCollection(array($t1, $t2, $t3, $t4, $t5, $t6, $t7)); - $this->assertEquals($coll, $tree, 'findTree() retrieves the tree of a scope, ordered by branch'); - $tree = Table10Query::create()->findTree(2); - $coll = $this->buildCollection(array($t8, $t9, $t10)); - $this->assertEquals($coll, $tree, 'findTree() retrieves the tree of a scope, ordered by branch'); - } - - protected function buildCollection($arr) - { - $coll = new PropelObjectCollection(); - $coll->setData($arr); - $coll->setModel('Table10'); - - return $coll; - } - } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorTest.php index 06594aac8..dd42cd63e 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorTest.php @@ -1,7 +1,6 @@ assertEquals(count($table9->getColumns()), 5, 'nested_set adds three column by default'); - $this->assertTrue(method_exists('Table9', 'getTreeLeft'), 'nested_set adds a tree_left column by default'); - $this->assertTrue(method_exists('Table9', 'getLeftValue'), 'nested_set maps the left_value getter with the tree_left column'); - $this->assertTrue(method_exists('Table9', 'getTreeRight'), 'nested_set adds a tree_right column by default'); - $this->assertTrue(method_exists('Table9', 'getRightValue'), 'nested_set maps the right_value getter with the tree_right column'); - $this->assertTrue(method_exists('Table9', 'getTreeLevel'), 'nested_set adds a tree_level column by default'); - $this->assertTrue(method_exists('Table9', 'getLevel'), 'nested_set maps the level getter with the tree_level column'); - $this->assertFalse(method_exists('Table9', 'getTreeScope'), 'nested_set does not add a tree_scope column by default'); - $this->assertFalse(method_exists('Table9', 'getScopeValue'), 'nested_set does not map the scope_value getter with the tree_scope column by default'); + public function testDefault() + { + $table9 = Table9Peer::getTableMap(); + $this->assertEquals(count($table9->getColumns()), 5, 'nested_set adds three column by default'); + $this->assertTrue(method_exists('Table9', 'getTreeLeft'), 'nested_set adds a tree_left column by default'); + $this->assertTrue(method_exists('Table9', 'getLeftValue'), 'nested_set maps the left_value getter with the tree_left column'); + $this->assertTrue(method_exists('Table9', 'getTreeRight'), 'nested_set adds a tree_right column by default'); + $this->assertTrue(method_exists('Table9', 'getRightValue'), 'nested_set maps the right_value getter with the tree_right column'); + $this->assertTrue(method_exists('Table9', 'getTreeLevel'), 'nested_set adds a tree_level column by default'); + $this->assertTrue(method_exists('Table9', 'getLevel'), 'nested_set maps the level getter with the tree_level column'); + $this->assertFalse(method_exists('Table9', 'getTreeScope'), 'nested_set does not add a tree_scope column by default'); + $this->assertFalse(method_exists('Table9', 'getScopeValue'), 'nested_set does not map the scope_value getter with the tree_scope column by default'); - } - - public function testParameters() - { - $table10 = Table10Peer::getTableMap(); - $this->assertEquals(count($table10->getColumns()), 6, 'nested_set does not add columns when they already exist'); - $this->assertTrue(method_exists('Table10', 'getLeftValue'), 'nested_set maps the left_value getter with the tree_left column'); - $this->assertTrue(method_exists('Table10', 'getRightValue'), 'nested_set maps the right_value getter with the tree_right column'); - $this->assertTrue(method_exists('Table10', 'getLevel'), 'nested_set maps the level getter with the tree_level column'); - $this->assertTrue(method_exists('Table10', 'getScopeValue'), 'nested_set maps the scope_value getter with the tree_scope column when the use_scope parameter is true'); - } + } -} \ No newline at end of file + public function testParameters() + { + $table10 = Table10Peer::getTableMap(); + $this->assertEquals(count($table10->getColumns()), 6, 'nested_set does not add columns when they already exist'); + $this->assertTrue(method_exists('Table10', 'getLeftValue'), 'nested_set maps the left_value getter with the tree_left column'); + $this->assertTrue(method_exists('Table10', 'getRightValue'), 'nested_set maps the right_value getter with the tree_right column'); + $this->assertTrue(method_exists('Table10', 'getLevel'), 'nested_set maps the level getter with the tree_level column'); + $this->assertTrue(method_exists('Table10', 'getScopeValue'), 'nested_set maps the scope_value getter with the tree_scope column when the use_scope parameter is true'); + } + + public function testGeneratedSqlForMySQL() + { + $schema = << + + +
+ + + + + + + + + + + + + + + + +
+ +XML; + $expectedSql = <<= 4.1.x +# It "suspends judgement" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +-- --------------------------------------------------------------------- +-- thread +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `thread`; + +CREATE TABLE `thread` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`) +) ENGINE=MyISAM; + +-- --------------------------------------------------------------------- +-- post +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `post`; + +CREATE TABLE `post` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `body` VARCHAR(255) NOT NULL, + `tree_left` INTEGER, + `tree_right` INTEGER, + `tree_level` INTEGER, + `thread_id` INTEGER, + PRIMARY KEY (`id`), + INDEX `post_FI_1` (`thread_id`), + CONSTRAINT `post_FK_1` + FOREIGN KEY (`thread_id`) + REFERENCES `thread` (`id`) + ON DELETE CASCADE +) ENGINE=InnoDB; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; + +SQL; + $builder = new PropelQuickBuilder(); + $builder->setPlatform(new MysqlPlatform()); + $builder->setSchema($schema); + + $this->assertEquals($expectedSql, $builder->getSQL()); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorWithNamespaceTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorWithNamespaceTest.php new file mode 100644 index 000000000..7040c5404 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/nestedset/NestedSetBehaviorWithNamespaceTest.php @@ -0,0 +1,59 @@ + + + + + + +
+ +EOF; + + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $builder->build(); + } + } + + public function testActiveRecordApi() + { + $this->assertTrue(method_exists('My\NestedSet1', 'getTreeLeft'), 'nested_set adds a tree_left column by default'); + $this->assertTrue(method_exists('My\NestedSet1', 'getLeftValue'), 'nested_set maps the left_value getter with the tree_left column'); + $this->assertTrue(method_exists('My\NestedSet1', 'getTreeRight'), 'nested_set adds a tree_right column by default'); + $this->assertTrue(method_exists('My\NestedSet1', 'getRightValue'), 'nested_set maps the right_value getter with the tree_right column'); + $this->assertTrue(method_exists('My\NestedSet1', 'getTreeLevel'), 'nested_set adds a tree_level column by default'); + $this->assertTrue(method_exists('My\NestedSet1', 'getLevel'), 'nested_set maps the level getter with the tree_level column'); + $this->assertFalse(method_exists('My\NestedSet1', 'getTreeScope'), 'nested_set does not add a tree_scope column by default'); + $this->assertFalse(method_exists('My\NestedSet1', 'getScopeValue'), 'nested_set does not map the scope_value getter with the tree_scope column by default'); + } + + public function testAddChild() + { + $obj1 = new \My\NestedSet1(); + $obj1->save(); + + $obj1->addChild(new \My\NestedSet1()); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/sluggable/SluggableBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/sluggable/SluggableBehaviorTest.php index a65bf3ea8..f1b07987c 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/sluggable/SluggableBehaviorTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/sluggable/SluggableBehaviorTest.php @@ -1,7 +1,6 @@ assertEquals(count($table13->getColumns()), 3, 'Sluggable adds one columns by default'); - $this->assertTrue(method_exists('Table13', 'getSlug'), 'Sluggable adds a slug column by default'); - $table14 = Table14Peer::getTableMap(); - $this->assertEquals(count($table14->getColumns()), 3, 'Sluggable does not add a column when it already exists'); - $this->assertTrue(method_exists('Table14', 'getUrl'), 'Sluggable allows customization of slug_column name'); - $this->assertTrue(method_exists('Table14', 'getSlug'), 'Sluggable adds a standard getter for the slug column'); - } - - public function testObjectGetter() - { - $this->assertTrue(method_exists('Table13', 'getSlug'), 'Sluggable adds a getter for the slug column'); - $t = new Table13(); - $t->setSlug('foo'); - $this->assertEquals('foo', $t->getSlug(), 'getSlug() returns the object slug'); - $this->assertTrue(method_exists('Table14', 'getSlug'), 'Sluggable adds a getter for the slug column, even if the column does not have the default name'); - $t = new Table14(); - $t->setUrl('foo'); - $this->assertEquals('foo', $t->getSlug(), 'getSlug() returns the object slug'); - } + public function testParameters() + { + $table13 = Table13Peer::getTableMap(); + $this->assertEquals(count($table13->getColumns()), 3, 'Sluggable adds one columns by default'); + $this->assertTrue(method_exists('Table13', 'getSlug'), 'Sluggable adds a slug column by default'); + $table14 = Table14Peer::getTableMap(); + $this->assertEquals(count($table14->getColumns()), 3, 'Sluggable does not add a column when it already exists'); + $this->assertTrue(method_exists('Table14', 'getUrl'), 'Sluggable allows customization of slug_column name'); + $this->assertTrue(method_exists('Table14', 'getSlug'), 'Sluggable adds a standard getter for the slug column'); + } - public function testObjectSetter() - { - $this->assertTrue(method_exists('Table13', 'setSlug'), 'Sluggable adds a setter for the slug column'); - $t = new Table13(); - $t->setSlug('foo'); - $this->assertEquals('foo', $t->getSlug(), 'setSlug() sets the object slug'); - $this->assertTrue(method_exists('Table14', 'setSlug'), 'Sluggable adds a setter for the slug column, even if the column does not have the default name'); - $t = new Table14(); - $t->setSlug('foo'); - $this->assertEquals('foo', $t->getUrl(), 'setSlug() sets the object slug'); - } - - public function testObjectCreateRawSlug() - { - $t = new TestableTable13(); - $this->assertEquals('n-a', $t->createRawSlug(), 'createRawSlug() returns an empty string for an empty object with no pattern'); - $t->setTitle('Hello, World'); - $this->assertEquals('hello-world', $t->createRawSlug(), 'createRawSlug() returns the cleaned up object string representation by default'); - - $t = new TestableTable14(); - $this->assertEquals('/foo/n-a/bar', $t->createRawSlug(), 'createRawSlug() returns a slug for an empty object with a pattern'); - $t->setTitle('Hello, World'); - $this->assertEquals('/foo/hello-world/bar', $t->createRawSlug(), 'createRawSlug() returns a slug based on a pattern'); - } - - public static function cleanupSlugProvider() - { - return array( - array('', 'n-a'), - array('foo', 'foo'), - array('foo bar', 'foo-bar'), - array('foo bar', 'foo-bar'), - array('FoO', 'foo'), - array('fôo', 'foo'), - array(' foo ', 'foo'), - array('f/o:o', 'f-o-o'), - array('foo1', 'foo1'), - ); - } - - /** - * @dataProvider cleanupSlugProvider - */ - public function testObjectCleanupSlugPart($in, $out) - { - $t = new TestableTable13(); - $this->assertEquals($out, $t->cleanupSlugPart($in), 'cleanupSlugPart() cleans up the slug part'); - } + public function testObjectGetter() + { + $this->assertTrue(method_exists('Table13', 'getSlug'), 'Sluggable adds a getter for the slug column'); + $t = new Table13(); + $t->setSlug('foo'); + $this->assertEquals('foo', $t->getSlug(), 'getSlug() returns the object slug'); + $this->assertTrue(method_exists('Table14', 'getSlug'), 'Sluggable adds a getter for the slug column, even if the column does not have the default name'); + $t = new Table14(); + $t->setUrl('foo'); + $this->assertEquals('foo', $t->getSlug(), 'getSlug() returns the object slug'); + } - public static function limitSlugSizeProvider() - { - return array( - array('123', '123'), - array(str_repeat('*', 80), str_repeat('*', 80)), - array(str_repeat('*', 97), str_repeat('*', 97)), - array(str_repeat('*', 98), str_repeat('*', 97)), - array(str_repeat('*', 99), str_repeat('*', 97)), - array(str_repeat('*', 100), str_repeat('*', 97)), - array(str_repeat('*', 150), str_repeat('*', 97)), - ); - } - - /** - * @dataProvider limitSlugSizeProvider - */ - public function testObjectLimitSlugSize($in, $out) - { - $t = new TestableTable14(); - $this->assertEquals($out, $t->limitSlugSize($in), 'limitSlugsize() limits the slug size'); - } - - public function testObjectMakeSlugUnique() - { - Table13Query::create()->deleteAll(); - $t = new TestableTable13(); - $this->assertEquals('', $t->makeSlugUnique(''), 'makeSlugUnique() returns the input slug when the input is empty'); - $this->assertEquals('foo', $t->makeSlugUnique('foo'), 'makeSlugUnique() returns the input slug when the table is empty'); - $t->setSlug('foo'); - $t->save(); - $t = new TestableTable13(); - $this->assertEquals('bar', $t->makeSlugUnique('bar'), 'makeSlugUnique() returns the input slug when the table does not contain a similar slug'); - $t->save(); - $t = new TestableTable13(); - $this->assertEquals('foo-1', $t->makeSlugUnique('foo'), 'makeSlugUnique() returns an incremented input when it already exists'); - $t->setSlug('foo-1'); - $t->save(); - $t = new TestableTable13(); - $this->assertEquals('foo-2', $t->makeSlugUnique('foo'), 'makeSlugUnique() returns an incremented input when it already exists'); - } - - public function testObjectCreateSlug() - { - Table13Query::create()->deleteAll(); - $t = new TestableTable13(); - $this->assertEquals('n-a', $t->createSlug(), 'createSlug() returns n-a for an empty object'); - $t->setTitle('Hello, World!'); - $this->assertEquals('hello-world', $t->createSlug(), 'createSlug() returns a cleaned up slug'); - $t->setSlug('hello-world'); - $t->save(); - $t = new TestableTable13(); - $t->setTitle('Hello; wOrld'); - $this->assertEquals('hello-world-1', $t->createSlug(), 'createSlug() returns a unique slug'); + public function testObjectSetter() + { + $this->assertTrue(method_exists('Table13', 'setSlug'), 'Sluggable adds a setter for the slug column'); + $t = new Table13(); + $t->setSlug('foo'); + $this->assertEquals('foo', $t->getSlug(), 'setSlug() sets the object slug'); + $this->assertTrue(method_exists('Table14', 'setSlug'), 'Sluggable adds a setter for the slug column, even if the column does not have the default name'); + $t = new Table14(); + $t->setSlug('foo'); + $this->assertEquals('foo', $t->getUrl(), 'setSlug() sets the object slug'); + } - Table14Query::create()->deleteAll(); - $t = new TestableTable14(); - $this->assertEquals('/foo/n-a/bar', $t->createSlug(), 'createSlug() returns a slug for an empty object with a pattern'); - $t->setTitle('Hello, World!'); - $this->assertEquals('/foo/hello-world/bar', $t->createSlug(), 'createSlug() returns a cleaned up slug'); - $t->setSlug('/foo/hello-world/bar'); - $t->save(); - $t = new TestableTable14(); - $t->setTitle('Hello; wOrld:'); - $this->assertEquals('/foo/hello-world/bar/1', $t->createSlug(), 'createSlug() returns a unique slug'); - } - - public function testObjectPreSave() - { - Table14Query::create()->deleteAll(); - $t = new Table14(); - $t->save(); - $this->assertEquals('/foo/n-a/bar', $t->getSlug(), 'preSave() sets a default slug for empty objects'); - $t = new Table14(); - $t->setTitle('Hello, World'); - $t->save(); - $this->assertEquals('/foo/hello-world/bar', $t->getSlug(), 'preSave() sets a cleanued up slug for objects'); - $t = new Table14(); - $t->setTitle('Hello, World'); - $t->save(); - $this->assertEquals('/foo/hello-world/bar/1', $t->getSlug(), 'preSave() sets a unique slug for objects'); - $t = new Table14(); - $t->setTitle('Hello, World'); - $t->setSlug('/foo/custom/bar'); - $t->save(); - $this->assertEquals('/foo/custom/bar', $t->getSlug(), 'preSave() uses the given slug if it exists'); - $t = new Table14(); - $t->setTitle('Hello, World'); - $t->setSlug('/foo/custom/bar'); - $t->save(); - $this->assertEquals('/foo/custom/bar/1', $t->getSlug(), 'preSave() uses the given slug if it exists and makes it unique'); - } - - public function testObjectSlugLifecycle() - { - Table13Query::create()->deleteAll(); - $t = new Table13(); - $t->setTitle('Hello, World'); - $t->save(); - $this->assertEquals('hello-world', $t->getSlug(), 'preSave() creates a slug for new objects'); - $t->setSlug('hello-bar'); - $t->save(); - $this->assertEquals('hello-bar', $t->getSlug(), 'setSlug() allows to override default slug'); - $t->setSlug(''); - $t->save(); - $this->assertEquals('hello-world', $t->getSlug(), 'setSlug(null) relaunches the slug generation'); + public function testObjectCreateRawSlug() + { + $t = new TestableTable13(); + $this->assertEquals('n-a', $t->createRawSlug(), 'createRawSlug() returns an empty string for an empty object with no pattern'); + $t->setTitle('Hello, World'); + $this->assertEquals('hello-world', $t->createRawSlug(), 'createRawSlug() returns the cleaned up object string representation by default'); - Table14Query::create()->deleteAll(); - $t = new Table14(); - $t->setTitle('Hello, World2'); - $t->setSlug('hello-bar2'); - $t->save(); - $this->assertEquals('hello-bar2', $t->getSlug(), 'setSlug() allows to override default slug, even before save'); - $t->setSlug(''); - $t->save(); - $this->assertEquals('/foo/hello-world2/bar', $t->getSlug(), 'setSlug(null) relaunches the slug generation'); - } - - public function testObjectSlugAutoUpdate() - { - Table13Query::create()->deleteAll(); - $t = new Table13(); - $t->setTitle('Hello, World'); - $t->save(); - $this->assertEquals('hello-world', $t->getSlug(), 'preSave() creates a slug for new objects'); - $t->setTitle('Hello, My World'); - $t->save(); - $this->assertEquals('hello-my-world', $t->getSlug(), 'preSave() autoupdates slug on object change'); - $t->setTitle('Hello, My Whole New World'); - $t->setSlug('hello-bar'); - $t->save(); - $this->assertEquals('hello-bar', $t->getSlug(), 'preSave() does not autoupdate slug when it was set by the user'); - } + $t = new TestableTable14(); + $this->assertEquals('/foo/n-a/bar', $t->createRawSlug(), 'createRawSlug() returns a slug for an empty object with a pattern'); + $t->setTitle('Hello, World'); + $this->assertEquals('/foo/hello-world/bar', $t->createRawSlug(), 'createRawSlug() returns a slug based on a pattern'); + } - public function testObjectSlugAutoUpdatePermanent() - { - Table14Query::create()->deleteAll(); - $t = new Table14(); - $t->setTitle('Hello, World'); - $t->save(); - $this->assertEquals('/foo/hello-world/bar', $t->getSlug(), 'preSave() creates a slug for new objects'); - $t->setTitle('Hello, My World'); - $t->save(); - $this->assertEquals('/foo/hello-world/bar', $t->getSlug(), 'preSave() does not autoupdate slug on object change for permanent slugs'); - $t->setSlug('hello-bar'); - $t->save(); - $this->assertEquals('hello-bar', $t->getSlug(), 'setSlug() still works for permanent slugs'); - } + public static function cleanupSlugProvider() + { + return array( + array('', 'n-a'), + array('foo', 'foo'), + array('foo bar', 'foo-bar'), + array('foo bar', 'foo-bar'), + array('FoO', 'foo'), + array('fôo', 'foo'), + array(' foo ', 'foo'), + array('f/o:o', 'f-o-o'), + array('foo1', 'foo1'), + ); + } - public function testQueryFindOneBySlug() - { - $this->assertTrue(method_exists('Table13Query', 'findOneBySlug'), 'The generated query provides a findOneBySlug() method'); - $this->assertTrue(method_exists('Table14Query', 'findOneBySlug'), 'The generated query provides a findOneBySlug() method even if the slug column doesnt have the default name'); - - Table14Query::create()->deleteAll(); - $t1 = new Table14(); - $t1->setTitle('Hello, World'); - $t1->save(); - $t2 = new Table14(); - $t2->setTitle('Hello, Cruel World'); - $t2->save(); - $t = Table14Query::create()->findOneBySlug('/foo/hello-world/bar'); - $this->assertEquals($t1, $t, 'findOneBySlug() returns a single object matching the slug'); - } + /** + * @dataProvider cleanupSlugProvider + */ + public function testObjectCleanupSlugPart($in, $out) + { + $t = new TestableTable13(); + $this->assertEquals($out, $t->cleanupSlugPart($in), 'cleanupSlugPart() cleans up the slug part'); + } + + public static function limitSlugSizeProvider() + { + return array( + array('123', '123'), + array(str_repeat('*', 80), str_repeat('*', 80)), + array(str_repeat('*', 97), str_repeat('*', 97)), + array(str_repeat('*', 98), str_repeat('*', 97)), + array(str_repeat('*', 99), str_repeat('*', 97)), + array(str_repeat('*', 100), str_repeat('*', 97)), + array(str_repeat('*', 150), str_repeat('*', 97)), + ); + } + + /** + * @dataProvider limitSlugSizeProvider + */ + public function testObjectLimitSlugSize($in, $out) + { + $t = new TestableTable14(); + $this->assertEquals($out, $t->limitSlugSize($in), 'limitSlugsize() limits the slug size'); + } + + public function testObjectMakeSlugUnique() + { + Table13Query::create()->deleteAll(); + $t = new TestableTable13(); + $this->assertEquals('', $t->makeSlugUnique(''), 'makeSlugUnique() returns the input slug when the input is empty'); + $this->assertEquals('foo', $t->makeSlugUnique('foo'), 'makeSlugUnique() returns the input slug when the table is empty'); + $t->setSlug('foo'); + $t->save(); + $t = new TestableTable13(); + $this->assertEquals('bar', $t->makeSlugUnique('bar'), 'makeSlugUnique() returns the input slug when the table does not contain a similar slug'); + $t->save(); + $t = new TestableTable13(); + $this->assertEquals('foo-1', $t->makeSlugUnique('foo'), 'makeSlugUnique() returns an incremented input when it already exists'); + $t->setSlug('foo-1'); + $t->save(); + $t = new TestableTable13(); + $this->assertEquals('foo-2', $t->makeSlugUnique('foo'), 'makeSlugUnique() returns an incremented input when it already exists'); + + TableWithScopeQuery::create()->deleteAll(); + $t = new TestTableWithScope(); + $this->assertEquals('foo', $t->makeSlugUnique('foo'), 'makeSlugUnique() returns the input slug when the table is empty'); + $t->setSlug('foo'); + $t->setScope(1); + $t->save(); + $t = new TestTableWithScope(); + $t->setScope(1); + $this->assertEquals('foo-1', $t->makeSlugUnique('foo'), 'makeSlugUnique() returns an incremented input when it already exists'); + $t->setSlug('foo-1'); + $t->save(); + $t = new TestTableWithScope(); + $t->setScope(1); + $this->assertEquals('foo-2', $t->makeSlugUnique('foo'), 'makeSlugUnique() returns an incremented input when it already exists'); + } + + public function testObjectCreateSlug() + { + Table13Query::create()->deleteAll(); + $t = new TestableTable13(); + $this->assertEquals('n-a', $t->createSlug(), 'createSlug() returns n-a for an empty object'); + $t->setTitle('Hello, World!'); + $this->assertEquals('hello-world', $t->createSlug(), 'createSlug() returns a cleaned up slug'); + $t->setSlug('hello-world'); + $t->save(); + $t = new TestableTable13(); + $t->setTitle('Hello; wOrld'); + $this->assertEquals('hello-world-1', $t->createSlug(), 'createSlug() returns a unique slug'); + + Table14Query::create()->deleteAll(); + $t = new TestableTable14(); + $this->assertEquals('/foo/n-a/bar', $t->createSlug(), 'createSlug() returns a slug for an empty object with a pattern'); + $t->setTitle('Hello, World!'); + $this->assertEquals('/foo/hello-world/bar', $t->createSlug(), 'createSlug() returns a cleaned up slug'); + $t->setSlug('/foo/hello-world/bar'); + $t->save(); + $t = new TestableTable14(); + $t->setTitle('Hello; wOrld:'); + $this->assertEquals('/foo/hello-world/bar/1', $t->createSlug(), 'createSlug() returns a unique slug'); + } + + public function testObjectPreSave() + { + Table14Query::create()->deleteAll(); + $t = new Table14(); + $t->save(); + $this->assertEquals('/foo/n-a/bar', $t->getSlug(), 'preSave() sets a default slug for empty objects'); + $t = new Table14(); + $t->setTitle('Hello, World'); + $t->save(); + $this->assertEquals('/foo/hello-world/bar', $t->getSlug(), 'preSave() sets a cleaned up slug for objects'); + $t = new Table14(); + $t->setTitle('Hello, World'); + $t->save(); + $this->assertEquals('/foo/hello-world/bar/1', $t->getSlug(), 'preSave() sets a unique slug for objects'); + $t = new Table14(); + $t->setTitle('Hello, World'); + $t->setSlug('/foo/custom/bar'); + $t->save(); + $this->assertEquals('/foo/custom/bar', $t->getSlug(), 'preSave() uses the given slug if it exists'); + $t = new Table14(); + $t->setTitle('Hello, World'); + $t->setSlug('/foo/custom/bar'); + $t->save(); + $this->assertEquals('/foo/custom/bar/1', $t->getSlug(), 'preSave() uses the given slug if it exists and makes it unique'); + } + + public function testObjectSlugLifecycle() + { + Table13Query::create()->deleteAll(); + $t = new Table13(); + $t->setTitle('Hello, World'); + $t->save(); + $this->assertEquals('hello-world', $t->getSlug(), 'preSave() creates a slug for new objects'); + $t->setSlug('hello-bar'); + $t->save(); + $this->assertEquals('hello-bar', $t->getSlug(), 'setSlug() allows to override default slug'); + $t->setSlug(''); + $t->save(); + $this->assertEquals('hello-world', $t->getSlug(), 'setSlug(null) relaunches the slug generation'); + + Table14Query::create()->deleteAll(); + $t = new Table14(); + $t->setTitle('Hello, World2'); + $t->setSlug('hello-bar2'); + $t->save(); + $this->assertEquals('hello-bar2', $t->getSlug(), 'setSlug() allows to override default slug, even before save'); + $t->setSlug(''); + $t->save(); + $this->assertEquals('/foo/hello-world2/bar', $t->getSlug(), 'setSlug(null) relaunches the slug generation'); + } + + public function testObjectSlugAutoUpdate() + { + Table13Query::create()->deleteAll(); + $t = new Table13(); + $t->setTitle('Hello, World'); + $t->save(); + $this->assertEquals('hello-world', $t->getSlug(), 'preSave() creates a slug for new objects'); + $t->setTitle('Hello, My World'); + $t->save(); + $this->assertEquals('hello-my-world', $t->getSlug(), 'preSave() autoupdates slug on object change'); + $t->setTitle('Hello, My Whole New World'); + $t->setSlug('hello-bar'); + $t->save(); + $this->assertEquals('hello-bar', $t->getSlug(), 'preSave() does not autoupdate slug when it was set by the user'); + } + + public function testObjectSlugAutoUpdatePermanent() + { + Table14Query::create()->deleteAll(); + $t = new Table14(); + $t->setTitle('Hello, World'); + $t->save(); + $this->assertEquals('/foo/hello-world/bar', $t->getSlug(), 'preSave() creates a slug for new objects'); + $t->setTitle('Hello, My World'); + $t->save(); + $this->assertEquals('/foo/hello-world/bar', $t->getSlug(), 'preSave() does not autoupdate slug on object change for permanent slugs'); + $t->setSlug('hello-bar'); + $t->save(); + $this->assertEquals('hello-bar', $t->getSlug(), 'setSlug() still works for permanent slugs'); + } + + public function testQueryFindOneBySlug() + { + $this->assertFalse(method_exists('Table13Query', 'findOneBySlug'), 'The generated query does not provide a findOneBySlug() method if the slug column is "slug".'); + $this->assertTrue(method_exists('Table14Query', 'findOneBySlug'), 'The generated query provides a findOneBySlug() method if the slug column is not "slug".'); + + Table14Query::create()->deleteAll(); + $t1 = new Table14(); + $t1->setTitle('Hello, World'); + $t1->save(); + $t2 = new Table14(); + $t2->setTitle('Hello, Cruel World'); + $t2->save(); + $t = Table14Query::create()->findOneBySlug('/foo/hello-world/bar'); + $this->assertEquals($t1, $t, 'findOneBySlug() returns a single object matching the slug'); + } + + public function testUniqueViolationWithoutScope() + { + TableWithScopeQuery::create()->deleteAll(); + $t = new TableWithScope(); + $t->setTitle('Hello, World'); + $t->save(); + $this->assertEquals('hello-world', $t->getSlug()); + + try { + $t = new TableWithScope(); + $t->setTitle('Hello, World'); + $t->save(); + + $this->fail('Exception expected'); + } catch (Exception $e) { + $this->assertTrue(true, 'Exception successfully thrown'); + } + } + + public function testNoUniqueViolationWithScope() + { + TableWithScopeQuery::create()->deleteAll(); + $t = new TableWithScope(); + $t->setTitle('Hello, World'); + $t->save(); + $this->assertEquals('hello-world', $t->getSlug()); + + try { + $t = new TableWithScope(); + $t->setTitle('Hello, World'); + $t->setScope(1); + $t->save(); + + $this->assertEquals('hello-world', $t->getSlug()); + } catch (Exception $e) { + $this->fail($e->getMessage()); + } + } + + public function testPatternNonPermanent() + { + Table14PatternQuery::create()->deleteAll(); + + $t = new Table14Pattern(); + $t->setTitle('Hello, World'); + $t->setTags('test,tag,php'); + $t->save(); + $this->assertEquals('/foo/hello-world/bar/test-tag-php', $t->getUrl()); + + $t->setTags('php,propel'); + $t->save(); + $this->assertEquals('/foo/hello-world/bar/php-propel', $t->getUrl()); + + $t->setTitle('Title2'); + $t->save(); + $this->assertEquals('/foo/title2/bar/php-propel', $t->getUrl()); + } + + public function testNumberOfQueriesForMakeUniqSlug() + { + Table13Query::create()->deleteAll(); + $con = Propel::getConnection(Table13Peer::DATABASE_NAME); + + for ($i=0; $i < 5; $i++) { + $nbQuery = $con->getQueryCount(); + + $t = new Table13(); + $t->setTitle('Hello, World'); + $t->save($con); + + $this->assertLessThanOrEqual(4, $con->getQueryCount() - $nbQuery, 'no more than 4 query to get a slug when it already exist'); + } + } + + public function testSlugRegexp() + { + Table13Query::create()->deleteAll(); + $con = Propel::getConnection(Table13Peer::DATABASE_NAME); + + for ($i=0; $i < 3; $i++) { + $t = new Table13(); + $t->setTitle('Hello, World'); + $t->save($con); + } + $this->assertEquals('hello-world-2', $t->getSlug()); + + $t = new Table13(); + $t->setTitle('World'); + $t->save($con); + + $this->assertEquals('world', $t->getSlug()); + + $t = new Table13(); + $t->setTitle('World'); + $t->save($con); + + $this->assertEquals('world-1', $t->getSlug()); + + $t = new Table13(); + $t->setTitle('Hello, World'); + $t->save($con); + + $this->assertEquals('hello-world-3', $t->getSlug()); + + $t = new Table13(); + $t->setTitle('World'); + $t->save($con); + + $this->assertEquals('world-2', $t->getSlug()); + + $t = new Table13(); + $t->setTitle('World 000'); + $t->save($con); + + $this->assertEquals('world-000', $t->getSlug()); + + $t = new Table13(); + $t->setTitle('World'); + $t->save($con); + + $this->assertEquals('world-101', $t->getSlug()); + + $t = new Table13(); + $t->setTitle('World'); + $t->save($con); + + $this->assertEquals('world-102', $t->getSlug()); + } } class TestableTable13 extends Table13 { - public function createSlug() - { - return parent::createSlug(); - } - - public function createRawSlug() - { - return parent::createRawSlug(); - } - - public static function cleanupSlugPart($slug, $separator = '-') - { - return parent::cleanupSlugPart($slug, $separator); - } - - public function makeSlugUnique($slug, $separator = '-', $increment = 0) - { - return parent::makeSlugUnique($slug, $separator, $increment); - } + public function createSlug() + { + return parent::createSlug(); + } + + public function createRawSlug() + { + return parent::createRawSlug(); + } + + public static function cleanupSlugPart($slug, $separator = '-') + { + return parent::cleanupSlugPart($slug, $separator); + } + + public function makeSlugUnique($slug, $separator = '-', $increment = 0) + { + return parent::makeSlugUnique($slug, $separator, $increment); + } } class TestableTable14 extends Table14 { - public function createSlug() - { - return parent::createSlug(); - } - - public function createRawSlug() - { - return parent::createRawSlug(); - } - - public static function limitSlugSize($slug, $incrementReservedSpace = 3) - { - return parent::limitSlugSize($slug, $incrementReservedSpace); - } -} \ No newline at end of file + public function createSlug() + { + return parent::createSlug(); + } + + public function createRawSlug() + { + return parent::createRawSlug(); + } + + public static function limitSlugSize($slug, $incrementReservedSpace = 3) + { + return parent::limitSlugSize($slug, $incrementReservedSpace); + } +} + +class TestTableWithScope extends TableWithScope +{ + public function createSlug() + { + return parent::createSlug(); + } + + public function createRawSlug() + { + return parent::createRawSlug(); + } + + public static function cleanupSlugPart($slug, $separator = '-') + { + return parent::cleanupSlugPart($slug, $separator); + } + + public function makeSlugUnique($slug, $separator = '-', $increment = 0) + { + return parent::makeSlugUnique($slug, $separator, $increment); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorObjectBuilderModifierTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorObjectBuilderModifierTest.php index 125e03a7f..c43383654 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorObjectBuilderModifierTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorObjectBuilderModifierTest.php @@ -9,271 +9,270 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/behavior/BookstoreSortableTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/behavior/BookstoreSortableTestBase.php'; /** * Tests for SortableBehavior class * * @author Massimiliano Arione - * @version $Revision: 1612 $ + * @version $Revision$ * @package generator.behavior.sortable */ class SortableBehaviorObjectBuilderModifierTest extends BookstoreSortableTestBase { - protected function setUp() - { - parent::setUp(); - $this->populateTable11(); - } - - public function testPreInsert() - { - Table11Peer::doDeleteAll(); - $t1 = new Table11(); - $t1->save(); - $this->assertEquals($t1->getRank(), 1, 'Sortable inserts new line in first position if no row present'); - $t2 = new Table11(); - $t2->setTitle('row2'); - $t2->save(); - $this->assertEquals($t2->getRank(), 2, 'Sortable inserts new line in last position'); - } - - public function testPreDelete() - { - $max = Table11Peer::getMaxRank(); - $t3 = Table11Peer::retrieveByRank(3); - $t3->delete(); - $this->assertEquals($max - 1, Table11Peer::getMaxRank(), 'Sortable rearrange subsequent rows on delete'); - $c = new Criteria(); - $c->add(Table11Peer::TITLE, 'row4'); - $t4 = Table11Peer::doSelectOne($c); - $this->assertEquals(3, $t4->getRank(), 'Sortable rearrange subsequent rows on delete'); - } - - public function testIsFirst() - { - $first = Table11Peer::retrieveByRank(1); - $middle = Table11Peer::retrieveByRank(2); - $last = Table11Peer::retrieveByRank(4); - $this->assertTrue($first->isFirst(), 'isFirst() returns true for the first in the rank'); - $this->assertFalse($middle->isFirst(), 'isFirst() returns false for a middle rank'); - $this->assertFalse($last->isFirst(), 'isFirst() returns false for the last in the rank'); - } + protected function setUp() + { + parent::setUp(); + $this->populateTable11(); + } - public function testIsLast() - { - $first = Table11Peer::retrieveByRank(1); - $middle = Table11Peer::retrieveByRank(2); - $last = Table11Peer::retrieveByRank(4); - $this->assertFalse($first->isLast(), 'isLast() returns false for the first in the rank'); - $this->assertFalse($middle->isLast(), 'isLast() returns false for a middle rank'); - $this->assertTrue($last->isLast(), 'isLast() returns true for the last in the rank'); - } + public function testPreInsert() + { + Table11Peer::doDeleteAll(); + $t1 = new Table11(); + $t1->save(); + $this->assertEquals($t1->getRank(), 1, 'Sortable inserts new line in first position if no row present'); + $t2 = new Table11(); + $t2->setTitle('row2'); + $t2->save(); + $this->assertEquals($t2->getRank(), 2, 'Sortable inserts new line in last position'); + } - public function testGetNext() - { - $t = Table11Peer::retrieveByRank(3); - $this->assertEquals(4, $t->getNext()->getRank(), 'getNext() returns the next object in rank'); - - $t = Table11Peer::retrieveByRank(4); - $this->assertNull($t->getNext(), 'getNext() returns null for the last object'); - } + public function testPreDelete() + { + $max = Table11Peer::getMaxRank(); + $t3 = Table11Peer::retrieveByRank(3); + $t3->delete(); + $this->assertEquals($max - 1, Table11Peer::getMaxRank(), 'Sortable rearrange subsequent rows on delete'); + $c = new Criteria(); + $c->add(Table11Peer::TITLE, 'row4'); + $t4 = Table11Peer::doSelectOne($c); + $this->assertEquals(3, $t4->getRank(), 'Sortable rearrange subsequent rows on delete'); + } - public function testGetPrevious() - { - $t = Table11Peer::retrieveByRank(3); - $this->assertEquals(2, $t->getPrevious()->getRank(), 'getPrevious() returns the previous object in rank'); + public function testIsFirst() + { + $first = Table11Peer::retrieveByRank(1); + $middle = Table11Peer::retrieveByRank(2); + $last = Table11Peer::retrieveByRank(4); + $this->assertTrue($first->isFirst(), 'isFirst() returns true for the first in the rank'); + $this->assertFalse($middle->isFirst(), 'isFirst() returns false for a middle rank'); + $this->assertFalse($last->isFirst(), 'isFirst() returns false for the last in the rank'); + } - $t = Table11Peer::retrieveByRank(1); - $this->assertNull($t->getPrevious(), 'getPrevious() returns null for the first object'); - } - - public function testInsertAtRank() - { - $t = new Table11(); - $t->setTitle('new'); - $t->insertAtRank(2); - $this->assertEquals(2, $t->getRank(), 'insertAtRank() sets the position'); - $this->assertTrue($t->isNew(), 'insertAtRank() doesn\'t save the object'); - $t->save(); - $expected = array(1 => 'row1', 2 => 'new', 3 => 'row2', 4 => 'row3', 5 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArray(), 'insertAtRank() shifts the entire suite'); - } - - public function testInsertAtMaxRankPlusOne() - { - $t = new Table11(); - $t->setTitle('new'); - $t->insertAtRank(5); - $this->assertEquals(5, $t->getRank(), 'insertAtRank() sets the position'); - $t->save(); - $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4', 5 => 'new'); - $this->assertEquals($expected, $this->getFixturesArray(), 'insertAtRank() can insert an object at the end of the list'); - } + public function testIsLast() + { + $first = Table11Peer::retrieveByRank(1); + $middle = Table11Peer::retrieveByRank(2); + $last = Table11Peer::retrieveByRank(4); + $this->assertFalse($first->isLast(), 'isLast() returns false for the first in the rank'); + $this->assertFalse($middle->isLast(), 'isLast() returns false for a middle rank'); + $this->assertTrue($last->isLast(), 'isLast() returns true for the last in the rank'); + } - /** - * @expectedException PropelException - */ - public function testInsertAtNegativeRank() - { - $t = new Table11(); - $t->insertAtRank(0); - } + public function testGetNext() + { + $t = Table11Peer::retrieveByRank(3); + $this->assertEquals(4, $t->getNext()->getRank(), 'getNext() returns the next object in rank'); - /** - * @expectedException PropelException - */ - public function testInsertAtOverMaxRank() - { - $t = new Table11(); - $t->insertAtRank(6); - } + $t = Table11Peer::retrieveByRank(4); + $this->assertNull($t->getNext(), 'getNext() returns null for the last object'); + } - public function testInsertAtBottom() - { - $t = new Table11(); - $t->setTitle('new'); - $t->insertAtBottom(); - $this->assertEquals(5, $t->getRank(), 'insertAtBottom() sets the position to the last'); - $this->assertTrue($t->isNew(), 'insertAtBottom() doesn\'t save the object'); - $t->save(); - $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4', 5 => 'new'); - $this->assertEquals($expected, $this->getFixturesArray(), 'insertAtBottom() does not shift the entire suite'); - } + public function testGetPrevious() + { + $t = Table11Peer::retrieveByRank(3); + $this->assertEquals(2, $t->getPrevious()->getRank(), 'getPrevious() returns the previous object in rank'); - public function testInsertAtTop() - { - $t = new Table11(); - $t->setTitle('new'); - $t->insertAtTop(); - $this->assertEquals(1, $t->getRank(), 'insertAtTop() sets the position to 1'); - $this->assertTrue($t->isNew(), 'insertAtTop() doesn\'t save the object'); - $t->save(); - $expected = array(1 => 'new', 2 => 'row1', 3 => 'row2', 4 => 'row3', 5 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArray(), 'insertAtTop() shifts the entire suite'); - } + $t = Table11Peer::retrieveByRank(1); + $this->assertNull($t->getPrevious(), 'getPrevious() returns null for the first object'); + } - public function testMoveToRank() - { - $t2 = Table11Peer::retrieveByRank(2); - $t2->moveToRank(3); - $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row2', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArray(), 'moveToRank() can move up'); - $t2->moveToRank(1); - $expected = array(1 => 'row2', 2 => 'row1', 3 => 'row3', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArray(), 'moveToRank() can move to the first rank'); - $t2->moveToRank(4); - $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); - $this->assertEquals($expected, $this->getFixturesArray(), 'moveToRank() can move to the last rank'); - $t2->moveToRank(2); - $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArray(), 'moveToRank() can move down'); - } + public function testInsertAtRank() + { + $t = new Table11(); + $t->setTitle('new'); + $t->insertAtRank(2); + $this->assertEquals(2, $t->getRank(), 'insertAtRank() sets the position'); + $this->assertTrue($t->isNew(), 'insertAtRank() doesn\'t save the object'); + $t->save(); + $expected = array(1 => 'row1', 2 => 'new', 3 => 'row2', 4 => 'row3', 5 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArray(), 'insertAtRank() shifts the entire suite'); + } - /** - * @expectedException PropelException - */ - public function testMoveToNewObject() - { - $t = new Table11(); - $t->moveToRank(2); - } + public function testInsertAtMaxRankPlusOne() + { + $t = new Table11(); + $t->setTitle('new'); + $t->insertAtRank(5); + $this->assertEquals(5, $t->getRank(), 'insertAtRank() sets the position'); + $t->save(); + $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4', 5 => 'new'); + $this->assertEquals($expected, $this->getFixturesArray(), 'insertAtRank() can insert an object at the end of the list'); + } - /** - * @expectedException PropelException - */ - public function testMoveToNegativeRank() - { - $t = Table11Peer::retrieveByRank(2); - $t->moveToRank(0); - } + /** + * @expectedException PropelException + */ + public function testInsertAtNegativeRank() + { + $t = new Table11(); + $t->insertAtRank(0); + } - /** - * @expectedException PropelException - */ - public function testMoveToOverMaxRank() - { - $t = Table11Peer::retrieveByRank(2); - $t->moveToRank(5); - } + /** + * @expectedException PropelException + */ + public function testInsertAtOverMaxRank() + { + $t = new Table11(); + $t->insertAtRank(6); + } - public function testSwapWith() - { - $t2 = Table11Peer::retrieveByRank(2); - $t4 = Table11Peer::retrieveByRank(4); - $t2->swapWith($t4); - $expected = array(1 => 'row1', 2 => 'row4', 3 => 'row3', 4 => 'row2'); - $this->assertEquals($expected, $this->getFixturesArray(), 'swapWith() swaps ranks of the two objects and leaves the other ranks unchanged'); - } + public function testInsertAtBottom() + { + $t = new Table11(); + $t->setTitle('new'); + $t->insertAtBottom(); + $this->assertEquals(5, $t->getRank(), 'insertAtBottom() sets the position to the last'); + $this->assertTrue($t->isNew(), 'insertAtBottom() doesn\'t save the object'); + $t->save(); + $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4', 5 => 'new'); + $this->assertEquals($expected, $this->getFixturesArray(), 'insertAtBottom() does not shift the entire suite'); + } - public function testMoveUp() - { - $t3 = Table11Peer::retrieveByRank(3); - $res = $t3->moveUp(); - $this->assertEquals($t3, $res, 'moveUp() returns the current object'); - $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row2', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArray(), 'moveUp() swaps ranks with the object of higher rank'); - $t3->moveUp(); - $expected = array(1 => 'row3', 2 => 'row1', 3 => 'row2', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArray(), 'moveUp() swaps ranks with the object of higher rank'); - $res = $t3->moveUp(); - $expected = array(1 => 'row3', 2 => 'row1', 3 => 'row2', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArray(), 'moveUp() changes nothing when called on the object at the top'); - } + public function testInsertAtTop() + { + $t = new Table11(); + $t->setTitle('new'); + $t->insertAtTop(); + $this->assertEquals(1, $t->getRank(), 'insertAtTop() sets the position to 1'); + $this->assertTrue($t->isNew(), 'insertAtTop() doesn\'t save the object'); + $t->save(); + $expected = array(1 => 'new', 2 => 'row1', 3 => 'row2', 4 => 'row3', 5 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArray(), 'insertAtTop() shifts the entire suite'); + } - public function testMoveDown() - { - $t2 = Table11Peer::retrieveByRank(2); - $res = $t2->moveDown(); - $this->assertEquals($t2, $res, 'moveDown() returns the current object'); - $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row2', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArray(), 'moveDown() swaps ranks with the object of lower rank'); - $t2->moveDown(); - $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); - $this->assertEquals($expected, $this->getFixturesArray(), 'moveDown() swaps ranks with the object of lower rank'); - $res = $t2->moveDown(); - $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); - $this->assertEquals($expected, $this->getFixturesArray(), 'moveDown() changes nothing when called on the object at the bottom'); - } + public function testMoveToRank() + { + $t2 = Table11Peer::retrieveByRank(2); + $t2->moveToRank(3); + $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row2', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArray(), 'moveToRank() can move up'); + $t2->moveToRank(1); + $expected = array(1 => 'row2', 2 => 'row1', 3 => 'row3', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArray(), 'moveToRank() can move to the first rank'); + $t2->moveToRank(4); + $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); + $this->assertEquals($expected, $this->getFixturesArray(), 'moveToRank() can move to the last rank'); + $t2->moveToRank(2); + $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArray(), 'moveToRank() can move down'); + } - public function testMoveToTop() - { - $t3 = Table11Peer::retrieveByRank(3); - $res = $t3->moveToTop(); - $this->assertEquals($t3, $res, 'moveToTop() returns the current oobject'); - $expected = array(1 => 'row3', 2 => 'row1', 3 => 'row2', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArray(), 'moveToTop() moves to the top'); - $res = $t3->moveToTop(); - $expected = array(1 => 'row3', 2 => 'row1', 3 => 'row2', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArray(), 'moveToTop() changes nothing when called on the top node'); - } + /** + * @expectedException PropelException + */ + public function testMoveToNewObject() + { + $t = new Table11(); + $t->moveToRank(2); + } - public function testMoveToBottom() - { - $t2 = Table11Peer::retrieveByRank(2); - $res = $t2->moveToBottom(); - $this->assertEquals($t2, $res, 'moveToBottom() returns the current object'); - $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); - $this->assertEquals($expected, $this->getFixturesArray(), 'moveToBottom() moves to the bottom'); - $res = $t2->moveToBottom(); - $this->assertFalse($res, 'moveToBottom() returns false when called on the bottom node'); - $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); - $this->assertEquals($expected, $this->getFixturesArray(), 'moveToBottom() changes nothing when called on the bottom node'); - } - - public function testRemoveFromList() - { - $t2 = Table11Peer::retrieveByRank(2); - $res = $t2->removeFromList(); - $this->assertTrue($res instanceof Table11, 'removeFromList() returns the current object'); - $this->assertNull($res->getRank(), 'removeFromList() resets the object\'s rank'); - Table11Peer::clearInstancePool(); - $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArray(), 'removeFromList() does not change the list until the object is saved'); - $t2->save(); - Table11Peer::clearInstancePool(); - $expected = array(null => 'row2', 1 => 'row1', 2 => 'row3', 3 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArray(), 'removeFromList() changes the list once the object is saved'); - } + /** + * @expectedException PropelException + */ + public function testMoveToNegativeRank() + { + $t = Table11Peer::retrieveByRank(2); + $t->moveToRank(0); + } -} \ No newline at end of file + /** + * @expectedException PropelException + */ + public function testMoveToOverMaxRank() + { + $t = Table11Peer::retrieveByRank(2); + $t->moveToRank(5); + } + + public function testSwapWith() + { + $t2 = Table11Peer::retrieveByRank(2); + $t4 = Table11Peer::retrieveByRank(4); + $t2->swapWith($t4); + $expected = array(1 => 'row1', 2 => 'row4', 3 => 'row3', 4 => 'row2'); + $this->assertEquals($expected, $this->getFixturesArray(), 'swapWith() swaps ranks of the two objects and leaves the other ranks unchanged'); + } + + public function testMoveUp() + { + $t3 = Table11Peer::retrieveByRank(3); + $res = $t3->moveUp(); + $this->assertEquals($t3, $res, 'moveUp() returns the current object'); + $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row2', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArray(), 'moveUp() swaps ranks with the object of higher rank'); + $t3->moveUp(); + $expected = array(1 => 'row3', 2 => 'row1', 3 => 'row2', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArray(), 'moveUp() swaps ranks with the object of higher rank'); + $res = $t3->moveUp(); + $expected = array(1 => 'row3', 2 => 'row1', 3 => 'row2', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArray(), 'moveUp() changes nothing when called on the object at the top'); + } + + public function testMoveDown() + { + $t2 = Table11Peer::retrieveByRank(2); + $res = $t2->moveDown(); + $this->assertEquals($t2, $res, 'moveDown() returns the current object'); + $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row2', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArray(), 'moveDown() swaps ranks with the object of lower rank'); + $t2->moveDown(); + $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); + $this->assertEquals($expected, $this->getFixturesArray(), 'moveDown() swaps ranks with the object of lower rank'); + $res = $t2->moveDown(); + $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); + $this->assertEquals($expected, $this->getFixturesArray(), 'moveDown() changes nothing when called on the object at the bottom'); + } + + public function testMoveToTop() + { + $t3 = Table11Peer::retrieveByRank(3); + $res = $t3->moveToTop(); + $this->assertEquals($t3, $res, 'moveToTop() returns the current object'); + $expected = array(1 => 'row3', 2 => 'row1', 3 => 'row2', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArray(), 'moveToTop() moves to the top'); + $res = $t3->moveToTop(); + $expected = array(1 => 'row3', 2 => 'row1', 3 => 'row2', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArray(), 'moveToTop() changes nothing when called on the top node'); + } + + public function testMoveToBottom() + { + $t2 = Table11Peer::retrieveByRank(2); + $res = $t2->moveToBottom(); + $this->assertEquals($t2, $res, 'moveToBottom() returns the current object'); + $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); + $this->assertEquals($expected, $this->getFixturesArray(), 'moveToBottom() moves to the bottom'); + $res = $t2->moveToBottom(); + $this->assertFalse($res, 'moveToBottom() returns false when called on the bottom node'); + $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); + $this->assertEquals($expected, $this->getFixturesArray(), 'moveToBottom() changes nothing when called on the bottom node'); + } + + public function testRemoveFromList() + { + $t2 = Table11Peer::retrieveByRank(2); + $res = $t2->removeFromList(); + $this->assertTrue($res instanceof Table11, 'removeFromList() returns the current object'); + $this->assertNull($res->getRank(), 'removeFromList() resets the object\'s rank'); + Table11Peer::clearInstancePool(); + $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArray(), 'removeFromList() does not change the list until the object is saved'); + $t2->save(); + Table11Peer::clearInstancePool(); + $expected = array(null => 'row2', 1 => 'row1', 2 => 'row3', 3 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArray(), 'removeFromList() changes the list once the object is saved'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorObjectBuilderModifierWithScopeTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorObjectBuilderModifierWithScopeTest.php index 22261880a..2fcaef7ee 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorObjectBuilderModifierWithScopeTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorObjectBuilderModifierWithScopeTest.php @@ -9,327 +9,603 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/behavior/BookstoreSortableTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/behavior/BookstoreSortableTestBase.php'; /** * Tests for SortableBehavior class * * @author Massimiliano Arione - * @version $Revision: 1612 $ + * @author rozwell + * @version $Revision$ * @package generator.behavior.sortable */ class SortableBehaviorObjectBuilderModifierWithScopeTest extends BookstoreSortableTestBase { - protected function setUp() - { - parent::setUp(); - $this->populateTable12(); - } - - public function testPreInsert() - { - Table12Peer::doDeleteAll(); - $t1 = new Table12(); - $t1->setScopeValue(1); - $t1->save(); - $this->assertEquals($t1->getRank(), 1, 'Sortable inserts new line in first position if no row present'); - $t2 = new Table12(); - $t2->setScopeValue(1); - $t2->save(); - $this->assertEquals($t2->getRank(), 2, 'Sortable inserts new line in last position'); - $t2 = new Table12(); - $t2->setScopeValue(2); - $t2->save(); - $this->assertEquals($t2->getRank(), 1, 'Sortable inserts new line in last position'); - } - - public function testPreDelete() - { - $max = Table12Peer::getMaxRank(1); - $t3 = Table12Peer::retrieveByRank(3, 1); - $t3->delete(); - $this->assertEquals($max - 1, Table12Peer::getMaxRank(1), 'Sortable rearrange subsequent rows on delete'); - $c = new Criteria(); - $c->add(Table12Peer::TITLE, 'row4'); - $t4 = Table12Peer::doSelectOne($c); - $this->assertEquals(3, $t4->getRank(), 'Sortable rearrange subsequent rows on delete'); - $expected = array(1 => 'row5', 2 => 'row6'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'delete() leaves other suites unchanged'); - } - - public function testIsFirst() - { - $first = Table12Peer::retrieveByRank(1, 1); - $middle = Table12Peer::retrieveByRank(2, 1); - $last = Table12Peer::retrieveByRank(4, 1); - $this->assertTrue($first->isFirst(), 'isFirst() returns true for the first in the rank'); - $this->assertFalse($middle->isFirst(), 'isFirst() returns false for a middle rank'); - $this->assertFalse($last->isFirst(), 'isFirst() returns false for the last in the rank'); - $first = Table12Peer::retrieveByRank(1, 2); - $last = Table12Peer::retrieveByRank(2, 2); - $this->assertTrue($first->isFirst(), 'isFirst() returns true for the first in the rank'); - $this->assertFalse($last->isFirst(), 'isFirst() returns false for the last in the rank'); - } + protected function setUp() + { + parent::setUp(); + $this->populateTable12(); + } - public function testIsLast() - { - $first = Table12Peer::retrieveByRank(1, 1); - $middle = Table12Peer::retrieveByRank(2, 1); - $last = Table12Peer::retrieveByRank(4, 1); - $this->assertFalse($first->isLast(), 'isLast() returns false for the first in the rank'); - $this->assertFalse($middle->isLast(), 'isLast() returns false for a middle rank'); - $this->assertTrue($last->isLast(), 'isLast() returns true for the last in the rank'); - $first = Table12Peer::retrieveByRank(1, 2); - $last = Table12Peer::retrieveByRank(2, 2); - $this->assertFalse($first->isLast(), 'isLast() returns false for the first in the rank'); - $this->assertTrue($last->isLast(), 'isLast() returns true for the last in the rank'); - } + public function testPreInsert() + { + Table12Peer::doDeleteAll(); + $t1 = new Table12(); + $t1->setScopeValue(1); + $t1->save(); + $this->assertEquals($t1->getRank(), 1, 'Sortable inserts new line in first position if no row present'); + $t2 = new Table12(); + $t2->setScopeValue(1); + $t2->save(); + $this->assertEquals($t2->getRank(), 2, 'Sortable inserts new line in last position'); + $t2 = new Table12(); + $t2->setScopeValue(2); + $t2->save(); + $this->assertEquals($t2->getRank(), 1, 'Sortable inserts new line in last position'); + } - public function testGetNext() - { - $t = Table12Peer::retrieveByRank(1, 1); - $this->assertEquals('row2', $t->getNext()->getTitle(), 'getNext() returns the next object in rank in the same suite'); - $t = Table12Peer::retrieveByRank(1, 2); - $this->assertEquals('row6', $t->getNext()->getTitle(), 'getNext() returns the next object in rank in the same suite'); - - $t = Table12Peer::retrieveByRank(3, 1); - $this->assertEquals(4, $t->getNext()->getRank(), 'getNext() returns the next object in rank'); - - $t = Table12Peer::retrieveByRank(4, 1); - $this->assertNull($t->getNext(), 'getNext() returns null for the last object'); - } + public function testPreDelete() + { + $max = Table12Peer::getMaxRank(1); + $t3 = Table12Peer::retrieveByRank(3, 1); + $t3->delete(); + $this->assertEquals($max - 1, Table12Peer::getMaxRank(1), 'Sortable rearrange subsequent rows on delete'); + $c = new Criteria(); + $c->add(Table12Peer::TITLE, 'row4'); + $t4 = Table12Peer::doSelectOne($c); + $this->assertEquals(3, $t4->getRank(), 'Sortable rearrange subsequent rows on delete'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'delete() leaves other suites unchanged'); + $expected = array(1 => 'row7', 2 => 'row8', 3 => 'row9', 4 => 'row10'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(), 'delete() leaves other suites unchanged'); + } - public function testGetPrevious() - { - $t = Table12Peer::retrieveByRank(2, 1); - $this->assertEquals('row1', $t->getPrevious()->getTitle(), 'getPrevious() returns the previous object in rank in the same suite'); - $t = Table12Peer::retrieveByRank(2, 2); - $this->assertEquals('row5', $t->getPrevious()->getTitle(), 'getPrevious() returns the previous object in rank in the same suite'); - - $t = Table12Peer::retrieveByRank(3, 1); - $this->assertEquals(2, $t->getPrevious()->getRank(), 'getPrevious() returns the previous object in rank'); + public function testPreDeleteFkScope() + { + $this->populateFkScopeTable(); - $t = Table12Peer::retrieveByRank(1, 1); - $this->assertNull($t->getPrevious(), 'getPrevious() returns null for the first object'); - } - - public function testInsertAtRank() - { - $t = new Table12(); - $t->setTitle('new'); - $t->setScopeValue(1); - $t->insertAtRank(2); - $this->assertEquals(2, $t->getRank(), 'insertAtRank() sets the position'); - $this->assertTrue($t->isNew(), 'insertAtTop() doesn\'t save the object'); - $t->save(); - $expected = array(1 => 'row1', 2 => 'new', 3 => 'row2', 4 => 'row3', 5 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'insertAtRank() shifts the entire suite'); - $expected = array(1 => 'row5', 2 => 'row6'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'insertAtRank() leaves other suites unchanged'); - } + $t = Table11Peer::retrieveByRank(2); + $t->delete(); + $expected = array(1 => 'row7', 2 => 'row8', 3 => 'row9', 4 => 'row4', 5 => 'row5', 6 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithFkScope(), 'delete() moves related objects to the end of null scope'); - /** - * @expectedException PropelException - */ - public function testInsertAtNegativeRank() - { - $t = new Table12(); - $t->setScopeValue(1); - $t->insertAtRank(0); - } + $s = Table11Peer::retrieveByRank(1); + $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3'); + $this->assertEquals($expected, $this->getFixturesArrayWithFkScope($s->getId()), 'delete() leaves other suites unchanged'); + } - /** - * @expectedException PropelException - */ - public function testInsertAtOverMaxRank() - { - $t = new Table12(); - $t->setScopeValue(1); - $t->insertAtRank(6); - } - - /** - * @expectedException PropelException - */ - public function testInsertAtNoScope() - { - $t = new Table12(); - $t->insertAtRank(3); - } + public function testIsFirst() + { + $first = Table12Peer::retrieveByRank(1, 1); + $middle = Table12Peer::retrieveByRank(2, 1); + $last = Table12Peer::retrieveByRank(4, 1); + $this->assertTrue($first->isFirst(), 'isFirst() returns true for the first in the rank'); + $this->assertFalse($middle->isFirst(), 'isFirst() returns false for a middle rank'); + $this->assertFalse($last->isFirst(), 'isFirst() returns false for the last in the rank'); + $first = Table12Peer::retrieveByRank(1, 2); + $last = Table12Peer::retrieveByRank(2, 2); + $this->assertTrue($first->isFirst(), 'isFirst() returns true for the first in the rank'); + $this->assertFalse($last->isFirst(), 'isFirst() returns false for the last in the rank'); + } - public function testInsertAtBottom() - { - $t = new Table12(); - $t->setTitle('new'); - $t->setScopeValue(1); - $t->insertAtBottom(); - $this->assertEquals(5, $t->getRank(), 'insertAtBottom() sets the position to the last'); - $this->assertTrue($t->isNew(), 'insertAtTop() doesn\'t save the object'); - $t->save(); - $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4', 5 => 'new'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'insertAtBottom() does not shift the entire suite'); - $expected = array(1 => 'row5', 2 => 'row6'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'insertAtBottom() leaves other suites unchanged'); - } - - /** - * @expectedException PropelException - */ - public function testInsertAtBottomNoScope() - { - $t = new Table12(); - $t->insertAtBottom(); - } + public function testIsLast() + { + $first = Table12Peer::retrieveByRank(1, 1); + $middle = Table12Peer::retrieveByRank(2, 1); + $last = Table12Peer::retrieveByRank(4, 1); + $this->assertFalse($first->isLast(), 'isLast() returns false for the first in the rank'); + $this->assertFalse($middle->isLast(), 'isLast() returns false for a middle rank'); + $this->assertTrue($last->isLast(), 'isLast() returns true for the last in the rank'); + $first = Table12Peer::retrieveByRank(1, 2); + $last = Table12Peer::retrieveByRank(2, 2); + $this->assertFalse($first->isLast(), 'isLast() returns false for the first in the rank'); + $this->assertTrue($last->isLast(), 'isLast() returns true for the last in the rank'); + } - public function testInsertAtTop() - { - $t = new Table12(); - $t->setTitle('new'); - $t->setScopeValue(1); - $t->insertAtTop(); - $this->assertEquals(1, $t->getRank(), 'insertAtTop() sets the position to 1'); - $this->assertTrue($t->isNew(), 'insertAtTop() doesn\'t save the object'); - $t->save(); - $expected = array(1 => 'new', 2 => 'row1', 3 => 'row2', 4 => 'row3', 5 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'insertAtTop() shifts the entire suite'); - $expected = array(1 => 'row5', 2 => 'row6'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'insertAtTop() leaves other suites unchanged'); - } + public function testGetNext() + { + $t = Table12Peer::retrieveByRank(1, 1); + $this->assertEquals('row2', $t->getNext()->getTitle(), 'getNext() returns the next object in rank in the same suite'); + $t = Table12Peer::retrieveByRank(1, 2); + $this->assertEquals('row6', $t->getNext()->getTitle(), 'getNext() returns the next object in rank in the same suite'); - public function testMoveToRank() - { - $t2 = Table12Peer::retrieveByRank(2, 1); - $t2->moveToRank(3); - $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row2', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToRank() can move up'); - $expected = array(1 => 'row5', 2 => 'row6'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'moveToRank() leaves other suites unchanged'); - $t2->moveToRank(1); - $expected = array(1 => 'row2', 2 => 'row1', 3 => 'row3', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToRank() can move to the first rank'); - $t2->moveToRank(4); - $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToRank() can move to the last rank'); - $t2->moveToRank(2); - $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToRank() can move down'); - } + $t = Table12Peer::retrieveByRank(3, 1); + $this->assertEquals(4, $t->getNext()->getRank(), 'getNext() returns the next object in rank'); - /** - * @expectedException PropelException - */ - public function testMoveToNewObject() - { - $t = new Table12(); - $t->moveToRank(2); - } + $t = Table12Peer::retrieveByRank(4, 1); + $this->assertNull($t->getNext(), 'getNext() returns null for the last object'); + } - /** - * @expectedException PropelException - */ - public function testMoveToNegativeRank() - { - $t = Table12Peer::retrieveByRank(2, 1); - $t->moveToRank(0); - } + public function testGetPrevious() + { + $t = Table12Peer::retrieveByRank(2, 1); + $this->assertEquals('row1', $t->getPrevious()->getTitle(), 'getPrevious() returns the previous object in rank in the same suite'); + $t = Table12Peer::retrieveByRank(2, 2); + $this->assertEquals('row5', $t->getPrevious()->getTitle(), 'getPrevious() returns the previous object in rank in the same suite'); - /** - * @expectedException PropelException - */ - public function testMoveToOverMaxRank() - { - $t = Table12Peer::retrieveByRank(2, 1); - $t->moveToRank(5); - } + $t = Table12Peer::retrieveByRank(3, 1); + $this->assertEquals(2, $t->getPrevious()->getRank(), 'getPrevious() returns the previous object in rank'); - public function testSwapWith() - { - $t2 = Table12Peer::retrieveByRank(2, 1); - $t4 = Table12Peer::retrieveByRank(4, 1); - $t2->swapWith($t4); - $expected = array(1 => 'row1', 2 => 'row4', 3 => 'row3', 4 => 'row2'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'swapWith() swaps ranks of the two objects and leaves the other ranks unchanged'); - $expected = array(1 => 'row5', 2 => 'row6'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'swapWith() leaves other suites unchanged'); - } + $t = Table12Peer::retrieveByRank(1, 1); + $this->assertNull($t->getPrevious(), 'getPrevious() returns null for the first object'); + } - public function testMoveUp() - { - $t3 = Table12Peer::retrieveByRank(3, 1); - $res = $t3->moveUp(); - $this->assertEquals($t3, $res, 'moveUp() returns the current object'); - $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row2', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveUp() swaps ranks with the object of higher rank'); - $expected = array(1 => 'row5', 2 => 'row6'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'moveUp() leaves other suites unchanged'); - $t3->moveUp(); - $expected = array(1 => 'row3', 2 => 'row1', 3 => 'row2', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveUp() swaps ranks with the object of higher rank'); - $res = $t3->moveUp(); - $expected = array(1 => 'row3', 2 => 'row1', 3 => 'row2', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveUp() changes nothing when called on the object at the top'); - } + public function testInsertAtRank() + { + $t = new Table12(); + $t->setTitle('new'); + $t->setScopeValue(1); + $t->insertAtRank(2); + $this->assertEquals(2, $t->getRank(), 'insertAtRank() sets the position'); + $this->assertTrue($t->isNew(), 'insertAtRank() doesn\'t save the object'); + $t->save(); + $expected = array(1 => 'row1', 2 => 'new', 3 => 'row2', 4 => 'row3', 5 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'insertAtRank() shifts the entire suite'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'insertAtRank() leaves other suites unchanged'); + } - public function testMoveDown() - { - $t2 = Table12Peer::retrieveByRank(2, 1); - $res = $t2->moveDown(); - $this->assertEquals($t2, $res, 'moveDown() returns the current object'); - $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row2', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveDown() swaps ranks with the object of lower rank'); - $expected = array(1 => 'row5', 2 => 'row6'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'moveDown() leaves other suites unchanged'); - $t2->moveDown(); - $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveDown() swaps ranks with the object of lower rank'); - $res = $t2->moveDown(); - $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveDown() changes nothing when called on the object at the bottom'); - } + public function testInsertAtRankNoScope() + { + $t = new Table12(); + $t->setTitle('new'); + $t->insertAtRank(2); + $this->assertEquals(2, $t->getRank(), 'insertAtRank() sets the position'); + $this->assertTrue($t->isNew(), 'insertAtRank() doesn\'t save the object'); + $t->save(); + $expected = array(1 => 'row7', 2 => 'new', 3 => 'row8', 4 => 'row9', 5 => 'row10'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(), 'insertAtRank() shifts the entire suite'); + $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'insertAtRank() leaves other suites unchanged'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'insertAtRank() leaves other suites unchanged'); + } - public function testMoveToTop() - { - $t3 = Table12Peer::retrieveByRank(3, 1); - $res = $t3->moveToTop(); - $this->assertEquals($t3, $res, 'moveToTop() returns the current object'); - $expected = array(1 => 'row3', 2 => 'row1', 3 => 'row2', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToTop() moves to the top'); - $expected = array(1 => 'row5', 2 => 'row6'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'moveToTop() leaves other suites unchanged'); - $res = $t3->moveToTop(); - $expected = array(1 => 'row3', 2 => 'row1', 3 => 'row2', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToTop() changes nothing when called on the top node'); - } + /** + * @expectedException PropelException + */ + public function testInsertAtNegativeRank() + { + $t = new Table12(); + $t->setScopeValue(1); + $t->insertAtRank(0); + } - public function testMoveToBottom() - { - $t2 = Table12Peer::retrieveByRank(2, 1); - $res = $t2->moveToBottom(); - $this->assertEquals($t2, $res, 'moveToBottom() returns the current object'); - $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToBottom() moves to the bottom'); - $expected = array(1 => 'row5', 2 => 'row6'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'moveToBottom() leaves other suites unchanged'); - $res = $t2->moveToBottom(); - $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToBottom() changes nothing when called on the bottom node'); - } - - public function testRemoveFromList() - { - $t2 = Table12Peer::retrieveByRank(2, 1); - $res = $t2->removeFromList(); - $this->assertTrue($res instanceof Table12, 'removeFromList() returns the current object'); - $this->assertNull($res->getRank(), 'removeFromList() resets the object\'s rank'); - Table12Peer::clearInstancePool(); - $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'removeFromList() does not change the list until the object is saved'); - $t2->save(); - Table12Peer::clearInstancePool(); - $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'removeFromList() changes the list once the object is saved'); - $expected = array(1 => 'row5', 2 => 'row6'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'removeFromList() leaves other suites unchanged'); - } + /** + * @expectedException PropelException + */ + public function testInsertAtOverMaxRank() + { + $t = new Table12(); + $t->setScopeValue(1); + $t->insertAtRank(6); + } -} \ No newline at end of file + public function testInsertAtBottom() + { + $t = new Table12(); + $t->setTitle('new'); + $t->setScopeValue(1); + $t->insertAtBottom(); + $this->assertEquals(5, $t->getRank(), 'insertAtBottom() sets the position to the last'); + $this->assertTrue($t->isNew(), 'insertAtTop() doesn\'t save the object'); + $t->save(); + $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4', 5 => 'new'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'insertAtBottom() does not shift the entire suite'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'insertAtBottom() leaves other suites unchanged'); + } + + public function testInsertAtBottomNoScope() + { + $t = new Table12(); + $t->setTitle('new'); + $t->insertAtBottom(); + $this->assertEquals(5, $t->getRank(), 'insertAtBottom() sets the position to the last'); + $this->assertTrue($t->isNew(), 'insertAtTop() doesn\'t save the object'); + $t->save(); + $expected = array(1 => 'row7', 2 => 'row8', 3 => 'row9', 4 => 'row10', 5 => 'new'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(), 'insertAtBottom() does not shift the entire suite'); + $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'insertAtRank() leaves other suites unchanged'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'insertAtRank() leaves other suites unchanged'); + } + + public function testInsertAtTop() + { + $t = new Table12(); + $t->setTitle('new'); + $t->setScopeValue(1); + $t->insertAtTop(); + $this->assertEquals(1, $t->getRank(), 'insertAtTop() sets the position to 1'); + $this->assertTrue($t->isNew(), 'insertAtTop() doesn\'t save the object'); + $t->save(); + $expected = array(1 => 'new', 2 => 'row1', 3 => 'row2', 4 => 'row3', 5 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'insertAtTop() shifts the entire suite'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'insertAtTop() leaves other suites unchanged'); + } + + public function testInsertAtTopNoScope() + { + $t = new Table12(); + $t->setTitle('new'); + $t->insertAtTop(); + $this->assertEquals(1, $t->getRank(), 'insertAtTop() sets the position to 1'); + $this->assertTrue($t->isNew(), 'insertAtTop() doesn\'t save the object'); + $t->save(); + $expected = array(1 => 'new', 2 => 'row7', 3 => 'row8', 4 => 'row9', 5 => 'row10'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(), 'insertAtTop() shifts the entire suite'); + $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'insertAtRank() leaves other suites unchanged'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'insertAtRank() leaves other suites unchanged'); + } + + public function testMoveToRank() + { + $t2 = Table12Peer::retrieveByRank(2, 1); + $t2->moveToRank(3); + $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row2', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToRank() can move up'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'moveToRank() leaves other suites unchanged'); + $t2->moveToRank(1); + $expected = array(1 => 'row2', 2 => 'row1', 3 => 'row3', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToRank() can move to the first rank'); + $t2->moveToRank(4); + $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToRank() can move to the last rank'); + $t2->moveToRank(2); + $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToRank() can move down'); + } + + public function testMoveToRankNoScope() + { + $t2 = Table12Peer::retrieveByRank(2); + $t2->moveToRank(3); + $expected = array(1 => 'row7', 2 => 'row9', 3 => 'row8', 4 => 'row10'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(), 'moveToRank() can move up'); + $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'insertAtRank() leaves other suites unchanged'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'insertAtRank() leaves other suites unchanged'); + $t2->moveToRank(1); + $expected = array(1 => 'row8', 2 => 'row7', 3 => 'row9', 4 => 'row10'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(), 'moveToRank() can move to the first rank'); + $t2->moveToRank(4); + $expected = array(1 => 'row7', 2 => 'row9', 3 => 'row10', 4 => 'row8'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(), 'moveToRank() can move to the last rank'); + $t2->moveToRank(2); + $expected = array(1 => 'row7', 2 => 'row8', 3 => 'row9', 4 => 'row10'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(), 'moveToRank() can move down'); + } + + /** + * @expectedException PropelException + */ + public function testMoveToNewObject() + { + $t = new Table12(); + $t->moveToRank(2); + } + + /** + * @expectedException PropelException + */ + public function testMoveToNegativeRank() + { + $t = Table12Peer::retrieveByRank(2, 1); + $t->moveToRank(0); + } + + /** + * @expectedException PropelException + */ + public function testMoveToOverMaxRank() + { + $t = Table12Peer::retrieveByRank(2, 1); + $t->moveToRank(5); + } + + public function testSwapWith() + { + $t2 = Table12Peer::retrieveByRank(2, 1); + $t4 = Table12Peer::retrieveByRank(4, 1); + $t2->swapWith($t4); + $expected = array(1 => 'row1', 2 => 'row4', 3 => 'row3', 4 => 'row2'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'swapWith() swaps ranks of the two objects and leaves the other ranks unchanged'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'swapWith() leaves other suites unchanged'); + } + + public function testSwapWithBetweenScopes() + { + $t2 = Table12Peer::retrieveByRank(2, 1); + $t4 = Table12Peer::retrieveByRank(4); + $t2->swapWith($t4); + $expected = array(1 => 'row7', 2 => 'row8', 3 => 'row9', 4 => 'row2'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(), 'swapWith() swaps ranks of the two objects between scopes and leaves the other ranks unchanged'); + $expected = array(1 => 'row1', 2 => 'row10', 3 => 'row3', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'swapWith() swaps ranks of the two objects between scopes and leaves the other ranks unchanged'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'swapWith() leaves rest of suites unchanged'); + } + + public function testMoveUp() + { + $t3 = Table12Peer::retrieveByRank(3, 1); + $res = $t3->moveUp(); + $this->assertEquals($t3, $res, 'moveUp() returns the current object'); + $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row2', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveUp() swaps ranks with the object of higher rank'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'moveUp() leaves other suites unchanged'); + $t3->moveUp(); + $expected = array(1 => 'row3', 2 => 'row1', 3 => 'row2', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveUp() swaps ranks with the object of higher rank'); + $res = $t3->moveUp(); + $expected = array(1 => 'row3', 2 => 'row1', 3 => 'row2', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveUp() changes nothing when called on the object at the top'); + } + + public function testMoveDown() + { + $t2 = Table12Peer::retrieveByRank(2, 1); + $res = $t2->moveDown(); + $this->assertEquals($t2, $res, 'moveDown() returns the current object'); + $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row2', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveDown() swaps ranks with the object of lower rank'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'moveDown() leaves other suites unchanged'); + $t2->moveDown(); + $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveDown() swaps ranks with the object of lower rank'); + $res = $t2->moveDown(); + $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveDown() changes nothing when called on the object at the bottom'); + } + + public function testMoveToTop() + { + $t3 = Table12Peer::retrieveByRank(3, 1); + $res = $t3->moveToTop(); + $this->assertEquals($t3, $res, 'moveToTop() returns the current object'); + $expected = array(1 => 'row3', 2 => 'row1', 3 => 'row2', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToTop() moves to the top'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'moveToTop() leaves other suites unchanged'); + $res = $t3->moveToTop(); + $expected = array(1 => 'row3', 2 => 'row1', 3 => 'row2', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToTop() changes nothing when called on the top node'); + } + + public function testMoveToBottom() + { + $t2 = Table12Peer::retrieveByRank(2, 1); + $res = $t2->moveToBottom(); + $this->assertEquals($t2, $res, 'moveToBottom() returns the current object'); + $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToBottom() moves to the bottom'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'moveToBottom() leaves other suites unchanged'); + $res = $t2->moveToBottom(); + $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4', 4 => 'row2'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'moveToBottom() changes nothing when called on the bottom node'); + } + + public function testRemoveFromList() + { + $t2 = Table12Peer::retrieveByRank(2, 1); + $res = $t2->removeFromList(); + $this->assertTrue($res instanceof Table12, 'removeFromList() returns the current object'); + Table12Peer::clearInstancePool(); + $expected = array(1 => 'row1', 2 => 'row2', 3 => 'row3', 4 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'removeFromList() does not change the list until the object is saved'); + $t2->save(); + Table12Peer::clearInstancePool(); + $expected = array(1 => 'row1', 2 => 'row3', 3 => 'row4'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'removeFromList() changes the list and moves object to null scope once the object is saved'); + $expected = array(1 => 'row7', 2 => 'row8', 3 => 'row9', 4 => 'row10', 5 => 'row2'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(), 'removeFromList() moves object to the end of null scope'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'removeFromList() leaves other suites unchanged'); + } + + /** + * @expectedException PropelException + */ + public function testRemoveFromListNoScope() + { + $t2 = Table12Peer::retrieveByRank(2); + $t2->removeFromList(); + } + + /** + * @return SortableMultiScopes[] + */ + private function generateMultipleScopeEntries() + { + SortableMultiScopesPeer::doDeleteAll(); + + $items = array( + // cat scat title + array( 1, 1, 'item 1'), //1 + array( 2, 1, 'item 2'), //1 + array( 3, 1, 'item 3'), //1 + array( 3, 1, 'item 3.1'),//2 + array( 1, 1, 'item 1.1'),//2 + array( 1, 1, 'item 1.2'),//3 + array( 1, 2, 'item 1.3'),//1 + array( 1, 2, 'item 1.4'),//2 + ); + + $result = array(); + foreach ($items as $value) { + $item = new SortableMultiScopes(); + $item->setCategoryId($value[0]); + $item->setSubCategoryId($value[1]); + $item->setTitle($value[2]); + $item->save(); + $result[] = $item; + } + + return $result; + } + /** + * @return SortableMultiCommaScopes[] + */ + private function generateMultipleCommaScopeEntries() + { + SortableMultiCommaScopesPeer::doDeleteAll(); + + $items = array( + // cat scat title + array( 1, 1, 'item 1'), //1 + array( 2, 1, 'item 2'), //1 + array( 3, 1, 'item 3'), //1 + array( 3, 1, 'item 3.1'),//2 + array( 1, 1, 'item 1.1'),//2 + array( 1, 1, 'item 1.2'),//3 + array( 1, 2, 'item 1.3'),//1 + array( 1, 2, 'item 1.4'),//2 + ); + + $result = array(); + foreach ($items as $value) { + $item = new SortableMultiCommaScopes(); + $item->setCategoryId($value[0]); + $item->setSubCategoryId($value[1]); + $item->setTitle($value[2]); + $item->save(); + $result[] = $item; + } + + return $result; + } + + public function testMultipleScopes() + { + list($t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4) = $this->generateMultipleScopeEntries(); + + $this->assertEquals($t1->getRank(), 1); + $this->assertEquals($t2->getRank(), 1); + + $this->assertEquals($t3->getRank(), 1); + $this->assertEquals($t3_1->getRank(), 2); + + $this->assertEquals($t1_1->getRank(), 2); + $this->assertEquals($t1_2->getRank(), 3); + $this->assertEquals($t1_3->getRank(), 1); + $this->assertEquals($t1_4->getRank(), 2); + + } + + public function testMoveMultipleScopes() + { + list($t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4) = $this->generateMultipleScopeEntries(); + + $this->assertEquals($t1->getRank(), 1); + $this->assertEquals($t1_1->getRank(), 2); + $this->assertEquals($t1_2->getRank(), 3); + + $t1->moveDown(); + $this->assertEquals($t1->getRank(), 2); + $this->assertEquals($t1_1->getRank(), 1); + $this->assertEquals($t1_2->getRank(), 3); + + $t1->moveDown(); + $this->assertEquals($t1->getRank(), 3); + $this->assertEquals($t1_1->getRank(), 1); + $this->assertEquals($t1_2->getRank(), 2); + + $t1_1->moveUp(); //no changes + $this->assertEquals($t1->getRank(), 3); + $this->assertEquals($t1_1->getRank(), 1); + $this->assertEquals($t1_2->getRank(), 2); + + $t1_2->moveUp(); //no changes + $this->assertEquals($t1->getRank(), 3); + $this->assertEquals($t1_1->getRank(), 2); + $this->assertEquals($t1_2->getRank(), 1); + } + + public function testDeleteMultipleScopes() + { + list($t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4) = $this->generateMultipleScopeEntries(); + + $this->assertEquals($t1->getRank(), 1); + $this->assertEquals($t1_1->getRank(), 2); + $this->assertEquals($t1_2->getRank(), 3); + + $t1->delete(); + + $t1_1->reload(); + $t1_2->reload(); + $this->assertEquals($t1_1->getRank(), 1); + $this->assertEquals($t1_2->getRank(), 2); + } + + public function testMultipleCommaScopes() + { + list($t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4) = $this->generateMultipleCommaScopeEntries(); + + $this->assertEquals($t1->getRank(), 1); + $this->assertEquals($t2->getRank(), 1); + + $this->assertEquals($t3->getRank(), 1); + $this->assertEquals($t3_1->getRank(), 2); + + $this->assertEquals($t1_1->getRank(), 2); + $this->assertEquals($t1_2->getRank(), 3); + $this->assertEquals($t1_3->getRank(), 1); + $this->assertEquals($t1_4->getRank(), 2); + } + + public function testMoveMultipleCommaScopes() + { + list($t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4) = $this->generateMultipleCommaScopeEntries(); + + $this->assertEquals($t1->getRank(), 1); + $this->assertEquals($t1_1->getRank(), 2); + $this->assertEquals($t1_2->getRank(), 3); + + $t1->moveDown(); + $this->assertEquals($t1->getRank(), 2); + $this->assertEquals($t1_1->getRank(), 1); + $this->assertEquals($t1_2->getRank(), 3); + + $t1->moveDown(); + $this->assertEquals($t1->getRank(), 3); + $this->assertEquals($t1_1->getRank(), 1); + $this->assertEquals($t1_2->getRank(), 2); + + $t1_1->moveUp(); //no changes + $this->assertEquals($t1->getRank(), 3); + $this->assertEquals($t1_1->getRank(), 1); + $this->assertEquals($t1_2->getRank(), 2); + + $t1_2->moveUp(); //no changes + $this->assertEquals($t1->getRank(), 3); + $this->assertEquals($t1_1->getRank(), 2); + $this->assertEquals($t1_2->getRank(), 1); + } + + public function testDeleteMultipleCommaScopes() + { + list($t1, $t2, $t3, $t3_1, $t1_1, $t1_2, $t1_3, $t1_4) = $this->generateMultipleCommaScopeEntries(); + + $this->assertEquals($t1->getRank(), 1); + $this->assertEquals($t1_1->getRank(), 2); + $this->assertEquals($t1_2->getRank(), 3); + + $t1->delete(); + + $t1_1->reload(); + $t1_2->reload(); + $this->assertEquals($t1_1->getRank(), 1); + $this->assertEquals($t1_2->getRank(), 2); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorPeerBuilderModifierTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorPeerBuilderModifierTest.php index 3ffb26b7e..c1674ed8a 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorPeerBuilderModifierTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorPeerBuilderModifierTest.php @@ -9,75 +9,74 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/behavior/BookstoreSortableTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/behavior/BookstoreSortableTestBase.php'; /** * Tests for SortableBehavior class * * @author Massimiliano Arione - * @version $Revision: 1612 $ + * @version $Revision$ * @package generator.behavior.sortable */ class SortableBehaviorPeerBuilderModifierTest extends BookstoreSortableTestBase { - protected function setUp() - { - parent::setUp(); - $this->populateTable11(); - } - - public function testStaticAttributes() - { - $this->assertEquals(Table11Peer::RANK_COL, 'table11.SORTABLE_RANK'); - } - - public function testGetMaxRank() - { - $this->assertEquals(4, Table11Peer::getMaxRank(), 'getMaxRank() returns the maximum rank'); - $t4 = Table11Peer::retrieveByRank(4); - $t4->delete(); - $this->assertEquals(3, Table11Peer::getMaxRank(), 'getMaxRank() returns the maximum rank'); - Table11Peer::doDeleteAll(); - $this->assertNull(Table11Peer::getMaxRank(), 'getMaxRank() returns null for empty tables'); - } - public function testRetrieveByRank() - { - $t = Table11Peer::retrieveByRank(5); - $this->assertNull($t, 'retrieveByRank() returns null for an unknown rank'); - $t3 = Table11Peer::retrieveByRank(3); - $this->assertEquals(3, $t3->getRank(), 'retrieveByRank() returns the object with the required rank'); - $this->assertEquals('row3', $t3->getTitle(), 'retrieveByRank() returns the object with the required rank'); - } - - public function testReorder() - { - $objects = Table11Peer::doSelect(new Criteria()); - $ids = array(); - foreach ($objects as $object) { - $ids[]= $object->getPrimaryKey(); - } - $ranks = array(4, 3, 2, 1); - $order = array_combine($ids, $ranks); - Table11Peer::reorder($order); - $expected = array(1 => 'row3', 2 => 'row2', 3 => 'row4', 4 => 'row1'); - $this->assertEquals($expected, $this->getFixturesArray(), 'reorder() reorders the suite'); - } - - public function testDoSelectOrderByRank() - { - $objects = Table11Peer::doSelectOrderByRank(); - $oldRank = 0; - while ($object = array_shift($objects)) { - $this->assertTrue($object->getRank() > $oldRank); - $oldRank = $object->getRank(); - } - $objects = Table11Peer::doSelectOrderByRank(null, Criteria::DESC); - $oldRank = 10; - while ($object = array_shift($objects)) { - $this->assertTrue($object->getRank() < $oldRank); - $oldRank = $object->getRank(); - } - } - + protected function setUp() + { + parent::setUp(); + $this->populateTable11(); + } -} \ No newline at end of file + public function testStaticAttributes() + { + $this->assertEquals(Table11Peer::RANK_COL, 'table11.sortable_rank'); + } + + public function testGetMaxRank() + { + $this->assertEquals(4, Table11Peer::getMaxRank(), 'getMaxRank() returns the maximum rank'); + $t4 = Table11Peer::retrieveByRank(4); + $t4->delete(); + $this->assertEquals(3, Table11Peer::getMaxRank(), 'getMaxRank() returns the maximum rank'); + Table11Peer::doDeleteAll(); + $this->assertNull(Table11Peer::getMaxRank(), 'getMaxRank() returns null for empty tables'); + } + public function testRetrieveByRank() + { + $t = Table11Peer::retrieveByRank(5); + $this->assertNull($t, 'retrieveByRank() returns null for an unknown rank'); + $t3 = Table11Peer::retrieveByRank(3); + $this->assertEquals(3, $t3->getRank(), 'retrieveByRank() returns the object with the required rank'); + $this->assertEquals('row3', $t3->getTitle(), 'retrieveByRank() returns the object with the required rank'); + } + + public function testReorder() + { + $objects = Table11Peer::doSelect(new Criteria()); + $ids = array(); + foreach ($objects as $object) { + $ids[]= $object->getPrimaryKey(); + } + $ranks = array(4, 3, 2, 1); + $order = array_combine($ids, $ranks); + Table11Peer::reorder($order); + $expected = array(1 => 'row3', 2 => 'row2', 3 => 'row4', 4 => 'row1'); + $this->assertEquals($expected, $this->getFixturesArray(), 'reorder() reorders the suite'); + } + + public function testDoSelectOrderByRank() + { + $objects = Table11Peer::doSelectOrderByRank(); + $oldRank = 0; + while ($object = array_shift($objects)) { + $this->assertTrue($object->getRank() > $oldRank); + $oldRank = $object->getRank(); + } + $objects = Table11Peer::doSelectOrderByRank(null, Criteria::DESC); + $oldRank = 10; + while ($object = array_shift($objects)) { + $this->assertTrue($object->getRank() < $oldRank); + $oldRank = $object->getRank(); + } + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorPeerBuilderModifierWithScopeTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorPeerBuilderModifierWithScopeTest.php index f9a80f6e5..69a66a2fc 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorPeerBuilderModifierWithScopeTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorPeerBuilderModifierWithScopeTest.php @@ -9,106 +9,112 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/behavior/BookstoreSortableTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/behavior/BookstoreSortableTestBase.php'; /** * Tests for SortableBehavior class * * @author Massimiliano Arione - * @version $Revision: 1612 $ + * @author rozwell + * @version $Revision$ * @package generator.behavior.sortable */ class SortableBehaviorPeerBuilderModifierWithScopeTest extends BookstoreSortableTestBase { - protected function setUp() - { - parent::setUp(); - $this->populateTable12(); - } - - public function testStaticAttributes() - { - $this->assertEquals(Table12Peer::RANK_COL, 'table12.POSITION'); - $this->assertEquals(Table12Peer::SCOPE_COL, 'table12.MY_SCOPE_COLUMN'); - } - - public function testGetMaxRank() - { - $this->assertEquals(4, Table12Peer::getMaxRank(1), 'getMaxRank() returns the maximum rank of the suite'); - $this->assertEquals(2, Table12Peer::getMaxRank(2), 'getMaxRank() returns the maximum rank of the suite'); - $t4 = Table12Peer::retrieveByRank(4, 1); - $t4->delete(); - $this->assertEquals(3, Table12Peer::getMaxRank(1), 'getMaxRank() returns the maximum rank'); - Table12Peer::doDeleteAll(); - $this->assertNull(Table12Peer::getMaxRank(1), 'getMaxRank() returns null for empty tables'); - } - public function testRetrieveByRank() - { - $t = Table12Peer::retrieveByRank(5, 1); - $this->assertNull($t, 'retrieveByRank() returns null for an unknown rank'); - $t3 = Table12Peer::retrieveByRank(3, 1); - $this->assertEquals(3, $t3->getRank(), 'retrieveByRank() returns the object with the required rank in the required suite'); - $this->assertEquals('row3', $t3->getTitle(), 'retrieveByRank() returns the object with the required rank in the required suite'); - $t6 = Table12Peer::retrieveByRank(2, 2); - $this->assertEquals(2, $t6->getRank(), 'retrieveByRank() returns the object with the required rank in the required suite'); - $this->assertEquals('row6', $t6->getTitle(), 'retrieveByRank() returns the object with the required rank in the required suite'); - } - - public function testReorder() - { - $c = new Criteria(); - $c->add(Table12Peer::SCOPE_COL, 1); - $objects = Table12Peer::doSelectOrderByRank($c); - $ids = array(); - foreach ($objects as $object) { - $ids[]= $object->getPrimaryKey(); - } - $ranks = array(4, 3, 2, 1); - $order = array_combine($ids, $ranks); - Table12Peer::reorder($order); - $expected = array(1 => 'row4', 2 => 'row3', 3 => 'row2', 4 => 'row1'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'reorder() reorders the suite'); - $expected = array(1 => 'row5', 2 => 'row6'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'reorder() leaves other suites unchanged'); - } - - public function testDoSelectOrderByRank() - { - $c = new Criteria(); - $c->add(Table12Peer::SCOPE_COL, 1); - $objects = Table12Peer::doSelectOrderByRank($c); - $oldRank = 0; - while ($object = array_shift($objects)) { - $this->assertTrue($object->getRank() > $oldRank); - $oldRank = $object->getRank(); - } - $c = new Criteria(); - $c->add(Table12Peer::SCOPE_COL, 1); - $objects = Table12Peer::doSelectOrderByRank($c, Criteria::DESC); - $oldRank = 10; - while ($object = array_shift($objects)) { - $this->assertTrue($object->getRank() < $oldRank); - $oldRank = $object->getRank(); - } - } - - public function testRetrieveList() - { - $this->assertEquals(4, count(Table12Peer::retrieveList(1)), 'retrieveList() returns the list of objects in the scope'); - $this->assertEquals(2, count(Table12Peer::retrieveList(2)), 'retrieveList() returns the list of objects in the scope'); - } - - public function testCountList() - { - $this->assertEquals(4, Table12Peer::countList(1), 'countList() returns the list of objects in the scope'); - $this->assertEquals(2, Table12Peer::countList(2), 'countList() returns the list of objects in the scope'); - } + protected function setUp() + { + parent::setUp(); + $this->populateTable12(); + } - public function testDeleteList() - { - $this->assertEquals(4, Table12Peer::deleteList(1), 'deleteList() returns the list of objects in the scope'); - $this->assertEquals(2, Table12Peer::doCount(new Criteria()), 'deleteList() deletes the objects in the scope'); - $this->assertEquals(2, Table12Peer::deleteList(2), 'deleteList() returns the list of objects in the scope'); - $this->assertEquals(0, Table12Peer::doCount(new Criteria()), 'deleteList() deletes the objects in the scope'); - } -} \ No newline at end of file + public function testStaticAttributes() + { + $this->assertEquals(Table12Peer::RANK_COL, 'table12.position'); + $this->assertEquals(Table12Peer::SCOPE_COL, 'table12.my_scope_column'); + } + + public function testGetMaxRank() + { + $this->assertEquals(4, Table12Peer::getMaxRank(1), 'getMaxRank() returns the maximum rank of the suite'); + $this->assertEquals(2, Table12Peer::getMaxRank(2), 'getMaxRank() returns the maximum rank of the suite'); + $t4 = Table12Peer::retrieveByRank(4, 1); + $t4->delete(); + $this->assertEquals(3, Table12Peer::getMaxRank(1), 'getMaxRank() returns the maximum rank'); + Table12Peer::doDeleteAll(); + $this->assertNull(Table12Peer::getMaxRank(1), 'getMaxRank() returns null for empty tables'); + } + + public function testRetrieveByRank() + { + $t = Table12Peer::retrieveByRank(5, 1); + $this->assertNull($t, 'retrieveByRank() returns null for an unknown rank'); + $t3 = Table12Peer::retrieveByRank(3, 1); + $this->assertEquals(3, $t3->getRank(), 'retrieveByRank() returns the object with the required rank in the required suite'); + $this->assertEquals('row3', $t3->getTitle(), 'retrieveByRank() returns the object with the required rank in the required suite'); + $t6 = Table12Peer::retrieveByRank(2, 2); + $this->assertEquals(2, $t6->getRank(), 'retrieveByRank() returns the object with the required rank in the required suite'); + $this->assertEquals('row6', $t6->getTitle(), 'retrieveByRank() returns the object with the required rank in the required suite'); + } + + public function testReorder() + { + $c = new Criteria(); + Table12Peer::sortableApplyScopeCriteria($c, 1); + $objects = Table12Peer::doSelectOrderByRank($c); + $ids = array(); + foreach ($objects as $object) { + $ids[]= $object->getPrimaryKey(); + } + $ranks = array(4, 3, 2, 1); + $order = array_combine($ids, $ranks); + Table12Peer::reorder($order); + $expected = array(1 => 'row4', 2 => 'row3', 3 => 'row2', 4 => 'row1'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'reorder() reorders the suite'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'reorder() leaves other suites unchanged'); + } + + public function testDoSelectOrderByRank() + { + $c = new Criteria(); + Table12Peer::sortableApplyScopeCriteria($c, 1); + $objects = Table12Peer::doSelectOrderByRank($c); + $oldRank = 0; + while ($object = array_shift($objects)) { + $this->assertTrue($object->getRank() > $oldRank); + $oldRank = $object->getRank(); + } + $c = new Criteria(); + Table12Peer::sortableApplyScopeCriteria($c, 1); + $objects = Table12Peer::doSelectOrderByRank($c, Criteria::DESC); + $oldRank = 10; + while ($object = array_shift($objects)) { + $this->assertTrue($object->getRank() < $oldRank); + $oldRank = $object->getRank(); + } + } + + public function testRetrieveList() + { + $this->assertEquals(4, count(Table12Peer::retrieveList(null)), 'retrieveList() returns the list of objects in the scope'); + $this->assertEquals(4, count(Table12Peer::retrieveList(1)), 'retrieveList() returns the list of objects in the scope'); + $this->assertEquals(2, count(Table12Peer::retrieveList(2)), 'retrieveList() returns the list of objects in the scope'); + } + + public function testCountList() + { + $this->assertEquals(4, Table12Peer::countList(null), 'countList() returns the list of objects in the scope'); + $this->assertEquals(4, Table12Peer::countList(1), 'countList() returns the list of objects in the scope'); + $this->assertEquals(2, Table12Peer::countList(2), 'countList() returns the list of objects in the scope'); + } + + public function testDeleteList() + { + $this->assertEquals(4, Table12Peer::deleteList(null), 'deleteList() returns the list of deleted objects in the scope'); + $this->assertEquals(6, Table12Peer::doCount(new Criteria()), 'deleteList() deletes the objects in the scope'); + $this->assertEquals(4, Table12Peer::deleteList(1), 'deleteList() returns the list of deleted objects in the scope'); + $this->assertEquals(2, Table12Peer::doCount(new Criteria()), 'deleteList() deletes the objects in the scope'); + $this->assertEquals(2, Table12Peer::deleteList(2), 'deleteList() returns the list of deleted objects in the scope'); + $this->assertEquals(0, Table12Peer::doCount(new Criteria()), 'deleteList() deletes the objects in the scope'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorQueryBuilderModifierTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorQueryBuilderModifierTest.php index 15614f10c..37ac007f8 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorQueryBuilderModifierTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorQueryBuilderModifierTest.php @@ -9,107 +9,107 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/behavior/BookstoreSortableTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/behavior/BookstoreSortableTestBase.php'; /** * Tests for SortableBehavior class query modifier * * @author Francois Zaninotto - * @version $Revision: 1612 $ + * @version $Revision$ * @package generator.behavior.sortable */ class SortableBehaviorQueryBuilderModifierTest extends BookstoreSortableTestBase { - protected function setUp() - { - parent::setUp(); - $this->populateTable11(); - } - - public function testFilterByRank() - { - $this->assertTrue(Table11Query::create()->filterByRank(1) instanceof Table11Query, 'filterByRank() returns the current query object'); - $this->assertEquals('row1', Table11Query::create()->filterByRank(1)->findOne()->getTitle(), 'filterByRank() filters on the rank'); - $this->assertEquals('row4', Table11Query::create()->filterByRank(4)->findOne()->getTitle(), 'filterByRank() filters on the rank'); - $this->assertNull(Table11Query::create()->filterByRank(5)->findOne(), 'filterByRank() filters on the rank, which makes the query return no result on a non-existent rank'); - } + protected function setUp() + { + parent::setUp(); + $this->populateTable11(); + } - public function testOrderByRank() - { - $this->assertTrue(Table11Query::create()->orderByRank() instanceof Table11Query, 'orderByRank() returns the current query object'); - // default order - $query = Table11Query::create()->orderByRank(); - $expectedQuery = Table11Query::create()->addAscendingOrderByColumn(Table11Peer::SORTABLE_RANK); - $this->assertEquals($expectedQuery, $query, 'orderByRank() orders the query by rank asc'); - // asc order - $query = Table11Query::create()->orderByRank(Criteria::ASC); - $expectedQuery = Table11Query::create()->addAscendingOrderByColumn(Table11Peer::SORTABLE_RANK); - $this->assertEquals($expectedQuery, $query, 'orderByRank() orders the query by rank, using the argument as sort direction'); - // desc order - $query = Table11Query::create()->orderByRank(Criteria::DESC); - $expectedQuery = Table11Query::create()->addDescendingOrderByColumn(Table11Peer::SORTABLE_RANK); - $this->assertEquals($expectedQuery, $query, 'orderByRank() orders the query by rank, using the argument as sort direction'); - } + public function testFilterByRank() + { + $this->assertTrue(Table11Query::create()->filterByRank(1) instanceof Table11Query, 'filterByRank() returns the current query object'); + $this->assertEquals('row1', Table11Query::create()->filterByRank(1)->findOne()->getTitle(), 'filterByRank() filters on the rank'); + $this->assertEquals('row4', Table11Query::create()->filterByRank(4)->findOne()->getTitle(), 'filterByRank() filters on the rank'); + $this->assertNull(Table11Query::create()->filterByRank(5)->findOne(), 'filterByRank() filters on the rank, which makes the query return no result on a non-existent rank'); + } - /** - * @expectedException PropelException - */ - public function testOrderByRankIncorrectDirection() - { - Table11Query::create()->orderByRank('foo'); - } - - public function testFindList() - { - $ts = Table11Query::create()->findList(); - $this->assertTrue($ts instanceof PropelObjectCollection, 'findList() returns a collection of objects'); - $this->assertEquals(4, count($ts), 'findList() does not filter the query'); - $this->assertEquals('row1', $ts[0]->getTitle(), 'findList() returns an ordered list'); - $this->assertEquals('row2', $ts[1]->getTitle(), 'findList() returns an ordered list'); - $this->assertEquals('row3', $ts[2]->getTitle(), 'findList() returns an ordered list'); - $this->assertEquals('row4', $ts[3]->getTitle(), 'findList() returns an ordered list'); - } + public function testOrderByRank() + { + $this->assertTrue(Table11Query::create()->orderByRank() instanceof Table11Query, 'orderByRank() returns the current query object'); + // default order + $query = Table11Query::create()->orderByRank(); + $expectedQuery = Table11Query::create()->addAscendingOrderByColumn(Table11Peer::SORTABLE_RANK); + $this->assertEquals($expectedQuery, $query, 'orderByRank() orders the query by rank asc'); + // asc order + $query = Table11Query::create()->orderByRank(Criteria::ASC); + $expectedQuery = Table11Query::create()->addAscendingOrderByColumn(Table11Peer::SORTABLE_RANK); + $this->assertEquals($expectedQuery, $query, 'orderByRank() orders the query by rank, using the argument as sort direction'); + // desc order + $query = Table11Query::create()->orderByRank(Criteria::DESC); + $expectedQuery = Table11Query::create()->addDescendingOrderByColumn(Table11Peer::SORTABLE_RANK); + $this->assertEquals($expectedQuery, $query, 'orderByRank() orders the query by rank, using the argument as sort direction'); + } - public function testFindOneByRank() - { - $this->assertTrue(Table11Query::create()->findOneByRank(1) instanceof Table11, 'findOneByRank() returns an instance of the model object'); - $this->assertEquals('row1', Table11Query::create()->findOneByRank(1)->getTitle(), 'findOneByRank() returns a single item based on the rank'); - $this->assertEquals('row4', Table11Query::create()->findOneByRank(4)->getTitle(), 'findOneByRank() returns a single item based on the rank'); - $this->assertNull(Table11Query::create()->findOneByRank(5), 'findOneByRank() returns no result on a non-existent rank'); - } - - public function testGetMaxRank() - { - $this->assertEquals(4, Table11Query::create()->getMaxRank(), 'getMaxRank() returns the maximum rank'); - // delete one - $t4 = Table11Query::create()->findOneByRank(4); - $t4->delete(); - $this->assertEquals(3, Table11Query::create()->getMaxRank(), 'getMaxRank() returns the maximum rank'); - // add one - $t = new Table11(); - $t->save(); - $this->assertEquals(4, Table11Query::create()->getMaxRank(), 'getMaxRank() returns the maximum rank'); - // delete all - Table11Query::create()->deleteAll(); - $this->assertNull(Table11Query::create()->getMaxRank(), 'getMaxRank() returns null for empty tables'); - // add one - $t = new Table11(); - $t->save(); - $this->assertEquals(1, Table11Query::create()->getMaxRank(), 'getMaxRank() returns the maximum rank'); - } + /** + * @expectedException PropelException + */ + public function testOrderByRankIncorrectDirection() + { + Table11Query::create()->orderByRank('foo'); + } - public function testReorder() - { - $objects = Table11Query::create()->find(); - $ids = array(); - foreach ($objects as $object) { - $ids[]= $object->getPrimaryKey(); - } - $ranks = array(4, 3, 2, 1); - $order = array_combine($ids, $ranks); - Table11Query::create()->reorder($order); - $expected = array(1 => 'row3', 2 => 'row2', 3 => 'row4', 4 => 'row1'); - $this->assertEquals($expected, $this->getFixturesArray(), 'reorder() reorders the suite'); - } + public function testFindList() + { + $ts = Table11Query::create()->findList(); + $this->assertTrue($ts instanceof PropelObjectCollection, 'findList() returns a collection of objects'); + $this->assertEquals(4, count($ts), 'findList() does not filter the query'); + $this->assertEquals('row1', $ts[0]->getTitle(), 'findList() returns an ordered list'); + $this->assertEquals('row2', $ts[1]->getTitle(), 'findList() returns an ordered list'); + $this->assertEquals('row3', $ts[2]->getTitle(), 'findList() returns an ordered list'); + $this->assertEquals('row4', $ts[3]->getTitle(), 'findList() returns an ordered list'); + } -} \ No newline at end of file + public function testFindOneByRank() + { + $this->assertTrue(Table11Query::create()->findOneByRank(1) instanceof Table11, 'findOneByRank() returns an instance of the model object'); + $this->assertEquals('row1', Table11Query::create()->findOneByRank(1)->getTitle(), 'findOneByRank() returns a single item based on the rank'); + $this->assertEquals('row4', Table11Query::create()->findOneByRank(4)->getTitle(), 'findOneByRank() returns a single item based on the rank'); + $this->assertNull(Table11Query::create()->findOneByRank(5), 'findOneByRank() returns no result on a non-existent rank'); + } + + public function testGetMaxRank() + { + $this->assertEquals(4, Table11Query::create()->getMaxRank(), 'getMaxRank() returns the maximum rank'); + // delete one + $t4 = Table11Query::create()->findOneByRank(4); + $t4->delete(); + $this->assertEquals(3, Table11Query::create()->getMaxRank(), 'getMaxRank() returns the maximum rank'); + // add one + $t = new Table11(); + $t->save(); + $this->assertEquals(4, Table11Query::create()->getMaxRank(), 'getMaxRank() returns the maximum rank'); + // delete all + Table11Query::create()->deleteAll(); + $this->assertNull(Table11Query::create()->getMaxRank(), 'getMaxRank() returns null for empty tables'); + // add one + $t = new Table11(); + $t->save(); + $this->assertEquals(1, Table11Query::create()->getMaxRank(), 'getMaxRank() returns the maximum rank'); + } + + public function testReorder() + { + $objects = Table11Query::create()->find(); + $ids = array(); + foreach ($objects as $object) { + $ids[]= $object->getPrimaryKey(); + } + $ranks = array(4, 3, 2, 1); + $order = array_combine($ids, $ranks); + Table11Query::create()->reorder($order); + $expected = array(1 => 'row3', 2 => 'row2', 3 => 'row4', 4 => 'row1'); + $this->assertEquals($expected, $this->getFixturesArray(), 'reorder() reorders the suite'); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorQueryBuilderModifierWithScopeTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorQueryBuilderModifierWithScopeTest.php index db6f41b6d..98a6a16d8 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorQueryBuilderModifierWithScopeTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorQueryBuilderModifierWithScopeTest.php @@ -9,134 +9,134 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/behavior/BookstoreSortableTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/behavior/BookstoreSortableTestBase.php'; /** * Tests for SortableBehavior class query modifier when the scope is enabled * * @author Francois Zaninotto - * @version $Revision: 1612 $ + * @version $Revision$ * @package generator.behavior.sortable */ class SortableBehaviorQueryBuilderModifierWithScopeTest extends BookstoreSortableTestBase { - protected function setUp() - { - parent::setUp(); - $this->populateTable12(); - } + protected function setUp() + { + parent::setUp(); + $this->populateTable12(); + } - public function testInList() - { - /* List used for tests - scope=1 scope=2 - row1 row5 - row2 row6 - row3 - row4 - */ - $query = Table12Query::create()->inList(1); - $expectedQuery = Table12Query::create()->add(Table12Peer::MY_SCOPE_COLUMN, 1, Criteria::EQUAL); - $this->assertEquals($expectedQuery, $query, 'inList() filters the query by scope'); - $this->assertEquals(4, $query->count(), 'inList() filters the query by scope'); - $query = Table12Query::create()->inList(2); - $expectedQuery = Table12Query::create()->add(Table12Peer::MY_SCOPE_COLUMN, 2, Criteria::EQUAL); - $this->assertEquals($expectedQuery, $query, 'inList() filters the query by scope'); - $this->assertEquals(2, $query->count(), 'inList() filters the query by scope'); - } - - public function testFilterByRank() - { - /* List used for tests - scope=1 scope=2 - row1 row5 - row2 row6 - row3 - row4 - */ - $this->assertEquals('row1', Table12Query::create()->filterByRank(1, 1)->findOne()->getTitle(), 'filterByRank() filters on the rank and the scope'); - $this->assertEquals('row5', Table12Query::create()->filterByRank(1, 2)->findOne()->getTitle(), 'filterByRank() filters on the rank and the scope'); - $this->assertEquals('row4', Table12Query::create()->filterByRank(4, 1)->findOne()->getTitle(), 'filterByRank() filters on the rank and the scope'); - $this->assertNull(Table12Query::create()->filterByRank(4, 2)->findOne(), 'filterByRank() filters on the rank and the scope, which makes the query return no result on a non-existent rank'); - } + public function testInList() + { + /* List used for tests + scope=1 scope=2 + row1 row5 + row2 row6 + row3 + row4 + */ + $query = Table12Query::create()->inList(1); + $expectedQuery = Table12Query::create()->add(Table12Peer::MY_SCOPE_COLUMN, 1, Criteria::EQUAL); + $this->assertEquals($expectedQuery, $query, 'inList() filters the query by scope'); + $this->assertEquals(4, $query->count(), 'inList() filters the query by scope'); + $query = Table12Query::create()->inList(2); + $expectedQuery = Table12Query::create()->add(Table12Peer::MY_SCOPE_COLUMN, 2, Criteria::EQUAL); + $this->assertEquals($expectedQuery, $query, 'inList() filters the query by scope'); + $this->assertEquals(2, $query->count(), 'inList() filters the query by scope'); + } - public function testOrderByRank() - { - $this->assertTrue(Table12Query::create()->orderByRank() instanceof Table12Query, 'orderByRank() returns the current query object'); - // default order - $query = Table12Query::create()->orderByRank(); - $expectedQuery = Table12Query::create()->addAscendingOrderByColumn(Table12Peer::POSITION); - $this->assertEquals($expectedQuery, $query, 'orderByRank() orders the query by rank asc'); - // asc order - $query = Table12Query::create()->orderByRank(Criteria::ASC); - $expectedQuery = Table12Query::create()->addAscendingOrderByColumn(Table12Peer::POSITION); - $this->assertEquals($expectedQuery, $query, 'orderByRank() orders the query by rank, using the argument as sort direction'); - // desc order - $query = Table12Query::create()->orderByRank(Criteria::DESC); - $expectedQuery = Table12Query::create()->addDescendingOrderByColumn(Table12Peer::POSITION); - $this->assertEquals($expectedQuery, $query, 'orderByRank() orders the query by rank, using the argument as sort direction'); - } - - public function testFindList() - { - $ts = Table12Query::create()->findList(1); - $this->assertTrue($ts instanceof PropelObjectCollection, 'findList() returns a collection of objects'); - $this->assertEquals(4, count($ts), 'findList() filters the query by scope'); - $this->assertEquals('row1', $ts[0]->getTitle(), 'findList() returns an ordered scoped list'); - $this->assertEquals('row2', $ts[1]->getTitle(), 'findList() returns an ordered scoped list'); - $this->assertEquals('row3', $ts[2]->getTitle(), 'findList() returns an ordered scoped list'); - $this->assertEquals('row4', $ts[3]->getTitle(), 'findList() returns an ordered scoped list'); - $ts = Table12Query::create()->findList(2); - $this->assertEquals(2, count($ts), 'findList() filters the query by scope'); - $this->assertEquals('row5', $ts[0]->getTitle(), 'findList() returns an ordered scoped list'); - $this->assertEquals('row6', $ts[1]->getTitle(), 'findList() returns an ordered scoped list'); - } + public function testFilterByRank() + { + /* List used for tests + scope=1 scope=2 + row1 row5 + row2 row6 + row3 + row4 + */ + $this->assertEquals('row1', Table12Query::create()->filterByRank(1, 1)->findOne()->getTitle(), 'filterByRank() filters on the rank and the scope'); + $this->assertEquals('row5', Table12Query::create()->filterByRank(1, 2)->findOne()->getTitle(), 'filterByRank() filters on the rank and the scope'); + $this->assertEquals('row4', Table12Query::create()->filterByRank(4, 1)->findOne()->getTitle(), 'filterByRank() filters on the rank and the scope'); + $this->assertNull(Table12Query::create()->filterByRank(4, 2)->findOne(), 'filterByRank() filters on the rank and the scope, which makes the query return no result on a non-existent rank'); + } - public function testFindOneByRank() - { - $this->assertTrue(Table12Query::create()->findOneByRank(1, 1) instanceof Table12, 'findOneByRank() returns an instance of the model object'); - $this->assertEquals('row1', Table12Query::create()->findOneByRank(1, 1)->getTitle(), 'findOneByRank() returns a single item based on the rank and the scope'); - $this->assertEquals('row5', Table12Query::create()->findOneByRank(1, 2)->getTitle(), 'findOneByRank() returns a single item based on the rank and the scope'); - $this->assertEquals('row4', Table12Query::create()->findOneByRank(4, 1)->getTitle(), 'findOneByRank() returns a single item based on the rank a,d the scope'); - $this->assertNull(Table12Query::create()->findOneByRank(4, 2), 'findOneByRank() returns no result on a non-existent rank and scope'); - } - - public function testGetMaxRank() - { - $this->assertEquals(4, Table12Query::create()->getMaxRank(1), 'getMaxRank() returns the maximum rank in the scope'); - $this->assertEquals(2, Table12Query::create()->getMaxRank(2), 'getMaxRank() returns the maximum rank in the scope'); - // delete one - $t4 = Table12Query::create()->findOneByRank(4, 1); - $t4->delete(); - $this->assertEquals(3, Table12Query::create()->getMaxRank(1), 'getMaxRank() returns the maximum rank'); - // add one - $t = new Table12(); - $t->setMyScopeColumn(1); - $t->save(); - $this->assertEquals(4, Table12Query::create()->getMaxRank(1), 'getMaxRank() returns the maximum rank'); - // delete all - Table12Query::create()->deleteAll(); - $this->assertNull(Table12Query::create()->getMaxRank(1), 'getMaxRank() returns null for empty tables'); - // add one - $t = new Table12(); - $t->setMyScopeColumn(1); - $t->save(); - $this->assertEquals(1, Table12Query::create()->getMaxRank(1), 'getMaxRank() returns the maximum rank'); - } + public function testOrderByRank() + { + $this->assertTrue(Table12Query::create()->orderByRank() instanceof Table12Query, 'orderByRank() returns the current query object'); + // default order + $query = Table12Query::create()->orderByRank(); + $expectedQuery = Table12Query::create()->addAscendingOrderByColumn(Table12Peer::POSITION); + $this->assertEquals($expectedQuery, $query, 'orderByRank() orders the query by rank asc'); + // asc order + $query = Table12Query::create()->orderByRank(Criteria::ASC); + $expectedQuery = Table12Query::create()->addAscendingOrderByColumn(Table12Peer::POSITION); + $this->assertEquals($expectedQuery, $query, 'orderByRank() orders the query by rank, using the argument as sort direction'); + // desc order + $query = Table12Query::create()->orderByRank(Criteria::DESC); + $expectedQuery = Table12Query::create()->addDescendingOrderByColumn(Table12Peer::POSITION); + $this->assertEquals($expectedQuery, $query, 'orderByRank() orders the query by rank, using the argument as sort direction'); + } - public function testReorder() - { - $objects = Table12Query::create()->findList(1); - $ids = array(); - foreach ($objects as $object) { - $ids[]= $object->getPrimaryKey(); - } - $ranks = array(4, 3, 2, 1); - $order = array_combine($ids, $ranks); - Table12Query::create()->reorder($order); - $expected = array(1 => 'row4', 2 => 'row3', 3 => 'row2', 4 => 'row1'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'reorder() reorders the suite'); - $expected = array(1 => 'row5', 2 => 'row6'); - $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'reorder() leaves other suites unchanged'); - } -} \ No newline at end of file + public function testFindList() + { + $ts = Table12Query::create()->findList(1); + $this->assertTrue($ts instanceof PropelObjectCollection, 'findList() returns a collection of objects'); + $this->assertEquals(4, count($ts), 'findList() filters the query by scope'); + $this->assertEquals('row1', $ts[0]->getTitle(), 'findList() returns an ordered scoped list'); + $this->assertEquals('row2', $ts[1]->getTitle(), 'findList() returns an ordered scoped list'); + $this->assertEquals('row3', $ts[2]->getTitle(), 'findList() returns an ordered scoped list'); + $this->assertEquals('row4', $ts[3]->getTitle(), 'findList() returns an ordered scoped list'); + $ts = Table12Query::create()->findList(2); + $this->assertEquals(2, count($ts), 'findList() filters the query by scope'); + $this->assertEquals('row5', $ts[0]->getTitle(), 'findList() returns an ordered scoped list'); + $this->assertEquals('row6', $ts[1]->getTitle(), 'findList() returns an ordered scoped list'); + } + + public function testFindOneByRank() + { + $this->assertTrue(Table12Query::create()->findOneByRank(1, 1) instanceof Table12, 'findOneByRank() returns an instance of the model object'); + $this->assertEquals('row1', Table12Query::create()->findOneByRank(1, 1)->getTitle(), 'findOneByRank() returns a single item based on the rank and the scope'); + $this->assertEquals('row5', Table12Query::create()->findOneByRank(1, 2)->getTitle(), 'findOneByRank() returns a single item based on the rank and the scope'); + $this->assertEquals('row4', Table12Query::create()->findOneByRank(4, 1)->getTitle(), 'findOneByRank() returns a single item based on the rank a,d the scope'); + $this->assertNull(Table12Query::create()->findOneByRank(4, 2), 'findOneByRank() returns no result on a non-existent rank and scope'); + } + + public function testGetMaxRank() + { + $this->assertEquals(4, Table12Query::create()->getMaxRank(1), 'getMaxRank() returns the maximum rank in the scope'); + $this->assertEquals(2, Table12Query::create()->getMaxRank(2), 'getMaxRank() returns the maximum rank in the scope'); + // delete one + $t4 = Table12Query::create()->findOneByRank(4, 1); + $t4->delete(); + $this->assertEquals(3, Table12Query::create()->getMaxRank(1), 'getMaxRank() returns the maximum rank'); + // add one + $t = new Table12(); + $t->setMyScopeColumn(1); + $t->save(); + $this->assertEquals(4, Table12Query::create()->getMaxRank(1), 'getMaxRank() returns the maximum rank'); + // delete all + Table12Query::create()->deleteAll(); + $this->assertNull(Table12Query::create()->getMaxRank(1), 'getMaxRank() returns null for empty tables'); + // add one + $t = new Table12(); + $t->setMyScopeColumn(1); + $t->save(); + $this->assertEquals(1, Table12Query::create()->getMaxRank(1), 'getMaxRank() returns the maximum rank'); + } + + public function testReorder() + { + $objects = Table12Query::create()->findList(1); + $ids = array(); + foreach ($objects as $object) { + $ids[]= $object->getPrimaryKey(); + } + $ranks = array(4, 3, 2, 1); + $order = array_combine($ids, $ranks); + Table12Query::create()->reorder($order); + $expected = array(1 => 'row4', 2 => 'row3', 3 => 'row2', 4 => 'row1'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(1), 'reorder() reorders the suite'); + $expected = array(1 => 'row5', 2 => 'row6'); + $this->assertEquals($expected, $this->getFixturesArrayWithScope(2), 'reorder() leaves other suites unchanged'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorTest.php index 6192614a5..771b80425 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/sortable/SortableBehaviorTest.php @@ -1,7 +1,7 @@ assertEquals(count($table11->getColumns()), 3, 'Sortable adds one columns by default'); - $this->assertTrue(method_exists('Table11', 'getRank'), 'Sortable adds a rank column by default'); - $table12 = Table12Peer::getTableMap(); - $this->assertEquals(count($table12->getColumns()), 4, 'Sortable does not add a column when it already exists'); - $this->assertTrue(method_exists('Table12', 'getPosition'), 'Sortable allows customization of rank_column name'); - } + if (!class_exists('Test\SortableTest1')) { + $schema = << + + + + +
+ +EOF; + + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $builder->build(); + } + } + + /** + * See: https://github.com/propelorm/Propel/issues/515 + * + */ + public function testShiftRank() + { + $peer = new \Test\SortableTest1Peer(); + $peer->shiftRank(1); //should not throw any exception + } + + public function testParameters() + { + $table11 = Table11Peer::getTableMap(); + $this->assertEquals(count($table11->getColumns()), 3, 'Sortable adds one columns by default'); + $this->assertTrue(method_exists('Table11', 'getRank'), 'Sortable adds a rank column by default'); + + $table12 = Table12Peer::getTableMap(); + $this->assertEquals(count($table12->getColumns()), 4, 'Sortable does not add a column when it already exists'); + $this->assertTrue(method_exists('Table12', 'getPosition'), 'Sortable allows customization of rank_column name'); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/versionable/VersionableBehaviorObjectBuilderModifierTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/versionable/VersionableBehaviorObjectBuilderModifierTest.php new file mode 100644 index 000000000..6cfb3d43f --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/versionable/VersionableBehaviorObjectBuilderModifierTest.php @@ -0,0 +1,1021 @@ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+ +XML; + PropelQuickBuilder::buildSchema($schema); + } + + if (!class_exists('VersionableBehaviorTest6')) { + $schema2 = << + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ +XML; + PropelQuickBuilder::buildSchema($schema2); + } + + if (!class_exists('VersionableBehaviorTest8')) { + $schema3 = << + + + + + + + + + +
+ + + + + + + + + +
+ +XML; + PropelQuickBuilder::buildSchema($schema3); + } + + if (!class_exists('VersionableBehaviorTest10')) { + $schema4 = << + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + +
+ +XML; + PropelQuickBuilder::buildSchema($schema4); + } + + if (!class_exists('VersionableBehaviorTest13')) { + $schema5 = << + + + + + +
+ + + + + + + + + + +
+ +XML; + PropelQuickBuilder::buildSchema($schema5); + } + } + + public function testGetVersionExists() + { + $this->assertTrue(method_exists('VersionableBehaviorTest1', 'getVersion')); + $this->assertTrue(method_exists('VersionableBehaviorTest2', 'getVersion')); + } + + public function testSetVersionExists() + { + $this->assertTrue(method_exists('VersionableBehaviorTest1', 'setVersion')); + $this->assertTrue(method_exists('VersionableBehaviorTest2', 'setVersion')); + } + + public function testMethodsExistsNoChangeNaming() + { + $this->assertTrue(method_exists('VersionableBehaviorTest6', 'setFooBar')); + $this->assertTrue(method_exists('VersionableBehaviorTest6', 'setversion_created_at')); + $this->assertTrue(method_exists('VersionableBehaviorTest6', 'setversion_created_by')); + $this->assertTrue(method_exists('VersionableBehaviorTest6', 'setversion_comment')); + + $this->assertTrue(method_exists('VersionableBehaviorTest7', 'setFooBar')); + $this->assertTrue(method_exists('VersionableBehaviorTest7', 'setVersionCreatedAt')); + $this->assertTrue(method_exists('VersionableBehaviorTest7', 'setVersionCreatedBy')); + $this->assertTrue(method_exists('VersionableBehaviorTest7', 'setMyComment')); + + } + + public function providerForNewActiveRecordTests() + { + return array( + array('VersionableBehaviorTest1'), + array('VersionableBehaviorTest2'), + ); + } + + /** + * @dataProvider providerForNewActiveRecordTests + */ + public function testVersionGetterAndSetter($class) + { + $o = new $class; + $o->setVersion(1234); + $this->assertEquals(1234, $o->getVersion()); + } + + /** + * @dataProvider providerForNewActiveRecordTests + */ + public function testVersionDefaultValue($class) + { + $o = new $class; + $this->assertEquals(0, $o->getVersion()); + } + + /** + * @dataProvider providerForNewActiveRecordTests + */ + public function testVersionValueInitializesOnInsert($class) + { + $o = new $class; + $o->save(); + $this->assertEquals(1, $o->getVersion()); + } + + /** + * @dataProvider providerForNewActiveRecordTests + */ + public function testVersionValueIncrementsOnUpdate($class) + { + $o = new $class; + $o->save(); + $this->assertEquals(1, $o->getVersion()); + $o->setBar(12); + $o->save(); + $this->assertEquals(2, $o->getVersion()); + $o->setBar(13); + $o->save(); + $this->assertEquals(3, $o->getVersion()); + $o->setBar(12); + $o->save(); + $this->assertEquals(4, $o->getVersion()); + } + + public function testVersionValueIncrementsOnDeleteManyToMany() + { + $bar = new VersionableBehaviorTest10(); + $bar->setBar(42); + $bar->save(); + + $foo = new VersionableBehaviorTest11(); + $foo->setFoo('Marvin'); + $foo->save(); + + $baz = new VersionableBehaviorTest12(); + $baz->setVersionablebehaviortest11($foo); + $baz->setBaz('So long and thanks for all the fish'); + + $bar->addVersionablebehaviortest12($baz); + $bar->save(); + + $this->assertEquals(1, $baz->getVersion()); + $this->assertEquals(2, $bar->getVersion()); + + $baz->delete(); + $bar->save(); + + $this->assertEquals(3, $bar->getVersion()); + } + + /** + * @dataProvider providerForNewActiveRecordTests + */ + public function testVersionDoesNotIncrementOnUpdateWithNoChange($class) + { + $o = new $class; + $o->setBar(12); + $o->save(); + $this->assertEquals(1, $o->getVersion()); + $o->setBar(12); + $o->save(); + $this->assertEquals(1, $o->getVersion()); + } + + /** + * @dataProvider providerForNewActiveRecordTests + */ + public function testVersionDoesNotIncrementWhenVersioningIsDisabled($class) + { + $o = new $class; + VersionableBehaviorTest1Peer::disableVersioning(); + VersionableBehaviorTest2Peer::disableVersioning(); + $o->setBar(12); + $o->save(); + $this->assertEquals(0, $o->getVersion()); + $o->setBar(13); + $o->save(); + $this->assertEquals(0, $o->getVersion()); + VersionableBehaviorTest1Peer::enableVersioning(); + VersionableBehaviorTest2Peer::enableVersioning(); + + } + + public function testNewVersionCreatesRecordInVersionTable() + { + VersionableBehaviorTest1Query::create()->deleteAll(); + VersionableBehaviorTest1VersionQuery::create()->deleteAll(); + $o = new VersionableBehaviorTest1(); + $o->save(); + $versions = VersionableBehaviorTest1VersionQuery::create()->find(); + $this->assertEquals(1, $versions->count()); + $this->assertEquals($o, $versions[0]->getVersionableBehaviorTest1()); + $o->save(); + $versions = VersionableBehaviorTest1VersionQuery::create()->find(); + $this->assertEquals(1, $versions->count()); + $o->setBar(123); + $o->save(); + $versions = VersionableBehaviorTest1VersionQuery::create()->orderByVersion()->find(); + $this->assertEquals(2, $versions->count()); + $this->assertEquals($o->getId(), $versions[0]->getId()); + $this->assertNull($versions[0]->getBar()); + $this->assertEquals($o->getId(), $versions[1]->getId()); + $this->assertEquals(123, $versions[1]->getBar()); + } + + public function testNewVersionCreatesRecordInVersionTableWithCustomName() + { + VersionableBehaviorTest3Query::create()->deleteAll(); + VersionableBehaviorTest3VersionQuery::create()->deleteAll(); + $o = new VersionableBehaviorTest3(); + $o->save(); + $versions = VersionableBehaviorTest3VersionQuery::create()->find(); + $this->assertEquals(1, $versions->count()); + $this->assertEquals($o, $versions[0]->getVersionableBehaviorTest3()); + $o->save(); + $versions = VersionableBehaviorTest3VersionQuery::create()->find(); + $this->assertEquals(1, $versions->count()); + $o->setBar(123); + $o->save(); + $versions = VersionableBehaviorTest3VersionQuery::create()->orderByVersion()->find(); + $this->assertEquals(2, $versions->count()); + $this->assertEquals($o->getId(), $versions[0]->getId()); + $this->assertNull($versions[0]->getBar()); + $this->assertEquals($o->getId(), $versions[1]->getId()); + $this->assertEquals(123, $versions[1]->getBar()); + } + + public function testNewVersionDoesNotCreateRecordInVersionTableWhenVersioningIsDisabled() + { + VersionableBehaviorTest1Query::create()->deleteAll(); + VersionableBehaviorTest1VersionQuery::create()->deleteAll(); + VersionableBehaviorTest1Peer::disableVersioning(); + $o = new VersionableBehaviorTest1(); + $o->save(); + $versions = VersionableBehaviorTest1VersionQuery::create()->find(); + $this->assertEquals(0, $versions->count()); + VersionableBehaviorTest1Peer::enableVersioning(); + } + + public function testDeleteObjectDeletesRecordInVersionTable() + { + VersionableBehaviorTest1Query::create()->deleteAll(); + VersionableBehaviorTest1VersionQuery::create()->deleteAll(); + $o = new VersionableBehaviorTest1(); + $o->save(); + $o->setBar(123); + $o->save(); + $nbVersions = VersionableBehaviorTest1VersionQuery::create()->count(); + $this->assertEquals(2, $nbVersions); + $o->delete(); + $nbVersions = VersionableBehaviorTest1VersionQuery::create()->count(); + $this->assertEquals(0, $nbVersions); + } + + public function testDeleteObjectDeletesRecordInVersionTableWithCustomName() + { + VersionableBehaviorTest3Query::create()->deleteAll(); + VersionableBehaviorTest3VersionQuery::create()->deleteAll(); + $o = new VersionableBehaviorTest3(); + $o->save(); + $o->setBar(123); + $o->save(); + $nbVersions = VersionableBehaviorTest3VersionQuery::create()->count(); + $this->assertEquals(2, $nbVersions); + $o->delete(); + $nbVersions = VersionableBehaviorTest3VersionQuery::create()->count(); + $this->assertEquals(0, $nbVersions); + } + + public function testToVersion() + { + $o = new VersionableBehaviorTest1(); + $o->setBar(123); // version 1 + $o->save(); + $o->setBar(456); // version 2 + $o->save(); + $o->toVersion(1); + $this->assertEquals(123, $o->getBar()); + $o->toVersion(2); + $this->assertEquals(456, $o->getBar()); + } + + public function testToVersionAllowsFurtherSave() + { + $o = new VersionableBehaviorTest1(); + $o->setBar(123); // version 1 + $o->save(); + $o->setBar(456); // version 2 + $o->save(); + $o->toVersion(1); + $this->assertTrue($o->isModified()); + $o->save(); + $this->assertEquals(3, $o->getVersion()); + } + + /** + * @expectedException PropelException + */ + public function testToVersionThrowsExceptionOnIncorrectVersion() + { + $o = new VersionableBehaviorTest1(); + $o->setBar(123); // version 1 + $o->save(); + $o->toVersion(2); + } + + public function testToVersionPreservesVersionedFkObjects() + { + $a = new VersionableBehaviorTest4(); + $a->setBar(123); // a1 + $b = new VersionableBehaviorTest5(); + $b->setFoo('Hello'); + $b->setVersionableBehaviorTest4($a); + $b->save(); //b1 + $a->setBar(456); //a2 + $b->save(); // b2 + $b->setFoo('World'); + $b->save(); // b3 + $b->toVersion(2); + $this->assertEquals($b->getVersion(), 2); + $this->assertEquals($b->getVersionableBehaviorTest4()->getVersion(), 2); + $b->toVersion(1); + $this->assertEquals($b->getVersion(), 1); + $this->assertEquals($b->getVersionableBehaviorTest4()->getVersion(), 1); + $b->toVersion(3); + $this->assertEquals($b->getVersion(), 3); + $this->assertEquals($b->getVersionableBehaviorTest4()->getVersion(), 2); + } + + public function testToVersionPreservesVersionedReferrerObjects() + { + $b1 = new VersionableBehaviorTest5(); + $b1->setFoo('Hello'); + $b2 = new VersionableBehaviorTest5(); + $b2->setFoo('World'); + $a = new VersionableBehaviorTest4(); + $a->setBar(123); // a1 + $a->addVersionableBehaviorTest5($b1); + $a->addVersionableBehaviorTest5($b2); + $a->save(); //b1 + $this->assertEquals(1, $a->getVersion()); + $bs = $a->getVersionableBehaviorTest5s(); + $this->assertEquals(1, $bs[0]->getVersion()); + $this->assertEquals(1, $bs[1]->getVersion()); + $b1->setFoo('Heloo'); + $a->save(); + $this->assertEquals(2, $a->getVersion()); + $bs = $a->getVersionableBehaviorTest5s(); + $this->assertEquals(2, $bs[0]->getVersion()); + $this->assertEquals(1, $bs[1]->getVersion()); + $b3 = new VersionableBehaviorTest5(); + $b3->setFoo('Yep'); + $a->clearVersionableBehaviorTest5s(); + $a->addVersionableBehaviorTest5($b3); + $a->save(); + $a->clearVersionableBehaviorTest5s(); + $this->assertEquals(3, $a->getVersion()); + $bs = $a->getVersionableBehaviorTest5s(); + $this->assertEquals(2, $bs[0]->getVersion()); + $this->assertEquals(1, $bs[1]->getVersion()); + $this->assertEquals(1, $bs[2]->getVersion()); + + $a->toVersion(1); + $bs = $a->getVersionableBehaviorTest5s(); + $this->assertEquals(1, $bs[0]->getVersion()); + $this->assertEquals(1, $bs[1]->getVersion()); + } + + public function testGetLastVersionNumber() + { + $o = new VersionableBehaviorTest1(); + $this->assertEquals(0, $o->getLastVersionNumber()); + $o->setBar(123); // version 1 + $o->save(); + $this->assertEquals(1, $o->getLastVersionNumber()); + $o->setBar(456); // version 2 + $o->save(); + $this->assertEquals(2, $o->getLastVersionNumber()); + $o->toVersion(1); + $o->save(); + $this->assertEquals(3, $o->getLastVersionNumber()); + } + + public function testIsLastVersion() + { + $o = new VersionableBehaviorTest1(); + $this->assertTrue($o->isLastVersion()); + $o->setBar(123); // version 1 + $o->save(); + $this->assertTrue($o->isLastVersion()); + $o->setBar(456); // version 2 + $o->save(); + $this->assertTrue($o->isLastVersion()); + $o->toVersion(1); + $this->assertFalse($o->isLastVersion()); + $o->save(); + $this->assertTrue($o->isLastVersion()); + } + + public function testIsVersioningNecessary() + { + $o = new VersionableBehaviorTest1(); + $this->assertTrue($o->isVersioningNecessary()); + $o->save(); + $this->assertFalse($o->isVersioningNecessary()); + $o->setBar(123); + $this->assertTrue($o->isVersioningNecessary()); + $o->save(); + $this->assertFalse($o->isVersioningNecessary()); + + VersionableBehaviorTest1Peer::disableVersioning(); + $o = new VersionableBehaviorTest1(); + $this->assertFalse($o->isVersioningNecessary()); + $o->save(); + $this->assertFalse($o->isVersioningNecessary()); + $o->setBar(123); + $this->assertFalse($o->isVersioningNecessary()); + $o->save(); + $this->assertFalse($o->isVersioningNecessary()); + VersionableBehaviorTest1Peer::enableVersioning(); + + $b1 = new VersionableBehaviorTest5(); + $b1->setFoo('Hello'); + $b2 = new VersionableBehaviorTest5(); + $b2->setFoo('World'); + $a = new VersionableBehaviorTest4(); + $a->setBar(123); // a1 + $this->assertTrue($a->isVersioningNecessary()); + $a->save(); + $this->assertFalse($a->isVersioningNecessary()); + $a->addVersionableBehaviorTest5($b1); + $this->assertTrue($a->isVersioningNecessary()); + $a->save(); + $this->assertFalse($a->isVersioningNecessary()); + $a->addVersionableBehaviorTest5($b2); + $this->assertTrue($a->isVersioningNecessary()); + $a->save(); + $this->assertFalse($a->isVersioningNecessary()); + $b2->setFoo('World !'); + $this->assertTrue($b2->isVersioningNecessary()); + $this->assertTrue($a->isVersioningNecessary()); + $a->save(); + $this->assertFalse($b2->isVersioningNecessary()); + $this->assertFalse($a->isVersioningNecessary()); + } + + public function testIsVersioningNecessaryWithNullFk() + { + // the purpose of this tests is to highlight a bug with FK and isVersioningNecessary() + $b1 = new VersionableBehaviorTest5(); + $b1->setNew(false); + + // this time, the object isn't modified, so the isVersioningNecessary() + // method is called on FK objects... which can be null. + $b1->isVersioningNecessary(); + + $this->assertTrue(true, 'getting here means that nothing went wrong'); + } + + public function testAddVersionNewObject() + { + VersionableBehaviorTest1Peer::disableVersioning(); + VersionableBehaviorTest1Query::create()->deleteAll(); + VersionableBehaviorTest1VersionQuery::create()->deleteAll(); + $o = new VersionableBehaviorTest1(); + $o->addVersion(); + $o->save(); + $versions = VersionableBehaviorTest1VersionQuery::create()->find(); + $this->assertEquals(1, $versions->count()); + $this->assertEquals($o, $versions[0]->getVersionableBehaviorTest1()); + VersionableBehaviorTest1Peer::enableVersioning(); + } + + public function testVersionCreatedAt() + { + $o = new VersionableBehaviorTest4(); + $t = time(); + $o->save(); + $version = VersionableBehaviorTest4VersionQuery::create() + ->filterByVersionableBehaviorTest4($o) + ->findOne(); + $this->assertEquals($t, $version->getVersionCreatedAt('U')); + + $o = new VersionableBehaviorTest4(); + $inThePast = time() - 123456; + $o->setVersionCreatedAt($inThePast); + $o->save(); + $this->assertEquals($inThePast, $o->getVersionCreatedAt('U')); + $version = VersionableBehaviorTest4VersionQuery::create() + ->filterByVersionableBehaviorTest4($o) + ->findOne(); + $this->assertEquals($o->getVersionCreatedAt(), $version->getVersionCreatedAt()); + } + + public function testVersionCreatedBy() + { + $o = new VersionableBehaviorTest4(); + $o->setVersionCreatedBy('me me me'); + $o->save(); + $version = VersionableBehaviorTest4VersionQuery::create() + ->filterByVersionableBehaviorTest4($o) + ->findOne(); + $this->assertEquals('me me me', $version->getVersionCreatedBy()); + } + + public function testSaveAndModifyWithNoChangeSchema() + { + $o = new VersionableBehaviorTest7(); + //$o->setVersionCreatedBy('You and I'); + $o->save(); + $this->assertEquals(1, $o->getVersion()); + $o->setFooBar('Something'); + $o->save(); + $this->assertEquals(2, $o->getVersion()); + + $o = new VersionableBehaviorTest6(); + //$o->setVersionCreatedBy('You and I'); + $o->save(); + $this->assertEquals(1, $o->getVersion()); + $o->setFooBar('Something'); + $o->save(); + $this->assertEquals(2, $o->getVersion()); + } + + public function testVersionComment() + { + $o = new VersionableBehaviorTest4(); + $o->setVersionComment('Because you deserve it'); + $o->save(); + $version = VersionableBehaviorTest4VersionQuery::create() + ->filterByVersionableBehaviorTest4($o) + ->findOne(); + $this->assertEquals('Because you deserve it', $version->getVersionComment()); + + $o->reload(); + $o->setBar(123); + $o->save(); + + $this->assertEquals(2, $o->getVersion()); + $this->assertNull($o->getVersionComment()); + + $o->reload(); + $o->setBar(456); + $o->setVersionComment('It is just fine.'); + $o->save(); + + $this->assertEquals(3, $o->getVersion()); + $this->assertEquals('It is just fine.', $o->getVersionComment()); + } + + public function testToVersionWorksWithComments() + { + $o = new VersionableBehaviorTest4(); + $o->setVersionComment('Because you deserve it'); + $o->setBar(123); // version 1 + $o->save(); + $o->setVersionComment('Unless I change my mind'); + $o->setBar(456); // version 2 + $o->save(); + $o->toVersion(1); + $this->assertEquals('Because you deserve it', $o->getVersionComment()); + $o->toVersion(2); + $this->assertEquals('Unless I change my mind', $o->getVersionComment()); + } + + public function testGetOneVersion() + { + $o = new VersionableBehaviorTest1(); + $o->setBar(123); // version 1 + $o->save(); + $o->setBar(456); // version 2 + $o->save(); + $version = $o->getOneVersion(1); + $this->assertTrue($version instanceof VersionableBehaviorTest1Version); + $this->assertEquals(1, $version->getVersion()); + $this->assertEquals(123, $version->getBar()); + $version = $o->getOneVersion(2); + $this->assertEquals(2, $version->getVersion()); + $this->assertEquals(456, $version->getBar()); + } + + public function testGetAllVersions() + { + $o = new VersionableBehaviorTest1(); + $versions = $o->getAllVersions(); + $this->assertTrue($versions->isEmpty()); + $o->setBar(123); // version 1 + $o->save(); + $o->setBar(456); // version 2 + $o->save(); + $versions = $o->getAllVersions(); + $this->assertTrue($versions instanceof PropelObjectCollection); + $this->assertEquals(2, $versions->count()); + $this->assertEquals(1, $versions[0]->getVersion()); + $this->assertEquals(123, $versions[0]->getBar()); + $this->assertEquals(2, $versions[1]->getVersion()); + $this->assertEquals(456, $versions[1]->getBar()); + } + + public function testGetLastVersions() + { + $o = new VersionableBehaviorTest1(); + $versions = $o->getAllVersions(); + $this->assertTrue($versions->isEmpty()); + $o->setBar(123); // version 1 + $o->save(); + $o->setBar(456); // version 2 + $o->save(); + $o->setBar(789); // version 3 + $o->save(); + $o->setBar(101112); // version 4 + $o->save(); + + $versions = $o->getLastVersions(); + $this->assertTrue($versions instanceof PropelObjectCollection); + $this->assertEquals(4, $versions->count()); + $this->assertEquals(4, $versions[0]->getVersion()); + $this->assertEquals(101112, $versions[0]->getBar()); + $this->assertEquals(3, $versions[1]->getVersion()); + $this->assertEquals(789, $versions[1]->getBar()); + $this->assertEquals(2, $versions[2]->getVersion()); + $this->assertEquals(456, $versions[2]->getBar()); + $this->assertEquals(1, $versions[3]->getVersion()); + $this->assertEquals(123, $versions[3]->getBar()); + + $versions = $o->getLastVersions(2); + $this->assertTrue($versions instanceof PropelObjectCollection); + $this->assertEquals(2, $versions->count()); + $this->assertEquals(4, $versions[0]->getVersion()); + $this->assertEquals(101112, $versions[0]->getBar()); + $this->assertEquals(3, $versions[1]->getVersion()); + $this->assertEquals(789, $versions[1]->getBar()); + } + + public function testCompareVersion() + { + $o = new VersionableBehaviorTest4(); + $versions = $o->getAllVersions(); + $this->assertTrue($versions->isEmpty()); + $o->setBar(123); // version 1 + $o->save(); + $o->setBar(456); // version 2 + $o->save(); + $o->setBar(789); // version 3 + $o->setVersionComment('Foo'); + $o->save(); + $diff = $o->compareVersion(3); // $o is in version 3 + $expected = array(); + $this->assertEquals($expected, $diff); + $diff = $o->compareVersion(2); + $expected = array( + 'Bar' => array(2 => 456, 3 => 789), + ); + $this->assertEquals($expected, $diff); + + $diff = $o->compareVersion(1); + $expected = array( + 'Bar' => array(1 => 123, 3 => 789), + ); + $this->assertEquals($expected, $diff); + } + + public function testCompareVersions() + { + $o = new VersionableBehaviorTest4(); + $versions = $o->getAllVersions(); + $this->assertTrue($versions->isEmpty()); + $o->setBar(123); // version 1 + $o->save(); + $o->setBar(456); // version 2 + $o->save(); + $o->setBar(789); // version 3 + $o->setVersionComment('Foo'); + $o->save(); + $diff = $o->compareVersions(1, 3); + $expected = array( + 'Bar' => array(1 => 123, 3 => 789) + ); + $this->assertEquals($expected, $diff); + $diff = $o->compareVersions(1, 3, 'versions'); + $expected = array( + 1 => array('Bar' => 123), + 3 => array('Bar' => 789) + ); + $this->assertEquals($expected, $diff); + } + + public function testForeignKeyVersion() + { + $a = new VersionableBehaviorTest4(); + $a->setBar(123); // a1 + $b = new VersionableBehaviorTest5(); + $b->setFoo('Hello'); + $b->setVersionableBehaviorTest4($a); + $b->save(); //b1 + $this->assertEquals($b->getVersion(), 1); + $this->assertEquals($b->getVersionableBehaviorTest4()->getVersion(), 1); + $a->setBar(456); //a2 + $b->save(); // b2 + $this->assertEquals($b->getVersion(), 2); + $this->assertEquals($b->getVersionableBehaviorTest4()->getVersion(), 2); + $b->setFoo('World'); + $b->save(); // b3 + $this->assertEquals($b->getVersion(), 3); + $this->assertEquals($b->getVersionableBehaviorTest4()->getVersion(), 2); + } + + public function testReferrerVersion() + { + $b1 = new VersionableBehaviorTest5(); + $b1->setFoo('Hello'); + $b2 = new VersionableBehaviorTest5(); + $b2->setFoo('World'); + $a = new VersionableBehaviorTest4(); + $a->setBar(123); // a1 + $a->addVersionableBehaviorTest5($b1); + $a->addVersionableBehaviorTest5($b2); + $a->save(); //b1 + $this->assertEquals(1, $a->getVersion()); + $this->assertEquals(array(1, 1), $a->getOneVersion(1)->getVersionableBehaviorTest5Versions()); + $b1->setFoo('Heloo'); + $a->save(); + $this->assertEquals(2, $a->getVersion()); + $this->assertEquals(array(2, 1), $a->getOneVersion(2)->getVersionableBehaviorTest5Versions()); + $b3 = new VersionableBehaviorTest5(); + $b3->setFoo('Yep'); + $a->clearVersionableBehaviorTest5s(); + $a->addVersionableBehaviorTest5($b3); + $a->save(); + $a->clearVersionableBehaviorTest5s(); + $this->assertEquals(3, $a->getVersion()); + $this->assertEquals(array(2, 1, 1), $a->getOneVersion(3)->getVersionableBehaviorTest5Versions()); + } + + public function testEnumField() + { + $o = new VersionableBehaviorTest7(); + $o->setStyle('novel'); + $o->save(); + + $this->assertEquals('novel', $o->getStyle(), 'Set style to novel'); + $this->assertEquals(1, $o->getVersion(), ''); + + $o->setStyle('essay'); + $o->save(); + + $this->assertEquals('essay', $o->getStyle(), 'Set style to essay'); + $this->assertEquals(2, $o->getVersion(), ''); + + $this->assertEquals('novel', $o->getOneVersion(1)->getStyle(), 'First version is a novel'); + $this->assertEquals('essay', $o->getOneVersion(2)->getStyle(), 'Second version is an essay'); + } + + public function testCustomIdName() + { + $b1 = new VersionableBehaviorTest8(); + $b2 = new VersionableBehaviorTest9(); + $b1->save(); + $b2->setVersionableBehaviorTest8($b1); + $b2->save(); + $b2->setFoo('test2'); + $b2->save(); + $b1->setFoobar('test1'); + $b1->save(); + } + + public function testWithInheritance() + { + $b1 = new VersionableBehaviorTest8Foo(); + $b1->save(); + + $b1->setFoobar('name'); + $b1->save(); + + $object = $b1->getOneVersion($b1->getVersion()); + $this->assertTrue($object instanceof Versionablebehaviortest8Version); + } + + public function testEnforceVersioning() + { + $bar = new VersionableBehaviorTest10(); + $bar->setBar(42); + $bar->save(); + + $this->assertEquals(1, $bar->getVersion()); + $this->assertFalse($bar->isVersioningNecessary()); + + $bar->enforceVersioning(); + $this->assertTrue($bar->isVersioningNecessary()); + + $bar->save(); + $this->assertEquals(2, $bar->getVersion()); + } + + public function testOneToOneHasForeignVersionColumn() + { + $this->assertTrue(class_exists('VersionableBehaviorTest13Peer')); + + $this->assertEquals('VersionableBehaviorTest13_version.VersionableBehaviorTest14_id', VersionableBehaviorTest13VersionPeer::VERSIONABLEBEHAVIORTEST14_ID); + $this->assertEquals('VersionableBehaviorTest13_version.VersionableBehaviorTest14_version', VersionableBehaviorTest13VersionPeer::VERSIONABLEBEHAVIORTEST14_VERSION); + } + + public function testOneToOneRelatesSingle() + { + $foo = new VersionableBehaviorTest13(); + $foo->setName('Foo'); + + $bar = new VersionableBehaviorTest14(); + $bar->setValue('Something'); + + $foo->setVersionableBehaviorTest14($bar); + $foo->save(); + + $this->assertEquals(1, $foo->getVersion()); + $this->assertEquals(1, $bar->getVersion()); + + $foo = VersionableBehaviorTest13Query::create()->findOne(); + $this->assertInstanceOf('VersionableBehaviorTest13', $foo); + + $bar = $foo->getVersionableBehaviorTest14(); + $this->assertInstanceOf('VersionableBehaviorTest14', $bar); + + $this->assertFalse($foo->isVersioningNecessary()); + + $bar->setValue('Something new'); + $this->assertTrue($foo->isVersioningNecessary()); + + $foo->save(); + + $this->assertEquals(2, $foo->getVersion()); + $this->assertEquals(2, $bar->getVersion()); + + $foo->toVersion(1); + + $this->assertEquals('Something', $foo->getVersionableBehaviorTest14()->getValue()); + } + + public function testVersionColumnNameCaseInsensitivity() + { + $schema = << + + + + + + + +
+ +XML; + + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + + $classes = $builder->getClasses(); + + preg_match_all('/public function getVersion\(/', $classes, $getterMatches); + preg_match_all('/public function filterByVersion\(/', $classes, $filterMatches); + + // there should be two versions of this getter in the source. one for the main + // class and one for the version class + $this->assertEquals(2, sizeof($getterMatches[0])); + + // there should be two versions of the filter. one for the main query class + // and one for the version query class + $this->assertEquals(2, sizeof($filterMatches[0])); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/versionable/VersionableBehaviorPeerBuilderModifierTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/versionable/VersionableBehaviorPeerBuilderModifierTest.php new file mode 100644 index 000000000..bbcada332 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/versionable/VersionableBehaviorPeerBuilderModifierTest.php @@ -0,0 +1,51 @@ + + + + + +
+> +EOF; + PropelQuickBuilder::buildSchema($schema); + } + } + + public function testIsVersioningEnabled() + { + $this->assertTrue(VersionableBehaviorTest10Peer::isVersioningEnabled()); + VersionableBehaviorTest10Peer::disableVersioning(); + $this->assertFalse(VersionableBehaviorTest10Peer::isVersioningEnabled()); + VersionableBehaviorTest10Peer::enableVersioning(); + $this->assertTrue(VersionableBehaviorTest10Peer::isVersioningEnabled()); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/behavior/versionable/VersionableBehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/behavior/versionable/VersionableBehaviorTest.php new file mode 100644 index 000000000..b47d20242 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/behavior/versionable/VersionableBehaviorTest.php @@ -0,0 +1,467 @@ + + + + + +
+ +EOF; + + return array(array($schema)); + } + + /** + * @dataProvider basicSchemaDataProvider + */ + public function testModifyTableAddsVersionColumn($schema) + { + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + public function testModifyTableAddsVersionColumnCustomName() + { + $schema = << + + + + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + public function testModifyTableDoesNotAddVersionColumnIfExists() + { + $schema = << + + + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + public function foreignTableSchemaDataProvider() + { + $schema = << + + + + + + + + +
+ + + + +
+ +EOF; + + return array(array($schema)); + } + + /** + * @dataProvider foreignTableSchemaDataProvider + */ + public function testModifyTableAddsVersionColumnForForeignKeysIfForeignTableIsVersioned($schema) + { + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + /** + * @dataProvider foreignTableSchemaDataProvider + */ + public function testModifyTableAddsVersionColumnForReferrersIfForeignTableIsVersioned($schema) + { + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + /** + * @dataProvider basicSchemaDataProvider + */ + public function testModifyTableAddsVersionTable($schema) + { + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + public function testModifyTableAddsVersionTableCustomName() + { + $schema = << + + + + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + public function testModifyTableDoesNotAddVersionTableIfExists() + { + $schema = << + + + + +
+ + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertEquals($expected, $builder->getSQL()); + } + + public function logSchemaDataProvider() + { + $schema = << + + + + + + + + +
+ +EOF; + + return array(array($schema)); + } + + /** + * @dataProvider logSchemaDataProvider + */ + public function testModifyTableAddsLogColumns($schema) + { + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + /** + * @dataProvider logSchemaDataProvider + */ + public function testModifyTableAddsVersionTableLogColumns($schema) + { + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + + public function testDatabaseLevelBehavior() + { + $schema = << + + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/NamespaceTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/NamespaceTest.php index ff69d6f7e..c95b4b4af 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/builder/NamespaceTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/NamespaceTest.php @@ -8,218 +8,298 @@ * @license MIT License */ -require_once 'PHPUnit/Framework/TestCase.php'; require_once dirname(__FILE__) . '/../../../../runtime/lib/Propel.php'; -set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/namespaced/build/classes"); +set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../../fixtures/namespaced/build/classes')); /** * Tests for Namespaces in generated classes class * Requires a build of the 'namespaced' fixture * - * @version $Revision: 1792 $ + * @version $Revision$ * @package generator.builder */ class NamespaceTest extends PHPUnit_Framework_TestCase { - protected function setUp() - { - if (version_compare(PHP_VERSION, '5.3.0') < 0) { - $this->markTestSkipped('Namespace support requires PHP 5.3'); - } - parent::setUp(); - Propel::init('fixtures/namespaced/build/conf/bookstore_namespaced-conf.php'); - } + protected function setUp() + { + if (version_compare(PHP_VERSION, '5.3.0') < 0) { + $this->markTestSkipped('Namespace support requires PHP 5.3'); + } + parent::setUp(); + Propel::init(dirname(__FILE__) . '/../../../fixtures/namespaced/build/conf/bookstore_namespaced-conf.php'); + } - protected function tearDown() - { - parent::tearDown(); - Propel::init('fixtures/bookstore/build/conf/bookstore-conf.php'); - } - - public function testInsert() - { - $book = new \Foo\Bar\NamespacedBook(); - $book->setTitle('foo'); - $book->save(); - $this->assertFalse($book->isNew()); - - $publisher = new \Baz\NamespacedPublisher(); - $publisher->save(); - $this->assertFalse($publisher->isNew()); - } + protected function tearDown() + { + parent::tearDown(); + Propel::init(dirname(__FILE__) . '/../../../fixtures/bookstore/build/conf/bookstore-conf.php'); + } - public function testUpdate() - { - $book = new \Foo\Bar\NamespacedBook(); - $book->setTitle('foo'); - $book->save(); - $book->setTitle('bar'); - $book->save(); - $this->assertFalse($book->isNew()); - } + public function testInsert() + { + $book = new \Foo\Bar\NamespacedBook(); + $book->setTitle('foo'); + $book->setISBN('something'); + $book->save(); + $this->assertFalse($book->isNew()); - public function testRelate() - { - $author = new NamespacedAuthor(); - $book = new \Foo\Bar\NamespacedBook(); - $book->setNamespacedAuthor($author); - $book->save(); - $this->assertFalse($book->isNew()); - $this->assertFalse($author->isNew()); - - $author = new NamespacedAuthor(); - $book = new \Foo\Bar\NamespacedBook(); - $author->addNamespacedBook($book); - $author->save(); - $this->assertFalse($book->isNew()); - $this->assertFalse($author->isNew()); - - $publisher = new \Baz\NamespacedPublisher(); - $book = new \Foo\Bar\NamespacedBook(); - $book->setNamespacedPublisher($publisher); - $book->save(); - $this->assertFalse($book->isNew()); - $this->assertFalse($publisher->isNew()); - } - - public function testBasicQuery() - { - \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); - \Baz\NamespacedPublisherQuery::create()->deleteAll(); - $noNamespacedBook = \Foo\Bar\NamespacedBookQuery::create()->findOne(); - $this->assertNull($noNamespacedBook); - $noPublihser = \Baz\NamespacedPublisherQuery::create()->findOne(); - $this->assertNull($noPublihser); - } - - public function testFind() - { - \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); - $book = new \Foo\Bar\NamespacedBook(); - $book->setTitle('War And Peace'); - $book->save(); - $book2 = \Foo\Bar\NamespacedBookQuery::create()->findPk($book->getId()); - $this->assertEquals($book, $book2); - $book3 = \Foo\Bar\NamespacedBookQuery::create()->findOneByTitle($book->getTitle()); - $this->assertEquals($book, $book3); - } + $publisher = new \Baz\NamespacedPublisher(); + $publisher->save(); + $this->assertFalse($publisher->isNew()); + } - public function testGetRelatedManyToOne() - { - \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); - \Baz\NamespacedPublisherQuery::create()->deleteAll(); - $publisher = new \Baz\NamespacedPublisher(); - $book = new \Foo\Bar\NamespacedBook(); - $book->setNamespacedPublisher($publisher); - $book->save(); - \Foo\Bar\NamespacedBookPeer::clearInstancePool(); - \Baz\NamespacedPublisherPeer::clearInstancePool(); - $book2 = \Foo\Bar\NamespacedBookQuery::create()->findPk($book->getId()); - $publisher2 = $book2->getNamespacedPublisher(); - $this->assertEquals($publisher->getId(), $publisher2->getId()); - } + public function testUpdate() + { + $book = new \Foo\Bar\NamespacedBook(); + $book->setTitle('foo'); + $book->setISBN('something'); + $book->save(); + $book->setTitle('bar'); + $book->save(); + $this->assertFalse($book->isNew()); + } - public function testGetRelatedOneToMany() - { - \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); - \Baz\NamespacedPublisherQuery::create()->deleteAll(); - $author = new NamespacedAuthor(); - $book = new \Foo\Bar\NamespacedBook(); - $book->setNamespacedAuthor($author); - $book->save(); - \Foo\Bar\NamespacedBookPeer::clearInstancePool(); - NamespacedAuthorPeer::clearInstancePool(); - $author2 = NamespacedAuthorQuery::create()->findPk($author->getId()); - $book2 = $author2->getNamespacedBooks()->getFirst(); - $this->assertEquals($book->getId(), $book2->getId()); - } - - public function testFindWithManyToOne() - { - \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); - \Baz\NamespacedPublisherQuery::create()->deleteAll(); - $publisher = new \Baz\NamespacedPublisher(); - $book = new \Foo\Bar\NamespacedBook(); - $book->setNamespacedPublisher($publisher); - $book->save(); - \Foo\Bar\NamespacedBookPeer::clearInstancePool(); - \Baz\NamespacedPublisherPeer::clearInstancePool(); - $book2 = \Foo\Bar\NamespacedBookQuery::create() - ->joinWith('NamespacedPublisher') - ->findPk($book->getId()); - $publisher2 = $book2->getNamespacedPublisher(); - $this->assertEquals($publisher->getId(), $publisher2->getId()); - } + public function testRelate() + { + $author = new NamespacedAuthor(); + $author->setFirstName('Chuck'); + $author->setLastname('Norris'); + $book = new \Foo\Bar\NamespacedBook(); + $book->setNamespacedAuthor($author); + $book->setTitle('foo'); + $book->setISBN('something'); + $book->save(); + $this->assertFalse($book->isNew()); + $this->assertFalse($author->isNew()); - public function testFindWithOneToMany() - { - \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); - NamespacedAuthorQuery::create()->deleteAll(); - $author = new NamespacedAuthor(); - $book = new \Foo\Bar\NamespacedBook(); - $book->setNamespacedAuthor($author); - $book->save(); - \Foo\Bar\NamespacedBookPeer::clearInstancePool(); - NamespacedAuthorPeer::clearInstancePool(); - $author2 = NamespacedAuthorQuery::create() - ->joinWith('NamespacedBook') - ->findPk($author->getId()); - $book2 = $author2->getNamespacedBooks()->getFirst(); - $this->assertEquals($book->getId(), $book2->getId()); - } - - public function testSingleTableInheritance() - { - \Foo\Bar\NamespacedBookstoreEmployeeQuery::create()->deleteAll(); - $emp = new \Foo\Bar\NamespacedBookstoreEmployee(); - $emp->setName('Henry'); - $emp->save(); - $man = new \Foo\Bar\NamespacedBookstoreManager(); - $man->setName('John'); - $man->save(); - $cas = new \Foo\Bar\NamespacedBookstoreCashier(); - $cas->setName('William'); - $cas->save(); - $emps = \Foo\Bar\NamespacedBookstoreEmployeeQuery::create() - ->orderByName() - ->find(); - $this->assertEquals(3, count($emps)); - $this->assertTrue($emps[0] instanceof \Foo\Bar\NamespacedBookstoreEmployee); - $this->assertTrue($emps[1] instanceof \Foo\Bar\NamespacedBookstoreManager); - $this->assertTrue($emps[2] instanceof \Foo\Bar\NamespacedBookstoreCashier); - $nbMan = \Foo\Bar\NamespacedBookstoreManagerQuery::create() - ->count(); - $this->assertEquals(1, $nbMan); - } - - public function testManyToMany() - { - \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); - \Baz\NamespacedBookClubQuery::create()->deleteAll(); - NamespacedBookListRelQuery::create()->deleteAll(); - $book1 = new \Foo\Bar\NamespacedBook(); - $book1->setTitle('bar'); - $book1->save(); - $book2 = new \Foo\Bar\NamespacedBook(); - $book2->setTitle('foo'); - $book2->save(); - $bookClub1 = new \Baz\NamespacedBookClub(); - $bookClub1->addNamespacedBook($book1); - $bookClub1->addNamespacedBook($book2); - $bookClub1->save(); - $bookClub2 = new \Baz\NamespacedBookClub(); - $bookClub2->addNamespacedBook($book1); - $bookClub2->save(); - $this->assertEquals(2, $book1->countNamespacedBookClubs()); - $this->assertEquals(1, $book2->countNamespacedBookClubs()); - $nbRels = NamespacedBookListRelQuery::create()->count(); - $this->assertEquals(3, $nbRels); - $con = Propel::getConnection(NamespacedBookListRelPeer::DATABASE_NAME); - $books = \Foo\Bar\NamespacedBookQuery::create() - ->orderByTitle() - ->joinWith('NamespacedBookListRel') - ->joinWith('NamespacedBookListRel.NamespacedBookClub') - ->find($con); - } - + $author = new NamespacedAuthor(); + $author->setFirstName('Henning'); + $author->setLastname('Mankell'); + $book = new \Foo\Bar\NamespacedBook(); + $book->setTitle('Mördare utan ansikte'); + $book->setISBN('1234'); + $author->addNamespacedBook($book); + $author->save(); + $this->assertFalse($book->isNew()); + $this->assertFalse($author->isNew()); + + $publisher = new \Baz\NamespacedPublisher(); + $book = new \Foo\Bar\NamespacedBook(); + $book->setTitle('Där vi en gång gått'); + $book->setISBN('1234'); + $book->setNamespacedPublisher($publisher); + $book->save(); + $this->assertFalse($book->isNew()); + $this->assertFalse($publisher->isNew()); + } + + public function testBasicQuery() + { + \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); + \Baz\NamespacedPublisherQuery::create()->deleteAll(); + $noNamespacedBook = \Foo\Bar\NamespacedBookQuery::create()->findOne(); + $this->assertNull($noNamespacedBook); + $noPublisher = \Baz\NamespacedPublisherQuery::create()->findOne(); + $this->assertNull($noPublisher); + } + + public function testFind() + { + \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); + $book = new \Foo\Bar\NamespacedBook(); + $book->setTitle('War And Peace'); + $book->setISBN('1234'); + $book->save(); + $book2 = \Foo\Bar\NamespacedBookQuery::create()->findPk($book->getId()); + $this->assertEquals($book, $book2); + $book3 = \Foo\Bar\NamespacedBookQuery::create()->findOneByTitle($book->getTitle()); + $this->assertEquals($book, $book3); + } + + public function testGetRelatedManyToOne() + { + \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); + \Baz\NamespacedPublisherQuery::create()->deleteAll(); + $publisher = new \Baz\NamespacedPublisher(); + $book = new \Foo\Bar\NamespacedBook(); + $book->setTitle('Something'); + $book->setISBN('1234'); + $book->setNamespacedPublisher($publisher); + $book->save(); + \Foo\Bar\NamespacedBookPeer::clearInstancePool(); + \Baz\NamespacedPublisherPeer::clearInstancePool(); + $book2 = \Foo\Bar\NamespacedBookQuery::create()->findPk($book->getId()); + $publisher2 = $book2->getNamespacedPublisher(); + $this->assertEquals($publisher->getId(), $publisher2->getId()); + } + + public function testGetRelatedOneToMany() + { + \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); + \Baz\NamespacedPublisherQuery::create()->deleteAll(); + $author = new NamespacedAuthor(); + $author->setFirstName('Foo'); + $author->setLastName('Bar'); + $book = new \Foo\Bar\NamespacedBook(); + $book->setTitle('Quux'); + $book->setISBN('1235'); + $book->setNamespacedAuthor($author); + $book->save(); + \Foo\Bar\NamespacedBookPeer::clearInstancePool(); + NamespacedAuthorPeer::clearInstancePool(); + $author2 = NamespacedAuthorQuery::create()->findPk($author->getId()); + $book2 = $author2->getNamespacedBooks()->getFirst(); + $this->assertEquals($book->getId(), $book2->getId()); + } + + public function testFindWithManyToOne() + { + \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); + \Baz\NamespacedPublisherQuery::create()->deleteAll(); + $publisher = new \Baz\NamespacedPublisher(); + $book = new \Foo\Bar\NamespacedBook(); + $book->setTitle('asdf'); + $book->setISBN('something'); + $book->setNamespacedPublisher($publisher); + $book->save(); + \Foo\Bar\NamespacedBookPeer::clearInstancePool(); + \Baz\NamespacedPublisherPeer::clearInstancePool(); + $book2 = \Foo\Bar\NamespacedBookQuery::create() + ->joinWith('NamespacedPublisher') + ->findPk($book->getId()); + $publisher2 = $book2->getNamespacedPublisher(); + $this->assertEquals($publisher->getId(), $publisher2->getId()); + } + + public function testFindWithOneToMany() + { + \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); + NamespacedAuthorQuery::create()->deleteAll(); + $author = new NamespacedAuthor(); + $author->setFirstName('Foo'); + $author->setLastName('Bar'); + $book = new \Foo\Bar\NamespacedBook(); + $book->setTitle('asdf'); + $book->setISBN('something'); + $book->setNamespacedAuthor($author); + $book->save(); + \Foo\Bar\NamespacedBookPeer::clearInstancePool(); + NamespacedAuthorPeer::clearInstancePool(); + $author2 = NamespacedAuthorQuery::create() + ->joinWith('NamespacedBook') + ->findPk($author->getId()); + $book2 = $author2->getNamespacedBooks()->getFirst(); + $this->assertEquals($book->getId(), $book2->getId()); + } + + public function testSingleTableInheritance() + { + \Foo\Bar\NamespacedBookstoreEmployeeQuery::create()->deleteAll(); + $emp = new \Foo\Bar\NamespacedBookstoreEmployee(); + $emp->setName('Henry'); + $emp->save(); + $man = new \Foo\Bar\NamespacedBookstoreManager(); + $man->setName('John'); + $man->save(); + $cas = new \Foo\Bar\NamespacedBookstoreCashier(); + $cas->setName('William'); + $cas->save(); + $emps = \Foo\Bar\NamespacedBookstoreEmployeeQuery::create() + ->orderByName() + ->find(); + $this->assertEquals(3, count($emps)); + $this->assertTrue($emps[0] instanceof \Foo\Bar\NamespacedBookstoreEmployee); + $this->assertTrue($emps[1] instanceof \Foo\Bar\NamespacedBookstoreManager); + $this->assertTrue($emps[2] instanceof \Foo\Bar\NamespacedBookstoreCashier); + $nbMan = \Foo\Bar\NamespacedBookstoreManagerQuery::create() + ->count(); + $this->assertEquals(1, $nbMan); + } + + public function testManyToMany() + { + \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); + \Baz\NamespacedBookClubQuery::create()->deleteAll(); + NamespacedBookListRelQuery::create()->deleteAll(); + $book1 = new \Foo\Bar\NamespacedBook(); + $book1->setTitle('bar'); + $book1->setISBN('1234'); + $book1->save(); + $book2 = new \Foo\Bar\NamespacedBook(); + $book2->setTitle('foo'); + $book2->setISBN('4567'); + $book2->save(); + $bookClub1 = new \Baz\NamespacedBookClub(); + $bookClub1->addNamespacedBook($book1); + $bookClub1->addNamespacedBook($book2); + $bookClub1->setGroupLeader('Someone1'); + $bookClub1->save(); + $bookClub2 = new \Baz\NamespacedBookClub(); + $bookClub2->addNamespacedBook($book1); + $bookClub2->setGroupLeader('Someone2'); + $bookClub2->save(); + $this->assertEquals(2, $book1->countNamespacedBookClubs()); + $this->assertEquals(1, $book2->countNamespacedBookClubs()); + $nbRels = NamespacedBookListRelQuery::create()->count(); + $this->assertEquals(3, $nbRels); + $con = Propel::getConnection(NamespacedBookListRelPeer::DATABASE_NAME); + $books = \Foo\Bar\NamespacedBookQuery::create() + ->orderByTitle() + ->joinWith('NamespacedBookListRel') + ->joinWith('NamespacedBookListRel.NamespacedBookClub') + ->find($con); + } + + public function testManyToManyRecursiveSave() + { + \Foo\Bar\NamespacedBookQuery::create()->deleteAll(); + \Baz\NamespacedBookClubQuery::create()->deleteAll(); + NamespacedBookListRelQuery::create()->deleteAll(); + $book1 = new \Foo\Bar\NamespacedBook(); + $book1->setTitle('bar'); + $book1->setISBN('1234'); + $book1->save(); + $book2 = new \Foo\Bar\NamespacedBook(); + $book2->setTitle('foo'); + $book2->setISBN('4567'); + $book2->save(); + $bookClub1 = new \Baz\NamespacedBookClub(); + $bookClub1->addNamespacedBook($book1); + $bookClub1->addNamespacedBook($book2); + $bookClub1->setGroupLeader('Someone1'); + $bookClub1->save(); + + $book2->setTitle('boo'); + + $bookClub1->setGroupLeader('Someone2'); + $bookClub1->save(); + + $this->assertEquals(false, $book2->isModified()); + } + + public function testUseQuery() + { + $book = \Foo\Bar\NamespacedBookQuery::create() + ->useNamespacedPublisherQuery() + ->filterByName('foo') + ->endUse() + ->findOne(); + $this->assertNull($book); + } + + public function testFindOneOrCreateFunction() + { + \Foo\Bar\NamespacedBookstoreCashierQuery::create()->deleteAll(); + + $cashier = \Foo\Bar\NamespacedBookstoreCashierQuery::create()->findOneOrCreate(); + $this->assertTrue($cashier instanceof \Foo\Bar\NamespacedBookstoreCashier, 'findOneOrCreate return right object when create one : NamespacedBookstoreCashier'); + + try { + $cashier = \Foo\Bar\NamespacedBookstoreCashierQuery::create() + ->joinSubordinate() + ->findOneOrCreate(); + } catch (\PropelException $e) { + $this->assertEquals('findOneOrCreate() cannot be used on a query with a join, because Propel cannot transform a SQL JOIN into a subquery. You should split the query in two queries to avoid joins.', $e->getMessage()); + } + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedNestedSetObjectTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedNestedSetObjectTest.php index e6f7fb943..1b318a859 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedNestedSetObjectTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedNestedSetObjectTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/cms/CmsTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/cms/CmsTestBase.php'; /** * Tests the generated nested-set Object classes. @@ -17,7 +17,7 @@ require_once 'tools/helpers/cms/CmsTestBase.php'; * object operations. The _idea_ here is to test every possible generated method * from Object.tpl; if necessary, bookstore will be expanded to accommodate this. * - * The database is relaoded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same * for each test method in this class. See the CmsDataPopulator::populate() * method for the exact contents of the database. @@ -27,161 +27,158 @@ require_once 'tools/helpers/cms/CmsTestBase.php'; */ class GeneratedNestedSetObjectTest extends CmsTestBase { - /** - * Test xxxNestedSet::isRoot() as true - */ - public function testObjectIsRootTrue() - { - $pp = PagePeer::retrieveRoot(1); - $this->assertTrue($pp->isRoot(), 'Node must be root'); - } + /** + * Test xxxNestedSet::isRoot() as true + */ + public function testObjectIsRootTrue() + { + $pp = PagePeer::retrieveRoot(1); + $this->assertTrue($pp->isRoot(), 'Node must be root'); + } - /** - * Test xxxNestedSet::isRoot() as false - */ - public function testObjectIsRootFalse() - { - $c = new Criteria(PagePeer::DATABASE_NAME); - $c->add(PagePeer::TITLE, 'school', Criteria::EQUAL); + /** + * Test xxxNestedSet::isRoot() as false + */ + public function testObjectIsRootFalse() + { + $c = new Criteria(PagePeer::DATABASE_NAME); + $c->add(PagePeer::TITLE, 'school', Criteria::EQUAL); - $school = PagePeer::doSelectOne($c); - $this->assertFalse($school->isRoot(), 'Node must not be root'); - } + $school = PagePeer::doSelectOne($c); + $this->assertFalse($school->isRoot(), 'Node must not be root'); + } - /** - * Test xxxNestedSet::retrieveParent() as true. - */ - public function testObjectRetrieveParentTrue() - { - $c = new Criteria(PagePeer::DATABASE_NAME); - $c->add(PagePeer::TITLE, 'school', Criteria::EQUAL); + /** + * Test xxxNestedSet::retrieveParent() as true. + */ + public function testObjectRetrieveParentTrue() + { + $c = new Criteria(PagePeer::DATABASE_NAME); + $c->add(PagePeer::TITLE, 'school', Criteria::EQUAL); - $school = PagePeer::doSelectOne($c); - $this->assertNotNull($school->retrieveParent(), 'Parent node must exist'); - } + $school = PagePeer::doSelectOne($c); + $this->assertNotNull($school->retrieveParent(), 'Parent node must exist'); + } - /** - * Test xxxNestedSet::retrieveParent() as false. - */ - public function testObjectRetrieveParentFalse() - { - $c = new Criteria(PagePeer::DATABASE_NAME); - $c->add(PagePeer::TITLE, 'home', Criteria::EQUAL); + /** + * Test xxxNestedSet::retrieveParent() as false. + */ + public function testObjectRetrieveParentFalse() + { + $c = new Criteria(PagePeer::DATABASE_NAME); + $c->add(PagePeer::TITLE, 'home', Criteria::EQUAL); - $home = PagePeer::doSelectOne($c); - $this->assertNull($home->retrieveParent(), 'Parent node must not exist and retrieved not be null'); - } + $home = PagePeer::doSelectOne($c); + $this->assertNull($home->retrieveParent(), 'Parent node must not exist and retrieved not be null'); + } - /** - * Test xxxNestedSet::hasParent() as true. - */ - public function testObjectHasParentTrue() - { - $c = new Criteria(); - $c->add(PagePeer::TITLE, 'school', Criteria::EQUAL); + /** + * Test xxxNestedSet::hasParent() as true. + */ + public function testObjectHasParentTrue() + { + $c = new Criteria(); + $c->add(PagePeer::TITLE, 'school', Criteria::EQUAL); - $school = PagePeer::doSelectOne($c); - $this->assertTrue($school->hasParent(), 'Node must have parent node'); - } + $school = PagePeer::doSelectOne($c); + $this->assertTrue($school->hasParent(), 'Node must have parent node'); + } - /** - * Test xxxNestedSet::hasParent() as false - */ - public function testObjectHasParentFalse() - { - $c = new Criteria(); - $c->add(PagePeer::TITLE, 'home', Criteria::EQUAL); + /** + * Test xxxNestedSet::hasParent() as false + */ + public function testObjectHasParentFalse() + { + $c = new Criteria(); + $c->add(PagePeer::TITLE, 'home', Criteria::EQUAL); - $home = PagePeer::doSelectOne($c); - $this->assertFalse($home->hasParent(), 'Root node must not have parent'); - } + $home = PagePeer::doSelectOne($c); + $this->assertFalse($home->hasParent(), 'Root node must not have parent'); + } - /** - * Test xxxNestedSet::isLeaf() as true. - */ - public function testObjectIsLeafTrue() - { - $c = new Criteria(); - $c->add(PagePeer::TITLE, 'simulator', Criteria::EQUAL); + /** + * Test xxxNestedSet::isLeaf() as true. + */ + public function testObjectIsLeafTrue() + { + $c = new Criteria(); + $c->add(PagePeer::TITLE, 'simulator', Criteria::EQUAL); - $simulator = PagePeer::doSelectOne($c); - $this->assertTrue($simulator->isLeaf($simulator), 'Node must be a leaf'); - } + $simulator = PagePeer::doSelectOne($c); + $this->assertTrue($simulator->isLeaf($simulator), 'Node must be a leaf'); + } - /** - * Test xxxNestedSet::isLeaf() as false - */ - public function testObjectIsLeafFalse() - { - $c = new Criteria(); - $c->add(PagePeer::TITLE, 'contact', Criteria::EQUAL); + /** + * Test xxxNestedSet::isLeaf() as false + */ + public function testObjectIsLeafFalse() + { + $c = new Criteria(); + $c->add(PagePeer::TITLE, 'contact', Criteria::EQUAL); - $contact = PagePeer::doSelectOne($c); - $this->assertFalse($contact->isLeaf($contact), 'Node must not be a leaf'); - } + $contact = PagePeer::doSelectOne($c); + $this->assertFalse($contact->isLeaf($contact), 'Node must not be a leaf'); + } - /** - * Test xxxNestedSet::makeRoot() - */ - public function testObjectMakeRoot() - { - $page = new Page(); - $page->makeRoot(); - $this->assertEquals(1, $page->getLeftValue(), 'Node left value must equal 1'); - $this->assertEquals(2, $page->getRightValue(), 'Node right value must equal 2'); - } + /** + * Test xxxNestedSet::makeRoot() + */ + public function testObjectMakeRoot() + { + $page = new Page(); + $page->makeRoot(); + $this->assertEquals(1, $page->getLeftValue(), 'Node left value must equal 1'); + $this->assertEquals(2, $page->getRightValue(), 'Node right value must equal 2'); + } - /** - * Test xxxNestedSet::makeRoot() exception - * @expectedException PropelException - */ - public function testObjectMakeRootException() - { - $c = new Criteria(); - $c->add(PagePeer::TITLE, 'home', Criteria::EQUAL); + /** + * Test xxxNestedSet::makeRoot() exception + * @expectedException PropelException + */ + public function testObjectMakeRootException() + { + $c = new Criteria(); + $c->add(PagePeer::TITLE, 'home', Criteria::EQUAL); - $home = PagePeer::doSelectOne($c); - $home->makeRoot(); - } + $home = PagePeer::doSelectOne($c); + $home->makeRoot(); + } - /** - * Test xxxNestedSet::getDescendants() - */ - public function testPeerGetDescendants() - { - $nodesWithoutPool = array(); - CategoryPeer::clearInstancePool(); - $cat = CategoryPeer::retrieveRoot(1); - $children = $cat->getDescendants(); - foreach($children as $child) - { - $nodesWithoutPool[] = $child->getTitle(); - } - $this->assertEquals($nodesWithoutPool, array('Cat_1_1', 'Cat_1_1_1', 'Cat_1_1_1_1')); - } + /** + * Test xxxNestedSet::getDescendants() + */ + public function testPeerGetDescendants() + { + $nodesWithoutPool = array(); + CategoryPeer::clearInstancePool(); + $cat = CategoryPeer::retrieveRoot(1); + $children = $cat->getDescendants(); + foreach ($children as $child) { + $nodesWithoutPool[] = $child->getTitle(); + } + $this->assertEquals($nodesWithoutPool, array('Cat_1_1', 'Cat_1_1_1', 'Cat_1_1_1_1')); + } - /** - * Test xxxNestedSet::getDescendantsTwice() - */ - public function testPeerGetDescendantsTwice() - { - $nodesWithoutPool = array(); - $nodesWithPool = array(); + /** + * Test xxxNestedSet::getDescendantsTwice() + */ + public function testPeerGetDescendantsTwice() + { + $nodesWithoutPool = array(); + $nodesWithPool = array(); - CategoryPeer::clearInstancePool(); - $cat = CategoryPeer::retrieveRoot(1); - $children = $cat->getDescendants(); - foreach($children as $child) - { - $nodesWithoutPool[] = $child->getTitle(); - } + CategoryPeer::clearInstancePool(); + $cat = CategoryPeer::retrieveRoot(1); + $children = $cat->getDescendants(); + foreach ($children as $child) { + $nodesWithoutPool[] = $child->getTitle(); + } - $cat = CategoryPeer::retrieveRoot(1); - $children = $cat->getDescendants(); - foreach($children as $child) - { - $nodesWithPool[] = $child->getTitle(); - } - $this->assertEquals($nodesWithoutPool, $nodesWithPool, 'Retrieved nodes must be the same with and without InstancePooling'); - } + $cat = CategoryPeer::retrieveRoot(1); + $children = $cat->getDescendants(); + foreach ($children as $child) { + $nodesWithPool[] = $child->getTitle(); + } + $this->assertEquals($nodesWithoutPool, $nodesWithPool, 'Retrieved nodes must be the same with and without InstancePooling'); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedNestedSetPeerTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedNestedSetPeerTest.php index ae255c010..5598cb647 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedNestedSetPeerTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedNestedSetPeerTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/cms/CmsTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/cms/CmsTestBase.php'; /** * Tests the generated nested-set Object classes. @@ -17,7 +17,7 @@ require_once 'tools/helpers/cms/CmsTestBase.php'; * object operations. The _idea_ here is to test every possible generated method * from Object.tpl; if necessary, bookstore will be expanded to accommodate this. * - * The database is relaoded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same * for each test method in this class. See the CmsDataPopulator::populate() * method for the exact contents of the database. @@ -27,162 +27,162 @@ require_once 'tools/helpers/cms/CmsTestBase.php'; */ class GeneratedNestedSetPeerTest extends CmsTestBase { - /** - * Test retrieveRoot() as true - */ - public function testRetrieveRootExist() - { - $pp = PagePeer::retrieveRoot(1); - $this->assertNotNull($pp, 'Node must exist and not be null'); - $this->assertEquals(1, $pp->getLeftValue(), 'Node left value must be equal to 1'); - } + /** + * Test retrieveRoot() as true + */ + public function testRetrieveRootExist() + { + $pp = PagePeer::retrieveRoot(1); + $this->assertNotNull($pp, 'Node must exist and not be null'); + $this->assertEquals(1, $pp->getLeftValue(), 'Node left value must be equal to 1'); + } - /** - * Test retrieveRoot() as false - */ - public function testRetrieveRootNotExist() - { - $pp = PagePeer::retrieveRoot(2); - $this->assertNull($pp, 'Root with such scopeId must not exist'); - } + /** + * Test retrieveRoot() as false + */ + public function testRetrieveRootNotExist() + { + $pp = PagePeer::retrieveRoot(2); + $this->assertNull($pp, 'Root with such scopeId must not exist'); + } - /** - * Test xxxNestedSetPeer::isRoot() as true - */ - public function testPeerIsRootTrue() - { - $pp = PagePeer::retrieveRoot(1); - $this->assertTrue(PagePeer::isRoot($pp), 'Node must be root'); - } + /** + * Test xxxNestedSetPeer::isRoot() as true + */ + public function testPeerIsRootTrue() + { + $pp = PagePeer::retrieveRoot(1); + $this->assertTrue(PagePeer::isRoot($pp), 'Node must be root'); + } - /** - * Test xxxNestedSetPeer::isRoot() as false - */ - public function testPeerIsRootFalse() - { - $c = new Criteria(PagePeer::DATABASE_NAME); - $c->add(PagePeer::TITLE, 'school', Criteria::EQUAL); + /** + * Test xxxNestedSetPeer::isRoot() as false + */ + public function testPeerIsRootFalse() + { + $c = new Criteria(PagePeer::DATABASE_NAME); + $c->add(PagePeer::TITLE, 'school', Criteria::EQUAL); - $school = PagePeer::doSelectOne($c); - $this->assertFalse(PagePeer::isRoot($school), 'Node must not be root'); - } + $school = PagePeer::doSelectOne($c); + $this->assertFalse(PagePeer::isRoot($school), 'Node must not be root'); + } - /** - * Test xxxNestedSetPeer::retrieveParent() as true. - */ - public function testPeerRetrieveParentTrue() - { - $c = new Criteria(PagePeer::DATABASE_NAME); - $c->add(PagePeer::TITLE, 'school', Criteria::EQUAL); + /** + * Test xxxNestedSetPeer::retrieveParent() as true. + */ + public function testPeerRetrieveParentTrue() + { + $c = new Criteria(PagePeer::DATABASE_NAME); + $c->add(PagePeer::TITLE, 'school', Criteria::EQUAL); - $school = PagePeer::doSelectOne($c); - $this->assertNotNull(PagePeer::retrieveParent($school), 'Parent node must exist'); - } + $school = PagePeer::doSelectOne($c); + $this->assertNotNull(PagePeer::retrieveParent($school), 'Parent node must exist'); + } - /** - * Test xxxNestedSetPeer::retrieveParent() as false. - */ - public function testPeerRetrieveParentFalse() - { - $c = new Criteria(PagePeer::DATABASE_NAME); - $c->add(PagePeer::TITLE, 'home', Criteria::EQUAL); + /** + * Test xxxNestedSetPeer::retrieveParent() as false. + */ + public function testPeerRetrieveParentFalse() + { + $c = new Criteria(PagePeer::DATABASE_NAME); + $c->add(PagePeer::TITLE, 'home', Criteria::EQUAL); - $home = PagePeer::doSelectOne($c); - $this->assertNull(PagePeer::retrieveParent($home), 'Parent node must not exist and retrieved not be null'); - } + $home = PagePeer::doSelectOne($c); + $this->assertNull(PagePeer::retrieveParent($home), 'Parent node must not exist and retrieved not be null'); + } - /** - * Test xxxNestedSetPeer::hasParent() as true. - */ - public function testPeerHasParentTrue() - { - $c = new Criteria(); - $c->add(PagePeer::TITLE, 'school', Criteria::EQUAL); + /** + * Test xxxNestedSetPeer::hasParent() as true. + */ + public function testPeerHasParentTrue() + { + $c = new Criteria(); + $c->add(PagePeer::TITLE, 'school', Criteria::EQUAL); - $school = PagePeer::doSelectOne($c); - $this->assertTrue(PagePeer::hasParent($school), 'Node must have parent node'); - } + $school = PagePeer::doSelectOne($c); + $this->assertTrue(PagePeer::hasParent($school), 'Node must have parent node'); + } - /** - * Test xxxNestedSetPeer::hasParent() as false - */ - public function testPeerHasParentFalse() - { - $c = new Criteria(); - $c->add(PagePeer::TITLE, 'home', Criteria::EQUAL); + /** + * Test xxxNestedSetPeer::hasParent() as false + */ + public function testPeerHasParentFalse() + { + $c = new Criteria(); + $c->add(PagePeer::TITLE, 'home', Criteria::EQUAL); - $home = PagePeer::doSelectOne($c); - $this->assertFalse(PagePeer::hasParent($home), 'Root node must not have parent'); - } + $home = PagePeer::doSelectOne($c); + $this->assertFalse(PagePeer::hasParent($home), 'Root node must not have parent'); + } - /** - * Test xxxNestedSetPeer::isValid() as true. - */ - public function testPeerIsValidTrue() - { - $c = new Criteria(); - $c->add(PagePeer::TITLE, 'school', Criteria::EQUAL); + /** + * Test xxxNestedSetPeer::isValid() as true. + */ + public function testPeerIsValidTrue() + { + $c = new Criteria(); + $c->add(PagePeer::TITLE, 'school', Criteria::EQUAL); - $school = PagePeer::doSelectOne($c); - $this->assertTrue(PagePeer::isValid($school), 'Node must be valid'); - } + $school = PagePeer::doSelectOne($c); + $this->assertTrue(PagePeer::isValid($school), 'Node must be valid'); + } - /** - * Test xxxNestedSetPeer::isValid() as false - */ - public function testPeerIsValidFalse() - { - $page = new Page(); - $this->assertFalse(PagePeer::isValid($page), 'Node left and right values must be invalid'); - $this->assertFalse(PagePeer::isValid(null), 'Null must be invalid'); - } + /** + * Test xxxNestedSetPeer::isValid() as false + */ + public function testPeerIsValidFalse() + { + $page = new Page(); + $this->assertFalse(PagePeer::isValid($page), 'Node left and right values must be invalid'); + $this->assertFalse(PagePeer::isValid(null), 'Null must be invalid'); + } - /** - * Test xxxNestedSetPeer::isLeaf() as true. - */ - public function testPeerIsLeafTrue() - { - $c = new Criteria(); - $c->add(PagePeer::TITLE, 'simulator', Criteria::EQUAL); + /** + * Test xxxNestedSetPeer::isLeaf() as true. + */ + public function testPeerIsLeafTrue() + { + $c = new Criteria(); + $c->add(PagePeer::TITLE, 'simulator', Criteria::EQUAL); - $simulator = PagePeer::doSelectOne($c); - $this->assertTrue(PagePeer::isLeaf($simulator), 'Node must be a leaf'); - } + $simulator = PagePeer::doSelectOne($c); + $this->assertTrue(PagePeer::isLeaf($simulator), 'Node must be a leaf'); + } - /** - * Test xxxNestedSetPeer::isLeaf() as false - */ - public function testPeerIsLeafFalse() - { - $c = new Criteria(); - $c->add(PagePeer::TITLE, 'contact', Criteria::EQUAL); + /** + * Test xxxNestedSetPeer::isLeaf() as false + */ + public function testPeerIsLeafFalse() + { + $c = new Criteria(); + $c->add(PagePeer::TITLE, 'contact', Criteria::EQUAL); - $contact = PagePeer::doSelectOne($c); - $this->assertFalse(PagePeer::isLeaf($contact), 'Node must not be a leaf'); - } + $contact = PagePeer::doSelectOne($c); + $this->assertFalse(PagePeer::isLeaf($contact), 'Node must not be a leaf'); + } - /** - * Test xxxNestedSetPeer::createRoot() - */ - public function testPeerCreateRoot() - { - $page = new Page(); - PagePeer::createRoot($page); - $this->assertEquals(1, $page->getLeftValue(), 'Node left value must equal 1'); - $this->assertEquals(2, $page->getRightValue(), 'Node right value must equal 2'); - } + /** + * Test xxxNestedSetPeer::createRoot() + */ + public function testPeerCreateRoot() + { + $page = new Page(); + PagePeer::createRoot($page); + $this->assertEquals(1, $page->getLeftValue(), 'Node left value must equal 1'); + $this->assertEquals(2, $page->getRightValue(), 'Node right value must equal 2'); + } - /** - * Test xxxNestedSetPeer::createRoot() exception - * @expectedException PropelException - */ - public function testPeerCreateRootException() - { - $c = new Criteria(); - $c->add(PagePeer::TITLE, 'home', Criteria::EQUAL); + /** + * Test xxxNestedSetPeer::createRoot() exception + * @expectedException PropelException + */ + public function testPeerCreateRootException() + { + $c = new Criteria(); + $c->add(PagePeer::TITLE, 'home', Criteria::EQUAL); - $home = PagePeer::doSelectOne($c); - PagePeer::createRoot($home); - } + $home = PagePeer::doSelectOne($c); + PagePeer::createRoot($home); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedNestedSetTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedNestedSetTest.php index b09178551..bab4e56ac 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedNestedSetTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedNestedSetTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/cms/CmsTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/cms/CmsTestBase.php'; /** * Tests the generated nested-set Object classes. @@ -17,7 +17,7 @@ require_once 'tools/helpers/cms/CmsTestBase.php'; * object operations. The _idea_ here is to test every possible generated method * from Object.tpl; if necessary, bookstore will be expanded to accommodate this. * - * The database is relaoded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same * for each test method in this class. See the CmsDataPopulator::populate() * method for the exact contents of the database. @@ -27,94 +27,94 @@ require_once 'tools/helpers/cms/CmsTestBase.php'; */ class GeneratedNestedSetTest extends CmsTestBase { - /** - * A convenience method to dump the page rows. - */ - private function showPageItems() - { - $tree = PagePeer::retrieveTree(); - $iterator = new RecursiveIteratorIterator($tree, RecursiveIteratorIterator::SELF_FIRST); + /** + * A convenience method to dump the page rows. + */ + private function showPageItems() + { + $tree = PagePeer::retrieveTree(); + $iterator = new RecursiveIteratorIterator($tree, RecursiveIteratorIterator::SELF_FIRST); - foreach ($iterator as $item) { /* @var $item Page */ - echo str_repeat('- ', $iterator->getDepth()) - , $item->getId() , ': ' - , $item->getTitle() - , ' [', $item->getLeftValue(), ':', $item->getRightValue() , ']' - . "\n"; - } - } + foreach ($iterator as $item) { /* @var $item Page */ + echo str_repeat('- ', $iterator->getDepth()) + , $item->getId() , ': ' + , $item->getTitle() + , ' [', $item->getLeftValue(), ':', $item->getRightValue() , ']' + . "\n"; + } + } - /** - * Adds a new Page row with specified parent Id. - * - * @param int $parentId - */ - protected function addNewChildPage($parentId) - { - $db = Propel::getConnection(PagePeer::DATABASE_NAME); + /** + * Adds a new Page row with specified parent Id. + * + * @param int $parentId + */ + protected function addNewChildPage($parentId) + { + $db = Propel::getConnection(PagePeer::DATABASE_NAME); - //$db->beginTransaction(); + //$db->beginTransaction(); - $parent = PagePeer::retrieveByPK($parentId); - $page = new Page(); - $page->setTitle('new page '.time()); - $page->insertAsLastChildOf($parent); - $page->save(); + $parent = PagePeer::retrieveByPK($parentId); + $page = new Page(); + $page->setTitle('new page '.time()); + $page->insertAsLastChildOf($parent); + $page->save(); - //$db->commit(); - } + //$db->commit(); + } - /** - * Asserts that the Page table tree integrity is intact. - */ - protected function assertPageTreeIntegrity() - { - $db = Propel::getConnection(PagePeer::DATABASE_NAME); + /** + * Asserts that the Page table tree integrity is intact. + */ + protected function assertPageTreeIntegrity() + { + $db = Propel::getConnection(PagePeer::DATABASE_NAME); - $values = array(); - $log = ''; + $values = array(); + $log = ''; - foreach ($db->query('SELECT Id, LeftChild, RightChild, Title FROM Page', PDO::FETCH_NUM) as $row) { + foreach ($db->query('SELECT Id, LeftChild, RightChild, Title FROM Page', PDO::FETCH_NUM) as $row) { - list($id, $leftChild, $rightChild, $title) = $row; + list($id, $leftChild, $rightChild, $title) = $row; - if (!in_array($leftChild, $values)) { - $values[] = (int) $leftChild; - } else { - $this->fail('Duplicate LeftChild value '.$leftChild); - } + if (!in_array($leftChild, $values)) { + $values[] = (int) $leftChild; + } else { + $this->fail('Duplicate LeftChild value '.$leftChild); + } - if (!in_array($rightChild, $values)) { - $values[] = (int) $rightChild; - } else { - $this->fail('Duplicate RightChild value '.$rightChild); - } + if (!in_array($rightChild, $values)) { + $values[] = (int) $rightChild; + } else { + $this->fail('Duplicate RightChild value '.$rightChild); + } - $log .= "[$id($leftChild:$rightChild)]"; - } + $log .= "[$id($leftChild:$rightChild)]"; + } - sort($values); + sort($values); - if ($values[count($values)-1] != count($values)) { - $message = sprintf("Tree integrity NOT ok (%s)\n", $log); - $message .= sprintf('Integrity error: value count: %d, high value: %d', count($values), $values[count($values)-1]); - $this->fail($message); - } + if ($values[count($values)-1] != count($values)) { + $message = sprintf("Tree integrity NOT ok (%s)\n", $log); + $message .= sprintf('Integrity error: value count: %d, high value: %d', count($values), $values[count($values)-1]); + $this->fail($message); + } - } + } - /** - * Tests adding a node to the Page tree. - */ - public function testAdd() - { - $db = Propel::getConnection(PagePeer::DATABASE_NAME); + /** + * Tests adding a node to the Page tree. + */ + public function testAdd() + { + $db = Propel::getConnection(PagePeer::DATABASE_NAME); - // I'm not sure if the specific ID matters, but this should match original - // code. The ID will change with subsequent runs (e.g. the first time it will be 11) - $startId = $db->query('SELECT MIN(Id) FROM Page')->fetchColumn(); - $this->addNewChildPage($startId + 10); - $this->assertPageTreeIntegrity(); - } + // I'm not sure if the specific ID matters, but this should match original + // code. The ID will change with subsequent runs (e.g. the first time it will be 11) + $startId = $db->query('SELECT MIN(Id) FROM Page')->fetchColumn(); + $this->addNewChildPage($startId + 10); + $this->assertPageTreeIntegrity(); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectArrayColumnTypeTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectArrayColumnTypeTest.php new file mode 100644 index 000000000..3a0555af5 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectArrayColumnTypeTest.php @@ -0,0 +1,237 @@ + + + + + + + +
+ +EOF; + PropelQuickBuilder::buildSchema($schema); + } + + ComplexColumnTypeEntity2Peer::doDeleteAll(); + } + + public function testActiveRecordMethods() + { + $this->assertTrue(method_exists('ComplexColumnTypeEntity2', 'getTags')); + $this->assertTrue(method_exists('ComplexColumnTypeEntity2', 'hasTag')); + $this->assertTrue(method_exists('ComplexColumnTypeEntity2', 'setTags')); + $this->assertTrue(method_exists('ComplexColumnTypeEntity2', 'addTag')); + $this->assertTrue(method_exists('ComplexColumnTypeEntity2', 'removeTag')); + // only plural column names get a tester, an adder, and a remover method + $this->assertTrue(method_exists('ComplexColumnTypeEntity2', 'getValueSet')); + $this->assertFalse(method_exists('ComplexColumnTypeEntity2', 'hasValueSet')); + $this->assertTrue(method_exists('ComplexColumnTypeEntity2', 'setValueSet')); + $this->assertFalse(method_exists('ComplexColumnTypeEntity2', 'addValueSet')); + $this->assertFalse(method_exists('ComplexColumnTypeEntity2', 'removeValueSet')); + } + + public function testGetterDefaultValue() + { + $e = new ComplexColumnTypeEntity2(); + $this->assertEquals(array(), $e->getValueSet(), 'array columns return an empty array by default'); + } + + public function testGetterDefaultValueWithData() + { + $e = new ComplexColumnTypeEntity2(); + $this->assertEquals(array('FOO'), $e->getDefaults()); + } + + public function testGetterDefaultValueWithMultipleData() + { + $e = new ComplexColumnTypeEntity2(); + $this->assertEquals(array('FOO', 'BAR', 'BAZ'), $e->getMultipleDefaults()); + } + + public function testAdderAddsNewValueToExistingData() + { + $e = new ComplexColumnTypeEntity2(); + $this->assertEquals(array('FOO'), $e->getDefaults()); + $e->addDefault('bar'); + $this->assertEquals(array('FOO', 'bar'), $e->getDefaults()); + } + + public function testAdderAddsNewValueToMultipleExistingData() + { + $e = new ComplexColumnTypeEntity2(); + $this->assertEquals(array('FOO', 'BAR', 'BAZ'), $e->getMultipleDefaults()); + $e->addMultipleDefault('bar'); + $this->assertEquals(array('FOO', 'BAR', 'BAZ', 'bar'), $e->getMultipleDefaults()); + } + + public function testDefaultValuesAreWellPersisted() + { + $e = new ComplexColumnTypeEntity2(); + $e->save(); + + ComplexColumnTypeEntity2Peer::clearInstancePool(); + $e = ComplexColumnTypeEntity2Query::create()->findOne(); + + $this->assertEquals(array('FOO'), $e->getDefaults()); + } + + public function testMultipleDefaultValuesAreWellPersisted() + { + $e = new ComplexColumnTypeEntity2(); + $e->save(); + + ComplexColumnTypeEntity2Peer::clearInstancePool(); + $e = ComplexColumnTypeEntity2Query::create()->findOne(); + + $this->assertEquals(array('FOO', 'BAR', 'BAZ'), $e->getMultipleDefaults()); + } + + public function testSetterArrayValue() + { + $e = new ComplexColumnTypeEntity2(); + $value = array('foo', 1234); + $e->setTags($value); + $this->assertEquals($value, $e->getTags(), 'array columns can store arrays'); + } + + public function testSetterResetValue() + { + $e = new ComplexColumnTypeEntity2(); + $value = array('foo', 1234); + $e->setTags($value); + $e->setTags(array()); + $this->assertEquals(array(), $e->getTags(), 'object columns can be reset'); + } + + public function testTester() + { + $e = new ComplexColumnTypeEntity2(); + $this->assertFalse($e->hasTag('foo')); + $this->assertFalse($e->hasTag(1234)); + $value = array('foo', 1234); + $e->setTags($value); + $this->assertTrue($e->hasTag('foo')); + $this->assertTrue($e->hasTag(1234)); + $this->assertFalse($e->hasTag('bar')); + $this->assertFalse($e->hasTag(12)); + } + + public function testAdder() + { + $e = new ComplexColumnTypeEntity2(); + $e->addTag('foo'); + $this->assertEquals(array('foo'), $e->getTags()); + $e->addTag(1234); + $this->assertEquals(array('foo', 1234), $e->getTags()); + $e->addTag('foo'); + $this->assertEquals(array('foo', 1234, 'foo'), $e->getTags()); + $e->setTags(array(12, 34)); + $e->addTag('foo'); + $this->assertEquals(array(12, 34, 'foo'), $e->getTags()); + } + + public function testRemover() + { + $e = new ComplexColumnTypeEntity2(); + $e->removeTag('foo'); + $this->assertEquals(array(), $e->getTags()); + $e->setTags(array('foo', 1234)); + $e->removeTag('foo'); + $this->assertEquals(array(1234), $e->getTags()); + $e->removeTag(1234); + $this->assertEquals(array(), $e->getTags()); + $e->setTags(array(12, 34, 1234)); + $e->removeTag('foo'); + $this->assertEquals(array(12, 34, 1234), $e->getTags()); + $e->removeTag('1234'); + $this->assertEquals(array(12, 34), $e->getTags()); + } + + public function testValueIsPersisted() + { + $e = new ComplexColumnTypeEntity2(); + $value = array('foo', 1234); + $e->setTags($value); + $e->save(); + ComplexColumnTypeEntity2Peer::clearInstancePool(); + $e = ComplexColumnTypeEntity2Query::create()->findOne(); + $this->assertEquals($value, $e->getTags(), 'array columns are persisted'); + } + + public function testGetterDoesNotKeepValueBetweenTwoHydrationsWhenUsingOnDemandFormatter() + { + ComplexColumnTypeEntity2Query::create()->deleteAll(); + $e = new ComplexColumnTypeEntity2(); + $e->setTags(array(1,2)); + $e->save(); + $e = new ComplexColumnTypeEntity2(); + $e->setTags(array(3,4)); + $e->save(); + $q = ComplexColumnTypeEntity2Query::create() + ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND) + ->find(); + + $tags = array(); + foreach ($q as $e) { + $tags[] = $e->getTags(); + } + $this->assertNotEquals($tags[0], $tags[1]); + } + + public function testHydrateOverwritePreviousValues() + { + $schema = << + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $builder->setClassTargets(array('tablemap', 'peer', 'object', 'query', 'peerstub', 'querystub')); + $builder->build(); + + require_once dirname(__FILE__) . '/fixtures/ComplexColumnTypeEntityWithConstructor.php'; + Propel::disableInstancePooling(); // need to be disabled to test the hydrate() method + + $obj = new ComplexColumnTypeEntityWithConstructor(); + $this->assertEquals(array('foo', 'bar'), $obj->getTags()); + + $obj->setTags(array('baz')); + $this->assertEquals(array('baz'), $obj->getTags()); + + $obj->save(); + + $obj = ComplexColumnTypeEntityWithConstructorQuery::create() + ->findOne(); + $this->assertEquals(array('baz'), $obj->getTags()); + + Propel::enableInstancePooling(); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectBooleanColumnTypeTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectBooleanColumnTypeTest.php new file mode 100644 index 000000000..58e17b695 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectBooleanColumnTypeTest.php @@ -0,0 +1,86 @@ + + + + + + +
+ +EOF; + PropelQuickBuilder::buildSchema($schema); + } + } + + public function providerForSetter() + { + return array( + array(true, true), + array(false, false), + array('true', true), + array('false', false), + array(1, true), + array(0, false), + array('1', true), + array('0', false), + array('on', true), + array('off', false), + array('yes', true), + array('no', false), + array('y', true), + array('n', false), + array('Y', true), + array('N', false), + array('+', true), + array('-', false), + array('', false), + ); + } + + /** + * @dataProvider providerForSetter + */ + public function testSetterBooleanValue($value, $expected) + { + $e = new ComplexColumnTypeEntity4(); + $e->setBar($value); + if ($expected) { + $this->assertTrue($e->getBar()); + } else { + $this->assertFalse($e->getBar()); + } + } + + public function testDefaultValue() + { + $e = new ComplexColumnTypeEntity4(); + $this->assertNull($e->getBar()); + $this->assertTrue($e->getTrueBar()); + $this->assertFalse($e->getFalseBar()); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectDateTimeColumnTypeTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectDateTimeColumnTypeTest.php new file mode 100644 index 000000000..156d52a4f --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectDateTimeColumnTypeTest.php @@ -0,0 +1,51 @@ + + + + +
+ +EOF; + $builder = new PropelQuickBuilder; + $builder->getConfig()->setBuildProperty('defaultDateFormat', null); + + $builder->setSchema($schema); + + $builder->build(); + } + } + + public function testAddInstanceToPoolWithDateTime() + { + DateTimeColumnTypeEntityPeer::clearInstancePool(); + $obj = new DateTimeColumnTypeEntity(); + $obj->setId(1); + $obj->setPrimaryDate(new \DateTime()); + DateTimeColumnTypeEntityPeer::addInstanceToPool($obj); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectEnumColumnTypeTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectEnumColumnTypeTest.php new file mode 100644 index 000000000..dcb1f20b2 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectEnumColumnTypeTest.php @@ -0,0 +1,144 @@ + + + + + +
+ +EOF; + PropelQuickBuilder::buildSchema($schema); + // ok this is hackish but it makes testing of getter and setter independent of each other + $publicAccessorCode = <<assertTrue(method_exists('ComplexColumnTypeEntity3', 'getBar')); + $e = new ComplexColumnTypeEntity3(); + $this->assertNull($e->getBar()); + $e = new PublicComplexColumnTypeEntity3(); + $e->bar = 0; + $this->assertEquals('foo', $e->getBar()); + $e->bar = 3; + $this->assertEquals('1', $e->getBar()); + $e->bar = 6; + $this->assertEquals('foo bar', $e->getBar()); + } + + /** + * @expectedException PropelException + */ + public function testGetterThrowsExceptionOnUnknownKey() + { + $e = new PublicComplexColumnTypeEntity3(); + $e->bar = 156; + $e->getBar(); + } + + public function testGetterDefaultValue() + { + $e = new PublicComplexColumnTypeEntity3(); + $this->assertEquals('bar', $e->getBar2()); + } + + public function testSetter() + { + $this->assertTrue(method_exists('ComplexColumnTypeEntity3', 'setBar')); + $e = new PublicComplexColumnTypeEntity3(); + $e->setBar('foo'); + $this->assertEquals(0, $e->bar); + $e->setBar(1); + $this->assertEquals(3, $e->bar); + $e->setBar('1'); + $this->assertEquals(3, $e->bar); + $e->setBar('foo bar'); + $this->assertEquals(6, $e->bar); + } + + /** + * @expectedException PropelException + */ + public function testSetterThrowsExceptionOnUnknownValue() + { + $e = new ComplexColumnTypeEntity3(); + $e->setBar('bazz'); + } + + public function testValueIsPersisted() + { + $e = new ComplexColumnTypeEntity3(); + $e->setBar('baz'); + $e->save(); + ComplexColumnTypeEntity3Peer::clearInstancePool(); + $e = ComplexColumnTypeEntity3Query::create()->findOne(); + $this->assertEquals('baz', $e->getBar()); + } + + public function testValueIsCopied() + { + $e1 = new ComplexColumnTypeEntity3(); + $e1->setBar('baz'); + $e2 = new ComplexColumnTypeEntity3(); + $e1->copyInto($e2); + $this->assertEquals('baz', $e2->getBar()); + } + + /** + * @see https://github.com/propelorm/Propel/issues/139 + */ + public function testSetterWithSameValueDoesNotUpdateObject() + { + $e = new ComplexColumnTypeEntity3(); + $e->setBar('baz'); + $e->resetModified(); + $e->setBar('baz'); + $this->assertFalse($e->isModified()); + } + + /** + * @see https://github.com/propelorm/Propel/issues/139 + */ + public function testSetterWithSameValueDoesNotUpdateHydratedObject() + { + $e = new ComplexColumnTypeEntity3(); + $e->setBar('baz'); + $e->save(); + // force hydration + ComplexColumnTypeEntity3Peer::clearInstancePool(); + $e = ComplexColumnTypeEntity3Query::create()->findPk($e->getPrimaryKey()); + $e->setBar('baz'); + $this->assertFalse($e->isModified()); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectLazyLoadTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectLazyLoadTest.php new file mode 100644 index 000000000..d589add8b --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectLazyLoadTest.php @@ -0,0 +1,96 @@ + + + + + + +
+ +EOF; + //PropelQuickBuilder::debugClassesForTable($schema, 'lazy_load_active_record'); + PropelQuickBuilder::buildSchema($schema); + } + } + + public function testNormalColumnsRequireNoQueryOnGetter() + { + $con = Propel::getconnection(LazyLoadActiveRecordPeer::DATABASE_NAME); + $con->useDebug(true); + $obj = new LazyLoadActiveRecord(); + $obj->setFoo('hello'); + $obj->save($con); + LazyLoadActiveRecordPeer::clearInstancePool(); + $obj2 = LazyLoadActiveRecordQuery::create()->findPk($obj->getId(), $con); + $count = $con->getQueryCount(); + $this->assertEquals('hello', $obj2->getFoo()); + $this->assertEquals($count, $con->getQueryCount()); + } + + public function testLazyLoadedColumnsRequireAnAdditionalQueryOnGetter() + { + $con = Propel::getconnection(LazyLoadActiveRecordPeer::DATABASE_NAME); + $con->useDebug(true); + $obj = new LazyLoadActiveRecord(); + $obj->setBar('hello'); + $obj->save($con); + LazyLoadActiveRecordPeer::clearInstancePool(); + $obj2 = LazyLoadActiveRecordQuery::create()->findPk($obj->getId(), $con); + $count = $con->getQueryCount(); + $this->assertEquals('hello', $obj2->getBar($con)); + $this->assertEquals($count + 1, $con->getQueryCount()); + } + + public function testLazyLoadedColumnsWithDefaultRequireAnAdditionalQueryOnGetter() + { + $con = Propel::getconnection(LazyLoadActiveRecordPeer::DATABASE_NAME); + $con->useDebug(true); + $obj = new LazyLoadActiveRecord(); + $obj->setBaz('hello'); + $obj->save($con); + LazyLoadActiveRecordPeer::clearInstancePool(); + $obj2 = LazyLoadActiveRecordQuery::create()->findPk($obj->getId(), $con); + $count = $con->getQueryCount(); + $this->assertEquals('hello', $obj2->getBaz($con)); + $this->assertEquals($count + 1, $con->getQueryCount()); + } + + public function testLazyLoadedColumnsMayBeUnsetWithoutLoading() + { + $con = Propel::getconnection(LazyLoadActiveRecordPeer::DATABASE_NAME); + $con->useDebug(true); + $obj = new LazyLoadActiveRecord(); + $obj->setBar('hello'); + $obj->save($con); + LazyLoadActiveRecordPeer::clearInstancePool(); + $obj2 = LazyLoadActiveRecordQuery::create()->findPk($obj->getId(), $con); + $obj2->setBar(null); + $obj2->save(); + LazyLoadActiveRecordPeer::clearInstancePool(); + $obj3 = LazyLoadActiveRecordQuery::create()->findPk($obj->getId(), $con); + $this->assertNull($obj3->getBar()); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectLobTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectLobTest.php index 290e73c4f..3ddfea3a7 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectLobTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectLobTest.php @@ -8,7 +8,11 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; + +if (!defined('TESTS_BASE_DIR')) { + define('TESTS_BASE_DIR', realpath(dirname(__FILE__) . '/../../../..')); +} /** * Tests the generated Object classes and LOB behavior. @@ -17,7 +21,7 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; * object operations. The _idea_ here is to test every possible generated method * from Object.tpl; if necessary, bookstore will be expanded to accommodate this. * - * The database is relaoded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same * for each test method in this class. See the BookstoreDataPopulator::populate() * method for the exact contents of the database. @@ -29,261 +33,261 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; class GeneratedObjectLobTest extends BookstoreEmptyTestBase { - /** - * Array of filenames pointing to blob/clob files indexed by the basename. - * - * @var array string[] - */ - protected $sampleLobFiles = array(); + /** + * Array of filenames pointing to blob/clob files indexed by the basename. + * + * @var array string[] + */ + protected $sampleLobFiles = array(); - protected function setUp() - { - parent::setUp(); - BookstoreDataPopulator::populate(); - $this->sampleLobFiles['tin_drum.gif'] = TESTS_BASE_DIR . '/etc/lob/tin_drum.gif'; - $this->sampleLobFiles['tin_drum.txt'] = TESTS_BASE_DIR . '/etc/lob/tin_drum.txt'; - $this->sampleLobFiles['propel.gif'] = TESTS_BASE_DIR . '/etc/lob/propel.gif'; - } + protected function setUp() + { + parent::setUp(); + BookstoreDataPopulator::populate(); + $this->sampleLobFiles['tin_drum.gif'] = TESTS_BASE_DIR . '/etc/lob/tin_drum.gif'; + $this->sampleLobFiles['tin_drum.txt'] = TESTS_BASE_DIR . '/etc/lob/tin_drum.txt'; + $this->sampleLobFiles['propel.gif'] = TESTS_BASE_DIR . '/etc/lob/propel.gif'; + } - /** - * Gets a LOB filename. - * - * @param string $basename Basename of LOB filename to return (if left blank, will choose random file). - * @return string - * @throws Exception - if specified basename doesn't correspond to a registered LOB filename - */ - protected function getLobFile($basename = null) - { - if ($basename === null) { - $basename = array_rand($this->sampleLobFiles); - } + /** + * Gets a LOB filename. + * + * @param string $basename Basename of LOB filename to return (if left blank, will choose random file). + * @return string + * @throws Exception - if specified basename doesn't correspond to a registered LOB filename + */ + protected function getLobFile($basename = null) + { + if ($basename === null) { + $basename = array_rand($this->sampleLobFiles); + } - if (isset($this->sampleLobFiles[$basename])) { - return $this->sampleLobFiles[$basename]; - } else { - throw new Exception("Invalid base LOB filename: $basename"); - } - } + if (isset($this->sampleLobFiles[$basename])) { + return $this->sampleLobFiles[$basename]; + } else { + throw new Exception("Invalid base LOB filename: $basename"); + } + } - /** - * Test the LOB results returned in a resultset. - */ - public function testLobResults() - { + /** + * Test the LOB results returned in a resultset. + */ + public function testLobResults() + { - $blob_path = $this->getLobFile('tin_drum.gif'); - $clob_path = $this->getLobFile('tin_drum.txt'); + $blob_path = $this->getLobFile('tin_drum.gif'); + $clob_path = $this->getLobFile('tin_drum.txt'); - $book = BookPeer::doSelectOne(new Criteria()); + $book = BookPeer::doSelectOne(new Criteria()); - $m1 = new Media(); - $m1->setBook($book); - $m1->setCoverImage(file_get_contents($blob_path)); - $m1->setExcerpt(file_get_contents($clob_path)); - $m1->save(); - $m1_id = $m1->getId(); + $m1 = new Media(); + $m1->setBook($book); + $m1->setCoverImage(file_get_contents($blob_path)); + $m1->setExcerpt(file_get_contents($clob_path)); + $m1->save(); + $m1_id = $m1->getId(); - $m1->reload(); + $m1->reload(); - $img = $m1->getCoverImage(); - $txt = $m1->getExcerpt(); + $img = $m1->getCoverImage(); + $txt = $m1->getExcerpt(); - $this->assertType('resource', $img, "Expected results of BLOB method to be a resource."); - $this->assertType('string', $txt, "Expected results of CLOB method to be a string."); + $this->assertInternalType('resource', $img, "Expected results of BLOB method to be a resource."); + $this->assertInternalType('string', $txt, "Expected results of CLOB method to be a string."); - $stat = fstat($img); - $size = $stat['size']; + $stat = fstat($img); + $size = $stat['size']; - $this->assertEquals(filesize($blob_path), $size, "Expected filesize to match stat(blobrsc)"); - $this->assertEquals(filesize($clob_path), strlen($txt), "Expected filesize to match clob strlen"); - } + $this->assertEquals(filesize($blob_path), $size, "Expected filesize to match stat(blobrsc)"); + $this->assertEquals(filesize($clob_path), strlen($txt), "Expected filesize to match clob strlen"); + } - /** - * Test to make sure that file pointer is not when it is fetched - * from the object. - * - * This is actually a test for correct behavior and does not completely fix - * the associated ticket (which was resolved wontfix). - * - * This does test the rewind-after-save functionality, however. - * - * @link http://propel.phpdb.org/trac/ticket/531 - */ - public function testLobRepeatRead() - { - $blob_path = $this->getLobFile('tin_drum.gif'); - $clob_path = $this->getLobFile('tin_drum.txt'); + /** + * Test to make sure that file pointer is not when it is fetched + * from the object. + * + * This is actually a test for correct behavior and does not completely fix + * the associated ticket (which was resolved wontfix). + * + * This does test the rewind-after-save functionality, however. + * + * @link http://trac.propelorm.org/ticket/531 + */ + public function testLobRepeatRead() + { + $blob_path = $this->getLobFile('tin_drum.gif'); + $clob_path = $this->getLobFile('tin_drum.txt'); - $book = BookPeer::doSelectOne(new Criteria()); + $book = BookPeer::doSelectOne(new Criteria()); - $m1 = new Media(); - $m1->setBook($book); - $m1->setCoverImage(file_get_contents($blob_path)); - $m1->setExcerpt(file_get_contents($clob_path)); - $m1->save(); + $m1 = new Media(); + $m1->setBook($book); + $m1->setCoverImage(file_get_contents($blob_path)); + $m1->setExcerpt(file_get_contents($clob_path)); + $m1->save(); - $img = $m1->getCoverImage(); + $img = $m1->getCoverImage(); - // 1) Assert that this resource has been rewound. + // 1) Assert that this resource has been rewound. - $this->assertEquals(0, ftell($img), "Expected position of cursor in file pointer to be 0"); + $this->assertEquals(0, ftell($img), "Expected position of cursor in file pointer to be 0"); - // 1) Assert that we've got a valid stream to start with + // 1) Assert that we've got a valid stream to start with - $this->assertType('resource', $img, "Expected results of BLOB method to be a resource."); + $this->assertInternalType('resource', $img, "Expected results of BLOB method to be a resource."); - // read first 100 bytes - $firstBytes = fread($img, 100); + // read first 100 bytes + $firstBytes = fread($img, 100); - $img2 = $m1->getCoverImage(); - $this->assertSame($img, $img2, "Assert that the two resources are the same."); + $img2 = $m1->getCoverImage(); + $this->assertSame($img, $img2, "Assert that the two resources are the same."); - // read next 100 bytes - $nextBytes = fread($img, 100); + // read next 100 bytes + $nextBytes = fread($img, 100); - $this->assertNotEquals(bin2hex($firstBytes), bin2hex($nextBytes), "Expected the first 100 and next 100 bytes to not be identical."); - } + $this->assertNotEquals(bin2hex($firstBytes), bin2hex($nextBytes), "Expected the first 100 and next 100 bytes to not be identical."); + } - /** - * Tests the setting of null LOBs - */ - public function testLobNulls() - { - $book = BookPeer::doSelectOne(new Criteria()); + /** + * Tests the setting of null LOBs + */ + public function testLobNulls() + { + $book = BookPeer::doSelectOne(new Criteria()); - $m1 = new Media(); - $m1->setBook($book); - $this->assertTrue($m1->getCoverImage() === null, "Initial LOB value for a new object should be null."); + $m1 = new Media(); + $m1->setBook($book); + $this->assertTrue($m1->getCoverImage() === null, "Initial LOB value for a new object should be null."); - $m1->save(); - $m1_id = $m1->getId(); + $m1->save(); + $m1_id = $m1->getId(); - $m2 = new Media(); - $m2->setBook($book); - $m2->setCoverImage(null); - $this->assertTrue($m2->getCoverImage() === null, "Setting a LOB to null should cause accessor to return null."); + $m2 = new Media(); + $m2->setBook($book); + $m2->setCoverImage(null); + $this->assertTrue($m2->getCoverImage() === null, "Setting a LOB to null should cause accessor to return null."); - $m2->save(); - $m2_id = $m2->getId(); + $m2->save(); + $m2_id = $m2->getId(); - $m1->reload(); - $this->assertTrue($m1->getCoverImage() === null, "Default null LOB value should be null after a reload."); + $m1->reload(); + $this->assertTrue($m1->getCoverImage() === null, "Default null LOB value should be null after a reload."); - $m2->reload(); - $this->assertTrue($m2->getCoverImage() === null, "LOB value set to null should be null after a reload."); - } + $m2->reload(); + $this->assertTrue($m2->getCoverImage() === null, "LOB value set to null should be null after a reload."); + } - /** - * Tests the setting of LOB (BLOB and CLOB) values. - */ - public function testLobSetting() - { - $blob_path = $this->getLobFile('tin_drum.gif'); - $blob2_path = $this->getLobFile('propel.gif'); + /** + * Tests the setting of LOB (BLOB and CLOB) values. + */ + public function testLobSetting() + { + $blob_path = $this->getLobFile('tin_drum.gif'); + $blob2_path = $this->getLobFile('propel.gif'); - $clob_path = $this->getLobFile('tin_drum.txt'); - $book = BookPeer::doSelectOne(new Criteria()); + $clob_path = $this->getLobFile('tin_drum.txt'); + $book = BookPeer::doSelectOne(new Criteria()); - $m1 = new Media(); - $m1->setBook($book); - $m1->setCoverImage(file_get_contents($blob_path)); - $m1->setExcerpt(file_get_contents($clob_path)); - $m1->save(); - $m1_id = $m1->getId(); + $m1 = new Media(); + $m1->setBook($book); + $m1->setCoverImage(file_get_contents($blob_path)); + $m1->setExcerpt(file_get_contents($clob_path)); + $m1->save(); + $m1_id = $m1->getId(); - // 1) Assert that we've got a valid stream to start with - $img = $m1->getCoverImage(); - $this->assertType('resource', $img, "Expected results of BLOB method to be a resource."); + // 1) Assert that we've got a valid stream to start with + $img = $m1->getCoverImage(); + $this->assertInternalType('resource', $img, "Expected results of BLOB method to be a resource."); - // 2) Test setting a BLOB column with file contents - $m1->setCoverImage(file_get_contents($blob2_path)); - $this->assertType('resource', $m1->getCoverImage(), "Expected to get a resource back after setting BLOB with file contents."); + // 2) Test setting a BLOB column with file contents + $m1->setCoverImage(file_get_contents($blob2_path)); + $this->assertInternalType('resource', $m1->getCoverImage(), "Expected to get a resource back after setting BLOB with file contents."); - // commit those changes & reload - $m1->save(); + // commit those changes & reload + $m1->save(); - // 3) Verify that we've got a valid resource after reload - $m1->reload(); - $this->assertType('resource', $m1->getCoverImage(), "Expected to get a resource back after setting reloading object."); + // 3) Verify that we've got a valid resource after reload + $m1->reload(); + $this->assertInternalType('resource', $m1->getCoverImage(), "Expected to get a resource back after setting reloading object."); - // 4) Test isModified() behavior - $fp = fopen("php://temp", "r+"); - fwrite($fp, file_get_contents($blob2_path)); + // 4) Test isModified() behavior + $fp = fopen("php://temp", "r+"); + fwrite($fp, file_get_contents($blob2_path)); - $m1->setCoverImage($fp); - $this->assertTrue($m1->isModified(), "Expected Media object to be modified, despite fact that stream is to same data"); + $m1->setCoverImage($fp); + $this->assertTrue($m1->isModified(), "Expected Media object to be modified, despite fact that stream is to same data"); - // 5) Test external modification of the stream (and re-setting it into the object) - $stream = $m1->getCoverImage(); - fwrite($stream, file_get_contents($blob_path)); // change the contents of the stream + // 5) Test external modification of the stream (and re-setting it into the object) + $stream = $m1->getCoverImage(); + fwrite($stream, file_get_contents($blob_path)); // change the contents of the stream - $m1->setCoverImage($stream); + $m1->setCoverImage($stream); - $this->assertTrue($m1->isModified(), "Expected Media object to be modified when stream contents changed."); - $this->assertNotEquals(file_get_contents($blob2_path), stream_get_contents($m1->getCoverImage())); + $this->assertTrue($m1->isModified(), "Expected Media object to be modified when stream contents changed."); + $this->assertNotEquals(file_get_contents($blob2_path), stream_get_contents($m1->getCoverImage())); - $m1->save(); + $m1->save(); - // 6) Assert that when we call the setter with a stream, that the file in db gets updated. + // 6) Assert that when we call the setter with a stream, that the file in db gets updated. - $m1->reload(); // start with a fresh copy from db + $m1->reload(); // start with a fresh copy from db - // Ensure that object is set up correctly - $this->assertNotEquals(file_get_contents($blob_path), stream_get_contents($m1->getCoverImage()), "The object is not correctly set up to verify the stream-setting test."); + // Ensure that object is set up correctly + $this->assertNotEquals(file_get_contents($blob_path), stream_get_contents($m1->getCoverImage()), "The object is not correctly set up to verify the stream-setting test."); - $fp = fopen($blob_path, "r"); - $m1->setCoverImage($fp); - $m1->save(); - $m1->reload(); // refresh from db + $fp = fopen($blob_path, "r"); + $m1->setCoverImage($fp); + $m1->save(); + $m1->reload(); // refresh from db - // Assert that we've updated the db - $this->assertEquals(file_get_contents($blob_path), stream_get_contents($m1->getCoverImage()), "Expected the updated BLOB value after setting with a stream."); + // Assert that we've updated the db + $this->assertEquals(md5(file_get_contents($blob_path)), md5(stream_get_contents($m1->getCoverImage())), "Expected the updated BLOB value after setting with a stream."); - // 7) Assert that 'w' mode works + // 7) Assert that 'w' mode works - } + } - public function testLobSetting_WriteMode() - { - $blob_path = $this->getLobFile('tin_drum.gif'); - $blob2_path = $this->getLobFile('propel.gif'); + public function testLobSetting_WriteMode() + { + $blob_path = $this->getLobFile('tin_drum.gif'); + $blob2_path = $this->getLobFile('propel.gif'); - $clob_path = $this->getLobFile('tin_drum.txt'); - $book = BookPeer::doSelectOne(new Criteria()); + $clob_path = $this->getLobFile('tin_drum.txt'); + $book = BookPeer::doSelectOne(new Criteria()); - $m1 = new Media(); - $m1->setBook($book); - $m1->setCoverImage(file_get_contents($blob_path)); - $m1->setExcerpt(file_get_contents($clob_path)); - $m1->save(); + $m1 = new Media(); + $m1->setBook($book); + $m1->setCoverImage(file_get_contents($blob_path)); + $m1->setExcerpt(file_get_contents($clob_path)); + $m1->save(); - MediaPeer::clearInstancePool(); + MediaPeer::clearInstancePool(); - // make sure we have the latest from the db: - $m2 = MediaPeer::retrieveByPK($m1->getId()); + // make sure we have the latest from the db: + $m2 = MediaPeer::retrieveByPK($m1->getId()); - // now attempt to assign a temporary stream, opened in 'w' mode, to the db + // now attempt to assign a temporary stream, opened in 'w' mode, to the db - $stream = fopen("php://memory", 'w'); - fwrite($stream, file_get_contents($blob2_path)); - $m2->setCoverImage($stream); - $m2->save(); - fclose($stream); + $stream = fopen("php://memory", 'w'); + fwrite($stream, file_get_contents($blob2_path)); + $m2->setCoverImage($stream); + $m2->save(); + fclose($stream); - $m2->reload(); - $this->assertEquals(file_get_contents($blob2_path), stream_get_contents($m2->getCoverImage()), "Expected contents to match when setting stream w/ 'w' mode"); + $m2->reload(); + $this->assertEquals(md5(file_get_contents($blob2_path)), md5(stream_get_contents($m2->getCoverImage())), "Expected contents to match when setting stream w/ 'w' mode"); - $stream2 = fopen("php://memory", 'w+'); - fwrite($stream2, file_get_contents($blob_path)); - rewind($stream2); - $this->assertEquals(file_get_contents($blob_path), stream_get_contents($stream2), "Expecting setup to be correct"); + $stream2 = fopen("php://memory", 'w+'); + fwrite($stream2, file_get_contents($blob_path)); + rewind($stream2); + $this->assertEquals(md5(file_get_contents($blob_path)), md5(stream_get_contents($stream2)), "Expecting setup to be correct"); - $m2->setCoverImage($stream2); - $m2->save(); - $m2->reload(); + $m2->setCoverImage($stream2); + $m2->save(); + $m2->reload(); - $this->assertEquals(file_get_contents($blob_path), stream_get_contents($m2->getCoverImage()), "Expected contents to match when setting stream w/ 'w+' mode"); + $this->assertEquals(md5(file_get_contents($blob_path)), md5(stream_get_contents($m2->getCoverImage())), "Expected contents to match when setting stream w/ 'w+' mode"); - } + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectMoreRelationTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectMoreRelationTest.php new file mode 100644 index 000000000..a6c0935a0 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectMoreRelationTest.php @@ -0,0 +1,236 @@ + + + + + +
+ + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+ + +EOF; + + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $builder->build(); + } + + \MoreRelationTest\ContentCommentPeer::doDeleteAll(); + \MoreRelationTest\ContentPeer::doDeleteAll(); + \MoreRelationTest\CommentPeer::doDeleteAll(); + \MoreRelationTest\PagePeer::doDeleteAll(); + + for ($i=1;$i<=2;$i++) { + + $page = new \MoreRelationTest\Page(); + + $page->setTitle('Page '.$i); + for ($j=1;$j<=3;$j++) { + + $content = new \MoreRelationTest\Content(); + $content->setTitle('Content '.$j); + $content->setContent(str_repeat('Content', $j)); + $page->addContent($content); + + $comment = new \MoreRelationTest\Comment(); + $comment->setUserId($j); + $comment->setComment(str_repeat('Comment', $j)); + $page->addComment($comment); + + $comment = new \MoreRelationTest\ContentComment(); + $comment->setContentId($i*$j); + $comment->setComment(str_repeat('Comment-'.$j.', ', $j)); + $content->addContentComment($comment); + + } + + $page->save(); + } + + } + + /** + * Composite PK deletion of a 1-to-n relation through set() and remove() + * where the PK is at the same time a FK. + */ + public function testCommentsDeletion() + { + $commentCollection = new PropelObjectCollection(); + $commentCollection->setModel('MoreRelationTest\\Comment'); + + $comment = new \MoreRelationTest\Comment(); + $comment->setComment('I should be alone :-('); + $comment->setUserId(123); + + $commentCollection[] = $comment; + + $page = \MoreRelationTest\PageQuery::create()->findOne(); + $id = $page->getId(); + + $count = \MoreRelationTest\CommentQuery::create()->filterByPageId($id)->count(); + $this->assertEquals(3, $count, 'We created for each page 3 comments.'); + + $page->setComments($commentCollection); + $page->save(); + + $count = \MoreRelationTest\CommentQuery::create()->filterByPageId($id)->count(); + $this->assertEquals(1, $count, 'We assigned a collection of only one item.'); + + $count = \MoreRelationTest\CommentQuery::create()->filterByPageId(NULL)->count(); + $this->assertEquals(0, $count, 'There should be no unassigned comment.'); + + $page->removeComment($comment); + $page->save(); + + $count = \MoreRelationTest\CommentQuery::create()->filterByPageId($id)->count(); + $this->assertEquals(0, $count, 'We assigned a collection of only one item.'); + + $count = \MoreRelationTest\CommentQuery::create()->filterByPageId(NULL)->count(); + $this->assertEquals(0, $count, 'There should be no unassigned comment.'); + + } + + /** + * Deletion of a 1-to-n relation through set() + * with onDelete=setnull + */ + public function testContentCommentDeletion() + { + $commentCollection = new PropelObjectCollection(); + $commentCollection->setModel('MoreRelationTest\\ContentComment'); + + $comment = new \MoreRelationTest\ContentComment(); + $comment->setComment('I\'m Mario'); + $commentCollection[] = $comment; + + $comment2 = new \MoreRelationTest\ContentComment(); + $comment2->setComment('I\'m Mario\'s friend'); + $commentCollection[] = $comment2; + + $content = \MoreRelationTest\ContentQuery::create()->findOne(); + $id = $content->getId(); + + $count = \MoreRelationTest\ContentCommentQuery::create()->filterByContentId($id)->count(); + $this->assertEquals(1, $count, 'We created for each page 1 comments.'); + + $content->setContentComments($commentCollection); + $content->save(); + + unset($content); + + $count = \MoreRelationTest\ContentCommentQuery::create()->filterByContentId($id)->count(); + $this->assertEquals(2, $count, 'We assigned a collection of two items.'); + + $count = \MoreRelationTest\ContentCommentQuery::create()->filterByContentId(NULL)->count(); + $this->assertEquals(1, $count, 'There should be one unassigned contentComment.'); + + } + + /** + * Basic deletion of a 1-to-n relation through set(). + * + */ + public function testContentsDeletion() + { + $contentCollection = new PropelObjectCollection(); + $contentCollection->setModel('MoreRelationTest\\Content'); + + $content = new \MoreRelationTest\Content(); + $content->setTitle('I should be alone :-('); + + $contentCollection[] = $content; + + $page = \MoreRelationTest\PageQuery::create()->findOne(); + $id = $page->getId(); + + $count = \MoreRelationTest\ContentQuery::create()->filterByPageId($id)->count(); + $this->assertEquals(3, $count, 'We created for each page 3 contents.'); + + $page->setContents($contentCollection); + $page->save(); + + unset($page); + + $count = \MoreRelationTest\ContentQuery::create()->filterByPageId($id)->count(); + $this->assertEquals(1, $count, 'We assigned a collection of only one item.'); + + } + + public function testOnDeleteCascadeNotRequired() + { + \MoreRelationTest\PagePeer::doDeleteAll(); + \MoreRelationTest\ContentPeer::doDeleteAll(); + + $page = new \MoreRelationTest\Page(); + $page->setTitle('Some important Page'); + + $content = new \MoreRelationTest\Content(); + $content->setTitle('Content'); + + $page->addContent($content); + $page->save(); + + $this->assertEquals(1, \MoreRelationTest\ContentQuery::create()->count()); + + $page->removeContent($content); + $page->save(); + + $this->assertEquals(0, \MoreRelationTest\ContentQuery::create()->count()); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectObjectColumnTypeTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectObjectColumnTypeTest.php new file mode 100644 index 000000000..e69490520 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectObjectColumnTypeTest.php @@ -0,0 +1,84 @@ + + + + +
+ +EOF; + PropelQuickBuilder::buildSchema($schema); + } + } + + public function testObjectColumnType() + { + $e = new ComplexColumnTypeEntity1(); + $this->assertNull($e->getBar(), 'object columns are null by default'); + $c = new FooColumnValue(); + $c->bar = 1234; + $e->setBar($c); + $this->assertEquals($c, $e->getBar(), 'object columns can store objects'); + $e->setBar(null); + $this->assertNull($e->getBar(), 'object columns are nullable'); + $e->setBar($c); + $e->save(); + ComplexColumnTypeEntity1Peer::clearInstancePool(); + $e = ComplexColumnTypeEntity1Query::create()->findOne(); + $this->assertEquals($c, $e->getBar(), 'object columns are persisted'); + } + + public function testGetterDoesNotKeepValueBetweenTwoHydrationsWhenUsingOnDemandFormatter() + { + ComplexColumnTypeEntity1Query::create()->deleteAll(); + $e = new ComplexColumnTypeEntity1(); + $e->setBar(array( + 'a' => 1, + 'b' => 2 + )); + $e->save(); + $e = new ComplexColumnTypeEntity1(); + $e->setBar(array( + 'a' => 3, + 'b' => 4 + )); + $e->save(); + $q = ComplexColumnTypeEntity1Query::create() + ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND) + ->find(); + + $objects = array(); + foreach ($q as $e) { + $objects[] = $e->getBar(); + } + $this->assertNotEquals($objects[0], $objects[1]); + } +} + +class FooColumnValue +{ + public $bar; +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectPhpNameTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectPhpNameTest.php new file mode 100644 index 000000000..f2a22d85d --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectPhpNameTest.php @@ -0,0 +1,83 @@ + + * @package generator.builder.om + */ +class GeneratedObjectPhpNameTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + parent::setUp(); + + if (!class_exists('PhpNameTest\Page')) { + $schema = << + + + +
+ + + + +
+ + + + + + + + + + + +
+ +XML; + + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $builder->build(); + } + + // Clear existing data, if any. + \PhpNameTest\PagePeer::doDeleteAll(); + \PhpNameTest\AuthorPeer::doDeleteAll(); + \PhpNameTest\AuthorPagePeer::doDeleteAll(); + } + + public function testDeleteWorksWithRefPhpName() + { + $author = new \PhpNameTest\Author(); + $author->setName('Really Important'); + $author->save(); + + $anotherAuthor = new \PhpNameTest\Author(); + $anotherAuthor->setName('Not S. Important'); + $anotherAuthor->save(); + + $page = new \PhpNameTest\Page(); + $page->setTitle('Awesomeness at its finest'); + $page->save(); + + $page->addAuthor($author); + $page->addAuthor($anotherAuthor); + $page->save(); + + // Should not result in "Fatal error: Class 'PhpNameTest\om\WriterQuery' not found" + $page->removeAuthor($author); + $page->save(); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectRelTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectRelTest.php index 465545560..2bd9f39f5 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectRelTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectRelTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Tests relationships between generated Object classes. @@ -17,7 +17,7 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; * object operations. The _idea_ here is to test every possible generated method * from Object.tpl; if necessary, bookstore will be expanded to accommodate this. * - * The database is relaoded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same * for each test method in this class. See the BookstoreDataPopulator::populate() * method for the exact contents of the database. @@ -29,324 +29,972 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; class GeneratedObjectRelTest extends BookstoreEmptyTestBase { - protected function setUp() - { - parent::setUp(); - } + protected function setUp() + { + parent::setUp(); + } - /** - * Tests one side of a bi-directional setting of many-to-many relationships. - */ - public function testManyToMany_Dir1() - { - $list = new BookClubList(); - $list->setGroupLeader('Archimedes Q. Porter'); - // No save ... + /** + * Tests one side of a bi-directional setting of many-to-many relationships. + */ + public function testManyToMany_Dir1() + { + $list = new BookClubList(); + $list->setGroupLeader('Archimedes Q. Porter'); + // No save ... - $book = new Book(); - $book->setTitle( "Jungle Expedition Handbook" ); - $book->setISBN('TEST'); - // No save ... + $book = new Book(); + $book->setTitle( "Jungle Expedition Handbook" ); + $book->setIsbn('TEST'); + // No save ... - $this->assertEquals(0, count($list->getBookListRels()) ); - $this->assertEquals(0, count($book->getBookListRels()) ); - $this->assertEquals(0, count(BookListRelPeer::doSelect(new Criteria())) ); + $this->assertEquals(0, count($list->getBookListRels()) ); + $this->assertEquals(0, count($book->getBookListRels()) ); + $this->assertEquals(0, count(BookListRelPeer::doSelect(new Criteria())) ); - $xref = new BookListRel(); - $xref->setBook($book); - $list->addBookListRel($xref); + $xref = new BookListRel(); + $xref->setBook($book); + $list->addBookListRel($xref); - $this->assertEquals(1, count($list->getBookListRels())); - $this->assertEquals(1, count($book->getBookListRels()) ); - $this->assertEquals(0, count(BookListRelPeer::doSelect(new Criteria())) ); + $this->assertEquals(1, count($list->getBookListRels())); + $this->assertEquals(1, count($book->getBookListRels()) ); + $this->assertEquals(0, count(BookListRelPeer::doSelect(new Criteria())) ); - $list->save(); + $list->save(); - $this->assertEquals(1, count($list->getBookListRels()) ); - $this->assertEquals(1, count($book->getBookListRels()) ); - $this->assertEquals(1, count(BookListRelPeer::doSelect(new Criteria())) ); + $this->assertEquals(1, count($list->getBookListRels()) ); + $this->assertEquals(1, count($book->getBookListRels()) ); + $this->assertEquals(1, count(BookListRelPeer::doSelect(new Criteria())) ); - } + } - /** - * Tests reverse setting of one of many-to-many relationship, with all saves cascaded. - */ - public function testManyToMany_Dir2_Unsaved() - { - $list = new BookClubList(); - $list->setGroupLeader('Archimedes Q. Porter'); - // No save ... + /** + * Tests reverse setting of one of many-to-many relationship, with all saves cascaded. + */ + public function testManyToMany_Dir2_Unsaved() + { + $list = new BookClubList(); + $list->setGroupLeader('Archimedes Q. Porter'); + // No save ... - $book = new Book(); - $book->setTitle( "Jungle Expedition Handbook" ); - $book->setISBN('TEST'); - // No save (yet) ... + $book = new Book(); + $book->setTitle( "Jungle Expedition Handbook" ); + $book->setIsbn('TEST'); + // No save (yet) ... - $this->assertEquals(0, count($list->getBookListRels()) ); - $this->assertEquals(0, count($book->getBookListRels()) ); - $this->assertEquals(0, count(BookListRelPeer::doSelect(new Criteria())) ); + $this->assertEquals(0, count($list->getBookListRels()) ); + $this->assertEquals(0, count($book->getBookListRels()) ); + $this->assertEquals(0, count(BookListRelPeer::doSelect(new Criteria())) ); - $xref = new BookListRel(); - $xref->setBookClubList($list); - $book->addBookListRel($xref); + $xref = new BookListRel(); + $xref->setBookClubList($list); + $book->addBookListRel($xref); - $this->assertEquals(1, count($list->getBookListRels()) ); - $this->assertEquals(1, count($book->getBookListRels()) ); - $this->assertEquals(0, count(BookListRelPeer::doSelect(new Criteria())) ); - $book->save(); + $this->assertEquals(1, count($list->getBookListRels()) ); + $this->assertEquals(1, count($book->getBookListRels()) ); + $this->assertEquals(0, count(BookListRelPeer::doSelect(new Criteria())) ); + $book->save(); - $this->assertEquals(1, count($list->getBookListRels()) ); - $this->assertEquals(1, count($book->getBookListRels()) ); - $this->assertEquals(1, count(BookListRelPeer::doSelect(new Criteria())) ); + $this->assertEquals(1, count($list->getBookListRels()) ); + $this->assertEquals(1, count($book->getBookListRels()) ); + $this->assertEquals(1, count(BookListRelPeer::doSelect(new Criteria())) ); - } + } - /** - * Tests reverse setting of relationships, saving one of the objects first. - * @link http://propel.phpdb.org/trac/ticket/508 - */ - public function testManyToMany_Dir2_Saved() - { - $list = new BookClubList(); - $list->setGroupLeader('Archimedes Q. Porter'); - $list->save(); + /** + * Tests reverse setting of relationships, saving one of the objects first. + * @link http://trac.propelorm.org/ticket/508 + */ + public function testManyToMany_Dir2_Saved() + { + $list = new BookClubList(); + $list->setGroupLeader('Archimedes Q. Porter'); + $list->save(); - $book = new Book(); - $book->setTitle( "Jungle Expedition Handbook" ); - $book->setISBN('TEST'); - // No save (yet) ... + $book = new Book(); + $book->setTitle( "Jungle Expedition Handbook" ); + $book->setIsbn('TEST'); + // No save (yet) ... - $this->assertEquals(0, count($list->getBookListRels()) ); - $this->assertEquals(0, count($book->getBookListRels()) ); - $this->assertEquals(0, count(BookListRelPeer::doSelect(new Criteria())) ); + $this->assertEquals(0, count($list->getBookListRels()) ); + $this->assertEquals(0, count($book->getBookListRels()) ); + $this->assertEquals(0, count(BookListRelPeer::doSelect(new Criteria())) ); - // Now set the relationship from the opposite direction. + // Now set the relationship from the opposite direction. - $xref = new BookListRel(); - $xref->setBookClubList($list); - $book->addBookListRel($xref); + $xref = new BookListRel(); + $xref->setBookClubList($list); + $book->addBookListRel($xref); - $this->assertEquals(1, count($list->getBookListRels()) ); - $this->assertEquals(1, count($book->getBookListRels()) ); - $this->assertEquals(0, count(BookListRelPeer::doSelect(new Criteria())) ); - $book->save(); + $this->assertEquals(1, count($list->getBookListRels()) ); + $this->assertEquals(1, count($book->getBookListRels()) ); + $this->assertEquals(0, count(BookListRelPeer::doSelect(new Criteria())) ); + $book->save(); - $this->assertEquals(1, count($list->getBookListRels()) ); - $this->assertEquals(1, count($book->getBookListRels()) ); - $this->assertEquals(1, count(BookListRelPeer::doSelect(new Criteria())) ); + $this->assertEquals(1, count($list->getBookListRels()) ); + $this->assertEquals(1, count($book->getBookListRels()) ); + $this->assertEquals(1, count(BookListRelPeer::doSelect(new Criteria())) ); + } - } - - public function testManyToManyGetterExists() - { - $this->assertTrue(method_exists('BookClubList', 'getBooks'), 'Object generator correcly adds getter for the crossRefFk'); - $this->assertFalse(method_exists('BookClubList', 'getBookClubLists'), 'Object generator correcly adds getter for the crossRefFk'); - } - - public function testManyToManyGetterNewObject() - { - $blc1 = new BookClubList(); - $books = $blc1->getBooks(); - $this->assertTrue($books instanceof PropelObjectCollection, 'getCrossRefFK() returns a Propel collection'); - $this->assertEquals('Book', $books->getModel(), 'getCrossRefFK() returns a collection of the correct model'); - $this->assertEquals(0, count($books), 'getCrossRefFK() returns an empty list for new objects'); - $query = BookQuery::create() - ->filterByTitle('Harry Potter and the Order of the Phoenix'); - $books = $blc1->getBooks($query); - $this->assertEquals(0, count($books), 'getCrossRefFK() accepts a query as first parameter'); - } - - public function testManyToManyGetter() - { - BookstoreDataPopulator::populate(); - $blc1 = BookClubListQuery::create()->findOneByGroupLeader('Crazyleggs'); - $books = $blc1->getBooks(); - $this->assertTrue($books instanceof PropelObjectCollection, 'getCrossRefFK() returns a Propel collection'); - $this->assertEquals('Book', $books->getModel(), 'getCrossRefFK() returns a collection of the correct model'); - $this->assertEquals(2, count($books), 'getCrossRefFK() returns the correct list of objects'); - $query = BookQuery::create() - ->filterByTitle('Harry Potter and the Order of the Phoenix'); - $books = $blc1->getBooks($query); - $this->assertEquals(1, count($books), 'getCrossRefFK() accepts a query as first parameter'); - } + public function testManyToManyGetterExists() + { + $this->assertTrue(method_exists('BookClubList', 'getBooks'), 'Object generator correctly adds getter for the crossRefFk'); + $this->assertFalse(method_exists('BookClubList', 'getBookClubLists'), 'Object generator correctly adds getter for the crossRefFk'); + } - public function testManyToManyCounterExists() - { - $this->assertTrue(method_exists('BookClubList', 'countBooks'), 'Object generator correcly adds counter for the crossRefFk'); - $this->assertFalse(method_exists('BookClubList', 'countBookClubLists'), 'Object generator correcly adds counter for the crossRefFk'); - } - - public function testManyToManyCounterNewObject() - { - $blc1 = new BookClubList(); - $nbBooks = $blc1->countBooks(); - $this->assertEquals(0, $nbBooks, 'countCrossRefFK() returns 0 for new objects'); - $query = BookQuery::create() - ->filterByTitle('Harry Potter and the Order of the Phoenix'); - $nbBooks = $blc1->countBooks($query); - $this->assertEquals(0, $nbBooks, 'countCrossRefFK() accepts a query as first parameter'); - } - - public function testManyToManyCounter() - { - BookstoreDataPopulator::populate(); - $blc1 = BookClubListQuery::create()->findOneByGroupLeader('Crazyleggs'); - $nbBooks = $blc1->countBooks(); - $this->assertEquals(2, $nbBooks, 'countCrossRefFK() returns the correct list of objects'); - $query = BookQuery::create() - ->filterByTitle('Harry Potter and the Order of the Phoenix'); - $nbBooks = $blc1->countBooks($query); - $this->assertEquals(1, $nbBooks, 'countCrossRefFK() accepts a query as first parameter'); - } - - public function testManyToManyAdd() - { - $list = new BookClubList(); - $list->setGroupLeader('Archimedes Q. Porter'); + public function testManyToManyGetterNewObject() + { + $blc1 = new BookClubList(); + $books = $blc1->getBooks(); + $this->assertTrue($books instanceof PropelObjectCollection, 'getCrossRefFK() returns a Propel collection'); + $this->assertEquals('Book', $books->getModel(), 'getCrossRefFK() returns a collection of the correct model'); + $this->assertEquals(0, count($books), 'getCrossRefFK() returns an empty list for new objects'); + $query = BookQuery::create() + ->filterByTitle('Harry Potter and the Order of the Phoenix'); + $books = $blc1->getBooks($query); + $this->assertEquals(0, count($books), 'getCrossRefFK() accepts a query as first parameter'); + } - $book = new Book(); - $book->setTitle( "Jungle Expedition Handbook" ); - $book->setISBN('TEST'); - - $list->addBook($book); - $this->assertEquals(1, $list->countBooks(), 'addCrossFk() sets the internal collection properly'); - $this->assertEquals(1, $list->countBookListRels(), 'addCrossFk() sets the internal cross reference collection properly'); - - $list->save(); - $this->assertFalse($book->isNew(), 'related object is saved if added'); - $rels = $list->getBookListRels(); - $rel = $rels[0]; - $this->assertFalse($rel->isNew(), 'cross object is saved if added'); - - $list->clearBookListRels(); - $list->clearBooks(); - $books = $list->getBooks(); - $expected = new PropelObjectCollection(array($book)); - $expected->setModel('Book'); - $this->assertEquals($expected, $books, 'addCrossFk() adds the object properly'); - $this->assertEquals(1, $list->countBookListRels()); - } + public function testManyToManyGetter() + { + BookstoreDataPopulator::populate(); + $blc1 = BookClubListQuery::create()->findOneByGroupLeader('Crazyleggs'); + $books = $blc1->getBooks(); + $this->assertTrue($books instanceof PropelObjectCollection, 'getCrossRefFK() returns a Propel collection'); + $this->assertEquals('Book', $books->getModel(), 'getCrossRefFK() returns a collection of the correct model'); + $this->assertEquals(2, count($books), 'getCrossRefFK() returns the correct list of objects'); + $query = BookQuery::create() + ->filterByTitle('Harry Potter and the Order of the Phoenix'); + $books = $blc1->getBooks($query); + $this->assertEquals(1, count($books), 'getCrossRefFK() accepts a query as first parameter'); + } - - /** - * Test behavior of columns that are implicated in multiple foreign keys. - * @link http://propel.phpdb.org/trac/ticket/228 - */ - public function testMultiFkImplication() - { - BookstoreDataPopulator::populate(); - // Create a new bookstore, contest, bookstore_contest, and bookstore_contest_entry - $b = new Bookstore(); - $b->setStoreName("Foo!"); - $b->save(); + public function testOneToManyGetter() + { + BookstoreDataPopulator::populate(null, true); + $author = AuthorQuery::create()->findOneByLastName('Grass'); + $books = $author->getBooks(new Criteria()); + $this->assertNotNull($books->getCurrent(), 'getRelCol() initialize the internal iterator at the beginning'); + } - $c = new Contest(); - $c->setName("Bookathon Contest"); - $c->save(); + /** + * @group issue677 + */ + public function testManyToManySetterIsNotLoosingAnyReference() + { + $list1 = new BookClubList(); + $list2 = new BookClubList(); + $book = new Book(); - $bc = new BookstoreContest(); - $bc->setBookstore($b); - $bc->setContest($c); - $bc->save(); + $book->addBookClubList($list1); + $book->addBookClubList($list2); - $c = new Customer(); - $c->setName("Happy Customer"); - $c->save(); + $lists = $book->getBookClubLists(); + $this->assertCount(2, $lists, 'setRelCol is losing references to referenced object'); - $bce = new BookstoreContestEntry(); - $bce->setBookstore($b); - $bce->setBookstoreContest($bc); - $bce->setCustomer($c); - $bce->save(); + $rels = $book->getBookListRels(); + $this->assertCount(2, $rels, 'setRelCol is losing references to relation object'); - $bce->setBookstoreId(null); + foreach ($rels as $rel) { + $this->assertNotNull($rel->getBook(), 'setRelCol is losing backreference on set relation to local object'); + $this->assertNotNull($rel->getBookClubList(), 'setRelCol is losing backreference on set relation to referenced object'); + } - $this->assertNull($bce->getBookstoreContest()); - $this->assertNull($bce->getBookstore()); - } + foreach ($lists as $list) { + $this->assertCount(1, $list->getBooks(), 'setRelCol is losing backreference on set objects'); + } + } + public function testManyToManyCounterExists() + { + $this->assertTrue(method_exists('BookClubList', 'countBooks'), 'Object generator correcly adds counter for the crossRefFk'); + $this->assertFalse(method_exists('BookClubList', 'countBookClubLists'), 'Object generator correcly adds counter for the crossRefFk'); + } - /** - * Test the clearing of related object collection. - * @link http://propel.phpdb.org/trac/ticket/529 - */ - public function testClearRefFk() - { - BookstoreDataPopulator::populate(); - $book = new Book(); - $book->setISBN("Foo-bar-baz"); - $book->setTitle("The book title"); + public function testManyToManyCounterNewObject() + { + $blc1 = new BookClubList(); + $nbBooks = $blc1->countBooks(); + $this->assertEquals(0, $nbBooks, 'countCrossRefFK() returns 0 for new objects'); + $query = BookQuery::create() + ->filterByTitle('Harry Potter and the Order of the Phoenix'); + $nbBooks = $blc1->countBooks($query); + $this->assertEquals(0, $nbBooks, 'countCrossRefFK() accepts a query as first parameter'); + } - // No save ... + public function testManyToManyCounter() + { + BookstoreDataPopulator::populate(); + $blc1 = BookClubListQuery::create()->findOneByGroupLeader('Crazyleggs'); + $nbBooks = $blc1->countBooks(); + $this->assertEquals(2, $nbBooks, 'countCrossRefFK() returns the correct list of objects'); + $query = BookQuery::create() + ->filterByTitle('Harry Potter and the Order of the Phoenix'); + $nbBooks = $blc1->countBooks($query); + $this->assertEquals(1, $nbBooks, 'countCrossRefFK() accepts a query as first parameter'); + } - $r = new Review(); - $r->setReviewedBy('Me'); - $r->setReviewDate(new DateTime("now")); + public function testManyToManyAdd() + { + $list = new BookClubList(); + $list->setGroupLeader('Archimedes Q. Porter'); - $book->addReview($r); + $book = new Book(); + $book->setTitle( "Jungle Expedition Handbook" ); + $book->setIsbn('TEST'); - // No save (yet) ... + $list->addBook($book); + $this->assertEquals(1, $list->countBooks(), 'addCrossFk() sets the internal collection properly'); + $this->assertEquals(1, $list->countBookListRels(), 'addCrossFk() sets the internal cross reference collection properly'); - $this->assertEquals(1, count($book->getReviews()) ); - $book->clearReviews(); - $this->assertEquals(0, count($book->getReviews())); - } + $list->save(); + $this->assertFalse($book->isNew(), 'related object is saved if added'); + $rels = $list->getBookListRels(); + $rel = $rels[0]; + $this->assertFalse($rel->isNew(), 'cross object is saved if added'); - /** - * This tests to see whether modified objects are being silently overwritten by calls to fk accessor methods. - * @link http://propel.phpdb.org/trac/ticket/509#comment:5 - */ - public function testModifiedObjectOverwrite() - { - BookstoreDataPopulator::populate(); - $author = new Author(); - $author->setFirstName("John"); - $author->setLastName("Public"); + $list->clearBookListRels(); + $list->clearBooks(); + $books = $list->getBooks(); + $expected = new PropelObjectCollection(array($book)); + $expected->setModel('Book'); + $this->assertEquals($expected, $books, 'addCrossFk() adds the object properly'); + $this->assertEquals(1, $list->countBookListRels()); + } - $books = $author->getBooks(); // empty, of course - $this->assertEquals(0, count($books), "Expected empty collection."); + /** + * Test behavior of columns that are implicated in multiple foreign keys. + * @link http://trac.propelorm.org/ticket/228 + */ + public function testMultiFkImplication() + { + BookstoreDataPopulator::populate(); + // Create a new bookstore, contest, bookstore_contest, and bookstore_contest_entry + $b = new Bookstore(); + $b->setStoreName("Foo!"); + $b->save(); - $book = new Book(); - $book->setTitle("A sample book"); - $book->setISBN("INITIAL ISBN"); + $c = new Contest(); + $c->setName("Bookathon Contest"); + $c->save(); - $author->addBook($book); + $bc = new BookstoreContest(); + $bc->setBookstore($b); + $bc->setContest($c); + $bc->save(); - $author->save(); + $c = new Customer(); + $c->setName("Happy Customer"); + $c->save(); - $book->setISBN("MODIFIED ISBN"); + $bce = new BookstoreContestEntry(); + $bce->setBookstore($b); + $bce->setBookstoreContest($bc); + $bce->setCustomer($c); + $bce->save(); - $books = $author->getBooks(); - $this->assertEquals(1, count($books), "Expected 1 book."); - $this->assertSame($book, $books[0], "Expected the same object to be returned by fk accessor."); - $this->assertEquals("MODIFIED ISBN", $books[0]->getISBN(), "Expected the modified value NOT to have been overwritten."); - } + $bce->setBookstoreId(null); - public function testFKGetterUseInstancePool() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $author = AuthorPeer::doSelectOne(new Criteria(), $con); - // populate book instance pool - $books = $author->getBooks(null, $con); - $sql = $con->getLastExecutedQuery(); - $author = $books[0]->getAuthor($con); - $this->assertEquals($sql, $con->getLastExecutedQuery(), 'refFK getter uses instance pool if possible'); - } - - public function testRefFKGetJoin() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - PublisherPeer::clearInstancePool(); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $author = AuthorPeer::doSelectOne(new Criteria(), $con); - // populate book instance pool - $books = $author->getBooksJoinPublisher(null, $con); - $sql = $con->getLastExecutedQuery(); - $publisher = $books[0]->getPublisher($con); - $this->assertEquals($sql, $con->getLastExecutedQuery(), 'refFK getter uses instance pool if possible'); - } + $this->assertNull($bce->getBookstoreContest()); + $this->assertNull($bce->getBookstore()); + } + + /** + * Test the clearing of related object collection. + * @link http://www.propelorm.org/ticket/529 + */ + public function testClearRefFk() + { + BookstoreDataPopulator::populate(); + $book = new Book(); + $book->setIsbn("Foo-bar-baz"); + $book->setTitle("The book title"); + + // No save ... + + $r = new Review(); + $r->setReviewedBy('Me'); + $r->setReviewDate(new DateTime("now")); + + $book->addReview($r); + + // No save (yet) ... + + $this->assertEquals(1, count($book->getReviews()) ); + $book->clearReviews(); + $this->assertEquals(0, count($book->getReviews())); + } + + /** + * Test the clearing of related object collection via a many-to-many association. + * @link http://www.propelorm.org/ticket/1374 + */ + public function testClearCrossFk() + { + $book = new Book(); + $bookClub = new BookClubList(); + $book->addBookClubList($bookClub); + $this->assertEquals(1, count($book->getBookClubLists())); + $book->clear(); + $this->assertEquals(0, count($book->getBookClubLists())); + } + + /** + * This tests to see whether modified objects are being silently overwritten by calls to fk accessor methods. + * @link http://trac.propelorm.org/ticket/509#comment:5 + */ + public function testModifiedObjectOverwrite() + { + BookstoreDataPopulator::populate(); + $author = new Author(); + $author->setFirstName("John"); + $author->setLastName("Public"); + + $books = $author->getBooks(); // empty, of course + $this->assertEquals(0, count($books), "Expected empty collection."); + + $book = new Book(); + $book->setTitle("A sample book"); + $book->setIsbn("INITIAL ISBN"); + + $author->addBook($book); + + $author->save(); + + $book->setIsbn("MODIFIED ISBN"); + + $books = $author->getBooks(); + $this->assertEquals(1, count($books), "Expected 1 book."); + $this->assertSame($book, $books[0], "Expected the same object to be returned by fk accessor."); + $this->assertEquals("MODIFIED ISBN", $books[0]->getISBN(), "Expected the modified value NOT to have been overwritten."); + } + + public function testFKGetterUseInstancePool() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $author = AuthorPeer::doSelectOne(new Criteria(), $con); + // populate book instance pool + $books = $author->getBooks(null, $con); + $sql = $con->getLastExecutedQuery(); + $author = $books[0]->getAuthor($con); + $this->assertEquals($sql, $con->getLastExecutedQuery(), 'refFK getter uses instance pool if possible'); + } + + public function testRefFKGetJoin() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + PublisherPeer::clearInstancePool(); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $author = AuthorPeer::doSelectOne(new Criteria(), $con); + // populate book instance pool + $books = $author->getBooksJoinPublisher(null, $con); + $sql = $con->getLastExecutedQuery(); + $publisher = $books[0]->getPublisher($con); + $this->assertEquals($sql, $con->getLastExecutedQuery(), 'refFK getter uses instance pool if possible'); + } + + public function testRefFKAddReturnsCurrentObject() + { + $author = new Author(); + $author->setFirstName('Leo'); + $ret = $author->addBook(new Book()); + $this->assertSame($author, $ret); + } + + public function testSetterCollection() + { + // Ensure no data + BookQuery::create()->deleteAll(); + BookClubListQuery::create()->deleteAll(); + BookListRelQuery::create()->deleteAll(); + + $books = new PropelObjectCollection(); + for ($i = 0; $i < 10; $i++) { + $b = new Book(); + $b->setTitle('My Book ' . $i); + $b->setIsbn($i); + + $books[] = $b; + } + $this->assertEquals(10, $books->count()); + + // Basic usage + $bookClubList1 = new BookClubList(); + $bookClubList1->setGroupLeader('BookClubList1 Leader'); + $bookClubList1->setBooks($books); + $bookClubList1->save(); + + $this->assertEquals(10, $bookClubList1->getBooks()->count()); + $this->assertEquals(1, BookClubListQuery::create()->count()); + $this->assertEquals(10, BookQuery::create()->count()); + $this->assertEquals(10, BookListRelQuery::create()->count()); + + $i = 0; + foreach ($bookClubList1->getBooks() as $book) { + $this->assertEquals('My Book ' . $i, $book->getTitle()); + $this->assertEquals($i++, $book->getIsbn()); + } + + // Remove an element + $books->shift(); + $this->assertEquals(9, $books->count()); + + $bookClubList1->setBooks($books); + $bookClubList1->save(); + + $this->assertEquals(9, $bookClubList1->getBooks()->count()); + $this->assertEquals(1, BookClubListQuery::create()->count()); + $this->assertEquals(9, BookListRelQuery::create()->count()); + $this->assertEquals(10, BookQuery::create()->count()); + + // Add a new object + $newBook = new Book(); + $newBook->setTitle('My New Book'); + $newBook->setIsbn(1234); + + // Kind of new collection + $books = clone $books; + $books[] = $newBook; + + $bookClubList1->setBooks($books); + $bookClubList1->save(); + + $this->assertEquals(10, $books->count()); + $this->assertEquals(10, $bookClubList1->getBooks()->count()); + $this->assertEquals(1, BookClubListQuery::create()->count()); + $this->assertEquals(10, BookListRelQuery::create()->count()); + $this->assertEquals(11, BookQuery::create()->count()); + + // Add a new object + $newBook1 = new Book(); + $newBook1->setTitle('My New Book1'); + $newBook1->setIsbn(1256); + + // Existing collection - The fix around reference is tested here. + // Ths `$books` collection has ever been setted to the `$bookClubList1` object. + // Here we are adding a new object into the collection but, in this process, it + // added the new object in the internal `collBooks` of the `$bookClubList1` + // object too. + // That's why the new object is not tracked and the cross object is not created, + // in `addBook()` we consider the `collBooks` ever contains this new object. It's + // not true but this is the "reference" process. + // By saying "all new objects have to be added", we solve this issue. To know if + // it's the best solution is the question. + $books[] = $newBook1; + + $bookClubList1->setBooks($books); + $bookClubList1->save(); + + $this->assertEquals(11, $books->count()); + $this->assertEquals(11, $bookClubList1->getBooks()->count()); + $this->assertEquals(1, BookClubListQuery::create()->count()); + $this->assertEquals(11, BookListRelQuery::create()->count()); + $this->assertEquals(12, BookQuery::create()->count()); + + // Add the same collection + $books = $bookClubList1->getBooks(); + + $bookClubList1->setBooks($books); + $bookClubList1->save(); + + $this->assertEquals(11, $books->count()); + $this->assertEquals(11, $bookClubList1->getBooks()->count()); + $this->assertEquals(1, BookClubListQuery::create()->count()); + $this->assertEquals(11, BookListRelQuery::create()->count()); + $this->assertEquals(12, BookQuery::create()->count()); + } + + public function testSetterCollectionWithNoData() + { + // Ensure no data + BookQuery::create()->deleteAll(); + BookClubListQuery::create()->deleteAll(); + BookListRelQuery::create()->deleteAll(); + + $books = new PropelObjectCollection(); + $this->assertEquals(0, $books->count()); + + // Basic usage + $bookClubList1 = new BookClubList(); + $bookClubList1->setGroupLeader('BookClubList1 Leader'); + $bookClubList1->setBooks($books); + $bookClubList1->save(); + + $this->assertEquals(0, $bookClubList1->getBooks()->count()); + $this->assertEquals(1, BookClubListQuery::create()->count()); + $this->assertEquals(0, BookQuery::create()->count()); + $this->assertEquals(0, BookListRelQuery::create()->count()); + } + + public function testSetterCollectionSavesForeignObjects() + { + // Ensure no data + BookQuery::create()->deleteAll(); + BookClubListQuery::create()->deleteAll(); + BookListRelQuery::create()->deleteAll(); + + $book = new Book(); + $book->setTitle('My Book'); + $book->setIsbn('123452'); + $book->save(); + + // Modify it but don't save it + $book->setTitle('My Title'); + + $coll = new PropelObjectCollection(); + $coll[] = $book; + + BookPeer::clearInstancePool(); + $book = BookQuery::create()->findPk($book->getPrimaryKey()); + + $bookClubList1 = new BookClubList(); + $bookClubList1->setGroupLeader('Something'); + $bookClubList1->setBooks($coll); + $bookClubList1->save(); + + $this->assertEquals(1, $bookClubList1->getBooks()->count()); + $this->assertEquals(1, BookClubListQuery::create()->count()); + $this->assertEquals(1, BookQuery::create()->count()); + $this->assertEquals(1, BookListRelQuery::create()->count()); + + $result = BookQuery::create() + ->filterById($book->getId()) + ->select('Title') + ->findOne(); + $this->assertSame('My Title', $result); + } + + public function testSetterCollectionWithNewObjects() + { + // Ensure no data + BookQuery::create()->deleteAll(); + BookClubListQuery::create()->deleteAll(); + BookListRelQuery::create()->deleteAll(); + + $coll = new PropelObjectCollection(); + $coll->setModel('Book'); + + for ($i = 0; $i < 3; $i++) { + $b = new Book(); + $b->setTitle('Title ' . $i); + $b->setIsbn('1245' . $i); + + $coll[] = $b; + } + + $bookClubList = new BookClubList(); + $bookClubList->setGroupLeader('Something'); + $bookClubList->setBooks($coll); + $bookClubList->save(); + + $this->assertEquals(3, $coll->count()); + $this->assertEquals(3, count($bookClubList->getBooks())); + $this->assertSame($coll, $bookClubList->getBooks()); + $this->assertEquals(3, BookQuery::create()->count()); + $this->assertEquals(1, BookClubListQuery::create()->count()); + $this->assertEquals(3, BookListRelQuery::create()->count()); + } + + public function testSetterCollectionWithExistingObjects() + { + // Ensure no data + BookQuery::create()->deleteAll(); + BookClubListQuery::create()->deleteAll(); + BookListRelQuery::create()->deleteAll(); + + for ($i = 0; $i < 3; $i++) { + $b = new Book(); + $b->setTitle('Book ' . $i); + $b->setIsbn('123445' . $i); + $b->save(); + } + + BookPeer::clearInstancePool(); + $books = BookQuery::create()->find(); + + $bookClubList = new BookClubList(); + $bookClubList->setGroupLeader('Something'); + $bookClubList->setBooks($books); + $bookClubList->save(); + + $this->assertEquals(3, count($bookClubList->getBooks())); + $this->assertEquals(3, BookQuery::create()->count()); + $this->assertEquals(1, BookClubListQuery::create()->count()); + $this->assertEquals(3, BookListRelQuery::create()->count()); + + $i = 0; + foreach ($bookClubList->getBooks() as $book) { + $this->assertEquals('Book ' . $i++, $book->getTitle()); + } + } + + public function testSetterCollectionWithEmptyCollection() + { + // Ensure no data + BookQuery::create()->deleteAll(); + BookClubListQuery::create()->deleteAll(); + BookListRelQuery::create()->deleteAll(); + + $bookClubList = new BookClubList(); + $bookClubList->setGroupLeader('Something'); + $bookClubList->setBooks(new PropelObjectCollection()); + $bookClubList->save(); + + $this->assertEquals(0, count($bookClubList->getBooks())); + + $this->assertEquals(0, BookQuery::create()->count()); + $this->assertEquals(1, BookClubListQuery::create()->count()); + $this->assertEquals(0, BookListRelQuery::create()->count()); + } + + public function testSetterCollectionReplacesOldObjectsByNewObjects() + { + // Ensure no data + BookQuery::create()->deleteAll(); + BookClubListQuery::create()->deleteAll(); + BookListRelQuery::create()->deleteAll(); + + $books = new PropelObjectCollection(); + foreach (array('foo', 'bar') as $title) { + $b = new Book(); + $b->setTitle($title); + $b->setIsbn('12553'); + + $books[] = $b; + } + + $bookClubList = new BookClubList(); + $bookClubList->setGroupLeader('Something'); + $bookClubList->setBooks($books); + $bookClubList->save(); + + $books = $bookClubList->getBooks(); + $this->assertEquals('foo', $books[0]->getTitle()); + $this->assertEquals('bar', $books[1]->getTitle()); + + $books = new PropelObjectCollection(); + foreach (array('bam', 'bom') as $title) { + $b = new Book(); + $b->setTitle($title); + $b->setIsbn('1345'); + + $books[] = $b; + } + + $bookClubList->setBooks($books); + $bookClubList->save(); + + $books = $bookClubList->getBooks(); + $this->assertEquals('bam', $books[0]->getTitle()); + $this->assertEquals('bom', $books[1]->getTitle()); + + $this->assertEquals(1, BookClubListQuery::create()->count()); + $this->assertEquals(2, BookListRelQuery::create()->count()); + // ensure we have valid "association" objects + $this->assertEquals(1, BookListRelQuery::create() + ->filterByBookClubList($bookClubList) + ->filterByBook($books[0]) + ->count() + ); + $this->assertEquals(1, BookListRelQuery::create() + ->filterByBookClubList($bookClubList) + ->filterByBook($books[1]) + ->count() + ); + $this->assertEquals(4, BookQuery::create()->count()); + } + + public function testSetterCollectionWithManyToManyModifiedByReferenceWithANewObject() + { + // Ensure no data + BookQuery::create()->deleteAll(); + BookClubListQuery::create()->deleteAll(); + BookListRelQuery::create()->deleteAll(); + + $book = new Book(); + $book->setTitle('foo'); + $book->setIsbn('12345'); + + // The object is "new" + $this->assertTrue($book->isNew()); + + $bookClubList = new BookClubList(); + $bookClubList->setGroupLeader('Something'); + $books = $bookClubList->getBooks(); + // Add the object by reference + $books[] = $book; + + $bookClubList->setBooks($books); + $bookClubList->save(); + + $this->assertEquals(1, BookQuery::create()->count()); + $this->assertEquals(1, BookListRelQuery::create()->count()); + $this->assertEquals(1, BookClubListQuery::create()->count()); + } + + public function testSetterCollectionWithManyToManyModifiedByReferenceWithAnExistingObject() + { + // Ensure no data + BookQuery::create()->deleteAll(); + BookClubListQuery::create()->deleteAll(); + BookListRelQuery::create()->deleteAll(); + + $book = new Book(); + $book->setTitle('foo'); + $book->setIsbn('124'); + $book->save(); + + // The object isn't "new" + $this->assertFalse($book->isNew()); + + $bookClubList = new BookClubList(); + $bookClubList->setGroupLeader('Something'); + $books = $bookClubList->getBooks(); + // Add the object by reference + $books[] = $book; + + $bookClubList->setBooks($books); + $bookClubList->save(); + + $this->assertEquals(1, BookQuery::create()->count()); + $this->assertEquals(1, BookListRelQuery::create()->count()); + $this->assertEquals(1, BookClubListQuery::create()->count()); + } + + public function testRemoveObjectFromCollection() + { + $list = new BookClubList(); + $list->setGroupLeader('Archimedes Q. Porter'); + + $list2 = new BookClubList(); + $list2->setGroupLeader('FooBar group'); + // No save ... + + $book = new Book(); + $book->setTitle( "Jungle Expedition Handbook" ); + $book->setIsbn('TEST'); + // No save ... + $this->assertCount(0, $book->getBookClubLists(), 'No BookClubList'); + + $book->addBookClubList($list); + $book->addBookClubList($list2); + $this->assertCount(2, $book->getBookClubLists(), 'Two BookClubList'); + + $book->removeBookClubList($list); + $this->assertCount(1, $book->getBookClubLists(), 'One BookClubList has been remove'); + } + + public function testRemoveObjectStoredInDBFromCollection() + { + BookQuery::create()->deleteAll(); + BookClubListQuery::create()->deleteAll(); + + $list = new BookClubList(); + $list->setGroupLeader('Archimedes Q. Porter'); + + $list2 = new BookClubList(); + $list2->setGroupLeader('FooBar group'); + // No save ... + + $book = new Book(); + $book->setTitle( "Jungle Expedition Handbook" ); + $book->setIsbn('TEST'); + $book->addBookClubList($list); + $book->addBookClubList($list2); + $book->save(); + + $this->assertEquals(2, BookClubListQuery::create()->count(), 'Two BookClubList'); + $this->assertEquals(2, BookListRelQuery::create()->count(), 'Two BookClubList'); + + $book->removeBookClubList($list); + $this->assertEquals(2, BookListRelQuery::create()->count(), 'still Two BookClubList in db before save()'); + $this->assertCount(1, $book->getBookClubLists(), 'One BookClubList has been remove'); + $book->save(); + + $this->assertCount(1, $book->getBookClubLists(), 'One BookClubList has been remove'); + $this->assertEquals(1, BookListRelQuery::create()->count(), 'One BookClubList has been remove'); + } + + public function testRemoveObjectOneToMany() + { + BookQuery::create()->deleteAll(); + AuthorQuery::create()->deleteAll(); + + $book = new Book(); + $book->setTitle('Propel Book'); + $book->setIsbn('14'); + + $book2 = new Book(); + $book2->setTitle('Propel2 Book'); + $book2->setIsbn('124'); + + $author = new Author(); + $author->setFirstName('François'); + $author->setLastName('Z'); + + $author->addBook($book); + $author->addBook($book2); + + $this->assertCount(2, $author->getBooks()); + + $author->removeBook($book); + + $books = $author->getBooks(); + $this->assertCount(1, $books); + $this->assertEquals('Propel2 Book', reset($books)->getTitle()); + + $author->save(); + $book->save(); + $book2->save(); + + $this->assertEquals(2, BookQuery::create()->count(), 'Two Book'); + $this->assertEquals(1, AuthorQuery::create()->count(), 'One Author'); + $this->assertEquals(1, BookQuery::create()->filterByAuthor($author)->count()); + + $author->addBook($book); + $author->save(); + + $this->assertEquals(2, BookQuery::create()->filterByAuthor($author)->count()); + + $author->removeBook($book2); + $author->save(); + + $this->assertEquals(1, BookQuery::create()->filterByAuthor($author)->count()); + $this->assertEquals(2, BookQuery::create()->count(), 'Two Book because FK is not required so book is not delete when removed from author\'s book collection'); + } + + public function testRemoveObjectOneToManyWithFkRequired() + { + BookSummaryQuery::create()->deleteAll(); + BookQuery::create()->deleteAll(); + + $bookSummary = new BookSummary(); + $bookSummary->setSummary('summary Propel Book'); + + $bookSummary2 = new BookSummary(); + $bookSummary2->setSummary('summary2 Propel Book'); + + $book = new Book(); + $book->setTitle('Propel Book'); + $book->setIsbn('1235'); + + $book->addBookSummary($bookSummary); + $book->addBookSummary($bookSummary2); + + $this->assertCount(2, $book->getBookSummarys()); + + $book->removeBookSummary($bookSummary); + + $bookSummaries = $book->getBookSummarys(); + $this->assertCount(1, $bookSummaries); + $this->assertEquals('summary2 Propel Book', reset($bookSummaries)->getSummary()); + + $book->save(); + $bookSummary2->save(); + + $this->assertEquals(1, BookQuery::create()->count(), 'One Book'); + $this->assertEquals(1, BookSummaryQuery::create()->count(), 'One Summary'); + $this->assertEquals(1, BookSummaryQuery::create()->filterBySummarizedBook($book)->count()); + + $book->addBookSummary($bookSummary); + $bookSummary->save(); + $book->save(); + + $this->assertEquals(2, BookSummaryQuery::create()->filterBySummarizedBook($book)->count()); + + $book->removeBookSummary($bookSummary2); + $book->save(); + + $this->assertEquals(1, BookSummaryQuery::create()->filterBySummarizedBook($book)->count()); + $this->assertEquals(1, BookSummaryQuery::create()->count(), 'One Book summary because FK is required so book summary is deleted when book is saved'); + } + + public function testRefPhpNameCrossMany() + { + $book = new Book(); + $bookClubList = new BookClubList(); + $bookClubList->addFavoriteBookRelated($book); + + $this->assertCount(1, $bookClubList->getFavoriteBookRelateds(), 'there should be one book in the bookClubList'); + } + + public function testRefIsOnlySavedWhenRequired() + { + BookQuery::create()->deleteAll(); + + $book = new Book(); + $book->setTitle('Propel Book'); + $book->setISBN('TEST'); + $book->save(); + $bookId = $book->getId(); + + BookPeer::clearInstancePool(); + + $summary = $this->getMock('BookSummary'); + $summary + ->expects($this->once()) + ->method('isDeleted') + ->will($this->returnValue(false)) + ; + $summary + ->expects($this->once()) + ->method('isNew') + ->will($this->returnValue(false)) + ; + $summary + ->expects($this->once()) + ->method('isModified') + ->will($this->returnValue(false)) + ; + $summary + ->expects($this->never()) + ->method('save') + ; + + $coll = new PropelObjectCollection(); + $coll->append($summary); + + $book = BookQuery::create()->findOneById($bookId); + + // In conjunction with the mock above, this simulates loading those entries prior saving the book. + $book->setBookSummarys($coll); + + $book->setTitle('Propel2 Book'); + $book->save(); + } + + public function testAddAfterRemoveKeepsReferences() + { + $list = new BookClubList(); + $list->setGroupLeader('Archimedes Q. Porter'); + + $book = new Book(); + $book->setTitle( "Jungle Expedition Handbook" ); + $book->setIsbn('TEST'); + + $xref = new BookListRel(); + $xref->setBook($book); + $xref->setBookClubList($list); + $xref->save(); + + $book->removeBookListRel($xref); + $book->addBookListRel($xref); + $book->save(); + + $this->assertCount(1, $list->getBookListRels()); + $this->assertCount(1, $book->getBookListRels()); + $this->assertCount(1, BookListRelPeer::doSelect(new Criteria())); + + $book->removeBookClubList($list); + $book->addBookClubList($list); + $book->save(); + + $this->assertCount(1, $list->getBookListRels()); + $this->assertCount(1, $book->getBookListRels()); + $this->assertCount(1, BookListRelPeer::doSelect(new Criteria())); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectTemporalColumnTypeTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectTemporalColumnTypeTest.php new file mode 100644 index 000000000..e1336a4e0 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectTemporalColumnTypeTest.php @@ -0,0 +1,125 @@ + + + + + + +
+ +EOF; + PropelQuickBuilder::buildSchema($schema); + } + } + + public function testNullValue() + { + $r = new ComplexColumnTypeEntity5(); + $this->assertNull($r->getBar1()); + $r->setBar1(new DateTime('2011-12-02')); + $this->assertNotNull($r->getBar1()); + $r->setBar1(null); + $this->assertNull($r->getBar1()); + } + + /** + * @link http://trac.propelorm.org/ticket/586 + */ + public function testEmptyValue() + { + $r = new ComplexColumnTypeEntity5(); + $r->setBar1(''); + $this->assertNull($r->getBar1()); + } + + public function testPreEpochValue() + { + $r = new ComplexColumnTypeEntity5(); + $r->setBar1(new DateTime('1602-02-02')); + $this->assertEquals('1602-02-02', $r->getBar1(null)->format('Y-m-d')); + + $r->setBar1('1702-02-02'); + $this->assertTrue($r->isModified()); + $this->assertEquals('1702-02-02', $r->getBar1(null)->format('Y-m-d')); + } + + /** + * @expectedException PropelException + */ + public function testInvalidValueThrowsPropelException() + { + $r = new ComplexColumnTypeEntity5(); + $r->setBar1("Invalid Date"); + } + + public function testUnixTimestampValue() + { + $r = new ComplexColumnTypeEntity5(); + $r->setBar1(time()); + $this->assertEquals(date('Y-m-d'), $r->getBar1('Y-m-d')); + + $r = new ComplexColumnTypeEntity5(); + $r->setBar2(strtotime('12:55')); + $this->assertEquals('12:55', $r->getBar2(null)->format('H:i')); + + $r = new ComplexColumnTypeEntity5(); + $r->setBar3(time()); + $this->assertEquals(date('Y-m-d H:i'), $r->getBar3('Y-m-d H:i')); + } + + public function testDatePersistence() + { + $r = new ComplexColumnTypeEntity5(); + $r->setBar1(new DateTime('1999-12-20')); + $r->save(); + ComplexColumnTypeEntity5Peer::clearInstancePool(); + $r1 = ComplexColumnTypeEntity5Query::create()->findPk($r->getId()); + $this->assertEquals('1999-12-20', $r1->getBar1(null)->format('Y-m-d')); + } + + public function testTimePersistence() + { + $r = new ComplexColumnTypeEntity5(); + $r->setBar2(strtotime('12:55')); + $r->save(); + ComplexColumnTypeEntity5Peer::clearInstancePool(); + $r1 = ComplexColumnTypeEntity5Query::create()->findPk($r->getId()); + $this->assertEquals('12:55', $r1->getBar2(null)->format('H:i')); + } + + public function testTimestampPersistence() + { + $r = new ComplexColumnTypeEntity5(); + $r->setBar3(new DateTime('1999-12-20 12:55')); + $r->save(); + ComplexColumnTypeEntity5Peer::clearInstancePool(); + $r1 = ComplexColumnTypeEntity5Query::create()->findPk($r->getId()); + $this->assertEquals('1999-12-20 12:55', $r1->getBar3(null)->format('Y-m-d H:i')); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectTest.php index 63dead162..5639562bd 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectTest.php @@ -8,7 +8,8 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../../../generator/lib/util/PropelQuickBuilder.php'; /** * Tests the generated Object classes. @@ -17,7 +18,7 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; * object operations. The _idea_ here is to test every possible generated method * from Object.tpl; if necessary, bookstore will be expanded to accommodate this. * - * The database is relaoded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same * for each test method in this class. See the BookstoreDataPopulator::populate() * method for the exact contents of the database. @@ -26,1330 +27,1665 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; * @author Hans Lellelid * @package generator.builder.om */ -class GeneratedObjectTest extends BookstoreEmptyTestBase +class GeneratedObjectTest extends BookstoreTestBase { - protected function setUp() - { - parent::setUp(); - require_once 'tools/helpers/bookstore/behavior/TestAuthor.php'; - } - - /** - * Test saving an object after setting default values for it. - */ - public function testSaveWithDefaultValues() - { - // From the schema.xml, I am relying on the following: - // - that 'Penguin' is the default Name for a Publisher - // - that 2001-01-01 is the default ReviewDate for a Review - - // 1) check regular values (VARCHAR) - $pub = new Publisher(); - $pub->setName('Penguin'); - $pub->save(); - $this->assertTrue($pub->getId() !== null, "Expect Publisher to have been saved when default value set."); - - // 2) check date/time values - $review = new Review(); - // note that this is different from how it's represented in schema, but should resolve to same unix timestamp - $review->setReviewDate('2001-01-01'); - $this->assertTrue($review->isModified(), "Expect Review to have been marked 'modified' after default date/time value set."); - - } - - /** - * Test isModified() to be false after setting default value second time - */ - public function testDefaultValueSetTwice() - { - $pub = new Publisher(); - $pub->setName('Penguin'); - $pub->save(); - - $pubId = $pub->getId(); - - PublisherPeer::clearInstancePool(); - - $pub2 = PublisherPeer::retrieveByPK($pubId); - $pub2->setName('Penguin'); - $this->assertFalse($pub2->isModified(), "Expect Publisher to be not modified after setting default value second time."); - } - - public function testHasApplyDefaultValues() - { - $this->assertTrue(method_exists('Publisher', 'applyDefaultValues'), 'Tables with default values should have an applyDefaultValues() method'); - $this->assertFalse(method_exists('Book', 'applyDefaultValues'), 'Tables with no default values should not have an applyDefaultValues() method'); - } - - /** - * Test default return values. - */ - public function testDefaultValues() - { - $r = new Review(); - $this->assertEquals('2001-01-01', $r->getReviewDate('Y-m-d')); - - $this->assertFalse($r->isModified(), "expected isModified() to be false"); - - $acct = new BookstoreEmployeeAccount(); - $this->assertEquals(true, $acct->getEnabled()); - $this->assertFalse($acct->isModified()); - - $acct->setLogin("testuser"); - $acct->setPassword("testpass"); - $this->assertTrue($acct->isModified()); - } - - /** - * Tests the use of default expressions and the reloadOnInsert and reloadOnUpdate attributes. - * - * @link http://propel.phpdb.org/trac/ticket/378 - * @link http://propel.phpdb.org/trac/ticket/555 - */ - public function testDefaultExpresions() - { - if (Propel::getDb(BookstoreEmployeePeer::DATABASE_NAME) instanceof DBSqlite) { - $this->markTestSkipped("Cannot test default expressions with SQLite"); - } - - $b = new Bookstore(); - $b->setStoreName("Foo!"); - $b->save(); - - $employee = new BookstoreEmployee(); - $employee->setName("Johnny Walker"); - - $acct = new BookstoreEmployeeAccount(); - $acct->setBookstoreEmployee($employee); - $acct->setLogin("test-login"); - - $this->assertNull($acct->getCreated(), "Expected created column to be NULL."); - $this->assertNull($acct->getAuthenticator(), "Expected authenticator column to be NULL."); - - $acct->save(); - - $acct = BookstoreEmployeeAccountPeer::retrieveByPK($acct->getEmployeeId()); - - $this->assertNotNull($acct->getAuthenticator(), "Expected a valid (non-NULL) authenticator column after save."); - $this->assertEquals('Password', $acct->getAuthenticator(), "Expected authenticator='Password' after save."); - $this->assertNotNull($acct->getCreated(), "Expected a valid date after retrieving saved object."); - - $now = new DateTime("now"); - $this->assertEquals($now->format("Y-m-d"), $acct->getCreated("Y-m-d")); - - $acct->setCreated($now); - $this->assertEquals($now->format("Y-m-d"), $acct->getCreated("Y-m-d")); - - // Unfortunately we can't really test the conjunction of reloadOnInsert and reloadOnUpdate when using just - // default values. (At least not in a cross-db way.) - } - - /** - * Tests the use of default expressions and the reloadOnInsert attribute. - * - * @link http://propel.phpdb.org/trac/ticket/378 - * @link http://propel.phpdb.org/trac/ticket/555 - */ - public function testDefaultExpresions_ReloadOnInsert() - { - if (Propel::getDb(BookstoreEmployeePeer::DATABASE_NAME) instanceof DBSqlite) { - $this->markTestSkipped("Cannot test default date expressions with SQLite"); - } - - // Create a new bookstore, contest, bookstore_contest, and bookstore_contest_entry - - $b = new Bookstore(); - $b->setStoreName("Barnes & Noble"); - $b->save(); - - $c = new Contest(); - $c->setName("Bookathon Contest"); - $c->save(); - - $bc = new BookstoreContest(); - $bc->setBookstore($b); - $bc->setContest($c); - $bc->save(); - - $c = new Customer(); - $c->setName("Happy Customer"); - $c->save(); - - $bce = new BookstoreContestEntry(); - $bce->setBookstore($b); - $bce->setBookstoreContest($bc); - $bce->setCustomer($c); - $bce->save(); - - $this->assertNotNull($bce->getEntryDate(), "Expected a non-null entry_date after save."); - } - - /** - * Tests the overriding reloadOnInsert at runtime. - * - * @link http://propel.phpdb.org/trac/ticket/378 - * @link http://propel.phpdb.org/trac/ticket/555 - */ - public function testDefaultExpresions_ReloadOnInsert_Override() - { - if (Propel::getDb(BookstoreEmployeePeer::DATABASE_NAME) instanceof DBSqlite) { - $this->markTestSkipped("Cannot test default date expressions with SQLite"); - } - - // Create a new bookstore, contest, bookstore_contest, and bookstore_contest_entry - $b = new Bookstore(); - $b->setStoreName("Barnes & Noble"); - $b->save(); - - $c = new Contest(); - $c->setName("Bookathon Contest"); - $c->save(); - - $bc = new BookstoreContest(); - $bc->setBookstore($b); - $bc->setContest($c); - $bc->save(); - - $c = new Customer(); - $c->setName("Happy Customer"); - $c->save(); - - $bce = new BookstoreContestEntry(); - $bce->setBookstore($b); - $bce->setBookstoreContest($bc); - $bce->setCustomer($c); - $bce->save(null, $skipReload=true); - - $this->assertNull($bce->getEntryDate(), "Expected a NULL entry_date after save."); - } - - /** - * Tests the use of default expressions and the reloadOnUpdate attribute. - * - * @link http://propel.phpdb.org/trac/ticket/555 - */ - public function testDefaultExpresions_ReloadOnUpdate() - { - $b = new Bookstore(); - $b->setStoreName("Foo!"); - $b->save(); - - $sale = new BookstoreSale(); - $sale->setBookstore(BookstorePeer::doSelectOne(new Criteria())); - $sale->setSaleName("Spring Sale"); - $sale->save(); - - // Expect that default values are set, but not default expressions - $this->assertNull($sale->getDiscount(), "Expected discount to be NULL."); - - $sale->setSaleName("Winter Clearance"); - $sale->save(); - // Since reloadOnUpdate = true, we expect the discount to be set now. - - $this->assertNotNull($sale->getDiscount(), "Expected discount to be non-NULL after save."); - } - - /** - * Tests the overriding reloadOnUpdate at runtime. - * - * @link http://propel.phpdb.org/trac/ticket/378 - * @link http://propel.phpdb.org/trac/ticket/555 - */ - public function testDefaultExpresions_ReloadOnUpdate_Override() - { - $b = new Bookstore(); - $b->setStoreName("Foo!"); - $b->save(); - - $sale = new BookstoreSale(); - $sale->setBookstore(BookstorePeer::doSelectOne(new Criteria())); - $sale->setSaleName("Spring Sale"); - $sale->save(); - - // Expect that default values are set, but not default expressions - $this->assertNull($sale->getDiscount(), "Expected discount to be NULL."); - - $sale->setSaleName("Winter Clearance"); - $sale->save(null, $skipReload=true); - - // Since reloadOnUpdate = true, we expect the discount to be set now. - - $this->assertNull($sale->getDiscount(), "Expected NULL value for discount after save."); - } - - /** - * Test the behavior of date/time/values. - * This requires that the model was built with propel.useDateTimeClass=true. - */ - public function testTemporalValues_PreEpoch() - { - $r = new Review(); - - $preEpochDate = new DateTime('1602-02-02'); - - $r->setReviewDate($preEpochDate); - - $this->assertEquals('1602-02-02', $r->getReviewDate(null)->format("Y-m-d")); - - $r->setReviewDate('1702-02-02'); - - $this->assertTrue($r->isModified()); - - $this->assertEquals('1702-02-02', $r->getReviewDate(null)->format("Y-m-d")); - - // Now test for setting null - $r->setReviewDate(null); - $this->assertNull($r->getReviewDate()); - - } - - /** - * Test setting invalid date/time. - */ - public function testSetTemporalValue_Invalid() - { - $this->markTestSkipped(); - // FIXME - Figure out why this doesn't work (causes a PHP ERROR instead of throwing Exception) in - // the Phing+PHPUnit context - $r = new Review(); - try { - $r->setReviewDate("Invalid Date"); - $this->fail("Expected PropelException when setting date column w/ invalid date"); - } catch (PropelException $x) { - print "Caught expected PropelException: " . $x->__toString(); - } - } - - /** - * Test setting TIMESTAMP columns w/ unix int timestamp. - */ - public function testTemporalValues_Unix() - { - $store = new Bookstore(); - $store->setStoreName("test"); - $store->setStoreOpenTime(strtotime('12:55')); - $store->save(); - $this->assertEquals('12:55', $store->getStoreOpenTime(null)->format('H:i')); - - $acct = new BookstoreEmployeeAccount(); - $acct->setCreated(time()); - $this->assertEquals(date('Y-m-d H:i'), $acct->getCreated('Y-m-d H:i')); - - $review = new Review(); - $review->setReviewDate(time()); - $this->assertEquals(date('Y-m-d'), $review->getReviewDate('Y-m-d')); - } - - /** - * Test setting empty temporal values. - * @link http://propel.phpdb.org/trac/ticket/586 - */ - public function testTemporalValues_Empty() - { - $review = new Review(); - $review->setReviewDate(''); - $this->assertNull($review->getReviewDate()); - } - - /** - * Test setting TIME columns. - */ - public function testTemporalValues_TimeSetting() - { - $store = new Bookstore(); - $store->setStoreName("test"); - $store->setStoreOpenTime("12:55"); - $store->save(); - - $store = new Bookstore(); - $store->setStoreName("test2"); - $store->setStoreOpenTime(new DateTime("12:55")); - $store->save(); - } - - /** - * Test setting TIME columns. - */ - public function testTemporalValues_DateSetting() - { - BookstoreDataPopulator::populate(); - - $r = new Review(); - $r->setBook(BookPeer::doSelectOne(new Criteria())); - $r->setReviewDate(new DateTime('1999-12-20')); - $r->setReviewedBy("Hans"); - $r->setRecommended(false); - $r->save(); - } - - /** - * Testing creating & saving new object & instance pool. - */ - public function testObjectInstances_New() - { - $emp = new BookstoreEmployee(); - $emp->setName(md5(microtime())); - $emp->save(); - $id = $emp->getId(); - - $retrieved = BookstoreEmployeePeer::retrieveByPK($id); - $this->assertSame($emp, $retrieved, "Expected same object (from instance pool)"); - } - - /** - * - */ - public function testObjectInstances_Fkeys() - { - // Establish a relationship between one employee and account - // and then change the employee_id and ensure that the account - // is not pulling the old employee. - - $pub1 = new Publisher(); - $pub1->setName('Publisher 1'); - $pub1->save(); - - $pub2 = new Publisher(); - $pub2->setName('Publisher 2'); - $pub2->save(); - - $book = new Book(); - $book->setTitle("Book Title"); - $book->setISBN("1234"); - $book->setPublisher($pub1); - $book->save(); - - $this->assertSame($pub1, $book->getPublisher()); - - // now change values behind the scenes - $con = Propel::getConnection(BookstoreEmployeeAccountPeer::DATABASE_NAME); - $con->exec("UPDATE " . BookPeer::TABLE_NAME . " SET " - . " publisher_id = " . $pub2->getId() - . " WHERE id = " . $book->getId()); - - - $book2 = BookPeer::retrieveByPK($book->getId()); - $this->assertSame($book, $book2, "Expected same book object instance"); - - $this->assertEquals($pub1->getId(), $book->getPublisherId(), "Expected book to have OLD publisher id before reload()"); - - $book->reload(); - - $this->assertEquals($pub2->getId(), $book->getPublisherId(), "Expected book to have new publisher id"); - $this->assertSame($pub2, $book->getPublisher(), "Expected book to have new publisher object associated."); - - // Now let's set it back, just to be double sure ... - - $con->exec("UPDATE " . BookPeer::TABLE_NAME . " SET " - . " publisher_id = " . $pub1->getId() - . " WHERE id = " . $book->getId()); - - $book->reload(); - - $this->assertEquals($pub1->getId(), $book->getPublisherId(), "Expected book to have old publisher id (again)."); - $this->assertSame($pub1, $book->getPublisher(), "Expected book to have old publisher object associated (again)."); - - } - - /** - * Test the effect of typecast on primary key values and instance pool retrieval. - */ - public function testObjectInstancePoolTypecasting() - { - $reader = new BookReader(); - $reader->setName("Tester"); - $reader->save(); - $readerId = $reader->getId(); - - $book = new Book(); - $book->setTitle("BookTest"); - $book->setISBN("TEST"); - $book->save(); - $bookId = $book->getId(); - - $opinion = new BookOpinion(); - $opinion->setBookId((string)$bookId); - $opinion->setReaderId((string)$readerId); - $opinion->setRating(5); - $opinion->setRecommendToFriend(false); - $opinion->save(); - - - $opinion2 = BookOpinionPeer::retrieveByPK($bookId, $readerId); - - $this->assertSame($opinion, $opinion2, "Expected same object to be retrieved from differently type-casted primary key values."); + protected function setUp() + { + parent::setUp(); + require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/behavior/TestAuthor.php'; + } + + /** + * Test saving an object after setting default values for it. + */ + public function testSaveWithDefaultValues() + { + // From the schema.xml, I am relying on the following: + // - that 'Penguin' is the default Name for a Publisher + // - that 2001-01-01 is the default ReviewDate for a Review + + // 1) check regular values (VARCHAR) + $pub = new Publisher(); + $pub->setName('Penguin'); + $pub->save(); + $this->assertTrue($pub->getId() !== null, "Expect Publisher to have been saved when default value set."); + + // 2) check date/time values + $review = new Review(); + // note that this is different from how it's represented in schema, but should resolve to same unix timestamp + $review->setReviewDate('2001-01-01'); + $this->assertTrue($review->isModified(), "Expect Review to have been marked 'modified' after default date/time value set."); + + } + + /** + * Test isModified() to be false after setting default value second time + */ + public function testDefaultValueSetTwice() + { + $pub = new Publisher(); + $pub->setName('Penguin'); + $pub->save(); + + $pubId = $pub->getId(); + + PublisherPeer::clearInstancePool(); + + $pub2 = PublisherPeer::retrieveByPK($pubId); + $pub2->setName('Penguin'); + $this->assertFalse($pub2->isModified(), "Expect Publisher to be not modified after setting default value second time."); + } + + public function testHasApplyDefaultValues() + { + $this->assertTrue(method_exists('Publisher', 'applyDefaultValues'), 'Tables with default values should have an applyDefaultValues() method'); + $this->assertFalse(method_exists('Book', 'applyDefaultValues'), 'Tables with no default values should not have an applyDefaultValues() method'); + } + + /** + * Test default return values. + */ + public function testDefaultValues() + { + $r = new Review(); + $this->assertEquals('2001-01-01', $r->getReviewDate('Y-m-d')); + + $this->assertFalse($r->isModified(), "expected isModified() to be false"); + + $acct = new BookstoreEmployeeAccount(); + $this->assertEquals(true, $acct->getEnabled()); + $this->assertFalse($acct->isModified()); + + $acct->setLogin("testuser"); + $acct->setPassword("testpass"); + $this->assertTrue($acct->isModified()); + } + + /** + * Tests the use of default expressions and the reloadOnInsert and reloadOnUpdate attributes. + * + * @link http://trac.propelorm.org/ticket/378 + * @link http://trac.propelorm.org/ticket/555 + */ + public function testDefaultExpressions() + { + if (Propel::getDb(BookstoreEmployeePeer::DATABASE_NAME) instanceof DBSqlite) { + $this->markTestSkipped("Cannot test default expressions with SQLite"); + } + BookstoreEmployeeAccountPeer::doDeleteAll(); + + $b = new Bookstore(); + $b->setStoreName("Foo!"); + $b->save(); + + $employee = new BookstoreEmployee(); + $employee->setName("Johnny Walker"); + + $acct = new BookstoreEmployeeAccount(); + $acct->setBookstoreEmployee($employee); + $acct->setLogin("test-login"); + + $this->assertNull($acct->getCreated(), "Expected created column to be NULL."); + $this->assertNull($acct->getAuthenticator(), "Expected authenticator column to be NULL."); + + $acct->save(); + + $acct = BookstoreEmployeeAccountPeer::retrieveByPK($acct->getEmployeeId()); + + $this->assertNotNull($acct->getAuthenticator(), "Expected a valid (non-NULL) authenticator column after save."); + $this->assertEquals('Password', $acct->getAuthenticator(), "Expected authenticator='Password' after save."); + $this->assertNotNull($acct->getCreated(), "Expected a valid date after retrieving saved object."); + + $now = new DateTime("now"); + $this->assertEquals($now->format("Y-m-d"), $acct->getCreated("Y-m-d")); + + $acct->setCreated($now); + $this->assertEquals($now->format("Y-m-d"), $acct->getCreated("Y-m-d")); + + // Unfortunately we can't really test the conjunction of reloadOnInsert and reloadOnUpdate when using just + // default values. (At least not in a cross-db way.) + } + + /** + * Tests the use of default expressions and the reloadOnInsert attribute. + * + * @link http://trac.propelorm.org/ticket/378 + * @link http://trac.propelorm.org/ticket/555 + */ + public function testDefaultExpresions_ReloadOnInsert() + { + if (Propel::getDb(BookstoreEmployeePeer::DATABASE_NAME) instanceof DBSqlite) { + $this->markTestSkipped("Cannot test default date expressions with SQLite"); + } + + // Create a new bookstore, contest, bookstore_contest, and bookstore_contest_entry + + $b = new Bookstore(); + $b->setStoreName("Barnes & Noble"); + $b->save(); + + $c = new Contest(); + $c->setName("Bookathon Contest"); + $c->save(); + + $bc = new BookstoreContest(); + $bc->setBookstore($b); + $bc->setContest($c); + $bc->save(); + + $c = new Customer(); + $c->setName("Happy Customer"); + $c->save(); + + $bce = new BookstoreContestEntry(); + $bce->setBookstore($b); + $bce->setBookstoreContest($bc); + $bce->setCustomer($c); + $bce->save(); + + $this->assertNotNull($bce->getEntryDate(), "Expected a non-null entry_date after save."); + } + + /** + * Tests the overriding reloadOnInsert at runtime. + * + * @link http://trac.propelorm.org/ticket/378 + * @link http://trac.propelorm.org/ticket/555 + */ + public function testDefaultExpresions_ReloadOnInsert_Override() + { + if (Propel::getDb(BookstoreEmployeePeer::DATABASE_NAME) instanceof DBSqlite) { + $this->markTestSkipped("Cannot test default date expressions with SQLite"); + } + + // Create a new bookstore, contest, bookstore_contest, and bookstore_contest_entry + $b = new Bookstore(); + $b->setStoreName("Barnes & Noble"); + $b->save(); + + $c = new Contest(); + $c->setName("Bookathon Contest"); + $c->save(); + + $bc = new BookstoreContest(); + $bc->setBookstore($b); + $bc->setContest($c); + $bc->save(); + + $c = new Customer(); + $c->setName("Happy Customer"); + $c->save(); + + $bce = new BookstoreContestEntry(); + $bce->setBookstore($b); + $bce->setBookstoreContest($bc); + $bce->setCustomer($c); + $bce->save(null, $skipReload=true); + + $this->assertNull($bce->getEntryDate(), "Expected a NULL entry_date after save."); + } + + /** + * Tests the use of default expressions and the reloadOnUpdate attribute. + * + * @link http://trac.propelorm.org/ticket/555 + */ + public function testDefaultExpresions_ReloadOnUpdate() + { + $b = new Bookstore(); + $b->setStoreName("Foo!"); + $b->save(); + + $sale = new BookstoreSale(); + $sale->setBookstore(BookstorePeer::doSelectOne(new Criteria())); + $sale->setSaleName("Spring Sale"); + $sale->save(); + + // Expect that default values are set, but not default expressions + $this->assertNull($sale->getDiscount(), "Expected discount to be NULL."); + + $sale->setSaleName("Winter Clearance"); + $sale->save(); + // Since reloadOnUpdate = true, we expect the discount to be set now. + + $this->assertNotNull($sale->getDiscount(), "Expected discount to be non-NULL after save."); + } + + /** + * Tests the overriding reloadOnUpdate at runtime. + * + * @link http://trac.propelorm.org/ticket/378 + * @link http://trac.propelorm.org/ticket/555 + */ + public function testDefaultExpresions_ReloadOnUpdate_Override() + { + $b = new Bookstore(); + $b->setStoreName("Foo!"); + $b->save(); + + $sale = new BookstoreSale(); + $sale->setBookstore(BookstorePeer::doSelectOne(new Criteria())); + $sale->setSaleName("Spring Sale"); + $sale->save(); + + // Expect that default values are set, but not default expressions + $this->assertNull($sale->getDiscount(), "Expected discount to be NULL."); + + $sale->setSaleName("Winter Clearance"); + $sale->save(null, $skipReload=true); + + // Since reloadOnUpdate = true, we expect the discount to be set now. + + $this->assertNull($sale->getDiscount(), "Expected NULL value for discount after save."); + } + + /** + * Testing creating & saving new object & instance pool. + */ + public function testObjectInstances_New() + { + $emp = new BookstoreEmployee(); + $emp->setName(md5(microtime())); + $emp->save(); + $id = $emp->getId(); + + $retrieved = BookstoreEmployeePeer::retrieveByPK($id); + $this->assertSame($emp, $retrieved, "Expected same object (from instance pool)"); + } + + /** + * + */ + public function testObjectInstances_Fkeys() + { + // Establish a relationship between one employee and account + // and then change the employee_id and ensure that the account + // is not pulling the old employee. + + $pub1 = new Publisher(); + $pub1->setName('Publisher 1'); + $pub1->save(); + + $pub2 = new Publisher(); + $pub2->setName('Publisher 2'); + $pub2->save(); + + $book = new Book(); + $book->setTitle("Book Title"); + $book->setISBN("1234"); + $book->setPublisher($pub1); + $book->save(); + + $this->assertSame($pub1, $book->getPublisher()); + + // now change values behind the scenes + $con = Propel::getConnection(BookstoreEmployeeAccountPeer::DATABASE_NAME); + $con->exec("UPDATE " . BookPeer::TABLE_NAME . " SET " + . " publisher_id = " . $pub2->getId() + . " WHERE id = " . $book->getId()); + + $book2 = BookPeer::retrieveByPK($book->getId()); + $this->assertSame($book, $book2, "Expected same book object instance"); + + $this->assertEquals($pub1->getId(), $book->getPublisherId(), "Expected book to have OLD publisher id before reload()"); + + $book->reload(); + + $this->assertEquals($pub2->getId(), $book->getPublisherId(), "Expected book to have new publisher id"); + $this->assertSame($pub2, $book->getPublisher(), "Expected book to have new publisher object associated."); + + // Now let's set it back, just to be double sure ... + + $con->exec("UPDATE " . BookPeer::TABLE_NAME . " SET " + . " publisher_id = " . $pub1->getId() + . " WHERE id = " . $book->getId()); + + $book->reload(); + + $this->assertEquals($pub1->getId(), $book->getPublisherId(), "Expected book to have old publisher id (again)."); + $this->assertSame($pub1, $book->getPublisher(), "Expected book to have old publisher object associated (again)."); + + } + + /** + * Test the effect of typecast on primary key values and instance pool retrieval. + */ + public function testObjectInstancePoolTypecasting() + { + $reader = new BookReader(); + $reader->setName("Tester"); + $reader->save(); + $readerId = $reader->getId(); + + $book = new Book(); + $book->setTitle("BookTest"); + $book->setISBN("TEST"); + $book->save(); + $bookId = $book->getId(); + + $opinion = new BookOpinion(); + $opinion->setBookId((string) $bookId); + $opinion->setReaderId((string) $readerId); + $opinion->setRating(5); + $opinion->setRecommendToFriend(false); + $opinion->save(); + + + $opinion2 = BookOpinionPeer::retrieveByPK($bookId, $readerId); + + $this->assertSame($opinion, $opinion2, "Expected same object to be retrieved from differently type-casted primary key values."); + + } + + /** + * Test saving an object and getting correct number of affected rows from save(). + * This includes tests of cascading saves to fk-related objects. + */ + public function testSaveReturnValues() + { + + $author = new Author(); + $author->setFirstName("Mark"); + $author->setLastName("Kurlansky"); + // do not save + + $pub = new Publisher(); + $pub->setName("Penguin Books"); + // do not save + + $book = new Book(); + $book->setTitle("Salt: A World History"); + $book->setISBN("0142001619"); + $book->setAuthor($author); + $book->setPublisher($pub); + + $affected = $book->save(); + $this->assertEquals(3, $affected, "Expected 3 affected rows when saving book + publisher + author."); + + // change nothing ... + $affected = $book->save(); + $this->assertEquals(0, $affected, "Expected 0 affected rows when saving already-saved book."); + + // modify the book (UPDATE) + $book->setTitle("Salt A World History"); + $affected = $book->save(); + $this->assertEquals(1, $affected, "Expected 1 affected row when saving modified book."); + + // modify the related author + $author->setLastName("Kurlanski"); + $affected = $book->save(); + $this->assertEquals(1, $affected, "Expected 1 affected row when saving book with updated author."); + + // modify both the related author and the book + $author->setLastName("Kurlansky"); + $book->setTitle("Salt: A World History"); + $affected = $book->save(); + $this->assertEquals(2, $affected, "Expected 2 affected rows when saving updated book with updated author."); + + } + + /* + WTF!!!!!! + public function testSaveCanInsertEmptyObjects() + { + $b = new Book(); + $b->save(); + $this->assertFalse($b->isNew()); + $this->assertNotNull($b->getId()); + } + */ + + public function testSaveCanInsertNonEmptyObjects() + { + $b = new Book(); + $b->setTitle('foo'); + $b->setIsbn('124'); + $b->save(); + $this->assertFalse($b->isNew()); + $this->assertNotNull($b->getId()); + } + + /** + * + */ + public function testNoColsModified() + { + $e1 = new BookstoreEmployee(); + $e1->setName('Employee 1'); + + $e2 = new BookstoreEmployee(); + $e2->setName('Employee 2'); + + $super = new BookstoreEmployee(); + // we don't know who the supervisor is yet + $super->addSubordinate($e1); + $super->addSubordinate($e2); + + $affected = $super->save(); + + } + + public function testIsModifiedIsFalseForNewObjects() + { + $a = new Author(); + $this->assertFalse($a->isModified()); + } + + public function testIsModifiedIsTrueForNewObjectsWithModifications() + { + $a = new Author(); + $a->setFirstName('Foo'); + $this->assertTrue($a->isModified()); + } + + public function testIsModifiedIsFalseForNewObjectsWithNullModifications() + { + $a = new Author(); + $a->setFirstName(null); + $this->assertFalse($a->isModified()); + } + + public function testIsModifiedIsFalseForObjectsAfterResetModified() + { + $a = new Author(); + $a->setFirstName('Foo'); + $a->resetModified(); + $this->assertFalse($a->isModified()); + } + + public function testIsModifiedIsFalseForSavedObjects() + { + $a = new Author(); + $a->setFirstName('Foo'); + $a->setLastName('Bar'); + $a->save(); + $this->assertFalse($a->isModified()); + } + + public function testIsModifiedIsTrueForSavedObjectsWithModifications() + { + $a = new Author(); + $a->setFirstName('Foo'); + $this->assertTrue($a->isModified()); + } + + public function testIsModifiedIsFalseAfterSetToDefaultValueOnNewObject() + { + $p = new Publisher(); + $p->setName('Penguin'); // default column value + $this->assertFalse($p->isModified()); + } + + public function testIsModifiedIsTrueAfterModifyingOnNonDefaultValueOnNewObject() + { + $p = new Publisher(); + $p->setName('Puffin Books'); + $this->assertTrue($p->isModified()); + } + + public function testIsModifiedIsTrueAfterSetToDefaultValueOnModifiedObject() + { + $p = new Publisher(); + $p->setName('Puffin Books'); + $p->resetModified(); + $p->setName('Penguin'); // default column value + $this->assertTrue($p->isModified()); + } + + public function testIsModifiedIsFalseAfterChangingColumnTypeButNotValue() + { + $a = new Author(); + $a->setFirstName('1'); + $a->setAge(25); + $a->resetModified(); + + $a->setAge('25'); + $this->assertFalse($a->isModified()); + + $a->setFirstName(1); + $this->assertFalse($a->isModified()); + } + + public function testIsModifiedAndNullValues() + { + $a = new Author(); + $a->setFirstName(''); + $a->setLastName('Bar'); + $a->setAge(0); + $a->save(); + + $a->setFirstName(null); + $this->assertTrue($a->isModified(), "Expected Author to be modified after changing empty string column value to NULL."); + + $a->setAge(null); + $this->assertTrue($a->isModified(), "Expected Author to be modified after changing 0-value int column to NULL."); + + $a->setFirstName(''); + $this->assertTrue($a->isModified(), "Expected Author to be modified after changing NULL column value to empty string."); + + $a->setAge(0); + $this->assertTrue($a->isModified(), "Expected Author to be modified after changing NULL column to 0-value int."); + } + + /** + * Test checking for non-default values. + * @see http://trac.propelorm.org/ticket/331 + */ + public function testHasOnlyDefaultValues() + { + $emp = new BookstoreEmployee(); + $emp->setName(md5(microtime())); + + $acct2 = new BookstoreEmployeeAccount(); + + $acct = new BookstoreEmployeeAccount(); + $acct->setBookstoreEmployee($emp); + $acct->setLogin("foo"); + $acct->setPassword("bar"); + $acct->save(); + + $this->assertFalse($acct->isModified(), "Expected BookstoreEmployeeAccount NOT to be modified after save()."); + + $acct->setEnabled(true); + $acct->setPassword($acct2->getPassword()); + + $this->assertTrue($acct->isModified(), "Expected BookstoreEmployeeAccount to be modified after setting default values."); + + $this->assertTrue($acct->hasOnlyDefaultValues(), "Expected BookstoreEmployeeAccount to not have only default values."); + + $acct->setPassword("bar"); + $this->assertFalse($acct->hasOnlyDefaultValues(), "Expected BookstoreEmployeeAccount to have at one non-default value after setting one value to non-default."); + + // Test a default date/time value + $r = new Review(); + $r->setReviewDate(new DateTime("now")); + $this->assertFalse($r->hasOnlyDefaultValues()); + } + + public function testCountRefFk() + { + $book = new Book(); + $book->setTitle("Test Book"); + $book->setISBN("TT-EE-SS-TT"); + + $num = 5; + + for ($i=2; $i < $num + 2; $i++) { + $r = new Review(); + $r->setReviewedBy('Hans ' . $num); + $dt = new DateTime("now"); + $dt->modify("-".$i." weeks"); + $r->setReviewDate($dt); + $r->setRecommended(($i % 2) == 0); + $book->addReview($r); + } + + $this->assertEquals($num, $book->countReviews(), "Expected countReviews to return $num"); + $this->assertEquals($num, count($book->getReviews()), "Expected getReviews to return $num reviews"); + + $book->save(); + + BookPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + + $book = BookPeer::retrieveByPK($book->getId()); + $this->assertEquals($num, $book->countReviews(), "Expected countReviews() to return $num (after save)"); + $this->assertEquals($num, count($book->getReviews()), "Expected getReviews() to return $num (after save)"); + + // Now set different criteria and expect different results + $c = new Criteria(); + $c->add(ReviewPeer::RECOMMENDED, false); + $this->assertEquals(floor($num/2), $book->countReviews($c), "Expected " . floor($num/2) . " results from countReviews(recomm=false)"); + + // Change Criteria, run again -- expect different. + $c = new Criteria(); + $c->add(ReviewPeer::RECOMMENDED, true); + $this->assertEquals(ceil($num/2), count($book->getReviews($c)), "Expected " . ceil($num/2) . " results from getReviews(recomm=true)"); + + $this->assertEquals($num, $book->countReviews(), "Expected countReviews to return $num with new empty Criteria"); + } + + /** + * Test copying when an object has composite primary key. + * @link http://trac.propelorm.org/ticket/618 + */ + public function testCopy_CompositePK() + { + $br = new BookReader(); + $br->setName("TestReader"); + $br->save(); + $br->copy(); + + $b = new Book(); + $b->setTitle("TestBook"); + $b->setISBN("XX-XX-XX-XX"); + $b->save(); + + $op = new BookOpinion(); + $op->setBookReader($br); + $op->setBook($b); + $op->setRating(10); + $op->setRecommendToFriend(true); + $op->save(); + + $br2 = $br->copy(true); + + $this->assertNull($br2->getId()); + + $opinions = $br2->getBookOpinions(); + $this->assertEquals(1, count($opinions), "Expected to have a related BookOpinion after copy()"); + + // We DO expect the reader_id to be null + $this->assertNull($opinions[0]->getReaderId()); + // but we DO NOT expect the book_id to be null + $this->assertEquals($op->getBookId(), $opinions[0]->getBookId()); + } + + /** + * When a relation PK is a composite, replacing the list of relations will flag some of them to be deleted. + * We primary keys on the "To be deleted" opinions must not be blanked (null) because we need to values to be able to delete the entry. + */ + public function testReplace_RelationWithCompositePK() + { + BookReaderQuery::create()->deleteAll(); + BookQuery::create()->deleteAll(); + BookOpinionQuery::create()->deleteAll(); + + $br1 = new BookReader(); + $br1->setName("TestReader"); + $br1->save(); + + $br2 = new BookReader(); + $br2->setName("TestReader2"); + $br2->save(); + + $b = new Book(); + $b->setTitle("TestBook"); + $b->setISBN("XX-XX-XX-XX"); + $b->save(); + + $op1 = new BookOpinion(); + $op1->setBookReader($br1); + $op1->setBook($b); + $op1->setRating(10); + $op1->setRecommendToFriend(true); + $op1->save(); + + // make sure everything is loaded correctly (and their relation too) + $br1->reload(true); + $b->reload(true); + $op1->reload(true); + $br2->reload(true); + + $op2 = new BookOpinion(); + $op2->setBookReader($br2); + $op2->setRating(8); + $op2->setRecommendToFriend(false); + + // the setBookOpinions function expect a PropelCollection + $pc = new PropelObjectCollection(); + $pc->setModel('BookOpinion'); + $pc->append($op2); + + $br1->getBookOpinions(); // load the relation + + $b->setBookOpinions($pc); // this will flag to be deleted the currently assigned opinion and will add the new opinion so it will can be saved + $b->save(); // this will delete $op1 and insert $op2 + + $this->assertEquals(2, BookReaderQuery::create()->count(), '2 BookReader'); + $this->assertEquals(1, BookQuery::create()->count(), '1 Book'); + $this->assertEquals(1, BookOpinionQuery::create()->count(), 'Only 1 BookOpinion; the new one got inserted and the previously associated one got deleted'); + + $this->assertEquals(1, count($b->getBookOpinions()), 'Book has 1 BookOpinion'); + $this->assertEquals(1, count($op2->getBook()), 'BookOpinion2 has a relation to the Book'); + $this->assertEquals(1, count($br1->getBookOpinions()), 'BookReader1 has 1 BookOpinion (BookOpinion1)'); + $this->assertEquals(1, count($br2->getBookOpinions()), 'BookReader2 has 1 BookOpinion (BookOpinion2)'); + + $this->assertFalse($op1->isDeleted(), 'BookOpinion1 think it has not been deleted'); + + $caughtException = false; + try { + $op1->reload(false); // will fail because won't find the entry in the db + } catch (PropelException $pe) { + $caughtException = true; + } + + $this->assertTrue($caughtException, 'Could not reload BookOpinion1 because it has been deleted from the db'); + + $this->assertFalse($op2->isDeleted(), 'BookOpinion2 is not deleted'); + + $this->assertEquals(1, count($br1->getBookOpinions()), 'BookReader1 thinks it is assigned to 1 BookOpinion (BookOpinion1)'); + $temp_op = $br1->getBookOpinions(); + $this->assertEquals(spl_object_hash($op1), spl_object_hash($temp_op[0]), 'BookReader1 assigned BookOpinion is still BookOpinion1'); + $this->assertFalse($temp_op[0]->isDeleted(), 'BookReader1 assigned BookOpinion still thinks it has not been deleted'); + + $br1->reload(true); // and reset the relations + + $this->assertEquals(0, count($br1->getBookOpinions()), 'BookReader1 no longer has any BookOpinion'); + } + + /** + * Test removing object when FK is part of the composite PK + */ + public function testRemove_CompositePK() + { + BookReaderQuery::create()->deleteAll(); + BookQuery::create()->deleteAll(); + BookOpinionQuery::create()->deleteAll(); + + $br = new BookReader(); + $br->setName("TestReader"); + $br->save(); + + $b = new Book(); + $b->setTitle("TestBook"); + $b->setISBN("XX-XX-XX-XX"); + $b->save(); + + $op = new BookOpinion(); + $op->setBookReader($br); + $op->setBook($b); + $op->setRating(10); + $op->setRecommendToFriend(true); + $op->save(); + + $this->assertEquals(1, BookReaderQuery::create()->count(), '1 BookReader'); + $this->assertEquals(1, BookQuery::create()->count(), '1 Book'); + $this->assertEquals(1, BookOpinionQuery::create()->count(), '1 BookOpinion'); + + // make sure everything is loaded correctly (and their relation too) + $br->reload(true); + $b->reload(true); + $op->reload(true); + + $br->getBookOpinions(); // load the relation + + $b->removeBookOpinion($op); + $b->save(); + + // the Book knows that there is no longer an opinion + $this->assertEquals(0, count($b->getBookOpinions()), 'Book knows there is no opinion'); + // but not the BookReader + $this->assertEquals(1, count($br->getBookOpinions()), 'BookReader still thinks it has 1 opinion'); + + $br->reload(true); // with relations + + $this->assertEquals(0, count($br->getBookOpinions()), 'BookReader now knows the opinion is gone'); + + $this->assertEquals(1, BookReaderQuery::create()->count(), '1 BookReader'); + $this->assertEquals(1, BookQuery::create()->count(), '1 Book'); + $this->assertEquals(0, BookOpinionQuery::create()->count(), '0 BookOpinion'); + } + + /** + * + */ + public function testCopyConcretInheritance() + { + $concreteArticle = new ConcreteArticle(); + $concreteArticle->setBody('TestBody'); + $concreteArticle->save(); + + $copy = $concreteArticle->copy(); + + $this->assertNull($copy->getId(), "single PK not autoincremented shouldn't be copied"); + } + + public function testDeepCopyConcretInheritance() + { + $comment1 = new ConcreteComment(); + $comment1->setMessage('my-new-comment1'); + $concreteArticle = new ConcreteArticle(); + $concreteArticle->setBody('TestBody'); + $concreteArticle->addConcreteComment($comment1); + $concreteArticle->save(); + $comment1->save(); + + $this->assertNotNull($comment1->getId()); + $this->assertNotNull($concreteArticle->getId()); + $this->assertEquals(1, $concreteArticle->countConcreteComments()); + $this->assertEquals($comment1->getConcreteContentId(), $concreteArticle->getId()); + + $copy = $concreteArticle->copy(true); + $this->assertNull($copy->getId()); + $this->assertEquals(1, $concreteArticle->countConcreteComments()); + + $comments = $copy->getConcreteContent()->getConcreteComments(); + $this->assertEquals('my-new-comment1', $comments[0]->getMessage()); + } + + public function testToArray() + { + $b = new Book(); + $b->setTitle('Don Juan'); + + $arr1 = $b->toArray(); + $expectedKeys = array( + 'Id', + 'Title', + 'ISBN', + 'Price', + 'PublisherId', + 'AuthorId' + ); + $this->assertEquals($expectedKeys, array_keys($arr1), 'toArray() returns an associative array with BasePeer::TYPE_PHPNAME keys by default'); + $this->assertEquals('Don Juan', $arr1['Title'], 'toArray() returns an associative array representation of the object'); + } + + public function testToArrayWithColumn() + { + $book = BookQuery::create()->withColumn('Title', 'TitleCopy')->findOne(); + $bookArray = $book->toArray(); + $this->assertEquals($book->getTitleCopy(), $bookArray['TitleCopy']); + } + + public function testToArrayKeyType() + { + $b = new Book(); + $b->setTitle('Don Juan'); + + $arr1 = $b->toArray(BasePeer::TYPE_COLNAME); + $expectedKeys = array( + BookPeer::ID, + BookPeer::TITLE, + BookPeer::ISBN, + BookPeer::PRICE, + BookPeer::PUBLISHER_ID, + BookPeer::AUTHOR_ID + ); + $this->assertEquals($expectedKeys, array_keys($arr1), 'toArray() accepts a $keyType parameter to change the result keys'); + $this->assertEquals('Don Juan', $arr1[BookPeer::TITLE], 'toArray() returns an associative array representation of the object'); + } + + public function testToArrayKeyTypePreDefined() + { + $schema = << + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $builder->getConfig()->setBuildProperty('defaultKeyType', 'studlyPhpName'); + $builder->buildClasses(); + + $expectedKeys = array( + 'idKeyType', + 'nameKeyType', + ); + + $object = new TestKeyTypeTable(); + + $this->assertEquals($expectedKeys, array_keys($object->toArray()), 'toArray() returns an associative array with pre-defined key type in properties.'); + } + + /** + * Test regexp validator for ticket:542 + * @link http://trac.propelorm.org/ticket/542 + */ + public function testRegexValidator() + { + $b = new Bookstore(); + $b->setWebsite("http://this.is.valid.com/foo.bar"); + $res = $b->validate(); + $this->assertTrue($res, "Expected URL to validate"); + } + + /** + * Test that setting the auto-increment primary key will result in exception. + */ + public function testSettingAutoIncrementPK() + { + // The whole test is in a transaction, but this test needs real transactions + $this->con->commit(); + + $b = new Bookstore(); + $b->setId(1); + $b->setStoreName("Test"); + try { + $b->save(); + $this->fail("Expected setting auto-increment primary key to result in Exception"); + } catch (Exception $x) { + $this->assertInstanceOf('PropelException', $x); + } + + // ... but we should silently ignore NULL values, since these are really + // the same as "not set" in PHP world. + $b = new Bookstore(); + $b->setId(null); + $b->setStoreName("Test2"); + try { + $b->save(); + } catch (Exception $x) { + $this->fail("Expected no exception when setting auto-increment primary key to NULL"); + } + // success ... + + $this->con->beginTransaction(); + } + + /** + * Checks wether we are allowed to specify the primary key on a + * table with allowPkInsert=true set + * + * saves the object, gets it from data-source again and then compares + * them for equality (thus the instance pool is also checked) + */ + public function testAllowPkInsertOnIdMethodNativeTable() + { + CustomerPeer::doDeleteAll(); + $cu = new Customer; + $cu->setPrimaryKey(100000); + $cu->save(); + + $this->assertEquals(100000, $cu->getPrimaryKey()); + + $cu2 = CustomerPeer::retrieveByPk(100000); + + $this->assertSame($cu, $cu2); + } + + /** + * Checks if it is allowed to save new, empty objects with a auto increment column + */ + public function testAllowEmptyWithAutoIncrement() + { + $bookreader = new BookReader(); + $bookreader->save(); + + $this->assertFalse($bookreader->isNew()); + } + + /** + * Test foreign key relationships based on references to unique cols but not PK. + * @link http://trac.propelorm.org/ticket/691 + */ + public function testUniqueFkRel() + { + BookstoreEmployeeAccountPeer::doDeleteAll(); + + $employee = new BookstoreEmployee(); + $employee->setName("Johnny Walker"); + + $acct = new BookstoreEmployeeAccount(); + $acct->setBookstoreEmployee($employee); + $acct->setLogin("test-login"); + $acct->save(); + $acctId = $acct->getEmployeeId(); + + $al = new AcctAuditLog(); + $al->setBookstoreEmployeeAccount($acct); + $al->save(); + $alId = $al->getId(); + + BookstoreEmployeePeer::clearInstancePool(); + BookstoreEmployeeAccountPeer::clearInstancePool(); + AcctAuditLogPeer::clearInstancePool(); + + $al2 = AcctAuditLogPeer::retrieveByPK($alId); + /* @var $al2 AcctAuditLog */ + $mapacct = $al2->getBookstoreEmployeeAccount(); + $lookupacct = BookstoreEmployeeAccountPeer::retrieveByPK($acctId); + + $logs = $lookupacct->getAcctAuditLogs(); + + $this->assertTrue(count($logs) == 1, "Expected 1 audit log result."); + $this->assertEquals($logs[0]->getId(), $al->getId(), "Expected returned audit log to match created audit log."); + } + + public function testIsPrimaryKeyNull() + { + $b = new Book(); + $this->assertTrue($b->isPrimaryKeyNull()); + $b->setPrimaryKey(123); + $this->assertFalse($b->isPrimaryKeyNull()); + $b->setPrimaryKey(null); + $this->assertTrue($b->isPrimaryKeyNull()); + } + + public function testIsPrimaryKeyNullCompmosite() + { + $b = new BookOpinion(); + $this->assertTrue($b->isPrimaryKeyNull()); + $b->setPrimaryKey(array(123, 456)); + $this->assertFalse($b->isPrimaryKeyNull()); + $b->setPrimaryKey(array(123, null)); + $this->assertFalse($b->isPrimaryKeyNull()); + $b->setPrimaryKey(array(null, 456)); + $this->assertFalse($b->isPrimaryKeyNull()); + $b->setPrimaryKey(array(null, null)); + $this->assertTrue($b->isPrimaryKeyNull()); + } + + public function testAddToStringDefault() + { + $this->assertTrue(method_exists('Author', '__toString'), 'addPrimaryString() adds a __toString() method even if no column has the primaryString attribute'); + $author = new Author(); + $author->setFirstName('Leo'); + $author->setLastName('Tolstoi'); + $expected = <<assertEquals($expected, (string) $author, 'addPrimaryString() adds a __toString() method returning the YAML representation of the object where no column is defined as primaryString'); + } + + public function testAddToStringPrimaryString() + { + $this->assertTrue(method_exists('Book', '__toString'), 'addPrimaryString() adds a __toString() method if a column has the primaryString attribute'); + $book = new Book(); + $book->setTitle('foo'); + $this->assertEquals('foo', (string) $book, 'addPrimaryString() adds a __toString() method returning the value of the the first column where primaryString is true'); + } + + public function testPreInsert() + { + $author = new TestAuthor(); + $author->setFirstName("bogus"); + $author->setLastName("Lastname"); + $author->save(); + $this->assertEquals('PreInsertedFirstname', $author->getFirstName()); + } + + public function testPreUpdate() + { + $author = new TestAuthor(); + $author->setFirstName("bogus"); + $author->setLastName("Lastname"); + $author->save(); + $author->setNew(false); + $author->save(); + $this->assertEquals('PreUpdatedFirstname', $author->getFirstName()); + } + + public function testPostInsert() + { + $author = new TestAuthor(); + $author->setFirstName("bogus"); + $author->setLastName("Lastname"); + $author->save(); + $this->assertEquals('PostInsertedLastName', $author->getLastName()); + } + + public function testPostUpdate() + { + $author = new TestAuthor(); + $author->setFirstName("bogus"); + $author->setLastName("Lastname"); + $author->save(); + $author->setNew(false); + $author->save(); + $this->assertEquals('PostUpdatedLastName', $author->getLastName()); + } + + public function testPreSave() + { + $author = new TestAuthor(); + $author->setFirstName("bogus"); + $author->setLastName("Lastname"); + $author->save(); + $this->assertEquals('pre@save.com', $author->getEmail()); + } + + public function testPreSaveFalse() + { + $con = Propel::getConnection(AuthorPeer::DATABASE_NAME); + $author = new TestAuthorSaveFalse(); + $author->setFirstName("bogus"); + $author->setLastName("Lastname"); + $res = $author->save($con); + $this->assertEquals(0, $res); + $this->assertEquals('pre@save.com', $author->getEmail()); + $this->assertNotEquals(115, $author->getAge()); + $this->assertTrue($author->isNew()); + $this->assertEquals(1, $con->getNestedTransactionCount()); + } + + public function testPostSave() + { + $author = new TestAuthor(); + $author->setFirstName("bogus"); + $author->setLastName("Lastname"); + $author->save(); + $this->assertEquals(115, $author->getAge()); + } + + public function testPreDelete() + { + $author = new TestAuthor(); + $author->setFirstName("bogus"); + $author->setLastName("Lastname"); + $author->save(); + $author->delete(); + $this->assertEquals("Pre-Deleted", $author->getFirstName()); + } + + public function testPreDeleteFalse() + { + $con = Propel::getConnection(AuthorPeer::DATABASE_NAME); + $author = new TestAuthorDeleteFalse(); + $author->setFirstName("bogus"); + $author->setLastName("Lastname"); + $author->save($con); + $author->delete($con); + $this->assertEquals("Pre-Deleted", $author->getFirstName()); + $this->assertNotEquals("Post-Deleted", $author->getLastName()); + $this->assertFalse($author->isDeleted()); + $this->assertEquals(1, $con->getNestedTransactionCount()); + } + + public function testPostDelete() + { + $author = new TestAuthor(); + $author->setFirstName("bogus"); + $author->setLastName("Lastname"); + $author->save(); + $author->delete(); + $this->assertEquals("Post-Deleted", $author->getLastName()); + } + + public function testPostHydrate() + { + $author = new TestAuthor(); + $author->hydrate(array(1, 'bogus', 'Lastname', 'bogus@mail.com', 21)); + $this->assertEquals("Post-Hydrated", $author->getLastName()); + } + + public function testMagicVirtualColumnGetter() + { + $book = new Book(); + $book->setVirtualColumn('Foo', 'bar'); + $this->assertEquals('bar', $book->getFoo(), 'generated __call() catches getters for virtual columns'); + $book = new Book(); + $book->setVirtualColumn('foo', 'bar'); + $this->assertEquals('bar', $book->getFoo(), 'generated __call() catches getters for virtual columns starting with a lowercase character'); + } + + /** + * @expectedException PropelException + */ + public function testMagicCallUndefined() + { + $book = new Book(); + $book->fooMethodName(); + } + + public static function conditionsForTestReadOnly() + { + return array( + array('reload'), + array('delete'), + array('save'), + array('doSave'), + ); + } + + /** + * @dataProvider conditionsForTestReadOnly + */ + public function testReadOnly($method) + { + $cv = new ContestView(); + $this->assertFalse(method_exists($cv, $method), 'readOnly tables end up with no ' . $method . ' method in the generated object class'); + } + + public function testSetterOneToMany() + { + // Ensure no data + BookQuery::create()->deleteAll(); + AuthorQuery::create()->deleteAll(); + + $coll = new PropelObjectCollection(); + $coll->setModel('Book'); + + for ($i = 0; $i < 3; $i++) { + $b = new Book(); + $b->setTitle('Title ' . $i); + $b->setIsbn('1204' . $i); + + $coll[] = $b; + } + + $this->assertEquals(3, $coll->count()); + + $a = new Author(); + $a->setFirstName('Foo'); + $a->setLastName('Bar'); + $a->setBooks($coll); + $a->save(); + + $this->assertInstanceOf('PropelObjectCollection', $a->getBooks()); + $this->assertEquals(3, $a->getBooks()->count()); + $this->assertEquals(1, AuthorQuery::create()->count()); + $this->assertEquals(3, BookQuery::create()->count()); + + $coll->shift(); + $this->assertEquals(2, $coll->count()); + + $a->setBooks($coll); + $a->save(); + + $this->assertEquals(2, $a->getBooks()->count()); + $this->assertEquals(1, AuthorQuery::create()->count()); + //The book is not deleted because his fk is not required + $this->assertEquals(3, BookQuery::create()->count()); + + $newBook = new Book(); + $newBook->setTitle('My New Book'); + $newBook->setIsbn(1234); + + // Kind of new collection + $coll = clone $coll; + $coll[] = $newBook; + + $a->setBooks($coll); + $a->save(); + + $this->assertEquals(3, $coll->count()); + $this->assertEquals(3, $a->getBooks()->count()); + $this->assertEquals(1, AuthorQuery::create()->count()); + $this->assertEquals(4, BookQuery::create()->count()); + + // Add a new object + $newBook1 = new Book(); + $newBook1->setTitle('My New Book1'); + $newBook1->setIsbn(1256); + + // Existing collection - The fix around reference is tested here. + $coll[] = $newBook1; + + $a->setBooks($coll); + $a->save(); + + $this->assertEquals(4, $coll->count()); + $this->assertEquals(4, $a->getBooks()->count()); + $this->assertEquals(1, AuthorQuery::create()->count()); + $this->assertEquals(5, BookQuery::create()->count()); + + // Add the same collection + $books = $a->getBooks(); + + $a->setBooks($books); + $a->save(); + + $this->assertEquals(4, $books->count()); + $this->assertEquals(4, $a->getBooks()->count()); + $this->assertEquals(1, AuthorQuery::create()->count()); + $this->assertEquals(5, BookQuery::create()->count()); + } + + public function testSetterOneToManyWithFkRequired() + { + // Ensure no data + BookSummaryQuery::create()->deleteAll(); + BookQuery::create()->deleteAll(); + + $coll = new PropelObjectCollection(); + $coll->setModel('BookSummary'); + + for ($i = 0; $i < 3; $i++) { + $bs = new BookSummary(); + $bs->setSummary('A summary ' . $i); + + $coll[] = $bs; + } + + $this->assertEquals(3, $coll->count()); + + $b = new Book(); + $b->setTitle('myBook'); + $b->setBookSummarys($coll); + $b->setIsbn('12242'); + $b->save(); - } + $this->assertInstanceOf('PropelObjectCollection', $b->getBookSummarys()); + $this->assertEquals(3, $b->getBookSummarys()->count()); + $this->assertEquals(1, BookQuery::create()->count()); + $this->assertEquals(3, BookSummaryQuery::create()->count()); - /** - * Test the reload() method. - */ - public function testReload() - { - BookstoreDataPopulator::populate(); - $a = AuthorPeer::doSelectOne(new Criteria()); + $coll->shift(); + $this->assertEquals(2, $coll->count()); - $origName = $a->getFirstName(); - - $a->setFirstName(md5(time())); - - $this->assertNotEquals($origName, $a->getFirstName()); - $this->assertTrue($a->isModified()); - - $a->reload(); - - $this->assertEquals($origName, $a->getFirstName()); - $this->assertFalse($a->isModified()); - - } - - /** - * Test reload(deep=true) method. - */ - public function testReloadDeep() - { - BookstoreDataPopulator::populate(); - - // arbitrary book - $b = BookPeer::doSelectOne(new Criteria()); - - // arbitrary, different author - $c = new Criteria(); - $c->add(AuthorPeer::ID, $b->getAuthorId(), Criteria::NOT_EQUAL); - $a = AuthorPeer::doSelectOne($c); - - $origAuthor = $b->getAuthor(); - - $b->setAuthor($a); - - $this->assertNotEquals($origAuthor, $b->getAuthor(), "Expected just-set object to be different from obj from DB"); - $this->assertTrue($b->isModified()); - - $b->reload($deep=true); - - $this->assertEquals($origAuthor, $b->getAuthor(), "Expected object in DB to be restored"); - $this->assertFalse($a->isModified()); - } - - /** - * Test saving an object and getting correct number of affected rows from save(). - * This includes tests of cascading saves to fk-related objects. - */ - public function testSaveReturnValues() - { - - $author = new Author(); - $author->setFirstName("Mark"); - $author->setLastName("Kurlansky"); - // do not save - - $pub = new Publisher(); - $pub->setName("Penguin Books"); - // do not save - - $book = new Book(); - $book->setTitle("Salt: A World History"); - $book->setISBN("0142001619"); - $book->setAuthor($author); - $book->setPublisher($pub); - - $affected = $book->save(); - $this->assertEquals(3, $affected, "Expected 3 affected rows when saving book + publisher + author."); - - // change nothing ... - $affected = $book->save(); - $this->assertEquals(0, $affected, "Expected 0 affected rows when saving already-saved book."); - - // modify the book (UPDATE) - $book->setTitle("Salt A World History"); - $affected = $book->save(); - $this->assertEquals(1, $affected, "Expected 1 affected row when saving modified book."); - - // modify the related author - $author->setLastName("Kurlanski"); - $affected = $book->save(); - $this->assertEquals(1, $affected, "Expected 1 affected row when saving book with updated author."); - - // modify both the related author and the book - $author->setLastName("Kurlansky"); - $book->setTitle("Salt: A World History"); - $affected = $book->save(); - $this->assertEquals(2, $affected, "Expected 2 affected rows when saving updated book with updated author."); - - } - - /** - * Test deleting an object using the delete() method. - */ - public function testDelete() - { - BookstoreDataPopulator::populate(); - - // 1) grab an arbitrary object - $book = BookPeer::doSelectOne(new Criteria()); - $bookId = $book->getId(); - - // 2) delete it - $book->delete(); - - // 3) make sure it can't be save()d now that it's deleted - try { - $book->setTitle("Will Fail"); - $book->save(); - $this->fail("Expect an exception to be thrown when attempting to save() a deleted object."); - } catch (PropelException $e) {} - - // 4) make sure that it doesn't exist in db - $book = BookPeer::retrieveByPK($bookId); - $this->assertNull($book, "Expect NULL from retrieveByPK on deleted Book."); - - } - - /** - * - */ - public function testNoColsModified() - { - $e1 = new BookstoreEmployee(); - $e1->setName('Employee 1'); - - $e2 = new BookstoreEmployee(); - $e2->setName('Employee 2'); - - $super = new BookstoreEmployee(); - // we don't know who the supervisor is yet - $super->addSubordinate($e1); - $super->addSubordinate($e2); - - $affected = $super->save(); - - } - - /** - * Tests new one-to-one functionality. - */ - public function testOneToOne() - { - BookstoreDataPopulator::populate(); - - $emp = BookstoreEmployeePeer::doSelectOne(new Criteria()); - - $acct = new BookstoreEmployeeAccount(); - $acct->setBookstoreEmployee($emp); - $acct->setLogin("testuser"); - $acct->setPassword("testpass"); - - $this->assertSame($emp->getBookstoreEmployeeAccount(), $acct, "Expected same object instance."); - } - - /** - * Test the type sensitivity of the resturning columns. - * - */ - public function testTypeSensitive() - { - BookstoreDataPopulator::populate(); - - $book = BookPeer::doSelectOne(new Criteria()); - - $r = new Review(); - $r->setReviewedBy("testTypeSensitive Tester"); - $r->setReviewDate(time()); - $r->setBook($book); - $r->setRecommended(true); - $r->save(); - - $id = $r->getId(); - unset($r); - - // clear the instance cache to force reload from database. - ReviewPeer::clearInstancePool(); - BookPeer::clearInstancePool(); - - // reload and verify that the types are the same - $r2 = ReviewPeer::retrieveByPK($id); - - $this->assertType('integer', $r2->getId(), "Expected getId() to return an integer."); - $this->assertType('string', $r2->getReviewedBy(), "Expected getReviewedBy() to return a string."); - $this->assertType('boolean', $r2->getRecommended(), "Expected getRecommended() to return a boolean."); - $this->assertType('Book', $r2->getBook(), "Expected getBook() to return a Book."); - $this->assertType('float', $r2->getBook()->getPrice(), "Expected Book->getPrice() to return a float."); - $this->assertType('DateTime', $r2->getReviewDate(null), "Expected Book->getReviewDate() to return a DateTime."); - - } - - /** - * This is a test for expected exceptions when saving UNIQUE. - * See http://propel.phpdb.org/trac/ticket/2 - */ - public function testSaveUnique() - { - // The whole test is in a transaction, but this test needs real transactions - $this->con->commit(); - - $emp = new BookstoreEmployee(); - $emp->setName(md5(microtime())); - - $acct = new BookstoreEmployeeAccount(); - $acct->setBookstoreEmployee($emp); - $acct->setLogin("foo"); - $acct->setPassword("bar"); - $acct->save(); - - // now attempt to create a new acct - $acct2 = $acct->copy(); - - try { - $acct2->save(); - $this->fail("Expected PropelException in first attempt to save object with duplicate value for UNIQUE constraint."); - } catch (Exception $x) { - try { - // attempt to save it again - $acct3 = $acct->copy(); - $acct3->save(); - $this->fail("Expected PropelException in second attempt to save object with duplicate value for UNIQUE constraint."); - } catch (Exception $x) { - // this is expected. - } - // now let's double check that it can succeed if we're not violating the constraint. - $acct3->setLogin("foo2"); - $acct3->save(); - } - - $this->con->beginTransaction(); - } - - /** - * Test for correct reporting of isModified(). - */ - public function testIsModified() - { - // 1) Basic test - - $a = new Author(); - $a->setFirstName("John"); - $a->setLastName("Doe"); - $a->setAge(25); - - $this->assertTrue($a->isModified(), "Expected Author to be modified after setting values."); - - $a->save(); - - $this->assertFalse($a->isModified(), "Expected Author to be unmodified after saving set values."); - - // 2) Test behavior with setting vars of different types - - // checking setting int col to string val - $a->setAge('25'); - $this->assertFalse($a->isModified(), "Expected Author to be unmodified after setting int column to string-cast of same value."); - - $a->setFirstName("John2"); - $this->assertTrue($a->isModified(), "Expected Author to be modified after changing string column value."); - - // checking setting string col to int val - $a->setFirstName("1"); - $a->save(); - $this->assertFalse($a->isModified(), "Expected Author to be unmodified after saving set values."); - - $a->setFirstName(1); - $this->assertFalse($a->isModified(), "Expected Author to be unmodified after setting string column to int-cast of same value."); - - // 3) Test for appropriate behavior of NULL - - // checking "" -> NULL - $a->setFirstName(""); - $a->save(); - $this->assertFalse($a->isModified(), "Expected Author to be unmodified after saving set values."); - - $a->setFirstName(null); - $this->assertTrue($a->isModified(), "Expected Author to be modified after changing empty string column value to NULL."); - - $a->setFirstName("John"); - $a->setAge(0); - $a->save(); - $this->assertFalse($a->isModified(), "Expected Author to be unmodified after saving set values."); - - $a->setAge(null); - $this->assertTrue($a->isModified(), "Expected Author to be modified after changing 0-value int column to NULL."); - - $a->save(); - $this->assertFalse($a->isModified(), "Expected Author to be unmodified after saving set values."); - - $a->setAge(0); - $this->assertTrue($a->isModified(), "Expected Author to be modified after changing NULL-value int column to 0."); - - } - - /** - * Test the BaseObject#equals(). - */ - public function testEquals() - { - BookstoreDataPopulator::populate(); - - $b = BookPeer::doSelectOne(new Criteria()); - $c = new Book(); - $c->setId($b->getId()); - $this->assertTrue($b->equals($c), "Expected Book objects to be equal()"); - - $a = new Author(); - $a->setId($b->getId()); - $this->assertFalse($b->equals($a), "Expected Book and Author with same primary key NOT to match."); - } - - /** - * Test checking for non-default values. - * @see http://propel.phpdb.org/trac/ticket/331 - */ - public function testHasOnlyDefaultValues() - { - $emp = new BookstoreEmployee(); - $emp->setName(md5(microtime())); - - $acct2 = new BookstoreEmployeeAccount(); - - $acct = new BookstoreEmployeeAccount(); - $acct->setBookstoreEmployee($emp); - $acct->setLogin("foo"); - $acct->setPassword("bar"); - $acct->save(); - - $this->assertFalse($acct->isModified(), "Expected BookstoreEmployeeAccount NOT to be modified after save()."); - - $acct->setEnabled(true); - $acct->setPassword($acct2->getPassword()); - - $this->assertTrue($acct->isModified(), "Expected BookstoreEmployeeAccount to be modified after setting default values."); - - $this->assertTrue($acct->hasOnlyDefaultValues(), "Expected BookstoreEmployeeAccount to not have only default values."); - - $acct->setPassword("bar"); - $this->assertFalse($acct->hasOnlyDefaultValues(), "Expected BookstoreEmployeeAccount to have at one non-default value after setting one value to non-default."); - - // Test a default date/time value - $r = new Review(); - $r->setReviewDate(new DateTime("now")); - $this->assertFalse($r->hasOnlyDefaultValues()); - } - - public function testDefaultFkColVal() - { - BookstoreDataPopulator::populate(); - - $sale = new BookstoreSale(); - $this->assertEquals(1, $sale->getBookstoreId(), "Expected BookstoreSale object to have a default bookstore_id of 1."); - - $bookstore = BookstorePeer::doSelectOne(new Criteria()); - - $sale->setBookstore($bookstore); - $this->assertEquals($bookstore->getId(), $sale->getBookstoreId(), "Expected FK id to have changed when assigned a valid FK."); - - $sale->setBookstore(null); - $this->assertEquals(1, $sale->getBookstoreId(), "Expected BookstoreSale object to have reset to default ID."); - - $sale->setPublisher(null); - $this->assertEquals(null, $sale->getPublisherId(), "Expected BookstoreSale object to have reset to NULL publisher ID."); - } - - public function testCountRefFk() - { - $book = new Book(); - $book->setTitle("Test Book"); - $book->setISBN("TT-EE-SS-TT"); - - $num = 5; - - for ($i=2; $i < $num + 2; $i++) { - $r = new Review(); - $r->setReviewedBy('Hans ' . $num); - $dt = new DateTime("now"); - $dt->modify("-".$i." weeks"); - $r->setReviewDate($dt); - $r->setRecommended(($i % 2) == 0); - $book->addReview($r); - } - - $this->assertEquals($num, $book->countReviews(), "Expected countReviews to return $num"); - $this->assertEquals($num, count($book->getReviews()), "Expected getReviews to return $num reviews"); - - $book->save(); - - BookPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - - $book = BookPeer::retrieveByPK($book->getId()); - $this->assertEquals($num, $book->countReviews(), "Expected countReviews() to return $num (after save)"); - $this->assertEquals($num, count($book->getReviews()), "Expected getReviews() to return $num (after save)"); - - // Now set different criteria and expect different results - $c = new Criteria(); - $c->add(ReviewPeer::RECOMMENDED, false); - $this->assertEquals(floor($num/2), $book->countReviews($c), "Expected " . floor($num/2) . " results from countReviews(recomm=false)"); - - // Change Criteria, run again -- expect different. - $c = new Criteria(); - $c->add(ReviewPeer::RECOMMENDED, true); - $this->assertEquals(ceil($num/2), count($book->getReviews($c)), "Expected " . ceil($num/2) . " results from getReviews(recomm=true)"); - - $this->assertEquals($num, $book->countReviews(), "Expected countReviews to return $num with new empty Criteria"); - } - - /** - * Test copyInto method. - */ - public function testCopyInto_Deep() - { - BookstoreDataPopulator::populate(); - - // Test a "normal" object - $c = new Criteria(); - $c->add(BookPeer::TITLE, 'Harry%', Criteria::LIKE); - - $book = BookPeer::doSelectOne($c); - $reviews = $book->getReviews(); - - $b2 = $book->copy(true); - $this->assertType('Book', $b2); - $this->assertNull($b2->getId()); - - $r2 = $b2->getReviews(); - - $this->assertEquals(count($reviews), count($r2)); - - // Test a one-to-one object - $emp = BookstoreEmployeePeer::doSelectOne(new Criteria()); - $e2 = $emp->copy(true); - - $this->assertType('BookstoreEmployee', $e2); - $this->assertNull($e2->getId()); - - $this->assertEquals($emp->getBookstoreEmployeeAccount()->getLogin(), $e2->getBookstoreEmployeeAccount()->getLogin()); - } - - /** - * Test copying when an object has composite primary key. - * @link http://propel.phpdb.org/trac/ticket/618 - */ - public function testCopy_CompositePK() - { - $br = new BookReader(); - $br->setName("TestReader"); - $br->save(); - $br->copy(); - - $b = new Book(); - $b->setTitle("TestBook"); - $b->setISBN("XX-XX-XX-XX"); - $b->save(); - - $op = new BookOpinion(); - $op->setBookReader($br); - $op->setBook($b); - $op->setRating(10); - $op->setRecommendToFriend(true); - $op->save(); - - - $br2 = $br->copy(true); - - $this->assertNull($br2->getId()); - - $opinions = $br2->getBookOpinions(); - $this->assertEquals(1, count($opinions), "Expected to have a related BookOpinion after copy()"); - - // We DO expect the reader_id to be null - $this->assertNull($opinions[0]->getReaderId()); - // but we DO NOT expect the book_id to be null - $this->assertEquals($op->getBookId(), $opinions[0]->getBookId()); - } - - public function testToArray() - { - $b = new Book(); - $b->setTitle('Don Juan'); - - $arr1 = $b->toArray(); - $expectedKeys = array( - 'Id', - 'Title', - 'ISBN', - 'Price', - 'PublisherId', - 'AuthorId' - ); - $this->assertEquals($expectedKeys, array_keys($arr1), 'toArray() returns an associative array with BasePeer::TYPE_PHPNAME keys by default'); - $this->assertEquals('Don Juan', $arr1['Title'], 'toArray() returns an associative array representation of the object'); - } - - public function testToArrayKeyType() - { - $b = new Book(); - $b->setTitle('Don Juan'); - - $arr1 = $b->toArray(BasePeer::TYPE_COLNAME); - $expectedKeys = array( - BookPeer::ID, - BookPeer::TITLE, - BookPeer::ISBN, - BookPeer::PRICE, - BookPeer::PUBLISHER_ID, - BookPeer::AUTHOR_ID - ); - $this->assertEquals($expectedKeys, array_keys($arr1), 'toArray() accepts a $keyType parameter to change the result keys'); - $this->assertEquals('Don Juan', $arr1[BookPeer::TITLE], 'toArray() returns an associative array representation of the object'); - } - - /** - * Test the toArray() method with new lazyLoad param. - * @link http://propel.phpdb.org/trac/ticket/527 - */ - public function testToArrayLazyLoad() - { - BookstoreDataPopulator::populate(); - - $c = new Criteria(); - $c->add(MediaPeer::COVER_IMAGE, null, Criteria::NOT_EQUAL); - $c->add(MediaPeer::EXCERPT, null, Criteria::NOT_EQUAL); - - $m = MediaPeer::doSelectOne($c); - if ($m === null) { - $this->fail("Test requires at least one media row w/ cover_image and excerpt NOT NULL"); - } - - $arr1 = $m->toArray(BasePeer::TYPE_COLNAME); - $this->assertNotNull($arr1[MediaPeer::COVER_IMAGE]); - $this->assertType('resource', $arr1[MediaPeer::COVER_IMAGE]); - - $arr2 = $m->toArray(BasePeer::TYPE_COLNAME, false); - $this->assertNull($arr2[MediaPeer::COVER_IMAGE]); - $this->assertNull($arr2[MediaPeer::EXCERPT]); - - $diffKeys = array_keys(array_diff($arr1, $arr2)); - - $expectedDiff = array(MediaPeer::COVER_IMAGE, MediaPeer::EXCERPT); - - $this->assertEquals($expectedDiff, $diffKeys); - } - - public function testToArrayIncludeForeignObjects() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - PublisherPeer::clearInstancePool(); - - $c = new Criteria(); - $c->add(BookPeer::TITLE, 'Don Juan'); - $books = BookPeer::doSelectJoinAuthor($c); - $book = $books[0]; - - $arr1 = $book->toArray(BasePeer::TYPE_PHPNAME, null, true); - $expectedKeys = array( - 'Id', - 'Title', - 'ISBN', - 'Price', - 'PublisherId', - 'AuthorId', - 'Author' - ); - $this->assertEquals($expectedKeys, array_keys($arr1), 'toArray() can return sub arrays for hydrated related objects'); - $this->assertEquals('George', $arr1['Author']['FirstName'], 'toArray() can return sub arrays for hydrated related objects'); - - $c = new Criteria(); - $c->add(BookPeer::TITLE, 'Don Juan'); - $books = BookPeer::doSelectJoinAll($c); - $book = $books[0]; - - $arr2 = $book->toArray(BasePeer::TYPE_PHPNAME, null, true); - $expectedKeys = array( - 'Id', - 'Title', - 'ISBN', - 'Price', - 'PublisherId', - 'AuthorId', - 'Publisher', - 'Author' - ); - $this->assertEquals($expectedKeys, array_keys($arr2), 'toArray() can return sub arrays for hydrated related objects'); - } - - /** - * Test regexp validator for ticket:542 - * @link http://propel.phpdb.org/trac/ticket/542 - */ - public function testRegexValidator() - { - $b = new Bookstore(); - $b->setWebsite("http://this.is.valid.com/foo.bar"); - $res = $b->validate(); - $this->assertTrue($res, "Expected URL to validate"); - } - - /** - * Test that setting the auto-increment primary key will result in exception. - */ - public function testSettingAutoIncrementPK() - { - // The whole test is in a transaction, but this test needs real transactions - $this->con->commit(); - - $b = new Bookstore(); - $b->setId(1); - $b->setStoreName("Test"); - try { - $b->save(); - $this->fail("Expected setting auto-increment primary key to result in Exception"); - } catch (Exception $x) { - $this->assertType('PropelException', $x); - } - - // ... but we should silently ignore NULL values, since these are really - // the same as "not set" in PHP world. - $b = new Bookstore(); - $b->setId(null); - $b->setStoreName("Test2"); - try { - $b->save(); - } catch (Exception $x) { - $this->fail("Expected no exception when setting auto-increment primary key to NULL"); - } - // success ... - - $this->con->beginTransaction(); - } - - /** - * Checks wether we are allowed to specify the primary key on a - * table with allowPkInsert=true set - * - * saves the object, gets it from data-source again and then compares - * them for equality (thus the instance pool is also checked) - */ - public function testAllowPkInsertOnIdMethodNativeTable() - { - $cu = new Customer; - $cu->setPrimaryKey(100000); - $cu->save(); - - $this->assertEquals(100000, $cu->getPrimaryKey()); - - $cu2 = CustomerPeer::retrieveByPk(100000); - - $this->assertSame($cu, $cu2); - } - /** - * Checks if it is allowed to save new, empty objects with a auto increment column - */ - public function testAllowEmptyWithAutoIncrement() - { - $bookreader = new BookReader(); - $bookreader->save(); - - $this->assertFalse($bookreader->isNew() ); - } - - /** - * Test foreign key relationships based on references to unique cols but not PK. - * @link http://propel.phpdb.org/trac/ticket/691 - */ - public function testUniqueFkRel() - { - $employee = new BookstoreEmployee(); - $employee->setName("Johnny Walker"); - - $acct = new BookstoreEmployeeAccount(); - $acct->setBookstoreEmployee($employee); - $acct->setLogin("test-login"); - $acct->save(); - $acctId = $acct->getEmployeeId(); - - $al = new AcctAuditLog(); - $al->setBookstoreEmployeeAccount($acct); - $al->save(); - $alId = $al->getId(); - - BookstoreEmployeePeer::clearInstancePool(); - BookstoreEmployeeAccountPeer::clearInstancePool(); - AcctAuditLogPeer::clearInstancePool(); - - $al2 = AcctAuditLogPeer::retrieveByPK($alId); - /* @var $al2 AcctAuditLog */ - $mapacct = $al2->getBookstoreEmployeeAccount(); - $lookupacct = BookstoreEmployeeAccountPeer::retrieveByPK($acctId); - - $logs = $lookupacct->getAcctAuditLogs(); - - $this->assertTrue(count($logs) == 1, "Expected 1 audit log result."); - $this->assertEquals($logs[0]->getId(), $al->getId(), "Expected returned audit log to match created audit log."); - } - - public function testIsPrimaryKeyNull() - { - $b = new Book(); - $this->assertTrue($b->isPrimaryKeyNull()); - $b->setPrimaryKey(123); - $this->assertFalse($b->isPrimaryKeyNull()); - $b->setPrimaryKey(null); - $this->assertTrue($b->isPrimaryKeyNull()); - } - - public function testIsPrimaryKeyNullCompmosite() - { - $b = new BookOpinion(); - $this->assertTrue($b->isPrimaryKeyNull()); - $b->setPrimaryKey(array(123, 456)); - $this->assertFalse($b->isPrimaryKeyNull()); - $b->setPrimaryKey(array(123, null)); - $this->assertFalse($b->isPrimaryKeyNull()); - $b->setPrimaryKey(array(null, 456)); - $this->assertFalse($b->isPrimaryKeyNull()); - $b->setPrimaryKey(array(null, null)); - $this->assertTrue($b->isPrimaryKeyNull()); - } - - public function testAddPrimaryString() - { - $this->assertFalse(method_exists('Author', '__toString'), 'addPrimaryString() does not add a __toString() method if no column has the primaryString attribute'); - $this->assertTrue(method_exists('Book', '__toString'), 'addPrimaryString() adds a __toString() method if a column has the primaryString attribute'); - $book = new Book(); - $book->setTitle('foo'); - $this->assertEquals((string) $book, 'foo', 'addPrimaryString() adds a __toString() method returning the value of the the first column where primaryString is true'); - } - - public function testPreInsert() - { - $author = new TestAuthor(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); - $author->save(); - $this->assertEquals('PreInsertedFirstname', $author->getFirstName()); - } - - public function testPreUpdate() - { - $author = new TestAuthor(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); - $author->save(); - $author->setNew(false); - $author->save(); - $this->assertEquals('PreUpdatedFirstname', $author->getFirstName()); - } - - public function testPostInsert() - { - $author = new TestAuthor(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); - $author->save(); - $this->assertEquals('PostInsertedLastName', $author->getLastName()); - } - - public function testPostUpdate() - { - $author = new TestAuthor(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); - $author->save(); - $author->setNew(false); - $author->save(); - $this->assertEquals('PostUpdatedLastName', $author->getLastName()); - } - - public function testPreSave() - { - $author = new TestAuthor(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); - $author->save(); - $this->assertEquals('pre@save.com', $author->getEmail()); - } - - public function testPreSaveFalse() - { - $con = Propel::getConnection(AuthorPeer::DATABASE_NAME); - $author = new TestAuthorSaveFalse(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); - $res = $author->save($con); - $this->assertEquals(0, $res); - $this->assertEquals('pre@save.com', $author->getEmail()); - $this->assertNotEquals(115, $author->getAge()); - $this->assertTrue($author->isNew()); - $this->assertEquals(1, $con->getNestedTransactionCount()); - } - - public function testPostSave() - { - $author = new TestAuthor(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); - $author->save(); - $this->assertEquals(115, $author->getAge()); - } - - public function testPreDelete() - { - $author = new TestAuthor(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); - $author->save(); - $author->delete(); - $this->assertEquals("Pre-Deleted", $author->getFirstName()); - } - - public function testPreDeleteFalse() - { - $con = Propel::getConnection(AuthorPeer::DATABASE_NAME); - $author = new TestAuthorDeleteFalse(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); - $author->save($con); - $author->delete($con); - $this->assertEquals("Pre-Deleted", $author->getFirstName()); - $this->assertNotEquals("Post-Deleted", $author->getLastName()); - $this->assertFalse($author->isDeleted()); - $this->assertEquals(1, $con->getNestedTransactionCount()); - } - - public function testPostDelete() - { - $author = new TestAuthor(); - $author->setFirstName("bogus"); - $author->setLastName("Lastname"); - $author->save(); - $author->delete(); - $this->assertEquals("Post-Deleted", $author->getLastName()); - } - - public function testMagicVirtualColumnGetter() - { - $book = new Book(); - $book->setVirtualColumn('Foo', 'bar'); - $this->assertEquals('bar', $book->getFoo(), 'generated __call() catches getters for virtual columns'); - $book = new Book(); - $book->setVirtualColumn('foo', 'bar'); - $this->assertEquals('bar', $book->getFoo(), 'generated __call() catches getters for virtual columns starting with a lowercase character'); - } - - public static function conditionsForTestReadOnly() - { - return array( - array('reload'), - array('delete'), - array('save'), - array('doSave'), - ); - } - - /** - * @dataProvider conditionsForTestReadOnly - */ - public function testReadOnly($method) - { - $cv = new ContestView(); - $this->assertFalse(method_exists($cv, $method), 'readOnly tables end up with no ' . $method . ' method in the generated object class'); - } -} \ No newline at end of file + $b->setBookSummarys($coll); + $b->save(); + + $this->assertEquals(2, $b->getBookSummarys()->count()); + $this->assertEquals(1, BookQuery::create()->count()); + $this->assertEquals(2, BookSummaryQuery::create()->count()); + + $newBookSammary = new BookSummary(); + $newBookSammary->setSummary('My sammary'); + + // Kind of new collection + $coll = clone $coll; + $coll[] = $newBookSammary; + + $b->setBookSummarys($coll); + $b->save(); + + $this->assertEquals(3, $coll->count()); + $this->assertEquals(3, $b->getBookSummarys()->count()); + $this->assertEquals(1, BookQuery::create()->count()); + $this->assertEquals(3, BookSummaryQuery::create()->count()); + + // Add a new object + $newBookSammary1 = new BookSummary(); + $newBookSammary1->setSummary('My sammary 1'); + + // Existing collection - The fix around reference is tested here. + $coll[] = $newBookSammary1; + + $b->setBookSummarys($coll); + $b->save(); + + $this->assertEquals(4, $coll->count()); + $this->assertEquals(4, $b->getBookSummarys()->count()); + $this->assertEquals(1, BookQuery::create()->count()); + $this->assertEquals(4, BookSummaryQuery::create()->count()); + + // Add the same collection + $bookSummaries = $b->getBookSummarys(); + + $b->setBookSummarys($bookSummaries); + $b->save(); + + $this->assertEquals(4, $coll->count()); + $this->assertEquals(4, $b->getBookSummarys()->count()); + $this->assertEquals(1, BookQuery::create()->count()); + $this->assertEquals(4, BookSummaryQuery::create()->count()); + } + + public function testSetterOneToManyWithNoData() + { + // Ensure no data + BookQuery::create()->deleteAll(); + AuthorQuery::create()->deleteAll(); + + $books = new PropelObjectCollection(); + $this->assertEquals(0, $books->count()); + + // Basic usage + $a = new Author(); + $a->setFirstName('Foo'); + $a->setLastName('Bar'); + $a->setBooks($books); + $a->save(); + + $this->assertEquals(0, $a->getBooks()->count()); + $this->assertEquals(1, AuthorQuery::create()->count()); + $this->assertEquals(0, BookQuery::create()->count()); + } + + public function testSetterOneToManySavesForeignObjects() + { + // Ensure no data + BookQuery::create()->deleteAll(); + AuthorQuery::create()->deleteAll(); + + $book = new Book(); + $book->setTitle('My Book'); + $book->setIsbn('1245'); + $book->save(); + + // Modify it but don't save it + $book->setTitle('My Title'); + + $coll = new PropelObjectCollection(); + $coll[] = $book; + + BookPeer::clearInstancePool(); + $book = BookQuery::create()->findPk($book->getPrimaryKey()); + + $a = new Author(); + $a->setFirstName('Foo'); + $a->setLastName('Bar'); + $a->setBooks($coll); + $a->save(); + + $this->assertEquals(1, $a->getBooks()->count()); + $this->assertEquals(1, AuthorQuery::create()->count()); + $this->assertEquals(1, BookQuery::create()->count()); + + $result = BookQuery::create() + ->filterById($book->getId()) + ->select('Title') + ->findOne(); + $this->assertSame('My Title', $result); + } + + public function testSetterOneToManyWithNewObjects() + { + // Ensure no data + BookQuery::create()->deleteAll(); + AuthorQuery::create()->deleteAll(); + + $coll = new PropelObjectCollection(); + $coll->setModel('Book'); + + for ($i = 0; $i < 3; $i++) { + $b = new Book(); + $b->setTitle('Book ' . $i); + $b->setIsbn('124' . $i); + + $coll[] = $b; + } + + $a = new Author(); + $a->setFirstName('Foo'); + $a->setLastName('Bar'); + $a->setBooks($coll); + $a->save(); + + $this->assertEquals(3, $coll->count()); + $this->assertEquals(3, count($a->getBooks())); + $this->assertSame($coll, $a->getBooks()); + $this->assertEquals(1, AuthorQuery::create()->count()); + $this->assertEquals(3, BookQuery::create()->count()); + } + + public function testSetterOneToManyWithExistingObjects() + { + // Ensure no data + BookQuery::create()->deleteAll(); + AuthorQuery::create()->deleteAll(); + + for ($i = 0; $i < 3; $i++) { + $b = new Book(); + $b->setTitle('Book ' . $i); + $b->setIsbn('21234' . $i); + $b->save(); + } + + BookPeer::clearInstancePool(); + $books = BookQuery::create()->find(); + + $a = new Author(); + $a->setFirstName('Foo'); + $a->setLastName('Bar'); + $a->setBooks($books); + $a->save(); + + $this->assertEquals(3, count($a->getBooks())); + $this->assertEquals(1, AuthorQuery::create()->count()); + $this->assertEquals(3, BookQuery::create()->count()); + + $i = 0; + foreach ($a->getBooks() as $book) { + $this->assertEquals('Book ' . $i++, $book->getTitle()); + } + } + + public function testSetterOneToManyWithEmptyCollection() + { + // Ensure no data + BookQuery::create()->deleteAll(); + AuthorQuery::create()->deleteAll(); + + $a = new Author(); + $a->setFirstName('Foo'); + $a->setLastName('Bar'); + $a->setBooks(new PropelObjectCollection()); + $a->save(); + + $this->assertEquals(0, count($a->getBooks())); + + $this->assertEquals(0, BookQuery::create()->count()); + $this->assertEquals(1, AuthorQuery::create()->count()); + } + + public function testSetterOneToManyReplacesOldObjectsByNewObjects() + { + // Ensure no data + BookQuery::create()->deleteAll(); + AuthorQuery::create()->deleteAll(); + + $books = new PropelObjectCollection(); + foreach (array('foo', 'bar') as $title) { + $b = new Book(); + $b->setTitle($title); + $b->setIsbn('12354'); + + $books[] = $b; + } + + $a = new Author(); + $a->setFirstName('Foo'); + $a->setLastName('Bar'); + $a->setBooks($books); + $a->save(); + + $books = $a->getBooks(); + $this->assertEquals('foo', $books[0]->getTitle()); + $this->assertEquals('bar', $books[1]->getTitle()); + + $books = new PropelObjectCollection(); + foreach (array('bam', 'bom') as $title) { + $b = new Book(); + $b->setTitle($title); + $b->setIsbn('1235'); + + $books[] = $b; + } + + $a->setBooks($books); + $a->save(); + + $books = $a->getBooks(); + $this->assertEquals('bam', $books[0]->getTitle()); + $this->assertEquals('bom', $books[1]->getTitle()); + + $this->assertEquals(1, AuthorQuery::create()->count()); + // the replaced book are still there because the PK is not required + $this->assertEquals(4, BookQuery::create()->count()); + } + + public function testSetterOneToManyReplacesOldObjectsByNewObjectsWithFkRequired() + { + // Ensure no data + BookSummaryQuery::create()->deleteAll(); + BookQuery::create()->deleteAll(); + + $bookSummaries = new PropelObjectCollection(); + foreach (array('foo', 'bar') as $summary) { + $s = new BookSummary(); + $s->setSummary($summary); + $bookSummaries[] = $s; + } + + $b = new Book(); + $b->setTitle('Hello'); + $b->setBookSummarys($bookSummaries); + $b->setIsbn('1234'); + $b->save(); + + $bookSummaries = $b->getBookSummarys(); + $this->assertEquals('foo', $bookSummaries[0]->getSummary()); + $this->assertEquals('bar', $bookSummaries[1]->getSummary()); + + $bookSummaries = new PropelObjectCollection(); + foreach (array('bam', 'bom') as $summary) { + $s = new BookSummary(); + $s->setSummary($summary); + $bookSummaries[] = $s; + } + + $b->setBookSummarys($bookSummaries); + $b->save(); + + $bookSummaries = $b->getBookSummarys(); + $this->assertEquals('bam', $bookSummaries[0]->getSummary()); + $this->assertEquals('bom', $bookSummaries[1]->getSummary()); + + $this->assertEquals(1, BookQuery::create()->count()); + $this->assertEquals(2, BookSummaryQuery::create()->count()); + } + + public function testHooksCall() + { + AuthorQuery::create()->deleteAll(); + BookQuery::create()->deleteAll(); + + $author = new CountableAuthor(); + $author->setFirstName('Foo'); + $author->setLastName('Bar'); + + $book = new Book(); + $book->setTitle('A title'); + $book->setIsbn('13456'); + + $author->addBook($book); + $author->save(); + + $this->assertEquals(1, AuthorQuery::create()->count()); + $this->assertEquals(1, BookQuery::create()->count()); + $this->assertEquals(1, $author->nbCallPreSave); + } + + /** + * @expectedException PropelException + */ + public function testDoInsert() + { + if (!class_exists('Unexistent')) { + $schema = << + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $builder->buildClasses(); + } + + $object = new Unexistent(); + $object->setName('Foo'); + $object->save(); + + $this->fail('Should not be called'); + } +} + +class CountableAuthor extends Author +{ + public $nbCallPreSave = 0; + + /** + * {@inheritdoc} + */ + public function preSave(PropelPDO $con = null) + { + $this->nbCallPreSave++; + + return parent::preSave($con); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectWithFixturesTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectWithFixturesTest.php new file mode 100644 index 000000000..3f30c21dd --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectWithFixturesTest.php @@ -0,0 +1,369 @@ + + * @package generator.builder.om + */ +class GeneratedObjectWithFixturesTest extends BookstoreEmptyTestBase +{ + protected function setUp() + { + parent::setUp(); + require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/behavior/TestAuthor.php'; + } + + /** + * Test the reload() method. + */ + public function testReload() + { + BookstoreDataPopulator::populate(); + $a = AuthorPeer::doSelectOne(new Criteria()); + + $origName = $a->getFirstName(); + + $a->setFirstName(md5(time())); + + $this->assertNotEquals($origName, $a->getFirstName()); + $this->assertTrue($a->isModified()); + + $a->reload(); + + $this->assertEquals($origName, $a->getFirstName()); + $this->assertFalse($a->isModified()); + + } + + /** + * Test reload(deep=true) method. + */ + public function testReloadDeep() + { + BookstoreDataPopulator::populate(); + + // arbitrary book + $b = BookPeer::doSelectOne(new Criteria()); + + // arbitrary, different author + $c = new Criteria(); + $c->add(AuthorPeer::ID, $b->getAuthorId(), Criteria::NOT_EQUAL); + $a = AuthorPeer::doSelectOne($c); + + $origAuthor = $b->getAuthor(); + + $b->setAuthor($a); + + $this->assertNotEquals($origAuthor, $b->getAuthor(), "Expected just-set object to be different from obj from DB"); + $this->assertTrue($b->isModified()); + + $b->reload($deep=true); + + $this->assertEquals($origAuthor, $b->getAuthor(), "Expected object in DB to be restored"); + $this->assertFalse($a->isModified()); + } + + /** + * Test deleting an object using the delete() method. + */ + public function testDelete() + { + BookstoreDataPopulator::populate(); + + // 1) grab an arbitrary object + $book = BookPeer::doSelectOne(new Criteria()); + $bookId = $book->getId(); + + // 2) delete it + $book->delete(); + + // 3) make sure it can't be save()d now that it's deleted + try { + $book->setTitle("Will Fail"); + $book->save(); + $this->fail("Expect an exception to be thrown when attempting to save() a deleted object."); + } catch (PropelException $e) {} + + // 4) make sure that it doesn't exist in db + $book = BookPeer::retrieveByPK($bookId); + $this->assertNull($book, "Expect NULL from retrieveByPK on deleted Book."); + + } + + /** + * Tests new one-to-one functionality. + */ + public function testOneToOne() + { + BookstoreDataPopulator::populate(); + + $emp = BookstoreEmployeePeer::doSelectOne(new Criteria()); + + $acct = new BookstoreEmployeeAccount(); + $acct->setBookstoreEmployee($emp); + $acct->setLogin("testuser"); + $acct->setPassword("testpass"); + + $this->assertSame($emp->getBookstoreEmployeeAccount(), $acct, "Expected same object instance."); + } + + /** + * Test the type sensitivity of the returning columns. + * + */ + public function testTypeSensitive() + { + BookstoreDataPopulator::populate(); + + $book = BookPeer::doSelectOne(new Criteria()); + + $r = new Review(); + $r->setReviewedBy("testTypeSensitive Tester"); + $r->setReviewDate(time()); + $r->setBook($book); + $r->setRecommended(true); + $r->save(); + + $id = $r->getId(); + unset($r); + + // clear the instance cache to force reload from database. + ReviewPeer::clearInstancePool(); + BookPeer::clearInstancePool(); + + // reload and verify that the types are the same + $r2 = ReviewPeer::retrieveByPK($id); + + $this->assertInternalType('integer', $r2->getId(), "Expected getId() to return an integer."); + $this->assertInternalType('string', $r2->getReviewedBy(), "Expected getReviewedBy() to return a string."); + $this->assertInternalType('boolean', $r2->getRecommended(), "Expected getRecommended() to return a boolean."); + $this->assertInstanceOf('Book', $r2->getBook(), "Expected getBook() to return a Book."); + $this->assertInternalType('float', $r2->getBook()->getPrice(), "Expected Book->getPrice() to return a float."); + $this->assertInstanceOf('DateTime', $r2->getReviewDate(null), "Expected Book->getReviewDate() to return a DateTime."); + + } + + /** + * This is a test for expected exceptions when saving UNIQUE. + * See http://trac.propelorm.org/ticket/2 + */ + public function testSaveUnique() + { + // The whole test is in a transaction, but this test needs real transactions + $this->con->commit(); + + $emp = new BookstoreEmployee(); + $emp->setName(md5(microtime())); + + $acct = new BookstoreEmployeeAccount(); + $acct->setBookstoreEmployee($emp); + $acct->setLogin("foo"); + $acct->setPassword("bar"); + $acct->save(); + + // now attempt to create a new acct + $acct2 = $acct->copy(); + + try { + $acct2->save(); + $this->fail("Expected PropelException in first attempt to save object with duplicate value for UNIQUE constraint."); + } catch (Exception $x) { + try { + // attempt to save it again + $acct3 = $acct->copy(); + $acct3->save(); + $this->fail("Expected PropelException in second attempt to save object with duplicate value for UNIQUE constraint."); + } catch (Exception $x) { + // this is expected. + } + // now let's double check that it can succeed if we're not violating the constraint. + $acct3->setLogin("foo2"); + $acct3->save(); + } + + $this->con->beginTransaction(); + } + + /** + * Test the BaseObject#equals(). + */ + public function testEquals() + { + BookstoreDataPopulator::populate(); + + $b = BookPeer::doSelectOne(new Criteria()); + $c = new Book(); + $c->setId($b->getId()); + $this->assertTrue($b->equals($c), "Expected Book objects to be equal()"); + + $a = new Author(); + $a->setId($b->getId()); + $this->assertFalse($b->equals($a), "Expected Book and Author with same primary key NOT to match."); + } + + public function testDefaultFkColVal() + { + BookstoreDataPopulator::populate(); + + $sale = new BookstoreSale(); + $this->assertEquals(1, $sale->getBookstoreId(), "Expected BookstoreSale object to have a default bookstore_id of 1."); + + $bookstore = BookstorePeer::doSelectOne(new Criteria()); + + $sale->setBookstore($bookstore); + $this->assertEquals($bookstore->getId(), $sale->getBookstoreId(), "Expected FK id to have changed when assigned a valid FK."); + + $sale->setBookstore(null); + $this->assertEquals(1, $sale->getBookstoreId(), "Expected BookstoreSale object to have reset to default ID."); + + $sale->setPublisher(null); + $this->assertEquals(null, $sale->getPublisherId(), "Expected BookstoreSale object to have reset to NULL publisher ID."); + } + + /** + * Test copyInto method. + */ + public function testCopyInto_Deep() + { + BookstoreDataPopulator::populate(); + + // Test a "normal" object + $c = new Criteria(); + $c->add(BookPeer::TITLE, 'Harry%', Criteria::LIKE); + + $book = BookPeer::doSelectOne($c); + $reviews = $book->getReviews(); + + $b2 = $book->copy(true); + $this->assertInstanceOf('Book', $b2); + $this->assertNull($b2->getId()); + + $r2 = $b2->getReviews(); + + $this->assertEquals(count($reviews), count($r2)); + + // Test a one-to-one object + $emp = BookstoreEmployeePeer::doSelectOne(new Criteria()); + $e2 = $emp->copy(true); + + $this->assertInstanceOf('BookstoreEmployee', $e2); + $this->assertNull($e2->getId()); + + $this->assertEquals($emp->getBookstoreEmployeeAccount()->getLogin(), $e2->getBookstoreEmployeeAccount()->getLogin()); + } + + /** + * Test the toArray() method with new lazyLoad param. + * @link http://trac.propelorm.org/ticket/527 + */ + public function testToArrayLazyLoad() + { + BookstoreDataPopulator::populate(); + + $c = new Criteria(); + $c->add(MediaPeer::COVER_IMAGE, null, Criteria::NOT_EQUAL); + $c->add(MediaPeer::EXCERPT, null, Criteria::NOT_EQUAL); + + $m = MediaPeer::doSelectOne($c); + if ($m === null) { + $this->fail("Test requires at least one media row w/ cover_image and excerpt NOT NULL"); + } + + $arr1 = $m->toArray(BasePeer::TYPE_COLNAME); + $this->assertNotNull($arr1[MediaPeer::COVER_IMAGE]); + $this->assertInternalType('resource', $arr1[MediaPeer::COVER_IMAGE]); + + $arr2 = $m->toArray(BasePeer::TYPE_COLNAME, false); + $this->assertNull($arr2[MediaPeer::COVER_IMAGE]); + $this->assertNull($arr2[MediaPeer::EXCERPT]); + + $diffKeys = array_keys(array_diff($arr1, $arr2)); + + $expectedDiff = array(MediaPeer::COVER_IMAGE, MediaPeer::EXCERPT); + + $this->assertEquals($expectedDiff, $diffKeys); + } + + public function testToArrayIncludesForeignObjects() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + PublisherPeer::clearInstancePool(); + + $c = new Criteria(); + $c->add(BookPeer::TITLE, 'Don Juan'); + $books = BookPeer::doSelectJoinAuthor($c); + $book = $books[0]; + + $arr1 = $book->toArray(BasePeer::TYPE_PHPNAME, null, array(), true); + $expectedKeys = array( + 'Id', + 'Title', + 'ISBN', + 'Price', + 'PublisherId', + 'AuthorId', + 'Author' + ); + $this->assertEquals($expectedKeys, array_keys($arr1), 'toArray() can return sub arrays for hydrated related objects'); + $this->assertEquals('George', $arr1['Author']['FirstName'], 'toArray() can return sub arrays for hydrated related objects'); + + $c = new Criteria(); + $c->add(BookPeer::TITLE, 'Don Juan'); + $books = BookPeer::doSelectJoinAll($c); + $book = $books[0]; + + $arr2 = $book->toArray(BasePeer::TYPE_PHPNAME, null, array(), true); + $expectedKeys = array( + 'Id', + 'Title', + 'ISBN', + 'Price', + 'PublisherId', + 'AuthorId', + 'Publisher', + 'Author' + ); + $this->assertEquals($expectedKeys, array_keys($arr2), 'toArray() can return sub arrays for hydrated related objects'); + } + + public function testToArrayIncludesForeignReferrers() + { + $a1 = new Author(); + $a1->setFirstName('Leo'); + $a1->setLastName('Tolstoi'); + $arr = $a1->toArray(BasePeer::TYPE_PHPNAME, null, array(), true); + $this->assertFalse(array_key_exists('Books', $arr)); + $b1 = new Book(); + $b1->setTitle('War and Peace'); + $b2 = new Book(); + $b2->setTitle('Anna Karenina'); + $a1->addBook($b1); + $a1->addBook($b2); + $arr = $a1->toArray(BasePeer::TYPE_PHPNAME, null, array(), true); + $this->assertTrue(array_key_exists('Books', $arr)); + $this->assertEquals(2, count($arr['Books'])); + $this->assertEquals('War and Peace', $arr['Books']['Book_0']['Title']); + $this->assertEquals('Anna Karenina', $arr['Books']['Book_1']['Title']); + $this->assertEquals('*RECURSION*', $arr['Books']['Book_0']['Author']); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectWithInterfaceTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectWithInterfaceTest.php new file mode 100644 index 000000000..f593faa78 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedObjectWithInterfaceTest.php @@ -0,0 +1,46 @@ + + + + +
+ + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $builder->buildClasses(); + } + } + + public function testClassHasInterface() + { + $this->assertInstanceOf('Foo\MyInterface', new \Foo\MyClassWithInterface()); + } + + public function testClassHasDefaultInterface() + { + $this->assertInstanceOf('Persistent', new \Foo\MyClassWithoutInterface()); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerDoDeleteTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerDoDeleteTest.php index b68a53ba4..76b8847c9 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerDoDeleteTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerDoDeleteTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Tests the delete methods of the generated Peer classes. @@ -16,7 +16,7 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; * This test uses generated Bookstore classes to test the behavior of various * peer operations. * - * The database is relaoded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same * for each test method in this class. See the BookstoreDataPopulator::populate() * method for the exact contents of the database. @@ -27,519 +27,519 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; */ class GeneratedPeerDoDeleteTest extends BookstoreEmptyTestBase { - protected function setUp() - { - parent::setUp(); - BookstoreDataPopulator::populate(); - } - - /** - * Test ability to delete multiple rows via single Criteria object. - */ - public function testDoDelete_MultiTable() { - - $selc = new Criteria(); - $selc->add(BookPeer::TITLE, "Harry Potter and the Order of the Phoenix"); - $hp = BookPeer::doSelectOne($selc); - - // print "Attempting to delete [multi-table] by found pk: "; - $c = new Criteria(); - $c->add(BookPeer::ID, $hp->getId()); - // The only way for multi-delete to work currently - // is to specify the author_id and publisher_id (i.e. the fkeys - // have to be in the criteria). - $c->add(AuthorPeer::ID, $hp->getAuthorId()); - $c->add(PublisherPeer::ID, $hp->getPublisherId()); - $c->setSingleRecord(true); - BookPeer::doDelete($c); - - //print_r(AuthorPeer::doSelect(new Criteria())); - - // check to make sure the right # of records was removed - $this->assertEquals(3, count(AuthorPeer::doSelect(new Criteria())), "Expected 3 authors after deleting."); - $this->assertEquals(3, count(PublisherPeer::doSelect(new Criteria())), "Expected 3 publishers after deleting."); - $this->assertEquals(3, count(BookPeer::doSelect(new Criteria())), "Expected 3 books after deleting."); - } - - /** - * Test using a complex criteria to delete multiple rows from a single table. - */ - public function testDoDelete_ComplexCriteria() { - - //print "Attempting to delete books by complex criteria: "; - $c = new Criteria(); - $cn = $c->getNewCriterion(BookPeer::ISBN, "043935806X"); - $cn->addOr($c->getNewCriterion(BookPeer::ISBN, "0380977427")); - $cn->addOr($c->getNewCriterion(BookPeer::ISBN, "0140422161")); - $c->add($cn); - BookPeer::doDelete($c); + protected function setUp() + { + parent::setUp(); + BookstoreDataPopulator::populate(); + } + + /** + * Test ability to delete multiple rows via single Criteria object. + */ + public function testDoDelete_MultiTable() + { + $selc = new Criteria(); + $selc->add(BookPeer::TITLE, "Harry Potter and the Order of the Phoenix"); + $hp = BookPeer::doSelectOne($selc); + + // print "Attempting to delete [multi-table] by found pk: "; + $c = new Criteria(); + $c->add(BookPeer::ID, $hp->getId()); + // The only way for multi-delete to work currently + // is to specify the author_id and publisher_id (i.e. the fkeys + // have to be in the criteria). + $c->add(AuthorPeer::ID, $hp->getAuthorId()); + $c->add(PublisherPeer::ID, $hp->getPublisherId()); + $c->setSingleRecord(true); + BookPeer::doDelete($c); + + //print_r(AuthorPeer::doSelect(new Criteria())); + + // check to make sure the right # of records was removed + $this->assertEquals(3, count(AuthorPeer::doSelect(new Criteria())), "Expected 3 authors after deleting."); + $this->assertEquals(3, count(PublisherPeer::doSelect(new Criteria())), "Expected 3 publishers after deleting."); + $this->assertEquals(3, count(BookPeer::doSelect(new Criteria())), "Expected 3 books after deleting."); + } + + /** + * Test using a complex criteria to delete multiple rows from a single table. + */ + public function testDoDelete_ComplexCriteria() + { + //print "Attempting to delete books by complex criteria: "; + $c = new Criteria(); + $cn = $c->getNewCriterion(BookPeer::ISBN, "043935806X"); + $cn->addOr($c->getNewCriterion(BookPeer::ISBN, "0380977427")); + $cn->addOr($c->getNewCriterion(BookPeer::ISBN, "0140422161")); + $c->add($cn); + BookPeer::doDelete($c); + + // now there should only be one book left; "The Tin Drum" + + $books = BookPeer::doSelect(new Criteria()); + + $this->assertEquals(1, count($books), "Expected 1 book remaining after deleting."); + $this->assertEquals("The Tin Drum", $books[0]->getTitle(), "Expect the only remaining book to be 'The Tin Drum'"); + } + + /** + * Test that cascading deletes are happening correctly (whether emulated or native). + */ + public function testDoDelete_Cascade_Simple() + { + + // The 'media' table will cascade from book deletes + + // 1) Assert the row exists right now + + $medias = MediaPeer::doSelect(new Criteria()); + $this->assertTrue(count($medias) > 0, "Expected to find at least one row in 'media' table."); + $media = $medias[0]; + $mediaId = $media->getId(); + + // 2) Delete the owning book + + $owningBookId = $media->getBookId(); + BookPeer::doDelete($owningBookId); + + // 3) Assert that the media row is now also gone + + $obj = MediaPeer::retrieveByPK($mediaId); + $this->assertNull($obj, "Expect NULL when retrieving on no matching Media."); + + } + + /** + * Test that cascading deletes are happening correctly for composite pk. + * @link http://trac.propelorm.org/ticket/544 + */ + public function testDoDelete_Cascade_CompositePK() + { + + $origBceCount = BookstoreContestEntryPeer::doCount(new Criteria()); + + $cust1 = new Customer(); + $cust1->setName("Cust1"); + $cust1->save(); + + $cust2 = new Customer(); + $cust2->setName("Cust2"); + $cust2->save(); + + $c1 = new Contest(); + $c1->setName("Contest1"); + $c1->save(); + + $c2 = new Contest(); + $c2->setName("Contest2"); + $c2->save(); + + $store1 = new Bookstore(); + $store1->setStoreName("Store1"); + $store1->save(); - // now there should only be one book left; "The Tin Drum" + $bc1 = new BookstoreContest(); + $bc1->setBookstore($store1); + $bc1->setContest($c1); + $bc1->save(); + + $bc2 = new BookstoreContest(); + $bc2->setBookstore($store1); + $bc2->setContest($c2); + $bc2->save(); - $books = BookPeer::doSelect(new Criteria()); + $bce1 = new BookstoreContestEntry(); + $bce1->setEntryDate("now"); + $bce1->setCustomer($cust1); + $bce1->setBookstoreContest($bc1); + $bce1->save(); - $this->assertEquals(1, count($books), "Expected 1 book remaining after deleting."); - $this->assertEquals("The Tin Drum", $books[0]->getTitle(), "Expect the only remaining book to be 'The Tin Drum'"); - } + $bce2 = new BookstoreContestEntry(); + $bce2->setEntryDate("now"); + $bce2->setCustomer($cust1); + $bce2->setBookstoreContest($bc2); + $bce2->save(); - /** - * Test that cascading deletes are happening correctly (whether emulated or native). - */ - public function testDoDelete_Cascade_Simple() - { - - // The 'media' table will cascade from book deletes + // Now, if we remove $bc1, we expect *only* bce1 to be no longer valid. - // 1) Assert the row exists right now - - $medias = MediaPeer::doSelect(new Criteria()); - $this->assertTrue(count($medias) > 0, "Expected to find at least one row in 'media' table."); - $media = $medias[0]; - $mediaId = $media->getId(); + BookstoreContestPeer::doDelete($bc1); - // 2) Delete the owning book + $newCount = BookstoreContestEntryPeer::doCount(new Criteria()); - $owningBookId = $media->getBookId(); - BookPeer::doDelete($owningBookId); + $this->assertEquals($origBceCount + 1, $newCount, "Expected new number of rows in BCE to be orig + 1"); - // 3) Assert that the media row is now also gone + $bcetest = BookstoreContestEntryPeer::retrieveByPK($store1->getId(), $c1->getId(), $cust1->getId()); + $this->assertNull($bcetest, "Expected BCE for store1 to be cascade deleted."); - $obj = MediaPeer::retrieveByPK($mediaId); - $this->assertNull($obj, "Expect NULL when retrieving on no matching Media."); + $bcetest2 = BookstoreContestEntryPeer::retrieveByPK($store1->getId(), $c2->getId(), $cust1->getId()); + $this->assertNotNull($bcetest2, "Expected BCE for store2 to NOT be cascade deleted."); - } + } - /** - * Test that cascading deletes are happening correctly for composite pk. - * @link http://propel.phpdb.org/trac/ticket/544 - */ - public function testDoDelete_Cascade_CompositePK() - { - - $origBceCount = BookstoreContestEntryPeer::doCount(new Criteria()); - - $cust1 = new Customer(); - $cust1->setName("Cust1"); - $cust1->save(); - - $cust2 = new Customer(); - $cust2->setName("Cust2"); - $cust2->save(); - - $c1 = new Contest(); - $c1->setName("Contest1"); - $c1->save(); - - $c2 = new Contest(); - $c2->setName("Contest2"); - $c2->save(); - - $store1 = new Bookstore(); - $store1->setStoreName("Store1"); - $store1->save(); - - $bc1 = new BookstoreContest(); - $bc1->setBookstore($store1); - $bc1->setContest($c1); - $bc1->save(); - - $bc2 = new BookstoreContest(); - $bc2->setBookstore($store1); - $bc2->setContest($c2); - $bc2->save(); - - $bce1 = new BookstoreContestEntry(); - $bce1->setEntryDate("now"); - $bce1->setCustomer($cust1); - $bce1->setBookstoreContest($bc1); - $bce1->save(); - - $bce2 = new BookstoreContestEntry(); - $bce2->setEntryDate("now"); - $bce2->setCustomer($cust1); - $bce2->setBookstoreContest($bc2); - $bce2->save(); - - // Now, if we remove $bc1, we expect *only* bce1 to be no longer valid. - - BookstoreContestPeer::doDelete($bc1); - - $newCount = BookstoreContestEntryPeer::doCount(new Criteria()); - - $this->assertEquals($origBceCount + 1, $newCount, "Expected new number of rows in BCE to be orig + 1"); - - $bcetest = BookstoreContestEntryPeer::retrieveByPK($store1->getId(), $c1->getId(), $cust1->getId()); - $this->assertNull($bcetest, "Expected BCE for store1 to be cascade deleted."); - - $bcetest2 = BookstoreContestEntryPeer::retrieveByPK($store1->getId(), $c2->getId(), $cust1->getId()); - $this->assertNotNull($bcetest2, "Expected BCE for store2 to NOT be cascade deleted."); - - } - - /** - * Test that onDelete="SETNULL" is happening correctly (whether emulated or native). - */ - public function testDoDelete_SetNull() { - - // The 'author_id' column in 'book' table will be set to null when author is deleted. - - // 1) Get an arbitrary book - $c = new Criteria(); - $book = BookPeer::doSelectOne($c); - $bookId = $book->getId(); - $authorId = $book->getAuthorId(); - unset($book); - - // 2) Delete the author for that book - AuthorPeer::doDelete($authorId); - - // 3) Assert that the book.author_id column is now NULL - - $book = BookPeer::retrieveByPK($bookId); - $this->assertNull($book->getAuthorId(), "Expect the book.author_id to be NULL after the author was removed."); - - } - - /** - * Test deleting a row by passing in the primary key to the doDelete() method. - */ - public function testDoDelete_ByPK() { - - // 1) get an arbitrary book - $book = BookPeer::doSelectOne(new Criteria()); - $bookId = $book->getId(); - - // 2) now delete that book - BookPeer::doDelete($bookId); - - // 3) now make sure it's gone - $obj = BookPeer::retrieveByPK($bookId); - $this->assertNull($obj, "Expect NULL when retrieving on no matching Book."); - - } - - public function testDoDelete_ByPks() { - // 1) get all of the books - $books = BookPeer::doSelect(new Criteria()); - $bookCount = count($books); - - // 2) we have enough books to do this test - $this->assertGreaterThan(1, $bookCount, 'There are at least two books'); - - // 3) select two random books - $book1 = $books[0]; - $book2 = $books[1]; - - // 4) delete the books - BookPeer::doDelete(array($book1->getId(), $book2->getId())); - - // 5) we should have two less books than before - $this->assertEquals($bookCount-2, BookPeer::doCount(new Criteria()), 'Two books deleted successfully.'); - } - - /** - * Test deleting a row by passing the generated object to doDelete(). - */ - public function testDoDelete_ByObj() { - - // 1) get an arbitrary book - $book = BookPeer::doSelectOne(new Criteria()); - $bookId = $book->getId(); - - // 2) now delete that book - BookPeer::doDelete($book); - - // 3) now make sure it's gone - $obj = BookPeer::retrieveByPK($bookId); - $this->assertNull($obj, "Expect NULL when retrieving on no matching Book."); - - } - - - /** - * Test the doDeleteAll() method for single table. - */ - public function testDoDeleteAll() { - - BookPeer::doDeleteAll(); - $this->assertEquals(0, count(BookPeer::doSelect(new Criteria())), "Expect all book rows to have been deleted."); - } - - /** - * Test the state of the instance pool after a doDeleteAll() call. - */ - public function testDoDeleteAllInstancePool() - { - $review = ReviewPeer::doSelectOne(new Criteria); - $book = $review->getBook(); - BookPeer::doDeleteAll(); - $this->assertNull(BookPeer::retrieveByPk($book->getId()), 'doDeleteAll invalidates instance pool'); - $this->assertNull(ReviewPeer::retrieveByPk($review->getId()), 'doDeleteAll invalidates instance pool of releted tables with ON DELETE CASCADE'); - } - - /** - * Test the doDeleteAll() method when onDelete="CASCADE". - */ - public function testDoDeleteAll_Cascade() { - - BookPeer::doDeleteAll(); - $this->assertEquals(0, count(MediaPeer::doSelect(new Criteria())), "Expect all media rows to have been cascade deleted."); - $this->assertEquals(0, count(ReviewPeer::doSelect(new Criteria())), "Expect all review rows to have been cascade deleted."); - } - - /** - * Test the doDeleteAll() method when onDelete="SETNULL". - */ - public function testDoDeleteAll_SetNull() { - - $c = new Criteria(); - $c->add(BookPeer::AUTHOR_ID, null, Criteria::NOT_EQUAL); - - // 1) make sure there are some books with valid authors - $this->assertTrue(count(BookPeer::doSelect($c)) > 0, "Expect some book.author_id columns that are not NULL."); - - // 2) delete all the authors - AuthorPeer::doDeleteAll(); - - // 3) now verify that the book.author_id columns are all nul - $this->assertEquals(0, count(BookPeer::doSelect($c)), "Expect all book.author_id columns to be NULL."); - } - - /** - * @link http://propel.phpdb.org/trac/ticket/519 - */ - public function testDoDeleteCompositePK() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - - ReaderFavoritePeer::doDeleteAll(); - // Create books with IDs 1 to 3 - // Create readers with IDs 1 and 2 - - $this->createBookWithId(1); - $this->createBookWithId(2); - $this->createBookWithId(3); - $this->createReaderWithId(1); - $this->createReaderWithId(2); - - for ($i=1; $i <= 3; $i++) { - for ($j=1; $j <= 2; $j++) { - $bo = new BookOpinion(); - $bo->setBookId($i); - $bo->setReaderId($j); - $bo->save(); - - $rf = new ReaderFavorite(); - $rf->setBookId($i); - $rf->setReaderId($j); - $rf->save(); - } - } - - $this->assertEquals(6, ReaderFavoritePeer::doCount(new Criteria())); - - // Now delete 2 of those rows (2 is special in that it is the number of rows - // being deleted, as well as the number of things in the primary key) - ReaderFavoritePeer::doDelete(array(array(1,1), array(2,2))); - $this->assertEquals(4, ReaderFavoritePeer::doCount(new Criteria())); - - //Note: these composite PK's are pairs of (BookId, ReaderId) - $this->assertNotNull(ReaderFavoritePeer::retrieveByPK(2,1)); - $this->assertNotNull(ReaderFavoritePeer::retrieveByPK(1,2)); - $this->assertNotNull(ReaderFavoritePeer::retrieveByPk(3,1)); - $this->assertNotNull(ReaderFavoritePeer::retrieveByPk(3,2)); - $this->assertNull(ReaderFavoritePeer::retrieveByPK(1,1)); - $this->assertNull(ReaderFavoritePeer::retrieveByPK(2,2)); - - //test deletion of a single composite PK - ReaderFavoritePeer::doDelete(array(3,1)); - $this->assertEquals(3, ReaderFavoritePeer::doCount(new Criteria())); - $this->assertNotNull(ReaderFavoritePeer::retrieveByPK(2,1)); - $this->assertNotNull(ReaderFavoritePeer::retrieveByPK(1,2)); - $this->assertNotNull(ReaderFavoritePeer::retrieveByPk(3,2)); - $this->assertNull(ReaderFavoritePeer::retrieveByPK(1,1)); - $this->assertNull(ReaderFavoritePeer::retrieveByPK(2,2)); - $this->assertNull(ReaderFavoritePeer::retrieveByPk(3,1)); - - //test deleting the last three - ReaderFavoritePeer::doDelete(array(array(2,1), array(1,2), array(3,2))); - $this->assertEquals(0, ReaderFavoritePeer::doCount(new Criteria())); - } - - /** - * Test the doInsert() method when passed a Criteria object. - */ - public function testDoInsert_Criteria() { - - $name = "A Sample Publisher - " . time(); - - $values = new Criteria(); - $values->add(PublisherPeer::NAME, $name); - PublisherPeer::doInsert($values); - - $c = new Criteria(); - $c->add(PublisherPeer::NAME, $name); - - $matches = PublisherPeer::doSelect($c); - $this->assertEquals(1, count($matches), "Expect there to be exactly 1 publisher just-inserted."); - $this->assertTrue( 1 != $matches[0]->getId(), "Expected to have different ID than one put in values Criteria."); - - } - - /** - * Test the doInsert() method when passed a generated object. - */ - public function testDoInsert_Obj() { - - $name = "A Sample Publisher - " . time(); - - $values = new Publisher(); - $values->setName($name); - PublisherPeer::doInsert($values); - - $c = new Criteria(); - $c->add(PublisherPeer::NAME, $name); - - $matches = PublisherPeer::doSelect($c); - $this->assertEquals(1, count($matches), "Expect there to be exactly 1 publisher just-inserted."); - $this->assertTrue( 1 != $matches[0]->getId(), "Expected to have different ID than one put in values Criteria."); - - } - - /** - * Tests the return type of doCount*() methods. - */ - public function testDoCountType() - { - $c = new Criteria(); - $this->assertType('integer', BookPeer::doCount($c), "Expected doCount() to return an integer."); - $this->assertType('integer', BookPeer::doCountJoinAll($c), "Expected doCountJoinAll() to return an integer."); - $this->assertType('integer', BookPeer::doCountJoinAuthor($c), "Expected doCountJoinAuthor() to return an integer."); - } - - /** - * Tests the doCount() method with limit/offset. - */ - public function testDoCountLimitOffset() - { - BookPeer::doDeleteAll(); - - for ($i=0; $i < 25; $i++) { - $b = new Book(); - $b->setTitle("Book $i"); - $b->setISBN("ISBN $i"); - $b->save(); - } - - $c = new Criteria(); - $totalCount = BookPeer::doCount($c); - - $this->assertEquals(25, $totalCount); - - $c2 = new Criteria(); - $c2->setLimit(10); - $this->assertEquals(10, BookPeer::doCount($c2)); - - $c3 = new Criteria(); - $c3->setOffset(10); - $this->assertEquals(15, BookPeer::doCount($c3)); - - $c4 = new Criteria(); - $c4->setOffset(5); - $c4->setLimit(5); - $this->assertEquals(5, BookPeer::doCount($c4)); - - $c5 = new Criteria(); - $c5->setOffset(20); - $c5->setLimit(10); - $this->assertEquals(5, BookPeer::doCount($c5)); - } - - /** - * Test doCountJoin*() methods. - */ - public function testDoCountJoin() - { - BookPeer::doDeleteAll(); - - for ($i=0; $i < 25; $i++) { - $b = new Book(); - $b->setTitle("Book $i"); - $b->setISBN("ISBN $i"); - $b->save(); - } - - $c = new Criteria(); - $totalCount = BookPeer::doCount($c); - - $this->assertEquals($totalCount, BookPeer::doCountJoinAuthor($c)); - $this->assertEquals($totalCount, BookPeer::doCountJoinPublisher($c)); - } - - /** - * Test doCountJoin*() methods with ORDER BY columns in Criteria. - * @link http://propel.phpdb.org/trac/ticket/627 - */ - public function testDoCountJoinWithOrderBy() - { - $c = new Criteria(BookPeer::DATABASE_NAME); - $c->addAscendingOrderByColumn(BookPeer::ID); - - // None of these should not throw an exception! - BookPeer::doCountJoinAll($c); - BookPeer::doCountJoinAllExceptAuthor($c); - BookPeer::doCountJoinAuthor($c); - } - - /** - * Test passing null values to removeInstanceFromPool(). - */ - public function testRemoveInstanceFromPool_Null() - { - // if it throws an exception, then it's broken. - try { - BookPeer::removeInstanceFromPool(null); - } catch (Exception $x) { - $this->fail("Expected to get no exception when removing an instance from the pool."); - } - } - - /** - * @see testDoDeleteCompositePK() - */ - private function createBookWithId($id) - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $b = BookPeer::retrieveByPK($id); - if (!$b) { - $b = new Book(); - $b->setTitle("Book$id")->setISBN("BookISBN$id")->save(); - $b1Id = $b->getId(); - $sql = "UPDATE " . BookPeer::TABLE_NAME . " SET id = ? WHERE id = ?"; - $stmt = $con->prepare($sql); - $stmt->bindValue(1, $id); - $stmt->bindValue(2, $b1Id); - $stmt->execute(); - } - } - - /** - * @see testDoDeleteCompositePK() - */ - private function createReaderWithId($id) - { - $con = Propel::getConnection(BookReaderPeer::DATABASE_NAME); - $r = BookReaderPeer::retrieveByPK($id); - if (!$r) { - $r = new BookReader(); - $r->setName('Reader'.$id)->save(); - $r1Id = $r->getId(); - $sql = "UPDATE " . BookReaderPeer::TABLE_NAME . " SET id = ? WHERE id = ?"; - $stmt = $con->prepare($sql); - $stmt->bindValue(1, $id); - $stmt->bindValue(2, $r1Id); - $stmt->execute(); - } - } + /** + * Test that onDelete="SETNULL" is happening correctly (whether emulated or native). + */ + public function testDoDelete_SetNull() + { + // The 'author_id' column in 'book' table will be set to null when author is deleted. + + // 1) Get an arbitrary book + $c = new Criteria(); + $book = BookPeer::doSelectOne($c); + $bookId = $book->getId(); + $authorId = $book->getAuthorId(); + unset($book); + + // 2) Delete the author for that book + AuthorPeer::doDelete($authorId); + + // 3) Assert that the book.author_id column is now NULL + + $book = BookPeer::retrieveByPK($bookId); + $this->assertNull($book->getAuthorId(), "Expect the book.author_id to be NULL after the author was removed."); + + } + + /** + * Test deleting a row by passing in the primary key to the doDelete() method. + */ + public function testDoDelete_ByPK() + { + // 1) get an arbitrary book + $book = BookPeer::doSelectOne(new Criteria()); + $bookId = $book->getId(); + + // 2) now delete that book + BookPeer::doDelete($bookId); + + // 3) now make sure it's gone + $obj = BookPeer::retrieveByPK($bookId); + $this->assertNull($obj, "Expect NULL when retrieving on no matching Book."); + + } + + public function testDoDelete_ByPks() + { + // 1) get all of the books + $books = BookPeer::doSelect(new Criteria()); + $bookCount = count($books); + + // 2) we have enough books to do this test + $this->assertGreaterThan(1, $bookCount, 'There are at least two books'); + + // 3) select two random books + $book1 = $books[0]; + $book2 = $books[1]; + + // 4) delete the books + BookPeer::doDelete(array($book1->getId(), $book2->getId())); + + // 5) we should have two less books than before + $this->assertEquals($bookCount-2, BookPeer::doCount(new Criteria()), 'Two books deleted successfully.'); + } + + /** + * Test deleting a row by passing the generated object to doDelete(). + */ + public function testDoDelete_ByObj() + { + // 1) get an arbitrary book + $book = BookPeer::doSelectOne(new Criteria()); + $bookId = $book->getId(); + + // 2) now delete that book + BookPeer::doDelete($book); + + // 3) now make sure it's gone + $obj = BookPeer::retrieveByPK($bookId); + $this->assertNull($obj, "Expect NULL when retrieving on no matching Book."); + + } + + /** + * Test the doDeleteAll() method for single table. + */ + public function testDoDeleteAll() + { + BookPeer::doDeleteAll(); + $this->assertEquals(0, count(BookPeer::doSelect(new Criteria())), "Expect all book rows to have been deleted."); + } + + /** + * Test the state of the instance pool after a doDeleteAll() call. + */ + public function testDoDeleteAllInstancePool() + { + $review = ReviewPeer::doSelectOne(new Criteria); + $book = $review->getBook(); + BookPeer::doDeleteAll(); + $this->assertNull(BookPeer::retrieveByPk($book->getId()), 'doDeleteAll invalidates instance pool'); + $this->assertNull(ReviewPeer::retrieveByPk($review->getId()), 'doDeleteAll invalidates instance pool of related tables with ON DELETE CASCADE'); + } + + /** + * Test the doDeleteAll() method when onDelete="CASCADE". + */ + public function testDoDeleteAll_Cascade() + { + BookPeer::doDeleteAll(); + $this->assertEquals(0, count(MediaPeer::doSelect(new Criteria())), "Expect all media rows to have been cascade deleted."); + $this->assertEquals(0, count(ReviewPeer::doSelect(new Criteria())), "Expect all review rows to have been cascade deleted."); + } + + /** + * Test the doDeleteAll() method when onDelete="SETNULL". + */ + public function testDoDeleteAll_SetNull() + { + $c = new Criteria(); + $c->add(BookPeer::AUTHOR_ID, null, Criteria::NOT_EQUAL); + + // 1) make sure there are some books with valid authors + $this->assertTrue(count(BookPeer::doSelect($c)) > 0, "Expect some book.author_id columns that are not NULL."); + + // 2) delete all the authors + AuthorPeer::doDeleteAll(); + + // 3) now verify that the book.author_id columns are all nul + $this->assertEquals(0, count(BookPeer::doSelect($c)), "Expect all book.author_id columns to be NULL."); + } + + /** + * @link http://trac.propelorm.org/ticket/519 + */ + public function testDoDeleteCompositePK() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + ReaderFavoritePeer::doDeleteAll(); + // Create books with IDs 1 to 3 + // Create readers with IDs 1 and 2 + + $this->createBookWithId(1); + $this->createBookWithId(2); + $this->createBookWithId(3); + $this->createReaderWithId(1); + $this->createReaderWithId(2); + + for ($i=1; $i <= 3; $i++) { + for ($j=1; $j <= 2; $j++) { + $bo = new BookOpinion(); + $bo->setBookId($i); + $bo->setReaderId($j); + $bo->save(); + + $rf = new ReaderFavorite(); + $rf->setBookId($i); + $rf->setReaderId($j); + $rf->save(); + } + } + + $this->assertEquals(6, ReaderFavoritePeer::doCount(new Criteria())); + + // Now delete 2 of those rows (2 is special in that it is the number of rows + // being deleted, as well as the number of things in the primary key) + ReaderFavoritePeer::doDelete(array(array(1,1), array(2,2))); + $this->assertEquals(4, ReaderFavoritePeer::doCount(new Criteria())); + + //Note: these composite PK's are pairs of (BookId, ReaderId) + $this->assertNotNull(ReaderFavoritePeer::retrieveByPK(2,1)); + $this->assertNotNull(ReaderFavoritePeer::retrieveByPK(1,2)); + $this->assertNotNull(ReaderFavoritePeer::retrieveByPk(3,1)); + $this->assertNotNull(ReaderFavoritePeer::retrieveByPk(3,2)); + $this->assertNull(ReaderFavoritePeer::retrieveByPK(1,1)); + $this->assertNull(ReaderFavoritePeer::retrieveByPK(2,2)); + + //test deletion of a single composite PK + ReaderFavoritePeer::doDelete(array(3,1)); + $this->assertEquals(3, ReaderFavoritePeer::doCount(new Criteria())); + $this->assertNotNull(ReaderFavoritePeer::retrieveByPK(2,1)); + $this->assertNotNull(ReaderFavoritePeer::retrieveByPK(1,2)); + $this->assertNotNull(ReaderFavoritePeer::retrieveByPk(3,2)); + $this->assertNull(ReaderFavoritePeer::retrieveByPK(1,1)); + $this->assertNull(ReaderFavoritePeer::retrieveByPK(2,2)); + $this->assertNull(ReaderFavoritePeer::retrieveByPk(3,1)); + + //test deleting the last three + ReaderFavoritePeer::doDelete(array(array(2,1), array(1,2), array(3,2))); + $this->assertEquals(0, ReaderFavoritePeer::doCount(new Criteria())); + } + + /** + * Test the doInsert() method when passed a Criteria object. + */ + public function testDoInsert_Criteria() + { + $name = "A Sample Publisher - " . time(); + + $values = new Criteria(); + $values->add(PublisherPeer::NAME, $name); + PublisherPeer::doInsert($values); + + $c = new Criteria(); + $c->add(PublisherPeer::NAME, $name); + + $matches = PublisherPeer::doSelect($c); + $this->assertEquals(1, count($matches), "Expect there to be exactly 1 publisher just-inserted."); + $this->assertTrue( 1 != $matches[0]->getId(), "Expected to have different ID than one put in values Criteria."); + + } + + /** + * Test the doInsert() method when passed a generated object. + */ + public function testDoInsert_Obj() + { + $name = "A Sample Publisher - " . time(); + + $values = new Publisher(); + $values->setName($name); + PublisherPeer::doInsert($values); + + $c = new Criteria(); + $c->add(PublisherPeer::NAME, $name); + + $matches = PublisherPeer::doSelect($c); + $this->assertEquals(1, count($matches), "Expect there to be exactly 1 publisher just-inserted."); + $this->assertTrue( 1 != $matches[0]->getId(), "Expected to have different ID than one put in values Criteria."); + + } + + /** + * Tests the return type of doCount*() methods. + */ + public function testDoCountType() + { + $c = new Criteria(); + $this->assertInternalType('integer', BookPeer::doCount($c), "Expected doCount() to return an integer."); + $this->assertInternalType('integer', BookPeer::doCountJoinAll($c), "Expected doCountJoinAll() to return an integer."); + $this->assertInternalType('integer', BookPeer::doCountJoinAuthor($c), "Expected doCountJoinAuthor() to return an integer."); + } + + /** + * Tests the doCount() method with limit/offset. + */ + public function testDoCountLimitOffset() + { + BookPeer::doDeleteAll(); + + for ($i=0; $i < 25; $i++) { + $b = new Book(); + $b->setTitle("Book $i"); + $b->setISBN("ISBN $i"); + $b->save(); + } + + $c = new Criteria(); + $totalCount = BookPeer::doCount($c); + + $this->assertEquals(25, $totalCount); + + $c2 = new Criteria(); + $c2->setLimit(10); + $this->assertEquals(10, BookPeer::doCount($c2)); + + $c3 = new Criteria(); + $c3->setOffset(10); + $this->assertEquals(15, BookPeer::doCount($c3)); + + $c4 = new Criteria(); + $c4->setOffset(5); + $c4->setLimit(5); + $this->assertEquals(5, BookPeer::doCount($c4)); + + $c5 = new Criteria(); + $c5->setOffset(20); + $c5->setLimit(10); + $this->assertEquals(5, BookPeer::doCount($c5)); + } + + /** + * Test doCountJoin*() methods. + */ + public function testDoCountJoin() + { + BookPeer::doDeleteAll(); + + for ($i=0; $i < 25; $i++) { + $b = new Book(); + $b->setTitle("Book $i"); + $b->setISBN("ISBN $i"); + $b->save(); + } + + $c = new Criteria(); + $totalCount = BookPeer::doCount($c); + + $this->assertEquals($totalCount, BookPeer::doCountJoinAuthor($c)); + $this->assertEquals($totalCount, BookPeer::doCountJoinPublisher($c)); + } + + /** + * Test doCountJoin*() methods with ORDER BY columns in Criteria. + * @link http://trac.propelorm.org/ticket/627 + */ + public function testDoCountJoinWithOrderBy() + { + $c = new Criteria(BookPeer::DATABASE_NAME); + $c->addAscendingOrderByColumn(BookPeer::ID); + + // None of these should not throw an exception! + BookPeer::doCountJoinAll($c); + BookPeer::doCountJoinAllExceptAuthor($c); + BookPeer::doCountJoinAuthor($c); + } + + /** + * Test passing null values to removeInstanceFromPool(). + */ + public function testRemoveInstanceFromPool_Null() + { + // if it throws an exception, then it's broken. + try { + BookPeer::removeInstanceFromPool(null); + } catch (Exception $x) { + $this->fail("Expected to get no exception when removing an instance from the pool."); + } + } + + /** + * @see testDoDeleteCompositePK() + */ + private function createBookWithId($id) + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $b = BookPeer::retrieveByPK($id); + if (!$b) { + $b = new Book(); + $b->setTitle("Book$id")->setISBN("BookISBN$id")->save(); + $b1Id = $b->getId(); + $sql = "UPDATE " . BookPeer::TABLE_NAME . " SET id = ? WHERE id = ?"; + $stmt = $con->prepare($sql); + $stmt->bindValue(1, $id); + $stmt->bindValue(2, $b1Id); + $stmt->execute(); + } + } + + /** + * @see testDoDeleteCompositePK() + */ + private function createReaderWithId($id) + { + $con = Propel::getConnection(BookReaderPeer::DATABASE_NAME); + $r = BookReaderPeer::retrieveByPK($id); + if (!$r) { + $r = new BookReader(); + $r->setName('Reader'.$id)->save(); + $r1Id = $r->getId(); + $sql = "UPDATE " . BookReaderPeer::TABLE_NAME . " SET id = ? WHERE id = ?"; + $stmt = $con->prepare($sql); + $stmt->bindValue(1, $id); + $stmt->bindValue(2, $r1Id); + $stmt->execute(); + } + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerDoSelectTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerDoSelectTest.php index e6be9d3f6..85acaf0d1 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerDoSelectTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerDoSelectTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Tests the generated Peer classes. @@ -16,7 +16,7 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; * This test uses generated Bookstore classes to test the behavior of various * peer operations. * - * The database is relaoded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same * for each test method in this class. See the BookstoreDataPopulator::populate() * method for the exact contents of the database. @@ -27,413 +27,411 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; */ class GeneratedPeerDoSelectTest extends BookstoreEmptyTestBase { - protected function setUp() - { - parent::setUp(); - BookstoreDataPopulator::populate(); - } + protected function setUp() + { + parent::setUp(); + BookstoreDataPopulator::populate(); + } - public function testDoSelect() - { - $books = BookPeer::doSelect(new Criteria()); - $this->assertEquals(4, count($books), 'doSelect() with an empty Criteria returns all results'); - $book1 = $books[0]; - - $c = new Criteria(); - $c->add(BookPeer::ID, $book1->getId()); - $res = BookPeer::doSelect($c); - $this->assertEquals(array($book1), $res, 'doSelect() accepts a Criteria object with a condition'); - - $c = new Criteria(); - $c->add(BookPeer::ID, $book1->getId()); - $c->add(BookPeer::TITLE, $book1->getTitle()); - $res = BookPeer::doSelect($c); - $this->assertEquals(array($book1), $res, 'doSelect() accepts a Criteria object with several condition'); - - $c = new Criteria(); - $c->add(BookPeer::ID, 'foo'); - $res = BookPeer::doSelect($c); - $this->assertEquals(array(), $res, 'doSelect() accepts an incorrect Criteria'); - } - - /** - * Tests performing doSelect() and doSelectJoin() using LIMITs. - */ - public function testDoSelect_Limit() { + public function testDoSelect() + { + $books = BookPeer::doSelect(new Criteria()); + $this->assertEquals(4, count($books), 'doSelect() with an empty Criteria returns all results'); + $book1 = $books[0]; - // 1) get the total number of items in a particular table - $count = BookPeer::doCount(new Criteria()); + $c = new Criteria(); + $c->add(BookPeer::ID, $book1->getId()); + $res = BookPeer::doSelect($c); + $this->assertEquals(array($book1), $res, 'doSelect() accepts a Criteria object with a condition'); - $this->assertTrue($count > 1, "Need more than 1 record in books table to perform this test."); + $c = new Criteria(); + $c->add(BookPeer::ID, $book1->getId()); + $c->add(BookPeer::TITLE, $book1->getTitle()); + $res = BookPeer::doSelect($c); + $this->assertEquals(array($book1), $res, 'doSelect() accepts a Criteria object with several condition'); - $limitcount = $count - 1; + $c = new Criteria(); + $c->add(BookPeer::ID, 'foo'); + $res = BookPeer::doSelect($c); + $this->assertEquals(array(), $res, 'doSelect() accepts an incorrect Criteria'); + } - $lc = new Criteria(); - $lc->setLimit($limitcount); + /** + * Tests performing doSelect() and doSelectJoin() using LIMITs. + */ + public function testDoSelect_Limit() + { + // 1) get the total number of items in a particular table + $count = BookPeer::doCount(new Criteria()); - $results = BookPeer::doSelect($lc); + $this->assertTrue($count > 1, "Need more than 1 record in books table to perform this test."); - $this->assertEquals($limitcount, count($results), "Expected $limitcount results from BookPeer::doSelect()"); + $limitcount = $count - 1; - // re-create it just to avoid side-effects - $lc2 = new Criteria(); - $lc2->setLimit($limitcount); - $results2 = BookPeer::doSelectJoinAuthor($lc2); + $lc = new Criteria(); + $lc->setLimit($limitcount); - $this->assertEquals($limitcount, count($results2), "Expected $limitcount results from BookPeer::doSelectJoinAuthor()"); + $results = BookPeer::doSelect($lc); - } + $this->assertEquals($limitcount, count($results), "Expected $limitcount results from BookPeer::doSelect()"); - /** - * Test the basic functionality of the doSelectJoin*() methods. - */ - public function testDoSelectJoin() - { + // re-create it just to avoid side-effects + $lc2 = new Criteria(); + $lc2->setLimit($limitcount); + $results2 = BookPeer::doSelectJoinAuthor($lc2); - BookPeer::clearInstancePool(); + $this->assertEquals($limitcount, count($results2), "Expected $limitcount results from BookPeer::doSelectJoinAuthor()"); - $c = new Criteria(); + } - $books = BookPeer::doSelect($c); - $obj = $books[0]; - // $size = strlen(serialize($obj)); - - BookPeer::clearInstancePool(); + /** + * Test the basic functionality of the doSelectJoin*() methods. + */ + public function testDoSelectJoin() + { - $joinBooks = BookPeer::doSelectJoinAuthor($c); - $obj2 = $joinBooks[0]; - $obj2Array = $obj2->toArray(BasePeer::TYPE_PHPNAME, true, true); - // $joinSize = strlen(serialize($obj2)); + BookPeer::clearInstancePool(); - $this->assertEquals(count($books), count($joinBooks), "Expected to find same number of rows in doSelectJoin*() call as doSelect() call."); - - // $this->assertTrue($joinSize > $size, "Expected a serialized join object to be larger than a non-join object."); - - $this->assertTrue(array_key_exists('Author', $obj2Array)); - } + $c = new Criteria(); - /** - * Test the doSelectJoin*() methods when the related object is NULL. - */ - public function testDoSelectJoin_NullFk() - { - $b1 = new Book(); - $b1->setTitle("Test NULLFK 1"); - $b1->setISBN("NULLFK-1"); - $b1->save(); + $books = BookPeer::doSelect($c); + $obj = $books[0]; + // $size = strlen(serialize($obj)); - $b2 = new Book(); - $b2->setTitle("Test NULLFK 2"); - $b2->setISBN("NULLFK-2"); - $b2->setAuthor(new Author()); - $b2->getAuthor()->setFirstName("Hans")->setLastName("L"); - $b2->save(); + BookPeer::clearInstancePool(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); + $joinBooks = BookPeer::doSelectJoinAuthor($c); + $obj2 = $joinBooks[0]; + $obj2Array = $obj2->toArray(BasePeer::TYPE_PHPNAME, true, array(), true); + // $joinSize = strlen(serialize($obj2)); - $c = new Criteria(); - $c->add(BookPeer::ISBN, 'NULLFK-%', Criteria::LIKE); - $c->addAscendingOrderByColumn(BookPeer::ISBN); + $this->assertEquals(count($books), count($joinBooks), "Expected to find same number of rows in doSelectJoin*() call as doSelect() call."); - $matches = BookPeer::doSelectJoinAuthor($c); - $this->assertEquals(2, count($matches), "Expected 2 matches back from new books; got back " . count($matches)); + // $this->assertTrue($joinSize > $size, "Expected a serialized join object to be larger than a non-join object."); - $this->assertNull($matches[0]->getAuthor(), "Expected first book author to be null"); - $this->assertType('Author', $matches[1]->getAuthor(), "Expected valid Author object for second book."); - } + $this->assertTrue(array_key_exists('Author', $obj2Array)); + } - public function testDoSelectJoinOneToOne() - { - $con = Propel::getConnection(); - $count = $con->getQueryCount(); - Propel::disableInstancePooling(); - $c = new Criteria(); - $accs = BookstoreEmployeeAccountPeer::doSelectJoinBookstoreEmployee($c); - Propel::enableInstancePooling(); - $this->assertEquals(1, $con->getQueryCount() - $count, 'doSelectJoin() makes only one query in a one-to-one relationship'); - } - - public function testDoSelectOne() - { - $books = BookPeer::doSelect(new Criteria()); - $book1 = $books[0]; - - $c = new Criteria(); - $c->add(BookPeer::ID, $book1->getId()); - $res = BookPeer::doSelectOne($c); - $this->assertEquals($book1, $res, 'doSelectOne() returns a single object'); - - $c = new Criteria(); - $c->add(BookPeer::ID, 'foo'); - $res = BookPeer::doSelectOne($c); - $this->assertNull($res, 'doSelectOne() returns null if the Criteria matches no record'); - } - - public function testObjectInstances() - { + /** + * Test the doSelectJoin*() methods when the related object is NULL. + */ + public function testDoSelectJoin_NullFk() + { + $b1 = new Book(); + $b1->setTitle("Test NULLFK 1"); + $b1->setISBN("NULLFK-1"); + $b1->save(); - $sample = BookPeer::doSelectOne(new Criteria()); - $samplePk = $sample->getPrimaryKey(); + $b2 = new Book(); + $b2->setTitle("Test NULLFK 2"); + $b2->setISBN("NULLFK-2"); + $b2->setAuthor(new Author()); + $b2->getAuthor()->setFirstName("Hans")->setLastName("L"); + $b2->save(); - // 1) make sure consecutive calls to retrieveByPK() return the same object. + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); - $b1 = BookPeer::retrieveByPK($samplePk); - $b2 = BookPeer::retrieveByPK($samplePk); + $c = new Criteria(); + $c->add(BookPeer::ISBN, 'NULLFK-%', Criteria::LIKE); + $c->addAscendingOrderByColumn(BookPeer::ISBN); - $sampleval = md5(microtime()); + $matches = BookPeer::doSelectJoinAuthor($c); + $this->assertEquals(2, count($matches), "Expected 2 matches back from new books; got back " . count($matches)); - $this->assertTrue($b1 === $b2, "Expected object instances to match for calls with same retrieveByPK() method signature."); + $this->assertNull($matches[0]->getAuthor(), "Expected first book author to be null"); + $this->assertInstanceOf('Author', $matches[1]->getAuthor(), "Expected valid Author object for second book."); + } - // 2) make sure that calls to doSelect also return references to the same objects. - $allbooks = BookPeer::doSelect(new Criteria()); - foreach ($allbooks as $testb) { - if ($testb->getPrimaryKey() == $b1->getPrimaryKey()) { - $this->assertTrue($testb === $b1, "Expected same object instance from doSelect() as from retrieveByPK()"); - } - } + public function testDoSelectJoinOneToOne() + { + $con = Propel::getConnection(); + $count = $con->getQueryCount(); + Propel::disableInstancePooling(); + $c = new Criteria(); + $accs = BookstoreEmployeeAccountPeer::doSelectJoinBookstoreEmployee($c); + Propel::enableInstancePooling(); + $this->assertEquals(1, $con->getQueryCount() - $count, 'doSelectJoin() makes only one query in a one-to-one relationship'); + } - // 3) test fetching related objects - $book = BookPeer::retrieveByPK($samplePk); + public function testDoSelectOne() + { + $books = BookPeer::doSelect(new Criteria()); + $book1 = $books[0]; - $bookauthor = $book->getAuthor(); + $c = new Criteria(); + $c->add(BookPeer::ID, $book1->getId()); + $res = BookPeer::doSelectOne($c); + $this->assertEquals($book1, $res, 'doSelectOne() returns a single object'); - $author = AuthorPeer::retrieveByPK($bookauthor->getId()); + $c = new Criteria(); + $c->add(BookPeer::ID, 'foo'); + $res = BookPeer::doSelectOne($c); + $this->assertNull($res, 'doSelectOne() returns null if the Criteria matches no record'); + } - $this->assertTrue($bookauthor === $author, "Expected same object instance when calling fk object accessor as retrieveByPK()"); + public function testObjectInstances() + { - // 4) test a doSelectJoin() - $morebooks = BookPeer::doSelectJoinAuthor(new Criteria()); - for ($i=0,$j=0; $j < count($morebooks); $i++, $j++) { - $testb1 = $allbooks[$i]; - $testb2 = $allbooks[$j]; - $this->assertTrue($testb1 === $testb2, "Expected the same objects from consecutive doSelect() calls."); - // we could probably also test this by just verifying that $book & $testb are the same - if ($testb1->getPrimaryKey() === $book) { - $this->assertTrue($book->getAuthor() === $testb1->getAuthor(), "Expected same author object in calls to pkey-matching books."); - } - } + $sample = BookPeer::doSelectOne(new Criteria()); + $samplePk = $sample->getPrimaryKey(); + // 1) make sure consecutive calls to retrieveByPK() return the same object. - // 5) test creating a new object, saving it, and then retrieving that object (should all be same instance) - $b = new BookstoreEmployee(); - $b->setName("Testing"); - $b->setJobTitle("Testing"); - $b->save(); + $b1 = BookPeer::retrieveByPK($samplePk); + $b2 = BookPeer::retrieveByPK($samplePk); - $empId = $b->getId(); + $sampleval = md5(microtime()); - $this->assertSame($b, BookstoreEmployeePeer::retrieveByPK($empId), "Expected newly saved object to be same instance as pooled."); + $this->assertTrue($b1 === $b2, "Expected object instances to match for calls with same retrieveByPK() method signature."); - } + // 2) make sure that calls to doSelect also return references to the same objects. + $allbooks = BookPeer::doSelect(new Criteria()); + foreach ($allbooks as $testb) { + if ($testb->getPrimaryKey() == $b1->getPrimaryKey()) { + $this->assertTrue($testb === $b1, "Expected same object instance from doSelect() as from retrieveByPK()"); + } + } - /** - * Test inheritance features. - */ - public function testInheritance() - { - $manager = new BookstoreManager(); - $manager->setName("Manager 1"); - $manager->setJobTitle("Warehouse Manager"); - $manager->save(); - $managerId = $manager->getId(); + // 3) test fetching related objects + $book = BookPeer::retrieveByPK($samplePk); - $employee = new BookstoreEmployee(); - $employee->setName("Employee 1"); - $employee->setJobTitle("Janitor"); - $employee->setSupervisorId($managerId); - $employee->save(); - $empId = $employee->getId(); + $bookauthor = $book->getAuthor(); - $cashier = new BookstoreCashier(); - $cashier->setName("Cashier 1"); - $cashier->setJobTitle("Cashier"); - $cashier->save(); - $cashierId = $cashier->getId(); + $author = AuthorPeer::retrieveByPK($bookauthor->getId()); - // 1) test the pooled instances' - $c = new Criteria(); - $c->add(BookstoreEmployeePeer::ID, array($managerId, $empId, $cashierId), Criteria::IN); - $c->addAscendingOrderByColumn(BookstoreEmployeePeer::ID); + $this->assertTrue($bookauthor === $author, "Expected same object instance when calling fk object accessor as retrieveByPK()"); - $objects = BookstoreEmployeePeer::doSelect($c); + // 4) test a doSelectJoin() + $morebooks = BookPeer::doSelectJoinAuthor(new Criteria()); + for ($i=0,$j=0; $j < count($morebooks); $i++, $j++) { + $testb1 = $allbooks[$i]; + $testb2 = $allbooks[$j]; + $this->assertTrue($testb1 === $testb2, "Expected the same objects from consecutive doSelect() calls."); + // we could probably also test this by just verifying that $book & $testb are the same + if ($testb1->getPrimaryKey() === $book) { + $this->assertTrue($book->getAuthor() === $testb1->getAuthor(), "Expected same author object in calls to pkey-matching books."); + } + } - $this->assertEquals(3, count($objects), "Expected 3 objects to be returned."); + // 5) test creating a new object, saving it, and then retrieving that object (should all be same instance) + $b = new BookstoreEmployee(); + $b->setName("Testing"); + $b->setJobTitle("Testing"); + $b->save(); - list($o1, $o2, $o3) = $objects; + $empId = $b->getId(); - $this->assertSame($o1, $manager); - $this->assertSame($o2, $employee); - $this->assertSame($o3, $cashier); + $this->assertSame($b, BookstoreEmployeePeer::retrieveByPK($empId), "Expected newly saved object to be same instance as pooled."); - // 2) test a forced reload from database - BookstoreEmployeePeer::clearInstancePool(); + } - list($o1,$o2,$o3) = BookstoreEmployeePeer::doSelect($c); + /** + * Test inheritance features. + */ + public function testInheritance() + { + $manager = new BookstoreManager(); + $manager->setName("Manager 1"); + $manager->setJobTitle("Warehouse Manager"); + $manager->save(); + $managerId = $manager->getId(); - $this->assertTrue($o1 instanceof BookstoreManager, "Expected BookstoreManager object, got " . get_class($o1)); - $this->assertTrue($o2 instanceof BookstoreEmployee, "Expected BookstoreEmployee object, got " . get_class($o2)); - $this->assertTrue($o3 instanceof BookstoreCashier, "Expected BookstoreCashier object, got " . get_class($o3)); + $employee = new BookstoreEmployee(); + $employee->setName("Employee 1"); + $employee->setJobTitle("Janitor"); + $employee->setSupervisorId($managerId); + $employee->save(); + $empId = $employee->getId(); - } + $cashier = new BookstoreCashier(); + $cashier->setName("Cashier 1"); + $cashier->setJobTitle("Cashier"); + $cashier->save(); + $cashierId = $cashier->getId(); - /** - * Test hydration of joined rows that contain lazy load columns. - * @link http://propel.phpdb.org/trac/ticket/464 - */ - public function testHydrationJoinLazyLoad() - { - BookstoreEmployeeAccountPeer::doDeleteAll(); - BookstoreEmployeePeer::doDeleteAll(); - AcctAccessRolePeer::doDeleteAll(); + // 1) test the pooled instances' + $c = new Criteria(); + $c->add(BookstoreEmployeePeer::ID, array($managerId, $empId, $cashierId), Criteria::IN); + $c->addAscendingOrderByColumn(BookstoreEmployeePeer::ID); - $bemp2 = new BookstoreEmployee(); - $bemp2->setName("Pieter"); - $bemp2->setJobTitle("Clerk"); - $bemp2->save(); + $objects = BookstoreEmployeePeer::doSelect($c); - $role = new AcctAccessRole(); - $role->setName("Admin"); + $this->assertEquals(3, count($objects), "Expected 3 objects to be returned."); - $bempacct = new BookstoreEmployeeAccount(); - $bempacct->setBookstoreEmployee($bemp2); - $bempacct->setAcctAccessRole($role); - $bempacct->setLogin("john"); - $bempacct->setPassword("johnp4ss"); - $bempacct->save(); + list($o1, $o2, $o3) = $objects; - $c = new Criteria(); - $results = BookstoreEmployeeAccountPeer::doSelectJoinAll($c); - $o = $results[0]; + $this->assertSame($o1, $manager); + $this->assertSame($o2, $employee); + $this->assertSame($o3, $cashier); - $this->assertEquals('Admin', $o->getAcctAccessRole()->getName()); - } + // 2) test a forced reload from database + BookstoreEmployeePeer::clearInstancePool(); - /** - * Testing foreign keys with multiple referrer columns. - * @link http://propel.phpdb.org/trac/ticket/606 - */ - public function testMultiColFk() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); + list($o1,$o2,$o3) = BookstoreEmployeePeer::doSelect($c); - ReaderFavoritePeer::doDeleteAll(); - - $b1 = new Book(); - $b1->setTitle("Book1"); - $b1->setISBN("ISBN-1"); - $b1->save(); - - $r1 = new BookReader(); - $r1-> setName("Me"); - $r1->save(); - - $bo1 = new BookOpinion(); - $bo1->setBookId($b1->getId()); - $bo1->setReaderId($r1->getId()); - $bo1->setRating(9); - $bo1->setRecommendToFriend(true); - $bo1->save(); - - $rf1 = new ReaderFavorite(); - $rf1->setReaderId($r1->getId()); - $rf1->setBookId($b1->getId()); - $rf1->save(); - - $c = new Criteria(ReaderFavoritePeer::DATABASE_NAME); - $c->add(ReaderFavoritePeer::BOOK_ID, $b1->getId()); - $c->add(ReaderFavoritePeer::READER_ID, $r1->getId()); - - $results = ReaderFavoritePeer::doSelectJoinBookOpinion($c); - $this->assertEquals(1, count($results), "Expected 1 result"); - } - - /** - * Testing foreign keys with multiple referrer columns. - * @link http://propel.phpdb.org/trac/ticket/606 - */ - public function testMultiColJoin() - { - BookstoreContestPeer::doDeleteAll(); - BookstoreContestEntryPeer::doDeleteAll(); - - $bs = new Bookstore(); - $bs->setStoreName("Test1"); - $bs->setPopulationServed(5); - $bs->save(); - $bs1Id = $bs->getId(); - - $bs2 = new Bookstore(); - $bs2->setStoreName("Test2"); - $bs2->setPopulationServed(5); - $bs2->save(); - $bs2Id = $bs2->getId(); - - $ct1 = new Contest(); - $ct1->setName("Contest1!"); - $ct1->save(); - $ct1Id = $ct1->getId(); - - $ct2 = new Contest(); - $ct2->setName("Contest2!"); - $ct2->save(); - $ct2Id = $ct2->getId(); - - $cmr = new Customer(); - $cmr->setName("Customer1"); - $cmr->save(); - $cmr1Id = $cmr->getId(); + $this->assertTrue($o1 instanceof BookstoreManager, "Expected BookstoreManager object, got " . get_class($o1)); + $this->assertTrue($o2 instanceof BookstoreEmployee, "Expected BookstoreEmployee object, got " . get_class($o2)); + $this->assertTrue($o3 instanceof BookstoreCashier, "Expected BookstoreCashier object, got " . get_class($o3)); - $cmr2 = new Customer(); - $cmr2->setName("Customer2"); - $cmr2->save(); - $cmr2Id = $cmr2->getId(); - - $contest = new BookstoreContest(); - $contest->setBookstoreId($bs1Id); - $contest->setContestId($ct1Id); - $contest->save(); - - $contest = new BookstoreContest(); - $contest->setBookstoreId($bs2Id); - $contest->setContestId($ct1Id); - $contest->save(); - - $entry = new BookstoreContestEntry(); - $entry->setBookstoreId($bs1Id); - $entry->setContestId($ct1Id); - $entry->setCustomerId($cmr1Id); - $entry->save(); - - $entry = new BookstoreContestEntry(); - $entry->setBookstoreId($bs1Id); - $entry->setContestId($ct1Id); - $entry->setCustomerId($cmr2Id); - $entry->save(); - - // Note: this test isn't really working very well. We setup fkeys that - // require that the BookstoreContest rows exist and then try to violate - // the rules ... :-/ This may work in some lenient databases, but an error - // is expected here. - - /* - * Commented out for now ... though without it, this test may not really be testing anything - $entry = new BookstoreContestEntry(); - $entry->setBookstoreId($bs1Id); - $entry->setContestId($ct2Id); - $entry->setCustomerId($cmr2Id); - $entry->save(); - */ - - - $c = new Criteria(); - $c->addJoin(array(BookstoreContestEntryPeer::BOOKSTORE_ID, BookstoreContestEntryPeer::CONTEST_ID), array(BookstoreContestPeer::BOOKSTORE_ID, BookstoreContestPeer::CONTEST_ID) ); + } - $results = BookstoreContestEntryPeer::doSelect($c); - $this->assertEquals(2, count($results) ); - foreach ($results as $result) { - $this->assertEquals($bs1Id, $result->getBookstoreId() ); - $this->assertEquals($ct1Id, $result->getContestId() ); - } - } + /** + * Test hydration of joined rows that contain lazy load columns. + * @link http://trac.propelorm.org/ticket/464 + */ + public function testHydrationJoinLazyLoad() + { + BookstoreEmployeeAccountPeer::doDeleteAll(); + BookstoreEmployeePeer::doDeleteAll(); + AcctAccessRolePeer::doDeleteAll(); + + $bemp2 = new BookstoreEmployee(); + $bemp2->setName("Pieter"); + $bemp2->setJobTitle("Clerk"); + $bemp2->save(); + + $role = new AcctAccessRole(); + $role->setName("Admin"); + + $bempacct = new BookstoreEmployeeAccount(); + $bempacct->setBookstoreEmployee($bemp2); + $bempacct->setAcctAccessRole($role); + $bempacct->setLogin("john"); + $bempacct->setPassword("johnp4ss"); + $bempacct->save(); + + $c = new Criteria(); + $results = BookstoreEmployeeAccountPeer::doSelectJoinAll($c); + $o = $results[0]; + + $this->assertEquals('Admin', $o->getAcctAccessRole()->getName()); + } + + /** + * Testing foreign keys with multiple referrer columns. + * @link http://trac.propelorm.org/ticket/606 + */ + public function testMultiColFk() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + ReaderFavoritePeer::doDeleteAll(); + + $b1 = new Book(); + $b1->setTitle("Book1"); + $b1->setISBN("ISBN-1"); + $b1->save(); + + $r1 = new BookReader(); + $r1-> setName("Me"); + $r1->save(); + + $bo1 = new BookOpinion(); + $bo1->setBookId($b1->getId()); + $bo1->setReaderId($r1->getId()); + $bo1->setRating(9); + $bo1->setRecommendToFriend(true); + $bo1->save(); + + $rf1 = new ReaderFavorite(); + $rf1->setReaderId($r1->getId()); + $rf1->setBookId($b1->getId()); + $rf1->save(); + + $c = new Criteria(ReaderFavoritePeer::DATABASE_NAME); + $c->add(ReaderFavoritePeer::BOOK_ID, $b1->getId()); + $c->add(ReaderFavoritePeer::READER_ID, $r1->getId()); + + $results = ReaderFavoritePeer::doSelectJoinBookOpinion($c); + $this->assertEquals(1, count($results), "Expected 1 result"); + } + + /** + * Testing foreign keys with multiple referrer columns. + * @link http://trac.propelorm.org/ticket/606 + */ + public function testMultiColJoin() + { + BookstoreContestPeer::doDeleteAll(); + BookstoreContestEntryPeer::doDeleteAll(); + + $bs = new Bookstore(); + $bs->setStoreName("Test1"); + $bs->setPopulationServed(5); + $bs->save(); + $bs1Id = $bs->getId(); + + $bs2 = new Bookstore(); + $bs2->setStoreName("Test2"); + $bs2->setPopulationServed(5); + $bs2->save(); + $bs2Id = $bs2->getId(); + + $ct1 = new Contest(); + $ct1->setName("Contest1!"); + $ct1->save(); + $ct1Id = $ct1->getId(); + + $ct2 = new Contest(); + $ct2->setName("Contest2!"); + $ct2->save(); + $ct2Id = $ct2->getId(); + + $cmr = new Customer(); + $cmr->setName("Customer1"); + $cmr->save(); + $cmr1Id = $cmr->getId(); + + $cmr2 = new Customer(); + $cmr2->setName("Customer2"); + $cmr2->save(); + $cmr2Id = $cmr2->getId(); + + $contest = new BookstoreContest(); + $contest->setBookstoreId($bs1Id); + $contest->setContestId($ct1Id); + $contest->save(); + + $contest = new BookstoreContest(); + $contest->setBookstoreId($bs2Id); + $contest->setContestId($ct1Id); + $contest->save(); + + $entry = new BookstoreContestEntry(); + $entry->setBookstoreId($bs1Id); + $entry->setContestId($ct1Id); + $entry->setCustomerId($cmr1Id); + $entry->save(); + + $entry = new BookstoreContestEntry(); + $entry->setBookstoreId($bs1Id); + $entry->setContestId($ct1Id); + $entry->setCustomerId($cmr2Id); + $entry->save(); + + // Note: this test isn't really working very well. We setup fkeys that + // require that the BookstoreContest rows exist and then try to violate + // the rules ... :-/ This may work in some lenient databases, but an error + // is expected here. + + /* + * Commented out for now ... though without it, this test may not really be testing anything + $entry = new BookstoreContestEntry(); + $entry->setBookstoreId($bs1Id); + $entry->setContestId($ct2Id); + $entry->setCustomerId($cmr2Id); + $entry->save(); + */ + + $c = new Criteria(); + $c->addJoin(array(BookstoreContestEntryPeer::BOOKSTORE_ID, BookstoreContestEntryPeer::CONTEST_ID), array(BookstoreContestPeer::BOOKSTORE_ID, BookstoreContestPeer::CONTEST_ID) ); + + $results = BookstoreContestEntryPeer::doSelect($c); + $this->assertEquals(2, count($results) ); + foreach ($results as $result) { + $this->assertEquals($bs1Id, $result->getBookstoreId() ); + $this->assertEquals($ct1Id, $result->getContestId() ); + } + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerEnumColumnTypeTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerEnumColumnTypeTest.php new file mode 100644 index 000000000..9b2d18c23 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerEnumColumnTypeTest.php @@ -0,0 +1,94 @@ + + + + +
+ +EOF; + PropelQuickBuilder::buildSchema($schema); + } + } + + public function valueSetConstantProvider() + { + return array( + array('ComplexColumnTypeEntity103Peer::BAR_FOO', 'foo'), + array('ComplexColumnTypeEntity103Peer::BAR_BAR', 'bar'), + array('ComplexColumnTypeEntity103Peer::BAR_BAZ', 'baz'), + array('ComplexColumnTypeEntity103Peer::BAR_1', '1'), + array('ComplexColumnTypeEntity103Peer::BAR_4', '4'), + array('ComplexColumnTypeEntity103Peer::BAR__', '('), + array('ComplexColumnTypeEntity103Peer::BAR_FOO_BAR', 'foo bar'), + ); + } + + /** + * @dataProvider valueSetConstantProvider + */ + public function testValueSetConstants($constantName, $value) + { + $this->assertTrue(defined($constantName)); + $this->assertEquals($value, constant($constantName)); + } + + public function testGetValueSets() + { + $expected = array(ComplexColumnTypeEntity103Peer::BAR => array('foo', 'bar', 'baz', '1', '4', '(', 'foo bar')); + $this->assertEquals($expected, ComplexColumnTypeEntity103Peer::getValueSets()); + } + + public function testGetValueSet() + { + $expected = array('foo', 'bar', 'baz', '1', '4', '(', 'foo bar'); + $this->assertEquals($expected, ComplexColumnTypeEntity103Peer::getValueSet(ComplexColumnTypeEntity103Peer::BAR)); + } + + /** + * @expectedException PropelException + */ + public function testGetValueSetInvalidColumn() + { + ComplexColumnTypeEntity103Peer::getValueSet(ComplexColumnTypeEntity103Peer::ID); + } + + public function testGetSqlValueForEnum() + { + $this->assertEquals(0, ComplexColumnTypeEntity103Peer::getSqlValueForEnum(ComplexColumnTypeEntity103Peer::BAR, ComplexColumnTypeEntity103Peer::BAR_FOO)); + $this->assertEquals(1, ComplexColumnTypeEntity103Peer::getSqlValueForEnum(ComplexColumnTypeEntity103Peer::BAR, ComplexColumnTypeEntity103Peer::BAR_BAR)); + $this->assertEquals(2, ComplexColumnTypeEntity103Peer::getSqlValueForEnum(ComplexColumnTypeEntity103Peer::BAR, ComplexColumnTypeEntity103Peer::BAR_BAZ)); + $this->assertEquals(6, ComplexColumnTypeEntity103Peer::getSqlValueForEnum(ComplexColumnTypeEntity103Peer::BAR, ComplexColumnTypeEntity103Peer::BAR_FOO_BAR)); + } + + public function testEnumSqlGetters() + { + $this->assertEquals(0, ComplexColumnTypeEntity103Peer::getBarSqlValue(ComplexColumnTypeEntity103Peer::BAR_FOO)); + $this->assertEquals(1, ComplexColumnTypeEntity103Peer::getBarSqlValue(ComplexColumnTypeEntity103Peer::BAR_BAR)); + $this->assertEquals(2, ComplexColumnTypeEntity103Peer::getBarSqlValue(ComplexColumnTypeEntity103Peer::BAR_BAZ)); + $this->assertEquals(6, ComplexColumnTypeEntity103Peer::getBarSqlValue(ComplexColumnTypeEntity103Peer::BAR_FOO_BAR)); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerLazyLoadTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerLazyLoadTest.php new file mode 100644 index 000000000..0bab38840 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerLazyLoadTest.php @@ -0,0 +1,107 @@ + + + + + + +
+ +EOF; + PropelQuickBuilder::buildSchema($schema); + } + } + + public function testNumHydrateColumns() + { + $this->assertEquals(3, LazyLoadActiveRecord2Peer::NUM_HYDRATE_COLUMNS); + } + + public function testPopulateObjectNotInPool() + { + LazyLoadActiveRecord2Peer::clearInstancePool(); + $values = array(123, 'fooValue', 'bazValue'); + $col = 0; + list($obj, $col) = LazyLoadActiveRecord2Peer::populateObject($values, $col); + $this->assertEquals(3, $col); + $this->assertEquals(123, $obj->getId()); + $this->assertEquals('fooValue', $obj->getFoo()); + $this->assertNull($obj->getBar()); + $this->assertEquals('bazValue', $obj->getBaz()); + } + + public function testPopulateObjectInPool() + { + LazyLoadActiveRecord2Peer::clearInstancePool(); + $ar = new LazyLoadActiveRecord2(); + $ar->setId(123); + $ar->setFoo('fooValue'); + $ar->setBaz('bazValue'); + $ar->setNew(false); + LazyLoadActiveRecord2Peer::addInstanceToPool($ar, 123); + $values = array(123, 'fooValue', 'bazValue'); + $col = 0; + list($obj, $col) = LazyLoadActiveRecord2Peer::populateObject($values, $col); + $this->assertEquals(3, $col); + $this->assertEquals(123, $obj->getId()); + $this->assertEquals('fooValue', $obj->getFoo()); + $this->assertNull($obj->getBar()); + $this->assertEquals('bazValue', $obj->getBaz()); + } + + public function testPopulateObjectNotInPoolStartColGreaterThanOne() + { + LazyLoadActiveRecord2Peer::clearInstancePool(); + $values = array('dummy', 'dummy', 123, 'fooValue', 'bazValue', 'dummy'); + $col = 2; + list($obj, $col) = LazyLoadActiveRecord2Peer::populateObject($values, $col); + $this->assertEquals(5, $col); + $this->assertEquals(123, $obj->getId()); + $this->assertEquals('fooValue', $obj->getFoo()); + $this->assertNull($obj->getBar()); + $this->assertEquals('bazValue', $obj->getBaz()); + } + + public function testPopulateObjectInPoolStartColGreaterThanOne() + { + LazyLoadActiveRecord2Peer::clearInstancePool(); + $ar = new LazyLoadActiveRecord2(); + $ar->setId(123); + $ar->setFoo('fooValue'); + $ar->setBaz('bazValue'); + $ar->setNew(false); + LazyLoadActiveRecord2Peer::addInstanceToPool($ar, 123); + $values = array('dummy', 'dummy', 123, 'fooValue', 'bazValue', 'dummy'); + $col = 2; + list($obj, $col) = LazyLoadActiveRecord2Peer::populateObject($values, $col); + $this->assertEquals(5, $col); + $this->assertEquals(123, $obj->getId()); + $this->assertEquals('fooValue', $obj->getFoo()); + $this->assertNull($obj->getBar()); + $this->assertEquals('bazValue', $obj->getBaz()); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerTest.php index 91d3755ce..d9fe8adce 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedPeerTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Tests the generated Peer classes. @@ -16,7 +16,7 @@ require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; * This test uses generated Bookstore classes to test the behavior of various * peer operations. * - * The database is relaoded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same * for each test method in this class. See the BookstoreDataPopulator::populate() * method for the exact contents of the database. @@ -27,64 +27,71 @@ require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; */ class GeneratedPeerTest extends BookstoreTestBase { - public function testAlias() - { - $this->assertEquals('foo.ID', BookPeer::alias('foo', BookPeer::ID), 'alias() returns a column name using the table alias'); - $this->assertEquals('book.ID', BookPeer::alias('book', BookPeer::ID), 'alias() returns a column name using the table alias'); - $this->assertEquals('foo.COVER_IMAGE', MediaPeer::alias('foo', MediaPeer::COVER_IMAGE), 'alias() also works for lazy-loaded columns'); - $this->assertEquals('foo.SUBTITLE', EssayPeer::alias('foo', EssayPeer::SUBTITLE), 'alias() also works for columns with custom phpName'); - } - - public function testAddSelectColumns() - { - $c = new Criteria(); - BookPeer::addSelectColumns($c); - $expected = array( - BookPeer::ID, - BookPeer::TITLE, - BookPeer::ISBN, - BookPeer::PRICE, - BookPeer::PUBLISHER_ID, - BookPeer::AUTHOR_ID - ); - $this->assertEquals($expected, $c->getSelectColumns(), 'addSelectColumns() adds the columns of the model to the criteria'); - } - - public function testAddSelectColumnsLazyLoad() - { - $c = new Criteria(); - MediaPeer::addSelectColumns($c); - $expected = array( - MediaPeer::ID, - MediaPeer::BOOK_ID - ); - $this->assertEquals($expected, $c->getSelectColumns(), 'addSelectColumns() does not add lazy loaded columns'); - } - - public function testAddSelectColumnsAlias() - { - $c = new Criteria(); - BookPeer::addSelectColumns($c, 'foo'); - $expected = array( - 'foo.ID', - 'foo.TITLE', - 'foo.ISBN', - 'foo.PRICE', - 'foo.PUBLISHER_ID', - 'foo.AUTHOR_ID' - ); - $this->assertEquals($expected, $c->getSelectColumns(), 'addSelectColumns() uses the second parameter as a table alias'); - } - - public function testAddSelectColumnsAliasLazyLoad() - { - $c = new Criteria(); - MediaPeer::addSelectColumns($c, 'bar'); - $expected = array( - 'bar.ID', - 'bar.BOOK_ID' - ); - $this->assertEquals($expected, $c->getSelectColumns(), 'addSelectColumns() does not add lazy loaded columns but uses the second parameter as an alias'); - } + public function testAlias() + { + $this->assertEquals('foo.id', BookPeer::alias('foo', BookPeer::ID), 'alias() returns a column name using the table alias'); + $this->assertEquals('book.id', BookPeer::alias('book', BookPeer::ID), 'alias() returns a column name using the table alias'); + $this->assertEquals('foo.cover_image', MediaPeer::alias('foo', MediaPeer::COVER_IMAGE), 'alias() also works for lazy-loaded columns'); + $this->assertEquals('foo.subtitle', EssayPeer::alias('foo', EssayPeer::SUBTITLE), 'alias() also works for columns with custom phpName'); + } + + public function testAddSelectColumns() + { + $c = new Criteria(); + BookPeer::addSelectColumns($c); + $expected = array( + BookPeer::ID, + BookPeer::TITLE, + BookPeer::ISBN, + BookPeer::PRICE, + BookPeer::PUBLISHER_ID, + BookPeer::AUTHOR_ID + ); + $this->assertEquals($expected, $c->getSelectColumns(), 'addSelectColumns() adds the columns of the model to the criteria'); + } + + public function testAddSelectColumnsLazyLoad() + { + $c = new Criteria(); + MediaPeer::addSelectColumns($c); + $expected = array( + MediaPeer::ID, + MediaPeer::BOOK_ID + ); + $this->assertEquals($expected, $c->getSelectColumns(), 'addSelectColumns() does not add lazy loaded columns'); + } + + public function testAddSelectColumnsAlias() + { + $c = new Criteria(); + BookPeer::addSelectColumns($c, 'foo'); + $expected = array( + 'foo.id', + 'foo.title', + 'foo.isbn', + 'foo.price', + 'foo.publisher_id', + 'foo.author_id' + ); + $this->assertEquals($expected, $c->getSelectColumns(), 'addSelectColumns() uses the second parameter as a table alias'); + } + + public function testAddSelectColumnsAliasLazyLoad() + { + $c = new Criteria(); + MediaPeer::addSelectColumns($c, 'bar'); + $expected = array( + 'bar.id', + 'bar.book_id' + ); + $this->assertEquals($expected, $c->getSelectColumns(), 'addSelectColumns() does not add lazy loaded columns but uses the second parameter as an alias'); + } + + public function testDefaultStringFormatConstant() + { + $this->assertTrue(defined('BookPeer::DEFAULT_STRING_FORMAT'), 'every Peer class has the DEFAULT_STRING_FORMAT constant'); + $this->assertEquals('YAML', AuthorPeer::DEFAULT_STRING_FORMAT, 'default string format is YAML by default'); + $this->assertEquals('XML', PublisherPeer::DEFAULT_STRING_FORMAT, 'default string format can be customized using the defaultStringFormat attribute in the schema'); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedQueryArrayColumnTypeTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedQueryArrayColumnTypeTest.php new file mode 100644 index 000000000..1fe743703 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedQueryArrayColumnTypeTest.php @@ -0,0 +1,226 @@ + + + + + +
+ +EOF; + PropelQuickBuilder::buildSchema($schema); + $e0 = new ComplexColumnTypeEntity11(); + $e0->save(); + $e1 = new ComplexColumnTypeEntity11(); + $e1->setTags(array('foo', 'bar', 'baz')); + $e1->save(); + $e2 = new ComplexColumnTypeEntity11(); + $e2->setTags(array('bar')); + $e2->save(); + $e3 = new ComplexColumnTypeEntity11(); + $e3->setTags(array('bar23')); + $e3->save(); + } + } + + public function testActiveQueryMethods() + { + $this->assertTrue(method_exists('ComplexColumnTypeEntity11Query', 'filterByTags')); + $this->assertTrue(method_exists('ComplexColumnTypeEntity11Query', 'filterByTag')); + // only plural column names get a singular filter + $this->assertTrue(method_exists('ComplexColumnTypeEntity11Query', 'filterByValueSet')); + } + + public function testColumnHydration() + { + $e = ComplexColumnTypeEntity11Query::create()->orderById()->offset(1)->findOne(); + $this->assertEquals(array('foo', 'bar', 'baz'), $e->getTags(), 'array columns are correctly hydrated'); + } + + public function testWhere() + { + $e = ComplexColumnTypeEntity11Query::create() + ->where('ComplexColumnTypeEntity11.Tags LIKE ?', '%| bar23 |%') + ->find(); + $this->assertEquals(1, $e->count()); + $this->assertEquals(array('bar23'), $e[0]->getTags(), 'array columns are searchable by serialized object using where()'); + $e = ComplexColumnTypeEntity11Query::create() + ->where('ComplexColumnTypeEntity11.Tags = ?', array('bar23')) + ->find(); + $this->assertEquals(1, $e->count()); + $this->assertEquals(array('bar23'), $e[0]->getTags(), 'array columns are searchable by object using where()'); + } + + public function testFilterByColumn() + { + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTags(array('bar')) + ->orderById() + ->find(); + $this->assertEquals(array('foo', 'bar', 'baz'), $e[0]->getTags(), 'array columns are searchable by element'); + $this->assertEquals(array('bar'), $e[1]->getTags(), 'array columns are searchable by element'); + $this->assertEquals(2, $e->count(), 'array columns do not return false positives'); + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTags(array('bar23')) + ->findOne(); + $this->assertEquals(array('bar23'), $e->getTags(), 'array columns are searchable by element'); + } + + public function testFilterByColumnUsingContainsAll() + { + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTags(array(), Criteria::CONTAINS_ALL) + ->find(); + $this->assertEquals(4, $e->count()); + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTags(array('bar'), Criteria::CONTAINS_ALL) + ->orderById() + ->find(); + $this->assertEquals(2, $e->count()); + $this->assertEquals(array('foo', 'bar', 'baz'), $e[0]->getTags()); + $this->assertEquals(array('bar'), $e[1]->getTags()); + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTags(array('bar23'), Criteria::CONTAINS_ALL) + ->find(); + $this->assertEquals(1, $e->count()); + $this->assertEquals(array('bar23'), $e[0]->getTags()); + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTags(array('foo', 'bar'), Criteria::CONTAINS_ALL) + ->find(); + $this->assertEquals(1, $e->count()); + $this->assertEquals(array('foo', 'bar', 'baz'), $e[0]->getTags()); + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTags(array('foo', 'bar23'), Criteria::CONTAINS_ALL) + ->find(); + $this->assertEquals(0, $e->count()); + } + + public function testFilterByColumnUsingContainsSome() + { + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTags(array(), Criteria::CONTAINS_SOME) + ->find(); + $this->assertEquals(4, $e->count()); + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTags(array('bar'), Criteria::CONTAINS_SOME) + ->orderById() + ->find(); + $this->assertEquals(2, $e->count()); + $this->assertEquals(array('foo', 'bar', 'baz'), $e[0]->getTags()); + $this->assertEquals(array('bar'), $e[1]->getTags()); + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTags(array('bar23'), Criteria::CONTAINS_SOME) + ->find(); + $this->assertEquals(1, $e->count()); + $this->assertEquals(array('bar23'), $e[0]->getTags()); + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTags(array('foo', 'bar'), Criteria::CONTAINS_SOME) + ->orderById() + ->find(); + $this->assertEquals(2, $e->count()); + $this->assertEquals(array('foo', 'bar', 'baz'), $e[0]->getTags()); + $this->assertEquals(array('bar'), $e[1]->getTags()); + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTags(array('foo', 'bar23'), Criteria::CONTAINS_SOME) + ->find(); + $this->assertEquals(2, $e->count()); + $this->assertEquals(array('foo', 'bar', 'baz'), $e[0]->getTags()); + $this->assertEquals(array('bar23'), $e[1]->getTags()); + } + + public function testFilterByColumnUsingContainsNone() + { + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTags(array(), Criteria::CONTAINS_NONE) + ->find(); + $this->assertEquals(1, $e->count()); + $this->assertEquals(array(), $e[0]->getTags()); + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTags(array('bar'), Criteria::CONTAINS_NONE) + ->orderById() + ->find(); + $this->assertEquals(2, $e->count()); + $this->assertEquals(array(), $e[0]->getTags()); + $this->assertEquals(array('bar23'), $e[1]->getTags()); + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTags(array('bar23'), Criteria::CONTAINS_NONE) + ->find(); + $this->assertEquals(3, $e->count()); + $this->assertEquals(array(), $e[0]->getTags()); + $this->assertEquals(array('foo', 'bar', 'baz'), $e[1]->getTags()); + $this->assertEquals(array('bar'), $e[2]->getTags()); + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTags(array('foo', 'bar'), Criteria::CONTAINS_NONE) + ->orderById() + ->find(); + $this->assertEquals(2, $e->count()); + $this->assertEquals(array(), $e[0]->getTags()); + $this->assertEquals(array('bar23'), $e[1]->getTags()); + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTags(array('foo', 'bar23'), Criteria::CONTAINS_NONE) + ->find(); + $this->assertEquals(2, $e->count()); + $this->assertEquals(array(), $e[0]->getTags()); + $this->assertEquals(array('bar'), $e[1]->getTags()); + } + + public function testFilterBySingularColumn() + { + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTag('bar') + ->orderById() + ->find(); + $this->assertEquals(array('foo', 'bar', 'baz'), $e[0]->getTags(), 'array columns are searchable by element'); + $this->assertEquals(array('bar'), $e[1]->getTags(), 'array columns are searchable by element'); + $this->assertEquals(2, $e->count(), 'array columns do not return false positives'); + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTag('bar23') + ->findOne(); + $this->assertEquals(array('bar23'), $e->getTags(), 'array columns are searchable by element'); + } + + public function testFilterBySingularColumnUsingContainsAll() + { + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTag('bar', Criteria::CONTAINS_ALL) + ->orderById() + ->find(); + $this->assertEquals(2, $e->count(), 'array columns are searchable by element using Criteria::CONTAINS_ALL'); + $this->assertEquals(array('foo', 'bar', 'baz'), $e[0]->getTags(), 'array columns are searchable by element using Criteria::CONTAINS_ALL'); + $this->assertEquals(array('bar'), $e[1]->getTags(), 'array columns are searchable by element using Criteria::CONTAINS_ALL'); + } + + public function testFilterBySingularColumnUsingContainsNone() + { + $e = ComplexColumnTypeEntity11Query::create() + ->filterByTag('bar', Criteria::CONTAINS_NONE) + ->orderById() + ->find(); + $this->assertEquals(2, $e->count(), 'array columns are searchable by element using Criteria::CONTAINS_NONE'); + $this->assertEquals(array(), $e[0]->getTags(), 'array columns are searchable by element using Criteria::CONTAINS_NONE'); + $this->assertEquals(array('bar23'), $e[1]->getTags(), 'array columns are searchable by element using Criteria::CONTAINS_NONE'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedQueryEnumColumnTypeTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedQueryEnumColumnTypeTest.php new file mode 100644 index 000000000..cc9956a15 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedQueryEnumColumnTypeTest.php @@ -0,0 +1,92 @@ + + + + + +
+ +EOF; + PropelQuickBuilder::buildSchema($schema); + $e0 = new ComplexColumnTypeEntity13(); + $e0->save(); + $e1 = new ComplexColumnTypeEntity13(); + $e1->setBar('baz'); + $e1->save(); + $e2 = new ComplexColumnTypeEntity13(); + $e2->setBar('4'); + $e2->save(); + ComplexColumnTypeEntity13Peer::clearInstancePool(); + } + } + + public function testColumnHydration() + { + $e = ComplexColumnTypeEntity13Query::create() + ->orderById() + ->offset(1) + ->findOne(); + $this->assertEquals('baz', $e->getBar(), 'enum columns are correctly hydrated'); + } + + public function testWhere() + { + $e = ComplexColumnTypeEntity13Query::create() + ->where('ComplexColumnTypeEntity13.Bar = ?', 'baz') + ->find(); + $this->assertEquals(1, $e->count(), 'object columns are searchable by enumerated value using where()'); + $this->assertEquals('baz', $e[0]->getBar(), 'object columns are searchable by enumerated value using where()'); + $e = ComplexColumnTypeEntity13Query::create() + ->where('ComplexColumnTypeEntity13.Bar IN ?', array('baz', 4)) + ->find(); + $this->assertEquals(2, $e->count(), 'object columns are searchable by enumerated value using where()'); + } + + public function testFilterByColumn() + { + $e = ComplexColumnTypeEntity13Query::create() + ->filterByBar('4') + ->findOne(); + $this->assertEquals('4', $e->getBar(), 'enum columns are searchable by enumerated value'); + $e = ComplexColumnTypeEntity13Query::create() + ->filterByBar('baz') + ->findOne(); + $this->assertEquals('baz', $e->getBar(), 'enum columns are searchable by enumerated value'); + $e = ComplexColumnTypeEntity13Query::create() + ->filterByBar('baz', Criteria::NOT_EQUAL) + ->findOne(); + $this->assertEquals('4', $e->getBar(), 'enum columns are searchable by enumerated value'); + $nb = ComplexColumnTypeEntity13Query::create() + ->filterByBar(array('baz', '4'), Criteria::IN) + ->count(); + $this->assertEquals(2, $nb, 'enum columns are searchable by enumerated value'); + $nb = ComplexColumnTypeEntity13Query::create() + ->filterByBar(array('baz', '4')) + ->count(); + $this->assertEquals(2, $nb, 'enum columns filters default to Criteria IN when passed an array'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedQueryObjectColumnTypeTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedQueryObjectColumnTypeTest.php new file mode 100644 index 000000000..8ce14984d --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/GeneratedQueryObjectColumnTypeTest.php @@ -0,0 +1,94 @@ +c1 = new FooColumnValue2(); + $this->c1->bar = 1234; + $this->c2 = new FooColumnValue2(); + $this->c2->bar = 5678; + + if (!class_exists('ComplexColumnTypeEntity10')) { + $schema = << + + + +
+ +EOF; + PropelQuickBuilder::buildSchema($schema); + $e0 = new ComplexColumnTypeEntity10(); + $e0->save(); + $e1 = new ComplexColumnTypeEntity10(); + $e1->setBar($this->c1); + $e1->save(); + $e2 = new ComplexColumnTypeEntity10(); + $e2->setBar($this->c2); + $e2->save(); + ComplexColumnTypeEntity10Peer::clearInstancePool(); + } + } + + public function testColumnHydration() + { + $e = ComplexColumnTypeEntity10Query::create() + ->orderById() + ->offset(1) + ->findOne(); + $this->assertEquals($this->c1, $e->getBar(), 'object columns are correctly hydrated'); + } + + public function testWhere() + { + $nb = ComplexColumnTypeEntity10Query::create() + ->where('ComplexColumnTypeEntity10.Bar LIKE ?', '%1234%') + ->count(); + $this->assertEquals(1, $nb, 'object columns are searchable by serialized object using where()'); + $e = ComplexColumnTypeEntity10Query::create() + ->where('ComplexColumnTypeEntity10.Bar = ?', $this->c1) + ->findOne(); + $this->assertEquals($this->c1, $e->getBar(), 'object columns are searchable by object using where()'); + } + + public function testFilterByColumn() + { + $e = ComplexColumnTypeEntity10Query::create() + ->filterByBar($this->c1) + ->findOne(); + $this->assertEquals($this->c1, $e->getBar(), 'object columns are searchable by object'); + $e = ComplexColumnTypeEntity10Query::create() + ->filterByBar($this->c2) + ->findOne(); + $this->assertEquals($this->c2, $e->getBar(), 'object columns are searchable by object'); + $e = ComplexColumnTypeEntity10Query::create() + ->filterByBar($this->c1, Criteria::NOT_EQUAL) + ->findOne(); + $this->assertEquals($this->c2, $e->getBar(), 'object columns are searchable by object'); + } +} + +class FooColumnValue2 +{ + public $bar; +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/OMBuilderNamespaceTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/OMBuilderNamespaceTest.php index c78f9532a..61fe611b6 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/OMBuilderNamespaceTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/OMBuilderNamespaceTest.php @@ -8,10 +8,10 @@ * @license MIT License */ -require_once 'model/Database.php'; -require_once 'model/Table.php'; -require_once 'builder/om/OMBuilder.php'; -require_once 'platform/MysqlPlatform.php'; +require_once dirname(__FILE__) . '/../../../../../generator/lib/model/Database.php'; +require_once dirname(__FILE__) . '/../../../../../generator/lib/model/Table.php'; +require_once dirname(__FILE__) . '/../../../../../generator/lib/builder/om/OMBuilder.php'; +require_once dirname(__FILE__) . '/../../../../../generator/lib/platform/MysqlPlatform.php'; /** * Test class for OMBuilder. @@ -20,130 +20,130 @@ require_once 'platform/MysqlPlatform.php'; * @version $Id: OMBuilderBuilderTest.php 1347 2009-12-03 21:06:36Z francois $ * @package generator.builder.om */ -class OMBuilderNamespaceTest extends PHPUnit_Framework_TestCase +class OMBuilderNamespaceTest extends PHPUnit_Framework_TestCase { - public function testNoNamespace() - { - $d = new Database('fooDb'); - $t = new Table('fooTable'); - $d->addTable($t); - $builder = new TestableOMBuilder2($t); - $this->assertNull($builder->getNamespace(), 'Builder namespace is null when neither the db nor the table have namespace'); - } - - public function testDbNamespace() - { - $d = new Database('fooDb'); - $d->setNamespace('Foo\\Bar'); - $t = new Table('fooTable'); - $d->addTable($t); - $builder = new TestableOMBuilder2($t); - $this->assertEquals('Foo\\Bar', $builder->getNamespace(), 'Builder namespace is the database namespace when no table namespace is set'); - } + public function testNoNamespace() + { + $d = new Database('fooDb'); + $t = new Table('fooTable'); + $d->addTable($t); + $builder = new TestableOMBuilder2($t); + $this->assertNull($builder->getNamespace(), 'Builder namespace is null when neither the db nor the table have namespace'); + } - public function testTableNamespace() - { - $d = new Database('fooDb'); - $t = new Table('fooTable'); - $t->setNamespace('Foo\\Bar'); - $d->addTable($t); - $builder = new TestableOMBuilder2($t); - $this->assertEquals('Foo\\Bar', $builder->getNamespace(), 'Builder namespace is the table namespace when no database namespace is set'); - } - - public function testAbsoluteTableNamespace() - { - $d = new Database('fooDb'); - $t = new Table('fooTable'); - $t->setNamespace('\\Foo\\Bar'); - $d->addTable($t); - $builder = new TestableOMBuilder2($t); - $this->assertEquals('Foo\\Bar', $builder->getNamespace(), 'Builder namespace is the table namespace when it is set as absolute'); - } + public function testDbNamespace() + { + $d = new Database('fooDb'); + $d->setNamespace('Foo\\Bar'); + $t = new Table('fooTable'); + $d->addTable($t); + $builder = new TestableOMBuilder2($t); + $this->assertEquals('Foo\\Bar', $builder->getNamespace(), 'Builder namespace is the database namespace when no table namespace is set'); + } - public function testAbsoluteTableNamespaceAndDbNamespace() - { - $d = new Database('fooDb'); - $d->setNamespace('Baz'); - $t = new Table('fooTable'); - $t->setNamespace('\\Foo\\Bar'); - $d->addTable($t); - $builder = new TestableOMBuilder2($t); - $this->assertEquals('Foo\\Bar', $builder->getNamespace(), 'Builder namespace is the table namespace when it is set as absolute'); - } + public function testTableNamespace() + { + $d = new Database('fooDb'); + $t = new Table('fooTable'); + $t->setNamespace('Foo\\Bar'); + $d->addTable($t); + $builder = new TestableOMBuilder2($t); + $this->assertEquals('Foo\\Bar', $builder->getNamespace(), 'Builder namespace is the table namespace when no database namespace is set'); + } - public function testTableNamespaceAndDbNamespace() - { - $d = new Database('fooDb'); - $d->setNamespace('Baz'); - $t = new Table('fooTable'); - $t->setNamespace('Foo\\Bar'); - $d->addTable($t); - $builder = new TestableOMBuilder2($t); - $this->assertEquals('Baz\\Foo\\Bar', $builder->getNamespace(), 'Builder namespace is composed from the database and table namespaces when both are set'); - } - - public function testDeclareClassNamespace() - { - $builder = new TestableOMBuilder2(new Table('fooTable')); - $builder->declareClassNamespace('Foo'); - $this->assertEquals(array('' => array('Foo')), $builder->getDeclaredClasses()); - $builder->declareClassNamespace('Bar'); - $this->assertEquals(array('' => array('Foo', 'Bar')), $builder->getDeclaredClasses()); - $builder->declareClassNamespace('Foo'); - $this->assertEquals(array('' => array('Foo', 'Bar')), $builder->getDeclaredClasses()); - $builder = new TestableOMBuilder2(new Table('fooTable')); - $builder->declareClassNamespace('Foo', 'Foo'); - $this->assertEquals(array('Foo' => array('Foo')), $builder->getDeclaredClasses()); - $builder->declareClassNamespace('Bar', 'Foo'); - $this->assertEquals(array('Foo' => array('Foo', 'Bar')), $builder->getDeclaredClasses()); - $builder->declareClassNamespace('Foo', 'Foo'); - $this->assertEquals(array('Foo' => array('Foo', 'Bar')), $builder->getDeclaredClasses()); - $builder->declareClassNamespace('Bar', 'Bar'); - $this->assertEquals(array('Foo' => array('Foo', 'Bar'), 'Bar' => array('Bar')), $builder->getDeclaredClasses()); - } - - public function testGetDeclareClass() - { - $builder = new TestableOMBuilder2(new Table('fooTable')); - $this->assertEquals(array(), $builder->getDeclaredClasses()); - $builder->declareClass('\\Foo'); - $this->assertEquals(array('Foo'), $builder->getDeclaredClasses('')); - $builder->declareClass('Bar'); - $this->assertEquals(array('Foo', 'Bar'), $builder->getDeclaredClasses('')); - $builder->declareClass('Foo\\Bar'); - $this->assertEquals(array('Bar'), $builder->getDeclaredClasses('Foo')); - $builder->declareClass('Foo\\Bar\\Baz'); - $this->assertEquals(array('Bar'), $builder->getDeclaredClasses('Foo')); - $this->assertEquals(array('Baz'), $builder->getDeclaredClasses('Foo\\Bar')); - $builder->declareClass('\\Hello\\World'); - $this->assertEquals(array('World'), $builder->getDeclaredClasses('Hello')); - } - - public function testDeclareClasses() - { - $builder = new TestableOMBuilder2(new Table('fooTable')); - $builder->declareClasses('Foo', '\\Bar', 'Baz\\Baz', 'Hello\\Cruel\\World'); - $expected = array( - '' => array('Foo', 'Bar'), - 'Baz' => array('Baz'), - 'Hello\\Cruel' => array('World') - ); - $this->assertEquals($expected, $builder->getDeclaredClasses()); - } + public function testAbsoluteTableNamespace() + { + $d = new Database('fooDb'); + $t = new Table('fooTable'); + $t->setNamespace('\\Foo\\Bar'); + $d->addTable($t); + $builder = new TestableOMBuilder2($t); + $this->assertEquals('Foo\\Bar', $builder->getNamespace(), 'Builder namespace is the table namespace when it is set as absolute'); + } + + public function testAbsoluteTableNamespaceAndDbNamespace() + { + $d = new Database('fooDb'); + $d->setNamespace('Baz'); + $t = new Table('fooTable'); + $t->setNamespace('\\Foo\\Bar'); + $d->addTable($t); + $builder = new TestableOMBuilder2($t); + $this->assertEquals('Foo\\Bar', $builder->getNamespace(), 'Builder namespace is the table namespace when it is set as absolute'); + } + + public function testTableNamespaceAndDbNamespace() + { + $d = new Database('fooDb'); + $d->setNamespace('Baz'); + $t = new Table('fooTable'); + $t->setNamespace('Foo\\Bar'); + $d->addTable($t); + $builder = new TestableOMBuilder2($t); + $this->assertEquals('Baz\\Foo\\Bar', $builder->getNamespace(), 'Builder namespace is composed from the database and table namespaces when both are set'); + } + + public function testDeclareClassNamespace() + { + $builder = new TestableOMBuilder2(new Table('fooTable')); + $builder->declareClassNamespace('Foo'); + $this->assertEquals(array('' => array('Foo')), $builder->getDeclaredClasses()); + $builder->declareClassNamespace('Bar'); + $this->assertEquals(array('' => array('Foo', 'Bar')), $builder->getDeclaredClasses()); + $builder->declareClassNamespace('Foo'); + $this->assertEquals(array('' => array('Foo', 'Bar')), $builder->getDeclaredClasses()); + $builder = new TestableOMBuilder2(new Table('fooTable')); + $builder->declareClassNamespace('Foo', 'Foo'); + $this->assertEquals(array('Foo' => array('Foo')), $builder->getDeclaredClasses()); + $builder->declareClassNamespace('Bar', 'Foo'); + $this->assertEquals(array('Foo' => array('Foo', 'Bar')), $builder->getDeclaredClasses()); + $builder->declareClassNamespace('Foo', 'Foo'); + $this->assertEquals(array('Foo' => array('Foo', 'Bar')), $builder->getDeclaredClasses()); + $builder->declareClassNamespace('Bar', 'Bar'); + $this->assertEquals(array('Foo' => array('Foo', 'Bar'), 'Bar' => array('Bar')), $builder->getDeclaredClasses()); + } + + public function testGetDeclareClass() + { + $builder = new TestableOMBuilder2(new Table('fooTable')); + $this->assertEquals(array(), $builder->getDeclaredClasses()); + $builder->declareClass('\\Foo'); + $this->assertEquals(array('Foo'), $builder->getDeclaredClasses('')); + $builder->declareClass('Bar'); + $this->assertEquals(array('Foo', 'Bar'), $builder->getDeclaredClasses('')); + $builder->declareClass('Foo\\Bar'); + $this->assertEquals(array('Bar'), $builder->getDeclaredClasses('Foo')); + $builder->declareClass('Foo\\Bar\\Baz'); + $this->assertEquals(array('Bar'), $builder->getDeclaredClasses('Foo')); + $this->assertEquals(array('Baz'), $builder->getDeclaredClasses('Foo\\Bar')); + $builder->declareClass('\\Hello\\World'); + $this->assertEquals(array('World'), $builder->getDeclaredClasses('Hello')); + } + + public function testDeclareClasses() + { + $builder = new TestableOMBuilder2(new Table('fooTable')); + $builder->declareClasses('Foo', '\\Bar', 'Baz\\Baz', 'Hello\\Cruel\\World'); + $expected = array( + '' => array('Foo', 'Bar'), + 'Baz' => array('Baz'), + 'Hello\\Cruel' => array('World') + ); + $this->assertEquals($expected, $builder->getDeclaredClasses()); + } } class TestableOMBuilder2 extends OMBuilder { - public static function getRelatedBySuffix(ForeignKey $fk) - { - return parent::getRelatedBySuffix($fk); - } - - public static function getRefRelatedBySuffix(ForeignKey $fk) - { - return parent::getRefRelatedBySuffix($fk); - } - - public function getUnprefixedClassname() {} -} \ No newline at end of file + public static function getRelatedBySuffix(ForeignKey $fk) + { + return parent::getRelatedBySuffix($fk); + } + + public static function getRefRelatedBySuffix(ForeignKey $fk) + { + return parent::getRefRelatedBySuffix($fk); + } + + public function getUnprefixedClassname() {} +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/OMBuilderRelatedByTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/OMBuilderRelatedByTest.php new file mode 100644 index 000000000..9bd541dbe --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/OMBuilderRelatedByTest.php @@ -0,0 +1,83 @@ +parseFile(realpath(dirname(__FILE__) . '/../../../../fixtures/bookstore/schema.xml')); + self::$database = $appData->getDatabase("bookstore"); + } + } + + protected function getForeignKey($tableName, $index) + { + $fks = self::$database->getTable($tableName)->getForeignKeys(); + + return $fks[$index]; + } + + public static function getRelatedBySuffixDataProvider() + { + return array( + array('book', 0, '', ''), + array('essay', 0, 'RelatedByFirstAuthor', 'RelatedByFirstAuthor'), + array('essay', 1, 'RelatedBySecondAuthor', 'RelatedBySecondAuthor'), + array('essay', 2, 'RelatedById', 'RelatedByNextEssayId'), + array('bookstore_employee', 0, 'RelatedById', 'RelatedBySupervisorId'), + array('composite_essay', 0, 'RelatedById0', 'RelatedByFirstEssayId'), + array('composite_essay', 1, 'RelatedById1', 'RelatedBySecondEssayId'), + array('man', 0, 'RelatedByWifeId', 'RelatedByWifeId'), + array('woman', 0, 'RelatedByHusbandId', 'RelatedByHusbandId'), + ); + } + + /** + * @dataProvider getRelatedBySuffixDataProvider + */ + public function testGetRelatedBySuffix($table, $index, $expectedSuffix, $expectedReverseSuffix) + { + $fk = $this->getForeignKey($table, $index); + $this->assertEquals($expectedSuffix, TestableOMBuilder::getRefRelatedBySuffix($fk)); + $this->assertEquals($expectedReverseSuffix, TestableOMBuilder::getRelatedBySuffix($fk)); + } +} + +class TestableOMBuilder extends OMBuilder +{ + public static function getRelatedBySuffix(ForeignKey $fk) + { + return parent::getRelatedBySuffix($fk); + } + + public static function getRefRelatedBySuffix(ForeignKey $fk) + { + return parent::getRefRelatedBySuffix($fk); + } + + public function getUnprefixedClassname() {} +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/OMBuilderTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/OMBuilderTest.php index 1d7162e70..a88eee98e 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/OMBuilderTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/OMBuilderTest.php @@ -8,10 +8,8 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; -require_once 'builder/om/OMBuilder.php'; -require_once 'builder/util/XmlToAppData.php'; -require_once 'platform/MysqlPlatform.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../../../generator/lib/builder/om/OMBuilder.php'; /** * Test class for OMBuilder. @@ -20,70 +18,106 @@ require_once 'platform/MysqlPlatform.php'; * @version $Id: OMBuilderBuilderTest.php 1347 2009-12-03 21:06:36Z francois $ * @package generator.builder.om */ -class OMBuilderTest extends PHPUnit_Framework_TestCase +class OMBuilderTest extends PHPUnit_Framework_TestCase { - public function setUp() - { - $xmlToAppData = new XmlToAppData(new MysqlPlatform(), "defaultpackage", null); - $appData = $xmlToAppData->parseFile('fixtures/bookstore/schema.xml'); - $this->database = $appData->getDatabase("bookstore"); - } - - protected function getForeignKey($tableName, $index) - { - $fks = $this->database->getTable($tableName)->getForeignKeys(); - return $fks[$index]; - } - - public static function getRelatedBySuffixDataProvider() - { - return array( - array('book', 0, '', ''), - array('essay', 0, 'RelatedByFirstAuthor', 'RelatedByFirstAuthor'), - array('essay', 1, 'RelatedBySecondAuthor', 'RelatedBySecondAuthor'), - array('essay', 2, 'RelatedById', 'RelatedByNextEssayId'), - array('bookstore_employee', 0, 'RelatedById', 'RelatedBySupervisorId'), - array('composite_essay', 0, 'RelatedById0', 'RelatedByFirstEssayId'), - array('composite_essay', 1, 'RelatedById1', 'RelatedBySecondEssayId'), - array('man', 0, 'RelatedByWifeId', 'RelatedByWifeId'), - array('woman', 0, 'RelatedByHusbandId', 'RelatedByHusbandId'), - ); - } - - /** - * @dataProvider getRelatedBySuffixDataProvider - */ - public function testGetRelatedBySuffix($table, $index, $expectedSuffix, $expectedReverseSuffix) - { - $fk = $this->getForeignKey($table, $index); - $this->assertEquals($expectedSuffix, TestableOMBuilder::getRefRelatedBySuffix($fk)); - $this->assertEquals($expectedReverseSuffix, TestableOMBuilder::getRelatedBySuffix($fk)); - } - public function testClear() - { - $b = new Book(); - $b->setNew(false); - $b->clear(); - $this->assertTrue($b->isNew(), 'clear() sets the object to new'); - $b = new Book(); - $b->setDeleted(true); - $b->clear(); - $this->assertFalse($b->isDeleted(), 'clear() sets the object to not deleted'); - } + public function testClear() + { + $b = new Book(); + $b->setNew(false); + $b->clear(); + $this->assertTrue($b->isNew(), 'clear() sets the object to new'); + $b = new Book(); + $b->setDeleted(true); + $b->clear(); + $this->assertFalse($b->isDeleted(), 'clear() sets the object to not deleted'); + } + + public function testToStringUsesDefaultStringFormat() + { + $author = new Author(); + $author->setFirstName('John'); + $author->setLastName('Doe'); + $expected = <<assertEquals($expected, (string) $author, 'generated __toString() uses default string format and exportTo()'); + + $publisher = new Publisher(); + $publisher->setId(345345); + $publisher->setName('Peguinoo'); + $expected = << + + 345345 + + + +EOF; + $this->assertEquals($expected, (string) $publisher, 'generated __toString() uses default string format and exportTo()'); + } + + /** + * @dataProvider dataGetPackagePath + */ + public function testGetPackagePath($package, $expectedPath) + { + $builder = new OMBuilderMock(); + $builder->setPackage($package); + + $this->assertEquals($expectedPath, $builder->getPackagePath()); + } + + public function dataGetPackagePath() + { + return array( + array('', ''), + array('foo.bar', 'foo/bar'), + array('foo/bar', 'foo/bar'), + array('foo.bar.map', 'foo/bar/map'), + array('foo.bar.om', 'foo/bar/om'), + array('foo.bar.baz', 'foo/bar/baz'), + array('foo.bar.baz.om', 'foo/bar/baz/om'), + array('foo.bar.baz.map', 'foo/bar/baz/map'), + array('foo/bar/baz', 'foo/bar/baz'), + array('foo/bar/baz/map', 'foo/bar/baz/map'), + array('foo/bar/baz/om', 'foo/bar/baz/om'), + array('foo/bar.baz', 'foo/bar.baz'), + array('foo/bar.baz.map', 'foo/bar.baz/map'), + array('foo/bar.baz.om', 'foo/bar.baz/om'), + array('foo.bar/baz', 'foo.bar/baz'), + array('foo.bar/baz.om', 'foo.bar/baz/om'), + array('foo.bar/baz.map', 'foo.bar/baz/map'), + array('.om', 'om'), + ); + } + } -class TestableOMBuilder extends OMBuilder +class OMBuilderMock extends OMBuilder { - public static function getRelatedBySuffix(ForeignKey $fk) - { - return parent::getRelatedBySuffix($fk); - } - - public static function getRefRelatedBySuffix(ForeignKey $fk) - { - return parent::getRefRelatedBySuffix($fk); - } - - public function getUnprefixedClassname() {} -} \ No newline at end of file + protected $pkg; + + public function __construct() + { + } + + public function setPackage($pkg) + { + $this->pkg = $pkg; + } + + public function getPackage() + { + return $this->pkg; + } + + public function getUnprefixedClassname() + { + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/PHP5ObjectBuilderTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/PHP5ObjectBuilderTest.php new file mode 100644 index 000000000..e88174059 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/PHP5ObjectBuilderTest.php @@ -0,0 +1,77 @@ +setPlatform(new MysqlPlatform()); + $this->builder = $builder; + } + + public static function getDefaultValueStringProvider() + { + $col1 = new Column('Bar'); + $col1->setDomain(new Domain('VARCHAR')); + $col1->setDefaultValue(new ColumnDefaultValue('abc', ColumnDefaultValue::TYPE_VALUE)); + $val1 = "'abc'"; + $col2 = new Column('Bar'); + $col2->setDomain(new Domain('INTEGER')); + $col2->setDefaultValue(new ColumnDefaultValue(1234, ColumnDefaultValue::TYPE_VALUE)); + $val2 = "1234"; + $col3 = new Column('Bar'); + $col3->setDomain(new Domain('DATE')); + $col3->setDefaultValue(new ColumnDefaultValue('0000-00-00', ColumnDefaultValue::TYPE_VALUE)); + $val3 = "NULL"; + + return array( + array($col1, $val1), + array($col2, $val2), + array($col3, $val3), + ); + } + + /** + * @dataProvider getDefaultValueStringProvider + */ + public function testGetDefaultValueString($column, $value) + { + $this->assertEquals($value, $this->builder->getDefaultValueString($column)); + } + + public function testGetDefaultKeyType() + { + $this->assertEquals('TYPE_PHPNAME', $this->builder->getDefaultKeyType()); + } +} + +class TestablePHP5ObjectBuilder extends PHP5ObjectBuilder +{ + public function getDefaultValueString(Column $col) + { + return parent::getDefaultValueString($col); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/PHP5TableMapBuilderTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/PHP5TableMapBuilderTest.php index f6463e51b..59893d797 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/PHP5TableMapBuilderTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/PHP5TableMapBuilderTest.php @@ -8,25 +8,25 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/BookstoreTestBase.php'; /** * Test class for PHP5TableMapBuilder. * * @author François Zaninotto - * @version $Id: PHP5TableMapBuilderTest.php 1612 2010-03-16 22:56:21Z francois $ + * @version $Id$ * @package generator.builder.om */ -class PHP5TableMapBuilderTest extends BookstoreTestBase -{ +class PHP5TableMapBuilderTest extends BookstoreTestBase +{ protected $databaseMap; protected function setUp() { - parent::setUp(); + parent::setUp(); $this->databaseMap = Propel::getDatabaseMap('bookstore'); } - + public function testColumnDefaultValue() { $table = $this->databaseMap->getTableByPhpName('BookstoreEmployeeAccount'); @@ -35,15 +35,15 @@ class PHP5TableMapBuilderTest extends BookstoreTestBase $this->assertTrue($table->getColumn('enabled')->getDefaultValue(), 'boolean default values are correctly mapped'); $this->assertFalse($table->getColumn('not_enabled')->getDefaultValue(), 'boolean default values are correctly mapped'); $this->assertEquals('CURRENT_TIMESTAMP', $table->getColumn('created')->getDefaultValue(), 'expression default values are correctly mapped'); - $this->assertNull($table->getColumn('role_id')->getDefaultValue(), 'explicit null default values are correctly mapped'); + $this->assertNull($table->getColumn('role_id')->getDefaultValue(), 'explicit null default values are correctly mapped'); } public function testRelationCount() { $bookTable = $this->databaseMap->getTableByPhpName('Book'); - $this->assertEquals(9, count($bookTable->getRelations()), 'The map builder creates relations for both incoming and outgoing keys'); + $this->assertEquals(14, count($bookTable->getRelations()), 'The map builder creates relations for both incoming and outgoing keys'); } - + public function testSimpleRelationName() { $bookTable = $this->databaseMap->getTableByPhpName('Book'); @@ -64,7 +64,7 @@ class PHP5TableMapBuilderTest extends BookstoreTestBase $this->assertTrue($essayTable->hasRelation('AuthorRelatedByFirstAuthor'), 'The map builder creates relations based on the foreign table name and the foreign key'); $this->assertTrue($essayTable->hasRelation('AuthorRelatedBySecondAuthor'), 'The map builder creates relations based on the foreign table name and the foreign key'); } - + public function testRelationDirectionManyToOne() { $bookTable = $this->databaseMap->getTableByPhpName('Book'); @@ -94,33 +94,33 @@ class PHP5TableMapBuilderTest extends BookstoreTestBase $bookTable = $this->databaseMap->getTableByPhpName('Book'); $this->assertEquals(RelationMap::MANY_TO_MANY, $bookTable->getRelation('BookClubList')->getType(), 'The map builder creates MANY_TO_MANY relations for every cross key'); } - + public function testRelationsColumns() { $bookTable = $this->databaseMap->getTableByPhpName('Book'); - $expectedMapping = array('book.PUBLISHER_ID' => 'publisher.ID'); + $expectedMapping = array('book.publisher_id' => 'publisher.id'); $this->assertEquals($expectedMapping, $bookTable->getRelation('Publisher')->getColumnMappings(), 'The map builder adds columns in the correct order for foreign keys'); - $expectedMapping = array('review.BOOK_ID' => 'book.ID'); + $expectedMapping = array('review.book_id' => 'book.id'); $this->assertEquals($expectedMapping, $bookTable->getRelation('Review')->getColumnMappings(), 'The map builder adds columns in the correct order for incoming foreign keys'); $publisherTable = $this->databaseMap->getTableByPhpName('Publisher'); - $expectedMapping = array('book.PUBLISHER_ID' => 'publisher.ID'); + $expectedMapping = array('book.publisher_id' => 'publisher.id'); $this->assertEquals($expectedMapping, $publisherTable->getRelation('Book')->getColumnMappings(), 'The map builder adds local columns where the foreign key lies'); $rfTable = $this->databaseMap->getTableByPhpName('ReaderFavorite'); $expectedMapping = array( - 'reader_favorite.BOOK_ID' => 'book_opinion.BOOK_ID', - 'reader_favorite.READER_ID' => 'book_opinion.READER_ID' + 'reader_favorite.book_id' => 'book_opinion.book_id', + 'reader_favorite.reader_id' => 'book_opinion.reader_id' ); $this->assertEquals($expectedMapping, $rfTable->getRelation('BookOpinion')->getColumnMappings(), 'The map builder adds all columns for composite foreign keys'); $expectedMapping = array(); $this->assertEquals($expectedMapping, $bookTable->getRelation('BookClubList')->getColumnMappings(), 'The map builder provides no column mapping for many-to-many relationships'); } - + public function testRelationOnDelete() { $bookTable = $this->databaseMap->getTableByPhpName('Book'); $this->assertEquals('SET NULL', $bookTable->getRelation('Publisher')->getOnDelete(), 'The map builder adds columns with the correct onDelete'); } - + public function testRelationOnUpdate() { $bookTable = $this->databaseMap->getTableByPhpName('Book'); @@ -133,17 +133,31 @@ class PHP5TableMapBuilderTest extends BookstoreTestBase $bookTable = $this->databaseMap->getTableByPhpName('Book'); $this->assertEquals($bookTable->getBehaviors(), array(), 'getBehaviors() returns an empty array when no behaviors are registered'); $tmap = Propel::getDatabaseMap(Table1Peer::DATABASE_NAME)->getTable(Table1Peer::TABLE_NAME); - $expectedBehaviorParams = array('timestampable' => array('create_column' => 'created_on', 'update_column' => 'updated_on')); + $expectedBehaviorParams = array('timestampable' => array('create_column' => 'created_on', 'update_column' => 'updated_on', 'disable_updated_at' => 'false')); $this->assertEquals($tmap->getBehaviors(), $expectedBehaviorParams, 'The map builder creates a getBehaviors() method to retrieve behaviors parameters when behaviors are registered'); } - public function testSingleTableInheritance() - { - $bookTable = $this->databaseMap->getTableByPhpName('Book'); - $this->assertFalse($bookTable->isSingleTableInheritance(), 'isSingleTabkeInheritance() returns false by default'); + public function testSingleTableInheritance() + { + $bookTable = $this->databaseMap->getTableByPhpName('Book'); + $this->assertFalse($bookTable->isSingleTableInheritance(), 'isSingleTableInheritance() returns false by default'); - $empTable = $this->databaseMap->getTableByPhpName('BookstoreEmployee'); - $this->assertTrue($empTable->isSingleTableInheritance(), 'isSingleTabkeInheritance() returns true for tables using single table inheritance'); + $empTable = $this->databaseMap->getTableByPhpName('BookstoreEmployee'); + $this->assertTrue($empTable->isSingleTableInheritance(), 'isSingleTableInheritance() returns true for tables using single table inheritance'); + } - } + public function testPrimaryString() + { + $bookTable = $this->databaseMap->getTableByPhpName('Book'); + $this->assertTrue($bookTable->hasPrimaryStringColumn(), 'The map builder adds primaryString columns.'); + $this->assertEquals($bookTable->getColumn('title'), $bookTable->getPrimaryStringColumn(), 'The map builder maps the correct column as primaryString.'); + } + + public function testIsCrossRef() + { + $bookTable = $this->databaseMap->getTableByPhpName('Book'); + $this->assertFalse($bookTable->isCrossRef(), 'The map builder add isCrossRef information "false"'); + $BookListRelTable = $this->databaseMap->getTableByPhpName('BookListRel'); + $this->assertTrue($BookListRelTable->isCrossRef(), 'The map builder add isCrossRef information "true"'); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/QueryBuilderInheritanceTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/QueryBuilderInheritanceTest.php index 10fbb1e23..5f68551f5 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/QueryBuilderInheritanceTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/QueryBuilderInheritanceTest.php @@ -8,8 +8,8 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; -require_once 'tools/helpers/bookstore/BookstoreDataPopulator.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/BookstoreDataPopulator.php'; /** * Test class for MultiExtensionQueryBuilder. @@ -18,78 +18,159 @@ require_once 'tools/helpers/bookstore/BookstoreDataPopulator.php'; * @version $Id: QueryBuilderTest.php 1347 2009-12-03 21:06:36Z francois $ * @package generator.builder.om */ -class QueryBuilderInheritanceTest extends BookstoreTestBase -{ - - public function testConstruct() - { - $query = BookstoreCashierQuery::create(); - $this->assertTrue($query instanceof BookstoreCashierQuery, 'the create() factory returns an instance of the correct class'); - } - - public function testFindFilter() - { - BookstoreDataPopulator::depopulate($this->con); - $employee = new BookstoreEmployee(); - $employee->save($this->con); - $manager = new BookstoreManager(); - $manager->save($this->con); - $cashier1 = new BookstoreCashier(); - $cashier1->save($this->con); - $cashier2 = new BookstoreCashier(); - $cashier2->save($this->con); - $nbEmp = BookstoreEmployeeQuery::create()->count($this->con); - $this->assertEquals(4, $nbEmp, 'find() in main query returns all results'); - $nbMan = BookstoreManagerQuery::create()->count($this->con); - $this->assertEquals(1, $nbMan, 'find() in sub query returns only child results'); - $nbCash = BookstoreCashierQuery::create()->count($this->con); - $this->assertEquals(2, $nbCash, 'find() in sub query returns only child results'); - } +class QueryBuilderInheritanceTest extends BookstoreTestBase +{ - public function testUpdateFilter() - { - BookstoreDataPopulator::depopulate($this->con); - $manager = new BookstoreManager(); - $manager->save($this->con); - $cashier1 = new BookstoreCashier(); - $cashier1->save($this->con); - $cashier2 = new BookstoreCashier(); - $cashier2->save($this->con); - BookstoreManagerQuery::create()->update(array('Name' => 'foo'), $this->con); - $nbMan = BookstoreEmployeeQuery::create() - ->filterByName('foo') - ->count($this->con); - $this->assertEquals(1, $nbMan, 'Update in sub query affects only child results'); - } + public function testConstruct() + { + $query = BookstoreCashierQuery::create(); + $this->assertTrue($query instanceof BookstoreCashierQuery, 'the create() factory returns an instance of the correct class'); + } - public function testDeleteFilter() - { - BookstoreDataPopulator::depopulate($this->con); - $manager = new BookstoreManager(); - $manager->save($this->con); - $cashier1 = new BookstoreCashier(); - $cashier1->save($this->con); - $cashier2 = new BookstoreCashier(); - $cashier2->save($this->con); - BookstoreManagerQuery::create() - ->filterByName() - ->delete(); - $nbCash = BookstoreEmployeeQuery::create()->count(); - $this->assertEquals(2, $nbCash, 'Delete in sub query affects only child results'); - } - - public function testDeleteAllFilter() - { - BookstoreDataPopulator::depopulate($this->con); - $manager = new BookstoreManager(); - $manager->save($this->con); - $cashier1 = new BookstoreCashier(); - $cashier1->save($this->con); - $cashier2 = new BookstoreCashier(); - $cashier2->save($this->con); - BookstoreManagerQuery::create()->deleteAll(); - $nbCash = BookstoreEmployeeQuery::create()->count(); - $this->assertEquals(2, $nbCash, 'Delete in sub query affects only child results'); - } + public function testFindFilter() + { + BookstoreDataPopulator::depopulate($this->con); + $employee = new BookstoreEmployee(); + $employee->save($this->con); + $manager = new BookstoreManager(); + $manager->save($this->con); + $cashier1 = new BookstoreCashier(); + $cashier1->save($this->con); + $cashier2 = new BookstoreCashier(); + $cashier2->save($this->con); + $nbEmp = BookstoreEmployeeQuery::create()->count($this->con); + $this->assertEquals(4, $nbEmp, 'find() in main query returns all results'); + $nbMan = BookstoreManagerQuery::create()->count($this->con); + $this->assertEquals(1, $nbMan, 'find() in sub query returns only child results'); + $nbCash = BookstoreCashierQuery::create()->count($this->con); + $this->assertEquals(2, $nbCash, 'find() in sub query returns only child results'); + } + + public function testUpdateFilter() + { + BookstoreDataPopulator::depopulate($this->con); + $manager = new BookstoreManager(); + $manager->save($this->con); + $cashier1 = new BookstoreCashier(); + $cashier1->save($this->con); + $cashier2 = new BookstoreCashier(); + $cashier2->save($this->con); + BookstoreManagerQuery::create()->update(array('Name' => 'foo'), $this->con); + $nbMan = BookstoreEmployeeQuery::create() + ->filterByName('foo') + ->count($this->con); + $this->assertEquals(1, $nbMan, 'Update in sub query affects only child results'); + } + + public function testDeleteFilter() + { + BookstoreDataPopulator::depopulate($this->con); + $manager = new BookstoreManager(); + $manager->save($this->con); + $cashier1 = new BookstoreCashier(); + $cashier1->save($this->con); + $cashier2 = new BookstoreCashier(); + $cashier2->save($this->con); + BookstoreManagerQuery::create() + ->filterByName() + ->delete(); + $nbCash = BookstoreEmployeeQuery::create()->count(); + $this->assertEquals(2, $nbCash, 'Delete in sub query affects only child results'); + } + + public function testDeleteAllFilter() + { + BookstoreDataPopulator::depopulate($this->con); + $manager = new BookstoreManager(); + $manager->save($this->con); + $cashier1 = new BookstoreCashier(); + $cashier1->save($this->con); + $cashier2 = new BookstoreCashier(); + $cashier2->save($this->con); + BookstoreManagerQuery::create()->deleteAll(); + $nbCash = BookstoreEmployeeQuery::create()->count(); + $this->assertEquals(2, $nbCash, 'Delete in sub query affects only child results'); + } + + public function testFindPkSimpleWithSingleTableInheritanceReturnCorrectClass() + { + Propel::disableInstancePooling(); + + $employee = new BookstoreEmployee(); + $employee->save($this->con); + $manager = new BookstoreManager(); + $manager->save($this->con); + $cashier1 = new BookstoreCashier(); + $cashier1->save($this->con); + $cashier2 = new BookstoreCashier(); + $cashier2->save($this->con); + + $this->assertInstanceOf('BookstoreEmployee', BookstoreEmployeeQuery::create()->findPk($employee->getId()), + 'findPk() return right object : BookstoreEmployee'); + $this->assertInstanceOf('BookstoreManager', BookstoreEmployeeQuery::create()->findPk($manager->getId()), + 'findPk() return right object : BookstoreManager'); + $this->assertInstanceOf('BookstoreCashier', BookstoreEmployeeQuery::create()->findPk($cashier1->getId()), + 'findPk() return right object : BookstoreCashier'); + $this->assertInstanceOf('BookstoreCashier', BookstoreEmployeeQuery::create()->findPk($cashier2->getId()), + 'findPk() return right object : BookstoreCashier'); + + Propel::enableInstancePooling(); + } + + public function testGetCorrectTableMapClassWithAbstractSingleTableInheritance() + { + Propel::initialize(); + $this->assertInstanceOf('DistributionTableMap', DistributionPeer::getTableMap(), 'getTableMap should return the right table map'); + } + + /** + * This test prove failure with propel.emulateForeignKeyConstraints = true + */ + public function testDeleteCascadeWithAbstractSingleTableInheritance() + { + $manager = new DistributionManager(); + $manager->setName('test'); + $manager->save(); + $manager->delete(); + } + + public function testFindPkSimpleWithAbstractSingleTableInheritanceReturnCorrectClass() + { + Propel::disableInstancePooling(); + + $manager = new DistributionManager(); + $manager->setName('manager1'); + $manager->save(); + + $distributionStore = new DistributionStore(); + $distributionStore->setName('my store 1'); + $distributionStore->setDistributionManager($manager); + $distributionStore->save(); + + $distributionVirtualStore = new DistributionVirtualStore(); + $distributionVirtualStore->setName('my VirtualStore 1'); + $distributionVirtualStore->setDistributionManager($manager); + $distributionVirtualStore->save(); + + $this->assertInstanceOf('DistributionStore', DistributionQuery::create()->findPk($distributionStore->getId()), + 'findPk() return right object : DistributionStore'); + $this->assertInstanceOf('DistributionVirtualStore', DistributionQuery::create()->findPk($distributionVirtualStore->getId()), + 'findPk() return right object : DistributionVirtualStore'); + + Propel::enableInstancePooling(); + } + + public function testFindOneOrCreateFunction() + { + $cashier1 = new BookstoreCashier(); + $cashier1->save($this->con); + + $cashier2 = BookstoreCashierQuery::create()->findOneOrCreate($this->con); + $this->assertInstanceOf('BookstoreCashier', $cashier2, 'findOneOrCreate return right object when find one : BookstoreCashier'); + + BookstoreCashierQuery::create()->deleteAll($this->con); + + $cashier3 = BookstoreCashierQuery::create()->findOneOrCreate($this->con); + $this->assertInstanceOf('BookstoreCashier', $cashier3, 'findOneOrCreate return right object when create one : BookstoreCashier'); + } } - diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/QueryBuilderTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/QueryBuilderTest.php index 056c1afd4..bf695fbac 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/QueryBuilderTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/QueryBuilderTest.php @@ -8,8 +8,8 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; -require_once 'tools/helpers/bookstore/BookstoreDataPopulator.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../../tools/helpers/bookstore/BookstoreDataPopulator.php'; /** * Test class for QueryBuilder. @@ -18,895 +18,1105 @@ require_once 'tools/helpers/bookstore/BookstoreDataPopulator.php'; * @version $Id: QueryBuilderTest.php 1347 2009-12-03 21:06:36Z francois $ * @package generator.builder.om */ -class QueryBuilderTest extends BookstoreTestBase -{ - - public function testExtends() - { - $q = new BookQuery(); - $this->assertTrue($q instanceof ModelCriteria, 'Model query extends ModelCriteria'); - } - - public function testConstructor() - { - $query = new BookQuery(); - $this->assertEquals($query->getDbName(), 'bookstore', 'Constructor sets dabatase name'); - $this->assertEquals($query->getModelName(), 'Book', 'Constructor sets model name'); - } - - public function testCreate() - { - $query = BookQuery::create(); - $this->assertTrue($query instanceof BookQuery, 'create() returns an object of its class'); - $this->assertEquals($query->getDbName(), 'bookstore', 'create() sets dabatase name'); - $this->assertEquals($query->getModelName(), 'Book', 'create() sets model name'); - $query = BookQuery::create('foo'); - $this->assertTrue($query instanceof BookQuery, 'create() returns an object of its class'); - $this->assertEquals($query->getDbName(), 'bookstore', 'create() sets dabatase name'); - $this->assertEquals($query->getModelName(), 'Book', 'create() sets model name'); - $this->assertEquals($query->getModelAlias(), 'foo', 'create() can set the model alias'); - } - - public function testCreateCustom() - { - // see the myBookQuery class definition at the end of this file - $query = myCustomBookQuery::create(); - $this->assertTrue($query instanceof myCustomBookQuery, 'create() returns an object of its class'); - $this->assertTrue($query instanceof BookQuery, 'create() returns an object of its class'); - $this->assertEquals($query->getDbName(), 'bookstore', 'create() sets dabatase name'); - $this->assertEquals($query->getModelName(), 'Book', 'create() sets model name'); - $query = myCustomBookQuery::create('foo'); - $this->assertTrue($query instanceof myCustomBookQuery, 'create() returns an object of its class'); - $this->assertEquals($query->getDbName(), 'bookstore', 'create() sets dabatase name'); - $this->assertEquals($query->getModelName(), 'Book', 'create() sets model name'); - $this->assertEquals($query->getModelAlias(), 'foo', 'create() can set the model alias'); - } - - public function testBasePreSelect() - { - $method = new ReflectionMethod('Table2Query', 'basePreSelect'); - $this->assertEquals('ModelCriteria', $method->getDeclaringClass()->getName(), 'BaseQuery does not override basePreSelect() by default'); - - $method = new ReflectionMethod('Table3Query', 'basePreSelect'); - $this->assertEquals('BaseTable3Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides basePreSelect() when a behavior is registered'); - } - - public function testBasePreDelete() - { - $method = new ReflectionMethod('Table2Query', 'basePreDelete'); - $this->assertEquals('ModelCriteria', $method->getDeclaringClass()->getName(), 'BaseQuery does not override basePreDelete() by default'); - - $method = new ReflectionMethod('Table3Query', 'basePreDelete'); - $this->assertEquals('BaseTable3Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides basePreDelete() when a behavior is registered'); - } - - public function testBasePostDelete() - { - $method = new ReflectionMethod('Table2Query', 'basePostDelete'); - $this->assertEquals('ModelCriteria', $method->getDeclaringClass()->getName(), 'BaseQuery does not override basePostDelete() by default'); - - $method = new ReflectionMethod('Table3Query', 'basePostDelete'); - $this->assertEquals('BaseTable3Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides basePostDelete() when a behavior is registered'); - } - - public function testBasePreUpdate() - { - $method = new ReflectionMethod('Table2Query', 'basePreUpdate'); - $this->assertEquals('ModelCriteria', $method->getDeclaringClass()->getName(), 'BaseQuery does not override basePreUpdate() by default'); - - $method = new ReflectionMethod('Table3Query', 'basePreUpdate'); - $this->assertEquals('BaseTable3Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides basePreUpdate() when a behavior is registered'); - } - - public function testBasePostUpdate() - { - $method = new ReflectionMethod('Table2Query', 'basePostUpdate'); - $this->assertEquals('ModelCriteria', $method->getDeclaringClass()->getName(), 'BaseQuery does not override basePostUpdate() by default'); - - $method = new ReflectionMethod('Table3Query', 'basePostUpdate'); - $this->assertEquals('BaseTable3Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides basePostUpdate() when a behavior is registered'); - } - - public function testQuery() - { - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - - $q = new BookQuery(); - $book = $q - ->setModelAlias('b') - ->where('b.Title like ?', 'Don%') - ->orderBy('b.ISBN', 'desc') - ->findOne(); - $this->assertTrue($book instanceof Book); - $this->assertEquals('Don Juan', $book->getTitle()); - } - - public function testFindPk() - { - $method = new ReflectionMethod('Table4Query', 'findPk'); - $this->assertEquals('BaseTable4Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides findPk()'); - } - - public function testFindPkSimpleKey() - { - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - - BookPeer::clearInstancePool(); - $con = Propel::getConnection('bookstore'); - - // prepare the test data - $c = new ModelCriteria('bookstore', 'Book'); - $c->orderBy('Book.Id', 'desc'); - $testBook = $c->findOne(); - $count = $con->getQueryCount(); - - BookPeer::clearInstancePool(); - - $q = new BookQuery(); - $book = $q->findPk($testBook->getId()); - $this->assertEquals($testBook, $book, 'BaseQuery overrides findPk() to make it faster'); - $this->assertEquals($count+1, $con->getQueryCount(), 'findPk() issues a database query when instance pool is empty'); - - $q = new BookQuery(); - $book = $q->findPk($testBook->getId()); - $this->assertEquals($testBook, $book, 'BaseQuery overrides findPk() to make it faster'); - $this->assertEquals($count+1, $con->getQueryCount(), 'findPk() does not issue a database query when instance is in pool'); - } - - public function testFindPkCompositeKey() - { - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - - // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->find(); - foreach ($books as $book) { - $book->save(); - } - - BookPeer::clearInstancePool(); - - // retrieve the test data - $c = new ModelCriteria('bookstore', 'BookListRel'); - $bookListRelTest = $c->findOne(); - $pk = $bookListRelTest->getPrimaryKey(); - - $q = new BookListRelQuery(); - $bookListRel = $q->findPk($pk); - $this->assertEquals($bookListRelTest, $bookListRel, 'BaseQuery overrides findPk() for composite primary keysto make it faster'); - } - - public function testFindPks() - { - $method = new ReflectionMethod('Table4Query', 'findPks'); - $this->assertEquals('BaseTable4Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides findPks()'); - } - - public function testFindPksSimpleKey() - { - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - - BookPeer::clearInstancePool(); - - // prepare the test data - $c = new ModelCriteria('bookstore', 'Book'); - $c->orderBy('Book.Id', 'desc'); - $testBooks = $c->find(); - $testBook1 = $testBooks->pop(); - $testBook2 = $testBooks->pop(); - - $q = new BookQuery(); - $books = $q->findPks(array($testBook1->getId(), $testBook2->getId())); - $this->assertEquals(array($testBook1, $testBook2), $books->getData(), 'BaseQuery overrides findPks() to make it faster'); - } - - public function testFindPksCompositeKey() - { - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - - // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->find(); - foreach ($books as $book) { - $book->save(); - } - - BookPeer::clearInstancePool(); - - // retrieve the test data - $c = new ModelCriteria('bookstore', 'BookListRel'); - $bookListRelTest = $c->find(); - $search = array(); - foreach ($bookListRelTest as $obj) { - $search[]= $obj->getPrimaryKey(); - } - - $q = new BookListRelQuery(); - $objs = $q->findPks($search); - $this->assertEquals($bookListRelTest, $objs, 'BaseQuery overrides findPks() for composite primary keys to make it work'); - } - - public function testFilterBy() - { - foreach (BookPeer::getFieldNames(BasePeer::TYPE_PHPNAME) as $colName) { - $filterMethod = 'filterBy' . $colName; - $this->assertTrue(method_exists('BookQuery', $filterMethod), 'QueryBuilder adds filterByColumn() methods for every column'); - $q = BookQuery::create()->$filterMethod(1); - $this->assertTrue($q instanceof BookQuery, 'filterByColumn() returns the current query instance'); - } - } - - public function testFilterByPrimaryKeySimpleKey() - { - $q = BookQuery::create()->filterByPrimaryKey(12); - $q1 = BookQuery::create()->add(BookPeer::ID, 12, Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByPrimaryKey() translates to a Criteria::EQUAL in the PK column'); - - $q = BookQuery::create()->setModelAlias('b', true)->filterByPrimaryKey(12); - $q1 = BookQuery::create()->setModelAlias('b', true)->add('b.ID', 12, Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByPrimaryKey() uses true table alias if set'); - } - - public function testFilterByPrimaryKeyCompositeKey() - { - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - - // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->find(); - foreach ($books as $book) { - $book->save(); - } - - BookPeer::clearInstancePool(); - - // retrieve the test data - $c = new ModelCriteria('bookstore', 'BookListRel'); - $bookListRelTest = $c->findOne(); - $pk = $bookListRelTest->getPrimaryKey(); - - $q = new BookListRelQuery(); - $q->filterByPrimaryKey($pk); - - $q1 = BookListRelQuery::create() - ->add(BookListRelPeer::BOOK_ID, $pk[0], Criteria::EQUAL) - ->add(BookListRelPeer::BOOK_CLUB_LIST_ID, $pk[1], Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByPrimaryKey() translates to a Criteria::EQUAL in the PK columns'); - } - - public function testFilterByPrimaryKeysSimpleKey() - { - $q = BookQuery::create()->filterByPrimaryKeys(array(10, 11, 12)); - $q1 = BookQuery::create()->add(BookPeer::ID, array(10, 11, 12), Criteria::IN); - $this->assertEquals($q1, $q, 'filterByPrimaryKeys() translates to a Criteria::IN on the PK column'); - - $q = BookQuery::create()->setModelAlias('b', true)->filterByPrimaryKeys(array(10, 11, 12)); - $q1 = BookQuery::create()->setModelAlias('b', true)->add('b.ID', array(10, 11, 12), Criteria::IN); - $this->assertEquals($q1, $q, 'filterByPrimaryKeys() uses true table alias if set'); - } - - public function testFilterByPrimaryKeysCompositeKey() - { - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - - // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->find(); - foreach ($books as $book) { - $book->save(); - } - - BookPeer::clearInstancePool(); - - // retrieve the test data - $c = new ModelCriteria('bookstore', 'BookListRel'); - $bookListRelTest = $c->find(); - $search = array(); - foreach ($bookListRelTest as $obj) { - $search[]= $obj->getPrimaryKey(); - } - - $q = new BookListRelQuery(); - $q->filterByPrimaryKeys($search); - - $q1 = BookListRelQuery::create(); - foreach ($search as $key) { - $cton0 = $q1->getNewCriterion(BookListRelPeer::BOOK_ID, $key[0], Criteria::EQUAL); - $cton1 = $q1->getNewCriterion(BookListRelPeer::BOOK_CLUB_LIST_ID, $key[1], Criteria::EQUAL); - $cton0->addAnd($cton1); - $q1->addOr($cton0); - } - $this->assertEquals($q1, $q, 'filterByPrimaryKeys() translates to a series of Criteria::EQUAL in the PK columns'); - } - - public function testFilterByIntegerPk() - { - $q = BookQuery::create()->filterById(12); - $q1 = BookQuery::create()->add(BookPeer::ID, 12, Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByPkColumn() translates to a Criteria::EQUAL by default'); - - $q = BookQuery::create()->filterById(12, Criteria::NOT_EQUAL); - $q1 = BookQuery::create()->add(BookPeer::ID, 12, Criteria::NOT_EQUAL); - $this->assertEquals($q1, $q, 'filterByPkColumn() accepts an optional comparison operator'); - - $q = BookQuery::create()->setModelAlias('b', true)->filterById(12); - $q1 = BookQuery::create()->setModelAlias('b', true)->add('b.ID', 12, Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByPkColumn() uses true table alias if set'); - - $q = BookQuery::create()->filterById(array(10, 11, 12)); - $q1 = BookQuery::create()->add(BookPeer::ID, array(10, 11, 12), Criteria::IN); - $this->assertEquals($q1, $q, 'filterByPkColumn() translates to a Criteria::IN when passed a simple array key'); - - $q = BookQuery::create()->filterById(array(10, 11, 12), Criteria::NOT_IN); - $q1 = BookQuery::create()->add(BookPeer::ID, array(10, 11, 12), Criteria::NOT_IN); - $this->assertEquals($q1, $q, 'filterByPkColumn() accepts a comparison when passed a simple array key'); - } - - public function testFilterByNumber() - { - $q = BookQuery::create()->filterByPrice(12); - $q1 = BookQuery::create()->add(BookPeer::PRICE, 12, Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByNumColumn() translates to a Criteria::EQUAL by default'); - - $q = BookQuery::create()->filterByPrice(12, Criteria::NOT_EQUAL); - $q1 = BookQuery::create()->add(BookPeer::PRICE, 12, Criteria::NOT_EQUAL); - $this->assertEquals($q1, $q, 'filterByNumColumn() accepts an optional comparison operator'); - - $q = BookQuery::create()->setModelAlias('b', true)->filterByPrice(12); - $q1 = BookQuery::create()->setModelAlias('b', true)->add('b.PRICE', 12, Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByNumColumn() uses true table alias if set'); - - $q = BookQuery::create()->filterByPrice(array(10, 11, 12)); - $q1 = BookQuery::create()->add(BookPeer::PRICE, array(10, 11, 12), Criteria::IN); - $this->assertEquals($q1, $q, 'filterByNumColumn() translates to a Criteria::IN when passed a simple array key'); - - $q = BookQuery::create()->filterByPrice(array(10, 11, 12), Criteria::NOT_IN); - $q1 = BookQuery::create()->add(BookPeer::PRICE, array(10, 11, 12), Criteria::NOT_IN); - $this->assertEquals($q1, $q, 'filterByNumColumn() accepts a comparison when passed a simple array key'); - - $q = BookQuery::create()->filterByPrice(array('min' => 10)); - $q1 = BookQuery::create()->add(BookPeer::PRICE, 10, Criteria::GREATER_EQUAL); - $this->assertEquals($q1, $q, 'filterByNumColumn() translates to a Criteria::GREATER_EQUAL when passed a \'min\' key'); - - $q = BookQuery::create()->filterByPrice(array('max' => 12)); - $q1 = BookQuery::create()->add(BookPeer::PRICE, 12, Criteria::LESS_EQUAL); - $this->assertEquals($q1, $q, 'filterByNumColumn() translates to a Criteria::LESS_EQUAL when passed a \'max\' key'); - - $q = BookQuery::create()->filterByPrice(array('min' => 10, 'max' => 12)); - $q1 = BookQuery::create() - ->add(BookPeer::PRICE, 10, Criteria::GREATER_EQUAL) - ->addAnd(BookPeer::PRICE, 12, Criteria::LESS_EQUAL); - $this->assertEquals($q1, $q, 'filterByNumColumn() translates to a between when passed both a \'min\' and a \'max\' key'); - } - - public function testFilterByTimestamp() - { - $q = BookstoreEmployeeAccountQuery::create()->filterByCreated(12); - $q1 = BookstoreEmployeeAccountQuery::create()->add(BookstoreEmployeeAccountPeer::CREATED, 12, Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByDateColumn() translates to a Criteria::EQUAL by default'); - - $q = BookstoreEmployeeAccountQuery::create()->filterByCreated(12, Criteria::NOT_EQUAL); - $q1 = BookstoreEmployeeAccountQuery::create()->add(BookstoreEmployeeAccountPeer::CREATED, 12, Criteria::NOT_EQUAL); - $this->assertEquals($q1, $q, 'filterByDateColumn() accepts an optional comparison operator'); - - $q = BookstoreEmployeeAccountQuery::create()->setModelAlias('b', true)->filterByCreated(12); - $q1 = BookstoreEmployeeAccountQuery::create()->setModelAlias('b', true)->add('b.CREATED', 12, Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByDateColumn() uses true table alias if set'); - - $q = BookstoreEmployeeAccountQuery::create()->filterByCreated(array('min' => 10)); - $q1 = BookstoreEmployeeAccountQuery::create()->add(BookstoreEmployeeAccountPeer::CREATED, 10, Criteria::GREATER_EQUAL); - $this->assertEquals($q1, $q, 'filterByDateColumn() translates to a Criteria::GREATER_EQUAL when passed a \'min\' key'); - - $q = BookstoreEmployeeAccountQuery::create()->filterByCreated(array('max' => 12)); - $q1 = BookstoreEmployeeAccountQuery::create()->add(BookstoreEmployeeAccountPeer::CREATED, 12, Criteria::LESS_EQUAL); - $this->assertEquals($q1, $q, 'filterByDateColumn() translates to a Criteria::LESS_EQUAL when passed a \'max\' key'); - - $q = BookstoreEmployeeAccountQuery::create()->filterByCreated(array('min' => 10, 'max' => 12)); - $q1 = BookstoreEmployeeAccountQuery::create() - ->add(BookstoreEmployeeAccountPeer::CREATED, 10, Criteria::GREATER_EQUAL) - ->addAnd(BookstoreEmployeeAccountPeer::CREATED, 12, Criteria::LESS_EQUAL); - $this->assertEquals($q1, $q, 'filterByDateColumn() translates to a between when passed both a \'min\' and a \'max\' key'); - } - - public function testFilterByString() - { - $q = BookQuery::create()->filterByTitle('foo'); - $q1 = BookQuery::create()->add(BookPeer::TITLE, 'foo', Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByStringColumn() translates to a Criteria::EQUAL by default'); - - $q = BookQuery::create()->filterByTitle('foo', Criteria::NOT_EQUAL); - $q1 = BookQuery::create()->add(BookPeer::TITLE, 'foo', Criteria::NOT_EQUAL); - $this->assertEquals($q1, $q, 'filterByStringColumn() accepts an optional comparison operator'); - - $q = BookQuery::create()->setModelAlias('b', true)->filterByTitle('foo'); - $q1 = BookQuery::create()->setModelAlias('b', true)->add('b.TITLE', 'foo', Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByStringColumn() uses true table alias if set'); - - $q = BookQuery::create()->filterByTitle(array('foo', 'bar')); - $q1 = BookQuery::create()->add(BookPeer::TITLE, array('foo', 'bar'), Criteria::IN); - $this->assertEquals($q1, $q, 'filterByStringColumn() translates to a Criteria::IN when passed an array'); - - $q = BookQuery::create()->filterByTitle(array('foo', 'bar'), Criteria::NOT_IN); - $q1 = BookQuery::create()->add(BookPeer::TITLE, array('foo', 'bar'), Criteria::NOT_IN); - $this->assertEquals($q1, $q, 'filterByStringColumn() accepts a comparison when passed an array'); - - $q = BookQuery::create()->filterByTitle('foo%'); - $q1 = BookQuery::create()->add(BookPeer::TITLE, 'foo%', Criteria::LIKE); - $this->assertEquals($q1, $q, 'filterByStringColumn() translates to a Criteria::LIKE when passed a string with a % wildcard'); - - $q = BookQuery::create()->filterByTitle('foo%', Criteria::NOT_LIKE); - $q1 = BookQuery::create()->add(BookPeer::TITLE, 'foo%', Criteria::NOT_LIKE); - $this->assertEquals($q1, $q, 'filterByStringColumn() accepts a comparison when passed a string with a % wildcard'); - - $q = BookQuery::create()->filterByTitle('foo%', Criteria::EQUAL); - $q1 = BookQuery::create()->add(BookPeer::TITLE, 'foo%', Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByStringColumn() accepts a comparison when passed a string with a % wildcard'); - - $q = BookQuery::create()->filterByTitle('*foo'); - $q1 = BookQuery::create()->add(BookPeer::TITLE, '%foo', Criteria::LIKE); - $this->assertEquals($q1, $q, 'filterByStringColumn() translates to a Criteria::LIKE when passed a string with a * wildcard, and turns * into %'); - - $q = BookQuery::create()->filterByTitle('*f%o*o%'); - $q1 = BookQuery::create()->add(BookPeer::TITLE, '%f%o%o%', Criteria::LIKE); - $this->assertEquals($q1, $q, 'filterByStringColumn() translates to a Criteria::LIKE when passed a string with mixed wildcards, and turns *s into %s'); - } - - public function testFilterByBoolean() - { - $q = ReviewQuery::create()->filterByRecommended(true); - $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, true, Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a Criteria::EQUAL by default'); - - $q = ReviewQuery::create()->filterByRecommended(true, Criteria::NOT_EQUAL); - $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, true, Criteria::NOT_EQUAL); - $this->assertEquals($q1, $q, 'filterByBooleanColumn() accepts an optional comparison operator'); - - $q = ReviewQuery::create()->filterByRecommended(false); - $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, false, Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a Criteria::EQUAL by default'); - - $q = ReviewQuery::create()->setModelAlias('b', true)->filterByRecommended(true); - $q1 = ReviewQuery::create()->setModelAlias('b', true)->add('b.RECOMMENDED', true, Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByBooleanColumn() uses true table alias if set'); - - $q = ReviewQuery::create()->filterByRecommended('true'); - $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, true, Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a = true when passed a true string'); - - $q = ReviewQuery::create()->filterByRecommended('yes'); - $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, true, Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a = true when passed a true string'); - - $q = ReviewQuery::create()->filterByRecommended('1'); - $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, true, Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a = true when passed a true string'); - - $q = ReviewQuery::create()->filterByRecommended('false'); - $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, false, Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a = false when passed a false string'); - - $q = ReviewQuery::create()->filterByRecommended('no'); - $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, false, Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a = false when passed a false string'); - - $q = ReviewQuery::create()->filterByRecommended('0'); - $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, false, Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a = false when passed a false string'); - } - - public function testFilterByFk() - { - $this->assertTrue(method_exists('BookQuery', 'filterByAuthor'), 'QueryBuilder adds filterByFk() methods'); - $this->assertTrue(method_exists('BookQuery', 'filterByPublisher'), 'QueryBuilder adds filterByFk() methods for all fkeys'); - - $this->assertTrue(method_exists('EssayQuery', 'filterByAuthorRelatedByFirstAuthor'), 'QueryBuilder adds filterByFk() methods for several fkeys on the same table'); - $this->assertTrue(method_exists('EssayQuery', 'filterByAuthorRelatedBySecondAuthor'), 'QueryBuilder adds filterByFk() methods for several fkeys on the same table'); - } - - public function testFilterByFkSimpleKey() - { - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - - // prepare the test data - $testBook = BookQuery::create() - ->innerJoin('Book.Author') // just in case there are books with no author - ->findOne(); - $testAuthor = $testBook->getAuthor(); - - $book = BookQuery::create() - ->filterByAuthor($testAuthor) - ->findOne(); - $this->assertEquals($testBook, $book, 'Generated query handles filterByFk() methods correctly for simple fkeys'); - - $q = BookQuery::create()->filterByAuthor($testAuthor); - $q1 = BookQuery::create()->add(BookPeer::AUTHOR_ID, $testAuthor->getId(), Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByFk() translates to a Criteria::EQUAL by default'); - - $q = BookQuery::create()->filterByAuthor($testAuthor, Criteria::NOT_EQUAL); - $q1 = BookQuery::create()->add(BookPeer::AUTHOR_ID, $testAuthor->getId(), Criteria::NOT_EQUAL); - $this->assertEquals($q1, $q, 'filterByFk() accepts an optional comparison operator'); - } - - public function testFilterByFkCompositeKey() - { - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - BookstoreDataPopulator::populateOpinionFavorite(); - - // prepare the test data - $testOpinion = BookOpinionQuery::create() - ->innerJoin('BookOpinion.ReaderFavorite') // just in case there are books with no author - ->findOne(); - $testFavorite = $testOpinion->getReaderFavorite(); - - $favorite = ReaderFavoriteQuery::create() - ->filterByBookOpinion($testOpinion) - ->findOne(); - $this->assertEquals($testFavorite, $favorite, 'Generated query handles filterByFk() methods correctly for composite fkeys'); - } - - public function testFilterByRefFk() - { - $this->assertTrue(method_exists('BookQuery', 'filterByReview'), 'QueryBuilder adds filterByRefFk() methods'); - $this->assertTrue(method_exists('BookQuery', 'filterByMedia'), 'QueryBuilder adds filterByRefFk() methods for all fkeys'); - - $this->assertTrue(method_exists('AuthorQuery', 'filterByEssayRelatedByFirstAuthor'), 'QueryBuilder adds filterByRefFk() methods for several fkeys on the same table'); - $this->assertTrue(method_exists('AuthorQuery', 'filterByEssayRelatedBySecondAuthor'), 'QueryBuilder adds filterByRefFk() methods for several fkeys on the same table'); - } - - public function testFilterByRefFkSimpleKey() - { - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - - // prepare the test data - $testBook = BookQuery::create() - ->innerJoin('Book.Author') // just in case there are books with no author - ->findOne(); - $testAuthor = $testBook->getAuthor(); - - $author = AuthorQuery::create() - ->filterByBook($testBook) - ->findOne(); - $this->assertEquals($testAuthor, $author, 'Generated query handles filterByRefFk() methods correctly for simple fkeys'); - - $q = AuthorQuery::create()->filterByBook($testBook); - $q1 = AuthorQuery::create()->add(AuthorPeer::ID, $testBook->getAuthorId(), Criteria::EQUAL); - $this->assertEquals($q1, $q, 'filterByRefFk() translates to a Criteria::EQUAL by default'); - - $q = AuthorQuery::create()->filterByBook($testBook, Criteria::NOT_EQUAL); - $q1 = AuthorQuery::create()->add(AuthorPeer::ID, $testBook->getAuthorId(), Criteria::NOT_EQUAL); - $this->assertEquals($q1, $q, 'filterByRefFk() accepts an optional comparison operator'); - } - - public function testFilterByRefFkCompositeKey() - { - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - BookstoreDataPopulator::populateOpinionFavorite(); - - // prepare the test data - $testOpinion = BookOpinionQuery::create() - ->innerJoin('BookOpinion.ReaderFavorite') // just in case there are books with no author - ->findOne(); - $testFavorite = $testOpinion->getReaderFavorite(); - - $opinion = BookOpinionQuery::create() - ->filterByReaderFavorite($testFavorite) - ->findOne(); - $this->assertEquals($testOpinion, $opinion, 'Generated query handles filterByRefFk() methods correctly for composite fkeys'); - } - - public function testFilterByCrossFK() - { - $this->assertTrue(method_exists('BookQuery', 'filterByBookClubList'), 'Generated query handles filterByCrossRefFK() for many-to-many relationships'); - $this->assertFalse(method_exists('BookQuery', 'filterByBook'), 'Generated query handles filterByCrossRefFK() for many-to-many relationships'); - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - $blc1 = BookClubListQuery::create()->findOneByGroupLeader('Crazyleggs'); - $nbBooks = BookQuery::create() - ->filterByBookClubList($blc1) - ->count(); - $this->assertEquals(2, $nbBooks, 'Generated query handles filterByCrossRefFK() methods correctly'); - } - - public function testJoinFk() - { - $q = BookQuery::create() - ->joinAuthor(); - $q1 = BookQuery::create() - ->join('Book.Author', Criteria::LEFT_JOIN); - $this->assertTrue($q->equals($q1), 'joinFk() translates to a left join on non-required columns'); - - $q = ReviewQuery::create() - ->joinBook(); - $q1 = ReviewQuery::create() - ->join('Review.Book', Criteria::INNER_JOIN); - $this->assertTrue($q->equals($q1), 'joinFk() translates to an inner join on required columns'); - - $q = BookQuery::create() - ->joinAuthor('a'); - $q1 = BookQuery::create() - ->join('Book.Author a', Criteria::LEFT_JOIN); - $this->assertTrue($q->equals($q1), 'joinFk() accepts a relation alias as first parameter'); - - $q = BookQuery::create() - ->joinAuthor('', Criteria::INNER_JOIN); - $q1 = BookQuery::create() - ->join('Book.Author', Criteria::INNER_JOIN); - $this->assertTrue($q->equals($q1), 'joinFk() accepts a join type as second parameter'); - - $q = EssayQuery::create() - ->joinAuthorRelatedBySecondAuthor(); - $q1 = EssayQuery::create() - ->join('Essay.AuthorRelatedBySecondAuthor', "INNER JOIN"); - $this->assertTrue($q->equals($q1), 'joinFk() translates to a "INNER JOIN" when this is defined as defaultJoin in the schema'); - } - - public function testJoinFkAlias() - { - $q = BookQuery::create('b') - ->joinAuthor('a'); - $q1 = BookQuery::create('b') - ->join('b.Author a', Criteria::LEFT_JOIN); - $this->assertTrue($q->equals($q1), 'joinFk() works fine with table aliases'); - - $q = BookQuery::create() - ->setModelAlias('b', true) - ->joinAuthor('a'); - $q1 = BookQuery::create() - ->setModelAlias('b', true) - ->join('b.Author a', Criteria::LEFT_JOIN); - $this->assertTrue($q->equals($q1), 'joinFk() works fine with true table aliases'); - } - - public function testJoinRefFk() - { - $q = AuthorQuery::create() - ->joinBook(); - $q1 = AuthorQuery::create() - ->join('Author.Book', Criteria::LEFT_JOIN); - $this->assertTrue($q->equals($q1), 'joinRefFk() translates to a left join on non-required columns'); - - $q = BookQuery::create() - ->joinreview(); - $q1 = BookQuery::create() - ->join('Book.Review', Criteria::INNER_JOIN); - $this->assertTrue($q->equals($q1), 'joinRefFk() translates to an inner join on required columns'); - - $q = AuthorQuery::create() - ->joinBook('b'); - $q1 = AuthorQuery::create() - ->join('Author.Book b', Criteria::LEFT_JOIN); - $this->assertTrue($q->equals($q1), 'joinRefFk() accepts a relation alias as first parameter'); - - $q = AuthorQuery::create() - ->joinBook('', Criteria::INNER_JOIN); - $q1 = AuthorQuery::create() - ->join('Author.Book', Criteria::INNER_JOIN); - $this->assertTrue($q->equals($q1), 'joinRefFk() accepts a join type as second parameter'); - - $q = AuthorQuery::create() - ->joinEssayRelatedBySecondAuthor(); - $q1 = AuthorQuery::create() - ->join('Author.EssayRelatedBySecondAuthor', Criteria::INNER_JOIN); - $this->assertTrue($q->equals($q1), 'joinRefFk() translates to a "INNER JOIN" when this is defined as defaultJoin in the schema'); - } - - public function testUseFkQuerySimple() - { - $q = BookQuery::create() - ->useAuthorQuery() - ->filterByFirstName('Leo') - ->endUse(); - $q1 = BookQuery::create() - ->join('Book.Author', Criteria::LEFT_JOIN) - ->add(AuthorPeer::FIRST_NAME, 'Leo', Criteria::EQUAL); - $this->assertTrue($q->equals($q1), 'useFkQuery() translates to a condition on a left join on non-required columns'); - - $q = ReviewQuery::create() - ->useBookQuery() - ->filterByTitle('War And Peace') - ->endUse(); - $q1 = ReviewQuery::create() - ->join('Review.Book', Criteria::INNER_JOIN) - ->add(BookPeer::TITLE, 'War And Peace', Criteria::EQUAL); - $this->assertTrue($q->equals($q1), 'useFkQuery() translates to a condition on aninner join on required columns'); - } - - public function testUseFkQueryJoinType() - { - $q = BookQuery::create() - ->useAuthorQuery(null, Criteria::LEFT_JOIN) - ->filterByFirstName('Leo') - ->endUse(); - $q1 = BookQuery::create() - ->join('Book.Author', Criteria::LEFT_JOIN) - ->add(AuthorPeer::FIRST_NAME, 'Leo', Criteria::EQUAL); - $this->assertTrue($q->equals($q1), 'useFkQuery() accepts a join type as second parameter'); - } - - public function testUseFkQueryAlias() - { - $q = BookQuery::create() - ->useAuthorQuery('a') - ->filterByFirstName('Leo') - ->endUse(); - $join = new ModelJoin(); - $join->setJoinType(Criteria::LEFT_JOIN); - $join->setTableMap(AuthorPeer::getTableMap()); - $join->setRelationMap(BookPeer::getTableMap()->getRelation('Author'), null, 'a'); - $join->setRelationAlias('a'); - $q1 = BookQuery::create() - ->addAlias('a', AuthorPeer::TABLE_NAME) - ->addJoinObject($join, 'a') - ->add('a.FIRST_NAME', 'Leo', Criteria::EQUAL); - $this->assertTrue($q->equals($q1), 'useFkQuery() uses the first argument as a table alias'); - } - - public function testUseFkQueryMixed() - { - $q = BookQuery::create() - ->useAuthorQuery() - ->filterByFirstName('Leo') - ->endUse() - ->filterByTitle('War And Peace'); - $q1 = BookQuery::create() - ->join('Book.Author', Criteria::LEFT_JOIN) - ->add(AuthorPeer::FIRST_NAME, 'Leo', Criteria::EQUAL) - ->add(BookPeer::TITLE, 'War And Peace', Criteria::EQUAL); - $this->assertTrue($q->equals($q1), 'useFkQuery() allows combining conditions on main and related query'); - } - - public function testUseFkQueryTwice() - { - $q = BookQuery::create() - ->useAuthorQuery() - ->filterByFirstName('Leo') - ->endUse() - ->useAuthorQuery() - ->filterByLastName('Tolstoi') - ->endUse(); - $q1 = BookQuery::create() - ->join('Book.Author', Criteria::LEFT_JOIN) - ->add(AuthorPeer::FIRST_NAME, 'Leo', Criteria::EQUAL) - ->add(AuthorPeer::LAST_NAME, 'Tolstoi', Criteria::EQUAL); - $this->assertTrue($q->equals($q1), 'useFkQuery() called twice on the same relation does not create two joins'); - } - - public function testUseFkQueryTwiceTwoAliases() - { - $q = BookQuery::create() - ->useAuthorQuery('a') - ->filterByFirstName('Leo') - ->endUse() - ->useAuthorQuery('b') - ->filterByLastName('Tolstoi') - ->endUse(); - $join1 = new ModelJoin(); - $join1->setJoinType(Criteria::LEFT_JOIN); - $join1->setTableMap(AuthorPeer::getTableMap()); - $join1->setRelationMap(BookPeer::getTableMap()->getRelation('Author'), null, 'a'); - $join1->setRelationAlias('a'); - $join2 = new ModelJoin(); - $join2->setJoinType(Criteria::LEFT_JOIN); - $join2->setTableMap(AuthorPeer::getTableMap()); - $join2->setRelationMap(BookPeer::getTableMap()->getRelation('Author'), null, 'b'); - $join2->setRelationAlias('b'); - $q1 = BookQuery::create() - ->addAlias('a', AuthorPeer::TABLE_NAME) - ->addJoinObject($join1, 'a') - ->add('a.FIRST_NAME', 'Leo', Criteria::EQUAL) - ->addAlias('b', AuthorPeer::TABLE_NAME) - ->addJoinObject($join2, 'b') - ->add('b.LAST_NAME', 'Tolstoi', Criteria::EQUAL); - $this->assertTrue($q->equals($q1), 'useFkQuery() called twice on the same relation with two aliases creates two joins'); - } - - public function testUseFkQueryNested() - { - $q = ReviewQuery::create() - ->useBookQuery() - ->useAuthorQuery() - ->filterByFirstName('Leo') - ->endUse() - ->endUse(); - $q1 = ReviewQuery::create() - ->join('Review.Book', Criteria::INNER_JOIN) - ->join('Book.Author', Criteria::LEFT_JOIN) - ->add(AuthorPeer::FIRST_NAME, 'Leo', Criteria::EQUAL); - // embedded queries create joins that keep a relation to the parent - // as this is not testable, we need to use another testing technique - $params = array(); - $result = BasePeer::createSelectSql($q, $params); - $expectedParams = array(); - $expectedResult = BasePeer::createSelectSql($q1, $expectedParams); - $this->assertEquals($expectedParams, $params, 'useFkQuery() called nested creates two joins'); - $this->assertEquals($expectedResult, $result, 'useFkQuery() called nested creates two joins'); - } - - public function testUseFkQueryTwoRelations() - { - $q = BookQuery::create() - ->useAuthorQuery() - ->filterByFirstName('Leo') - ->endUse() - ->usePublisherQuery() - ->filterByName('Penguin') - ->endUse(); - $q1 = BookQuery::create() - ->join('Book.Author', Criteria::LEFT_JOIN) - ->add(AuthorPeer::FIRST_NAME, 'Leo', Criteria::EQUAL) - ->join('Book.Publisher', Criteria::LEFT_JOIN) - ->add(PublisherPeer::NAME, 'Penguin', Criteria::EQUAL); - $this->assertTrue($q->equals($q1), 'useFkQuery() called twice on two relations creates two joins'); - } - - public function testPrune() - { - $q = BookQuery::create()->prune(); - $this->assertTrue($q instanceof BookQuery, 'prune() returns the current Query object'); - } - - public function testPruneSimpleKey() - { - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - - $nbBooks = BookQuery::create()->prune()->count(); - $this->assertEquals(4, $nbBooks, 'prune() does nothing when passed a null object'); - - $testBook = BookQuery::create()->findOne(); - $nbBooks = BookQuery::create()->prune($testBook)->count(); - $this->assertEquals(3, $nbBooks, 'prune() removes an object from the result'); - } - - public function testPruneCompositeKey() - { - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - - // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->find(); - foreach ($books as $book) { - $book->save(); - } - - BookPeer::clearInstancePool(); - - $nbBookListRel = BookListRelQuery::create()->prune()->count(); - $this->assertEquals(2, $nbBookListRel, 'prune() does nothing when passed a null object'); - - $testBookListRel = BookListRelQuery::create()->findOne(); - $nbBookListRel = BookListRelQuery::create()->prune($testBookListRel)->count(); - $this->assertEquals(1, $nbBookListRel, 'prune() removes an object from the result'); - } +class QueryBuilderTest extends BookstoreTestBase +{ + + public function testExtends() + { + $q = new BookQuery(); + $this->assertTrue($q instanceof ModelCriteria, 'Model query extends ModelCriteria'); + } + + public function testConstructor() + { + $query = new BookQuery(); + $this->assertEquals($query->getDbName(), 'bookstore', 'Constructor sets database name'); + $this->assertEquals($query->getModelName(), 'Book', 'Constructor sets model name'); + } + + public function testCreate() + { + $query = BookQuery::create(); + $this->assertTrue($query instanceof BookQuery, 'create() returns an object of its class'); + $this->assertEquals($query->getDbName(), 'bookstore', 'create() sets database name'); + $this->assertEquals($query->getModelName(), 'Book', 'create() sets model name'); + $query = BookQuery::create('foo'); + $this->assertTrue($query instanceof BookQuery, 'create() returns an object of its class'); + $this->assertEquals($query->getDbName(), 'bookstore', 'create() sets database name'); + $this->assertEquals($query->getModelName(), 'Book', 'create() sets model name'); + $this->assertEquals($query->getModelAlias(), 'foo', 'create() can set the model alias'); + } + + public function testCreateCustom() + { + // see the myBookQuery class definition at the end of this file + $query = myCustomBookQuery::create(); + $this->assertTrue($query instanceof myCustomBookQuery, 'create() returns an object of its class'); + $this->assertTrue($query instanceof BookQuery, 'create() returns an object of its class'); + $this->assertEquals($query->getDbName(), 'bookstore', 'create() sets database name'); + $this->assertEquals($query->getModelName(), 'Book', 'create() sets model name'); + $query = myCustomBookQuery::create('foo'); + $this->assertTrue($query instanceof myCustomBookQuery, 'create() returns an object of its class'); + $this->assertEquals($query->getDbName(), 'bookstore', 'create() sets database name'); + $this->assertEquals($query->getModelName(), 'Book', 'create() sets model name'); + $this->assertEquals($query->getModelAlias(), 'foo', 'create() can set the model alias'); + } + + public function testBasePreSelect() + { + $method = new ReflectionMethod('Table2Query', 'basePreSelect'); + $this->assertEquals('ModelCriteria', $method->getDeclaringClass()->getName(), 'BaseQuery does not override basePreSelect() by default'); + + $method = new ReflectionMethod('Table3Query', 'basePreSelect'); + $this->assertEquals('BaseTable3Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides basePreSelect() when a behavior is registered'); + } + + public function testBasePreDelete() + { + $method = new ReflectionMethod('Table2Query', 'basePreDelete'); + $this->assertEquals('ModelCriteria', $method->getDeclaringClass()->getName(), 'BaseQuery does not override basePreDelete() by default'); + + $method = new ReflectionMethod('Table3Query', 'basePreDelete'); + $this->assertEquals('BaseTable3Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides basePreDelete() when a behavior is registered'); + } + + public function testBasePostDelete() + { + $method = new ReflectionMethod('Table2Query', 'basePostDelete'); + $this->assertEquals('ModelCriteria', $method->getDeclaringClass()->getName(), 'BaseQuery does not override basePostDelete() by default'); + + $method = new ReflectionMethod('Table3Query', 'basePostDelete'); + $this->assertEquals('BaseTable3Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides basePostDelete() when a behavior is registered'); + } + + public function testBasePreUpdate() + { + $method = new ReflectionMethod('Table2Query', 'basePreUpdate'); + $this->assertEquals('ModelCriteria', $method->getDeclaringClass()->getName(), 'BaseQuery does not override basePreUpdate() by default'); + + $method = new ReflectionMethod('Table3Query', 'basePreUpdate'); + $this->assertEquals('BaseTable3Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides basePreUpdate() when a behavior is registered'); + } + + public function testBasePostUpdate() + { + $method = new ReflectionMethod('Table2Query', 'basePostUpdate'); + $this->assertEquals('ModelCriteria', $method->getDeclaringClass()->getName(), 'BaseQuery does not override basePostUpdate() by default'); + + $method = new ReflectionMethod('Table3Query', 'basePostUpdate'); + $this->assertEquals('BaseTable3Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides basePostUpdate() when a behavior is registered'); + } + + public function testQuery() + { + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + + $q = new BookQuery(); + $book = $q + ->setModelAlias('b') + ->where('b.Title like ?', 'Don%') + ->orderBy('b.ISBN', 'desc') + ->findOne(); + $this->assertTrue($book instanceof Book); + $this->assertEquals('Don Juan', $book->getTitle()); + } + + public function testFindPk() + { + $method = new ReflectionMethod('Table4Query', 'findPk'); + $this->assertEquals('BaseTable4Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides findPk()'); + } + + public function testFindOneById() + { + $method = new ReflectionMethod('Table4Query', 'findOneById'); + $this->assertEquals('BaseTable4Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides findOneById()'); + } + + public function testFindPkReturnsCorrectObjectForSimplePrimaryKey() + { + $b = new Book(); + $b->setTitle('bar'); + $b->setIsbn('2342'); + $b->save($this->con); + $count = $this->con->getQueryCount(); + + BookPeer::clearInstancePool(); + + $book = BookQuery::create()->findPk($b->getId(), $this->con); + $this->assertEquals($b, $book); + $this->assertEquals($count+1, $this->con->getQueryCount(), 'findPk() issues a database query when instance is not in pool'); + } + + public function testFindPkUsesInstancePoolingForSimplePrimaryKey() + { + $b = new Book(); + $b->setTitle('foo'); + $b->setIsbn('2342'); + $b->save($this->con); + $count = $this->con->getQueryCount(); + + $book = BookQuery::create()->findPk($b->getId(), $this->con); + $this->assertSame($b, $book); + $this->assertEquals($count, $this->con->getQueryCount(), 'findPk() does not issue a database query when instance is in pool'); + } + + public function testFindPkReturnsCorrectObjectForCompositePrimaryKey() + { + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + + // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->find(); + foreach ($books as $book) { + $book->save(); + } + + BookPeer::clearInstancePool(); + + // retrieve the test data + $c = new ModelCriteria('bookstore', 'BookListRel'); + $bookListRelTest = $c->findOne(); + $pk = $bookListRelTest->getPrimaryKey(); + + $q = new BookListRelQuery(); + $bookListRel = $q->findPk($pk); + $this->assertEquals($bookListRelTest, $bookListRel, 'BaseQuery overrides findPk() for composite primary keysto make it faster'); + } + + public function testFindPkUsesFindPkSimpleOnEmptyQueries() + { + BookQuery::create()->findPk(123, $this->con); + $expected = 'SELECT id, title, isbn, price, publisher_id, author_id FROM book WHERE id = 123'; + $this->assertEquals($expected, $this->con->getLastExecutedQuery()); + } + + public function testFindPkSimpleAddsObjectToInstancePool() + { + $b = new Book(); + $b->setTitle('foo'); + $b->setIsbn('2342'); + $b->save($this->con); + BookPeer::clearInstancePool(); + + BookQuery::create()->findPk($b->getId(), $this->con); + $count = $this->con->getQueryCount(); + + $book = BookQuery::create()->findPk($b->getId(), $this->con); + $this->assertEquals($b, $book); + $this->assertEquals($count, $this->con->getQueryCount()); + } + + public function testFindOneByIdAddsObjectToInstancePool() + { + $b = new Book(); + $b->setTitle('foo'); + $b->setIsbn('2342'); + $b->save($this->con); + BookPeer::clearInstancePool(); + + BookQuery::create()->findOneById($b->getId(), $this->con); + $count = $this->con->getQueryCount(); + + $book = BookQuery::create()->findOneById($b->getId(), $this->con); + $this->assertEquals($b, $book); + $this->assertEquals($count, $this->con->getQueryCount()); + } + + public function testFindPkUsesFindPkComplexOnNonEmptyQueries() + { + BookQuery::create('b')->findPk(123, $this->con); + $expected = 'SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.id=123'; + $this->assertEquals($expected, $this->con->getLastExecutedQuery()); + } + + public function testFindPkComplexAddsObjectToInstancePool() + { + $b = new Book(); + $b->setTitle('foo'); + $b->setIsbn('2345'); + $b->save($this->con); + BookPeer::clearInstancePool(); + + BookQuery::create('b')->findPk($b->getId(), $this->con); + $count = $this->con->getQueryCount(); + + $book = BookQuery::create()->findPk($b->getId(), $this->con); + $this->assertEquals($b, $book); + $this->assertEquals($count, $this->con->getQueryCount()); + } + + public function testFindPkCallsPreSelect() + { + $q = new mySecondBookQuery(); + $this->assertFalse($q::$preSelectWasCalled); + $q->findPk(123); + $this->assertTrue($q::$preSelectWasCalled); + } + + public function testFindPkDoesNotCallPreSelectWhenUsingInstancePool() + { + $b = new Book(); + $b->setTitle('foo'); + $b->setIsbn('1245'); + $b->save(); + + $q = new mySecondBookQuery(); + $this->assertFalse($q::$preSelectWasCalled); + $q->findPk($b->getId()); + $this->assertFalse($q::$preSelectWasCalled); + } + + public function testFindPks() + { + $method = new ReflectionMethod('Table4Query', 'findPks'); + $this->assertEquals('BaseTable4Query', $method->getDeclaringClass()->getName(), 'BaseQuery overrides findPks()'); + } + + public function testFindPksSimpleKey() + { + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + + BookPeer::clearInstancePool(); + + // prepare the test data + $c = new ModelCriteria('bookstore', 'Book'); + $c->orderBy('Book.Id', 'desc'); + $testBooks = $c->find(); + $testBook1 = $testBooks->pop(); + $testBook2 = $testBooks->pop(); + + $q = new BookQuery(); + $books = $q->findPks(array($testBook1->getId(), $testBook2->getId())); + $this->assertEquals(array($testBook1, $testBook2), $books->getData(), 'BaseQuery overrides findPks() to make it faster'); + } + + public function testFindPksCompositeKey() + { + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + + // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->find(); + foreach ($books as $book) { + $book->save(); + } + + BookPeer::clearInstancePool(); + + // retrieve the test data + $c = new ModelCriteria('bookstore', 'BookListRel'); + $bookListRelTest = $c->find(); + $search = array(); + foreach ($bookListRelTest as $obj) { + $search[]= $obj->getPrimaryKey(); + } + + $q = new BookListRelQuery(); + $objs = $q->findPks($search); + $this->assertEquals($bookListRelTest, $objs, 'BaseQuery overrides findPks() for composite primary keys to make it work'); + } + + public function testFilterBy() + { + foreach (BookPeer::getFieldNames(BasePeer::TYPE_PHPNAME) as $colName) { + $filterMethod = 'filterBy' . $colName; + $this->assertTrue(method_exists('BookQuery', $filterMethod), 'QueryBuilder adds filterByColumn() methods for every column'); + $q = BookQuery::create()->$filterMethod(1); + $this->assertTrue($q instanceof BookQuery, 'filterByColumn() returns the current query instance'); + } + } + + public function testFilterByPrimaryKeySimpleKey() + { + $q = BookQuery::create()->filterByPrimaryKey(12); + $q1 = BookQuery::create()->add(BookPeer::ID, 12, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByPrimaryKey() translates to a Criteria::EQUAL in the PK column'); + + $q = BookQuery::create()->setModelAlias('b', true)->filterByPrimaryKey(12); + $q1 = BookQuery::create()->setModelAlias('b', true)->add('b.id', 12, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByPrimaryKey() uses true table alias if set'); + } + + public function testFilterByPrimaryKeyCompositeKey() + { + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + + // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->find(); + foreach ($books as $book) { + $book->save(); + } + + BookPeer::clearInstancePool(); + + // retrieve the test data + $c = new ModelCriteria('bookstore', 'BookListRel'); + $bookListRelTest = $c->findOne(); + $pk = $bookListRelTest->getPrimaryKey(); + + $q = new BookListRelQuery(); + $q->filterByPrimaryKey($pk); + + $q1 = BookListRelQuery::create() + ->add(BookListRelPeer::BOOK_ID, $pk[0], Criteria::EQUAL) + ->add(BookListRelPeer::BOOK_CLUB_LIST_ID, $pk[1], Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByPrimaryKey() translates to a Criteria::EQUAL in the PK columns'); + } + + public function testFilterByPrimaryKeysSimpleKey() + { + $q = BookQuery::create()->filterByPrimaryKeys(array(10, 11, 12)); + $q1 = BookQuery::create()->add(BookPeer::ID, array(10, 11, 12), Criteria::IN); + $this->assertEquals($q1, $q, 'filterByPrimaryKeys() translates to a Criteria::IN on the PK column'); + + $q = BookQuery::create()->setModelAlias('b', true)->filterByPrimaryKeys(array(10, 11, 12)); + $q1 = BookQuery::create()->setModelAlias('b', true)->add('b.id', array(10, 11, 12), Criteria::IN); + $this->assertEquals($q1, $q, 'filterByPrimaryKeys() uses true table alias if set'); + } + + public function testFilterByPrimaryKeysCompositeKey() + { + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + + // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->find(); + foreach ($books as $book) { + $book->save(); + } + + BookPeer::clearInstancePool(); + + // retrieve the test data + $c = new ModelCriteria('bookstore', 'BookListRel'); + $bookListRelTest = $c->find(); + $search = array(); + foreach ($bookListRelTest as $obj) { + $search[]= $obj->getPrimaryKey(); + } + + $q = new BookListRelQuery(); + $q->filterByPrimaryKeys($search); + + $q1 = BookListRelQuery::create(); + foreach ($search as $key) { + $cton0 = $q1->getNewCriterion(BookListRelPeer::BOOK_ID, $key[0], Criteria::EQUAL); + $cton1 = $q1->getNewCriterion(BookListRelPeer::BOOK_CLUB_LIST_ID, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $q1->addOr($cton0); + } + $this->assertEquals($q1, $q, 'filterByPrimaryKeys() translates to a series of Criteria::EQUAL in the PK columns'); + + $q = new BookListRelQuery(); + $q->filterByPrimaryKeys(array()); + + $q1 = BookListRelQuery::create(); + $q1->add(null, '1<>1', Criteria::CUSTOM); + $this->assertEquals($q1, $q, 'filterByPrimaryKeys() translates to an always failing test on empty arrays'); + + } + + public function testFilterByIntegerPk() + { + $q = BookQuery::create()->filterById(12); + $q1 = BookQuery::create()->add(BookPeer::ID, 12, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByPkColumn() translates to a Criteria::EQUAL by default'); + + $q = BookQuery::create()->filterById(12, Criteria::NOT_EQUAL); + $q1 = BookQuery::create()->add(BookPeer::ID, 12, Criteria::NOT_EQUAL); + $this->assertEquals($q1, $q, 'filterByPkColumn() accepts an optional comparison operator'); + + $q = BookQuery::create()->setModelAlias('b', true)->filterById(12); + $q1 = BookQuery::create()->setModelAlias('b', true)->add('b.id', 12, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByPkColumn() uses true table alias if set'); + + $q = BookQuery::create()->filterById(array(10, 11, 12)); + $q1 = BookQuery::create()->add(BookPeer::ID, array(10, 11, 12), Criteria::IN); + $this->assertEquals($q1, $q, 'filterByPkColumn() translates to a Criteria::IN when passed a simple array key'); + + $q = BookQuery::create()->filterById(array(10, 11, 12), Criteria::NOT_IN); + $q1 = BookQuery::create()->add(BookPeer::ID, array(10, 11, 12), Criteria::NOT_IN); + $this->assertEquals($q1, $q, 'filterByPkColumn() accepts a comparison when passed a simple array key'); + } + + public function testFilterByNumber() + { + $q = BookQuery::create()->filterByPrice(12); + $q1 = BookQuery::create()->add(BookPeer::PRICE, 12, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByNumColumn() translates to a Criteria::EQUAL by default'); + + $q = BookQuery::create()->filterByPrice(12, Criteria::NOT_EQUAL); + $q1 = BookQuery::create()->add(BookPeer::PRICE, 12, Criteria::NOT_EQUAL); + $this->assertEquals($q1, $q, 'filterByNumColumn() accepts an optional comparison operator'); + + $q = BookQuery::create()->setModelAlias('b', true)->filterByPrice(12); + $q1 = BookQuery::create()->setModelAlias('b', true)->add('b.price', 12, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByNumColumn() uses true table alias if set'); + + $q = BookQuery::create()->filterByPrice(array(10, 11, 12)); + $q1 = BookQuery::create()->add(BookPeer::PRICE, array(10, 11, 12), Criteria::IN); + $this->assertEquals($q1, $q, 'filterByNumColumn() translates to a Criteria::IN when passed a simple array key'); + + $q = BookQuery::create()->filterByPrice(array(10, 11, 12), Criteria::NOT_IN); + $q1 = BookQuery::create()->add(BookPeer::PRICE, array(10, 11, 12), Criteria::NOT_IN); + $this->assertEquals($q1, $q, 'filterByNumColumn() accepts a comparison when passed a simple array key'); + + $q = BookQuery::create()->filterByPrice(array('min' => 10)); + $q1 = BookQuery::create()->add(BookPeer::PRICE, 10, Criteria::GREATER_EQUAL); + $this->assertEquals($q1, $q, 'filterByNumColumn() translates to a Criteria::GREATER_EQUAL when passed a \'min\' key'); + + $q = BookQuery::create()->filterByPrice(array('max' => 12)); + $q1 = BookQuery::create()->add(BookPeer::PRICE, 12, Criteria::LESS_EQUAL); + $this->assertEquals($q1, $q, 'filterByNumColumn() translates to a Criteria::LESS_EQUAL when passed a \'max\' key'); + + $q = BookQuery::create()->filterByPrice(array('min' => 10, 'max' => 12)); + $q1 = BookQuery::create() + ->add(BookPeer::PRICE, 10, Criteria::GREATER_EQUAL) + ->addAnd(BookPeer::PRICE, 12, Criteria::LESS_EQUAL); + $this->assertEquals($q1, $q, 'filterByNumColumn() translates to a between when passed both a \'min\' and a \'max\' key'); + } + + public function testFilterByTimestamp() + { + $q = BookstoreEmployeeAccountQuery::create()->filterByCreated(12); + $q1 = BookstoreEmployeeAccountQuery::create()->add(BookstoreEmployeeAccountPeer::CREATED, 12, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByDateColumn() translates to a Criteria::EQUAL by default'); + + $q = BookstoreEmployeeAccountQuery::create()->filterByCreated(12, Criteria::NOT_EQUAL); + $q1 = BookstoreEmployeeAccountQuery::create()->add(BookstoreEmployeeAccountPeer::CREATED, 12, Criteria::NOT_EQUAL); + $this->assertEquals($q1, $q, 'filterByDateColumn() accepts an optional comparison operator'); + + $q = BookstoreEmployeeAccountQuery::create()->setModelAlias('b', true)->filterByCreated(12); + $q1 = BookstoreEmployeeAccountQuery::create()->setModelAlias('b', true)->add('b.created', 12, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByDateColumn() uses true table alias if set'); + + $q = BookstoreEmployeeAccountQuery::create()->filterByCreated(array('min' => 10)); + $q1 = BookstoreEmployeeAccountQuery::create()->add(BookstoreEmployeeAccountPeer::CREATED, 10, Criteria::GREATER_EQUAL); + $this->assertEquals($q1, $q, 'filterByDateColumn() translates to a Criteria::GREATER_EQUAL when passed a \'min\' key'); + + $q = BookstoreEmployeeAccountQuery::create()->filterByCreated(array('max' => 12)); + $q1 = BookstoreEmployeeAccountQuery::create()->add(BookstoreEmployeeAccountPeer::CREATED, 12, Criteria::LESS_EQUAL); + $this->assertEquals($q1, $q, 'filterByDateColumn() translates to a Criteria::LESS_EQUAL when passed a \'max\' key'); + + $q = BookstoreEmployeeAccountQuery::create()->filterByCreated(array('min' => 10, 'max' => 12)); + $q1 = BookstoreEmployeeAccountQuery::create() + ->add(BookstoreEmployeeAccountPeer::CREATED, 10, Criteria::GREATER_EQUAL) + ->addAnd(BookstoreEmployeeAccountPeer::CREATED, 12, Criteria::LESS_EQUAL); + $this->assertEquals($q1, $q, 'filterByDateColumn() translates to a between when passed both a \'min\' and a \'max\' key'); + } + + public function testFilterByString() + { + $q = BookQuery::create()->filterByTitle('foo'); + $q1 = BookQuery::create()->add(BookPeer::TITLE, 'foo', Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByStringColumn() translates to a Criteria::EQUAL by default'); + + $q = BookQuery::create()->filterByTitle('foo', Criteria::NOT_EQUAL); + $q1 = BookQuery::create()->add(BookPeer::TITLE, 'foo', Criteria::NOT_EQUAL); + $this->assertEquals($q1, $q, 'filterByStringColumn() accepts an optional comparison operator'); + + $q = BookQuery::create()->setModelAlias('b', true)->filterByTitle('foo'); + $q1 = BookQuery::create()->setModelAlias('b', true)->add('b.title', 'foo', Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByStringColumn() uses true table alias if set'); + + $q = BookQuery::create()->filterByTitle(array('foo', 'bar')); + $q1 = BookQuery::create()->add(BookPeer::TITLE, array('foo', 'bar'), Criteria::IN); + $this->assertEquals($q1, $q, 'filterByStringColumn() translates to a Criteria::IN when passed an array'); + + $q = BookQuery::create()->filterByTitle(array('foo', 'bar'), Criteria::NOT_IN); + $q1 = BookQuery::create()->add(BookPeer::TITLE, array('foo', 'bar'), Criteria::NOT_IN); + $this->assertEquals($q1, $q, 'filterByStringColumn() accepts a comparison when passed an array'); + + $q = BookQuery::create()->filterByTitle('foo%'); + $q1 = BookQuery::create()->add(BookPeer::TITLE, 'foo%', Criteria::LIKE); + $this->assertEquals($q1, $q, 'filterByStringColumn() translates to a Criteria::LIKE when passed a string with a % wildcard'); + + $q = BookQuery::create()->filterByTitle('foo%', Criteria::NOT_LIKE); + $q1 = BookQuery::create()->add(BookPeer::TITLE, 'foo%', Criteria::NOT_LIKE); + $this->assertEquals($q1, $q, 'filterByStringColumn() accepts a comparison when passed a string with a % wildcard'); + + $q = BookQuery::create()->filterByTitle('foo%', Criteria::EQUAL); + $q1 = BookQuery::create()->add(BookPeer::TITLE, 'foo%', Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByStringColumn() accepts a comparison when passed a string with a % wildcard'); + + $q = BookQuery::create()->filterByTitle('*foo'); + $q1 = BookQuery::create()->add(BookPeer::TITLE, '%foo', Criteria::LIKE); + $this->assertEquals($q1, $q, 'filterByStringColumn() translates to a Criteria::LIKE when passed a string with a * wildcard, and turns * into %'); + + $q = BookQuery::create()->filterByTitle('*f%o*o%'); + $q1 = BookQuery::create()->add(BookPeer::TITLE, '%f%o%o%', Criteria::LIKE); + $this->assertEquals($q1, $q, 'filterByStringColumn() translates to a Criteria::LIKE when passed a string with mixed wildcards, and turns *s into %s'); + } + + public function testFilterByBoolean() + { + $q = ReviewQuery::create()->filterByRecommended(true); + $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, true, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a Criteria::EQUAL by default'); + + $q = ReviewQuery::create()->filterByRecommended(true, Criteria::NOT_EQUAL); + $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, true, Criteria::NOT_EQUAL); + $this->assertEquals($q1, $q, 'filterByBooleanColumn() accepts an optional comparison operator'); + + $q = ReviewQuery::create()->filterByRecommended(false); + $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, false, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a Criteria::EQUAL by default'); + + $q = ReviewQuery::create()->setModelAlias('b', true)->filterByRecommended(true); + $q1 = ReviewQuery::create()->setModelAlias('b', true)->add('b.recommended', true, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByBooleanColumn() uses true table alias if set'); + + $q = ReviewQuery::create()->filterByRecommended('true'); + $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, true, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a = true when passed a true string'); + + $q = ReviewQuery::create()->filterByRecommended('yes'); + $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, true, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a = true when passed a true string'); + + $q = ReviewQuery::create()->filterByRecommended('1'); + $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, true, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a = true when passed a true string'); + + $q = ReviewQuery::create()->filterByRecommended('false'); + $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, false, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a = false when passed a false string'); + + $q = ReviewQuery::create()->filterByRecommended('no'); + $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, false, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a = false when passed a false string'); + + $q = ReviewQuery::create()->filterByRecommended('0'); + $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, false, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a = false when passed a false string'); + + $q = ReviewQuery::create()->filterByRecommended(''); + $q1 = ReviewQuery::create()->add(ReviewPeer::RECOMMENDED, false, Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByBooleanColumn() translates to a = false when passed an empty string'); + + } + + public function testFilterByFk() + { + $this->assertTrue(method_exists('BookQuery', 'filterByAuthor'), 'QueryBuilder adds filterByFk() methods'); + $this->assertTrue(method_exists('BookQuery', 'filterByPublisher'), 'QueryBuilder adds filterByFk() methods for all fkeys'); + + $this->assertTrue(method_exists('EssayQuery', 'filterByAuthorRelatedByFirstAuthor'), 'QueryBuilder adds filterByFk() methods for several fkeys on the same table'); + $this->assertTrue(method_exists('EssayQuery', 'filterByAuthorRelatedBySecondAuthor'), 'QueryBuilder adds filterByFk() methods for several fkeys on the same table'); + } + + public function testFilterByFkSimpleKey() + { + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + + // prepare the test data + $testBook = BookQuery::create() + ->innerJoin('Book.Author') // just in case there are books with no author + ->findOne(); + $testAuthor = $testBook->getAuthor(); + + $book = BookQuery::create() + ->filterByAuthor($testAuthor) + ->findOne(); + $this->assertEquals($testBook, $book, 'Generated query handles filterByFk() methods correctly for simple fkeys'); + + $q = BookQuery::create()->filterByAuthor($testAuthor); + $q1 = BookQuery::create()->add(BookPeer::AUTHOR_ID, $testAuthor->getId(), Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByFk() translates to a Criteria::EQUAL by default'); + + $q = BookQuery::create()->filterByAuthor($testAuthor, Criteria::NOT_EQUAL); + $q1 = BookQuery::create()->add(BookPeer::AUTHOR_ID, $testAuthor->getId(), Criteria::NOT_EQUAL); + $this->assertEquals($q1, $q, 'filterByFk() accepts an optional comparison operator'); + } + + public function testFilterByFkCompositeKey() + { + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + BookstoreDataPopulator::populateOpinionFavorite(); + + // prepare the test data + $testOpinion = BookOpinionQuery::create() + ->innerJoin('BookOpinion.ReaderFavorite') // just in case there are books with no author + ->findOne(); + $testFavorite = $testOpinion->getReaderFavorite(); + + $favorite = ReaderFavoriteQuery::create() + ->filterByBookOpinion($testOpinion) + ->findOne(); + $this->assertEquals($testFavorite, $favorite, 'Generated query handles filterByFk() methods correctly for composite fkeys'); + } + + public function testFilterByFkObjectCollection() + { + BookstoreDataPopulator::depopulate($this->con); + BookstoreDataPopulator::populate($this->con); + + $authors = AuthorQuery::create() + ->orderByFirstName() + ->limit(2) + ->find($this->con); + + $books = BookQuery::create() + ->filterByAuthor($authors) + ->find($this->con); + $q1 = $this->con->getLastExecutedQuery(); + + $books = BookQuery::create() + ->add(BookPeer::AUTHOR_ID, $authors->getPrimaryKeys(), Criteria::IN) + ->find($this->con); + $q2 = $this->con->getLastExecutedQuery(); + + $this->assertEquals($q2, $q1, 'filterByFk() accepts a collection and results to an IN query'); + } + + public function testFilterByRefFk() + { + $this->assertTrue(method_exists('BookQuery', 'filterByReview'), 'QueryBuilder adds filterByRefFk() methods'); + $this->assertTrue(method_exists('BookQuery', 'filterByMedia'), 'QueryBuilder adds filterByRefFk() methods for all fkeys'); + + $this->assertTrue(method_exists('AuthorQuery', 'filterByEssayRelatedByFirstAuthor'), 'QueryBuilder adds filterByRefFk() methods for several fkeys on the same table'); + $this->assertTrue(method_exists('AuthorQuery', 'filterByEssayRelatedBySecondAuthor'), 'QueryBuilder adds filterByRefFk() methods for several fkeys on the same table'); + } + + public function testFilterByRefFkSimpleKey() + { + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + + // prepare the test data + $testBook = BookQuery::create() + ->innerJoin('Book.Author') // just in case there are books with no author + ->findOne(); + $testAuthor = $testBook->getAuthor(); + + $author = AuthorQuery::create() + ->filterByBook($testBook) + ->findOne(); + $this->assertEquals($testAuthor, $author, 'Generated query handles filterByRefFk() methods correctly for simple fkeys'); + + $q = AuthorQuery::create()->filterByBook($testBook); + $q1 = AuthorQuery::create()->add(AuthorPeer::ID, $testBook->getAuthorId(), Criteria::EQUAL); + $this->assertEquals($q1, $q, 'filterByRefFk() translates to a Criteria::EQUAL by default'); + + $q = AuthorQuery::create()->filterByBook($testBook, Criteria::NOT_EQUAL); + $q1 = AuthorQuery::create()->add(AuthorPeer::ID, $testBook->getAuthorId(), Criteria::NOT_EQUAL); + $this->assertEquals($q1, $q, 'filterByRefFk() accepts an optional comparison operator'); + } + + public function testFilterByRelationNameCompositePk() + { + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + + $testLabel = RecordLabelQuery::create() + ->limit(2) + ->find($this->con); + + $testRelease = ReleasePoolQuery::create() + ->addJoin(ReleasePoolPeer::RECORD_LABEL_ID, RecordLabelPeer::ID) + ->filterByRecordLabel($testLabel) + ->find($this->con); + $q1 = $this->con->getLastExecutedQuery(); + + $releasePool = ReleasePoolQuery::create() + ->addJoin(ReleasePoolPeer::RECORD_LABEL_ID, RecordLabelPeer::ID) + ->add(ReleasePoolPeer::RECORD_LABEL_ID, $testLabel->toKeyValue('Id', 'Id'), Criteria::IN) + ->find($this->con); + $q2 = $this->con->getLastExecutedQuery(); + + $this->assertEquals($q2, $q1, 'filterBy{RelationName}() only accepts arguments of type {RelationName} or PropelCollection'); + $this->assertEquals($releasePool, $testRelease); + } + + public function testFilterByRefFkCompositeKey() + { + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + BookstoreDataPopulator::populateOpinionFavorite(); + + // prepare the test data + $testOpinion = BookOpinionQuery::create() + ->innerJoin('BookOpinion.ReaderFavorite') // just in case there are books with no author + ->findOne(); + $testFavorite = $testOpinion->getReaderFavorite(); + + $opinion = BookOpinionQuery::create() + ->filterByReaderFavorite($testFavorite) + ->findOne(); + $this->assertEquals($testOpinion, $opinion, 'Generated query handles filterByRefFk() methods correctly for composite fkeys'); + } + + public function testFilterByRefFkObjectCollection() + { + BookstoreDataPopulator::depopulate($this->con); + BookstoreDataPopulator::populate($this->con); + + $books = BookQuery::create() + ->orderByTitle() + ->limit(2) + ->find($this->con); + + $authors = AuthorQuery::create() + ->filterByBook($books) + ->find($this->con); + $q1 = $this->con->getLastExecutedQuery(); + + $authors = AuthorQuery::create() + ->addJoin(AuthorPeer::ID, BookPeer::AUTHOR_ID, Criteria::LEFT_JOIN) + ->add(BookPeer::ID, $books->getPrimaryKeys(), Criteria::IN) + ->find($this->con); + $q2 = $this->con->getLastExecutedQuery(); + + $this->assertEquals($q2, $q1, 'filterByRefFk() accepts a collection and results to an IN query in the joined table'); + } + + public function testFilterByCrossFK() + { + $this->assertTrue(method_exists('BookQuery', 'filterByBookClubList'), 'Generated query handles filterByCrossRefFK() for many-to-many relationships'); + $this->assertFalse(method_exists('BookQuery', 'filterByBook'), 'Generated query handles filterByCrossRefFK() for many-to-many relationships'); + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + $blc1 = BookClubListQuery::create()->findOneByGroupLeader('Crazyleggs'); + $nbBooks = BookQuery::create() + ->filterByBookClubList($blc1) + ->count(); + $this->assertEquals(2, $nbBooks, 'Generated query handles filterByCrossRefFK() methods correctly'); + } + + public function testJoinFk() + { + $q = BookQuery::create() + ->joinAuthor(); + $q1 = BookQuery::create() + ->join('Book.Author', Criteria::LEFT_JOIN); + $this->assertTrue($q->equals($q1), 'joinFk() translates to a left join on non-required columns'); + + $q = BookSummaryQuery::create() + ->joinSummarizedBook(); + $q1 = BookSummaryQuery::create() + ->join('BookSummary.SummarizedBook', Criteria::INNER_JOIN); + $this->assertTrue($q->equals($q1), 'joinFk() translates to an inner join on required columns'); + + $q = BookQuery::create() + ->joinAuthor('a'); + $q1 = BookQuery::create() + ->join('Book.Author a', Criteria::LEFT_JOIN); + $this->assertTrue($q->equals($q1), 'joinFk() accepts a relation alias as first parameter'); + + $q = BookQuery::create() + ->joinAuthor('', Criteria::INNER_JOIN); + $q1 = BookQuery::create() + ->join('Book.Author', Criteria::INNER_JOIN); + $this->assertTrue($q->equals($q1), 'joinFk() accepts a join type as second parameter'); + + $q = EssayQuery::create() + ->joinAuthorRelatedBySecondAuthor(); + $q1 = EssayQuery::create() + ->join('Essay.AuthorRelatedBySecondAuthor', "INNER JOIN"); + $this->assertTrue($q->equals($q1), 'joinFk() translates to a "INNER JOIN" when this is defined as defaultJoin in the schema'); + } + + public function testJoinFkAlias() + { + $q = BookQuery::create('b') + ->joinAuthor('a'); + $q1 = BookQuery::create('b') + ->join('b.Author a', Criteria::LEFT_JOIN); + $this->assertTrue($q->equals($q1), 'joinFk() works fine with table aliases'); + + $q = BookQuery::create() + ->setModelAlias('b', true) + ->joinAuthor('a'); + $q1 = BookQuery::create() + ->setModelAlias('b', true) + ->join('b.Author a', Criteria::LEFT_JOIN); + $this->assertTrue($q->equals($q1), 'joinFk() works fine with true table aliases'); + } + + public function testJoinRefFk() + { + $q = AuthorQuery::create() + ->joinBook(); + $q1 = AuthorQuery::create() + ->join('Author.Book', Criteria::LEFT_JOIN); + $this->assertTrue($q->equals($q1), 'joinRefFk() translates to a left join on non-required columns'); + + $q = BookQuery::create() + ->joinBookSummary(); + $q1 = BookQuery::create() + ->join('Book.BookSummary', Criteria::INNER_JOIN); + $this->assertTrue($q->equals($q1), 'joinRefFk() translates to an inner join on required columns'); + + $q = AuthorQuery::create() + ->joinBook('b'); + $q1 = AuthorQuery::create() + ->join('Author.Book b', Criteria::LEFT_JOIN); + $this->assertTrue($q->equals($q1), 'joinRefFk() accepts a relation alias as first parameter'); + + $q = AuthorQuery::create() + ->joinBook('', Criteria::INNER_JOIN); + $q1 = AuthorQuery::create() + ->join('Author.Book', Criteria::INNER_JOIN); + $this->assertTrue($q->equals($q1), 'joinRefFk() accepts a join type as second parameter'); + + $q = AuthorQuery::create() + ->joinEssayRelatedBySecondAuthor(); + $q1 = AuthorQuery::create() + ->join('Author.EssayRelatedBySecondAuthor', Criteria::INNER_JOIN); + $this->assertTrue($q->equals($q1), 'joinRefFk() translates to a "INNER JOIN" when this is defined as defaultJoin in the schema'); + } + + public function testUseFkQuerySimple() + { + $q = BookQuery::create() + ->useAuthorQuery() + ->filterByFirstName('Leo') + ->endUse(); + $q1 = BookQuery::create() + ->join('Book.Author', Criteria::LEFT_JOIN) + ->add(AuthorPeer::FIRST_NAME, 'Leo', Criteria::EQUAL); + $this->assertTrue($q->equals($q1), 'useFkQuery() translates to a condition on a left join on non-required columns'); + + $q = BookSummaryQuery::create() + ->useSummarizedBookQuery() + ->filterByTitle('War And Peace') + ->endUse(); + $q1 = BookSummaryQuery::create() + ->join('BookSummary.SummarizedBook', Criteria::INNER_JOIN) + ->add(BookPeer::TITLE, 'War And Peace', Criteria::EQUAL); + $this->assertTrue($q->equals($q1), 'useFkQuery() translates to a condition on an inner join on required columns'); + } + + public function testUseFkQueryJoinType() + { + $q = BookQuery::create() + ->useAuthorQuery(null, Criteria::LEFT_JOIN) + ->filterByFirstName('Leo') + ->endUse(); + $q1 = BookQuery::create() + ->join('Book.Author', Criteria::LEFT_JOIN) + ->add(AuthorPeer::FIRST_NAME, 'Leo', Criteria::EQUAL); + $this->assertTrue($q->equals($q1), 'useFkQuery() accepts a join type as second parameter'); + } + + public function testUseFkQueryAlias() + { + $q = BookQuery::create() + ->useAuthorQuery('a') + ->filterByFirstName('Leo') + ->endUse(); + $join = new ModelJoin(); + $join->setJoinType(Criteria::LEFT_JOIN); + $join->setTableMap(AuthorPeer::getTableMap()); + $join->setRelationMap(BookPeer::getTableMap()->getRelation('Author'), null, 'a'); + $join->setRelationAlias('a'); + $q1 = BookQuery::create() + ->addAlias('a', AuthorPeer::TABLE_NAME) + ->addJoinObject($join, 'a') + ->add('a.first_name', 'Leo', Criteria::EQUAL); + $this->assertTrue($q->equals($q1), 'useFkQuery() uses the first argument as a table alias'); + } + + public function testUseFkQueryMixed() + { + $q = BookQuery::create() + ->useAuthorQuery() + ->filterByFirstName('Leo') + ->endUse() + ->filterByTitle('War And Peace'); + $q1 = BookQuery::create() + ->join('Book.Author', Criteria::LEFT_JOIN) + ->add(AuthorPeer::FIRST_NAME, 'Leo', Criteria::EQUAL) + ->add(BookPeer::TITLE, 'War And Peace', Criteria::EQUAL); + $this->assertTrue($q->equals($q1), 'useFkQuery() allows combining conditions on main and related query'); + } + + public function testUseFkQueryTwice() + { + $q = BookQuery::create() + ->useAuthorQuery() + ->filterByFirstName('Leo') + ->endUse() + ->useAuthorQuery() + ->filterByLastName('Tolstoi') + ->endUse(); + $q1 = BookQuery::create() + ->join('Book.Author', Criteria::LEFT_JOIN) + ->add(AuthorPeer::FIRST_NAME, 'Leo', Criteria::EQUAL) + ->add(AuthorPeer::LAST_NAME, 'Tolstoi', Criteria::EQUAL); + $this->assertTrue($q->equals($q1), 'useFkQuery() called twice on the same relation does not create two joins'); + } + + public function testUseFkQueryTwiceTwoAliases() + { + $q = BookQuery::create() + ->useAuthorQuery('a') + ->filterByFirstName('Leo') + ->endUse() + ->useAuthorQuery('b') + ->filterByLastName('Tolstoi') + ->endUse(); + $join1 = new ModelJoin(); + $join1->setJoinType(Criteria::LEFT_JOIN); + $join1->setTableMap(AuthorPeer::getTableMap()); + $join1->setRelationMap(BookPeer::getTableMap()->getRelation('Author'), null, 'a'); + $join1->setRelationAlias('a'); + $join2 = new ModelJoin(); + $join2->setJoinType(Criteria::LEFT_JOIN); + $join2->setTableMap(AuthorPeer::getTableMap()); + $join2->setRelationMap(BookPeer::getTableMap()->getRelation('Author'), null, 'b'); + $join2->setRelationAlias('b'); + $q1 = BookQuery::create() + ->addAlias('a', AuthorPeer::TABLE_NAME) + ->addJoinObject($join1, 'a') + ->add('a.first_name', 'Leo', Criteria::EQUAL) + ->addAlias('b', AuthorPeer::TABLE_NAME) + ->addJoinObject($join2, 'b') + ->add('b.last_name', 'Tolstoi', Criteria::EQUAL); + $this->assertTrue($q->equals($q1), 'useFkQuery() called twice on the same relation with two aliases creates two joins'); + } + + public function testUseFkQueryNested() + { + $q = ReviewQuery::create() + ->useBookQuery() + ->useAuthorQuery() + ->filterByFirstName('Leo') + ->endUse() + ->endUse(); + $q1 = ReviewQuery::create() + ->join('Review.Book', Criteria::LEFT_JOIN) + ->join('Book.Author', Criteria::LEFT_JOIN) + ->add(AuthorPeer::FIRST_NAME, 'Leo', Criteria::EQUAL); + // embedded queries create joins that keep a relation to the parent + // as this is not testable, we need to use another testing technique + $params = array(); + $result = BasePeer::createSelectSql($q, $params); + $expectedParams = array(); + $expectedResult = BasePeer::createSelectSql($q1, $expectedParams); + $this->assertEquals($expectedParams, $params, 'useFkQuery() called nested creates two joins'); + $this->assertEquals($expectedResult, $result, 'useFkQuery() called nested creates two joins'); + } + + public function testUseFkQueryTwoRelations() + { + $q = BookQuery::create() + ->useAuthorQuery() + ->filterByFirstName('Leo') + ->endUse() + ->usePublisherQuery() + ->filterByName('Penguin') + ->endUse(); + $q1 = BookQuery::create() + ->join('Book.Author', Criteria::LEFT_JOIN) + ->add(AuthorPeer::FIRST_NAME, 'Leo', Criteria::EQUAL) + ->join('Book.Publisher', Criteria::LEFT_JOIN) + ->add(PublisherPeer::NAME, 'Penguin', Criteria::EQUAL); + $this->assertTrue($q->equals($q1), 'useFkQuery() called twice on two relations creates two joins'); + } + + public function testUseFkQueryNoAliasThenWith() + { + $con = Propel::getConnection(); + $books = BookQuery::create() + ->useAuthorQuery() + ->filterByFirstName('Leo') + ->endUse() + ->with('Author') + ->find($con); + $q1 = $con->getLastExecutedQuery(); + $books = BookQuery::create() + ->leftJoinWithAuthor() + ->add(AuthorPeer::FIRST_NAME, 'Leo', Criteria::EQUAL) + ->find($con); + $q2 = $con->getLastExecutedQuery(); + $this->assertEquals($q1, $q2, 'with() can be used after a call to useFkQuery() with no alias'); + } + + public function testPrune() + { + $q = BookQuery::create()->prune(); + $this->assertTrue($q instanceof BookQuery, 'prune() returns the current Query object'); + } + + public function testPruneSimpleKey() + { + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + + $nbBooks = BookQuery::create()->prune()->count(); + $this->assertEquals(4, $nbBooks, 'prune() does nothing when passed a null object'); + + $testBook = BookQuery::create()->findOne(); + $nbBooks = BookQuery::create()->prune($testBook)->count(); + $this->assertEquals(3, $nbBooks, 'prune() removes an object from the result'); + } + + public function testPruneCompositeKey() + { + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + + // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->find(); + foreach ($books as $book) { + $book->save(); + } + + BookPeer::clearInstancePool(); + + $nbBookListRel = BookListRelQuery::create()->prune()->count(); + $this->assertEquals(2, $nbBookListRel, 'prune() does nothing when passed a null object'); + + $testBookListRel = BookListRelQuery::create()->findOne(); + $nbBookListRel = BookListRelQuery::create()->prune($testBookListRel)->count(); + $this->assertEquals(1, $nbBookListRel, 'prune() removes an object from the result'); + } } class myCustomBookQuery extends BookQuery { - public static function create($modelAlias = null, $criteria = null) - { - if ($criteria instanceof myCustomBookQuery) { - return $criteria; - } - $query = new myCustomBookQuery(); - if (null !== $modelAlias) { - $query->setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - return $query; - } - + public static function create($modelAlias = null, $criteria = null) + { + if ($criteria instanceof myCustomBookQuery) { + return $criteria; + } + $query = new myCustomBookQuery(); + if (null !== $modelAlias) { + $query->setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + +} + +class mySecondBookQuery extends BookQuery +{ + public static $preSelectWasCalled = false; + + public function __construct($dbName = 'bookstore', $modelName = 'Book', $modelAlias = null) + { + self::$preSelectWasCalled = false; + parent::__construct($dbName, $modelName, $modelAlias); + } + + public function preSelect(PropelPDO $con) + { + self::$preSelectWasCalled = true; + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/om/fixtures/ComplexColumnTypeEntityWithConstructor.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/fixtures/ComplexColumnTypeEntityWithConstructor.php new file mode 100644 index 000000000..2e8dac6db --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/om/fixtures/ComplexColumnTypeEntityWithConstructor.php @@ -0,0 +1,13 @@ +setTags( + array('foo', 'bar') + ); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/util/DefaultEnglishPluralizerTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/util/DefaultEnglishPluralizerTest.php new file mode 100644 index 000000000..5d94085d9 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/util/DefaultEnglishPluralizerTest.php @@ -0,0 +1,45 @@ +assertEquals($output, $pluralizer->getPluralForm($input)); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/util/PropelTemplateTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/util/PropelTemplateTest.php index bba32ac12..89b5560a4 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/builder/util/PropelTemplateTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/util/PropelTemplateTest.php @@ -8,47 +8,46 @@ * @license MIT License */ -require_once 'PHPUnit/Framework/TestCase.php'; -require_once 'builder/util/PropelTemplate.php'; +require_once dirname(__FILE__) . '/../../../../../generator/lib/builder/util/PropelTemplate.php'; /** * Tests for PropelTemplate class * - * @version $Revision: 1784 $ + * @version $Revision$ * @package generator.builder.util */ class PropelTemplateTest extends PHPUnit_Framework_TestCase { - public function testRenderStringNoParam() - { - $t = new PropelTemplate(); - $t->setTemplate('Hello, '); - $res = $t->render(); - $this->assertEquals('Hello, 3', $res); - } - - public function testRenderStringOneParam() - { - $t = new PropelTemplate(); - $t->setTemplate('Hello, '); - $res = $t->render(array('name' => 'John')); - $this->assertEquals('Hello, John', $res); - } + public function testRenderStringNoParam() + { + $t = new PropelTemplate(); + $t->setTemplate('Hello, '); + $res = $t->render(); + $this->assertEquals('Hello, 3', $res); + } - public function testRenderStringParams() - { - $time = time(); - $t = new PropelTemplate(); - $t->setTemplate('Hello, , it is to go!'); - $res = $t->render(array('name' => 'John', 'time' => $time)); - $this->assertEquals('Hello, John, it is ' . $time . ' to go!', $res); - } - - public function testRenderFile() - { - $t = new PropelTemplate(); - $t->setTemplateFile(dirname(__FILE__).'/template.php'); - $res = $t->render(array('name' => 'John')); - $this->assertEquals('Hello, John', $res); - } -} \ No newline at end of file + public function testRenderStringOneParam() + { + $t = new PropelTemplate(); + $t->setTemplate('Hello, '); + $res = $t->render(array('name' => 'John')); + $this->assertEquals('Hello, John', $res); + } + + public function testRenderStringParams() + { + $time = time(); + $t = new PropelTemplate(); + $t->setTemplate('Hello, , it is to go!'); + $res = $t->render(array('name' => 'John', 'time' => $time)); + $this->assertEquals('Hello, John, it is ' . $time . ' to go!', $res); + } + + public function testRenderFile() + { + $t = new PropelTemplate(); + $t->setTemplateFile(dirname(__FILE__).'/template.php'); + $res = $t->render(array('name' => 'John')); + $this->assertEquals('Hello, John', $res); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/util/StandardEnglishPluralizerTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/util/StandardEnglishPluralizerTest.php new file mode 100644 index 000000000..dc5c52dea --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/util/StandardEnglishPluralizerTest.php @@ -0,0 +1,102 @@ +assertEquals($output, $pluralizer->getPluralForm($input)); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/util/XmlToAppDataTest.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/util/XmlToAppDataTest.php new file mode 100644 index 000000000..94af5a9cc --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/util/XmlToAppDataTest.php @@ -0,0 +1,150 @@ +'; + $xtad = new XmlToAppData(); + $appData = $xtad->parseString($schema); + $expectedAppData = " +"; + $this->assertEquals($expectedAppData, $appData->toString()); + } + + public function testParseStringSchemaWithoutXmlDeclaration() + { + $schema = ''; + $xtad = new XmlToAppData(); + $appData = $xtad->parseString($schema); + $expectedAppData = " +"; + $this->assertEquals($expectedAppData, $appData->toString()); + } + + /** + * @expectedException SchemaException + */ + public function testParseStringIncorrectSchema() + { + $schema = ''; + $xtad = new XmlToAppData(); + $appData = $xtad->parseString($schema); + } + + public function testParseStringDatabase() + { + $schema = ''; + $xtad = new XmlToAppData(); + $appData = $xtad->parseString($schema); + $expectedDatabase = ''; + $database = $appData->getDatabase(); + $this->assertEquals($expectedDatabase, $database->toString()); + $expectedAppData = "\n$expectedDatabase\n"; + $this->assertEquals($expectedAppData, $appData->toString()); + } + + public function testParseStringTable() + { + $schema = '
'; + $xtad = new XmlToAppData(); + $appData = $xtad->parseString($schema); + $database = $appData->getDatabase(); + $table = $database->getTable('bar'); + $expectedTable = << + + +EOF; + $this->assertEquals($expectedTable, $table->toString()); + } + + public function testParseFile() + { + $path = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'testSchema.xml'); + $xtad = new XmlToAppData(); + $appData = $xtad->parseFile($path); + $expectedAppData = << + + + +
+
+ +EOF; + $this->assertEquals($expectedAppData, $appData->toString()); + } + + public function testParseFileExternalSchema() + { + $path = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'outerSchema.xml'); + $xtad = new XmlToAppData(); + $appData = $xtad->parseFile($path); + $expectedAppData = << + + + +
+ + +
+
+ +EOF; + $this->assertEquals($expectedAppData, $appData->toString()); + } + + /** + * @dataProvider providePathsForIsAbsolutePath + */ + public function testIsAbsolutePath($path, $expectedResult) + { + $xmlToAppData = new OpenedXmlToAppData(); + $result = $xmlToAppData->isAbsolutePath($path); + + $this->assertEquals($expectedResult, $result); + } + + /** + * @return array + */ + public function providePathsForIsAbsolutePath() + { + return array( + array('/var/lib', true), + array('c:\\\\var\\lib', true), + array('\\var\\lib', true), + array('var/lib', false), + array('../var/lib', false), + array('', false), + array(null, false) + ); + } +} + +class OpenedXmlToAppData extends XmlToAppData +{ + public function isAbsolutePath($file) + { + return parent::isAbsolutePath($file); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/util/innerSchema.xml b/airtime_mvc/library/propel/test/testsuite/generator/builder/util/innerSchema.xml new file mode 100644 index 000000000..bab631f8b --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/util/innerSchema.xml @@ -0,0 +1,6 @@ + + + + +
+
diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/util/outerSchema.xml b/airtime_mvc/library/propel/test/testsuite/generator/builder/util/outerSchema.xml new file mode 100644 index 000000000..abb7f2c53 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/util/outerSchema.xml @@ -0,0 +1,7 @@ + + + + +
+ +
diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/util/template.php b/airtime_mvc/library/propel/test/testsuite/generator/builder/util/template.php index 2ae040501..5883dc01d 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/builder/util/template.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/util/template.php @@ -1 +1 @@ -Hello, \ No newline at end of file +Hello, diff --git a/airtime_mvc/library/propel/test/testsuite/generator/builder/util/testSchema.xml b/airtime_mvc/library/propel/test/testsuite/generator/builder/util/testSchema.xml new file mode 100644 index 000000000..4e0bdedcd --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/builder/util/testSchema.xml @@ -0,0 +1,6 @@ + + + + +
+
diff --git a/airtime_mvc/library/propel/test/testsuite/generator/config/GeneratorConfigTest.php b/airtime_mvc/library/propel/test/testsuite/generator/config/GeneratorConfigTest.php new file mode 100644 index 000000000..b13ff6381 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/config/GeneratorConfigTest.php @@ -0,0 +1,68 @@ + + * @package propel.generator.config + */ +class GeneratorConfigTest extends PHPUnit_Framework_TestCase +{ + protected $pathToFixtureFiles; + + public function setUp() + { + $this->pathToFixtureFiles = dirname(__FILE__) . '/../../../fixtures/generator/config'; + } + + public function testGetClassnameWithClass() + { + $file = $this->pathToFixtureFiles . '/Foobar.php'; + + if (!file_exists($file)) { + $this->markTestSkipped(); + } + + // Load the file to simulate the autoloading process + require $file; + + $generator = new GeneratorConfig(); + $generator->setBuildProperty('propel.foo.bar', 'Foobar'); + + $this->assertSame('Foobar', $generator->getClassname('propel.foo.bar')); + } + + public function testGetClassnameWithClassAndNamespace() + { + $file = $this->pathToFixtureFiles . '/FoobarWithNS.php'; + + if (!file_exists($file)) { + $this->markTestSkipped(); + } + + // Load the file to simulate the autoloading process + require $file; + + $generator = new GeneratorConfig(); + $generator->setBuildProperty('propel.foo.bar', '\Foo\Test\FoobarWithNS'); + + $this->assertSame('\Foo\Test\FoobarWithNS', $generator->getClassname('propel.foo.bar')); + } + + /** + * @expectedException BuildException + */ + public function testGetClassnameOnInexistantProperty() + { + $generator = new GeneratorConfig(); + $generator->getClassname('propel.foo.bar'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/model/BehaviorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/model/BehaviorTest.php index af1daecb8..8d527dbaa 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/model/BehaviorTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/model/BehaviorTest.php @@ -8,31 +8,30 @@ * @license MIT License */ -require_once 'PHPUnit/Framework/TestCase.php'; -require_once 'platform/MysqlPlatform.php'; -require_once 'model/Behavior.php'; -require_once 'model/Table.php'; -require_once 'platform/MysqlPlatform.php'; +require_once dirname(__FILE__) . '/../../../../generator/lib/model/Behavior.php'; +require_once dirname(__FILE__) . '/../../../../generator/lib/model/Table.php'; +require_once dirname(__FILE__) . '/../../../../generator/lib/builder/util/XmlToAppData.php'; +require_once dirname(__FILE__) . '/../../../../generator/lib/behavior/TimestampableBehavior.php'; /** * Tests for Behavior class * * @author + + + + + + + + + +
+
+EOF; + $appData = $xmlToAppData->parseString($schema); + $table = $appData->getDatabase('test1')->getTable('table1'); + $behaviors = $table->getBehaviors(); + $this->assertEquals(1, count($behaviors), 'XmlToAppData ads as many behaviors as there are behaviors tags'); + $behavior = $table->getBehavior('timestampable'); + $this->assertEquals('table1', $behavior->getTable()->getName(), 'XmlToAppData sets the behavior table correctly'); + $this->assertEquals(array('create_column' => 'created_on', 'update_column' => 'updated_on', 'disable_updated_at' => 'false'), $behavior->getParameters(), 'XmlToAppData sets the behavior parameters correctly'); + } + /** - * test if the tables get the package name from the properties file - * + * @expectedException InvalidArgumentException */ - public function testXmlToAppData() - { - include_once 'builder/util/XmlToAppData.php'; - $this->xmlToAppData = new XmlToAppData(new MysqlPlatform(), "defaultpackage", null); - $this->appData = $this->xmlToAppData->parseFile('fixtures/bookstore/behavior-timestampable-schema.xml'); - $table = $this->appData->getDatabase("bookstore-behavior")->getTable('table1'); - $behaviors = $table->getBehaviors(); - $this->assertEquals(count($behaviors), 1, 'XmlToAppData ads as many behaviors as there are behaviors tags'); - $behavior = $table->getBehavior('timestampable'); - $this->assertEquals($behavior->getTable()->getName(), 'table1', 'XmlToAppData sets the behavior table correctly'); - $this->assertEquals($behavior->getParameters(), array('create_column' => 'created_on', 'update_column' => 'updated_on'), 'XmlToAppData sets the behavior parameters correctly'); - } - - public function testMofifyTable() - { - set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes"); - Propel::init('fixtures/bookstore/build/conf/bookstore-conf.php'); - $tmap = Propel::getDatabaseMap(Table2Peer::DATABASE_NAME)->getTable(Table2Peer::TABLE_NAME); - $this->assertEquals(count($tmap->getColumns()), 4, 'A behavior can modify its table by implementing modifyTable()'); - } - + public function testUnknownBehavior() + { + $xmlToAppData = new XmlToAppData(); + $schema = << + + + +
+ +EOF; + $appData = $xmlToAppData->parseString($schema); + } + + public function testModifyTable() + { + $xmlToAppData = new XmlToAppData(); + $schema = << + + + + +
+ +EOF; + $appData = $xmlToAppData->parseString($schema); + $table = $appData->getDatabase('test1')->getTable('table2'); + $this->assertEquals(count($table->getColumns()), 4, 'A behavior can modify its table by implementing modifyTable()'); + } + public function testModifyDatabase() { - set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes"); - require_once dirname(__FILE__) . '/../../../../runtime/lib/Propel.php'; - Propel::init('fixtures/bookstore/build/conf/bookstore-conf.php'); - $tmap = Propel::getDatabaseMap(Table3Peer::DATABASE_NAME)->getTable(Table3Peer::TABLE_NAME); - $this->assertTrue(array_key_exists('do_nothing', $tmap->getBehaviors()), 'A database behavior is automatically copied to all its table'); - } - + $xmlToAppData = new XmlToAppData(); + $schema = << + + + +
+ +EOF; + $appData = $xmlToAppData->parseString($schema); + $table = $appData->getDatabase('test1')->getTable('table1'); + $this->assertTrue(array_key_exists('timestampable', $table->getBehaviors()), 'A database behavior is automatically copied to all its table'); + } + public function testGetColumnForParameter() { - $this->xmlToAppData = new XmlToAppData(new MysqlPlatform(), "defaultpackage", null); - $this->appData = $this->xmlToAppData->parseFile('fixtures/bookstore/behavior-timestampable-schema.xml'); - - $table = $this->appData->getDatabase("bookstore-behavior")->getTable('table1'); - $behavior = $table->getBehavior('timestampable'); - $this->assertEquals($table->getColumn('created_on'), $behavior->getColumnForParameter('create_column'), 'getColumnForParameter() returns the configured column for behavior based on a parameter name'); - + $xmlToAppData = new XmlToAppData(); + $schema = << + + + + + + + + + +
+ +EOF; + $appData = $xmlToAppData->parseString($schema); + $table = $appData->getDatabase('test1')->getTable('table1'); + $behavior = $table->getBehavior('timestampable'); + $this->assertEquals($table->getColumn('created_on'), $behavior->getColumnForParameter('create_column'), 'getColumnForParameter() returns the configured column for behavior based on a parameter name'); } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/model/ColumnDefaultValueTest.php b/airtime_mvc/library/propel/test/testsuite/generator/model/ColumnDefaultValueTest.php new file mode 100644 index 000000000..8e1d01142 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/model/ColumnDefaultValueTest.php @@ -0,0 +1,43 @@ +assertTrue($def1->equals($def2)); + } else { + $this->assertFalse($def1->equals($def2)); + } + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/model/ColumnTest.php b/airtime_mvc/library/propel/test/testsuite/generator/model/ColumnTest.php index dbaf69432..0e6c23cfc 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/model/ColumnTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/model/ColumnTest.php @@ -8,74 +8,224 @@ * @license MIT License */ -require_once 'PHPUnit/Framework/TestCase.php'; -require_once 'model/Column.php'; -require_once 'builder/util/XmlToAppData.php'; -require_once 'platform/MysqlPlatform.php'; - +require_once dirname(__FILE__) . '/../../../../generator/lib/model/Column.php'; +require_once dirname(__FILE__) . '/../../../../generator/lib/builder/util/XmlToAppData.php'; +require_once dirname(__FILE__) . '/../../../../generator/lib/platform/DefaultPlatform.php'; +require_once dirname(__FILE__) . '/../../../../generator/lib/behavior/AutoAddPkBehavior.php'; /** * Tests for package handling. * * @author
setName("Column" . $i); - $objArray[] = $c; - } + /** + * Tests static Column::makeList() method. + * @deprecated - Column::makeList() is deprecated and set to be removed in 1.3 + */ + public function testMakeList() + { + $expected = '"Column0", "Column1", "Column2", "Column3", "Column4"'; + $objArray = array(); + for ($i=0; $i<5; $i++) { + $c = new Column(); + $c->setName("Column" . $i); + $objArray[] = $c; + } - $list = Column::makeList($objArray, new MySQLPlatform()); - $this->assertEquals($expected, $list, sprintf("Expected '%s' match, got '%s' ", var_export($expected, true), var_export($list,true))); + $list = Column::makeList($objArray, new DefaultPlatform()); + $this->assertEquals($expected, $list, sprintf("Expected '%s' match, got '%s' ", var_export($expected, true), var_export($list,true))); - $strArray = array(); - for ($i=0; $i<5; $i++) { - $strArray[] = "Column" . $i; - } + $strArray = array(); + for ($i=0; $i<5; $i++) { + $strArray[] = "Column" . $i; + } - $list = Column::makeList($strArray, new MySQLPlatform()); - $this->assertEquals($expected, $list, sprintf("Expected '%s' match, got '%s' ", var_export($expected, true), var_export($list,true))); + $list = Column::makeList($strArray, new DefaultPlatform()); + $this->assertEquals($expected, $list, sprintf("Expected '%s' match, got '%s' ", var_export($expected, true), var_export($list,true))); - } - - public function testPhpNamingMethod() - { - set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes"); - Propel::init('fixtures/bookstore/build/conf/bookstore-conf.php'); - $bookTmap = Propel::getDatabaseMap(BookPeer::DATABASE_NAME)->getTable(BookPeer::TABLE_NAME); - $this->assertEquals('AuthorId', $bookTmap->getColumn('AUTHOR_ID')->getPhpName(), 'setPhpName() uses the default phpNamingMethod'); - $pageTmap = Propel::getDatabaseMap(PagePeer::DATABASE_NAME)->getTable(PagePeer::TABLE_NAME); - $this->assertEquals('LeftChild', $pageTmap->getColumn('LEFTCHILD')->getPhpName(), 'setPhpName() uses the configured phpNamingMethod'); - } - - public function testGetConstantName() - { - $xmlToAppData = new XmlToAppData(new MysqlPlatform(), "defaultpackage", null); - $appData = $xmlToAppData->parseFile('fixtures/bookstore/behavior-timestampable-schema.xml'); - $column = $appData->getDatabase("bookstore-behavior")->getTable('table1')->getColumn('title'); + } + + public function testPhpNamingMethod() + { + $xmlToAppData = new XmlToAppData(new DefaultPlatform()); + $schema = << + + + + + +
+ +EOF; + $appData = $xmlToAppData->parseString($schema); + $column = $appData->getDatabase('test1')->getTable('table1')->getColumn('author_id'); + $this->assertEquals('AuthorId', $column->getPhpName(), 'setPhpName() uses the default phpNamingMethod'); + $column = $appData->getDatabase('test1')->getTable('table1')->getColumn('editor_id'); + $this->assertEquals('editor_id', $column->getPhpName(), 'setPhpName() uses the column phpNamingMethod if given'); + } + + public function testDefaultPhpNamingMethod() + { + $xmlToAppData = new XmlToAppData(new DefaultPlatform()); + $schema = << + + + + +
+ +EOF; + $appData = $xmlToAppData->parseString($schema); + $column = $appData->getDatabase('test2')->getTable('table1')->getColumn('author_id'); + $this->assertEquals('author_id', $column->getPhpName(), 'setPhpName() uses the database defaultPhpNamingMethod if given'); + } + + public function testGetConstantName() + { + $xmlToAppData = new XmlToAppData(new DefaultPlatform()); + $schema = << + + + +
+ +EOF; + $appData = $xmlToAppData->parseString($schema); + $column = $appData->getDatabase('test')->getTable('table1')->getColumn('title'); $this->assertEquals('Table1Peer::TITLE', $column->getConstantName(), 'getConstantName() returns the complete constant name by default'); - } - - public function testIsLocalColumnsRequired() - { - $xmlToAppData = new XmlToAppData(new MysqlPlatform(), "defaultpackage", null); - $appData = $xmlToAppData->parseFile('fixtures/bookstore/schema.xml'); - $fk = $appData->getDatabase("bookstore")->getTable('book')->getColumnForeignKeys('publisher_id'); - $this->assertFalse($fk[0]->isLocalColumnsRequired()); - $fk = $appData->getDatabase("bookstore")->getTable('review')->getColumnForeignKeys('book_id'); - $this->assertTrue($fk[0]->isLocalColumnsRequired()); - } + } + public function testIsLocalColumnsRequired() + { + $xmlToAppData = new XmlToAppData(new DefaultPlatform()); + $schema = << + + + + + + + + + + +
+ + + + +
+ +EOF; + $appData = $xmlToAppData->parseString($schema); + $fk = $appData->getDatabase('test')->getTable('table1')->getColumnForeignKeys('table2_foo'); + $this->assertFalse($fk[0]->isLocalColumnsRequired()); + $fk = $appData->getDatabase('test')->getTable('table1')->getColumnForeignKeys('table2_bar'); + $this->assertTrue($fk[0]->isLocalColumnsRequired()); + } + + public function testIsNamePlural() + { + $column = new Column('foo'); + $this->assertFalse($column->isNamePlural()); + $column = new Column('foos'); + $this->assertTrue($column->isNamePlural()); + $column = new Column('foso'); + $this->assertFalse($column->isNamePlural()); + } + + public function testGetSingularName() + { + $column = new Column('foo'); + $this->assertEquals('foo', $column->getSingularName()); + $column = new Column('foos'); + $this->assertEquals('foo', $column->getSingularName()); + $column = new Column('foso'); + $this->assertEquals('foso', $column->getSingularName()); + } + + public function testGetValidator() + { + $xmlToAppData = new XmlToAppData(new DefaultPlatform()); + $schema = << + + + + + + + + + + + +
+ +EOF; + $appData = $xmlToAppData->parseString($schema); + $table1 = $appData->getDatabase('test')->getTable('table1'); + $this->assertNull($table1->getColumn('id')->getValidator()); + $title1Column = $table1->getColumn('title1'); + $title1Validator = $title1Column->getValidator(); + $this->assertInstanceOf('Validator', $title1Validator); + $this->assertEquals(1, count($title1Validator->getRules())); + $title2Column = $table1->getColumn('title2'); + $title2Validator = $title2Column->getValidator(); + $this->assertInstanceOf('Validator', $title2Validator); + $this->assertEquals(2, count($title2Validator->getRules())); + } + + public function testHasPlatform() + { + $column = new Column(); + $this->assertFalse($column->hasPlatform()); + $table = new Table(); + $table->addColumn($column); + $this->assertFalse($column->hasPlatform()); + $database = new Database(); + $database->addTable($table); + $this->assertFalse($column->hasPlatform()); + $platform = new DefaultPlatform(); + $database->setPlatform($platform); + $this->assertTrue($column->hasPlatform()); + } + + public function testIsPhpArrayType() + { + $column = new Column(); + $this->assertFalse($column->isPhpArrayType()); + + $column->setType(PropelTypes::PHP_ARRAY); + $this->assertTrue($column->isPhpArrayType()); + } + + public function testCommaInEnumValueSet() + { + $column = new Column(); + $table = new Table(); + $database = new Database(); + $platform = new DefaultPlatform(); + + $table->addColumn($column); + $database->addTable($table); + $database->setPlatform($platform); + + $column->loadFromXML(array('valueSet' => 'Foo, Bar, "Foo, Bar"')); + $valueSet = $column->getValueSet(); + + $this->assertCount(3, $valueSet); + $this->assertEquals('Foo', $valueSet[0]); + $this->assertEquals('Bar', $valueSet[1]); + $this->assertEquals('Foo, Bar', $valueSet[2]); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/model/DatabaseTest.php b/airtime_mvc/library/propel/test/testsuite/generator/model/DatabaseTest.php new file mode 100644 index 000000000..a5fa903f2 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/model/DatabaseTest.php @@ -0,0 +1,146 @@ +addTable($table); + + return array( + array($database, $table) + ); + } + + public function testTableInheritsSchema() + { + $database = new Database(); + $database->setPlatform(new SchemaPlatform()); + $database->setSchema("Foo"); + $table = new Table("Bar"); + $database->addTable($table); + $this->assertTrue($database->hasTable("Foo.Bar")); + $this->assertFalse($database->hasTable("Bar")); + + $database = new Database(); + $database->setPlatform(new NoSchemaPlatform()); + $database->addTable($table); + $this->assertFalse($database->hasTable("Foo.Bar")); + $this->assertTrue($database->hasTable("Bar")); + } + + /** + * @dataProvider providerForTestHasTable + */ + public function testHasTable($database, $table) + { + $this->assertTrue($database->hasTable('Foo')); + $this->assertFalse($database->hasTable('foo')); + $this->assertFalse($database->hasTable('FOO')); + } + + /** + * @dataProvider providerForTestHasTable + */ + public function testHasTableCaseInsensitive($database, $table) + { + $this->assertTrue($database->hasTable('Foo', true)); + $this->assertTrue($database->hasTable('foo', true)); + $this->assertTrue($database->hasTable('FOO', true)); + } + + /** + * @dataProvider providerForTestHasTable + */ + public function testGetTable($database, $table) + { + $this->assertEquals($table, $database->getTable('Foo')); + $this->assertNull($database->getTable('foo')); + $this->assertNull($database->getTable('FOO')); + } + + /** + * @dataProvider providerForTestHasTable + */ + public function testGetTableCaseInsensitive($database, $table) + { + $this->assertEquals($table, $database->getTable('Foo', true)); + $this->assertEquals($table, $database->getTable('foo', true)); + $this->assertEquals($table, $database->getTable('FOO', true)); + } + + public function testAddTableDoesNotModifyTableNamespaceWhenDatabaseHasNoNamespace() + { + $db = new Database(); + + $t1 = new Table('t1'); + $db->addTable($t1); + $this->assertEquals('', $t1->getNamespace()); + + $t2 = new Table('t2'); + $t2->setNamespace('Bar'); + $db->addTable($t2); + $this->assertEquals('Bar', $t2->getNamespace()); + } + + public function testAddTableAddsDatabaseNamespaceToTheTable() + { + $db = new Database(); + $db->setNamespace('Foo'); + + $t1 = new Table('t1'); + $db->addTable($t1); + $this->assertEquals('Foo', $t1->getNamespace()); + + $t2 = new Table('t2'); + $t2->setNamespace('Bar'); + $db->addTable($t2); + $this->assertEquals('Foo\\Bar', $t2->getNamespace()); + } + + public function testAddTableSkipsDatabaseNamespaceWhenTableNamespaceIsAbsolute() + { + $db = new Database(); + $db->setNamespace('Foo'); + + $t1 = new Table('t1'); + $t1->setNamespace('\\Bar'); + $db->addTable($t1); + $this->assertEquals('Bar', $t1->getNamespace()); + } + + public function testAddTableWithSameNameOnDifferentSchema() + { + $db = new Database(); + $db->setPlatform(new SchemaPlatform()); + + $t1 = new Table('t1'); + $db->addTable($t1); + $this->assertEquals('t1', $t1->getName()); + + $t1b = new Table('t1'); + $t1b->setSchema('bis'); + $db->addTable($t1b); + $this->assertEquals('bis.t1', $t1b->getName()); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/model/NameFactoryTest.php b/airtime_mvc/library/propel/test/testsuite/generator/model/NameFactoryTest.php index e65ae05f4..b8b052356 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/model/NameFactoryTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/model/NameFactoryTest.php @@ -8,10 +8,10 @@ * @license MIT License */ -require_once 'tools/helpers/BaseTestCase.php'; -require_once 'model/NameFactory.php'; -require_once 'platform/MysqlPlatform.php'; -require_once 'model/AppData.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/BaseTestCase.php'; +require_once dirname(__FILE__) . '/../../../../generator/lib/model/NameFactory.php'; +require_once dirname(__FILE__) . '/../../../../generator/lib/platform/MysqlPlatform.php'; +require_once dirname(__FILE__) . '/../../../../generator/lib/model/AppData.php'; /** *

Unit tests for class NameFactory and known @@ -26,126 +26,130 @@ require_once 'model/AppData.php'; * characters.

* * @author
Daniel Rall - * @version $Id: NameFactoryTest.php 1612 2010-03-16 22:56:21Z francois $ + * @version $Id$ * @package generator.model */ class NameFactoryTest extends BaseTestCase { - /** The database to mimic in generating the SQL. */ - const DATABASE_TYPE = "mysql"; + /** The database to mimic in generating the SQL. */ + const DATABASE_TYPE = "mysql"; - /** - * The list of known name generation algorithms, specified as the - * fully qualified class names to NameGenerator - * implementations. - */ - private static $ALGORITHMS = array(NameFactory::CONSTRAINT_GENERATOR, NameFactory::PHP_GENERATOR); + /** + * The list of known name generation algorithms, specified as the + * fully qualified class names to NameGenerator + * implementations. + */ + private static $ALGORITHMS = array(NameFactory::CONSTRAINT_GENERATOR, NameFactory::PHP_GENERATOR); - /** - * Two dimensional arrays of inputs for each algorithm. - */ - private static $INPUTS = array(); + /** + * Two dimensional arrays of inputs for each algorithm. + */ + private static $INPUTS = array(); - /** - * Given the known inputs, the expected name outputs. - */ - private static $OUTPUTS = array(); + /** + * Given the known inputs, the expected name outputs. + */ + private static $OUTPUTS = array(); - /** - * Used as an input. - */ - private $database; + /** + * Used as an input. + */ + private $database; - /** - * Creates a new instance. - * - */ - public function __construct() { - - self::$INPUTS = array( - array( array(self::makeString(61), "I", 1), - array(self::makeString(61), "I", 2), - array(self::makeString(65), "I", 3), - array(self::makeString(4), "FK", 1), - array(self::makeString(5), "FK", 2) - ), - array( - array("MY_USER", NameGenerator::CONV_METHOD_UNDERSCORE), - array("MY_USER", NameGenerator::CONV_METHOD_PHPNAME), - array("MY_USER", NameGenerator::CONV_METHOD_NOCHANGE) - ) - ); + /** + * Creates a new instance. + * + */ + public function __construct() + { + self::$INPUTS = array( + array( array(self::makeString(61), "I", 1), + array(self::makeString(61), "I", 2), + array(self::makeString(65), "I", 3), + array(self::makeString(4), "FK", 1), + array(self::makeString(5), "FK", 2) + ), + array( + array("MY_USER", NameGenerator::CONV_METHOD_UNDERSCORE), + array("MY_USER", NameGenerator::CONV_METHOD_PHPNAME), + array("MY_USER", NameGenerator::CONV_METHOD_NOCHANGE) + ) + ); - self::$OUTPUTS = array( - array( - self::makeString(60) . "_I_1", - self::makeString(60) . "_I_2", - self::makeString(60) . "_I_3", - self::makeString(4) . "_FK_1", - self::makeString(5) . "_FK_2"), - array("MyUser", "MYUSER", "MY_USER") - ); + self::$OUTPUTS = array( + array( + self::makeString(60) . "_I_1", + self::makeString(60) . "_I_2", + self::makeString(60) . "_I_3", + self::makeString(4) . "_FK_1", + self::makeString(5) . "_FK_2"), + array("MyUser", "MYUSER", "MY_USER") + ); - } + } - /** - * Creates a string of the specified length consisting entirely of - * the character A. Useful for simulating table - * names, etc. - * - * @param int $len the number of characters to include in the string - * @return a string of length len with every character an 'A' - */ - private static function makeString($len) { - $buf = ""; - for ($i = 0; $i < $len; $i++) { - $buf .= 'A'; - } - return $buf; - } + /** + * Creates a string of the specified length consisting entirely of + * the character A. Useful for simulating table + * names, etc. + * + * @param int $len the number of characters to include in the string + * @return a string of length len with every character an 'A' + */ + private static function makeString($len) + { + $buf = ""; + for ($i = 0; $i < $len; $i++) { + $buf .= 'A'; + } - /** Sets up the Propel model. */ - public function setUp() - { - $appData = new AppData(new MysqlPlatform()); - $this->database = new Database(); - $appData->addDatabase($this->database); - } + return $buf; + } - /** - * @throws Exception on fail - */ - public function testNames() { - for ($algoIndex = 0; $algoIndex < count(self::$ALGORITHMS); $algoIndex++) { - $algo = self::$ALGORITHMS[$algoIndex]; - $algoInputs = self::$INPUTS[$algoIndex]; - for ($i = 0; $i < count($algoInputs); $i++) { - $inputs = $this->makeInputs($algo, $algoInputs[$i]); - $generated = NameFactory::generateName($algo, $inputs); - $expected = self::$OUTPUTS[$algoIndex][$i]; - $this->assertEquals($expected, $generated, 0, "Algorithm " . $algo . " failed to generate an unique name"); - } - } - } + /** Sets up the Propel model. */ + public function setUp() + { + $appData = new AppData(new MysqlPlatform()); + $this->database = new Database(); + $appData->addDatabase($this->database); + } - /** - * Creates the list of arguments to pass to the specified type of - * NameGenerator implementation. - * - * @param algo The class name of the NameGenerator to - * create an argument list for. - * @param inputs The (possibly partial) list inputs from which to - * generate the final list. - * @return the list of arguments to pass to the NameGenerator - */ - private function makeInputs($algo, $inputs) - { - if (NameFactory::CONSTRAINT_GENERATOR == $algo) { - array_unshift($inputs, $this->database); - } - return $inputs; - } + /** + * @throws Exception on fail + */ + public function testNames() + { + for ($algoIndex = 0; $algoIndex < count(self::$ALGORITHMS); $algoIndex++) { + $algo = self::$ALGORITHMS[$algoIndex]; + $algoInputs = self::$INPUTS[$algoIndex]; + for ($i = 0; $i < count($algoInputs); $i++) { + $inputs = $this->makeInputs($algo, $algoInputs[$i]); + $generated = NameFactory::generateName($algo, $inputs); + $expected = self::$OUTPUTS[$algoIndex][$i]; + $this->assertEquals($expected, $generated, "Algorithm " . $algo . " failed to generate an unique name"); + } + } + } + + /** + * Creates the list of arguments to pass to the specified type of + * NameGenerator implementation. + * + * @param algo The class name of the NameGenerator to + * create an argument list for. + * @param inputs The (possibly partial) list inputs from which to + * generate the final list. + * @return the list of arguments to pass to the NameGenerator + */ + private function makeInputs($algo, $inputs) + { + if (NameFactory::CONSTRAINT_GENERATOR == $algo) { + array_unshift($inputs, $this->database); + } + + return $inputs; + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/model/PhpNameGeneratorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/model/PhpNameGeneratorTest.php index ecde25cc6..264000dc0 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/model/PhpNameGeneratorTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/model/PhpNameGeneratorTest.php @@ -8,48 +8,74 @@ * @license MIT License */ -require_once 'PHPUnit/Framework/TestCase.php'; -require_once 'model/PhpNameGenerator.php'; - +require_once dirname(__FILE__) . '/../../../../generator/lib/model/PhpNameGenerator.php'; /** - * Tests for PhpNamleGenerator + * Tests for PhpNameGenerator * * @author + + + +
+ + + +
+ +EOF; + $appData = $xmlToAppData->parseString($schema); - //$this->appData = $this->xmlToAppData->parseFile(dirname(__FILE__) . "/tabletest-schema.xml"); - $this->appData = $this->xmlToAppData->parseFile("etc/schema/tabletest-schema.xml"); + $db = $appData->getDatabase("iddb"); + $this->assertEquals(IDMethod::NATIVE, $db->getDefaultIdMethod()); - $db = $this->appData->getDatabase("iddb"); - $expected = IDMethod::NATIVE; - $result = $db->getDefaultIdMethod(); - $this->assertEquals($expected, $result); + $table1 = $db->getTable("table_native"); + $this->assertEquals(IDMethod::NATIVE, $table1->getIdMethod()); - $table2 = $db->getTable("table_native"); - $expected = IDMethod::NATIVE; - $result = $table2->getIdMethod(); - $this->assertEquals($expected, $result); + $table2 = $db->getTable("table_none"); + $this->assertEquals(IDMethod::NO_ID_METHOD, $table2->getIdMethod()); + } - $table = $db->getTable("table_none"); - $expected = IDMethod::NO_ID_METHOD; - $result = $table->getIdMethod(); - $this->assertEquals($expected, $result); - } - - public function testGeneratorConfig() - { - $xmlToAppData = new XmlToAppData(new MysqlPlatform(), "defaultpackage", null); - $appData = $xmlToAppData->parseFile('fixtures/bookstore/behavior-timestampable-schema.xml'); - $table = $appData->getDatabase("bookstore-behavior")->getTable('table1'); - $config = new GeneratorConfig(); - $config->setBuildProperties(array('propel.foo.bar.class' => 'bazz')); - $table->getDatabase()->getAppData()->getPlatform()->setGeneratorConfig($config); - $this->assertThat($table->getGeneratorConfig(), $this->isInstanceOf('GeneratorConfig'), 'getGeneratorConfig() returns an instance of the generator configuration'); - $this->assertEquals($table->getGeneratorConfig()->getBuildProperty('fooBarClass'), 'bazz', 'getGeneratorConfig() returns the instance of the generator configuration used in the platform'); - } - - public function testAddBehavior() - { - $platform = new MysqlPlatform(); - $config = new GeneratorConfig(); - $config->setBuildProperties(array( - 'propel.behavior.timestampable.class' => 'behavior.TimestampableBehavior' - )); - $platform->setGeneratorConfig($config); - $xmlToAppData = new XmlToAppData($platform, "defaultpackage", null); - $appData = $xmlToAppData->parseFile('fixtures/bookstore/behavior-timestampable-schema.xml'); - $table = $appData->getDatabase("bookstore-behavior")->getTable('table1'); - $this->assertThat($table->getBehavior('timestampable'), $this->isInstanceOf('TimestampableBehavior'), 'addBehavior() uses the behavior class defined in build.properties'); - } - - public function testUniqueColumnName() - { - $platform = new MysqlPlatform(); - $config = new GeneratorConfig(); - $platform->setGeneratorConfig($config); - $xmlToAppData = new XmlToAppData($platform, 'defaultpackage', null); - try - { - $appData = $xmlToAppData->parseFile('fixtures/unique-column/column-schema.xml'); - $this->fail('Parsing file with duplicate column names in one table throws exception'); - } catch (EngineException $e) { - $this->assertTrue(true, 'Parsing file with duplicate column names in one table throws exception'); - } - } - - public function testUniqueTableName() - { - $platform = new MysqlPlatform(); - $config = new GeneratorConfig(); - $platform->setGeneratorConfig($config); - $xmlToAppData = new XmlToAppData($platform, 'defaultpackage', null); - try { - $appData = $xmlToAppData->parseFile('fixtures/unique-column/table-schema.xml'); - $this->fail('Parsing file with duplicate table name throws exception'); - } catch (EngineException $e) { - $this->assertTrue(true, 'Parsing file with duplicate table name throws exception'); - } - } + public function testGeneratorConfig() + { + $xmlToAppData = new XmlToAppData(); + $schema = << + + +
+ +EOF; + $appData = $xmlToAppData->parseString($schema); + $table = $appData->getDatabase('test1')->getTable('table1'); + $config = new GeneratorConfig(); + $config->setBuildProperties(array('propel.foo.bar.class' => 'bazz')); + $table->getDatabase()->getAppData()->setGeneratorConfig($config); + $this->assertThat($table->getGeneratorConfig(), $this->isInstanceOf('GeneratorConfig'), 'getGeneratorConfig() returns an instance of the generator configuration'); + $this->assertEquals($table->getGeneratorConfig()->getBuildProperty('fooBarClass'), 'bazz', 'getGeneratorConfig() returns the instance of the generator configuration used in the platform'); + } + + public function testAddBehavior() + { + $include_path = get_include_path(); + set_include_path($include_path . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../../../generator/lib')); + $xmlToAppData = new XmlToAppData(new DefaultPlatform()); + $config = new GeneratorConfig(); + $config->setBuildProperties(array( + 'propel.platform.class' => 'propel.engine.platform.DefaultPlatform', + 'propel.behavior.timestampable.class' => 'behavior.TimestampableBehavior' + )); + $xmlToAppData->setGeneratorConfig($config); + $schema = << + + + +
+ +EOF; + $appData = $xmlToAppData->parseString($schema); + set_include_path($include_path); + $table = $appData->getDatabase('test1')->getTable('table1'); + $this->assertThat($table->getBehavior('timestampable'), $this->isInstanceOf('TimestampableBehavior'), 'addBehavior() uses the behavior class defined in build.properties'); + } + + + public function testAddExtraIndicesForeignKeys() + { + $include_path = get_include_path(); + set_include_path($include_path . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../../../generator/lib')); + + $platform = new MysqlPlatform(); + $xmlToAppData = new XmlToAppData($platform); + $config = new GeneratorConfig(); + + $config->setBuildProperties(array( + 'propel.behavior.autoaddpkbehavior.class' => 'behavior.AutoAddPkBehavior' + )); + + $xmlToAppData->setGeneratorConfig($config); + + $schema = << + + + + + + + +
+ + + + + + + + + + + + + +
+ +EOF; + +$expectedRelationSql = " +CREATE TABLE `bar` +( + `name` VARCHAR(255), + `subid` INTEGER, + `id` INTEGER NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + INDEX `bar_FI_1` (`id`, `subid`) +) ENGINE=MyISAM; +"; + $appData = $xmlToAppData->parseString($schema); + set_include_path($include_path); + + $table = $appData->getDatabase('test1')->getTable('bar'); + $relationTableSql = $platform->getAddTableDDL($table); + + $this->assertEquals($expectedRelationSql, $relationTableSql); + + } + + /** + * @expectedException EngineException + */ + public function testUniqueColumnName() + { + $xmlToAppData = new XmlToAppData(); + $schema = << + + + + +
+ +EOF; + // Parsing file with duplicate column names in one table throws exception + $appData = $xmlToAppData->parseString($schema); + } + + /** + * @expectedException EngineException + */ + public function testUniqueTableName() + { + $xmlToAppData = new XmlToAppData(); + $schema = << + + + +
+ + + +
+ +EOF; + // Parsing file with duplicate table name throws exception + $appData = $xmlToAppData->parseString($schema); + } + + public function providerForTestHasColumn() + { + $table = new Table(); + $column = new Column('Foo'); + $table->addColumn($column); + + return array( + array($table, $column) + ); + } + + /** + * @dataProvider providerForTestHasColumn + */ + public function testHasColumn($table, $column) + { + $this->assertTrue($table->hasColumn('Foo')); + $this->assertFalse($table->hasColumn('foo')); + $this->assertFalse($table->hasColumn('FOO')); + } + + /** + * @dataProvider providerForTestHasColumn + */ + public function testHasColumnCaseInsensitive($table, $column) + { + $this->assertTrue($table->hasColumn('Foo', true)); + $this->assertTrue($table->hasColumn('foo', true)); + $this->assertTrue($table->hasColumn('FOO', true)); + } + + /** + * @dataProvider providerForTestHasColumn + */ + public function testGetColumn($table, $column) + { + $this->assertEquals($column, $table->getColumn('Foo')); + $this->assertNull($table->getColumn('foo')); + $this->assertNull($table->getColumn('FOO')); + } + + /** + * @dataProvider providerForTestHasColumn + */ + public function testGetColumnCaseInsensitive($table, $column) + { + $this->assertEquals($column, $table->getColumn('Foo', true)); + $this->assertEquals($column, $table->getColumn('foo', true)); + $this->assertEquals($column, $table->getColumn('FOO', true)); + } + + /** + * @dataProvider providerForTestHasColumn + */ + public function testRemoveColumnFromObject($table, $column) + { + $table->removeColumn($column); + $this->assertFalse($table->hasColumn('Foo')); + } + + /** + * @dataProvider providerForTestHasColumn + */ + public function testRemoveColumnFromName($table, $column) + { + $table->removeColumn($column->getName()); + $this->assertFalse($table->hasColumn('Foo')); + } + + public function testRemoveColumnFixesPositions() + { + $table = new Table(); + $col1 = new Column('Foo1'); + $table->addColumn($col1); + $col2 = new Column('Foo2'); + $table->addColumn($col2); + $col3 = new Column('Foo3'); + $table->addColumn($col3); + $this->assertEquals(1, $col1->getPosition()); + $this->assertEquals(2, $col2->getPosition()); + $this->assertEquals(3, $col3->getPosition()); + $this->assertEquals(array(0, 1, 2), array_keys($table->getColumns())); + $table->removeColumn($col2); + $this->assertEquals(1, $col1->getPosition()); + $this->assertEquals(2, $col3->getPosition()); + $this->assertEquals(array(0, 1), array_keys($table->getColumns())); + } + + public function testQualifiedName() + { + $table = new Table(); + $table->setSchema("foo"); + $table->setCommonName("bar"); + $this->assertEquals($table->getName(), "bar"); + $this->assertEquals($table->getCommonName(), "bar"); + $database = new Database(); + $database->addTable($table); + $database->setPlatform(new NoSchemaPlatform()); + $this->assertEquals($table->getName(), "bar"); + $database->setPlatform(new SchemaPlatform()); + $this->assertEquals($table->getName(), "foo.bar"); + } + + public function testRemoveValidatorForColumn() + { + $xmlToAppData = new XmlToAppData(new DefaultPlatform()); + $schema = << + + + + + + +
+ +EOF; + $appData = $xmlToAppData->parseString($schema); + $table1 = $appData->getDatabase('test')->getTable('table1'); + $title1Column = $table1->getColumn('title1'); + $this->assertNotNull($title1Column->getValidator()); + $table1->removeValidatorForColumn('title1'); + $this->assertNull($title1Column->getValidator()); + } + + public function testTableNamespaceAcrossDatabase() + { + $schema1 = << + + + +
+ +EOF; + $xmlToAppData = new XmlToAppData(new DefaultPlatform()); + $appData1 = $xmlToAppData->parseString($schema1); + $schema2 = << + + + +
+ +EOF; + $xmlToAppData = new XmlToAppData(new DefaultPlatform()); + $appData2 = $xmlToAppData->parseString($schema2); + $appData1->joinAppDatas(array($appData2)); + $this->assertEquals('NS1', $appData1->getDatabase('DB1')->getTable('table1')->getNamespace()); + $this->assertEquals('NS2', $appData1->getDatabase('DB1')->getTable('table2')->getNamespace()); + } + + public function testSetNamespaceSetsPackageWhenBuildPropertySet() + { + $schema = << + + + +
+ +EOF; + $config = new GeneratorConfig(); + $config->setBuildProperties(array('propel.namespace.autoPackage' => 'true')); + $xmlToAppData = new XmlToAppData(new DefaultPlatform()); + $xmlToAppData->setGeneratorConfig($config); + $table = $xmlToAppData->parseString($schema)->getDatabase('DB')->getTable('table'); + $this->assertEquals('NS', $table->getPackage()); + } + + public function testSetNamespaceSetsCompletePackageWhenBuildPropertySet() + { + $schema = << + + + +
+ +EOF; + $config = new GeneratorConfig(); + $config->setBuildProperties(array('propel.namespace.autoPackage' => 'true')); + $xmlToAppData = new XmlToAppData(new DefaultPlatform()); + $xmlToAppData->setGeneratorConfig($config); + $table = $xmlToAppData->parseString($schema)->getDatabase('DB')->getTable('table'); + $this->assertEquals('NS1.NS2', $table->getPackage()); + } + + public function testSetPackageOverridesNamespaceAutoPackage() + { + $schema = << + + + +
+ +EOF; + $config = new GeneratorConfig(); + $config->setBuildProperties(array('propel.namespace.autoPackage' => 'true')); + $xmlToAppData = new XmlToAppData(new DefaultPlatform()); + $xmlToAppData->setGeneratorConfig($config); + $table = $xmlToAppData->parseString($schema)->getDatabase('DB')->getTable('table'); + $this->assertEquals('foo', $table->getPackage()); + } + + public function testAppendXmlPackage() + { + $schema = << + +EOF; + + $doc = new DOMDocument('1.0'); + $doc->formatOutput = true; + + $table = new Table('test'); + $table->setPackage('test/package'); + $table->appendXml($doc); + + $xmlstr = trim($doc->saveXML()); + $this->assertSame($schema, $xmlstr); + } + + public function testAppendXmlNamespace() + { + $schema = << +
+EOF; + + $doc = new DOMDocument('1.0'); + $doc->formatOutput = true; + + $table = new Table('test'); + $table->setNamespace('\testNs'); + $table->appendXml($doc); + + $xmlstr = trim($doc->saveXML()); + $this->assertSame($schema, $xmlstr); + + $schema = << +
+EOF; + + $doc = new DOMDocument('1.0'); + $doc->formatOutput = true; + $table->setPackage('testPkg'); + $table->appendXml($doc); + + $xmlstr = trim($doc->saveXML()); + $this->assertSame($schema, $xmlstr); + } + + public function testAppendXmlNamespaceWithAutoPackage() + { + $schema = << +
+EOF; + + $doc = new DOMDocument('1.0'); + $doc->formatOutput = true; + + $config = new GeneratorConfig(); + $config->setBuildProperties(array('propel.namespace.autoPackage' => 'true')); + + $appData = new AppData(); + $appData->setGeneratorConfig($config); + + $db = new Database('testDb'); + $db->setAppData($appData); + + $table = new Table('test'); + $table->setDatabase($db); + $table->setNamespace('\testNs'); + $table->appendXml($doc); + + $xmlstr = trim($doc->saveXML()); + $this->assertSame($schema, $xmlstr); + + $schema = << +
+EOF; + + $doc = new DOMDocument('1.0'); + $doc->formatOutput = true; + $table->setPackage('testPkg'); + $table->appendXml($doc); + + $xmlstr = trim($doc->saveXML()); + $this->assertSame($schema, $xmlstr); + } + + public function testIsCrossRefAttribute() + { + $xmlToAppData = new XmlToAppData(); + $schema = << +
+ + +
+ + + +
+ + + +
+ +EOF; + $appData = $xmlToAppData->parseString($schema); + + $db = $appData->getDatabase("iddb"); + + $table1 = $db->getTable("table_native"); + $this->assertFalse($table1->getIsCrossRef()); + + $table2 = $db->getTable("table_is_cross_ref_true"); + $this->assertTrue($table2->getIsCrossRef()); + + $table3 = $db->getTable("table_is_cross_ref_false"); + $this->assertFalse($table3->getIsCrossRef()); + } + + public function testPrefixDoesntAffectPhpName() + { + $xmlToAppData = new XmlToAppData(); + $schema = << + + +
+ +EOF; + $appData = $xmlToAppData->parseString($schema); + + $table = $appData->getDatabase('test1')->getTable('pf_table1'); + + $this->assertEquals('Table1', $table->getPhpName()); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/model/XMLElementTest.php b/airtime_mvc/library/propel/test/testsuite/generator/model/XMLElementTest.php new file mode 100644 index 000000000..2e953b4bf --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/model/XMLElementTest.php @@ -0,0 +1,56 @@ + + */ +class XMLElementTest extends PHPUnit_Framework_TestCase +{ + /** + * @dataProvider providerForGetDefaultValueForArray + */ + public function testGetDefaultValueForArray($value, $expected) + { + $xmlElement = new TestableXmlElement(); + $this->assertEquals($expected, $xmlElement->getDefaultValueForArray($value)); + } + + public static function providerForGetDefaultValueForArray() + { + return array( + array('', null), + array(null, null), + array('FOO', '||FOO||'), + array('FOO, BAR', '||FOO | BAR||'), + array('FOO , BAR', '||FOO | BAR||'), + array('FOO,BAR', '||FOO | BAR||'), + array(' ', null), + array(', ', null), + ); + } +} + +class TestableXmlElement extends XMLElement +{ + public function getDefaultValueForArray($value) + { + return parent::getDefaultValueForArray($value); + } + + public function appendXml(DOMNode $node) + { + } + + protected function setupObject() + { + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelColumnComparatorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelColumnComparatorTest.php new file mode 100644 index 000000000..f8b69dc1a --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelColumnComparatorTest.php @@ -0,0 +1,190 @@ +platform = new MysqlPlatform(); + } + + public function testCompareNoDifference() + { + $c1 = new Column(); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $c2 = new Column(); + $c2->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c2->getDomain()->replaceScale(2); + $c2->getDomain()->replaceSize(3); + $c2->setNotNull(true); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $this->assertEquals(array(), PropelColumnComparator::compareColumns($c1, $c2)); + } + + public function testCompareType() + { + $c1 = new Column(); + $c1->getDomain()->copy($this->platform->getDomainForType('VARCHAR')); + $c2 = new Column(); + $c2->getDomain()->copy($this->platform->getDomainForType('LONGVARCHAR')); + $expectedChangedProperties = array( + 'type' => array('VARCHAR', 'LONGVARCHAR'), + 'sqlType' => array('VARCHAR', 'TEXT'), + ); + $this->assertEquals($expectedChangedProperties, PropelColumnComparator::compareColumns($c1, $c2)); + } + + public function testCompareScale() + { + $c1 = new Column(); + $c1->getDomain()->replaceScale(2); + $c2 = new Column(); + $c2->getDomain()->replaceScale(3); + $expectedChangedProperties = array('scale' => array(2, 3)); + $this->assertEquals($expectedChangedProperties, PropelColumnComparator::compareColumns($c1, $c2)); + } + + public function testCompareSize() + { + $c1 = new Column(); + $c1->getDomain()->replaceSize(2); + $c2 = new Column(); + $c2->getDomain()->replaceSize(3); + $expectedChangedProperties = array('size' => array(2, 3)); + $this->assertEquals($expectedChangedProperties, PropelColumnComparator::compareColumns($c1, $c2)); + } + + public function testCompareSqlType() + { + $c1 = new Column(); + $c1->getDomain()->copy($this->platform->getDomainForType('INTEGER')); + $c2 = new Column(); + $c2->getDomain()->copy($this->platform->getDomainForType('INTEGER')); + $c2->getDomain()->setSqlType('INTEGER(10) UNSIGNED'); + $expectedChangedProperties = array('sqlType' => array('INTEGER', 'INTEGER(10) UNSIGNED')); + $this->assertEquals($expectedChangedProperties, PropelColumnComparator::compareColumns($c1, $c2)); + } + + public function testCompareNotNull() + { + $c1 = new Column(); + $c1->setNotNull(true); + $c2 = new Column(); + $c2->setNotNull(false); + $expectedChangedProperties = array('notNull' => array(true, false)); + $this->assertEquals($expectedChangedProperties, PropelColumnComparator::compareColumns($c1, $c2)); + } + + public function testCompareDefaultValueToNull() + { + $c1 = new Column(); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $c2 = new Column(); + $expectedChangedProperties = array( + 'defaultValueType' => array(ColumnDefaultValue::TYPE_VALUE, null), + 'defaultValueValue' => array(123, null) + ); + $this->assertEquals($expectedChangedProperties, PropelColumnComparator::compareColumns($c1, $c2)); + } + + public function testCompareDefaultValueFromNull() + { + $c1 = new Column(); + $c2 = new Column(); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $expectedChangedProperties = array( + 'defaultValueType' => array(null, ColumnDefaultValue::TYPE_VALUE), + 'defaultValueValue' => array(null, 123) + ); + $this->assertEquals($expectedChangedProperties, PropelColumnComparator::compareColumns($c1, $c2)); + } + + public function testCompareDefaultValueValue() + { + $c1 = new Column(); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $c2 = new Column(); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(456, ColumnDefaultValue::TYPE_VALUE)); + $expectedChangedProperties = array( + 'defaultValueValue' => array(123, 456) + ); + $this->assertEquals($expectedChangedProperties, PropelColumnComparator::compareColumns($c1, $c2)); + } + + public function testCompareDefaultValueType() + { + $c1 = new Column(); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $c2 = new Column(); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_EXPR)); + $expectedChangedProperties = array( + 'defaultValueType' => array(ColumnDefaultValue::TYPE_VALUE, ColumnDefaultValue::TYPE_EXPR) + ); + $this->assertEquals($expectedChangedProperties, PropelColumnComparator::compareColumns($c1, $c2)); + } + + /** + * @see http://www.propelorm.org/ticket/1141 + */ + public function testCompareDefaultExprCurrentTimestamp() + { + $c1 = new Column(); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue("NOW()", ColumnDefaultValue::TYPE_EXPR)); + $c2 = new Column(); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue("CURRENT_TIMESTAMP", ColumnDefaultValue::TYPE_EXPR)); + $this->assertEquals(array(), PropelColumnComparator::compareColumns($c1, $c2)); + } + + public function testCompareAutoincrement() + { + $c1 = new Column(); + $c1->setAutoIncrement(true); + $c2 = new Column(); + $c2->setAutoIncrement(false); + $expectedChangedProperties = array('autoIncrement' => array(true, false)); + $this->assertEquals($expectedChangedProperties, PropelColumnComparator::compareColumns($c1, $c2)); + } + + public function testCompareMultipleDifferences() + { + $c1 = new Column(); + $c1->getDomain()->copy($this->platform->getDomainForType('INTEGER')); + $c1->setNotNull(false); + $c2 = new Column(); + $c2->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c2->getDomain()->replaceScale(2); + $c2->getDomain()->replaceSize(3); + $c2->setNotNull(true); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $expectedChangedProperties = array( + 'type' => array('INTEGER', 'DOUBLE'), + 'sqlType' => array('INTEGER', 'DOUBLE'), + 'scale' => array(NULL, 2), + 'size' => array(NULL, 3), + 'notNull' => array(false, true), + 'defaultValueType' => array(NULL, ColumnDefaultValue::TYPE_VALUE), + 'defaultValueValue' => array(NULL, 123) + ); + $this->assertEquals($expectedChangedProperties, PropelColumnComparator::compareColumns($c1, $c2)); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelDatabaseTableComparatorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelDatabaseTableComparatorTest.php new file mode 100644 index 000000000..9479377df --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelDatabaseTableComparatorTest.php @@ -0,0 +1,402 @@ +platform = new MysqlPlatform(); + } + + public function testCompareSameTables() + { + $d1 = new Database(); + $t1 = new Table('Foo_Table'); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t1->addColumn($c1); + $d1->addTable($t1); + $t2 = new Table('Bar'); + $d1->addTable($t2); + + $d2 = new Database(); + $t3 = new Table('Foo_Table'); + $c3 = new Column('Foo'); + $c3->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c3->getDomain()->replaceScale(2); + $c3->getDomain()->replaceSize(3); + $c3->setNotNull(true); + $c3->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t3->addColumn($c3); + $d2->addTable($t3); + $t4 = new Table('Bar'); + $d2->addTable($t4); + + $this->assertFalse(PropelDatabaseComparator::computeDiff($d1, $d2)); + } + + public function testCompareNotSameTables() + { + $d1 = new Database(); + $t1 = new Table('Foo'); + $d1->addTable($t1); + $d2 = new Database(); + $t2 = new Table('Bar'); + $d2->addTable($t2); + + $diff = PropelDatabaseComparator::computeDiff($d1, $d2); + $this->assertTrue($diff instanceof PropelDatabaseDiff); + } + + public function testCompareCaseInsensitive() + { + $d1 = new Database(); + $t1 = new Table('Foo'); + $d1->addTable($t1); + $d2 = new Database(); + $t2 = new Table('fOO'); + $d2->addTable($t2); + + $this->assertFalse(PropelDatabaseComparator::computeDiff($d1, $d2, true)); + } + + public function testCompareAddedTable() + { + $d1 = new Database(); + $t1 = new Table('Foo_Table'); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t1->addColumn($c1); + $d1->addTable($t1); + + $d2 = new Database(); + $t3 = new Table('Foo_Table'); + $c3 = new Column('Foo'); + $c3->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c3->getDomain()->replaceScale(2); + $c3->getDomain()->replaceSize(3); + $c3->setNotNull(true); + $c3->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t3->addColumn($c3); + $d2->addTable($t3); + $t4 = new Table('Bar'); + $d2->addTable($t4); + + $dc = new PropelDatabaseComparator(); + $dc->setFromDatabase($d1); + $dc->setToDatabase($d2); + $nbDiffs = $dc->compareTables(); + $databaseDiff = $dc->getDatabaseDiff(); + $this->assertEquals(1, $nbDiffs); + $this->assertEquals(1, count($databaseDiff->getAddedTables())); + $this->assertEquals(array('Bar' => $t4), $databaseDiff->getAddedTables()); + } + + public function testCompareAddedTableSkipSql() + { + $d1 = new Database(); + $t1 = new Table('Foo_Table'); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t1->addColumn($c1); + $d1->addTable($t1); + + $d2 = new Database(); + $t3 = new Table('Foo_Table'); + $c3 = new Column('Foo'); + $c3->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c3->getDomain()->replaceScale(2); + $c3->getDomain()->replaceSize(3); + $c3->setNotNull(true); + $c3->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t3->addColumn($c3); + $d2->addTable($t3); + $t4 = new Table('Bar'); + $t4->setSkipSql(true); + $d2->addTable($t4); + + $dc = new PropelDatabaseComparator(); + $dc->setFromDatabase($d1); + $dc->setToDatabase($d2); + $nbDiffs = $dc->compareTables(); + $databaseDiff = $dc->getDatabaseDiff(); + $this->assertEquals(0, $nbDiffs); + } + + public function testCompareRemovedTable() + { + $d1 = new Database(); + $t1 = new Table('Foo_Table'); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t1->addColumn($c1); + $d1->addTable($t1); + $t2 = new Table('Bar'); + $d1->addTable($t2); + + $d2 = new Database(); + $t3 = new Table('Foo_Table'); + $c3 = new Column('Foo'); + $c3->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c3->getDomain()->replaceScale(2); + $c3->getDomain()->replaceSize(3); + $c3->setNotNull(true); + $c3->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t3->addColumn($c3); + $d2->addTable($t3); + + $dc = new PropelDatabaseComparator(); + $dc->setFromDatabase($d1); + $dc->setToDatabase($d2); + $nbDiffs = $dc->compareTables(); + $databaseDiff = $dc->getDatabaseDiff(); + $this->assertEquals(1, $nbDiffs); + $this->assertEquals(1, count($databaseDiff->getRemovedTables())); + $this->assertEquals(array('Bar' => $t2), $databaseDiff->getRemovedTables()); + } + + public function testCompareRemovedTableSkipSql() + { + $d1 = new Database(); + $t1 = new Table('Foo_Table'); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t1->addColumn($c1); + $d1->addTable($t1); + $t2 = new Table('Bar'); + $t2->setSkipSql(true); + $d1->addTable($t2); + + $d2 = new Database(); + $t3 = new Table('Foo_Table'); + $c3 = new Column('Foo'); + $c3->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c3->getDomain()->replaceScale(2); + $c3->getDomain()->replaceSize(3); + $c3->setNotNull(true); + $c3->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t3->addColumn($c3); + $d2->addTable($t3); + + $dc = new PropelDatabaseComparator(); + $dc->setFromDatabase($d1); + $dc->setToDatabase($d2); + $nbDiffs = $dc->compareTables(); + $databaseDiff = $dc->getDatabaseDiff(); + $this->assertEquals(0, $nbDiffs); + } + + public function testCompareModifiedTable() + { + $d1 = new Database(); + $t1 = new Table('Foo_Table'); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t1->addColumn($c1); + $c2 = new Column('Foo2'); + $c2->getDomain()->copy($this->platform->getDomainForType('INTEGER')); + $t1->addColumn($c2); + $d1->addTable($t1); + $t2 = new Table('Bar'); + $d1->addTable($t2); + + $d2 = new Database(); + $t3 = new Table('Foo_Table'); + $c3 = new Column('Foo'); + $c3->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c3->getDomain()->replaceScale(2); + $c3->getDomain()->replaceSize(3); + $c3->setNotNull(true); + $c3->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t3->addColumn($c3); + $d2->addTable($t3); + $t4 = new Table('Bar'); + $d2->addTable($t4); + + $dc = new PropelDatabaseComparator(); + $dc->setFromDatabase($d1); + $dc->setToDatabase($d2); + $nbDiffs = $dc->compareTables(); + $databaseDiff = $dc->getDatabaseDiff(); + $this->assertEquals(1, $nbDiffs); + $this->assertEquals(1, count($databaseDiff->getModifiedTables())); + $tableDiff = PropelTableComparator::computeDiff($t1, $t3); + $this->assertEquals(array('Foo_Table' => $tableDiff), $databaseDiff->getModifiedTables()); + } + + public function testCompareModifiedTableSkipSql() + { + $d1 = new Database(); + $t1 = new Table('Foo_Table'); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t1->addColumn($c1); + $c2 = new Column('Foo2'); + $c2->getDomain()->copy($this->platform->getDomainForType('INTEGER')); + $t1->addColumn($c2); + $t1->setSkipSql(true); + $d1->addTable($t1); + $t2 = new Table('Bar'); + $d1->addTable($t2); + + $d2 = new Database(); + $t3 = new Table('Foo_Table'); + $c3 = new Column('Foo'); + $c3->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c3->getDomain()->replaceScale(2); + $c3->getDomain()->replaceSize(3); + $c3->setNotNull(true); + $c3->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t3->addColumn($c3); + $d2->addTable($t3); + $t4 = new Table('Bar'); + $d2->addTable($t4); + + $dc = new PropelDatabaseComparator(); + $dc->setFromDatabase($d1); + $dc->setToDatabase($d2); + $nbDiffs = $dc->compareTables(); + $this->assertEquals(0, $nbDiffs); + } + + public function testCompareRenamedTable() + { + $d1 = new Database(); + $t1 = new Table('Foo_Table'); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t1->addColumn($c1); + $d1->addTable($t1); + $t2 = new Table('Bar'); + $d1->addTable($t2); + + $d2 = new Database(); + $t3 = new Table('Foo_Table2'); + $c3 = new Column('Foo'); + $c3->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c3->getDomain()->replaceScale(2); + $c3->getDomain()->replaceSize(3); + $c3->setNotNull(true); + $c3->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t3->addColumn($c3); + $d2->addTable($t3); + $t4 = new Table('Bar'); + $d2->addTable($t4); + + $dc = new PropelDatabaseComparator(); + $dc->setFromDatabase($d1); + $dc->setToDatabase($d2); + $nbDiffs = $dc->compareTables(); + $databaseDiff = $dc->getDatabaseDiff(); + $this->assertEquals(1, $nbDiffs); + $this->assertEquals(1, count($databaseDiff->getRenamedTables())); + $this->assertEquals(array('Foo_Table' => 'Foo_Table2'), $databaseDiff->getRenamedTables()); + $this->assertEquals(array(), $databaseDiff->getAddedTables()); + $this->assertEquals(array(), $databaseDiff->getRemovedTables()); + } + + public function testCompareSeveralTableDifferences() + { + $d1 = new Database(); + $t1 = new Table('Foo_Table'); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t1->addColumn($c1); + $d1->addTable($t1); + $t2 = new Table('Bar'); + $c2 = new Column('Bar_Column'); + $c2->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $t2->addColumn($c2); + $d1->addTable($t2); + $t11 = new Table('Baz'); + $d1->addTable($t11); + + $d2 = new Database(); + $t3 = new Table('Foo_Table'); + $c3 = new Column('Foo1'); + $c3->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c3->getDomain()->replaceScale(2); + $c3->getDomain()->replaceSize(3); + $c3->setNotNull(true); + $c3->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t3->addColumn($c3); + $d2->addTable($t3); + $t4 = new Table('Bar2'); + $c4 = new Column('Bar_Column'); + $c4->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $t4->addColumn($c4); + $d2->addTable($t4); + $t5 = new Table('Biz'); + $c5 = new Column('Biz_Column'); + $c5->getDomain()->copy($this->platform->getDomainForType('INTEGER')); + $t5->addColumn($c5); + $d2->addTable($t5); + + // Foo_Table was modified, Bar was renamed, Baz was removed, Biz was added + $dc = new PropelDatabaseComparator(); + $dc->setFromDatabase($d1); + $dc->setToDatabase($d2); + $nbDiffs = $dc->compareTables(); + $databaseDiff = $dc->getDatabaseDiff(); + $this->assertEquals(4, $nbDiffs); + $this->assertEquals(array('Bar' => 'Bar2'), $databaseDiff->getRenamedTables()); + $this->assertEquals(array('Biz' => $t5), $databaseDiff->getAddedTables()); + $this->assertEquals(array('Baz' => $t11), $databaseDiff->getRemovedTables()); + $tableDiff = PropelTableComparator::computeDiff($t1, $t3); + $this->assertEquals(array('Foo_Table' => $tableDiff), $databaseDiff->getModifiedTables()); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelForeignKeyComparatorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelForeignKeyComparatorTest.php new file mode 100644 index 000000000..3a6a6dbb4 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelForeignKeyComparatorTest.php @@ -0,0 +1,165 @@ +addReference($c1, $c2); + $t1 = new Table('Baz'); + $t1->addForeignKey($fk1); + $c3 = new Column('Foo'); + $c4 = new Column('Bar'); + $fk2 = new ForeignKey(); + $fk2->addReference($c3, $c4); + $t2 = new Table('Baz'); + $t2->addForeignKey($fk2); + $this->assertFalse(PropelForeignKeyComparator::computeDiff($fk1, $fk2)); + } + + public function testCompareCaseInsensitive() + { + $c1 = new Column('Foo'); + $c2 = new Column('Bar'); + $fk1 = new ForeignKey(); + $fk1->addReference($c1, $c2); + $t1 = new Table('Baz'); + $t1->addForeignKey($fk1); + $c3 = new Column('fOO'); + $c4 = new Column('bAR'); + $fk2 = new ForeignKey(); + $fk2->addReference($c3, $c4); + $t2 = new Table('bAZ'); + $t2->addForeignKey($fk2); + $this->assertFalse(PropelForeignKeyComparator::computeDiff($fk1, $fk2, true)); + } + + public function testCompareLocalColumn() + { + $c1 = new Column('Foo'); + $c2 = new Column('Bar'); + $fk1 = new ForeignKey(); + $fk1->addReference($c1, $c2); + $t1 = new Table('Baz'); + $t1->addForeignKey($fk1); + $c3 = new Column('Foo2'); + $c4 = new Column('Bar'); + $fk2 = new ForeignKey(); + $fk2->addReference($c3, $c4); + $t2 = new Table('Baz'); + $t2->addForeignKey($fk2); + $this->assertTrue(PropelForeignKeyComparator::computeDiff($fk1, $fk2)); + } + + public function testCompareForeignColumn() + { + $c1 = new Column('Foo'); + $c2 = new Column('Bar'); + $fk1 = new ForeignKey(); + $fk1->addReference($c1, $c2); + $t1 = new Table('Baz'); + $t1->addForeignKey($fk1); + $c3 = new Column('Foo'); + $c4 = new Column('Bar2'); + $fk2 = new ForeignKey(); + $fk2->addReference($c3, $c4); + $t2 = new Table('Baz'); + $t2->addForeignKey($fk2); + $this->assertTrue(PropelForeignKeyComparator::computeDiff($fk1, $fk2)); + } + + public function testCompareColumnMappings() + { + $c1 = new Column('Foo'); + $c2 = new Column('Bar'); + $fk1 = new ForeignKey(); + $fk1->addReference($c1, $c2); + $t1 = new Table('Baz'); + $t1->addForeignKey($fk1); + $c3 = new Column('Foo'); + $c4 = new Column('Bar'); + $c5 = new Column('Foo2'); + $c6 = new Column('Bar2'); + $fk2 = new ForeignKey(); + $fk2->addReference($c3, $c4); + $fk2->addReference($c5, $c6); + $t2 = new Table('Baz'); + $t2->addForeignKey($fk2); + $this->assertTrue(PropelForeignKeyComparator::computeDiff($fk1, $fk2)); + } + + public function testCompareOnUpdate() + { + $c1 = new Column('Foo'); + $c2 = new Column('Bar'); + $fk1 = new ForeignKey(); + $fk1->addReference($c1, $c2); + $fk1->setOnUpdate(ForeignKey::SETNULL); + $t1 = new Table('Baz'); + $t1->addForeignKey($fk1); + $c3 = new Column('Foo'); + $c4 = new Column('Bar'); + $fk2 = new ForeignKey(); + $fk2->addReference($c3, $c4); + $fk2->setOnUpdate(ForeignKey::RESTRICT); + $t2 = new Table('Baz'); + $t2->addForeignKey($fk2); + $this->assertTrue(PropelForeignKeyComparator::computeDiff($fk1, $fk2)); + } + + public function testCompareOnDelete() + { + $c1 = new Column('Foo'); + $c2 = new Column('Bar'); + $fk1 = new ForeignKey(); + $fk1->addReference($c1, $c2); + $fk1->setOnDelete(ForeignKey::SETNULL); + $t1 = new Table('Baz'); + $t1->addForeignKey($fk1); + $c3 = new Column('Foo'); + $c4 = new Column('Bar'); + $fk2 = new ForeignKey(); + $fk2->addReference($c3, $c4); + $fk2->setOnDelete(ForeignKey::RESTRICT); + $t2 = new Table('Baz'); + $t2->addForeignKey($fk2); + $this->assertTrue(PropelForeignKeyComparator::computeDiff($fk1, $fk2)); + } + + public function testCompareSort() + { + $c1 = new Column('Foo'); + $c2 = new Column('Bar'); + $c3 = new Column('Baz'); + $c4 = new Column('Faz'); + $fk1 = new ForeignKey(); + $fk1->addReference($c1, $c3); + $fk1->addReference($c2, $c4); + $t1 = new Table('Baz'); + $t1->addForeignKey($fk1); + $fk2 = new ForeignKey(); + $fk2->addReference($c2, $c4); + $fk2->addReference($c1, $c3); + $t2 = new Table('Baz'); + $t2->addForeignKey($fk2); + $this->assertFalse(PropelForeignKeyComparator::computeDiff($fk1, $fk2)); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelIndexComparatorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelIndexComparatorTest.php new file mode 100644 index 000000000..23b860796 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelIndexComparatorTest.php @@ -0,0 +1,91 @@ +addColumn($c1); + $c2 = new Column('Foo'); + $i2 = new Index('Foo_Index'); + $i2->addColumn($c2); + $this->assertFalse(PropelIndexComparator::computeDiff($i1, $i2)); + + $c1 = new Column('Foo'); + $c2 = new Column('Bar'); + $i1 = new Index('Foo_Bar_Index'); + $i1->addColumn($c1); + $i1->addColumn($c2); + $c3 = new Column('Foo'); + $c4 = new Column('Bar'); + $i2 = new Index('Foo_Bar_Index'); + $i2->addColumn($c3); + $i2->addColumn($c4); + $this->assertFalse(PropelIndexComparator::computeDiff($i1, $i2)); + } + + public function testCompareCaseInsensitive() + { + $c1 = new Column('Foo'); + $i1 = new Index('Foo_Index'); + $i1->addColumn($c1); + $c2 = new Column('fOO'); + $i2 = new Index('fOO_iNDEX'); + $i2->addColumn($c2); + $this->assertFalse(PropelIndexComparator::computeDiff($i1, $i2, true)); + } + + public function testCompareType() + { + $c1 = new Column('Foo'); + $i1 = new Index('Foo_Index'); + $i1->addColumn($c1); + $c2 = new Column('Foo'); + $i2 = new Unique('Foo_Index'); + $i2->addColumn($c2); + $this->assertTrue(PropelIndexComparator::computeDiff($i1, $i2)); + } + + public function testCompareDifferentColumns() + { + $c1 = new Column('Foo'); + $i1 = new Index('Foo_Index'); + $i1->addColumn($c1); + $c2 = new Column('Bar'); + $i2 = new Unique('Foo_Index'); + $this->assertTrue(PropelIndexComparator::computeDiff($i1, $i2)); + } + + public function testCompareDifferentOrder() + { + $c1 = new Column('Foo'); + $c2 = new Column('Bar'); + $i1 = new Index('Foo_Bar_Index'); + $i1->addColumn($c1); + $i1->addColumn($c2); + $c3 = new Column('Foo'); + $c4 = new Column('Bar'); + $i2 = new Index('Foo_Bar_Index'); + $i2->addColumn($c4); + $i2->addColumn($c3); + $this->assertTrue(PropelIndexComparator::computeDiff($i1, $i2)); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelTableColumnComparatorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelTableColumnComparatorTest.php new file mode 100644 index 000000000..3753ff69b --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelTableColumnComparatorTest.php @@ -0,0 +1,229 @@ +platform = new MysqlPlatform(); + } + + public function testCompareSameColumns() + { + $t1 = new Table(); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t1->addColumn($c1); + $t2 = new Table(); + $c2 = new Column('Foo'); + $c2->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c2->getDomain()->replaceScale(2); + $c2->getDomain()->replaceSize(3); + $c2->setNotNull(true); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t2->addColumn($c2); + + $this->assertFalse(PropelTableComparator::computeDiff($t1, $t2)); + } + + public function testCompareNotSameColumns() + { + $t1 = new Table(); + $c1 = new Column('Foo'); + $t1->addColumn($c1); + $t2 = new Table(); + $c2 = new Column('Bar'); + $t2->addColumn($c2); + + $diff = PropelTableComparator::computeDiff($t1, $t2); + $this->assertTrue($diff instanceof PropelTableDiff); + } + + public function testCompareCaseInsensitive() + { + $t1 = new Table(); + $c1 = new Column('Foo'); + $t1->addColumn($c1); + $t2 = new Table(); + $c2 = new Column('fOO'); + $t2->addColumn($c2); + + $diff = PropelTableComparator::computeDiff($t1, $t2); + $this->assertTrue($diff instanceof PropelTableDiff); + + $this->assertFalse(PropelTableComparator::computeDiff($t1, $t2, true)); + } + + public function testCompareAddedColumn() + { + $t1 = new Table(); + $t2 = new Table(); + $c2 = new Column('Foo'); + $c2->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c2->getDomain()->replaceScale(2); + $c2->getDomain()->replaceSize(3); + $c2->setNotNull(true); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t2->addColumn($c2); + + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $nbDiffs = $tc->compareColumns(); + $tableDiff = $tc->getTableDiff(); + $this->assertEquals(1, $nbDiffs); + $this->assertEquals(1, count($tableDiff->getAddedColumns())); + $this->assertEquals(array('Foo' => $c2), $tableDiff->getAddedColumns()); + } + + public function testCompareRemovedColumn() + { + $t1 = new Table(); + $c1 = new Column('Bar'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t1->addColumn($c1); + $t2 = new Table(); + + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $nbDiffs = $tc->compareColumns(); + $tableDiff = $tc->getTableDiff(); + $this->assertEquals(1, $nbDiffs); + $this->assertEquals(1, count($tableDiff->getRemovedColumns())); + $this->assertEquals(array('Bar' => $c1), $tableDiff->getRemovedColumns()); + } + + public function testCompareModifiedColumn() + { + $t1 = new Table(); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('VARCHAR')); + $c1->getDomain()->replaceSize(255); + $c1->setNotNull(false); + $t1->addColumn($c1); + $t2 = new Table(); + $c2 = new Column('Foo'); + $c2->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c2->getDomain()->replaceScale(2); + $c2->getDomain()->replaceSize(3); + $c2->setNotNull(true); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t2->addColumn($c2); + + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $nbDiffs = $tc->compareColumns(); + $tableDiff = $tc->getTableDiff(); + $this->assertEquals(1, $nbDiffs); + $this->assertEquals(1, count($tableDiff->getModifiedColumns())); + $columnDiff = PropelColumnComparator::computeDiff($c1, $c2); + $this->assertEquals(array('Foo' => $columnDiff), $tableDiff->getModifiedColumns()); + } + + public function testCompareRenamedColumn() + { + $t1 = new Table(); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t1->addColumn($c1); + $t2 = new Table(); + $c2 = new Column('Bar'); + $c2->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c2->getDomain()->replaceScale(2); + $c2->getDomain()->replaceSize(3); + $c2->setNotNull(true); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t2->addColumn($c2); + + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $nbDiffs = $tc->compareColumns(); + $tableDiff = $tc->getTableDiff(); + $this->assertEquals(1, $nbDiffs); + $this->assertEquals(1, count($tableDiff->getRenamedColumns())); + $this->assertEquals(array(array($c1, $c2)), $tableDiff->getRenamedColumns()); + $this->assertEquals(array(), $tableDiff->getAddedColumns()); + $this->assertEquals(array(), $tableDiff->getRemovedColumns()); + } + + public function testCompareSeveralColumnDifferences() + { + $t1 = new Table(); + $c1 = new Column('col1'); + $c1->getDomain()->copy($this->platform->getDomainForType('VARCHAR')); + $c1->getDomain()->replaceSize(255); + $c1->setNotNull(false); + $t1->addColumn($c1); + $c2 = new Column('col2'); + $c2->getDomain()->copy($this->platform->getDomainForType('INTEGER')); + $c2->setNotNull(true); + $t1->addColumn($c2); + $c3 = new Column('col3'); + $c3->getDomain()->copy($this->platform->getDomainForType('VARCHAR')); + $c3->getDomain()->replaceSize(255); + $t1->addColumn($c3); + + $t2 = new Table(); + $c4 = new Column('col1'); + $c4->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c4->getDomain()->replaceScale(2); + $c4->getDomain()->replaceSize(3); + $c4->setNotNull(true); + $c4->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t2->addColumn($c4); + $c5 = new Column('col22'); + $c5->getDomain()->copy($this->platform->getDomainForType('INTEGER')); + $c5->setNotNull(true); + $t2->addColumn($c5); + $c6 = new Column('col4'); + $c6->getDomain()->copy($this->platform->getDomainForType('LONGVARCHAR')); + $c6->getDomain()->setDefaultValue(new ColumnDefaultValue('123', ColumnDefaultValue::TYPE_VALUE)); + $t2->addColumn($c6); + + // col1 was modified, col2 was renamed, col3 was removed, col4 was added + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $nbDiffs = $tc->compareColumns(); + $tableDiff = $tc->getTableDiff(); + $this->assertEquals(4, $nbDiffs); + $this->assertEquals(array(array($c2, $c5)), $tableDiff->getRenamedColumns()); + $this->assertEquals(array('col4' => $c6), $tableDiff->getAddedColumns()); + $this->assertEquals(array('col3' => $c3), $tableDiff->getRemovedColumns()); + $columnDiff = PropelColumnComparator::computeDiff($c1, $c4); + $this->assertEquals(array('col1' => $columnDiff), $tableDiff->getModifiedColumns()); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelTableForeignKeyComparatorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelTableForeignKeyComparatorTest.php new file mode 100644 index 000000000..1b668e7ef --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelTableForeignKeyComparatorTest.php @@ -0,0 +1,172 @@ +platform = new MysqlPlatform(); + } + + public function testCompareSameFks() + { + $c1 = new Column('Foo'); + $c2 = new Column('Bar'); + $fk1 = new ForeignKey(); + $fk1->addReference($c1, $c2); + $t1 = new Table('Baz'); + $t1->addForeignKey($fk1); + $c3 = new Column('Foo'); + $c4 = new Column('Bar'); + $fk2 = new ForeignKey(); + $fk2->addReference($c3, $c4); + $t2 = new Table('Baz'); + $t2->addForeignKey($fk2); + + $this->assertFalse(PropelTableComparator::computeDiff($t1, $t2)); + } + + public function testCompareNotSameFks() + { + $c1 = new Column('Foo'); + $c2 = new Column('Bar'); + $fk1 = new ForeignKey(); + $fk1->addReference($c1, $c2); + $t1 = new Table('Baz'); + $t1->addForeignKey($fk1); + + $t2 = new Table('Baz'); + + $diff = PropelTableComparator::computeDiff($t1, $t2); + $this->assertTrue($diff instanceof PropelTableDiff); + } + + public function testCaseInsensitive() + { + $t1 = new Table('Baz'); + $c1 = new Column('Foo'); + $c2 = new Column('Bar'); + $fk1 = new ForeignKey(); + $fk1->addReference($c1, $c2); + $t1->addForeignKey($fk1); + + $t2 = new Table('bAZ'); + $c3 = new Column('fOO'); + $c4 = new Column('bAR'); + $fk2 = new ForeignKey(); + $fk2->addReference($c3, $c4); + $t2->addForeignKey($fk2); + + $this->assertFalse(PropelTableComparator::computeDiff($t1, $t2, true)); + } + + public function testCompareAddedFks() + { + $db1 = new Database(); + $db1->setPlatform($this->platform); + $t1 = new Table('Baz'); + $db1->addTable($t1); + $t1->doNaming(); + + $db2 = new Database(); + $db2->setPlatform($this->platform); + $c3 = new Column('Foo'); + $c4 = new Column('Bar'); + $fk2 = new ForeignKey(); + $fk2->addReference($c3, $c4); + $t2 = new Table('Baz'); + $t2->addForeignKey($fk2); + $db2->addTable($t2); + $t2->doNaming(); + + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $nbDiffs = $tc->compareForeignKeys(); + $tableDiff = $tc->getTableDiff(); + $this->assertEquals(1, $nbDiffs); + $this->assertEquals(1, count($tableDiff->getAddedFks())); + $this->assertEquals(array('Baz_FK_1' => $fk2), $tableDiff->getAddedFks()); + } + + public function testCompareRemovedFks() + { + $db1 = new Database(); + $db1->setPlatform($this->platform); + $c1 = new Column('Foo'); + $c2 = new Column('Bar'); + $fk1 = new ForeignKey(); + $fk1->addReference($c1, $c2); + $t1 = new Table('Baz'); + $t1->addForeignKey($fk1); + $db1->addTable($t1); + $t1->doNaming(); + + $db2 = new Database(); + $db2->setPlatform($this->platform); + $t2 = new Table('Baz'); + $db2->addTable($t2); + $t2->doNaming(); + + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $nbDiffs = $tc->compareForeignKeys(); + $tableDiff = $tc->getTableDiff(); + $this->assertEquals(1, $nbDiffs); + $this->assertEquals(1, count($tableDiff->getRemovedFks())); + $this->assertEquals(array('Baz_FK_1' => $fk1), $tableDiff->getRemovedFks()); + } + + public function testCompareModifiedFks() + { + $db1 = new Database(); + $db1->setPlatform($this->platform); + $c1 = new Column('Foo'); + $c2 = new Column('Bar'); + $fk1 = new ForeignKey(); + $fk1->addReference($c1, $c2); + $t1 = new Table('Baz'); + $t1->addForeignKey($fk1); + $db1->addTable($t1); + $t1->doNaming(); + + $db2 = new Database(); + $db2->setPlatform($this->platform); + $c3 = new Column('Foo'); + $c4 = new Column('Bar2'); + $fk2 = new ForeignKey(); + $fk2->addReference($c3, $c4); + $t2 = new Table('Baz'); + $t2->addForeignKey($fk2); + $db2->addTable($t2); + $t2->doNaming(); + + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $nbDiffs = $tc->compareForeignKeys(); + $tableDiff = $tc->getTableDiff(); + $this->assertEquals(1, $nbDiffs); + $this->assertEquals(1, count($tableDiff->getModifiedFks())); + $this->assertEquals(array('Baz_FK_1' => array($fk1, $fk2)), $tableDiff->getModifiedFks()); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelTableIndexComparatorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelTableIndexComparatorTest.php new file mode 100644 index 000000000..3dc37befb --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelTableIndexComparatorTest.php @@ -0,0 +1,196 @@ +platform = new MysqlPlatform(); + } + + public function testCompareSameIndices() + { + $t1 = new Table(); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t1->addColumn($c1); + $i1 = new Index('Foo_Index'); + $i1->addColumn($c1); + $t1->addIndex($i1); + $t2 = new Table(); + $c2 = new Column('Foo'); + $c2->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c2->getDomain()->replaceScale(2); + $c2->getDomain()->replaceSize(3); + $c2->setNotNull(true); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t2->addColumn($c2); + $i2 = new Index('Foo_Index'); + $i2->addColumn($c2); + $t2->addIndex($i2); + + $this->assertFalse(PropelTableComparator::computeDiff($t1, $t2)); + } + + public function testCompareNotSameIndices() + { + $t1 = new Table(); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t1->addColumn($c1); + $i1 = new Index('Foo_Index'); + $i1->addColumn($c1); + $t1->addIndex($i1); + $t2 = new Table(); + $c2 = new Column('Foo'); + $c2->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c2->getDomain()->replaceScale(2); + $c2->getDomain()->replaceSize(3); + $c2->setNotNull(true); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t2->addColumn($c2); + $i2 = new Unique('Foo_Index'); + $i2->addColumn($c2); + $t2->addIndex($i2); + + $diff = PropelTableComparator::computeDiff($t1, $t2); + $this->assertTrue($diff instanceof PropelTableDiff); + } + + public function testCompareCaseInsensitive() + { + $t1 = new Table(); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t1->addColumn($c1); + $i1 = new Index('Foo_Index'); + $i1->addColumn($c1); + $t1->addIndex($i1); + $t2 = new Table(); + $c2 = new Column('fOO'); + $c2->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c2->getDomain()->replaceScale(2); + $c2->getDomain()->replaceSize(3); + $c2->setNotNull(true); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t2->addColumn($c2); + $i2 = new Index('fOO_iNDEX'); + $i2->addColumn($c2); + $t2->addIndex($i2); + + $this->assertFalse(PropelTableComparator::computeDiff($t1, $t2, true)); + } + + public function testCompareAddedIndices() + { + $t1 = new Table(); + $t2 = new Table(); + $c2 = new Column('Foo'); + $c2->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c2->getDomain()->replaceScale(2); + $c2->getDomain()->replaceSize(3); + $c2->setNotNull(true); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t2->addColumn($c2); + $i2 = new Index('Foo_Index'); + $i2->addColumn($c2); + $t2->addIndex($i2); + + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $nbDiffs = $tc->compareIndices(); + $tableDiff = $tc->getTableDiff(); + $this->assertEquals(1, $nbDiffs); + $this->assertEquals(1, count($tableDiff->getAddedIndices())); + $this->assertEquals(array('Foo_Index' => $i2), $tableDiff->getAddedIndices()); + } + + public function testCompareRemovedIndices() + { + $t1 = new Table(); + $c1 = new Column('Bar'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t1->addColumn($c1); + $i1 = new Index('Bar_Index'); + $i1->addColumn($c1); + $t1->addIndex($i1); + $t2 = new Table(); + + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $nbDiffs = $tc->compareIndices(); + $tableDiff = $tc->getTableDiff(); + $this->assertEquals(1, $nbDiffs); + $this->assertEquals(1, count($tableDiff->getRemovedIndices())); + $this->assertEquals(array('Bar_Index' => $i1), $tableDiff->getRemovedIndices()); + } + + public function testCompareModifiedIndices() + { + $t1 = new Table(); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('VARCHAR')); + $c1->getDomain()->replaceSize(255); + $c1->setNotNull(false); + $t1->addColumn($c1); + $i1 = new Index('Foo_Index'); + $i1->addColumn($c1); + $t1->addIndex($i1); + $t2 = new Table(); + $c2 = new Column('Foo'); + $c2->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c2->getDomain()->replaceScale(2); + $c2->getDomain()->replaceSize(3); + $c2->setNotNull(true); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t2->addColumn($c2); + $i2 = new Unique('Foo_Index'); + $i2->addColumn($c2); + $t2->addIndex($i2); + + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $nbDiffs = $tc->compareIndices(); + $tableDiff = $tc->getTableDiff(); + $this->assertEquals(1, $nbDiffs); + $this->assertEquals(1, count($tableDiff->getModifiedIndices())); + $this->assertEquals(array('Foo_Index' => array($i1, $i2)), $tableDiff->getModifiedIndices()); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelTablePkColumnComparatorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelTablePkColumnComparatorTest.php new file mode 100644 index 000000000..583d6099f --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/model/diff/PropelTablePkColumnComparatorTest.php @@ -0,0 +1,186 @@ +platform = new MysqlPlatform(); + } + + public function testCompareSamePks() + { + $t1 = new Table(); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->setPrimaryKey(true); + $t1->addColumn($c1); + $t2 = new Table(); + $c2 = new Column('Foo'); + $c2->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c2->setPrimaryKey(true); + $t2->addColumn($c2); + + $this->assertFalse(PropelTableComparator::computeDiff($t1, $t2)); + } + + public function testCompareNotSamePks() + { + $t1 = new Table(); + $c1 = new Column('Foo'); + $c1->setPrimaryKey(true); + $t1->addColumn($c1); + $t2 = new Table(); + $c2 = new Column('Foo'); + $t2->addColumn($c2); + + $diff = PropelTableComparator::computeDiff($t1, $t2); + $this->assertTrue($diff instanceof PropelTableDiff); + } + + public function testCompareAddedPkColumn() + { + $t1 = new Table(); + $t2 = new Table(); + $c2 = new Column('Foo'); + $c2->getDomain()->copy($this->platform->getDomainForType('INTEGER')); + $c2->setPrimaryKey(true); + $t2->addColumn($c2); + $c3 = new Column('Bar'); + $c3->getDomain()->copy($this->platform->getDomainForType('LONGVARCHAR')); + $t2->addColumn($c3); + + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $nbDiffs = $tc->comparePrimaryKeys(); + $tableDiff = $tc->getTableDiff(); + $this->assertEquals(1, $nbDiffs); + $this->assertEquals(1, count($tableDiff->getAddedPkColumns())); + $this->assertEquals(array('Foo' => $c2), $tableDiff->getAddedPkColumns()); + } + + public function testCompareRemovedPkColumn() + { + $t1 = new Table(); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('INTEGER')); + $c1->setPrimaryKey(true); + $t1->addColumn($c1); + $c2 = new Column('Bar'); + $c2->getDomain()->copy($this->platform->getDomainForType('LONGVARCHAR')); + $t1->addColumn($c2); + $t2 = new Table(); + + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $nbDiffs = $tc->comparePrimaryKeys(); + $tableDiff = $tc->getTableDiff(); + $this->assertEquals(1, $nbDiffs); + $this->assertEquals(1, count($tableDiff->getRemovedPkColumns())); + $this->assertEquals(array('Foo' => $c1), $tableDiff->getRemovedPkColumns()); + } + + public function testCompareRenamedPkColumn() + { + $t1 = new Table(); + $c1 = new Column('Foo'); + $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceScale(2); + $c1->getDomain()->replaceSize(3); + $c1->setNotNull(true); + $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $c1->setPrimaryKey(true); + $t1->addColumn($c1); + $t2 = new Table(); + $c2 = new Column('Bar'); + $c2->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c2->getDomain()->replaceScale(2); + $c2->getDomain()->replaceSize(3); + $c2->setNotNull(true); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $c2->setPrimaryKey(true); + $t2->addColumn($c2); + + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $nbDiffs = $tc->comparePrimaryKeys(); + $tableDiff = $tc->getTableDiff(); + $this->assertEquals(1, $nbDiffs); + $this->assertEquals(1, count($tableDiff->getRenamedPkColumns())); + $this->assertEquals(array(array($c1, $c2)), $tableDiff->getRenamedPkColumns()); + $this->assertEquals(array(), $tableDiff->getAddedPkColumns()); + $this->assertEquals(array(), $tableDiff->getRemovedPkColumns()); + } + + public function testCompareSeveralPrimaryKeyDifferences() + { + $t1 = new Table(); + $c1 = new Column('col1'); + $c1->getDomain()->copy($this->platform->getDomainForType('VARCHAR')); + $c1->getDomain()->replaceSize(255); + $c1->setNotNull(false); + $t1->addColumn($c1); + $c2 = new Column('col2'); + $c2->getDomain()->copy($this->platform->getDomainForType('INTEGER')); + $c2->setNotNull(true); + $c2->setPrimaryKey(true); + $t1->addColumn($c2); + $c3 = new Column('col3'); + $c3->getDomain()->copy($this->platform->getDomainForType('VARCHAR')); + $c3->getDomain()->replaceSize(255); + $c3->setPrimaryKey(true); + $t1->addColumn($c3); + + $t2 = new Table(); + $c4 = new Column('col1'); + $c4->getDomain()->copy($this->platform->getDomainForType('DOUBLE')); + $c4->getDomain()->replaceScale(2); + $c4->getDomain()->replaceSize(3); + $c4->setNotNull(true); + $c4->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $t2->addColumn($c4); + $c5 = new Column('col22'); + $c5->getDomain()->copy($this->platform->getDomainForType('INTEGER')); + $c5->setNotNull(true); + $c5->setPrimaryKey(true); + $t2->addColumn($c5); + $c6 = new Column('col4'); + $c6->getDomain()->copy($this->platform->getDomainForType('LONGVARCHAR')); + $c6->getDomain()->setDefaultValue(new ColumnDefaultValue('123', ColumnDefaultValue::TYPE_VALUE)); + $c6->setPrimaryKey(true); + $t2->addColumn($c6); + + // col2 was renamed, col3 was removed, col4 was added + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $nbDiffs = $tc->comparePrimaryKeys(); + $tableDiff = $tc->getTableDiff(); + $this->assertEquals(3, $nbDiffs); + $this->assertEquals(array(array($c2, $c5)), $tableDiff->getRenamedPkColumns()); + $this->assertEquals(array('col4' => $c6), $tableDiff->getAddedPkColumns()); + $this->assertEquals(array('col3' => $c3), $tableDiff->getRemovedPkColumns()); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/platform/DefaultPlatformTest.php b/airtime_mvc/library/propel/test/testsuite/generator/platform/DefaultPlatformTest.php index db1c91ef9..975fdad82 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/platform/DefaultPlatformTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/platform/DefaultPlatformTest.php @@ -8,38 +8,97 @@ * @license MIT License */ -require_once 'generator/platform/PlatformTestBase.php'; +require_once dirname(__FILE__) . '/../../../../generator/lib/platform/DefaultPlatform.php'; +require_once dirname(__FILE__) . '/../../../../generator/lib/model/Column.php'; +require_once dirname(__FILE__) . '/../../../../generator/lib/util/PropelQuickBuilder.php'; +require_once dirname(__FILE__) . '/../../../../runtime/lib/Propel.php'; + /** * - * @package generator.platform + * @package generator.platform */ -class DefaultPlatformTest extends PlatformTestBase +class DefaultPlatformTest extends PHPUnit_Framework_TestCase { + protected $platform; - protected function setUp() - { - parent::setUp(); - } + /** + * Get the Platform object for this class + * + * @return Platform + */ + protected function getPlatform() + { + if (null === $this->platform) { + $this->platform = new DefaultPlatform(); + } - public function tearDown() - { - parent::tearDown(); - } + return $this->platform; + } - public function testQuote() - { - $p = $this->getPlatform(); + protected function tearDown() + { + $this->platform = null; + } - $unquoted = "Nice"; - $quoted = $p->quote($unquoted); + public function testQuote() + { + $p = $this->getPlatform(); - $this->assertEquals("'$unquoted'", $quoted); + $unquoted = "Nice"; + $quoted = $p->quote($unquoted); + $this->assertEquals("'$unquoted'", $quoted); - $unquoted = "Naughty ' string"; - $quoted = $p->quote($unquoted); - $expected = "'Naughty '' string'"; - $this->assertEquals($expected, $quoted); - } + $unquoted = "Naughty ' string"; + $quoted = $p->quote($unquoted); + $expected = "'Naughty '' string'"; + $this->assertEquals($expected, $quoted); + } + + protected function createColumn($type, $defaultValue) + { + $column = new Column(); + $column->setType($type); + $column->setDefaultValue($defaultValue); + + return $column; + } + + public function createEnumColumn($defaultValues, $defaultValue) + { + $column = new Column(); + $column->setType(PropelTypes::ENUM); + $column->setValueSet($defaultValues); + $column->setDefaultValue($defaultValue); + + return $column; + } + + public function getColumnDefaultValueDDLDataProvider() + { + return array( + array($this->createColumn(PropelTypes::INTEGER, 0), "DEFAULT 0"), + array($this->createColumn(PropelTypes::INTEGER, '0'), "DEFAULT 0"), + array($this->createColumn(PropelTypes::VARCHAR, 'foo'), "DEFAULT 'foo'"), + array($this->createColumn(PropelTypes::VARCHAR, 0), "DEFAULT '0'"), + array($this->createColumn(PropelTypes::BOOLEAN, true), "DEFAULT 1"), + array($this->createColumn(PropelTypes::BOOLEAN, false), "DEFAULT 0"), + array($this->createColumn(PropelTypes::BOOLEAN, 'true'), "DEFAULT 1"), + array($this->createColumn(PropelTypes::BOOLEAN, 'false'), "DEFAULT 0"), + array($this->createColumn(PropelTypes::BOOLEAN, 'TRUE'), "DEFAULT 1"), + array($this->createColumn(PropelTypes::BOOLEAN, 'FALSE'), "DEFAULT 0"), + array($this->createEnumColumn(array('foo', 'bar', 'baz'), 'foo'), "DEFAULT 0"), + array($this->createEnumColumn(array('foo', 'bar', 'baz'), 'bar'), "DEFAULT 1"), + array($this->createEnumColumn(array('foo', 'bar', 'baz'), 'baz'), "DEFAULT 2"), + ); + } + + /** + * @dataProvider getColumnDefaultValueDDLDataProvider + */ + public function testGetColumnDefaultValueDDL($column, $default) + { + $this->assertEquals($default, $this->getPlatform()->getColumnDefaultValueDDL($column)); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/platform/MssqlPlatformTest.php b/airtime_mvc/library/propel/test/testsuite/generator/platform/MssqlPlatformTest.php new file mode 100644 index 000000000..148795fc3 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/platform/MssqlPlatformTest.php @@ -0,0 +1,640 @@ +setIdMethod(IDMethod::NATIVE); + $expected = 'foo_SEQ'; + $this->assertEquals($expected, $this->getPlatform()->getSequenceName($table)); + } + + public function testGetSequenceNameCustom() + { + $table = new Table('foo'); + $table->setIdMethod(IDMethod::NATIVE); + $idMethodParameter = new IdMethodParameter(); + $idMethodParameter->setValue('foo_sequence'); + $table->addIdMethodParameter($idMethodParameter); + $table->setIdMethod(IDMethod::NATIVE); + $expected = 'foo_sequence'; + $this->assertEquals($expected, $this->getPlatform()->getSequenceName($table)); + } + + /** + * @dataProvider providerForTestGetAddTablesDDL + */ + public function testGetAddTablesDDL($schema) + { + $database = $this->getDatabaseFromSchema($schema); + $expected = <<assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); + } + + /** + * @dataProvider providerForTestGetAddTablesDDLSchema + */ + public function testGetAddTablesDDLSchemas($schema) + { + $database = $this->getDatabaseFromSchema($schema); + $expected = <<assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); + } + + /** + * @dataProvider providerForTestGetAddTablesSkipSQLDDL + */ + public function testGetAddTablesSkipSQLDDL($schema) + { + $database = $this->getDatabaseFromSchema($schema); + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLSimplePK + */ + public function testGetAddTableDDLSimplePK($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = " +-- This is foo table +CREATE TABLE [foo] +( + [id] INT NOT NULL IDENTITY, + [bar] VARCHAR(255) NOT NULL, + CONSTRAINT [foo_PK] PRIMARY KEY ([id]) +); +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLCompositePK + */ + public function testGetAddTableDDLCompositePK($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE [foo] +( + [foo] INT NOT NULL, + [bar] INT NOT NULL, + [baz] VARCHAR(255) NOT NULL, + CONSTRAINT [foo_PK] PRIMARY KEY ([foo],[bar]) +); +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLUniqueIndex + */ + public function testGetAddTableDDLUniqueIndex($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE [foo] +( + [id] INT NOT NULL IDENTITY, + [bar] INT NULL, + CONSTRAINT [foo_PK] PRIMARY KEY ([id]), + UNIQUE ([bar]) +); +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLSchema + */ + public function testGetAddTableDDLSchema($schema) + { + $table = $this->getTableFromSchema($schema, 'Woopah.foo'); + $expected = " +CREATE TABLE [Woopah].[foo] +( + [id] INT NOT NULL IDENTITY, + [bar] INT NULL, + CONSTRAINT [foo_PK] PRIMARY KEY ([id]) +); +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + public function testGetDropTableDDL() + { + $table = new Table('foo'); + $expected = " +IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'foo') +BEGIN + DECLARE @reftable_6 nvarchar(60), @constraintname_6 nvarchar(60) + DECLARE refcursor CURSOR FOR + select reftables.name tablename, cons.name constraintname + from sysobjects tables, + sysobjects reftables, + sysobjects cons, + sysreferences ref + where tables.id = ref.rkeyid + and cons.id = ref.constid + and reftables.id = ref.fkeyid + and tables.name = 'foo' + OPEN refcursor + FETCH NEXT from refcursor into @reftable_6, @constraintname_6 + while @@FETCH_STATUS = 0 + BEGIN + exec ('alter table '+@reftable_6+' drop constraint '+@constraintname_6) + FETCH NEXT from refcursor into @reftable_6, @constraintname_6 + END + CLOSE refcursor + DEALLOCATE refcursor + DROP TABLE [foo] +END +"; + $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLSchema + */ + public function testGetDropTableDDLSchema($schema) + { + $table = $this->getTableFromSchema($schema, 'Woopah.foo'); + $expected = " +IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'Woopah.foo') +BEGIN + DECLARE @reftable_7 nvarchar(60), @constraintname_7 nvarchar(60) + DECLARE refcursor CURSOR FOR + select reftables.name tablename, cons.name constraintname + from sysobjects tables, + sysobjects reftables, + sysobjects cons, + sysreferences ref + where tables.id = ref.rkeyid + and cons.id = ref.constid + and reftables.id = ref.fkeyid + and tables.name = 'Woopah.foo' + OPEN refcursor + FETCH NEXT from refcursor into @reftable_7, @constraintname_7 + while @@FETCH_STATUS = 0 + BEGIN + exec ('alter table '+@reftable_7+' drop constraint '+@constraintname_7) + FETCH NEXT from refcursor into @reftable_7, @constraintname_7 + END + CLOSE refcursor + DEALLOCATE refcursor + DROP TABLE [Woopah].[foo] +END +"; + $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); + } + + public function testGetColumnDDLCustomSqlType() + { + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE')); + $column->getDomain()->replaceScale(2); + $column->getDomain()->replaceSize(3); + $column->setNotNull(true); + $column->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $column->getDomain()->replaceSqlType('DECIMAL(5,6)'); + + $expected = '[foo] DECIMAL(5,6) DEFAULT 123 NOT NULL'; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + } + + public function testGetPrimaryKeyDDLSimpleKey() + { + $table = new Table('foo'); + $column = new Column('bar'); + $column->setPrimaryKey(true); + $table->addColumn($column); + + $expected = 'CONSTRAINT [foo_PK] PRIMARY KEY ([bar])'; + $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); + } + + public function testGetPrimaryKeyDDLCompositeKey() + { + $table = new Table('foo'); + $column1 = new Column('bar1'); + $column1->setPrimaryKey(true); + $table->addColumn($column1); + $column2 = new Column('bar2'); + $column2->setPrimaryKey(true); + $table->addColumn($column2); + + $expected = 'CONSTRAINT [foo_PK] PRIMARY KEY ([bar1],[bar2])'; + $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestPrimaryKeyDDL + */ + public function testGetDropPrimaryKeyDDL($table) + { + $expected = " +ALTER TABLE [foo] DROP CONSTRAINT [foo_PK]; +"; + $this->assertEquals($expected, $this->getPlatform()->getDropPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestPrimaryKeyDDL + */ + public function testGetAddPrimaryKeyDDL($table) + { + $expected = " +ALTER TABLE [foo] ADD CONSTRAINT [foo_PK] PRIMARY KEY ([bar]); +"; + $this->assertEquals($expected, $this->getPlatform()->getAddPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestGetIndicesDDL + */ + public function testAddIndicesDDL($table) + { + $expected = " +CREATE INDEX [babar] ON [foo] ([bar1],[bar2]); + +CREATE INDEX [foo_index] ON [foo] ([bar1]); +"; + $this->assertEquals($expected, $this->getPLatform()->getAddIndicesDDL($table)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testAddIndexDDL($index) + { + $expected = " +CREATE INDEX [babar] ON [foo] ([bar1],[bar2]); +"; + $this->assertEquals($expected, $this->getPLatform()->getAddIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testDropIndexDDL($index) + { + $expected = " +DROP INDEX [babar]; +"; + $this->assertEquals($expected, $this->getPLatform()->getDropIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testGetIndexDDL($index) + { + $expected = 'INDEX [babar] ([bar1],[bar2])'; + $this->assertEquals($expected, $this->getPLatform()->getIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetUniqueDDL + */ + public function testGetUniqueDDL($index) + { + $expected = 'UNIQUE ([bar1],[bar2])'; + $this->assertEquals($expected, $this->getPLatform()->getUniqueDDL($index)); + } + + /** + * @dataProvider providerForTestGetForeignKeysDDL + */ + public function testGetAddForeignKeysDDL($table) + { + $expected = " +BEGIN +ALTER TABLE [foo] ADD CONSTRAINT [foo_bar_FK] FOREIGN KEY ([bar_id]) REFERENCES [bar] ([id]) ON DELETE CASCADE +END +; + +BEGIN +ALTER TABLE [foo] ADD CONSTRAINT [foo_baz_FK] FOREIGN KEY ([baz_id]) REFERENCES [baz] ([id]) +END +; +"; + $this->assertEquals($expected, $this->getPLatform()->getAddForeignKeysDDL($table)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetAddForeignKeyDDL($fk) + { + $expected = " +BEGIN +ALTER TABLE [foo] ADD CONSTRAINT [foo_bar_FK] FOREIGN KEY ([bar_id]) REFERENCES [bar] ([id]) ON DELETE CASCADE +END +; +"; + $this->assertEquals($expected, $this->getPLatform()->getAddForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeySkipSqlDDL + */ + public function testGetAddForeignKeySkipSqlDDL($fk) + { + $expected = ''; + $this->assertEquals($expected, $this->getPLatform()->getAddForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetDropForeignKeyDDL($fk) + { + $expected = " +ALTER TABLE [foo] DROP CONSTRAINT [foo_bar_FK]; +"; + $this->assertEquals($expected, $this->getPLatform()->getDropForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeySkipSqlDDL + */ + public function testGetDropForeignKeySkipSqlDDL($fk) + { + $expected = ''; + $this->assertEquals($expected, $this->getPLatform()->getDropForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetForeignKeyDDL($fk) + { + $expected = 'CONSTRAINT [foo_bar_FK] FOREIGN KEY ([bar_id]) REFERENCES [bar] ([id]) ON DELETE CASCADE'; + $this->assertEquals($expected, $this->getPLatform()->getForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeySkipSqlDDL + */ + public function testGetForeignKeySkipSqlDDL($fk) + { + $expected = ''; + $this->assertEquals($expected, $this->getPLatform()->getForeignKeyDDL($fk)); + } + + public function testGetCommentBlockDDL() + { + $expected = " +----------------------------------------------------------------------- +-- foo bar +----------------------------------------------------------------------- +"; + $this->assertEquals($expected, $this->getPLatform()->getCommentBlockDDL('foo bar')); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/platform/MysqlPlatformMigrationMyISAMTest.php b/airtime_mvc/library/propel/test/testsuite/generator/platform/MysqlPlatformMigrationMyISAMTest.php new file mode 100644 index 000000000..395b8d683 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/platform/MysqlPlatformMigrationMyISAMTest.php @@ -0,0 +1,262 @@ +setBuildProperties(array( + 'propel.mysql.tableType' => 'MyISAM' + )); + $platform->setGeneratorConfig($config); + } + + return $platform; + } + + /** + * @dataProvider providerForTestGetModifyDatabaseDDL + */ + public function testGetModifyDatabaseDDL($databaseDiff) + { + $expected = " +# This is a fix for InnoDB in MySQL >= 4.1.x +# It \"suspends judgement\" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +DROP TABLE IF EXISTS `foo1`; + +RENAME TABLE `foo3` TO `foo4`; + +ALTER TABLE `foo2` CHANGE `bar` `bar1` INTEGER; + +ALTER TABLE `foo2` CHANGE `baz` `baz` VARCHAR(12); + +ALTER TABLE `foo2` + ADD `baz3` TEXT AFTER `baz`; + +CREATE TABLE `foo5` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `lkdjfsh` INTEGER, + `dfgdsgf` TEXT, + PRIMARY KEY (`id`) +) ENGINE=MyISAM; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyDatabaseDDL($databaseDiff)); + } + + /** + * @dataProvider providerForTestGetRenameTableDDL + */ + public function testGetRenameTableDDL($fromName, $toName) + { + $expected = " +RENAME TABLE `foo1` TO `foo2`; +"; + $this->assertEquals($expected, $this->getPlatform()->getRenameTableDDL($fromName, $toName)); + } + + /** + * @dataProvider providerForTestGetModifyTableDDL + */ + public function testGetModifyTableDDL($tableDiff) + { + $expected = " +DROP INDEX `bar_baz_FK` ON `foo`; + +DROP INDEX `foo1_FI_2` ON `foo`; + +DROP INDEX `bar_FK` ON `foo`; + +ALTER TABLE `foo` CHANGE `bar` `bar1` INTEGER; + +ALTER TABLE `foo` CHANGE `baz` `baz` VARCHAR(12); + +ALTER TABLE `foo` + ADD `baz3` TEXT AFTER `baz`; + +CREATE INDEX `bar_FK` ON `foo` (`bar1`); + +CREATE INDEX `baz_FK` ON `foo` (`baz3`); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTableColumnsDDL + */ + public function testGetModifyTableColumnsDDL($tableDiff) + { + $expected = " +ALTER TABLE `foo` CHANGE `bar` `bar1` INTEGER; + +ALTER TABLE `foo` CHANGE `baz` `baz` VARCHAR(12); + +ALTER TABLE `foo` + ADD `baz3` TEXT AFTER `baz`; +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableColumnsDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTablePrimaryKeysDDL + */ + public function testGetModifyTablePrimaryKeysDDL($tableDiff) + { + $expected = " +ALTER TABLE `foo` DROP PRIMARY KEY; + +ALTER TABLE `foo` ADD PRIMARY KEY (`id`,`bar`); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTablePrimaryKeyDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTableIndicesDDL + */ + public function testGetModifyTableIndicesDDL($tableDiff) + { + $expected = " +DROP INDEX `bar_FK` ON `foo`; + +CREATE INDEX `baz_FK` ON `foo` (`baz`); + +DROP INDEX `bar_baz_FK` ON `foo`; + +CREATE INDEX `bar_baz_FK` ON `foo` (`id`,`bar`,`baz`); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableIndicesDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTableForeignKeysDDL + */ + public function testGetModifyTableForeignKeysDDL($tableDiff) + { + $expected = ""; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTableForeignKeysSkipSqlDDL + */ + public function testGetModifyTableForeignKeysSkipSqlDDL($tableDiff) + { + $expected = ""; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff)); + $expected = ""; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff->getReverseDiff())); + } + + /** + * @dataProvider providerForTestGetModifyTableForeignKeysSkipSql2DDL + */ + public function testGetModifyTableForeignKeysSkipSql2DDL($tableDiff) + { + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff)); + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff->getReverseDiff())); + } + + /** + * @dataProvider providerForTestGetRemoveColumnDDL + */ + public function testGetRemoveColumnDDL($column) + { + $expected = " +ALTER TABLE `foo` DROP `bar`; +"; + $this->assertEquals($expected, $this->getPlatform()->getRemoveColumnDDL($column)); + } + + /** + * @dataProvider providerForTestGetRenameColumnDDL + */ + public function testGetRenameColumnDDL($fromColumn, $toColumn) + { + $expected = " +ALTER TABLE `foo` CHANGE `bar1` `bar2` DOUBLE(2); +"; + $this->assertEquals($expected, $this->getPlatform()->getRenameColumnDDL($fromColumn, $toColumn)); + } + + /** + * @dataProvider providerForTestGetModifyColumnDDL + */ + public function testGetModifyColumnDDL($columnDiff) + { + $expected = " +ALTER TABLE `foo` CHANGE `bar` `bar` DOUBLE(3); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyColumnDDL($columnDiff)); + } + + /** + * @dataProvider providerForTestGetModifyColumnsDDL + */ + public function testGetModifyColumnsDDL($columnDiffs) + { + $expected = " +ALTER TABLE `foo` CHANGE `bar1` `bar1` DOUBLE(3); + +ALTER TABLE `foo` CHANGE `bar2` `bar2` INTEGER NOT NULL; +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyColumnsDDL($columnDiffs)); + } + + /** + * @dataProvider providerForTestGetAddColumnDDL + */ + public function testGetAddColumnDDL($column) + { + $expected = " +ALTER TABLE `foo` ADD `bar` INTEGER; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddColumnDDL($column)); + } + + /** + * @dataProvider providerForTestGetAddColumnsDDL + */ + public function testGetAddColumnsDDL($columns) + { + $expected = " +ALTER TABLE `foo` + ADD `bar1` INTEGER AFTER `id`, + ADD `bar2` DOUBLE(3,2) DEFAULT -1 NOT NULL AFTER `bar1`; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddColumnsDDL($columns)); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/platform/MysqlPlatformMigrationTest.php b/airtime_mvc/library/propel/test/testsuite/generator/platform/MysqlPlatformMigrationTest.php new file mode 100644 index 000000000..febaa499d --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/platform/MysqlPlatformMigrationTest.php @@ -0,0 +1,288 @@ +setBuildProperties(array( + 'propel.mysql.tableType' => 'InnoDB' + )); + $platform->setGeneratorConfig($config); + } + + return $platform; + } + + /** + * @dataProvider providerForTestGetModifyDatabaseDDL + */ + public function testGetModifyDatabaseDDL($databaseDiff) + { + $expected = " +# This is a fix for InnoDB in MySQL >= 4.1.x +# It \"suspends judgement\" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +DROP TABLE IF EXISTS `foo1`; + +RENAME TABLE `foo3` TO `foo4`; + +ALTER TABLE `foo2` CHANGE `bar` `bar1` INTEGER; + +ALTER TABLE `foo2` CHANGE `baz` `baz` VARCHAR(12); + +ALTER TABLE `foo2` + ADD `baz3` TEXT AFTER `baz`; + +CREATE TABLE `foo5` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `lkdjfsh` INTEGER, + `dfgdsgf` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyDatabaseDDL($databaseDiff)); + } + + /** + * @dataProvider providerForTestGetRenameTableDDL + */ + public function testGetRenameTableDDL($fromName, $toName) + { + $expected = " +RENAME TABLE `foo1` TO `foo2`; +"; + $this->assertEquals($expected, $this->getPlatform()->getRenameTableDDL($fromName, $toName)); + } + + /** + * @dataProvider providerForTestGetModifyTableDDL + */ + public function testGetModifyTableDDL($tableDiff) + { + $expected = " +ALTER TABLE `foo` DROP FOREIGN KEY `foo1_FK_2`; + +ALTER TABLE `foo` DROP FOREIGN KEY `foo1_FK_1`; + +DROP INDEX `bar_baz_FK` ON `foo`; + +DROP INDEX `foo1_FI_2` ON `foo`; + +DROP INDEX `bar_FK` ON `foo`; + +ALTER TABLE `foo` CHANGE `bar` `bar1` INTEGER; + +ALTER TABLE `foo` CHANGE `baz` `baz` VARCHAR(12); + +ALTER TABLE `foo` + ADD `baz3` TEXT AFTER `baz`; + +CREATE INDEX `bar_FK` ON `foo` (`bar1`); + +CREATE INDEX `baz_FK` ON `foo` (`baz3`); + +ALTER TABLE `foo` ADD CONSTRAINT `foo1_FK_1` + FOREIGN KEY (`bar1`) + REFERENCES `foo2` (`bar`); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTableColumnsDDL + */ + public function testGetModifyTableColumnsDDL($tableDiff) + { + $expected = " +ALTER TABLE `foo` CHANGE `bar` `bar1` INTEGER; + +ALTER TABLE `foo` CHANGE `baz` `baz` VARCHAR(12); + +ALTER TABLE `foo` + ADD `baz3` TEXT AFTER `baz`; +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableColumnsDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTablePrimaryKeysDDL + */ + public function testGetModifyTablePrimaryKeysDDL($tableDiff) + { + $expected = " +ALTER TABLE `foo` DROP PRIMARY KEY; + +ALTER TABLE `foo` ADD PRIMARY KEY (`id`,`bar`); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTablePrimaryKeyDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTableIndicesDDL + */ + public function testGetModifyTableIndicesDDL($tableDiff) + { + $expected = " +DROP INDEX `bar_FK` ON `foo`; + +CREATE INDEX `baz_FK` ON `foo` (`baz`); + +DROP INDEX `bar_baz_FK` ON `foo`; + +CREATE INDEX `bar_baz_FK` ON `foo` (`id`,`bar`,`baz`); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableIndicesDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTableForeignKeysDDL + */ + public function testGetModifyTableForeignKeysDDL($tableDiff) + { + $expected = " +ALTER TABLE `foo1` DROP FOREIGN KEY `foo1_FK_1`; + +ALTER TABLE `foo1` ADD CONSTRAINT `foo1_FK_5` + FOREIGN KEY (`baz`) + REFERENCES `foo2` (`baz`); + +ALTER TABLE `foo1` DROP FOREIGN KEY `foo1_FK_2`; + +ALTER TABLE `foo1` ADD CONSTRAINT `foo1_FK_2` + FOREIGN KEY (`bar`,`id`) + REFERENCES `foo2` (`bar`,`id`); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTableForeignKeysSkipSqlDDL + */ + public function testGetModifyTableForeignKeysSkipSqlDDL($tableDiff) + { + $expected = " +ALTER TABLE `foo1` DROP FOREIGN KEY `foo1_FK_1`; +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff)); + $expected = " +ALTER TABLE `foo1` ADD CONSTRAINT `foo1_FK_1` + FOREIGN KEY (`bar`) + REFERENCES `foo2` (`bar`); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff->getReverseDiff())); + } + + /** + * @dataProvider providerForTestGetModifyTableForeignKeysSkipSql2DDL + */ + public function testGetModifyTableForeignKeysSkipSql2DDL($tableDiff) + { + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff)); + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff->getReverseDiff())); + } + + /** + * @dataProvider providerForTestGetRemoveColumnDDL + */ + public function testGetRemoveColumnDDL($column) + { + $expected = " +ALTER TABLE `foo` DROP `bar`; +"; + $this->assertEquals($expected, $this->getPlatform()->getRemoveColumnDDL($column)); + } + + /** + * @dataProvider providerForTestGetRenameColumnDDL + */ + public function testGetRenameColumnDDL($fromColumn, $toColumn) + { + $expected = " +ALTER TABLE `foo` CHANGE `bar1` `bar2` DOUBLE(2); +"; + $this->assertEquals($expected, $this->getPlatform()->getRenameColumnDDL($fromColumn, $toColumn)); + } + + /** + * @dataProvider providerForTestGetModifyColumnDDL + */ + public function testGetModifyColumnDDL($columnDiff) + { + $expected = " +ALTER TABLE `foo` CHANGE `bar` `bar` DOUBLE(3); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyColumnDDL($columnDiff)); + } + + /** + * @dataProvider providerForTestGetModifyColumnsDDL + */ + public function testGetModifyColumnsDDL($columnDiffs) + { + $expected = " +ALTER TABLE `foo` CHANGE `bar1` `bar1` DOUBLE(3); + +ALTER TABLE `foo` CHANGE `bar2` `bar2` INTEGER NOT NULL; +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyColumnsDDL($columnDiffs)); + } + + /** + * @dataProvider providerForTestGetAddColumnDDL + */ + public function testGetAddColumnDDL($column) + { + $expected = " +ALTER TABLE `foo` ADD `bar` INTEGER; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddColumnDDL($column)); + } + + /** + * @dataProvider providerForTestGetAddColumnsDDL + */ + public function testGetAddColumnsDDL($columns) + { + $expected = " +ALTER TABLE `foo` + ADD `bar1` INTEGER AFTER `id`, + ADD `bar2` DOUBLE(3,2) DEFAULT -1 NOT NULL AFTER `bar1`; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddColumnsDDL($columns)); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/platform/MysqlPlatformMyISAMTest.php b/airtime_mvc/library/propel/test/testsuite/generator/platform/MysqlPlatformMyISAMTest.php new file mode 100644 index 000000000..947c4a2ac --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/platform/MysqlPlatformMyISAMTest.php @@ -0,0 +1,696 @@ +setBuildProperties(array( + 'propel.mysql.tableType' => 'MyISAM' + )); + $platform->setGeneratorConfig($config); + } + + return $platform; + } + + public function testGetSequenceNameDefault() + { + $table = new Table('foo'); + $table->setIdMethod(IDMethod::NATIVE); + $expected = 'foo_SEQ'; + $this->assertEquals($expected, $this->getPlatform()->getSequenceName($table)); + } + + public function testGetSequenceNameCustom() + { + $table = new Table('foo'); + $table->setIdMethod(IDMethod::NATIVE); + $idMethodParameter = new IdMethodParameter(); + $idMethodParameter->setValue('foo_sequence'); + $table->addIdMethodParameter($idMethodParameter); + $table->setIdMethod(IDMethod::NATIVE); + $expected = 'foo_sequence'; + $this->assertEquals($expected, $this->getPlatform()->getSequenceName($table)); + } + + /** + * @dataProvider providerForTestGetAddTablesDDLSchema + */ + public function testGetAddTablesDDLSchema($schema) + { + $database = $this->getDatabaseFromSchema($schema); + $expected = <<= 4.1.x +# It "suspends judgement" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +-- --------------------------------------------------------------------- +-- x.book +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `x`.`book`; + +CREATE TABLE `x`.`book` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `title` VARCHAR(255) NOT NULL, + `author_id` INTEGER, + PRIMARY KEY (`id`), + INDEX `book_I_1` (`title`), + INDEX `book_FI_1` (`author_id`) +) ENGINE=MyISAM; + +-- --------------------------------------------------------------------- +-- y.author +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `y`.`author`; + +CREATE TABLE `y`.`author` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `first_name` VARCHAR(100), + `last_name` VARCHAR(100), + PRIMARY KEY (`id`) +) ENGINE=MyISAM; + +-- --------------------------------------------------------------------- +-- x.book_summary +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `x`.`book_summary`; + +CREATE TABLE `x`.`book_summary` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `book_id` INTEGER NOT NULL, + `summary` TEXT NOT NULL, + PRIMARY KEY (`id`), + INDEX `book_summary_FI_1` (`book_id`) +) ENGINE=MyISAM; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; + +EOF; + $this->assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); + } + + /** + * @dataProvider providerForTestGetAddTablesDDL + */ + public function testGetAddTablesDDL($schema) + { + $database = $this->getDatabaseFromSchema($schema); + $expected = <<= 4.1.x +# It "suspends judgement" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +-- --------------------------------------------------------------------- +-- book +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `book`; + +CREATE TABLE `book` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `title` VARCHAR(255) NOT NULL, + `author_id` INTEGER, + PRIMARY KEY (`id`), + INDEX `book_I_1` (`title`), + INDEX `book_FI_1` (`author_id`) +) ENGINE=MyISAM; + +-- --------------------------------------------------------------------- +-- author +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `author`; + +CREATE TABLE `author` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `first_name` VARCHAR(100), + `last_name` VARCHAR(100), + PRIMARY KEY (`id`) +) ENGINE=MyISAM; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; + +EOF; + $this->assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); + } + + /** + * @dataProvider providerForTestGetAddTablesSkipSQLDDL + */ + public function testGetAddTablesSkipSQLDDL($schema) + { + $database = $this->getDatabaseFromSchema($schema); + $expected = " +# This is a fix for InnoDB in MySQL >= 4.1.x +# It \"suspends judgement\" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLSimplePK + */ + public function testGetAddTableDDLSimplePK($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE `foo` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `bar` VARCHAR(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM COMMENT='This is foo table'; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLCompositePK + */ + public function testGetAddTableDDLCompositePK($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE `foo` +( + `foo` INTEGER NOT NULL, + `bar` INTEGER NOT NULL, + `baz` VARCHAR(255) NOT NULL, + PRIMARY KEY (`foo`,`bar`) +) ENGINE=MyISAM; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLUniqueIndex + */ + public function testGetAddTableDDLUniqueIndex($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE `foo` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `bar` INTEGER, + PRIMARY KEY (`id`), + UNIQUE INDEX `foo_U_1` (`bar`) +) ENGINE=MyISAM; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + public function testGetAddTableDDLIndex() + { + $schema = << + + + + + + +
+ +EOF; + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE `foo` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `bar` INTEGER, + PRIMARY KEY (`id`), + INDEX `foo_I_1` (`bar`) +) ENGINE=MyISAM; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + public function testGetAddTableDDLForeignKey() + { + $schema = << + + + + + + +
+ + +
+ +EOF; + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE `foo` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `bar_id` INTEGER, + PRIMARY KEY (`id`), + INDEX `foo_FI_1` (`bar_id`) +) ENGINE=MyISAM; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + public function testGetAddTableDDLForeignKeySkipSql() + { + $schema = << + + + + + + +
+ + +
+ +EOF; + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE `foo` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `bar_id` INTEGER, + PRIMARY KEY (`id`), + INDEX `foo_FI_1` (`bar_id`) +) ENGINE=MyISAM; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + public function testGetAddTableDDLEngine() + { + $schema = << + + +
+ +EOF; + $platform = new MysqlPlatform(); + $platform->setTableEngineKeyword('TYPE'); + $platform->setDefaultTableEngine('MEMORY'); + $xtad = new XmlToAppData($platform); + $appData = $xtad->parseString($schema); + $table = $appData->getDatabase()->getTable('foo'); + $expected = " +CREATE TABLE `foo` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`) +) TYPE=MEMORY; +"; + $this->assertEquals($expected, $platform->getAddTableDDL($table)); + } + + public function testGetAddTableDDLVendor() + { + $schema = << + + + + + + + +
+ +EOF; + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE `foo` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1000 CHARACTER SET='utf8'; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLSchema + */ + public function testGetAddTableDDLSchema($schema) + { + $table = $this->getTableFromSchema($schema, 'Woopah.foo'); + $expected = " +CREATE TABLE `Woopah`.`foo` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `bar` INTEGER, + PRIMARY KEY (`id`) +) ENGINE=MyISAM; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + public function testGetDropTableDDL() + { + $table = new Table('foo'); + $expected = " +DROP TABLE IF EXISTS `foo`; +"; + $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLSchema + */ + public function testGetDropTableDDLSchema($schema) + { + $table = $this->getTableFromSchema($schema, 'Woopah.foo'); + $expected = " +DROP TABLE IF EXISTS `Woopah`.`foo`; +"; + $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); + } + + public function testGetColumnDDL() + { + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE')); + $column->getDomain()->replaceScale(2); + $column->getDomain()->replaceSize(3); + $column->setNotNull(true); + $column->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $expected = '`foo` DOUBLE(3,2) DEFAULT 123 NOT NULL'; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + } + + public function testGetColumnDDLCharsetVendor() + { + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('LONGVARCHAR')); + $vendor = new VendorInfo('mysql'); + $vendor->setParameter('Charset', 'greek'); + $column->addVendorInfo($vendor); + $expected = '`foo` TEXT CHARACTER SET \'greek\''; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + } + + public function testGetColumnDDLCharsetCollation() + { + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('LONGVARCHAR')); + $vendor = new VendorInfo('mysql'); + $vendor->setParameter('Collate', 'latin1_german2_ci'); + $column->addVendorInfo($vendor); + $expected = '`foo` TEXT COLLATE \'latin1_german2_ci\''; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('LONGVARCHAR')); + $vendor = new VendorInfo('mysql'); + $vendor->setParameter('Collation', 'latin1_german2_ci'); + $column->addVendorInfo($vendor); + $expected = '`foo` TEXT COLLATE \'latin1_german2_ci\''; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + } + + public function testGetColumnDDLComment() + { + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('INTEGER')); + $column->setDescription('This is column Foo'); + $expected = '`foo` INTEGER COMMENT \'This is column Foo\''; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + } + + public function testGetColumnDDLCharsetNotNull() + { + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('LONGVARCHAR')); + $column->setNotNull(true); + $vendor = new VendorInfo('mysql'); + $vendor->setParameter('Charset', 'greek'); + $column->addVendorInfo($vendor); + $expected = '`foo` TEXT CHARACTER SET \'greek\' NOT NULL'; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + } + + public function testGetColumnDDLCustomSqlType() + { + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE')); + $column->getDomain()->replaceScale(2); + $column->getDomain()->replaceSize(3); + $column->setNotNull(true); + $column->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $column->getDomain()->replaceSqlType('DECIMAL(5,6)'); + $expected = '`foo` DECIMAL(5,6) DEFAULT 123 NOT NULL'; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + } + + public function testGetPrimaryKeyDDLSimpleKey() + { + $table = new Table('foo'); + $column = new Column('bar'); + $column->setPrimaryKey(true); + $table->addColumn($column); + $expected = 'PRIMARY KEY (`bar`)'; + $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); + } + + public function testGetPrimaryKeyDDLCompositeKey() + { + $table = new Table('foo'); + $column1 = new Column('bar1'); + $column1->setPrimaryKey(true); + $table->addColumn($column1); + $column2 = new Column('bar2'); + $column2->setPrimaryKey(true); + $table->addColumn($column2); + $expected = 'PRIMARY KEY (`bar1`,`bar2`)'; + $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestPrimaryKeyDDL + */ + public function testGetDropPrimaryKeyDDL($table) + { + $expected = " +ALTER TABLE `foo` DROP PRIMARY KEY; +"; + $this->assertEquals($expected, $this->getPlatform()->getDropPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestPrimaryKeyDDL + */ + public function testGetAddPrimaryKeyDDL($table) + { + $expected = " +ALTER TABLE `foo` ADD PRIMARY KEY (`bar`); +"; + $this->assertEquals($expected, $this->getPlatform()->getAddPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestGetIndicesDDL + */ + public function testAddIndicesDDL($table) + { + $expected = " +CREATE INDEX `babar` ON `foo` (`bar1`,`bar2`); + +CREATE INDEX `foo_index` ON `foo` (`bar1`); +"; + $this->assertEquals($expected, $this->getPlatform()->getAddIndicesDDL($table)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testAddIndexDDL($index) + { + $expected = " +CREATE INDEX `babar` ON `foo` (`bar1`,`bar2`); +"; + $this->assertEquals($expected, $this->getPlatform()->getAddIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testDropIndexDDL($index) + { + $expected = " +DROP INDEX `babar` ON `foo`; +"; + $this->assertEquals($expected, $this->getPlatform()->getDropIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testGetIndexDDL($index) + { + $expected = 'INDEX `babar` (`bar1`, `bar2`)'; + $this->assertEquals($expected, $this->getPlatform()->getIndexDDL($index)); + } + + public function testGetIndexDDLKeySize() + { + $table = new Table('foo'); + $column1 = new Column('bar1'); + $column1->getDomain()->copy($this->getPlatform()->getDomainForType('VARCHAR')); + $column1->setSize(5); + $table->addColumn($column1); + $index = new Index('bar_index'); + $index->addColumn($column1); + $table->addIndex($index); + $expected = 'INDEX `bar_index` (`bar1`(5))'; + $this->assertEquals($expected, $this->getPlatform()->getIndexDDL($index)); + } + + public function testGetIndexDDLFulltext() + { + $table = new Table('foo'); + $column1 = new Column('bar1'); + $column1->getDomain()->copy($this->getPlatform()->getDomainForType('LONGVARCHAR')); + $table->addColumn($column1); + $index = new Index('bar_index'); + $index->addColumn($column1); + $vendor = new VendorInfo('mysql'); + $vendor->setParameter('Index_type', 'FULLTEXT'); + $index->addVendorInfo($vendor); + $table->addIndex($index); + $expected = 'FULLTEXT INDEX `bar_index` (`bar1`)'; + $this->assertEquals($expected, $this->getPlatform()->getIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetUniqueDDL + */ + public function testGetUniqueDDL($index) + { + $expected = 'UNIQUE INDEX `babar` (`bar1`, `bar2`)'; + $this->assertEquals($expected, $this->getPlatform()->getUniqueDDL($index)); + } + + /** + * @dataProvider providerForTestGetForeignKeysDDL + */ + public function testGetAddForeignKeysDDL($table) + { + $expected = ""; + $this->assertEquals($expected, $this->getPlatform()->getAddForeignKeysDDL($table)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetAddForeignKeyDDL($fk) + { + $expected = ""; + $this->assertEquals($expected, $this->getPlatform()->getAddForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeySkipSqlDDL + */ + public function testGetAddForeignKeySkipSqlDDL($fk) + { + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getAddForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetDropForeignKeyDDL($fk) + { + $expected = ""; + $this->assertEquals($expected, $this->getPlatform()->getDropForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeySkipSqlDDL + */ + public function testGetDropForeignKeySkipSqlDDL($fk) + { + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getDropForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetForeignKeyDDL($fk) + { + $expected = ""; + $this->assertEquals($expected, $this->getPlatform()->getForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeySkipSqlDDL + */ + public function testGetForeignKeySkipSqlDDL($fk) + { + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getForeignKeyDDL($fk)); + } + + public function testGetCommentBlockDDL() + { + $expected = " +-- --------------------------------------------------------------------- +-- foo bar +-- --------------------------------------------------------------------- +"; + $this->assertEquals($expected, $this->getPlatform()->getCommentBlockDDL('foo bar')); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/platform/MysqlPlatformTest.php b/airtime_mvc/library/propel/test/testsuite/generator/platform/MysqlPlatformTest.php new file mode 100644 index 000000000..07ac741d3 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/platform/MysqlPlatformTest.php @@ -0,0 +1,756 @@ +setBuildProperties(array( + 'propel.mysql.tableType' => 'InnoDB' + )); + $platform->setGeneratorConfig($config); + } + + return $platform; + } + + public function testGetSequenceNameDefault() + { + $table = new Table('foo'); + $table->setIdMethod(IDMethod::NATIVE); + $expected = 'foo_SEQ'; + $this->assertEquals($expected, $this->getPlatform()->getSequenceName($table)); + } + + public function testGetSequenceNameCustom() + { + $table = new Table('foo'); + $table->setIdMethod(IDMethod::NATIVE); + $idMethodParameter = new IdMethodParameter(); + $idMethodParameter->setValue('foo_sequence'); + $table->addIdMethodParameter($idMethodParameter); + $table->setIdMethod(IDMethod::NATIVE); + $expected = 'foo_sequence'; + $this->assertEquals($expected, $this->getPlatform()->getSequenceName($table)); + } + + /** + * @dataProvider providerForTestGetAddTablesDDLSchema + */ + public function testGetAddTablesDDLSchema($schema) + { + $database = $this->getDatabaseFromSchema($schema); + $expected = <<= 4.1.x +# It "suspends judgement" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +-- --------------------------------------------------------------------- +-- x.book +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `x`.`book`; + +CREATE TABLE `x`.`book` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `title` VARCHAR(255) NOT NULL, + `author_id` INTEGER, + PRIMARY KEY (`id`), + INDEX `book_I_1` (`title`), + INDEX `book_FI_1` (`author_id`), + CONSTRAINT `book_FK_1` + FOREIGN KEY (`author_id`) + REFERENCES `y`.`author` (`id`) +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- y.author +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `y`.`author`; + +CREATE TABLE `y`.`author` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `first_name` VARCHAR(100), + `last_name` VARCHAR(100), + PRIMARY KEY (`id`) +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- x.book_summary +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `x`.`book_summary`; + +CREATE TABLE `x`.`book_summary` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `book_id` INTEGER NOT NULL, + `summary` TEXT NOT NULL, + PRIMARY KEY (`id`), + INDEX `book_summary_FI_1` (`book_id`), + CONSTRAINT `book_summary_FK_1` + FOREIGN KEY (`book_id`) + REFERENCES `x`.`book` (`id`) + ON DELETE CASCADE +) ENGINE=InnoDB; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; + +EOF; + $this->assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); + } + + /** + * @dataProvider providerForTestGetAddTablesDDL + */ + public function testGetAddTablesDDL($schema) + { + $database = $this->getDatabaseFromSchema($schema); + $expected = <<= 4.1.x +# It "suspends judgement" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +-- --------------------------------------------------------------------- +-- book +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `book`; + +CREATE TABLE `book` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `title` VARCHAR(255) NOT NULL, + `author_id` INTEGER, + PRIMARY KEY (`id`), + INDEX `book_I_1` (`title`), + INDEX `book_FI_1` (`author_id`), + CONSTRAINT `book_FK_1` + FOREIGN KEY (`author_id`) + REFERENCES `author` (`id`) +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- author +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `author`; + +CREATE TABLE `author` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `first_name` VARCHAR(100), + `last_name` VARCHAR(100), + PRIMARY KEY (`id`) +) ENGINE=InnoDB; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; + +EOF; + $this->assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); + } + + /** + * @dataProvider providerForTestGetAddTablesSkipSQLDDL + */ + public function testGetAddTablesSkipSQLDDL($schema) + { + $database = $this->getDatabaseFromSchema($schema); + $expected = " +# This is a fix for InnoDB in MySQL >= 4.1.x +# It \"suspends judgement\" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLSimplePK + */ + public function testGetAddTableDDLSimplePK($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE `foo` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `bar` VARCHAR(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB COMMENT='This is foo table'; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + + public function testGetAddTableDDLComplexPK() + { + $schema = << + + + + + +
+ +EOF; + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE `foo` +( + `id` INTEGER NOT NULL, + `second_id` INTEGER NOT NULL AUTO_INCREMENT, + `third_id` INTEGER NOT NULL, + `bar` VARCHAR(255), + PRIMARY KEY (`second_id`,`id`,`third_id`) +) ENGINE=InnoDB; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLCompositePK + */ + public function testGetAddTableDDLCompositePK($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE `foo` +( + `foo` INTEGER NOT NULL, + `bar` INTEGER NOT NULL, + `baz` VARCHAR(255) NOT NULL, + PRIMARY KEY (`foo`,`bar`) +) ENGINE=InnoDB; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLUniqueIndex + */ + public function testGetAddTableDDLUniqueIndex($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE `foo` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `bar` INTEGER, + PRIMARY KEY (`id`), + UNIQUE INDEX `foo_U_1` (`bar`) +) ENGINE=InnoDB; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + public function testGetAddTableDDLIndex() + { + $schema = << + + + + + + +
+ +EOF; + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE `foo` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `bar` INTEGER, + PRIMARY KEY (`id`), + INDEX `foo_I_1` (`bar`) +) ENGINE=InnoDB; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + public function testGetAddTableDDLForeignKey() + { + $schema = << + + + + + + +
+ + +
+ +EOF; + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE `foo` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `bar_id` INTEGER, + PRIMARY KEY (`id`), + INDEX `foo_FI_1` (`bar_id`), + CONSTRAINT `foo_FK_1` + FOREIGN KEY (`bar_id`) + REFERENCES `bar` (`id`) +) ENGINE=InnoDB; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + public function testGetAddTableDDLForeignKeySkipSql() + { + $schema = << + + + + + + +
+ + +
+ +EOF; + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE `foo` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `bar_id` INTEGER, + PRIMARY KEY (`id`), + INDEX `foo_FI_1` (`bar_id`) +) ENGINE=InnoDB; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + public function testGetAddTableDDLEngine() + { + $schema = << + + +
+ +EOF; + $platform = new MysqlPlatform(); + $platform->setTableEngineKeyword('TYPE'); + $platform->setDefaultTableEngine('MEMORY'); + $xtad = new XmlToAppData($platform); + $appData = $xtad->parseString($schema); + $table = $appData->getDatabase()->getTable('foo'); + $expected = " +CREATE TABLE `foo` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`) +) TYPE=MEMORY; +"; + $this->assertEquals($expected, $platform->getAddTableDDL($table)); + } + + public function testGetAddTableDDLVendor() + { + $schema = << + + + + + + + +
+ +EOF; + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE `foo` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1000 CHARACTER SET='utf8'; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLSchema + */ + public function testGetAddTableDDLSchema($schema) + { + $table = $this->getTableFromSchema($schema, 'Woopah.foo'); + $expected = " +CREATE TABLE `Woopah`.`foo` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `bar` INTEGER, + PRIMARY KEY (`id`) +) ENGINE=InnoDB; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + public function testGetDropTableDDL() + { + $table = new Table('foo'); + $expected = " +DROP TABLE IF EXISTS `foo`; +"; + $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLSchema + */ + public function testGetDropTableDDLSchema($schema) + { + $table = $this->getTableFromSchema($schema, 'Woopah.foo'); + $expected = " +DROP TABLE IF EXISTS `Woopah`.`foo`; +"; + $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); + } + + public function testGetColumnDDL() + { + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE')); + $column->getDomain()->replaceScale(2); + $column->getDomain()->replaceSize(3); + $column->setNotNull(true); + $column->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $expected = '`foo` DOUBLE(3,2) DEFAULT 123 NOT NULL'; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + } + + public function testGetColumnDDLCharsetVendor() + { + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('LONGVARCHAR')); + $vendor = new VendorInfo('mysql'); + $vendor->setParameter('Charset', 'greek'); + $column->addVendorInfo($vendor); + $expected = '`foo` TEXT CHARACTER SET \'greek\''; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + } + + public function testGetColumnDDLCharsetCollation() + { + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('LONGVARCHAR')); + $vendor = new VendorInfo('mysql'); + $vendor->setParameter('Collate', 'latin1_german2_ci'); + $column->addVendorInfo($vendor); + $expected = '`foo` TEXT COLLATE \'latin1_german2_ci\''; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('LONGVARCHAR')); + $vendor = new VendorInfo('mysql'); + $vendor->setParameter('Collation', 'latin1_german2_ci'); + $column->addVendorInfo($vendor); + $expected = '`foo` TEXT COLLATE \'latin1_german2_ci\''; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + } + + public function testGetColumnDDLComment() + { + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('INTEGER')); + $column->setDescription('This is column Foo'); + $expected = '`foo` INTEGER COMMENT \'This is column Foo\''; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + } + + public function testGetColumnDDLCharsetNotNull() + { + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('LONGVARCHAR')); + $column->setNotNull(true); + $vendor = new VendorInfo('mysql'); + $vendor->setParameter('Charset', 'greek'); + $column->addVendorInfo($vendor); + $expected = '`foo` TEXT CHARACTER SET \'greek\' NOT NULL'; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + } + + public function testGetColumnDDLCustomSqlType() + { + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE')); + $column->getDomain()->replaceScale(2); + $column->getDomain()->replaceSize(3); + $column->setNotNull(true); + $column->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $column->getDomain()->replaceSqlType('DECIMAL(5,6)'); + $expected = '`foo` DECIMAL(5,6) DEFAULT 123 NOT NULL'; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + } + + public function testGetPrimaryKeyDDLSimpleKey() + { + $table = new Table('foo'); + $column = new Column('bar'); + $column->setPrimaryKey(true); + $table->addColumn($column); + $expected = 'PRIMARY KEY (`bar`)'; + $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); + } + + public function testGetPrimaryKeyDDLCompositeKey() + { + $table = new Table('foo'); + $column1 = new Column('bar1'); + $column1->setPrimaryKey(true); + $table->addColumn($column1); + $column2 = new Column('bar2'); + $column2->setPrimaryKey(true); + $table->addColumn($column2); + $expected = 'PRIMARY KEY (`bar1`,`bar2`)'; + $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestPrimaryKeyDDL + */ + public function testGetDropPrimaryKeyDDL($table) + { + $expected = " +ALTER TABLE `foo` DROP PRIMARY KEY; +"; + $this->assertEquals($expected, $this->getPlatform()->getDropPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestPrimaryKeyDDL + */ + public function testGetAddPrimaryKeyDDL($table) + { + $expected = " +ALTER TABLE `foo` ADD PRIMARY KEY (`bar`); +"; + $this->assertEquals($expected, $this->getPlatform()->getAddPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestGetIndicesDDL + */ + public function testAddIndicesDDL($table) + { + $expected = " +CREATE INDEX `babar` ON `foo` (`bar1`,`bar2`); + +CREATE INDEX `foo_index` ON `foo` (`bar1`); +"; + $this->assertEquals($expected, $this->getPLatform()->getAddIndicesDDL($table)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testAddIndexDDL($index) + { + $expected = " +CREATE INDEX `babar` ON `foo` (`bar1`,`bar2`); +"; + $this->assertEquals($expected, $this->getPLatform()->getAddIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testDropIndexDDL($index) + { + $expected = " +DROP INDEX `babar` ON `foo`; +"; + $this->assertEquals($expected, $this->getPLatform()->getDropIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testGetIndexDDL($index) + { + $expected = 'INDEX `babar` (`bar1`, `bar2`)'; + $this->assertEquals($expected, $this->getPLatform()->getIndexDDL($index)); + } + + public function testGetIndexDDLKeySize() + { + $table = new Table('foo'); + $column1 = new Column('bar1'); + $column1->getDomain()->copy($this->getPlatform()->getDomainForType('VARCHAR')); + $column1->setSize(5); + $table->addColumn($column1); + $index = new Index('bar_index'); + $index->addColumn($column1); + $table->addIndex($index); + $expected = 'INDEX `bar_index` (`bar1`(5))'; + $this->assertEquals($expected, $this->getPLatform()->getIndexDDL($index)); + } + + public function testGetIndexDDLFulltext() + { + $table = new Table('foo'); + $column1 = new Column('bar1'); + $column1->getDomain()->copy($this->getPlatform()->getDomainForType('LONGVARCHAR')); + $table->addColumn($column1); + $index = new Index('bar_index'); + $index->addColumn($column1); + $vendor = new VendorInfo('mysql'); + $vendor->setParameter('Index_type', 'FULLTEXT'); + $index->addVendorInfo($vendor); + $table->addIndex($index); + $expected = 'FULLTEXT INDEX `bar_index` (`bar1`)'; + $this->assertEquals($expected, $this->getPLatform()->getIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetUniqueDDL + */ + public function testGetUniqueDDL($index) + { + $expected = 'UNIQUE INDEX `babar` (`bar1`, `bar2`)'; + $this->assertEquals($expected, $this->getPLatform()->getUniqueDDL($index)); + } + + /** + * @dataProvider providerForTestGetForeignKeysDDL + */ + public function testGetAddForeignKeysDDL($table) + { + $expected = " +ALTER TABLE `foo` ADD CONSTRAINT `foo_bar_FK` + FOREIGN KEY (`bar_id`) + REFERENCES `bar` (`id`) + ON DELETE CASCADE; + +ALTER TABLE `foo` ADD CONSTRAINT `foo_baz_FK` + FOREIGN KEY (`baz_id`) + REFERENCES `baz` (`id`) + ON DELETE SET NULL; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddForeignKeysDDL($table)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetAddForeignKeyDDL($fk) + { + $expected = " +ALTER TABLE `foo` ADD CONSTRAINT `foo_bar_FK` + FOREIGN KEY (`bar_id`) + REFERENCES `bar` (`id`) + ON DELETE CASCADE; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeySkipSqlDDL + */ + public function testGetAddForeignKeySkipSqlDDL($fk) + { + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getAddForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetDropForeignKeyDDL($fk) + { + $expected = " +ALTER TABLE `foo` DROP FOREIGN KEY `foo_bar_FK`; +"; + $this->assertEquals($expected, $this->getPLatform()->getDropForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeySkipSqlDDL + */ + public function testGetDropForeignKeySkipSqlDDL($fk) + { + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getDropForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetForeignKeyDDL($fk) + { + $expected = "CONSTRAINT `foo_bar_FK` + FOREIGN KEY (`bar_id`) + REFERENCES `bar` (`id`) + ON DELETE CASCADE"; + $this->assertEquals($expected, $this->getPLatform()->getForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeySkipSqlDDL + */ + public function testGetForeignKeySkipSqlDDL($fk) + { + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getForeignKeyDDL($fk)); + } + + public function testGetCommentBlockDDL() + { + $expected = " +-- --------------------------------------------------------------------- +-- foo bar +-- --------------------------------------------------------------------- +"; + $this->assertEquals($expected, $this->getPLatform()->getCommentBlockDDL('foo bar')); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/platform/OraclePlatformMigrationTest.php b/airtime_mvc/library/propel/test/testsuite/generator/platform/OraclePlatformMigrationTest.php new file mode 100644 index 000000000..d744a2537 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/platform/OraclePlatformMigrationTest.php @@ -0,0 +1,454 @@ +assertEquals($expected, $this->getPlatform()->getModifyDatabaseDDL($databaseDiff)); + } + + /** + * @dataProvider providerForTestGetRenameTableDDL + */ + public function testGetRenameTableDDL($fromName, $toName) + { + $expected = " +ALTER TABLE foo1 RENAME TO foo2; +"; + $this->assertEquals($expected, $this->getPlatform()->getRenameTableDDL($fromName, $toName)); + } + + /** + * @dataProvider providerForTestGetModifyTableDDL + */ + public function testGetModifyTableDDL($tableDiff) + { + $expected = " +ALTER TABLE foo DROP CONSTRAINT foo1_FK_2; + +ALTER TABLE foo DROP CONSTRAINT foo1_FK_1; + +DROP INDEX bar_baz_FK; + +DROP INDEX bar_FK; + +ALTER TABLE foo RENAME COLUMN bar TO bar1; + +ALTER TABLE foo MODIFY +( + baz NVARCHAR2(12) +); + +ALTER TABLE foo ADD +( + baz3 NVARCHAR2(2000) +); + +CREATE INDEX bar_FK ON foo (bar1); + +CREATE INDEX baz_FK ON foo (baz3); + +ALTER TABLE foo ADD CONSTRAINT foo1_FK_1 + FOREIGN KEY (bar1) REFERENCES foo2 (bar); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTableColumnsDDL + */ + public function testGetModifyTableColumnsDDL($tableDiff) + { + $expected = " +ALTER TABLE foo RENAME COLUMN bar TO bar1; + +ALTER TABLE foo MODIFY +( + baz NVARCHAR2(12) +); + +ALTER TABLE foo ADD +( + baz3 NVARCHAR2(2000) +); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableColumnsDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTablePrimaryKeysDDL + */ + public function testGetModifyTablePrimaryKeysDDL($tableDiff) + { + $expected = " +ALTER TABLE foo DROP CONSTRAINT foo_PK; + +ALTER TABLE foo ADD CONSTRAINT foo_PK PRIMARY KEY (id,bar); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTablePrimaryKeyDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTableIndicesDDL + */ + public function testGetModifyTableIndicesDDL($tableDiff) + { + $expected = " +DROP INDEX bar_FK; + +CREATE INDEX baz_FK ON foo (baz); + +DROP INDEX bar_baz_FK; + +CREATE INDEX bar_baz_FK ON foo (id,bar,baz); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableIndicesDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTableForeignKeysDDL + */ + public function testGetModifyTableForeignKeysDDL($tableDiff) + { + $expected = " +ALTER TABLE foo1 DROP CONSTRAINT foo1_FK_1; + +ALTER TABLE foo1 ADD CONSTRAINT foo1_FK_5 + FOREIGN KEY (baz) REFERENCES foo2 (baz); + +ALTER TABLE foo1 DROP CONSTRAINT foo1_FK_2; + +ALTER TABLE foo1 ADD CONSTRAINT foo1_FK_2 + FOREIGN KEY (bar,id) REFERENCES foo2 (bar,id); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTableForeignKeysSkipSqlDDL + */ + public function testGetModifyTableForeignKeysSkipSqlDDL($tableDiff) + { + $expected = " +ALTER TABLE foo1 DROP CONSTRAINT foo1_FK_1; +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff)); + $expected = " +ALTER TABLE foo1 ADD CONSTRAINT foo1_FK_1 + FOREIGN KEY (bar) REFERENCES foo2 (bar); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff->getReverseDiff())); + } + + /** + * @dataProvider providerForTestGetModifyTableForeignKeysSkipSql2DDL + */ + public function testGetModifyTableForeignKeysSkipSql2DDL($tableDiff) + { + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff)); + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff->getReverseDiff())); + } + + /** + * @dataProvider providerForTestGetRemoveColumnDDL + */ + public function testGetRemoveColumnDDL($column) + { + $expected = " +ALTER TABLE foo DROP COLUMN bar; +"; + $this->assertEquals($expected, $this->getPlatform()->getRemoveColumnDDL($column)); + } + + /** + * @dataProvider providerForTestGetRenameColumnDDL + */ + public function testGetRenameColumnDDL($fromColumn, $toColumn) + { + $expected = " +ALTER TABLE foo RENAME COLUMN bar1 TO bar2; +"; + $this->assertEquals($expected, $this->getPlatform()->getRenameColumnDDL($fromColumn, $toColumn)); + } + + /** + * @dataProvider providerForTestGetModifyColumnDDL + */ + public function testGetModifyColumnDDL($columnDiff) + { + $expected = " +ALTER TABLE foo MODIFY bar FLOAT(3); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyColumnDDL($columnDiff)); + } + + /** + * @dataProvider providerForTestGetModifyColumnsDDL + */ + public function testGetModifyColumnsDDL($columnDiffs) + { + $expected = " +ALTER TABLE foo MODIFY +( + bar1 FLOAT(3), + bar2 INTEGER NOT NULL +); +"; + $this->assertEquals($expected, $this->getPlatform()->getModifyColumnsDDL($columnDiffs)); + } + + /** + * @dataProvider providerForTestGetAddColumnDDL + */ + public function testGetAddColumnDDL($column) + { + $expected = " +ALTER TABLE foo ADD bar NUMBER; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddColumnDDL($column)); + } + + /** + * @dataProvider providerForTestGetAddColumnsDDL + */ + public function testGetAddColumnsDDL($columns) + { + $expected = " +ALTER TABLE foo ADD +( + bar1 NUMBER, + bar2 FLOAT(3,2) DEFAULT -1 NOT NULL +); +"; + $this->assertEquals($expected, $this->getPlatform()->getAddColumnsDDL($columns)); + } + + public function testGetModifyDatabaseWithBlockStorageDDL() + { + $schema1 = << + + + +
+ + + + +
+ + + +
+ +EOF; + $schema2 = << + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +EOF; + $d1 = $this->getDatabaseFromSchema($schema1); + $d2 = $this->getDatabaseFromSchema($schema2); + $databaseDiff = PropelDatabaseComparator::computeDiff($d1, $d2); + $expected = " +ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'; +ALTER SESSION SET NLS_TIMESTAMP_FORMAT='YYYY-MM-DD HH24:MI:SS'; + +DROP TABLE foo1 CASCADE CONSTRAINTS; + +DROP SEQUENCE foo1_SEQ; + +ALTER TABLE foo3 RENAME TO foo4; + +CREATE TABLE foo5 +( + id NUMBER NOT NULL, + lkdjfsh NUMBER, + dfgdsgf CLOB +) +PCTFREE 20 +INITRANS 4 +STORAGE +( + MINEXTENTS 1 + MAXEXTENTS 99 + PCTINCREASE 0 +) +TABLESPACE L_128K; + +ALTER TABLE foo5 ADD CONSTRAINT foo5_PK PRIMARY KEY (id) +USING INDEX +PCTFREE 20 +INITRANS 4 +STORAGE +( + MINEXTENTS 1 + MAXEXTENTS 99 + PCTINCREASE 0 +) +TABLESPACE IL_128K; + +CREATE SEQUENCE foo5_SEQ + INCREMENT BY 1 START WITH 1 NOMAXVALUE NOCYCLE NOCACHE ORDER; + +CREATE INDEX lkdjfsh_IDX ON foo5 (lkdjfsh) +PCTFREE 20 +INITRANS 4 +STORAGE +( + MINEXTENTS 1 + MAXEXTENTS 99 + PCTINCREASE 0 +) +TABLESPACE L_128K; + +ALTER TABLE foo2 RENAME COLUMN bar TO bar1; + +ALTER TABLE foo2 MODIFY +( + baz NVARCHAR2(12) +); + +ALTER TABLE foo2 ADD +( + baz3 CLOB +); +"; + // ignore tab/space indentation comparison + $this->assertEquals($expected, str_replace("\t", ' ', $this->getPlatform()->getModifyDatabaseDDL($databaseDiff))); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/platform/OraclePlatformTest.php b/airtime_mvc/library/propel/test/testsuite/generator/platform/OraclePlatformTest.php new file mode 100644 index 000000000..21dbfd6e7 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/platform/OraclePlatformTest.php @@ -0,0 +1,589 @@ +setIdMethod(IDMethod::NATIVE); + $expected = 'foo_SEQ'; + $this->assertEquals($expected, $this->getPlatform()->getSequenceName($table)); + } + + public function testGetSequenceNameCustom() + { + $table = new Table('foo'); + $table->setIdMethod(IDMethod::NATIVE); + $idMethodParameter = new IdMethodParameter(); + $idMethodParameter->setValue('foo_sequence'); + $table->addIdMethodParameter($idMethodParameter); + $table->setIdMethod(IDMethod::NATIVE); + $expected = 'foo_sequence'; + $this->assertEquals($expected, $this->getPlatform()->getSequenceName($table)); + } + + /** + * @dataProvider providerForTestGetAddTablesDDL + */ + public function testGetAddTablesDDL($schema) + { + $database = $this->getDatabaseFromSchema($schema); + $expected = <<assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); + } + + /** + * @dataProvider providerForTestGetAddTablesSkipSQLDDL + */ + public function testGetAddTablesSkipSQLDDL($schema) + { + $database = $this->getDatabaseFromSchema($schema); + $expected = " +ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'; +ALTER SESSION SET NLS_TIMESTAMP_FORMAT='YYYY-MM-DD HH24:MI:SS'; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLSimplePK + */ + public function testGetAddTableDDLSimplePK($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = " +-- This is foo table +CREATE TABLE foo +( + id NUMBER NOT NULL, + bar NVARCHAR2(255) NOT NULL +); + +ALTER TABLE foo ADD CONSTRAINT foo_PK PRIMARY KEY (id); + +CREATE SEQUENCE foo_SEQ + INCREMENT BY 1 START WITH 1 NOMAXVALUE NOCYCLE NOCACHE ORDER; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLCompositePK + */ + public function testGetAddTableDDLCompositePK($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE foo +( + foo NUMBER NOT NULL, + bar NUMBER NOT NULL, + baz NVARCHAR2(255) NOT NULL +); + +ALTER TABLE foo ADD CONSTRAINT foo_PK PRIMARY KEY (foo,bar); +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLUniqueIndex + */ + public function testGetAddTableDDLUniqueIndex($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE foo +( + id NUMBER NOT NULL, + bar NUMBER, + CONSTRAINT foo_U_1 UNIQUE (bar) +); + +ALTER TABLE foo ADD CONSTRAINT foo_PK PRIMARY KEY (id); + +CREATE SEQUENCE foo_SEQ + INCREMENT BY 1 START WITH 1 NOMAXVALUE NOCYCLE NOCACHE ORDER; +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + public function testGetDropTableDDL() + { + $table = new Table('foo'); + $expected = " +DROP TABLE foo CASCADE CONSTRAINTS; +"; + $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); + } + + public function testGetDropTableWithSequenceDDL() + { + $table = new Table('foo'); + $idMethodParameter = new IdMethodParameter(); + $idMethodParameter->setValue('foo_sequence'); + $table->addIdMethodParameter($idMethodParameter); + $table->setIdMethod(IDMethod::NATIVE); + $expected = " +DROP TABLE foo CASCADE CONSTRAINTS; + +DROP SEQUENCE foo_sequence; +"; + $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); + } + + public function testGetColumnDDLCustomSqlType() + { + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE')); + $column->getDomain()->replaceScale(2); + $column->getDomain()->replaceSize(3); + $column->setNotNull(true); + $column->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $column->getDomain()->replaceSqlType('DECIMAL(5,6)'); + $expected = 'foo DECIMAL(5,6) DEFAULT 123 NOT NULL'; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + } + + /** + * @dataProvider providerForTestPrimaryKeyDDL + */ + public function testGetPrimaryKeyDDLSimpleKey($table) + { + $expected ='CONSTRAINT foo_PK PRIMARY KEY (bar)'; + $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); + } + + public function testGetPrimaryKeyDDLLongTableName() + { + $table = new Table('this_table_has_a_very_long_name'); + $column = new Column('bar'); + $column->setPrimaryKey(true); + $table->addColumn($column); + $expected = 'CONSTRAINT this_table_has_a_very_long__PK PRIMARY KEY (bar)'; + $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); + } + + public function testGetPrimaryKeyDDLCompositeKey() + { + $table = new Table('foo'); + $column1 = new Column('bar1'); + $column1->setPrimaryKey(true); + $table->addColumn($column1); + $column2 = new Column('bar2'); + $column2->setPrimaryKey(true); + $table->addColumn($column2); + $expected = 'CONSTRAINT foo_PK PRIMARY KEY (bar1,bar2)'; + $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestPrimaryKeyDDL + */ + public function testGetDropPrimaryKeyDDL($table) + { + $expected = " +ALTER TABLE foo DROP CONSTRAINT foo_PK; +"; + $this->assertEquals($expected, $this->getPlatform()->getDropPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestPrimaryKeyDDL + */ + public function testGetAddPrimaryKeyDDL($table) + { + $expected = " +ALTER TABLE foo ADD CONSTRAINT foo_PK PRIMARY KEY (bar); +"; + $this->assertEquals($expected, $this->getPlatform()->getAddPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestGetIndicesDDL + */ + public function testAddIndicesDDL($table) + { + $expected = " +CREATE INDEX babar ON foo (bar1,bar2); + +CREATE INDEX foo_index ON foo (bar1); +"; + $this->assertEquals($expected, $this->getPLatform()->getAddIndicesDDL($table)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testAddIndexDDL($index) + { + $expected = " +CREATE INDEX babar ON foo (bar1,bar2); +"; + $this->assertEquals($expected, $this->getPLatform()->getAddIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testDropIndexDDL($index) + { + $expected = " +DROP INDEX babar; +"; + $this->assertEquals($expected, $this->getPLatform()->getDropIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testGetIndexDDL($index) + { + $expected = 'INDEX babar (bar1,bar2)'; + $this->assertEquals($expected, $this->getPLatform()->getIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetUniqueDDL + */ + public function testGetUniqueDDL($index) + { + $expected = 'CONSTRAINT babar UNIQUE (bar1,bar2)'; + $this->assertEquals($expected, $this->getPlatform()->getUniqueDDL($index)); + } + + /** + * @dataProvider providerForTestGetForeignKeysDDL + */ + public function testGetAddForeignKeysDDL($table) + { + $expected = " +ALTER TABLE foo ADD CONSTRAINT foo_bar_FK + FOREIGN KEY (bar_id) REFERENCES bar (id) + ON DELETE CASCADE; + +ALTER TABLE foo ADD CONSTRAINT foo_baz_FK + FOREIGN KEY (baz_id) REFERENCES baz (id) + ON DELETE SET NULL; +"; + $this->assertEquals($expected, $this->getPLatform()->getAddForeignKeysDDL($table)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetAddForeignKeyDDL($fk) + { + $expected = " +ALTER TABLE foo ADD CONSTRAINT foo_bar_FK + FOREIGN KEY (bar_id) REFERENCES bar (id) + ON DELETE CASCADE; +"; + $this->assertEquals($expected, $this->getPLatform()->getAddForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeySkipSqlDDL + */ + public function testGetAddForeignKeySkipSqlDDL($fk) + { + $expected = ''; + $this->assertEquals($expected, $this->getPLatform()->getAddForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetDropForeignKeyDDL($fk) + { + $expected = " +ALTER TABLE foo DROP CONSTRAINT foo_bar_FK; +"; + $this->assertEquals($expected, $this->getPLatform()->getDropForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeySkipSqlDDL + */ + public function testGetDropForeignKeySkipSqlDDL($fk) + { + $expected = ''; + $this->assertEquals($expected, $this->getPLatform()->getDropForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetForeignKeyDDL($fk) + { + $expected = "CONSTRAINT foo_bar_FK + FOREIGN KEY (bar_id) REFERENCES bar (id) + ON DELETE CASCADE"; + $this->assertEquals($expected, $this->getPLatform()->getForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeySkipSqlDDL + */ + public function testGetForeignKeySkipSqlDDL($fk) + { + $expected = ''; + $this->assertEquals($expected, $this->getPLatform()->getForeignKeyDDL($fk)); + } + + public function testGetCommentBlockDDL() + { + $expected = " +----------------------------------------------------------------------- +-- foo bar +----------------------------------------------------------------------- +"; + $this->assertEquals($expected, $this->getPLatform()->getCommentBlockDDL('foo bar')); + } + + public function testGetOracleBlockStorageDDL() + { + $schema = << + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ +EOF; + $database = $this->getDatabaseFromSchema($schema); + $expected = <<assertEquals($expected, str_replace("\t", ' ', $this->getPlatform()->getAddTablesDDL($database))); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/platform/PgsqlPlatformMigrationTest.php b/airtime_mvc/library/propel/test/testsuite/generator/platform/PgsqlPlatformMigrationTest.php new file mode 100644 index 000000000..b88b69356 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/platform/PgsqlPlatformMigrationTest.php @@ -0,0 +1,394 @@ +assertEquals($expected, $this->getPlatform()->getModifyDatabaseDDL($databaseDiff)); + } + + /** + * @dataProvider providerForTestGetRenameTableDDL + */ + public function testGetRenameTableDDL($fromName, $toName) + { + $expected = ' +ALTER TABLE "foo1" RENAME TO "foo2"; +'; + $this->assertEquals($expected, $this->getPlatform()->getRenameTableDDL($fromName, $toName)); + } + + /** + * @dataProvider providerForTestGetModifyTableDDL + */ + public function testGetModifyTableDDL($tableDiff) + { + $expected = <<assertEquals($expected, $this->getPlatform()->getModifyTableDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTableColumnsDDL + */ + public function testGetModifyTableColumnsDDL($tableDiff) + { + $expected = <<assertEquals($expected, $this->getPlatform()->getModifyTableColumnsDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTablePrimaryKeysDDL + */ + public function testGetModifyTablePrimaryKeysDDL($tableDiff) + { + $expected = <<assertEquals($expected, $this->getPlatform()->getModifyTablePrimaryKeyDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTableIndicesDDL + */ + public function testGetModifyTableIndicesDDL($tableDiff) + { + $expected = <<assertEquals($expected, $this->getPlatform()->getModifyTableIndicesDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTableForeignKeysDDL + */ + public function testGetModifyTableForeignKeysDDL($tableDiff) + { + $expected = <<assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff)); + } + + /** + * @dataProvider providerForTestGetModifyTableForeignKeysSkipSqlDDL + */ + public function testGetModifyTableForeignKeysSkipSqlDDL($tableDiff) + { + $expected = <<assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff)); + $expected = <<assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff->getReverseDiff())); + } + + /** + * @dataProvider providerForTestGetModifyTableForeignKeysSkipSql2DDL + */ + public function testGetModifyTableForeignKeysSkipSql2DDL($tableDiff) + { + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff)); + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getModifyTableForeignKeysDDL($tableDiff->getReverseDiff())); + } + + /** + * @dataProvider providerForTestGetRemoveColumnDDL + */ + public function testGetRemoveColumnDDL($column) + { + $expected = ' +ALTER TABLE "foo" DROP COLUMN "bar"; +'; + $this->assertEquals($expected, $this->getPlatform()->getRemoveColumnDDL($column)); + } + + /** + * @dataProvider providerForTestGetRenameColumnDDL + */ + public function testGetRenameColumnDDL($fromColumn, $toColumn) + { + $expected = ' +ALTER TABLE "foo" RENAME COLUMN "bar1" TO "bar2"; +'; + $this->assertEquals($expected, $this->getPlatform()->getRenameColumnDDL($fromColumn, $toColumn)); + } + + /** + * @dataProvider providerForTestGetModifyColumnDDL + */ + public function testGetModifyColumnDDL($columnDiff) + { + $expected = ' +ALTER TABLE "foo" ALTER COLUMN "bar" TYPE DOUBLE PRECISION; +'; + $this->assertEquals($expected, $this->getPlatform()->getModifyColumnDDL($columnDiff)); + } + + public function testGetModifyColumnDDLWithChangedTypeAndDefault() + { + $t1 = new Table('foo'); + $c1 = new Column('bar'); + $c1->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceSize(2); + $t1->addColumn($c1); + $t2 = new Table('foo'); + $c2 = new Column('bar'); + $c2->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE')); + $c2->getDomain()->replaceSize(3); + $c2->getDomain()->setDefaultValue(new ColumnDefaultValue(-100, ColumnDefaultValue::TYPE_VALUE)); + $t2->addColumn($c2); + $columnDiff = PropelColumnComparator::computeDiff($c1, $c2); + $expected = <<assertEquals($expected, $this->getPlatform()->getModifyColumnDDL($columnDiff)); + } + + /** + * @dataProvider providerForTestGetModifyColumnsDDL + */ + public function testGetModifyColumnsDDL($columnDiffs) + { + $expected = <<assertEquals($expected, $this->getPlatform()->getModifyColumnsDDL($columnDiffs)); + } + + /** + * @dataProvider providerForTestGetAddColumnDDL + */ + public function testGetAddColumnDDL($column) + { + $expected = ' +ALTER TABLE "foo" ADD "bar" INTEGER; +'; + $this->assertEquals($expected, $this->getPlatform()->getAddColumnDDL($column)); + } + + /** + * @dataProvider providerForTestGetAddColumnsDDL + */ + public function testGetAddColumnsDDL($columns) + { + $expected = <<assertEquals($expected, $this->getPlatform()->getAddColumnsDDL($columns)); + } + + public function testGetModifyColumnDDLWithVarcharWithoutSize() + { + $t1 = new Table('foo'); + $c1 = new Column('bar'); + $c1->setTable($t1); + $c1->getDomain()->copy($this->getPlatform()->getDomainForType('VARCHAR')); + $c1->getDomain()->replaceSize(null); + $c1->getDomain()->replaceScale(null); + $t1->addColumn($c1); + + $schema = << + + + +
+ +EOF; + + $table = $this->getDatabaseFromSchema($schema)->getTable('foo'); + $c2 = $table->getColumn('bar'); + $columnDiff = PropelColumnComparator::computeDiff($c1, $c2); + $expected = false; + $this->assertSame($expected, $columnDiff); + } + +public function testGetModifyColumnDDLWithVarcharWithoutSizeAndPlatform() + { + $t1 = new Table('foo'); + $c1 = new Column('bar'); + $c1->setTable($t1); + $c1->getDomain()->copy($this->getPlatform()->getDomainForType('VARCHAR')); + $c1->getDomain()->replaceSize(null); + $c1->getDomain()->replaceScale(null); + $t1->addColumn($c1); + + $schema = << + + + +
+ +EOF; + + $xtad = new XmlToAppData(null); + $appData = $xtad->parseString($schema); + $db = $appData->getDatabase(); + $table = $db->getTable('foo'); + $c2 = $table->getColumn('bar'); + $columnDiff = PropelColumnComparator::computeDiff($c1, $c2); + $expected = false; + $this->assertSame($expected, $columnDiff); + } + + /** + * @dataProvider providerForTestGetModifyColumnRemoveDefaultValueDDL + */ + public function testGetModifyColumnRemoveDefaultValueDDL($columnDiffs) + { + $expected = <<assertEquals($expected, $this->getPlatform()->getModifyColumnDDL($columnDiffs)); + } + + /** + * @dataProvider providerForTestGetModifyTableForeignKeysSkipSql3DDL + */ + public function testGetModifyTableForeignKeysSkipSql3DDL($databaseDiff) + { + $this->assertFalse($databaseDiff); + } + + /** + * @dataProvider providerForTestGetModifyTableForeignKeysSkipSql4DDL + */ + public function testGetModifyTableForeignKeysSkipSql4DDL($databaseDiff) + { + $this->assertFalse($databaseDiff); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/platform/PgsqlPlatformTest.php b/airtime_mvc/library/propel/test/testsuite/generator/platform/PgsqlPlatformTest.php new file mode 100644 index 000000000..3db7f194d --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/platform/PgsqlPlatformTest.php @@ -0,0 +1,727 @@ +setIdMethod(IDMethod::NATIVE); + $col = new Column('bar'); + $col->getDomain()->copy($this->getPlatform()->getDomainForType('INTEGER')); + $col->setAutoIncrement(true); + $table->addColumn($col); + $expected = 'foo_bar_seq'; + $this->assertEquals($expected, $this->getPlatform()->getSequenceName($table)); + } + + public function testGetSequenceNameCustom() + { + $table = new Table('foo'); + $table->setIdMethod(IDMethod::NATIVE); + $idMethodParameter = new IdMethodParameter(); + $idMethodParameter->setValue('foo_sequence'); + $table->addIdMethodParameter($idMethodParameter); + $table->setIdMethod(IDMethod::NATIVE); + $col = new Column('bar'); + $col->getDomain()->copy($this->getPlatform()->getDomainForType('INTEGER')); + $col->setAutoIncrement(true); + $table->addColumn($col); + $expected = 'foo_sequence'; + $this->assertEquals($expected, $this->getPlatform()->getSequenceName($table)); + } + + /** + * @dataProvider providerForTestGetAddTablesDDL + */ + public function testGetAddTablesDDL($schema) + { + $database = $this->getDatabaseFromSchema($schema); + $expected = <<assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); + } + + /** + * @dataProvider providerForTestGetAddTablesSkipSQLDDL + */ + public function testGetAddTablesDDLSkipSQL($schema) + { + $database = $this->getDatabaseFromSchema($schema); + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); + } + + public function testGetAddTablesDDLSchemasVendor() + { + $schema = << + + + + + +
+ + +
+ + + + + +
+ +EOF; + $database = $this->getDatabaseFromSchema($schema); + $expected = <<assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); + } + + /** + * @dataProvider providerForTestGetAddTablesDDLSchema + */ + public function testGetAddTablesDDLSchemas($schema) + { + $database = $this->getDatabaseFromSchema($schema); + $expected = <<assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLSimplePK + */ + public function testGetAddTableDDLSimplePK($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLCompositePK + */ + public function testGetAddTableDDLCompositePK($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLUniqueIndex + */ + public function testGetAddTableDDLUniqueIndex($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + public function testGetAddTableDDLSchemaVendor() + { + $schema = << + + + + + +
+ +EOF; + $table = $this->getTableFromSchema($schema); + $expected = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLSchema + */ + public function testGetAddTableDDLSchema($schema) + { + $table = $this->getTableFromSchema($schema, 'Woopah.foo'); + $expected = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + public function testGetAddTableDDLSequence() + { + $schema = << + + + +
+ +EOF; + $table = $this->getTableFromSchema($schema); + $expected = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + public function testGetAddTableDDLColumnComments() + { + $schema = << + + + +
+ +EOF; + $table = $this->getTableFromSchema($schema); + $expected = <<assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + public function testGetDropTableDDL() + { + $table = new Table('foo'); + $expected = ' +DROP TABLE IF EXISTS "foo" CASCADE; +'; + $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); + } + + public function testGetDropTableDDLSchemaVendor() + { + $schema = << + + + + + +
+ +EOF; + $table = $this->getTableFromSchema($schema); + $expected = <<assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLSchema + */ + public function testGetDropTableDDLSchema($schema) + { + $table = $this->getTableFromSchema($schema, 'Woopah.foo'); + $expected = <<assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); + } + + public function testGetDropTableWithSequenceDDL() + { + $table = new Table('foo'); + $idMethodParameter = new IdMethodParameter(); + $idMethodParameter->setValue('foo_sequence'); + $table->addIdMethodParameter($idMethodParameter); + $table->setIdMethod(IDMethod::NATIVE); + $expected = ' +DROP TABLE IF EXISTS "foo" CASCADE; + +DROP SEQUENCE "foo_sequence"; +'; + $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); + } + + public function testGetColumnDDL() + { + $c = new Column('foo'); + $c->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE')); + $c->getDomain()->replaceScale(2); + $c->getDomain()->replaceSize(3); + $c->setNotNull(true); + $c->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + + $expected = '"foo" DOUBLE PRECISION DEFAULT 123 NOT NULL'; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($c)); + } + + public function testGetColumnDDLAutoIncrement() + { + $database = new Database(); + $database->setPlatform($this->getPlatform()); + $table = new Table('foo_table'); + $table->setIdMethod(IDMethod::NATIVE); + $database->addTable($table); + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType(PropelTypes::BIGINT)); + $column->setAutoIncrement(true); + $table->addColumn($column); + + $expected = '"foo" bigserial'; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + } + + public function testGetColumnDDLCustomSqlType() + { + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE')); + $column->getDomain()->replaceScale(2); + $column->getDomain()->replaceSize(3); + $column->setNotNull(true); + $column->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $column->getDomain()->replaceSqlType('DECIMAL(5,6)'); + + $expected = '"foo" DECIMAL(5,6) DEFAULT 123 NOT NULL'; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + } + + public function testGetPrimaryKeyDDLSimpleKey() + { + $table = new Table('foo'); + $column = new Column('bar'); + $column->setPrimaryKey(true); + $table->addColumn($column); + + $expected = 'PRIMARY KEY ("bar")'; + $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); + } + + public function testGetPrimaryKeyDDLCompositeKey() + { + $table = new Table('foo'); + $column1 = new Column('bar1'); + $column1->setPrimaryKey(true); + $table->addColumn($column1); + $column2 = new Column('bar2'); + $column2->setPrimaryKey(true); + $table->addColumn($column2); + + $expected = 'PRIMARY KEY ("bar1","bar2")'; + $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestPrimaryKeyDDL + */ + public function testGetDropPrimaryKeyDDL($table) + { + $expected = ' +ALTER TABLE "foo" DROP CONSTRAINT "foo_pkey"; +'; + $this->assertEquals($expected, $this->getPlatform()->getDropPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestPrimaryKeyDDL + */ + public function testGetAddPrimaryKeyDDL($table) + { + $expected = ' +ALTER TABLE "foo" ADD PRIMARY KEY ("bar"); +'; + $this->assertEquals($expected, $this->getPlatform()->getAddPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testAddIndexDDL($index) + { + $expected = ' +CREATE INDEX "babar" ON "foo" ("bar1","bar2"); +'; + $this->assertEquals($expected, $this->getPLatform()->getAddIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetIndicesDDL + */ + public function testAddIndicesDDL($table) + { + $expected = ' +CREATE INDEX "babar" ON "foo" ("bar1","bar2"); + +CREATE INDEX "foo_index" ON "foo" ("bar1"); +'; + $this->assertEquals($expected, $this->getPLatform()->getAddIndicesDDL($table)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testDropIndexDDL($index) + { + $expected = ' +DROP INDEX "babar"; +'; + $this->assertEquals($expected, $this->getPLatform()->getDropIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testGetIndexDDL($index) + { + $expected = 'INDEX "babar" ("bar1","bar2")'; + $this->assertEquals($expected, $this->getPLatform()->getIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetUniqueDDL + */ + public function testGetUniqueDDL($index) + { + $expected = 'CONSTRAINT "babar" UNIQUE ("bar1","bar2")'; + $this->assertEquals($expected, $this->getPlatform()->getUniqueDDL($index)); + } + + /** + * @dataProvider providerForTestGetForeignKeysDDL + */ + public function testGetAddForeignKeysDDL($table) + { + $expected = ' +ALTER TABLE "foo" ADD CONSTRAINT "foo_bar_FK" + FOREIGN KEY ("bar_id") + REFERENCES "bar" ("id") + ON DELETE CASCADE; + +ALTER TABLE "foo" ADD CONSTRAINT "foo_baz_FK" + FOREIGN KEY ("baz_id") + REFERENCES "baz" ("id") + ON DELETE SET NULL; +'; + $this->assertEquals($expected, $this->getPLatform()->getAddForeignKeysDDL($table)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetAddForeignKeyDDL($fk) + { + $expected = ' +ALTER TABLE "foo" ADD CONSTRAINT "foo_bar_FK" + FOREIGN KEY ("bar_id") + REFERENCES "bar" ("id") + ON DELETE CASCADE; +'; + $this->assertEquals($expected, $this->getPLatform()->getAddForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeySkipSqlDDL + */ + public function testGetAddForeignKeySkipSqlDDL($fk) + { + $expected = ''; + $this->assertEquals($expected, $this->getPLatform()->getAddForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetDropForeignKeyDDL($fk) + { + $expected = ' +ALTER TABLE "foo" DROP CONSTRAINT "foo_bar_FK"; +'; + $this->assertEquals($expected, $this->getPLatform()->getDropForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeySkipSqlDDL + */ + public function testGetDropForeignKeySkipSqlDDL($fk) + { + $expected = ''; + $this->assertEquals($expected, $this->getPLatform()->getDropForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetForeignKeyDDL($fk) + { + $expected = 'CONSTRAINT "foo_bar_FK" + FOREIGN KEY ("bar_id") + REFERENCES "bar" ("id") + ON DELETE CASCADE'; + $this->assertEquals($expected, $this->getPLatform()->getForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeySkipSqlDDL + */ + public function testGetForeignKeySkipSqlDDL($fk) + { + $expected = ''; + $this->assertEquals($expected, $this->getPLatform()->getForeignKeyDDL($fk)); + } + + public function testGetCommentBlockDDL() + { + $expected = " +----------------------------------------------------------------------- +-- foo bar +----------------------------------------------------------------------- +"; + $this->assertEquals($expected, $this->getPLatform()->getCommentBlockDDL('foo bar')); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/platform/PlatformMigrationTestProvider.php b/airtime_mvc/library/propel/test/testsuite/generator/platform/PlatformMigrationTestProvider.php new file mode 100644 index 000000000..17dec730f --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/platform/PlatformMigrationTestProvider.php @@ -0,0 +1,571 @@ + + + + +
+ + + + +
+ + + +
+ +EOF; + $schema2 = << + + + + + +
+ + + +
+ + + + +
+ +EOF; + $d1 = $this->getDatabaseFromSchema($schema1); + $d2 = $this->getDatabaseFromSchema($schema2); + + return array(array(PropelDatabaseComparator::computeDiff($d1, $d2))); + } + + public function providerForTestGetRenameTableDDL() + { + return array(array('foo1', 'foo2')); + } + + public function providerForTestGetModifyTableDDL() + { + $schema1 = << + + + + + + + + + + + + + + + + + +
+ + + + +
+ +EOF; + $schema2 = << + + + + + + + + + + + + + + +
+ + + + +
+ +EOF; + $t1 = $this->getDatabaseFromSchema($schema1)->getTable('foo'); + $t2 = $this->getDatabaseFromSchema($schema2)->getTable('foo'); + + return array(array(PropelTableComparator::computeDiff($t1,$t2))); + } + + public function providerForTestGetModifyTableColumnsDDL() + { + $schema1 = << + + + + +
+ +EOF; + $schema2 = << + + + + + +
+ +EOF; + $t1 = $this->getDatabaseFromSchema($schema1)->getTable('foo'); + $t2 = $this->getDatabaseFromSchema($schema2)->getTable('foo'); + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $tc->compareColumns(); + + return array(array($tc->getTableDiff())); + } + + public function providerForTestGetModifyTablePrimaryKeysDDL() + { + $schema1 = << + + + + +
+ +EOF; + $schema2 = << + + + + +
+ +EOF; + $t1 = $this->getDatabaseFromSchema($schema1)->getTable('foo'); + $t2 = $this->getDatabaseFromSchema($schema2)->getTable('foo'); + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $tc->comparePrimaryKeys(); + + return array(array($tc->getTableDiff())); + } + + public function providerForTestGetModifyTableIndicesDDL() + { + $schema1 = << + + + + + + + + + + + +
+ +EOF; + $schema2 = << + + + + + + + + + + + + +
+ +EOF; + $t1 = $this->getDatabaseFromSchema($schema1)->getTable('foo'); + $t2 = $this->getDatabaseFromSchema($schema2)->getTable('foo'); + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $tc->compareIndices(); + + return array(array($tc->getTableDiff())); + } + + public function providerForTestGetModifyTableForeignKeysDDL() + { + $schema1 = << + + + + + + + + + + + + + + + + + +
+ + + + +
+ +EOF; + $schema2 = << + + + + + + + + + + + + + + + + + +
+ + + + +
+ +EOF; + $t1 = $this->getDatabaseFromSchema($schema1)->getTable('foo1'); + $t2 = $this->getDatabaseFromSchema($schema2)->getTable('foo1'); + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $tc->compareForeignKeys(); + + return array(array($tc->getTableDiff())); + } + + public function providerForTestGetModifyTableForeignKeysSkipSqlDDL() + { + $schema1 = << + + + + + + +
+ + + +
+ +EOF; + $schema2 = << + + + + + + +
+ + + +
+ +EOF; + $t1 = $this->getDatabaseFromSchema($schema1)->getTable('foo1'); + $t2 = $this->getDatabaseFromSchema($schema2)->getTable('foo1'); + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $tc->compareForeignKeys(); + + return array(array($tc->getTableDiff())); + } + + public function providerForTestGetModifyTableForeignKeysSkipSql2DDL() + { + $schema1 = << + + + + + + +
+ + + +
+ +EOF; + $schema2 = << + + + +
+ + + +
+ +EOF; + $t1 = $this->getDatabaseFromSchema($schema1)->getTable('foo1'); + $t2 = $this->getDatabaseFromSchema($schema2)->getTable('foo1'); + $tc = new PropelTableComparator(); + $tc->setFromTable($t1); + $tc->setToTable($t2); + $tc->compareForeignKeys(); + + return array(array($tc->getTableDiff())); + } + + public function providerForTestGetRemoveColumnDDL() + { + $table = new Table('foo'); + $column = new Column('bar'); + $table->addColumn($column); + + return array(array($column)); + } + + public function providerForTestGetRenameColumnDDL() + { + $t1 = new Table('foo'); + $c1 = new Column('bar1'); + $c1->getDomain()->setType('DOUBLE'); + $c1->getDomain()->setSqlType('DOUBLE'); + $c1->getDomain()->replaceSize(2); + $t1->addColumn($c1); + $t2 = new Table('foo'); + $c2 = new Column('bar2'); + $c2->getDomain()->setType('DOUBLE'); + $c2->getDomain()->setSqlType('DOUBLE'); + $c2->getDomain()->replaceSize(2); + $t2->addColumn($c2); + + return array(array($c1, $c2)); + } + + public function providerForTestGetModifyColumnDDL() + { + $t1 = new Table('foo'); + $c1 = new Column('bar'); + $c1->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceSize(2); + $t1->addColumn($c1); + $t2 = new Table('foo'); + $c2 = new Column('bar'); + $c2->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE')); + $c2->getDomain()->replaceSize(3); + $t2->addColumn($c2); + + return array(array(PropelColumnComparator::computeDiff($c1, $c2))); + } + + public function providerForTestGetModifyColumnsDDL() + { + $t1 = new Table('foo'); + $c1 = new Column('bar1'); + $c1->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE')); + $c1->getDomain()->replaceSize(2); + $t1->addColumn($c1); + $c2 = new Column('bar2'); + $c2->getDomain()->setType('INTEGER'); + $c2->getDomain()->setSqlType('INTEGER'); + $t1->addColumn($c2); + $t2 = new Table('foo'); + $c3 = new Column('bar1'); + $c3->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE')); + $c3->getDomain()->replaceSize(3); + $t2->addColumn($c3); + $c4 = new Column('bar2'); + $c4->getDomain()->setType('INTEGER'); + $c4->getDomain()->setSqlType('INTEGER'); + $c4->setNotNull(true); + $t2->addColumn($c4); + + return array(array(array( + PropelColumnComparator::computeDiff($c1, $c3), + PropelColumnComparator::computeDiff($c2, $c4) + ))); + } + + public function providerForTestGetAddColumnDDL() + { + $schema = << + + + +
+ +EOF; + $column = $this->getDatabaseFromSchema($schema)->getTable('foo')->getColumn('bar'); + + return array(array($column)); + } + + public function providerForTestGetAddColumnsDDL() + { + $schema = << + + + + +
+ +EOF; + $table = $this->getDatabaseFromSchema($schema)->getTable('foo'); + + return array(array(array($table->getColumn('bar1'), $table->getColumn('bar2')))); + } + + public function providerForTestGetModifyColumnRemoveDefaultValueDDL() + { + $t1 = new Table('test'); + $c1 = new Column(); + $c1->setName('test'); + $c1->getDomain()->setType('INTEGER'); + $c1->setDefaultValue(0); + $t1->addColumn($c1); + $t2 = new Table('test'); + $c2 = new Column(); + $c2->setName('test'); + $c2->getDomain()->setType('INTEGER'); + $t2->addColumn($c2); + + return array(array(PropelColumnComparator::computeDiff($c1, $c2))); + } + + public function providerForTestGetModifyTableForeignKeysSkipSql3DDL() + { + $schema1 = << + + + + + + +
+ + +
+ +EOF; + $schema2 = << + + + +
+ + +
+ +EOF; + $d1 = $this->getDatabaseFromSchema($schema1); + $d2 = $this->getDatabaseFromSchema($schema2); + $diff = PropelDatabaseComparator::computeDiff($d1, $d2); + + return array(array($diff)); + } + + public function providerForTestGetModifyTableForeignKeysSkipSql4DDL() + { + $schema1 = << + + + + + + +
+ + +
+ +EOF; + $schema2 = << + + + +
+ + +
+ +EOF; + $d1 = $this->getDatabaseFromSchema($schema1); + $d2 = $this->getDatabaseFromSchema($schema2); + $diff = PropelDatabaseComparator::computeDiff($d2, $d1); + + return array(array($diff)); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/platform/PlatformTestBase.php b/airtime_mvc/library/propel/test/testsuite/generator/platform/PlatformTestBase.php index f384ca8c0..e8af0f8b2 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/platform/PlatformTestBase.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/platform/PlatformTestBase.php @@ -8,48 +8,28 @@ * @license MIT License */ -require_once 'PHPUnit/Framework/TestCase.php'; +require_once dirname(__FILE__) . '/../../../../generator/lib/builder/util/XmlToAppData.php'; /** - * + * Base class for all Platform tests * @package generator.platform */ -class PlatformTestBase extends PHPUnit_Framework_TestCase +abstract class PlatformTestBase extends PHPUnit_Framework_TestCase { - /** - * Platform object. - * - * @var Platform - */ - protected $platform; - /** - * - */ - protected function setUp() - { - parent::setUp(); + abstract protected function getPlatform(); - $clazz = preg_replace('/Test$/', '', get_class($this)); - include_once 'platform/' . $clazz . '.php'; - $this->platform = new $clazz(); - } + protected function getDatabaseFromSchema($schema) + { + $xtad = new XmlToAppData($this->getPlatform()); + $appData = $xtad->parseString($schema); - /** - * - */ - protected function tearDown() - { - parent::tearDown(); - } + return $appData->getDatabase(); + } - /** - * - * @return Platform - */ - protected function getPlatform() - { - return $this->platform; - } + protected function getTableFromSchema($schema, $tableName = 'foo') + { + return $this->getDatabaseFromSchema($schema)->getTable($tableName); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/platform/PlatformTestProvider.php b/airtime_mvc/library/propel/test/testsuite/generator/platform/PlatformTestProvider.php new file mode 100644 index 000000000..f6485956c --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/platform/PlatformTestProvider.php @@ -0,0 +1,321 @@ + + + + + + + + + + + +
+ + + + +
+ +EOF; + + return array(array($schema)); + } + + public function providerForTestGetAddTablesDDLSchema() + { + $schema = << + + + + + + + + + + +
+ + + + +
+ + + + + + + +
+ +EOF; + + return array(array($schema)); + } + + public function providerForTestGetAddTablesSkipSQLDDL() + { + $schema = << + + + + + + + + + + +
+ + + + +
+ +EOF; + + return array(array($schema)); + } + + public function providerForTestGetAddTableDDLSimplePK() + { + $schema = << + + + +
+ +EOF; + + return array(array($schema)); + } + + public function providerForTestGetAddTableDDLNonIntegerPK() + { + $schema = << + + + +
+ +EOF; + + return array(array($schema)); + } + + public function providerForTestGetAddTableDDLCompositePK() + { + $schema = << + + + + +
+ +EOF; + + return array(array($schema)); + } + + public function providerForTestGetAddTableDDLUniqueIndex() + { + $schema = << + + + + + + +
+ +EOF; + + return array(array($schema)); + } + + public function providerForTestGetAddTableDDLSchema() + { + $schema = << + + + +
+ +EOF; + + return array(array($schema)); + } + + public function providerForTestGetUniqueDDL() + { + $table = new Table('foo'); + $column1 = new Column('bar1'); + $column1->getDomain()->copy(new Domain('FOOTYPE')); + $table->addColumn($column1); + $column2 = new Column('bar2'); + $column2->getDomain()->copy(new Domain('BARTYPE')); + $table->addColumn($column2); + $index = new Unique('babar'); + $index->addColumn($column1); + $index->addColumn($column2); + $table->addUnique($index); + + return array( + array($index) + ); + } + + public function providerForTestGetIndicesDDL() + { + $table = new Table('foo'); + $column1 = new Column('bar1'); + $column1->getDomain()->copy(new Domain('FOOTYPE')); + $table->addColumn($column1); + $column2 = new Column('bar2'); + $column2->getDomain()->copy(new Domain('BARTYPE')); + $table->addColumn($column2); + $index1 = new Index('babar'); + $index1->addColumn($column1); + $index1->addColumn($column2); + $table->addIndex($index1); + $index2 = new Index('foo_index'); + $index2->addColumn($column1); + $table->addIndex($index2); + + return array( + array($table) + ); + } + + public function providerForTestGetIndexDDL() + { + $table = new Table('foo'); + $column1 = new Column('bar1'); + $column1->getDomain()->copy(new Domain('FOOTYPE')); + $table->addColumn($column1); + $column2 = new Column('bar2'); + $column2->getDomain()->copy(new Domain('BARTYPE')); + $table->addColumn($column2); + $index = new Index('babar'); + $index->addColumn($column1); + $index->addColumn($column2); + $table->addIndex($index); + + return array( + array($index) + ); + } + + public function providerForTestPrimaryKeyDDL() + { + $table = new Table('foo'); + $column = new Column('bar'); + $column->setPrimaryKey(true); + $table->addColumn($column); + + return array( + array($table) + ); + } + + public function providerForTestGetForeignKeyDDL() + { + $table1 = new Table('foo'); + $column1 = new Column('bar_id'); + $column1->getDomain()->copy(new Domain('FOOTYPE')); + $table1->addColumn($column1); + $table2 = new Table('bar'); + $column2 = new Column('id'); + $column2->getDomain()->copy(new Domain('BARTYPE')); + $table2->addColumn($column2); + $fk = new ForeignKey('foo_bar_FK'); + $fk->setForeignTableCommonName('bar'); + $fk->addReference($column1, $column2); + $fk->setOnDelete('CASCADE'); + $table1->addForeignKey($fk); + + return array( + array($fk) + ); + } + + public function providerForTestGetForeignKeySkipSqlDDL() + { + $arr = self::providerForTestGetForeignKeyDDL(); + $fk = $arr[0][0]; + $fk->setSkipSql(true); + + return array( + array($fk) + ); + } + + public function providerForTestGetForeignKeysDDL() + { + $table1 = new Table('foo'); + + $column1 = new Column('bar_id'); + $column1->getDomain()->copy(new Domain('FOOTYPE')); + $table1->addColumn($column1); + $table2 = new Table('bar'); + $column2 = new Column('id'); + $column2->getDomain()->copy(new Domain('BARTYPE')); + $table2->addColumn($column2); + + $fk = new ForeignKey('foo_bar_FK'); + $fk->setForeignTableCommonName('bar'); + $fk->addReference($column1, $column2); + $fk->setOnDelete('CASCADE'); + $table1->addForeignKey($fk); + + $column3 = new Column('baz_id'); + $column3->getDomain()->copy(new Domain('BAZTYPE')); + $table1->addColumn($column3); + $table3 = new Table('baz'); + $column4 = new Column('id'); + $column4->getDomain()->copy(new Domain('BAZTYPE')); + $table3->addColumn($column4); + + $fk = new ForeignKey('foo_baz_FK'); + $fk->setForeignTableCommonName('baz'); + $fk->addReference($column3, $column4); + $fk->setOnDelete('SETNULL'); + $table1->addForeignKey($fk); + + return array( + array($table1) + ); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/platform/SqlitePlatformTest.php b/airtime_mvc/library/propel/test/testsuite/generator/platform/SqlitePlatformTest.php index 4380485e3..3c59cb974 100644 --- a/airtime_mvc/library/propel/test/testsuite/generator/platform/SqlitePlatformTest.php +++ b/airtime_mvc/library/propel/test/testsuite/generator/platform/SqlitePlatformTest.php @@ -8,41 +8,370 @@ * @license MIT License */ -require_once 'generator/platform/DefaultPlatformTest.php'; +require_once dirname(__FILE__) . '/PlatformTestProvider.php'; +require_once dirname(__FILE__) . '/../../../../generator/lib/platform/SqlitePlatform.php'; /** - * + * * @package generator.platform */ -class SqlitePlatformTest extends DefaultPlatformTest +class SqlitePlatformTest extends PlatformTestProvider { - /** - * @var PDO The PDO connection to SQLite DB. - */ - private $pdo; + /** + * Get the Platform object for this class + * + * @return Platform + */ + protected function getPlatform() + { + return new SqlitePlatform(); + } - protected function setUp() - { - parent::setUp(); - $this->pdo = new PDO("sqlite::memory:"); + public function testQuoteConnected() + { + $p = $this->getPlatform(); + $p->setConnection(new PDO("sqlite::memory:")); - } + $unquoted = "Naughty ' string"; + $quoted = $p->quote($unquoted); - public function tearDown() - { - parent::tearDown(); - } + $expected = "'Naughty '' string'"; + $this->assertEquals($expected, $quoted); + } - public function testQuoteConnected() - { - $p = $this->getPlatform(); - $p->setConnection($this->pdo); + public function testGetSequenceNameDefault() + { + $table = new Table('foo'); + $table->setIdMethod(IDMethod::NATIVE); + $expected = 'foo_SEQ'; + $this->assertEquals($expected, $this->getPlatform()->getSequenceName($table)); + } - $unquoted = "Naughty ' string"; - $quoted = $p->quote($unquoted); + public function testGetSequenceNameCustom() + { + $table = new Table('foo'); + $table->setIdMethod(IDMethod::NATIVE); + $idMethodParameter = new IdMethodParameter(); + $idMethodParameter->setValue('foo_sequence'); + $table->addIdMethodParameter($idMethodParameter); + $table->setIdMethod(IDMethod::NATIVE); + $expected = 'foo_sequence'; + $this->assertEquals($expected, $this->getPlatform()->getSequenceName($table)); + } - $expected = "'Naughty '' string'"; - $this->assertEquals($expected, $quoted); - } + /** + * @dataProvider providerForTestGetAddTablesDDL + */ + public function testGetAddTablesDDL($schema) + { + $database = $this->getDatabaseFromSchema($schema); + $expected = <<assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); + } + + /** + * @dataProvider providerForTestGetAddTablesSkipSQLDDL + */ + public function testGetAddTablesSkipSQLDDL($schema) + { + $database = $this->getDatabaseFromSchema($schema); + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getAddTablesDDL($database)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLSimplePK + */ + public function testGetAddTableDDLSimplePK($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = " +-- This is foo table +CREATE TABLE [foo] +( + [id] INTEGER NOT NULL PRIMARY KEY, + [bar] VARCHAR(255) NOT NULL +); +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLNonIntegerPK + */ + public function testGetAddTableDDLNonIntegerPK($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = " +-- This is foo table +CREATE TABLE [foo] +( + [foo] VARCHAR(255) NOT NULL, + [bar] VARCHAR(255) NOT NULL, + PRIMARY KEY ([foo]) +); +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLCompositePK + */ + public function testGetAddTableDDLCompositePK($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE [foo] +( + [foo] INTEGER NOT NULL, + [bar] INTEGER NOT NULL, + [baz] VARCHAR(255) NOT NULL, + PRIMARY KEY ([foo],[bar]) +); +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + /** + * @dataProvider providerForTestGetAddTableDDLUniqueIndex + */ + public function testGetAddTableDDLUniqueIndex($schema) + { + $table = $this->getTableFromSchema($schema); + $expected = " +CREATE TABLE [foo] +( + [id] INTEGER NOT NULL PRIMARY KEY, + [bar] INTEGER, + UNIQUE ([bar]) +); +"; + $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table)); + } + + public function testGetDropTableDDL() + { + $table = new Table('foo'); + $expected = " +DROP TABLE IF EXISTS [foo]; +"; + $this->assertEquals($expected, $this->getPlatform()->getDropTableDDL($table)); + } + + public function testGetColumnDDL() + { + $c = new Column('foo'); + $c->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE')); + $c->getDomain()->replaceScale(2); + $c->getDomain()->replaceSize(3); + $c->setNotNull(true); + $c->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + + $expected = '[foo] DOUBLE(3,2) DEFAULT 123 NOT NULL'; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($c)); + } + + public function testGetColumnDDLCustomSqlType() + { + $column = new Column('foo'); + $column->getDomain()->copy($this->getPlatform()->getDomainForType('DOUBLE')); + $column->getDomain()->replaceScale(2); + $column->getDomain()->replaceSize(3); + $column->setNotNull(true); + $column->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE)); + $column->getDomain()->replaceSqlType('DECIMAL(5,6)'); + + $expected = '[foo] DECIMAL(5,6) DEFAULT 123 NOT NULL'; + $this->assertEquals($expected, $this->getPlatform()->getColumnDDL($column)); + } + + public function testGetPrimaryKeyDDLSimpleKey() + { + $table = new Table('foo'); + $column = new Column('bar'); + $column->setPrimaryKey(true); + $table->addColumn($column); + + $expected = 'PRIMARY KEY ([bar])'; + $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); + } + + public function testGetPrimaryKeyDDLCompositeKey() + { + $table = new Table('foo'); + $column1 = new Column('bar1'); + $column1->setPrimaryKey(true); + $table->addColumn($column1); + $column2 = new Column('bar2'); + $column2->setPrimaryKey(true); + $table->addColumn($column2); + + $expected = 'PRIMARY KEY ([bar1],[bar2])'; + $this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestPrimaryKeyDDL + */ + public function testGetDropPrimaryKeyDDL($table) + { + // not supported by SQLite + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getDropPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestPrimaryKeyDDL + */ + public function testGetAddPrimaryKeyDDL($table) + { + // not supported by SQLite + $expected = ''; + $this->assertEquals($expected, $this->getPlatform()->getAddPrimaryKeyDDL($table)); + } + + /** + * @dataProvider providerForTestGetIndicesDDL + */ + public function testAddIndicesDDL($table) + { + $expected = " +CREATE INDEX [babar] ON [foo] ([bar1],[bar2]); + +CREATE INDEX [foo_index] ON [foo] ([bar1]); +"; + $this->assertEquals($expected, $this->getPLatform()->getAddIndicesDDL($table)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testAddIndexDDL($index) + { + $expected = " +CREATE INDEX [babar] ON [foo] ([bar1],[bar2]); +"; + $this->assertEquals($expected, $this->getPLatform()->getAddIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testDropIndexDDL($index) + { + $expected = " +DROP INDEX [babar]; +"; + $this->assertEquals($expected, $this->getPLatform()->getDropIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetIndexDDL + */ + public function testGetIndexDDL($index) + { + $expected = 'INDEX [babar] ([bar1],[bar2])'; + $this->assertEquals($expected, $this->getPLatform()->getIndexDDL($index)); + } + + /** + * @dataProvider providerForTestGetUniqueDDL + */ + public function testGetUniqueDDL($index) + { + $expected = 'UNIQUE ([bar1],[bar2])'; + $this->assertEquals($expected, $this->getPlatform()->getUniqueDDL($index)); + } + + /** + * @dataProvider providerForTestGetForeignKeysDDL + */ + public function testGetAddForeignKeysDDL($table) + { + $expected = " +-- SQLite does not support foreign keys; this is just for reference +-- FOREIGN KEY ([bar_id]) REFERENCES bar ([id]) + +-- SQLite does not support foreign keys; this is just for reference +-- FOREIGN KEY ([baz_id]) REFERENCES baz ([id]) +"; + $this->assertEquals($expected, $this->getPLatform()->getAddForeignKeysDDL($table)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetAddForeignKeyDDL($fk) + { + $expected = " +-- SQLite does not support foreign keys; this is just for reference +-- FOREIGN KEY ([bar_id]) REFERENCES bar ([id]) +"; + $this->assertEquals($expected, $this->getPLatform()->getAddForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetDropForeignKeyDDL($fk) + { + $expected = ''; + $this->assertEquals($expected, $this->getPLatform()->getDropForeignKeyDDL($fk)); + } + + /** + * @dataProvider providerForTestGetForeignKeyDDL + */ + public function testGetForeignKeyDDL($fk) + { + $expected = " +-- SQLite does not support foreign keys; this is just for reference +-- FOREIGN KEY ([bar_id]) REFERENCES bar ([id]) +"; + $this->assertEquals($expected, $this->getPLatform()->getForeignKeyDDL($fk)); + } + + public function testGetCommentBlockDDL() + { + $expected = " +----------------------------------------------------------------------- +-- foo bar +----------------------------------------------------------------------- +"; + $this->assertEquals($expected, $this->getPLatform()->getCommentBlockDDL('foo bar')); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/generator/reverse/mssql/MssqlSchemaParserTest.php b/airtime_mvc/library/propel/test/testsuite/generator/reverse/mssql/MssqlSchemaParserTest.php new file mode 100644 index 000000000..8cca85ac4 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/reverse/mssql/MssqlSchemaParserTest.php @@ -0,0 +1,69 @@ +cleanDelimitedIdentifiers('\''.$expected.'\''); + $this->assertEquals($expected, $tested); + + $tested = $parser->cleanDelimitedIdentifiers('\''.$expected); + $this->assertEquals('\''.$expected, $tested); + + $tested = $parser->cleanDelimitedIdentifiers($expected.'\''); + $this->assertEquals($expected.'\'', $tested); + + $expected = 'this is a tabl\'ename'; + + $tested = $parser->cleanDelimitedIdentifiers('\''.$expected.'\''); + $this->assertEquals($expected, $tested); + + $tested = $parser->cleanDelimitedIdentifiers('\''.$expected); + $this->assertEquals('\''.$expected, $tested); + + $tested = $parser->cleanDelimitedIdentifiers($expected.'\''); + $this->assertEquals($expected.'\'', $tested); + + $expected = 'this is a\'tabl\'ename'; + + $tested = $parser->cleanDelimitedIdentifiers('\''.$expected.'\''); + $this->assertEquals($expected, $tested); + + $tested = $parser->cleanDelimitedIdentifiers('\''.$expected); + $this->assertEquals('\''.$expected, $tested); + + $tested = $parser->cleanDelimitedIdentifiers($expected.'\''); + $this->assertEquals($expected.'\'', $tested); + + } +} + +class TestableMssqlSchemaParser extends MssqlSchemaParser +{ + public function cleanDelimitedIdentifiers($identifier) + { + return parent::cleanDelimitedIdentifiers($identifier); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/reverse/mysql/MysqlSchemaParserTest.php b/airtime_mvc/library/propel/test/testsuite/generator/reverse/mysql/MysqlSchemaParserTest.php new file mode 100644 index 000000000..6f2bcde71 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/reverse/mysql/MysqlSchemaParserTest.php @@ -0,0 +1,100 @@ +load(dirname(__FILE__) . '/../../../../fixtures/reverse/mysql/runtime-conf.xml'); + $xml = simplexml_load_string($xmlDom->saveXML()); + $phpconf = OpenedPropelConvertConfTask::simpleXmlToArray($xml); + + Propel::setConfiguration($phpconf); + Propel::initialize(); + } + + protected function tearDown() + { + parent::tearDown(); + Propel::init(dirname(__FILE__) . '/../../../../fixtures/bookstore/build/conf/bookstore-conf.php'); + } + + public function testParse() + { + $parser = new MysqlSchemaParser(Propel::getConnection('reverse-bookstore')); + $parser->setGeneratorConfig(new QuickGeneratorConfig()); + + $database = new Database(); + $database->setPlatform(new DefaultPlatform()); + + $this->assertEquals(2, $parser->parse($database), 'two tables and one view defined should return two as we exclude views'); + + $tables = $database->getTables(); + $this->assertEquals(2, count($tables)); + + $table = $tables[0]; + $this->assertEquals('Book', $table->getPhpName()); + $this->assertEquals(4, count($table->getColumns())); + } + + public function testDecimal() + { + $t1 = new Table('foo'); + + $schema = '
'; + $xtad = new XmlToAppData(); + $appData = $xtad->parseString($schema); + $database = $appData->getDatabase(); + $table = $database->getTable('foo'); + $c1 = $table->getColumn('longitude'); + + $parser = new MysqlSchemaParser(Propel::getConnection('reverse-bookstore')); + $parser->setGeneratorConfig(new QuickGeneratorConfig()); + + $database = new Database(); + $database->setPlatform(new MysqlPlatform()); + $parser->parse($database); + + $table = $database->getTable('foo'); + + $c2 = $table->getColumn('longitude'); + $this->assertEquals($c1->getSize(), $c2->getSize()); + $this->assertEquals($c1->getScale(), $c2->getScale()); + } +} + +class OpenedPropelConvertConfTask extends PropelConvertConfTask +{ + public static function simpleXmlToArray($xml) + { + return parent::simpleXmlToArray($xml); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/reverse/pgsql/PgsqlSchemaParserTest.php b/airtime_mvc/library/propel/test/testsuite/generator/reverse/pgsql/PgsqlSchemaParserTest.php new file mode 100644 index 000000000..78615009e --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/reverse/pgsql/PgsqlSchemaParserTest.php @@ -0,0 +1,106 @@ +markTestSkipped('PGSQL unit test'); + + parent::setUp(); + + $xmlDom = new DOMDocument(); + $xmlDom->load(dirname(__FILE__) . '/../../../../fixtures/reverse/pgsql/runtime-conf.xml'); + $xml = simplexml_load_string($xmlDom->saveXML()); + $phpconf = TestablePropelConvertConfTask::simpleXmlToArray($xml); + + Propel::setConfiguration($phpconf); + Propel::initialize(); + + $this->con = Propel::getConnection('reverse-bookstore'); + $this->con->beginTransaction(); + } + + protected function tearDown() + { + if ($this->con) { + $this->con->rollback(); + } + + parent::tearDown(); + Propel::init(dirname(__FILE__) . '/../../../../fixtures/bookstore/build/conf/bookstore-conf.php'); + } + + public function parseDataProvider() + { + return array( + // columnDDL, expectedColumnPhpName, expectedColumnDefaultType, expectedColumnDefaultValue, expectedSize, expectedScale + array("my_column varchar(20) default null", "MyColumn", ColumnDefaultValue::TYPE_VALUE, "NULL", 20, null), + array("my_column varchar(20) default ''", "MyColumn", ColumnDefaultValue::TYPE_VALUE, "", 20, null), + array("my_column numeric(11,0) default 0", "MyColumn", ColumnDefaultValue::TYPE_VALUE, 0, 11, 0), + array("my_column numeric(55,8) default 0", "MyColumn", ColumnDefaultValue::TYPE_VALUE, 0, 55, 8), + ); + } + + /** + * @dataProvider parseDataProvider + */ + public function testParse($columnDDL, $expectedColumnPhpName, $expectedColumnDefaultType, $expectedColumnDefaultValue, $expectedSize, $expectedScale) + { + $this->con->query("create table foo ( {$columnDDL} );"); + $parser = new PgsqlSchemaParser($this->con); + $parser->setGeneratorConfig(new QuickGeneratorConfig()); + + $database = new Database(); + $database->setPlatform(new DefaultPlatform()); + + // make sure our DDL insert produced exactly the SQL we inserted + $this->assertEquals(1, $parser->parse($database), 'One table and one view defined should return one as we exclude views'); + $tables = $database->getTables(); + $this->assertEquals(1, count($tables)); + $table = $tables[0]; + $columns = $table->getColumns(); + $this->assertEquals(1, count($columns)); + + // check out our rev-eng column info + $defaultValue = $columns[0]->getDefaultValue(); + $this->assertEquals($expectedColumnPhpName, $columns[0]->getPhpName()); + $this->assertEquals($expectedColumnDefaultType, $defaultValue->getType()); + $this->assertEquals($expectedColumnDefaultValue, $defaultValue->getValue()); + $this->assertEquals($expectedSize, $columns[0]->getSize()); + $this->assertEquals($expectedScale, $columns[0]->getScale()); + } +} + +class TestablePropelConvertConfTask extends PropelConvertConfTask +{ + public static function simpleXmlToArray($xml) + { + return parent::simpleXmlToArray($xml); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/util/PropelDotGeneratorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/util/PropelDotGeneratorTest.php new file mode 100644 index 000000000..fdeb43c65 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/util/PropelDotGeneratorTest.php @@ -0,0 +1,197 @@ +setName('Empty'); + + $expected = implode("\n", array( + 'digraph G {', + '}', + '', + )); + $this->assertEquals($expected, PropelDotGenerator::create($db)); + } + + public function testSingleTableWithoutName() + { + $column = new Column(); + $column->setName('id'); + $column->setPrimaryKey(true); + $column->setAutoIncrement(true); + $column->setType('integer'); + + $table = new Table(); + $table->setCommonName("t"); + $table->addColumn($column); + + $db = new Database(); + $db->setName('SingleTable'); + $db->addTable($table); + + $expected = implode("\n", array( + 'digraph G {', + '"t" [label="{t|id (integer) [PK]\l}", shape=record];', + '}', + '', + )); + $this->assertEquals($expected, PropelDotGenerator::create($db)); + } + + public function testMultipleTablesWithoutForeignKey() + { + $column = new Column(); + $column->setName('id'); + $column->setPrimaryKey(true); + $column->setAutoIncrement(true); + $column->setType('integer'); + + $table = new Table(); + $table->setCommonName('table_one'); + $table->addColumn($column); + + $db = new Database(); + $db->setName('MultipleTables'); + $db->addTable($table); + + $column = new Column(); + $column->setName('id'); + $column->setPrimaryKey(true); + $column->setAutoIncrement(true); + $column->setType('integer'); + + $table = new Table(); + $table->setCommonName('table_two'); + $table->addColumn($column); + $db->addTable($table); + + $expected = implode("\n", array( + 'digraph G {', + '"table_one" [label="{
table_one|id (integer) [PK]\l}", shape=record];', + '"table_two" [label="{
table_two|id (integer) [PK]\l}", shape=record];', + '}', + '', + )); + $this->assertEquals($expected, PropelDotGenerator::create($db)); + } + + public function testMultipleTablesWithFK() + { + $column = new Column(); + $column->setName('id'); + $column->setPrimaryKey(true); + $column->setAutoIncrement(true); + $column->setType('integer'); + + $table = new Table(); + $table->setCommonName('table_one'); + $table->addColumn($column); + + $db = new Database(); + $db->setName('MultipleTables'); + $db->addTable($table); + + $column = new Column(); + $column->setName('id'); + $column->setPrimaryKey(true); + $column->setAutoIncrement(true); + $column->setType('integer'); + + $c2 = new Column(); + $c2->setName('foreign_id'); + $c2->setType('integer'); + + $table = new Table(); + $table->setCommonName('table_two'); + $table->addColumn($column); + $table->addColumn($c2); + + $fk = new ForeignKey(); + $fk->setName('FK_1'); + $fk->addReference('foreign_id', 'id'); + $fk->setForeignTableCommonName('table_one'); + + $table->addForeignKey($fk); + + $db->addTable($table); + + $expected = implode("\n", array( + 'digraph G {', + '"table_one" [label="{
table_one|id (integer) [PK]\l}", shape=record];', + '"table_two" [label="{
table_two|id (integer) [PK]\lforeign_id (integer) [FK]\l}", shape=record];', + '"table_two":cols -> "table_one":table [label="foreign_id=id"];', + '}', + '', + )); + $this->assertEquals($expected, PropelDotGenerator::create($db)); + } + + public function testColumnIsFKAndPK() + { + $column = new Column(); + $column->setName('id'); + $column->setPrimaryKey(true); + $column->setAutoIncrement(true); + $column->setType('integer'); + + $table = new Table(); + $table->setCommonName('table_one'); + $table->addColumn($column); + + $db = new Database(); + $db->setName('MultipleTables'); + $db->addTable($table); + + $column = new Column(); + $column->setName('id'); + $column->setPrimaryKey(true); + $column->setAutoIncrement(true); + $column->setType('integer'); + + $c2 = new Column(); + $c2->setPrimaryKey(true); + $c2->setName('foreign_id'); + $c2->setType('integer'); + + $table = new Table(); + $table->setCommonName('table_two'); + $table->addColumn($column); + $table->addColumn($c2); + + $fk = new ForeignKey(); + $fk->setName('FK_1'); + $fk->addReference('foreign_id', 'id'); + $fk->setForeignTableCommonName('table_one'); + + $table->addForeignKey($fk); + + $db->addTable($table); + + $expected = implode("\n", array( + 'digraph G {', + '"table_one" [label="{
table_one|id (integer) [PK]\l}", shape=record];', + '"table_two" [label="{
table_two|id (integer) [PK]\lforeign_id (integer) [FK] [PK]\l}", shape=record];', + '"table_two":cols -> "table_one":table [label="foreign_id=id"];', + '}', + '', + )); + $this->assertEquals($expected, PropelDotGenerator::create($db)); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/util/PropelPHPParserTest.php b/airtime_mvc/library/propel/test/testsuite/generator/util/PropelPHPParserTest.php new file mode 100644 index 000000000..de8d6fb84 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/util/PropelPHPParserTest.php @@ -0,0 +1,272 @@ +assertFalse($parser->findMethod('foo')); + } + + /** + * @dataProvider basicClassCodeProvider + */ + public function testFindMethodNReturnsMethod($code) + { + $parser = new PropelPHPParser($code); + $expected = <<assertEquals($expected, $parser->findMethod('bar1')); + } + + /** + * @dataProvider basicClassCodeProvider + */ + public function testFindMethodPrecededByAttribute($code) + { + $parser = new PropelPHPParser($code); + $expected = <<assertEquals($expected, $parser->findMethod('bar2')); + } + + /** + * @dataProvider basicClassCodeProvider + */ + public function testFindMethodPrecededByComment($code) + { + $parser = new PropelPHPParser($code); + $expected = <<assertEquals($expected, $parser->findMethod('bar3')); + } + + /** + * @dataProvider basicClassCodeProvider + */ + public function testFindMethodWithWrongCurlyBraces($code) + { + $parser = new PropelPHPParser($code); + $expected = <<assertEquals($expected, $parser->findMethod('bar4')); + } + + /** + * @dataProvider basicClassCodeProvider + */ + public function testRemoveMethodNotExistsReturnsFalse($code) + { + $parser = new PropelPHPParser($code); + $this->assertFalse($parser->removeMethod('foo')); + } + + /** + * @dataProvider basicClassCodeProvider + */ + public function testRemoveMethodReturnsMethod($code) + { + $parser = new PropelPHPParser($code); + $expected = <<assertEquals($expected, $parser->removeMethod('bar1')); + } + + /** + * @dataProvider basicClassCodeProvider + */ + public function testRemoveMethodRemovesMethod($code) + { + $parser = new PropelPHPParser($code); + $parser->removeMethod('bar1'); + $expected = <<assertEquals($expected, $parser->getCode()); + } + + /** + * @dataProvider basicClassCodeProvider + */ + public function testReplaceMethodNotExistsReturnsFalse($code) + { + $parser = new PropelPHPParser($code); + $this->assertFalse($parser->replaceMethod('foo', '// foo')); + } + + /** + * @dataProvider basicClassCodeProvider + */ + public function testReplaceMethodReturnsMethod($code) + { + $parser = new PropelPHPParser($code); + $expected = <<assertEquals($expected, $parser->replaceMethod('bar1', '// foo')); + } + + /** + * @dataProvider basicClassCodeProvider + */ + public function testReplaceMethodReplacesMethod($code) + { + $parser = new PropelPHPParser($code); + $newCode = <<replaceMethod('bar1', $newCode); + $expected = <<assertEquals($expected, $parser->getCode()); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/util/PropelQuickBuilderTest.php b/airtime_mvc/library/propel/test/testsuite/generator/util/PropelQuickBuilderTest.php new file mode 100644 index 000000000..f31f8e5a4 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/util/PropelQuickBuilderTest.php @@ -0,0 +1,140 @@ +setPlatform(new MysqlPlatform()); + $this->assertTrue($builder->getPLatform() instanceof MysqlPlatform); + $builder = new PropelQuickBuilder(); + $this->assertTrue($builder->getPLatform() instanceof SqlitePlatform); + } + + public function simpleSchemaProvider() + { + $schema = << +
+ + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + + return array(array($builder)); + } + + /** + * @dataProvider simpleSchemaProvider + */ + public function testGetDatabase($builder) + { + $database = $builder->getDatabase(); + $this->assertEquals('test_quick_build_2', $database->getName()); + $this->assertEquals(1, count($database->getTables())); + $this->assertEquals(2, count($database->getTable('quick_build_foo_1')->getColumns())); + } + + /** + * @dataProvider simpleSchemaProvider + */ + public function testGetSQL($builder) + { + $expected = <<assertEquals($expected, $builder->getSQL()); + } + + /** + * @dataProvider simpleSchemaProvider + */ + public function testGetClasses($builder) + { + $script = $builder->getClasses(); + $this->assertContains('class QuickBuildFoo1 extends BaseQuickBuildFoo1', $script); + $this->assertContains('class QuickBuildFoo1Peer extends BaseQuickBuildFoo1Peer', $script); + $this->assertContains('class QuickBuildFoo1Query extends BaseQuickBuildFoo1Query', $script); + $this->assertContains('class BaseQuickBuildFoo1 extends BaseObject', $script); + $this->assertContains('class BaseQuickBuildFoo1Peer', $script); + $this->assertContains('class BaseQuickBuildFoo1Query extends ModelCriteria', $script); + } + + /** + * @dataProvider simpleSchemaProvider + */ + public function testBuildClasses($builder) + { + $builder->buildClasses(); + $foo = new QuickBuildFoo1(); + $this->assertTrue($foo instanceof BaseObject); + $this->assertTrue(QuickBuildFoo1Peer::getTableMap() instanceof QuickBuildFoo1TableMap); + } + + /** + * @dataProvider simpleSchemaProvider + */ + public function testGetClassesLimitedClassTargets($builder) + { + $script = $builder->getClasses(array('tablemap', 'peer', 'object', 'query')); + $this->assertNotContains('class QuickBuildFoo1 extends BaseQuickBuildFoo1', $script); + $this->assertNotContains('class QuickBuildFoo1Peer extends BaseQuickBuildFoo1Peer', $script); + $this->assertNotContains('class QuickBuildFoo1Query extends BaseQuickBuildFoo1Query', $script); + $this->assertContains('class BaseQuickBuildFoo1 extends BaseObject', $script); + $this->assertContains('class BaseQuickBuildFoo1Peer', $script); + $this->assertContains('class BaseQuickBuildFoo1Query extends ModelCriteria', $script); + } + + public function testBuild() + { + $schema = << + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $builder->build(); + $this->assertEquals(0, QuickBuildFoo2Query::create()->count()); + $foo = new QuickBuildFoo2(); + $foo->setBar(3); + $foo->save(); + $this->assertEquals(1, QuickBuildFoo2Query::create()->count()); + $this->assertEquals($foo, QuickBuildFoo2Query::create()->findOne()); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/util/PropelSQLParserTest.php b/airtime_mvc/library/propel/test/testsuite/generator/util/PropelSQLParserTest.php new file mode 100644 index 000000000..8df935959 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/util/PropelSQLParserTest.php @@ -0,0 +1,228 @@ +setSQL($input); + $parser->stripSQLCommentLines(); + $this->assertEquals($output, $parser->getSQL()); + } + + public function convertLineFeedsToUnixStyleDataProvider() + { + return array( + array('', ''), + array("foo bar", "foo bar"), + array("foo\nbar", "foo\nbar"), + array("foo\rbar", "foo\nbar"), + array("foo\r\nbar", "foo\nbar"), + array("foo\r\nbar\rbaz\nbiz\r\n", "foo\nbar\nbaz\nbiz\n"), + ); + } + + /** + * @dataProvider convertLineFeedsToUnixStyleDataProvider + */ + public function testConvertLineFeedsToUnixStyle($input, $output) + { + $parser = new PropelSQLParser(); + $parser->setSQL($input); + $parser->convertLineFeedsToUnixStyle(); + $this->assertEquals($output, $parser->getSQL()); + } + + public function explodeIntoStatementsDataProvider() + { + return array( + array('', array()), + array('foo', array('foo')), + array('foo;', array('foo')), + array('foo; ', array('foo')), + array('foo;bar', array('foo', 'bar')), + array('foo;bar;', array('foo', 'bar')), + array("f\no\no;\nb\nar\n;", array("f\no\no", "b\nar")), + array('foo";"bar;baz', array('foo";"bar', 'baz')), + array('foo\';\'bar;baz', array('foo\';\'bar', 'baz')), + array('foo"\";"bar;', array('foo"\";"bar')), + ); + } + /** + * @dataProvider explodeIntoStatementsDataProvider + */ + public function testExplodeIntoStatements($input, $output) + { + $parser = new PropelSQLParser(); + $parser->setSQL($input); + $this->assertEquals($output, $parser->explodeIntoStatements()); + } + + public function testDelimiterOneCharacter() + { + $parser = new PropelSQLParser(); + $parser->setSQL('DELIMITER |'); + $this->assertEquals(array(), $parser->explodeIntoStatements()); + } + + public function testDelimiterMultipleCharacters() + { + $parser = new PropelSQLParser(); + $parser->setSQL('DELIMITER ||'); + $this->assertEquals(array(), $parser->explodeIntoStatements()); + + $parser = new PropelSQLParser(); + $parser->setSQL('DELIMITER |||'); + $this->assertEquals(array(), $parser->explodeIntoStatements()); + + $parser = new PropelSQLParser(); + $parser->setSQL('DELIMITER ////'); + $this->assertEquals(array(), $parser->explodeIntoStatements()); + } + + public function singleDelimiterExplodeIntoStatementsDataProvider() + { + return array( + array("delimiter |", array()), + array("DELIMITER |", array()), + array("foo;\nDELIMITER |", array('foo')), + array("foo;\nDELIMITER |\nbar", array('foo', 'bar')), + array("foo;\nDELIMITER |\nbar;", array('foo', 'bar;')), + array("foo;\nDELIMITER |\nbar;\nbaz;", array('foo', "bar;\nbaz;")), + array("foo;\nDELIMITER |\nbar;\nbaz;\nDELIMITER ;", array('foo', "bar;\nbaz;")), + array("foo;\nDELIMITER |\nbar;\nbaz;\nDELIMITER ;\nqux", array('foo', "bar;\nbaz;", 'qux')), + array("foo;\nDELIMITER |\nbar;\nbaz;\nDELIMITER ;\nqux;", array('foo', "bar;\nbaz;", 'qux')), + array("DELIMITER |\n".'foo"|"bar;'."\nDELIMITER ;\nbaz", array('foo"|"bar;', 'baz')), + array("DELIMITER |\n".'foo\'|\'bar;'."\nDELIMITER ;\nbaz", array('foo\'|\'bar;', 'baz')), + array("DELIMITER |\n".'foo"\"|"bar;'."\nDELIMITER ;\nbaz", array('foo"\"|"bar;', 'baz')), + ); + } + + /** + * @dataProvider singleDelimiterExplodeIntoStatementsDataProvider + */ + public function testSingleDelimiterExplodeIntoStatements($input, $output) + { + $parser = new PropelSQLParser(); + $parser->setSQL($input); + $this->assertEquals($output, $parser->explodeIntoStatements()); + } + + public function twoCharDelimiterExplodeIntoStatementsDataProvider() + { + return array( + array("delimiter ||", array()), + array("DELIMITER ||", array()), + array("foo;\nDELIMITER ||", array('foo')), + array("foo;\nDELIMITER ||\nbar", array('foo', 'bar')), + array("foo;\nDELIMITER ||\nbar;", array('foo', 'bar;')), + array("foo;\nDELIMITER ||\nbar;\nbaz;", array('foo', "bar;\nbaz;")), + array("foo;\nDELIMITER ||\nbar;\nbaz;\nDELIMITER ;", array('foo', "bar;\nbaz;")), + array("foo;\nDELIMITER ||\nbar;\nbaz;\nDELIMITER ;\nqux", array('foo', "bar;\nbaz;", 'qux')), + array("foo;\nDELIMITER ||\nbar;\nbaz;\nDELIMITER ;\nqux;", array('foo', "bar;\nbaz;", 'qux')), + array("DELIMITER ||\n".'foo"||"bar;'."\nDELIMITER ;\nbaz", array('foo"||"bar;', 'baz')), + array("DELIMITER ||\n".'foo\'||\'bar;'."\nDELIMITER ;\nbaz", array('foo\'||\'bar;', 'baz')), + array("DELIMITER ||\n".'foo"\"||"bar;'."\nDELIMITER ;\nbaz", array('foo"\"||"bar;', 'baz')), + ); + } + + /** + * @dataProvider twoCharDelimiterExplodeIntoStatementsDataProvider + */ + public function testTwoCharDelimiterExplodeIntoStatements($input, $output) + { + $parser = new PropelSQLParser(); + $parser->setSQL($input); + $this->assertEquals($output, $parser->explodeIntoStatements()); + } + + public function threeCharDelimiterExplodeIntoStatementsDataProvider() + { + return array( + array("delimiter |||", array()), + array("DELIMITER |||", array()), + array("foo;\nDELIMITER |||", array('foo')), + array("foo;\nDELIMITER |||\nbar", array('foo', 'bar')), + array("foo;\nDELIMITER |||\nbar;", array('foo', 'bar;')), + array("foo;\nDELIMITER |||\nbar;\nbaz;", array('foo', "bar;\nbaz;")), + array("foo;\nDELIMITER |||\nbar;\nbaz;\nDELIMITER ;", array('foo', "bar;\nbaz;")), + array("foo;\nDELIMITER |||\nbar;\nbaz;\nDELIMITER ;\nqux", array('foo', "bar;\nbaz;", 'qux')), + array("foo;\nDELIMITER |||\nbar;\nbaz;\nDELIMITER ;\nqux;", array('foo', "bar;\nbaz;", 'qux')), + array("DELIMITER |||\n".'foo"|||"bar;'."\nDELIMITER ;\nbaz", array('foo"|||"bar;', 'baz')), + array("DELIMITER |||\n".'foo\'|||\'bar;'."\nDELIMITER ;\nbaz", array('foo\'|||\'bar;', 'baz')), + array("DELIMITER |||\n".'foo"\"|||"bar;'."\nDELIMITER ;\nbaz", array('foo"\"|||"bar;', 'baz')), + ); + } + + /** + * @dataProvider threeCharDelimiterExplodeIntoStatementsDataProvider + */ + public function testThreeCharDelimiterExplodeIntoStatements($input, $output) + { + $parser = new PropelSQLParser(); + $parser->setSQL($input); + $this->assertEquals($output, $parser->explodeIntoStatements()); + } + + public function fourCharDelimiterExplodeIntoStatementsDataProvider() + { + return array( + array("delimiter ////", array()), + array("DELIMITER ////", array()), + array("foo;\nDELIMITER ////", array('foo')), + array("foo;\nDELIMITER ////\nbar", array('foo', 'bar')), + array("foo;\nDELIMITER ////\nbar;", array('foo', 'bar;')), + array("foo;\nDELIMITER ////\nbar;\nbaz;", array('foo', "bar;\nbaz;")), + array("foo;\nDELIMITER ////\nbar;\nbaz;\nDELIMITER ;", array('foo', "bar;\nbaz;")), + array("foo;\nDELIMITER ////\nbar;\nbaz;\nDELIMITER ;\nqux", array('foo', "bar;\nbaz;", 'qux')), + array("foo;\nDELIMITER ////\nbar;\nbaz;\nDELIMITER ;\nqux;", array('foo', "bar;\nbaz;", 'qux')), + array("DELIMITER ////\n".'foo"////"bar;'."\nDELIMITER ;\nbaz", array('foo"////"bar;', 'baz')), + array("DELIMITER ////\n".'foo\'////\'bar;'."\nDELIMITER ;\nbaz", array('foo\'////\'bar;', 'baz')), + array("DELIMITER ////\n".'foo"\"////"bar;'."\nDELIMITER ;\nbaz", array('foo"\"////"bar;', 'baz')), + ); + } + + /** + * @dataProvider fourCharDelimiterExplodeIntoStatementsDataProvider + */ + public function testFourCharDelimiterExplodeIntoStatements($input, $output) + { + $parser = new PropelSQLParser(); + $parser->setSQL($input); + $this->assertEquals($output, $parser->explodeIntoStatements()); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/generator/util/PropelSchemaValidatorTest.php b/airtime_mvc/library/propel/test/testsuite/generator/util/PropelSchemaValidatorTest.php new file mode 100644 index 000000000..bbf4789f4 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/generator/util/PropelSchemaValidatorTest.php @@ -0,0 +1,185 @@ +addTable($table); + $appData = new AppData(); + $appData->addDatabase($database); + + return $appData; + } + + public function testValidateReturnsTrueForEmptySchema() + { + $schema = new AppData(); + $validator = new PropelSchemaValidator($schema); + $this->assertTrue($validator->validate()); + } + + public function testValidateReturnsTrueForValidSchema() + { + $schema = << + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $database = $builder->getDatabase(); + $appData = new AppData(); + $appData->addDatabase($database); + $validator = new PropelSchemaValidator($appData); + $this->assertTrue($validator->validate()); + } + + public function testDatabasePackageName() + { + + $schema = << + + + +
+ +EOF; + $dom = new DomDocument('1.0', 'UTF-8'); + $dom->loadXML($schema); + + $this->assertTrue($dom->schemaValidate($this->xsdFile)); + } + + public function testValidateReturnsFalseWhenTwoTablesHaveSamePhpName() + { + $table1 = new Table('foo'); + $table2 = new Table('bar'); + $table2->setPhpName('Foo'); + $database = new Database(); + $database->addTable($table1); + $database->addTable($table2); + $appData = new AppData(); + $appData->addDatabase($database); + $validator = new PropelSchemaValidator($appData); + $this->assertFalse($validator->validate()); + $this->assertContains('Table "bar" declares a phpName already used in another table', $validator->getErrors()); + } + + public function testValidateReturnsTrueWhenTwoTablesHaveSamePhpNameInDifferentNamespaces() + { + $column1 = new Column('id'); + $column1->setPrimaryKey(true); + $table1 = new Table('foo'); + $table1->addColumn($column1); + $table1->setNamespace('Foo'); + + $column2 = new Column('id'); + $column2->setPrimaryKey(true); + $table2 = new Table('bar'); + $table2->addColumn($column2); + $table2->setPhpName('Foo'); + $table2->setNamespace('Bar'); + + $database = new Database(); + $database->addTable($table1); + $database->addTable($table2); + $appData = new AppData(); + $appData->addDatabase($database); + $validator = new PropelSchemaValidator($appData); + $this->assertTrue($validator->validate()); + } + + public function testValidateReturnsFalseWhenTableHasNoPk() + { + $appData = $this->getAppDataForTable(new Table('foo')); + $validator = new PropelSchemaValidator($appData); + $this->assertFalse($validator->validate()); + $this->assertContains('Table "foo" does not have a primary key defined. Propel requires all tables to have a primary key.', $validator->getErrors()); + } + + public function testValidateReturnsTrueWhenTableHasNoPkButIsAView() + { + $table = new Table('foo'); + $table->setSkipSql(true); + $appData = $this->getAppDataForTable($table); + $validator = new PropelSchemaValidator($appData); + $this->assertTrue($validator->validate()); + } + + public function testValidateReturnsFalseWhenTableHasAReservedName() + { + $appData = $this->getAppDataForTable(new Table('TABLE_NAME')); + $validator = new PropelSchemaValidator($appData); + $this->assertFalse($validator->validate()); + $this->assertContains('Table "TABLE_NAME" uses a reserved keyword as name', $validator->getErrors()); + } + + public function testValidateReturnsFalseWhenCrossRefTableHasTwoFksToTheSameTable() + { + $schema = << + + + +
+ + + + + + + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $database = $builder->getDatabase(); + $appData = new AppData(); + $appData->addDatabase($database); + $validator = new PropelSchemaValidator($appData); + $this->assertFalse($validator->validate()); + $this->assertContains('Table "book_book" implements an equal nest relationship for table "book". This feature is not supported', $validator->getErrors()); + } + + public function testValidateReturnsFalseWhenTwoColumnsHaveSamePhpName() + { + $column1 = new Column('foo'); + $column2 = new Column('bar'); + $column2->setPhpName('Foo'); + $table = new Table('foo_table'); + $table->addColumn($column1); + $table->addColumn($column2); + $appData = $this->getAppDataForTable($table); + $validator = new PropelSchemaValidator($appData); + $this->assertFalse($validator->validate()); + $this->assertContains('Column "bar" declares a phpName already used in table "foo_table"', $validator->getErrors()); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/misc/BookstoreTest.php b/airtime_mvc/library/propel/test/testsuite/misc/BookstoreTest.php index c0f63e28e..f7df815f0 100644 --- a/airtime_mvc/library/propel/test/testsuite/misc/BookstoreTest.php +++ b/airtime_mvc/library/propel/test/testsuite/misc/BookstoreTest.php @@ -6,9 +6,9 @@ * file that was distributed with this source code. * * @license MIT License - */ + */ -include_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Tests a functional scenario using the Bookstore model @@ -19,852 +19,902 @@ include_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; */ class BookstoreTest extends BookstoreEmptyTestBase { - public function testScenario() - { - // Add publisher records - // --------------------- - - try { - $scholastic = new Publisher(); - $scholastic->setName("Scholastic"); - // do not save, will do later to test cascade - - $morrow = new Publisher(); - $morrow->setName("William Morrow"); - $morrow->save(); - $morrow_id = $morrow->getId(); - - $penguin = new Publisher(); - $penguin->setName("Penguin"); - $penguin->save(); - $penguin_id = $penguin->getId(); - - $vintage = new Publisher(); - $vintage->setName("Vintage"); - $vintage->save(); - $vintage_id = $vintage->getId(); - $this->assertTrue(true, 'Save Publisher records'); - } catch (Exception $e) { - $this->fail('Save publisher records'); - } - // Add author records - // ------------------ + public function testConcreteOneToOne() + { - try { - $rowling = new Author(); - $rowling->setFirstName("J.K."); - $rowling->setLastName("Rowling"); - // do not save, will do later to test cascade - - $stephenson = new Author(); - $stephenson->setFirstName("Neal"); - $stephenson->setLastName("Stephenson"); - $stephenson->save(); - $stephenson_id = $stephenson->getId(); - - $byron = new Author(); - $byron->setFirstName("George"); - $byron->setLastName("Byron"); - $byron->save(); - $byron_id = $byron->getId(); - - $grass = new Author(); - $grass->setFirstName("Gunter"); - $grass->setLastName("Grass"); - $grass->save(); - $grass_id = $grass->getId(); - $this->assertTrue(true, 'Save Author records'); - } catch (Exception $e) { - $this->fail('Save Author records'); - } - - // Add book records - // ---------------- - - try { - $phoenix = new Book(); - $phoenix->setTitle("Harry Potter and the Order of the Phoenix"); - $phoenix->setISBN("043935806X"); - $phoenix->setAuthor($rowling); - $phoenix->setPublisher($scholastic); - $phoenix->save(); - $phoenix_id = $phoenix->getId(); - $this->assertFalse($rowling->isNew(), 'saving book also saves related author'); - $this->assertFalse($scholastic->isNew(), 'saving book also saves related publisher'); - - $qs = new Book(); - $qs->setISBN("0380977427"); - $qs->setTitle("Quicksilver"); - $qs->setAuthor($stephenson); - $qs->setPublisher($morrow); - $qs->save(); - $qs_id = $qs->getId(); - - $dj = new Book(); - $dj->setISBN("0140422161"); - $dj->setTitle("Don Juan"); - $dj->setAuthor($byron); - $dj->setPublisher($penguin); - $dj->save(); - $dj_id = $qs->getId(); - - $td = new Book(); - $td->setISBN("067972575X"); - $td->setTitle("The Tin Drum"); - $td->setAuthor($grass); - $td->setPublisher($vintage); - $td->save(); - $td_id = $td->getId(); - $this->assertTrue(true, 'Save Book records'); - } catch (Exception $e) { - $this->fail('Save Author records'); - } - - // Add review records - // ------------------ - - try { - $r1 = new Review(); - $r1->setBook($phoenix); - $r1->setReviewedBy("Washington Post"); - $r1->setRecommended(true); - $r1->setReviewDate(time()); - $r1->save(); - $r1_id = $r1->getId(); - - $r2 = new Review(); - $r2->setBook($phoenix); - $r2->setReviewedBy("New York Times"); - $r2->setRecommended(false); - $r2->setReviewDate(time()); - $r2->save(); - $r2_id = $r2->getId(); - $this->assertTrue(true, 'Save Review records'); - } catch (Exception $e) { - $this->fail('Save Review records'); - } - - // Perform a "complex" search - // -------------------------- - - $crit = new Criteria(); - $crit->add(BookPeer::TITLE, 'Harry%', Criteria::LIKE); - $results = BookPeer::doSelect($crit); - $this->assertEquals(1, count($results)); + $book = new ConcreteOnetooneScienceBook(); + $author = new ConcreteOnetooneBookAuthor(); - $crit2 = new Criteria(); - $crit2->add(BookPeer::ISBN, array("0380977427", "0140422161"), Criteria::IN); - $results = BookPeer::doSelect($crit2); - $this->assertEquals(2, count($results)); + $book->setTitle('Synthetic intelligence'); + $book->setAdditionField('technical area is humanoid robotics'); - // Perform a "limit" search - // ------------------------ - - $crit = new Criteria(); - $crit->setLimit(2); - $crit->setOffset(1); - $crit->addAscendingOrderByColumn(BookPeer::TITLE); - - $results = BookPeer::doSelect($crit); - $this->assertEquals(2, count($results)); - - // we ordered on book title, so we expect to get - $this->assertEquals("Harry Potter and the Order of the Phoenix", $results[0]->getTitle()); - $this->assertEquals("Quicksilver", $results[1]->getTitle()); + $author->setConcreteOnetooneScienceBook($book); + $author->save(); - // Perform a lookup & update! - // -------------------------- - - // Updating just-created book title - // First finding book by PK (=$qs_id) .... - $qs_lookup = BookPeer::retrieveByPk($qs_id); - $this->assertNotNull($qs_lookup, 'just-created book can be found by pk'); - - $new_title = "Quicksilver (".crc32(uniqid(rand())).")"; - // Attempting to update found object - $qs_lookup->setTitle($new_title); - $qs_lookup->save(); - - // Making sure object was correctly updated: "; - $qs_lookup2 = BookPeer::retrieveByPk($qs_id); - $this->assertEquals($new_title, $qs_lookup2->getTitle()); + $this->assertEquals($book->getId(), $author->getBookId()); - // Test some basic DATE / TIME stuff - // --------------------------------- - - // that's the control timestamp. - $control = strtotime('2004-02-29 00:00:00'); - - // should be two in the db - $r = ReviewPeer::doSelectOne(new Criteria()); - $r_id = $r->getId(); - $r->setReviewDate($control); - $r->save(); - - $r2 = ReviewPeer::retrieveByPk($r_id); - - $this->assertEquals(new Datetime('2004-02-29 00:00:00'), $r2->getReviewDate(null), 'ability to fetch DateTime'); - $this->assertEquals($control, $r2->getReviewDate('U'), 'ability to fetch native unix timestamp'); - $this->assertEquals('2-29-2004', $r2->getReviewDate('n-j-Y'), 'ability to use date() formatter'); + $insertedBook = ConcreteOnetooneScienceBookQuery::create()->findPk($book->getId()); - // Handle BLOB/CLOB Columns - // ------------------------ - - $blob_path = dirname(__FILE__) . '/../../etc/lob/tin_drum.gif'; - $blob2_path = dirname(__FILE__) . '/../../etc/lob/propel.gif'; - $clob_path = dirname(__FILE__) . '/../../etc/lob/tin_drum.txt'; - - $m1 = new Media(); - $m1->setBook($phoenix); - $m1->setCoverImage(file_get_contents($blob_path)); - $m1->setExcerpt(file_get_contents($clob_path)); - $m1->save(); - $m1_id = $m1->getId(); - - $m1_lookup = MediaPeer::retrieveByPk($m1_id); - - $this->assertNotNull($m1_lookup, 'Can find just-created media item'); - $this->assertEquals(file_get_contents($blob_path), stream_get_contents($m1_lookup->getCoverImage()), 'BLOB was correctly updated'); - $this->assertEquals(file_get_contents($clob_path), (string) $m1_lookup->getExcerpt(), 'CLOB was correctly updated'); - - // now update the BLOB column and save it & check the results - $m1_lookup->setCoverImage(file_get_contents($blob2_path)); - $m1_lookup->save(); - - $m2_lookup = MediaPeer::retrieveByPk($m1_id); - $this->assertNotNull($m2_lookup, 'Can find just-created media item'); - - $this->assertEquals(file_get_contents($blob2_path), stream_get_contents($m2_lookup->getCoverImage()), 'BLOB was correctly overwritten'); + $this->assertEquals('Synthetic intelligence', $insertedBook->getTitle()); + $this->assertEquals('technical area is humanoid robotics', $insertedBook->getAdditionField()); - // Test Validators - // --------------- + } - require_once 'tools/helpers/bookstore/validator/ISBNValidator.php'; + public function testScenario() + { + // Add publisher records + // --------------------- - $bk1 = new Book(); - $bk1->setTitle("12345"); // min length is 10 - $ret = $bk1->validate(); - - $this->assertFalse($ret, 'validation failed'); - $failures = $bk1->getValidationFailures(); - $this->assertEquals(1, count($failures), '1 validation message was returned'); - - $el = array_shift($failures); - $this->assertContains("must be more than", $el->getMessage(), 'Expected validation message was returned'); - - $bk2 = new Book(); - $bk2->setTitle("Don Juan"); - $ret = $bk2->validate(); - - $this->assertFalse($ret, 'validation failed'); - - $failures = $bk2->getValidationFailures(); - $this->assertEquals(1, count($failures), '1 validation message was returned'); - - $el = array_shift($failures); - $this->assertContains("Book title already in database.", $el->getMessage(), 'Expected validation message was returned'); - - //Now trying some more complex validation. - $auth1 = new Author(); - $auth1->setFirstName("Hans"); - // last name required; will fail - - $bk1->setAuthor($auth1); - - $rev1 = new Review(); - $rev1->setReviewDate("08/09/2001"); - // will fail: reviewed_by column required - - $bk1->addReview($rev1); - - $ret2 = $bk1->validate(); - $this->assertFalse($ret2, 'validation failed'); - - $failures2 = $bk1->getValidationFailures(); - - $this->assertEquals(3, count($failures2), '3 validation messages were returned'); - - $expectedKeys = array( - AuthorPeer::LAST_NAME, - BookPeer::TITLE, - ReviewPeer::REVIEWED_BY, - ); - $this->assertEquals($expectedKeys, array_keys($failures2), 'correct columns failed'); - - $bk2 = new Book(); - $bk2->setTitle("12345678901"); // passes - - $auth2 = new Author(); - $auth2->setLastName("Blah"); //passes - $auth2->setEmail("some@body.com"); //passes - $auth2->setAge(50); //passes - $bk2->setAuthor($auth2); - - $rev2 = new Review(); - $rev2->setReviewedBy("Me!"); // passes - $rev2->setStatus("new"); // passes - $bk2->addReview($rev2); - - $ret3 = $bk2->validate(); - - $this->assertTrue($ret3, 'complex validation can pass'); + try { + $scholastic = new Publisher(); + $scholastic->setName("Scholastic"); + // do not save, will do later to test cascade - // Testing doCount() functionality - // ------------------------------- - - $c = new Criteria(); - $records = BookPeer::doSelect($c); - $count = BookPeer::doCount($c); - - $this->assertEquals($count, count($records), 'correct number of results'); + $morrow = new Publisher(); + $morrow->setName("William Morrow"); + $morrow->save(); + $morrow_id = $morrow->getId(); - // Test many-to-many relationships - // --------------- + $penguin = new Publisher(); + $penguin->setName("Penguin"); + $penguin->save(); + $penguin_id = $penguin->getId(); - // init book club list 1 with 2 books - - $blc1 = new BookClubList(); - $blc1->setGroupLeader("Crazyleggs"); - $blc1->setTheme("Happiness"); - - $brel1 = new BookListRel(); - $brel1->setBook($phoenix); - - $brel2 = new BookListRel(); - $brel2->setBook($dj); - - $blc1->addBookListRel($brel1); - $blc1->addBookListRel($brel2); - - $blc1->save(); - - $this->assertNotNull($blc1->getId(), 'BookClubList 1 was saved'); - - // init book club list 2 with 1 book - - $blc2 = new BookClubList(); - $blc2->setGroupLeader("John Foo"); - $blc2->setTheme("Default"); - - $brel3 = new BookListRel(); - $brel3->setBook($phoenix); - - $blc2->addBookListRel($brel3); - - $blc2->save(); - - $this->assertNotNull($blc2->getId(), 'BookClubList 2 was saved'); - - // re-fetch books and lists from db to be sure that nothing is cached - - $crit = new Criteria(); - $crit->add(BookPeer::ID, $phoenix->getId()); - $phoenix = BookPeer::doSelectOne($crit); - $this->assertNotNull($phoenix, "book 'phoenix' has been re-fetched from db"); - - $crit = new Criteria(); - $crit->add(BookClubListPeer::ID, $blc1->getId()); - $blc1 = BookClubListPeer::doSelectOne($crit); - $this->assertNotNull($blc1, 'BookClubList 1 has been re-fetched from db'); - - $crit = new Criteria(); - $crit->add(BookClubListPeer::ID, $blc2->getId()); - $blc2 = BookClubListPeer::doSelectOne($crit); - $this->assertNotNull($blc2, 'BookClubList 2 has been re-fetched from db'); - - $relCount = $phoenix->countBookListRels(); - $this->assertEquals(2, $relCount, "book 'phoenix' has 2 BookListRels"); - - $relCount = $blc1->countBookListRels(); - $this->assertEquals(2, $relCount, 'BookClubList 1 has 2 BookListRels'); - - $relCount = $blc2->countBookListRels(); - $this->assertEquals(1, $relCount, 'BookClubList 2 has 1 BookListRel'); - - // Cleanup (tests DELETE) - // ---------------------- - - // Removing books that were just created - // First finding book by PK (=$phoenix_id) .... - $hp = BookPeer::retrieveByPk($phoenix_id); - $this->assertNotNull($hp, 'Could find just-created book'); - - // Attempting to delete [multi-table] by found pk - $c = new Criteria(); - $c->add(BookPeer::ID, $hp->getId()); - // The only way for cascading to work currently - // is to specify the author_id and publisher_id (i.e. the fkeys - // have to be in the criteria). - $c->add(AuthorPeer::ID, $hp->getAuthor()->getId()); - $c->add(PublisherPeer::ID, $hp->getPublisher()->getId()); - $c->setSingleRecord(true); - BookPeer::doDelete($c); - - // Checking to make sure correct records were removed. - $this->assertEquals(3, AuthorPeer::doCount(new Criteria()), 'Correct records were removed from author table'); - $this->assertEquals(3, PublisherPeer::doCount(new Criteria()), 'Correct records were removed from publisher table'); - $this->assertEquals(3, BookPeer::doCount(new Criteria()), 'Correct records were removed from book table'); - - // Attempting to delete books by complex criteria - $c = new Criteria(); - $cn = $c->getNewCriterion(BookPeer::ISBN, "043935806X"); - $cn->addOr($c->getNewCriterion(BookPeer::ISBN, "0380977427")); - $cn->addOr($c->getNewCriterion(BookPeer::ISBN, "0140422161")); - $c->add($cn); - BookPeer::doDelete($c); - - // Attempting to delete book [id = $td_id] - $td->delete(); - - // Attempting to delete authors - AuthorPeer::doDelete($stephenson_id); - AuthorPeer::doDelete($byron_id); - $grass->delete(); + $vintage = new Publisher(); + $vintage->setName("Vintage"); + $vintage->save(); + $vintage_id = $vintage->getId(); + $this->assertTrue(true, 'Save Publisher records'); + } catch (Exception $e) { + $this->fail('Save publisher records'); + } - // Attempting to delete publishers - PublisherPeer::doDelete($morrow_id); - PublisherPeer::doDelete($penguin_id); - $vintage->delete(); - - // These have to be deleted manually also since we have onDelete - // set to SETNULL in the foreign keys in book. Is this correct? - $rowling->delete(); - $scholastic->delete(); - $blc1->delete(); - $blc2->delete(); - - $this->assertEquals(array(), AuthorPeer::doSelect(new Criteria()), 'no records in [author] table'); - $this->assertEquals(array(), PublisherPeer::doSelect(new Criteria()), 'no records in [publisher] table'); - $this->assertEquals(array(), BookPeer::doSelect(new Criteria()), 'no records in [book] table'); - $this->assertEquals(array(), ReviewPeer::doSelect(new Criteria()), 'no records in [review] table'); - $this->assertEquals(array(), MediaPeer::doSelect(new Criteria()), 'no records in [media] table'); - $this->assertEquals(array(), BookClubListPeer::doSelect(new Criteria()), 'no records in [book_club_list] table'); - $this->assertEquals(array(), BookListRelPeer::doSelect(new Criteria()), 'no records in [book_x_list] table'); + // Add author records + // ------------------ - } - - public function testScenarioUsingQuery() - { - // Add publisher records - // --------------------- - - try { - $scholastic = new Publisher(); - $scholastic->setName("Scholastic"); - // do not save, will do later to test cascade - - $morrow = new Publisher(); - $morrow->setName("William Morrow"); - $morrow->save(); - $morrow_id = $morrow->getId(); - - $penguin = new Publisher(); - $penguin->setName("Penguin"); - $penguin->save(); - $penguin_id = $penguin->getId(); - - $vintage = new Publisher(); - $vintage->setName("Vintage"); - $vintage->save(); - $vintage_id = $vintage->getId(); - $this->assertTrue(true, 'Save Publisher records'); - } catch (Exception $e) { - $this->fail('Save publisher records'); - } + try { + $rowling = new Author(); + $rowling->setFirstName("J.K."); + $rowling->setLastName("Rowling"); + // do not save, will do later to test cascade - // Add author records - // ------------------ + $stephenson = new Author(); + $stephenson->setFirstName("Neal"); + $stephenson->setLastName("Stephenson"); + $stephenson->save(); + $stephenson_id = $stephenson->getId(); - try { - $rowling = new Author(); - $rowling->setFirstName("J.K."); - $rowling->setLastName("Rowling"); - // do not save, will do later to test cascade - - $stephenson = new Author(); - $stephenson->setFirstName("Neal"); - $stephenson->setLastName("Stephenson"); - $stephenson->save(); - $stephenson_id = $stephenson->getId(); - - $byron = new Author(); - $byron->setFirstName("George"); - $byron->setLastName("Byron"); - $byron->save(); - $byron_id = $byron->getId(); - - $grass = new Author(); - $grass->setFirstName("Gunter"); - $grass->setLastName("Grass"); - $grass->save(); - $grass_id = $grass->getId(); - $this->assertTrue(true, 'Save Author records'); - } catch (Exception $e) { - $this->fail('Save Author records'); - } - - // Add book records - // ---------------- - - try { - $phoenix = new Book(); - $phoenix->setTitle("Harry Potter and the Order of the Phoenix"); - $phoenix->setISBN("043935806X"); - $phoenix->setAuthor($rowling); - $phoenix->setPublisher($scholastic); - $phoenix->save(); - $phoenix_id = $phoenix->getId(); - $this->assertFalse($rowling->isNew(), 'saving book also saves related author'); - $this->assertFalse($scholastic->isNew(), 'saving book also saves related publisher'); - - $qs = new Book(); - $qs->setISBN("0380977427"); - $qs->setTitle("Quicksilver"); - $qs->setAuthor($stephenson); - $qs->setPublisher($morrow); - $qs->save(); - $qs_id = $qs->getId(); - - $dj = new Book(); - $dj->setISBN("0140422161"); - $dj->setTitle("Don Juan"); - $dj->setAuthor($byron); - $dj->setPublisher($penguin); - $dj->save(); - $dj_id = $qs->getId(); - - $td = new Book(); - $td->setISBN("067972575X"); - $td->setTitle("The Tin Drum"); - $td->setAuthor($grass); - $td->setPublisher($vintage); - $td->save(); - $td_id = $td->getId(); - $this->assertTrue(true, 'Save Book records'); - } catch (Exception $e) { - $this->fail('Save Author records'); - } - - // Add review records - // ------------------ - - try { - $r1 = new Review(); - $r1->setBook($phoenix); - $r1->setReviewedBy("Washington Post"); - $r1->setRecommended(true); - $r1->setReviewDate(time()); - $r1->save(); - $r1_id = $r1->getId(); - - $r2 = new Review(); - $r2->setBook($phoenix); - $r2->setReviewedBy("New York Times"); - $r2->setRecommended(false); - $r2->setReviewDate(time()); - $r2->save(); - $r2_id = $r2->getId(); - $this->assertTrue(true, 'Save Review records'); - } catch (Exception $e) { - $this->fail('Save Review records'); - } - - // Perform a "complex" search - // -------------------------- - - $results = BookQuery::create() - ->filterByTitle('Harry%') - ->find(); - $this->assertEquals(1, count($results)); - - $results = BookQuery::create() - ->where('Book.ISBN IN ?', array("0380977427", "0140422161")) - ->find(); - $this->assertEquals(2, count($results)); + $byron = new Author(); + $byron->setFirstName("George"); + $byron->setLastName("Byron"); + $byron->save(); + $byron_id = $byron->getId(); - // Perform a "limit" search - // ------------------------ - - $results = BookQuery::create() - ->limit(2) - ->offset(1) - ->orderByTitle() - ->find(); - $this->assertEquals(2, count($results)); - // we ordered on book title, so we expect to get - $this->assertEquals("Harry Potter and the Order of the Phoenix", $results[0]->getTitle()); - $this->assertEquals("Quicksilver", $results[1]->getTitle()); - - // Perform a lookup & update! - // -------------------------- - - // Updating just-created book title - // First finding book by PK (=$qs_id) .... - $qs_lookup = BookQuery::create()->findPk($qs_id); - $this->assertNotNull($qs_lookup, 'just-created book can be found by pk'); - - $new_title = "Quicksilver (".crc32(uniqid(rand())).")"; - // Attempting to update found object - $qs_lookup->setTitle($new_title); - $qs_lookup->save(); - - // Making sure object was correctly updated: "; - $qs_lookup2 = BookQuery::create()->findPk($qs_id); - $this->assertEquals($new_title, $qs_lookup2->getTitle()); + $grass = new Author(); + $grass->setFirstName("Gunter"); + $grass->setLastName("Grass"); + $grass->save(); + $grass_id = $grass->getId(); + $this->assertTrue(true, 'Save Author records'); + } catch (Exception $e) { + $this->fail('Save Author records'); + } - // Test some basic DATE / TIME stuff - // --------------------------------- - - // that's the control timestamp. - $control = strtotime('2004-02-29 00:00:00'); - - // should be two in the db - $r = ReviewQuery::create()->findOne(); - $r_id = $r->getId(); - $r->setReviewDate($control); - $r->save(); - - $r2 = ReviewQuery::create()->findPk($r_id); - $this->assertEquals(new Datetime('2004-02-29 00:00:00'), $r2->getReviewDate(null), 'ability to fetch DateTime'); - $this->assertEquals($control, $r2->getReviewDate('U'), 'ability to fetch native unix timestamp'); - $this->assertEquals('2-29-2004', $r2->getReviewDate('n-j-Y'), 'ability to use date() formatter'); + // Add book records + // ---------------- - // Handle BLOB/CLOB Columns - // ------------------------ - - $blob_path = dirname(__FILE__) . '/../../etc/lob/tin_drum.gif'; - $blob2_path = dirname(__FILE__) . '/../../etc/lob/propel.gif'; - $clob_path = dirname(__FILE__) . '/../../etc/lob/tin_drum.txt'; - - $m1 = new Media(); - $m1->setBook($phoenix); - $m1->setCoverImage(file_get_contents($blob_path)); - $m1->setExcerpt(file_get_contents($clob_path)); - $m1->save(); - $m1_id = $m1->getId(); - - $m1_lookup = MediaQuery::create()->findPk($m1_id); - - $this->assertNotNull($m1_lookup, 'Can find just-created media item'); - $this->assertEquals(file_get_contents($blob_path), stream_get_contents($m1_lookup->getCoverImage()), 'BLOB was correctly updated'); - $this->assertEquals(file_get_contents($clob_path), (string) $m1_lookup->getExcerpt(), 'CLOB was correctly updated'); - - // now update the BLOB column and save it & check the results - $m1_lookup->setCoverImage(file_get_contents($blob2_path)); - $m1_lookup->save(); - - $m2_lookup = MediaQuery::create()->findPk($m1_id); - $this->assertNotNull($m2_lookup, 'Can find just-created media item'); - - $this->assertEquals(file_get_contents($blob2_path), stream_get_contents($m2_lookup->getCoverImage()), 'BLOB was correctly overwritten'); + try { + $phoenix = new Book(); + $phoenix->setTitle("Harry Potter and the Order of the Phoenix"); + $phoenix->setISBN("043935806X"); + $phoenix->setAuthor($rowling); + $phoenix->setPublisher($scholastic); + $phoenix->save(); + $phoenix_id = $phoenix->getId(); + $this->assertFalse($rowling->isNew(), 'saving book also saves related author'); + $this->assertFalse($scholastic->isNew(), 'saving book also saves related publisher'); - // Test Validators - // --------------- + $qs = new Book(); + $qs->setISBN("0380977427"); + $qs->setTitle("Quicksilver"); + $qs->setAuthor($stephenson); + $qs->setPublisher($morrow); + $qs->save(); + $qs_id = $qs->getId(); - require_once 'tools/helpers/bookstore/validator/ISBNValidator.php'; + $dj = new Book(); + $dj->setISBN("0140422161"); + $dj->setTitle("Don Juan"); + $dj->setAuthor($byron); + $dj->setPublisher($penguin); + $dj->save(); + $dj_id = $qs->getId(); - $bk1 = new Book(); - $bk1->setTitle("12345"); // min length is 10 - $ret = $bk1->validate(); - - $this->assertFalse($ret, 'validation failed'); - $failures = $bk1->getValidationFailures(); - $this->assertEquals(1, count($failures), '1 validation message was returned'); - - $el = array_shift($failures); - $this->assertContains("must be more than", $el->getMessage(), 'Expected validation message was returned'); - - $bk2 = new Book(); - $bk2->setTitle("Don Juan"); - $ret = $bk2->validate(); - - $this->assertFalse($ret, 'validation failed'); - - $failures = $bk2->getValidationFailures(); - $this->assertEquals(1, count($failures), '1 validation message was returned'); - - $el = array_shift($failures); - $this->assertContains("Book title already in database.", $el->getMessage(), 'Expected validation message was returned'); - - //Now trying some more complex validation. - $auth1 = new Author(); - $auth1->setFirstName("Hans"); - // last name required; will fail - - $bk1->setAuthor($auth1); - - $rev1 = new Review(); - $rev1->setReviewDate("08/09/2001"); - // will fail: reviewed_by column required - - $bk1->addReview($rev1); - - $ret2 = $bk1->validate(); - $this->assertFalse($ret2, 'validation failed'); - - $failures2 = $bk1->getValidationFailures(); - - $this->assertEquals(3, count($failures2), '3 validation messages were returned'); - - $expectedKeys = array( - AuthorPeer::LAST_NAME, - BookPeer::TITLE, - ReviewPeer::REVIEWED_BY, - ); - $this->assertEquals($expectedKeys, array_keys($failures2), 'correct columns failed'); - - $bk2 = new Book(); - $bk2->setTitle("12345678901"); // passes - - $auth2 = new Author(); - $auth2->setLastName("Blah"); //passes - $auth2->setEmail("some@body.com"); //passes - $auth2->setAge(50); //passes - $bk2->setAuthor($auth2); - - $rev2 = new Review(); - $rev2->setReviewedBy("Me!"); // passes - $rev2->setStatus("new"); // passes - $bk2->addReview($rev2); - - $ret3 = $bk2->validate(); - - $this->assertTrue($ret3, 'complex validation can pass'); + $td = new Book(); + $td->setISBN("067972575X"); + $td->setTitle("The Tin Drum"); + $td->setAuthor($grass); + $td->setPublisher($vintage); + $td->save(); + $td_id = $td->getId(); + $this->assertTrue(true, 'Save Book records'); + } catch (Exception $e) { + $this->fail('Save Author records'); + } - // Testing doCount() functionality - // ------------------------------- - - // old way - $c = new Criteria(); - $records = BookPeer::doSelect($c); - $count = BookPeer::doCount($c); - $this->assertEquals($count, count($records), 'correct number of results'); - - // new way - $count = BookQuery::create()->count(); - $this->assertEquals($count, count($records), 'correct number of results'); + // Add review records + // ------------------ - // Test many-to-many relationships - // --------------- + try { + $r1 = new Review(); + $r1->setBook($phoenix); + $r1->setReviewedBy("Washington Post"); + $r1->setRecommended(true); + $r1->setReviewDate(time()); + $r1->save(); + $r1_id = $r1->getId(); - // init book club list 1 with 2 books - - $blc1 = new BookClubList(); - $blc1->setGroupLeader("Crazyleggs"); - $blc1->setTheme("Happiness"); - - $brel1 = new BookListRel(); - $brel1->setBook($phoenix); - - $brel2 = new BookListRel(); - $brel2->setBook($dj); - - $blc1->addBookListRel($brel1); - $blc1->addBookListRel($brel2); - - $blc1->save(); - - $this->assertNotNull($blc1->getId(), 'BookClubList 1 was saved'); - - // init book club list 2 with 1 book - - $blc2 = new BookClubList(); - $blc2->setGroupLeader("John Foo"); - $blc2->setTheme("Default"); - - $brel3 = new BookListRel(); - $brel3->setBook($phoenix); - - $blc2->addBookListRel($brel3); - - $blc2->save(); - - $this->assertNotNull($blc2->getId(), 'BookClubList 2 was saved'); - - // re-fetch books and lists from db to be sure that nothing is cached - - $crit = new Criteria(); - $crit->add(BookPeer::ID, $phoenix->getId()); - $phoenix = BookPeer::doSelectOne($crit); - $this->assertNotNull($phoenix, "book 'phoenix' has been re-fetched from db"); - - $crit = new Criteria(); - $crit->add(BookClubListPeer::ID, $blc1->getId()); - $blc1 = BookClubListPeer::doSelectOne($crit); - $this->assertNotNull($blc1, 'BookClubList 1 has been re-fetched from db'); - - $crit = new Criteria(); - $crit->add(BookClubListPeer::ID, $blc2->getId()); - $blc2 = BookClubListPeer::doSelectOne($crit); - $this->assertNotNull($blc2, 'BookClubList 2 has been re-fetched from db'); - - $relCount = $phoenix->countBookListRels(); - $this->assertEquals(2, $relCount, "book 'phoenix' has 2 BookListRels"); - - $relCount = $blc1->countBookListRels(); - $this->assertEquals(2, $relCount, 'BookClubList 1 has 2 BookListRels'); - - $relCount = $blc2->countBookListRels(); - $this->assertEquals(1, $relCount, 'BookClubList 2 has 1 BookListRel'); - - // Cleanup (tests DELETE) - // ---------------------- - - // Removing books that were just created - // First finding book by PK (=$phoenix_id) .... - $hp = BookQuery::create()->findPk($phoenix_id); - $this->assertNotNull($hp, 'Could find just-created book'); - - // Attempting to delete [multi-table] by found pk - $c = new Criteria(); - $c->add(BookPeer::ID, $hp->getId()); - // The only way for cascading to work currently - // is to specify the author_id and publisher_id (i.e. the fkeys - // have to be in the criteria). - $c->add(AuthorPeer::ID, $hp->getAuthor()->getId()); - $c->add(PublisherPeer::ID, $hp->getPublisher()->getId()); - $c->setSingleRecord(true); - BookPeer::doDelete($c); - - // Checking to make sure correct records were removed. - $this->assertEquals(3, AuthorPeer::doCount(new Criteria()), 'Correct records were removed from author table'); - $this->assertEquals(3, PublisherPeer::doCount(new Criteria()), 'Correct records were removed from publisher table'); - $this->assertEquals(3, BookPeer::doCount(new Criteria()), 'Correct records were removed from book table'); - - // Attempting to delete books by complex criteria - BookQuery::create() - ->filterByISBN("043935806X") - ->orWhere('Book.ISBN = ?', "0380977427") - ->orWhere('Book.ISBN = ?', "0140422161") - ->delete(); - - // Attempting to delete book [id = $td_id] - $td->delete(); - - // Attempting to delete authors - AuthorQuery::create()->filterById($stephenson_id)->delete(); - AuthorQuery::create()->filterById($byron_id)->delete(); - $grass->delete(); + $r2 = new Review(); + $r2->setBook($phoenix); + $r2->setReviewedBy("New York Times"); + $r2->setRecommended(false); + $r2->setReviewDate(time()); + $r2->save(); + $r2_id = $r2->getId(); + $this->assertTrue(true, 'Save Review records'); + } catch (Exception $e) { + $this->fail('Save Review records'); + } - // Attempting to delete publishers - PublisherQuery::create()->filterById($morrow_id)->delete(); - PublisherQuery::create()->filterById($penguin_id)->delete(); - $vintage->delete(); - - // These have to be deleted manually also since we have onDelete - // set to SETNULL in the foreign keys in book. Is this correct? - $rowling->delete(); - $scholastic->delete(); - $blc1->delete(); - $blc2->delete(); - - $this->assertEquals(array(), AuthorPeer::doSelect(new Criteria()), 'no records in [author] table'); - $this->assertEquals(array(), PublisherPeer::doSelect(new Criteria()), 'no records in [publisher] table'); - $this->assertEquals(array(), BookPeer::doSelect(new Criteria()), 'no records in [book] table'); - $this->assertEquals(array(), ReviewPeer::doSelect(new Criteria()), 'no records in [review] table'); - $this->assertEquals(array(), MediaPeer::doSelect(new Criteria()), 'no records in [media] table'); - $this->assertEquals(array(), BookClubListPeer::doSelect(new Criteria()), 'no records in [book_club_list] table'); - $this->assertEquals(array(), BookListRelPeer::doSelect(new Criteria()), 'no records in [book_x_list] table'); - } -} \ No newline at end of file + // Perform a "complex" search + // -------------------------- + + $crit = new Criteria(); + $crit->add(BookPeer::TITLE, 'Harry%', Criteria::LIKE); + $results = BookPeer::doSelect($crit); + $this->assertEquals(1, count($results)); + + $crit2 = new Criteria(); + $crit2->add(BookPeer::ISBN, array("0380977427", "0140422161"), Criteria::IN); + $results = BookPeer::doSelect($crit2); + $this->assertEquals(2, count($results)); + + // Perform a "limit" search + // ------------------------ + + $crit = new Criteria(); + $crit->setLimit(2); + $crit->setOffset(1); + $crit->addAscendingOrderByColumn(BookPeer::TITLE); + + $results = BookPeer::doSelect($crit); + $this->assertEquals(2, count($results)); + + // we ordered on book title, so we expect to get + $this->assertEquals("Harry Potter and the Order of the Phoenix", $results[0]->getTitle()); + $this->assertEquals("Quicksilver", $results[1]->getTitle()); + + // Perform a lookup & update! + // -------------------------- + + // Updating just-created book title + // First finding book by PK (=$qs_id) .... + $qs_lookup = BookPeer::retrieveByPk($qs_id); + $this->assertNotNull($qs_lookup, 'just-created book can be found by pk'); + + $new_title = "Quicksilver (".crc32(uniqid(rand())).")"; + // Attempting to update found object + $qs_lookup->setTitle($new_title); + $qs_lookup->save(); + + // Making sure object was correctly updated: "; + $qs_lookup2 = BookPeer::retrieveByPk($qs_id); + $this->assertEquals($new_title, $qs_lookup2->getTitle()); + + // Test some basic DATE / TIME stuff + // --------------------------------- + + // that's the control timestamp. + $control = strtotime('2004-02-29 00:00:00'); + + // should be two in the db + $r = ReviewPeer::doSelectOne(new Criteria()); + $r_id = $r->getId(); + $r->setReviewDate($control); + $r->save(); + + $r2 = ReviewPeer::retrieveByPk($r_id); + + $this->assertEquals(new Datetime('2004-02-29 00:00:00'), $r2->getReviewDate(null), 'ability to fetch DateTime'); + $this->assertEquals($control, $r2->getReviewDate('U'), 'ability to fetch native unix timestamp'); + $this->assertEquals('2-29-2004', $r2->getReviewDate('n-j-Y'), 'ability to use date() formatter'); + + // Handle BLOB/CLOB Columns + // ------------------------ + + $blob_path = dirname(__FILE__) . '/../../etc/lob/tin_drum.gif'; + $blob2_path = dirname(__FILE__) . '/../../etc/lob/propel.gif'; + $clob_path = dirname(__FILE__) . '/../../etc/lob/tin_drum.txt'; + + $m1 = new Media(); + $m1->setBook($phoenix); + $m1->setCoverImage(file_get_contents($blob_path)); + $m1->setExcerpt(file_get_contents($clob_path)); + $m1->save(); + $m1_id = $m1->getId(); + + $m1_lookup = MediaPeer::retrieveByPk($m1_id); + + $this->assertNotNull($m1_lookup, 'Can find just-created media item'); + $this->assertEquals(md5(file_get_contents($blob_path)), md5(stream_get_contents($m1_lookup->getCoverImage())), 'BLOB was correctly updated'); + $this->assertEquals(file_get_contents($clob_path), (string) $m1_lookup->getExcerpt(), 'CLOB was correctly updated'); + + // now update the BLOB column and save it & check the results + $m1_lookup->setCoverImage(file_get_contents($blob2_path)); + $m1_lookup->save(); + + $m2_lookup = MediaPeer::retrieveByPk($m1_id); + $this->assertNotNull($m2_lookup, 'Can find just-created media item'); + + $this->assertEquals(md5(file_get_contents($blob2_path)), md5(stream_get_contents($m2_lookup->getCoverImage())), 'BLOB was correctly overwritten'); + + // Test Validators + // --------------- + + require_once dirname(__FILE__) . '/../../tools/helpers/bookstore/validator/ISBNValidator.php'; + + $bk1 = new Book(); + $bk1->setTitle("12345"); // min length is 10 + $ret = $bk1->validate(); + + $this->assertFalse($ret, 'validation failed'); + $failures = $bk1->getValidationFailures(); + $this->assertEquals(1, count($failures), '1 validation message was returned'); + + $el = array_shift($failures); + $this->assertContains("must be more than", $el->getMessage(), 'Expected validation message was returned'); + + $bk2 = new Book(); + $bk2->setTitle("Don Juan"); + $ret = $bk2->validate(); + + $this->assertFalse($ret, 'validation failed'); + + $failures = $bk2->getValidationFailures(); + $this->assertEquals(1, count($failures), '1 validation message was returned'); + + $el = array_shift($failures); + $this->assertContains("Book title already in database.", $el->getMessage(), 'Expected validation message was returned'); + + //Now trying some more complex validation. + $auth1 = new Author(); + $auth1->setFirstName("Hans"); + // last name required; will fail + + $bk1->setAuthor($auth1); + + $rev1 = new Review(); + $rev1->setReviewDate("08/09/2001"); + // will fail: reviewed_by column required + + $bk1->addReview($rev1); + + $ret2 = $bk1->validate(); + $this->assertFalse($ret2, 'validation failed'); + + $failures2 = $bk1->getValidationFailures(); + + $this->assertEquals(3, count($failures2), '3 validation messages were returned'); + + $expectedKeys = array( + AuthorPeer::LAST_NAME, + BookPeer::TITLE, + ReviewPeer::REVIEWED_BY, + ); + $this->assertEquals($expectedKeys, array_keys($failures2), 'correct columns failed'); + + $bk2 = new Book(); + $bk2->setTitle("12345678901"); // passes + + $auth2 = new Author(); + $auth2->setLastName("Blah"); //passes + $auth2->setEmail("some@body.com"); //passes + $auth2->setAge(50); //passes + $bk2->setAuthor($auth2); + + $rev2 = new Review(); + $rev2->setReviewedBy("Me!"); // passes + $rev2->setStatus("new"); // passes + $bk2->addReview($rev2); + + $ret3 = $bk2->validate(); + + $this->assertTrue($ret3, 'complex validation can pass'); + + // Testing doCount() functionality + // ------------------------------- + + $c = new Criteria(); + $records = BookPeer::doSelect($c); + $count = BookPeer::doCount($c); + + $this->assertEquals($count, count($records), 'correct number of results'); + + // Test many-to-many relationships + // --------------- + + // init book club list 1 with 2 books + + $blc1 = new BookClubList(); + $blc1->setGroupLeader("Crazyleggs"); + $blc1->setTheme("Happiness"); + + $brel1 = new BookListRel(); + $brel1->setBook($phoenix); + + $brel2 = new BookListRel(); + $brel2->setBook($dj); + + $blc1->addBookListRel($brel1); + $blc1->addBookListRel($brel2); + + $blc1->save(); + + $this->assertNotNull($blc1->getId(), 'BookClubList 1 was saved'); + + // init book club list 2 with 1 book + + $blc2 = new BookClubList(); + $blc2->setGroupLeader("John Foo"); + $blc2->setTheme("Default"); + + $brel3 = new BookListRel(); + $brel3->setBook($phoenix); + + $blc2->addBookListRel($brel3); + + $blc2->save(); + + $this->assertNotNull($blc2->getId(), 'BookClubList 2 was saved'); + + // re-fetch books and lists from db to be sure that nothing is cached + + $crit = new Criteria(); + $crit->add(BookPeer::ID, $phoenix->getId()); + $phoenix = BookPeer::doSelectOne($crit); + $this->assertNotNull($phoenix, "book 'phoenix' has been re-fetched from db"); + + $crit = new Criteria(); + $crit->add(BookClubListPeer::ID, $blc1->getId()); + $blc1 = BookClubListPeer::doSelectOne($crit); + $this->assertNotNull($blc1, 'BookClubList 1 has been re-fetched from db'); + + $crit = new Criteria(); + $crit->add(BookClubListPeer::ID, $blc2->getId()); + $blc2 = BookClubListPeer::doSelectOne($crit); + $this->assertNotNull($blc2, 'BookClubList 2 has been re-fetched from db'); + + $relCount = $phoenix->countBookListRels(); + $this->assertEquals(2, $relCount, "book 'phoenix' has 2 BookListRels"); + + $relCount = $blc1->countBookListRels(); + $this->assertEquals(2, $relCount, 'BookClubList 1 has 2 BookListRels'); + + $relCount = $blc2->countBookListRels(); + $this->assertEquals(1, $relCount, 'BookClubList 2 has 1 BookListRel'); + + // Cleanup (tests DELETE) + // ---------------------- + + // Removing books that were just created + // First finding book by PK (=$phoenix_id) .... + $hp = BookPeer::retrieveByPk($phoenix_id); + $this->assertNotNull($hp, 'Could find just-created book'); + + // Attempting to delete [multi-table] by found pk + $c = new Criteria(); + $c->add(BookPeer::ID, $hp->getId()); + // The only way for cascading to work currently + // is to specify the author_id and publisher_id (i.e. the fkeys + // have to be in the criteria). + $c->add(AuthorPeer::ID, $hp->getAuthor()->getId()); + $c->add(PublisherPeer::ID, $hp->getPublisher()->getId()); + $c->setSingleRecord(true); + BookPeer::doDelete($c); + + // Checking to make sure correct records were removed. + $this->assertEquals(3, AuthorPeer::doCount(new Criteria()), 'Correct records were removed from author table'); + $this->assertEquals(3, PublisherPeer::doCount(new Criteria()), 'Correct records were removed from publisher table'); + $this->assertEquals(3, BookPeer::doCount(new Criteria()), 'Correct records were removed from book table'); + + // Attempting to delete books by complex criteria + $c = new Criteria(); + $cn = $c->getNewCriterion(BookPeer::ISBN, "043935806X"); + $cn->addOr($c->getNewCriterion(BookPeer::ISBN, "0380977427")); + $cn->addOr($c->getNewCriterion(BookPeer::ISBN, "0140422161")); + $c->add($cn); + BookPeer::doDelete($c); + + // Attempting to delete book [id = $td_id] + $td->delete(); + + // Attempting to delete authors + AuthorPeer::doDelete($stephenson_id); + AuthorPeer::doDelete($byron_id); + $grass->delete(); + + // Attempting to delete publishers + PublisherPeer::doDelete($morrow_id); + PublisherPeer::doDelete($penguin_id); + $vintage->delete(); + + // These have to be deleted manually also since we have onDelete + // set to SETNULL in the foreign keys in book. Is this correct? + $rowling->delete(); + $scholastic->delete(); + $blc1->delete(); + $blc2->delete(); + + $this->assertEquals(array(), AuthorPeer::doSelect(new Criteria()), 'no records in [author] table'); + $this->assertEquals(array(), PublisherPeer::doSelect(new Criteria()), 'no records in [publisher] table'); + $this->assertEquals(array(), BookPeer::doSelect(new Criteria()), 'no records in [book] table'); + $this->assertEquals(array(), ReviewPeer::doSelect(new Criteria()), 'no records in [review] table'); + $this->assertEquals(array(), MediaPeer::doSelect(new Criteria()), 'no records in [media] table'); + $this->assertEquals(array(), BookClubListPeer::doSelect(new Criteria()), 'no records in [book_club_list] table'); + $this->assertEquals(array(), BookListRelPeer::doSelect(new Criteria()), 'no records in [book_x_list] table'); + + } + + public function testScenarioUsingQuery() + { + // Add publisher records + // --------------------- + + try { + $scholastic = new Publisher(); + $scholastic->setName("Scholastic"); + // do not save, will do later to test cascade + + $morrow = new Publisher(); + $morrow->setName("William Morrow"); + $morrow->save(); + $morrow_id = $morrow->getId(); + + $penguin = new Publisher(); + $penguin->setName("Penguin"); + $penguin->save(); + $penguin_id = $penguin->getId(); + + $vintage = new Publisher(); + $vintage->setName("Vintage"); + $vintage->save(); + $vintage_id = $vintage->getId(); + $this->assertTrue(true, 'Save Publisher records'); + } catch (Exception $e) { + $this->fail('Save publisher records'); + } + + // Add author records + // ------------------ + + try { + $rowling = new Author(); + $rowling->setFirstName("J.K."); + $rowling->setLastName("Rowling"); + // do not save, will do later to test cascade + + $stephenson = new Author(); + $stephenson->setFirstName("Neal"); + $stephenson->setLastName("Stephenson"); + $stephenson->save(); + $stephenson_id = $stephenson->getId(); + + $byron = new Author(); + $byron->setFirstName("George"); + $byron->setLastName("Byron"); + $byron->save(); + $byron_id = $byron->getId(); + + $grass = new Author(); + $grass->setFirstName("Gunter"); + $grass->setLastName("Grass"); + $grass->save(); + $grass_id = $grass->getId(); + $this->assertTrue(true, 'Save Author records'); + } catch (Exception $e) { + $this->fail('Save Author records'); + } + + // Add book records + // ---------------- + + try { + $phoenix = new Book(); + $phoenix->setTitle("Harry Potter and the Order of the Phoenix"); + $phoenix->setISBN("043935806X"); + $phoenix->setAuthor($rowling); + $phoenix->setPublisher($scholastic); + $phoenix->save(); + $phoenix_id = $phoenix->getId(); + $this->assertFalse($rowling->isNew(), 'saving book also saves related author'); + $this->assertFalse($scholastic->isNew(), 'saving book also saves related publisher'); + + $qs = new Book(); + $qs->setISBN("0380977427"); + $qs->setTitle("Quicksilver"); + $qs->setAuthor($stephenson); + $qs->setPublisher($morrow); + $qs->save(); + $qs_id = $qs->getId(); + + $dj = new Book(); + $dj->setISBN("0140422161"); + $dj->setTitle("Don Juan"); + $dj->setAuthor($byron); + $dj->setPublisher($penguin); + $dj->save(); + $dj_id = $qs->getId(); + + $td = new Book(); + $td->setISBN("067972575X"); + $td->setTitle("The Tin Drum"); + $td->setAuthor($grass); + $td->setPublisher($vintage); + $td->save(); + $td_id = $td->getId(); + $this->assertTrue(true, 'Save Book records'); + } catch (Exception $e) { + $this->fail('Save Author records'); + } + + // Add review records + // ------------------ + + try { + $r1 = new Review(); + $r1->setBook($phoenix); + $r1->setReviewedBy("Washington Post"); + $r1->setRecommended(true); + $r1->setReviewDate(time()); + $r1->save(); + $r1_id = $r1->getId(); + + $r2 = new Review(); + $r2->setBook($phoenix); + $r2->setReviewedBy("New York Times"); + $r2->setRecommended(false); + $r2->setReviewDate(time()); + $r2->save(); + $r2_id = $r2->getId(); + $this->assertTrue(true, 'Save Review records'); + } catch (Exception $e) { + $this->fail('Save Review records'); + } + + // Perform a "complex" search + // -------------------------- + + $results = BookQuery::create() + ->filterByTitle('Harry%') + ->find(); + $this->assertEquals(1, count($results)); + + $results = BookQuery::create() + ->where('Book.ISBN IN ?', array("0380977427", "0140422161")) + ->find(); + $this->assertEquals(2, count($results)); + + // Perform a "limit" search + // ------------------------ + + $results = BookQuery::create() + ->limit(2) + ->offset(1) + ->orderByTitle() + ->find(); + $this->assertEquals(2, count($results)); + // we ordered on book title, so we expect to get + $this->assertEquals("Harry Potter and the Order of the Phoenix", $results[0]->getTitle()); + $this->assertEquals("Quicksilver", $results[1]->getTitle()); + + // Perform a lookup & update! + // -------------------------- + + // Updating just-created book title + // First finding book by PK (=$qs_id) .... + $qs_lookup = BookQuery::create()->findPk($qs_id); + $this->assertNotNull($qs_lookup, 'just-created book can be found by pk'); + + $new_title = "Quicksilver (".crc32(uniqid(rand())).")"; + // Attempting to update found object + $qs_lookup->setTitle($new_title); + $qs_lookup->save(); + + // Making sure object was correctly updated: "; + $qs_lookup2 = BookQuery::create()->findPk($qs_id); + $this->assertEquals($new_title, $qs_lookup2->getTitle()); + + // Test some basic DATE / TIME stuff + // --------------------------------- + + // that's the control timestamp. + $control = strtotime('2004-02-29 00:00:00'); + + // should be two in the db + $r = ReviewQuery::create()->findOne(); + $r_id = $r->getId(); + $r->setReviewDate($control); + $r->save(); + + $r2 = ReviewQuery::create()->findPk($r_id); + $this->assertEquals(new Datetime('2004-02-29 00:00:00'), $r2->getReviewDate(null), 'ability to fetch DateTime'); + $this->assertEquals($control, $r2->getReviewDate('U'), 'ability to fetch native unix timestamp'); + $this->assertEquals('2-29-2004', $r2->getReviewDate('n-j-Y'), 'ability to use date() formatter'); + + // Handle BLOB/CLOB Columns + // ------------------------ + + $blob_path = dirname(__FILE__) . '/../../etc/lob/tin_drum.gif'; + $blob2_path = dirname(__FILE__) . '/../../etc/lob/propel.gif'; + $clob_path = dirname(__FILE__) . '/../../etc/lob/tin_drum.txt'; + + $m1 = new Media(); + $m1->setBook($phoenix); + $m1->setCoverImage(file_get_contents($blob_path)); + $m1->setExcerpt(file_get_contents($clob_path)); + $m1->save(); + $m1_id = $m1->getId(); + + $m1_lookup = MediaQuery::create()->findPk($m1_id); + + $this->assertNotNull($m1_lookup, 'Can find just-created media item'); + $this->assertEquals(md5(file_get_contents($blob_path)), md5(stream_get_contents($m1_lookup->getCoverImage())), 'BLOB was correctly updated'); + $this->assertEquals(file_get_contents($clob_path), (string) $m1_lookup->getExcerpt(), 'CLOB was correctly updated'); + + // now update the BLOB column and save it & check the results + $m1_lookup->setCoverImage(file_get_contents($blob2_path)); + $m1_lookup->save(); + + $m2_lookup = MediaQuery::create()->findPk($m1_id); + $this->assertNotNull($m2_lookup, 'Can find just-created media item'); + + $this->assertEquals(md5(file_get_contents($blob2_path)), md5(stream_get_contents($m2_lookup->getCoverImage())), 'BLOB was correctly overwritten'); + + // Test Validators + // --------------- + + require_once dirname(__FILE__) . '/../../tools/helpers/bookstore/validator/ISBNValidator.php'; + + $bk1 = new Book(); + $bk1->setTitle("12345"); // min length is 10 + $ret = $bk1->validate(); + + $this->assertFalse($ret, 'validation failed'); + $failures = $bk1->getValidationFailures(); + $this->assertEquals(1, count($failures), '1 validation message was returned'); + + $el = array_shift($failures); + $this->assertContains("must be more than", $el->getMessage(), 'Expected validation message was returned'); + + $bk2 = new Book(); + $bk2->setTitle("Don Juan"); + $ret = $bk2->validate(); + + $this->assertFalse($ret, 'validation failed'); + + $failures = $bk2->getValidationFailures(); + $this->assertEquals(1, count($failures), '1 validation message was returned'); + + $el = array_shift($failures); + $this->assertContains("Book title already in database.", $el->getMessage(), 'Expected validation message was returned'); + + //Now trying some more complex validation. + $auth1 = new Author(); + $auth1->setFirstName("Hans"); + // last name required; will fail + + $bk1->setAuthor($auth1); + + $rev1 = new Review(); + $rev1->setReviewDate("08/09/2001"); + // will fail: reviewed_by column required + + $bk1->addReview($rev1); + + $ret2 = $bk1->validate(); + $this->assertFalse($ret2, 'validation failed'); + + $failures2 = $bk1->getValidationFailures(); + + $this->assertEquals(3, count($failures2), '3 validation messages were returned'); + + $expectedKeys = array( + AuthorPeer::LAST_NAME, + BookPeer::TITLE, + ReviewPeer::REVIEWED_BY, + ); + $this->assertEquals($expectedKeys, array_keys($failures2), 'correct columns failed'); + + $bk2 = new Book(); + $bk2->setTitle("12345678901"); // passes + + $auth2 = new Author(); + $auth2->setLastName("Blah"); //passes + $auth2->setEmail("some@body.com"); //passes + $auth2->setAge(50); //passes + $bk2->setAuthor($auth2); + + $rev2 = new Review(); + $rev2->setReviewedBy("Me!"); // passes + $rev2->setStatus("new"); // passes + $bk2->addReview($rev2); + + $ret3 = $bk2->validate(); + + $this->assertTrue($ret3, 'complex validation can pass'); + + // Testing doCount() functionality + // ------------------------------- + + // old way + $c = new Criteria(); + $records = BookPeer::doSelect($c); + $count = BookPeer::doCount($c); + $this->assertEquals($count, count($records), 'correct number of results'); + + // new way + $count = BookQuery::create()->count(); + $this->assertEquals($count, count($records), 'correct number of results'); + + // Test many-to-many relationships + // --------------- + + // init book club list 1 with 2 books + + $blc1 = new BookClubList(); + $blc1->setGroupLeader("Crazyleggs"); + $blc1->setTheme("Happiness"); + + $brel1 = new BookListRel(); + $brel1->setBook($phoenix); + + $brel2 = new BookListRel(); + $brel2->setBook($dj); + + $blc1->addBookListRel($brel1); + $blc1->addBookListRel($brel2); + + $blc1->save(); + + $this->assertNotNull($blc1->getId(), 'BookClubList 1 was saved'); + + // init book club list 2 with 1 book + + $blc2 = new BookClubList(); + $blc2->setGroupLeader("John Foo"); + $blc2->setTheme("Default"); + + $brel3 = new BookListRel(); + $brel3->setBook($phoenix); + + $blc2->addBookListRel($brel3); + + $blc2->save(); + + $this->assertNotNull($blc2->getId(), 'BookClubList 2 was saved'); + + // re-fetch books and lists from db to be sure that nothing is cached + + $crit = new Criteria(); + $crit->add(BookPeer::ID, $phoenix->getId()); + $phoenix = BookPeer::doSelectOne($crit); + $this->assertNotNull($phoenix, "book 'phoenix' has been re-fetched from db"); + + $crit = new Criteria(); + $crit->add(BookClubListPeer::ID, $blc1->getId()); + $blc1 = BookClubListPeer::doSelectOne($crit); + $this->assertNotNull($blc1, 'BookClubList 1 has been re-fetched from db'); + + $crit = new Criteria(); + $crit->add(BookClubListPeer::ID, $blc2->getId()); + $blc2 = BookClubListPeer::doSelectOne($crit); + $this->assertNotNull($blc2, 'BookClubList 2 has been re-fetched from db'); + + $relCount = $phoenix->countBookListRels(); + $this->assertEquals(2, $relCount, "book 'phoenix' has 2 BookListRels"); + + $relCount = $blc1->countBookListRels(); + $this->assertEquals(2, $relCount, 'BookClubList 1 has 2 BookListRels'); + + $relCount = $blc2->countBookListRels(); + $this->assertEquals(1, $relCount, 'BookClubList 2 has 1 BookListRel'); + + // Test collection setter for cross reference with custom relation names for the FK's. + + $booksCollection = BookQuery::create()->setLimit(4)->find(); + + $blc3 = new BookClubList(); + $blc3->setGroupLeader('Something'); + $blc3->setFavoriteBooks($booksCollection); + $blc3->save(); + + $blc3->reload(true); + + $this->assertEquals(4, $blc3->countBookListFavorites(), "BookClubList has 4 favorites"); + + // Test set collection with less values, removing the missing and skipping the existing to prevent duplicate key. + + $booksCollection = BookQuery::create()->setLimit(2)->find(); + + $blc3->reload(true); + + $blc3->setFavoriteBooks($booksCollection); + $blc3->save(); + + $blc3->reload(true); + + $this->assertEquals(2, $blc3->countBookListFavorites(), "BookClubList has 2 favorites after setting new collection"); + + // Cleanup (tests DELETE) + // ---------------------- + + // Removing books that were just created + // First finding book by PK (=$phoenix_id) .... + $hp = BookQuery::create()->findPk($phoenix_id); + $this->assertNotNull($hp, 'Could find just-created book'); + + // Attempting to delete [multi-table] by found pk + $c = new Criteria(); + $c->add(BookPeer::ID, $hp->getId()); + // The only way for cascading to work currently + // is to specify the author_id and publisher_id (i.e. the fkeys + // have to be in the criteria). + $c->add(AuthorPeer::ID, $hp->getAuthor()->getId()); + $c->add(PublisherPeer::ID, $hp->getPublisher()->getId()); + $c->setSingleRecord(true); + BookPeer::doDelete($c); + + // Checking to make sure correct records were removed. + $this->assertEquals(3, AuthorPeer::doCount(new Criteria()), 'Correct records were removed from author table'); + $this->assertEquals(3, PublisherPeer::doCount(new Criteria()), 'Correct records were removed from publisher table'); + $this->assertEquals(3, BookPeer::doCount(new Criteria()), 'Correct records were removed from book table'); + + // Attempting to delete books by complex criteria + BookQuery::create() + ->filterByISBN("043935806X") + ->orWhere('Book.ISBN = ?', "0380977427") + ->orWhere('Book.ISBN = ?', "0140422161") + ->delete(); + + // Attempting to delete book [id = $td_id] + $td->delete(); + + // Attempting to delete authors + AuthorQuery::create()->filterById($stephenson_id)->delete(); + AuthorQuery::create()->filterById($byron_id)->delete(); + $grass->delete(); + + // Attempting to delete publishers + PublisherQuery::create()->filterById($morrow_id)->delete(); + PublisherQuery::create()->filterById($penguin_id)->delete(); + $vintage->delete(); + + // These have to be deleted manually also since we have onDelete + // set to SETNULL in the foreign keys in book. Is this correct? + $rowling->delete(); + $scholastic->delete(); + $blc1->delete(); + $blc2->delete(); + $blc3->delete(); + + $this->assertEquals(array(), AuthorPeer::doSelect(new Criteria()), 'no records in [author] table'); + $this->assertEquals(array(), PublisherPeer::doSelect(new Criteria()), 'no records in [publisher] table'); + $this->assertEquals(array(), BookPeer::doSelect(new Criteria()), 'no records in [book] table'); + $this->assertEquals(array(), ReviewPeer::doSelect(new Criteria()), 'no records in [review] table'); + $this->assertEquals(array(), MediaPeer::doSelect(new Criteria()), 'no records in [media] table'); + $this->assertEquals(array(), BookClubListPeer::doSelect(new Criteria()), 'no records in [book_club_list] table'); + $this->assertEquals(array(), BookListRelPeer::doSelect(new Criteria()), 'no records in [book_x_list] table'); + $this->assertEquals(array(), BookListFavoritePeer::doSelect(new Criteria()), 'no records in [book_club_list_favorite_books] table'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/misc/CharacterEncodingTest.php b/airtime_mvc/library/propel/test/testsuite/misc/CharacterEncodingTest.php index dfc9c03e7..4c0a4c1a2 100644 --- a/airtime_mvc/library/propel/test/testsuite/misc/CharacterEncodingTest.php +++ b/airtime_mvc/library/propel/test/testsuite/misc/CharacterEncodingTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../tools/helpers/bookstore/BookstoreTestBase.php'; /** * Tests the character encoding support of the adapter. @@ -16,7 +16,7 @@ require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; * This test assumes that the created database supports UTF-8. For this to work, * this file also has to be UTF-8. * - * The database is relaoded before every test and flushed after every test. This + * The database is reloaded before every test and flushed after every test. This * means that you can always rely on the contents of the databases being the same * for each test method in this class. See the BookstoreDataPopulator::populate() * method for the exact contents of the database. @@ -27,86 +27,86 @@ require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; */ class CharacterEncodingTest extends BookstoreTestBase { - /** - * Database adapter. - * @var DBAdapter - */ - private $adapter; + /** + * Database adapter. + * @var DBAdapter + */ + private $adapter; - public function setUp() - { - parent::setUp(); - if (!extension_loaded('iconv')) { - throw new Exception("Character-encoding tests require iconv extension to be loaded."); - } - } + public function setUp() + { + parent::setUp(); + if (!extension_loaded('iconv')) { + throw new Exception("Character-encoding tests require iconv extension to be loaded."); + } + } - public function testUtf8() - { - $this->markTestSkipped(); - - $db = Propel::getDB(BookPeer::DATABASE_NAME); + public function testUtf8() + { + $this->markTestSkipped(); - $title = "Смерть на брудершафт. Младенец и черт"; - // 1234567890123456789012345678901234567 - // 1 2 3 + $db = Propel::getDB(BookPeer::DATABASE_NAME); - $a = new Author(); - $a->setFirstName("Б."); - $a->setLastName("ÐКУÐИÐ"); + $title = "Смерть на брудершафт. Младенец и черт"; + // 1234567890123456789012345678901234567 + // 1 2 3 - $p = new Publisher(); - $p->setName("Детектив роÑÑийÑкий, оÑтроÑÑŽÐ¶ÐµÑ‚Ð½Ð°Ñ Ð¿Ñ€Ð¾Ð·Ð°"); + $a = new Author(); + $a->setFirstName("Б."); + $a->setLastName("ÐКУÐИÐ"); - $b = new Book(); - $b->setTitle($title); - $b->setISBN("B-59246"); - $b->setAuthor($a); - $b->setPublisher($p); - $b->save(); + $p = new Publisher(); + $p->setName("Детектив роÑÑийÑкий, оÑтроÑÑŽÐ¶ÐµÑ‚Ð½Ð°Ñ Ð¿Ñ€Ð¾Ð·Ð°"); - $b->reload(); + $b = new Book(); + $b->setTitle($title); + $b->setISBN("B-59246"); + $b->setAuthor($a); + $b->setPublisher($p); + $b->save(); - $this->assertEquals(37, iconv_strlen($b->getTitle(), 'utf-8'), "Expected 37 characters (not bytes) in title."); - $this->assertTrue(strlen($b->getTitle()) > iconv_strlen($b->getTitle(), 'utf-8'), "Expected more bytes than characters in title."); + $b->reload(); - } + $this->assertEquals(37, iconv_strlen($b->getTitle(), 'utf-8'), "Expected 37 characters (not bytes) in title."); + $this->assertTrue(strlen($b->getTitle()) > iconv_strlen($b->getTitle(), 'utf-8'), "Expected more bytes than characters in title."); - public function testInvalidCharset() - { - $this->markTestSkipped(); - - $db = Propel::getDB(BookPeer::DATABASE_NAME); - if ($db instanceof DBSQLite) { - $this->markTestSkipped(); - } + } - $a = new Author(); - $a->setFirstName("Б."); - $a->setLastName("ÐКУÐИÐ"); - $a->save(); + public function testInvalidCharset() + { + $this->markTestSkipped(); - $authorNameWindows1251 = iconv("utf-8", "windows-1251", $a->getLastName()); - $a->setLastName($authorNameWindows1251); + $db = Propel::getDB(BookPeer::DATABASE_NAME); + if ($db instanceof DBSQLite) { + $this->markTestSkipped(); + } - // Different databases seem to handle invalid data differently (no surprise, I guess...) - if ($db instanceof DBPostgres) { - try { - $a->save(); - $this->fail("Expected an exception when saving non-UTF8 data to database."); - } catch (Exception $x) { - print $x; - } + $a = new Author(); + $a->setFirstName("Б."); + $a->setLastName("ÐКУÐИÐ"); + $a->save(); - } else { + $authorNameWindows1251 = iconv("utf-8", "windows-1251", $a->getLastName()); + $a->setLastName($authorNameWindows1251); - // No exception is thrown by MySQL ... (others need to be tested still) - $a->save(); - $a->reload(); + // Different databases seem to handle invalid data differently (no surprise, I guess...) + if ($db instanceof DBPostgres) { + try { + $a->save(); + $this->fail("Expected an exception when saving non-UTF8 data to database."); + } catch (Exception $x) { + print $x; + } - $this->assertEquals("",$a->getLastName(), "Expected last_name to be empty (after inserting invalid charset data)"); - } + } else { - } + // No exception is thrown by MySQL ... (others need to be tested still) + $a->save(); + $a->reload(); + + $this->assertEquals("",$a->getLastName(), "Expected last_name to be empty (after inserting invalid charset data)"); + } + + } } diff --git a/airtime_mvc/library/propel/test/testsuite/misc/FieldnameRelatedTest.php b/airtime_mvc/library/propel/test/testsuite/misc/FieldnameRelatedTest.php index fe43a94bb..fd2d80f3d 100644 --- a/airtime_mvc/library/propel/test/testsuite/misc/FieldnameRelatedTest.php +++ b/airtime_mvc/library/propel/test/testsuite/misc/FieldnameRelatedTest.php @@ -8,8 +8,6 @@ * @license MIT License */ -require_once 'PHPUnit/Framework/TestCase.php'; - /** * Tests some of the methods of generated Object classes. These are: * @@ -31,366 +29,368 @@ require_once 'PHPUnit/Framework/TestCase.php'; */ class FieldnameRelatedTest extends PHPUnit_Framework_TestCase { - protected function setUp() - { - parent::setUp(); - set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes"); - require_once 'bookstore/map/BookTableMap.php'; - require_once 'bookstore/BookPeer.php'; - require_once 'bookstore/Book.php'; - } - - /** - * Tests if fieldname type constants are defined - */ - public function testFieldNameTypeConstants () { + protected function setUp() + { + parent::setUp(); - $result = defined('BasePeer::TYPE_PHPNAME'); - $this->assertTrue($result); - } + require_once dirname(__FILE__) . '/../../fixtures/bookstore/build/classes/bookstore/map/BookTableMap.php'; + require_once dirname(__FILE__) . '/../../fixtures/bookstore/build/classes/bookstore/om/BaseBookPeer.php'; + require_once dirname(__FILE__) . '/../../fixtures/bookstore/build/classes/bookstore/BookPeer.php'; + require_once dirname(__FILE__) . '/../../fixtures/bookstore/build/classes/bookstore/om/BaseBook.php'; + require_once dirname(__FILE__) . '/../../fixtures/bookstore/build/classes/bookstore/Book.php'; + } - /** - * Tests the Base[Object]Peer::getFieldNames() method - */ - public function testGetFieldNames () - { - $types = array( - BasePeer::TYPE_PHPNAME, - BasePeer::TYPE_COLNAME, - BasePeer::TYPE_FIELDNAME, - BasePeer::TYPE_NUM - ); - $expecteds = array ( - BasePeer::TYPE_PHPNAME => array( - 0 => 'Id', - 1 => 'Title', - 2 => 'ISBN', - 3 => 'Price', - 4 => 'PublisherId', - 5 => 'AuthorId' - ), - BasePeer::TYPE_STUDLYPHPNAME => array( - 0 => 'id', - 1 => 'title', - 2 => 'iSBN', - 3 => 'price', - 4 => 'publisherId', - 5 => 'authorId' - ), - BasePeer::TYPE_COLNAME => array( - 0 => 'book.ID', - 1 => 'book.TITLE', - 2 => 'book.ISBN', - 3 => 'book.PRICE', - 4 => 'book.PUBLISHER_ID', - 5 => 'book.AUTHOR_ID' - ), - BasePeer::TYPE_FIELDNAME => array( - 0 => 'id', - 1 => 'title', - 2 => 'isbn', - 3 => 'price', - 4 => 'publisher_id', - 5 => 'author_id' - ), - BasePeer::TYPE_NUM => array( - 0 => 0, - 1 => 1, - 2 => 2, - 3 => 3, - 4 => 4, - 5 => 5 - ) - ); + /** + * Tests if fieldname type constants are defined + */ + public function testFieldNameTypeConstants() + { + $result = defined('BasePeer::TYPE_PHPNAME'); + $this->assertTrue($result); + } - foreach ($types as $type) { - $results[$type] = BookPeer::getFieldnames($type); - $this->assertEquals( - $expecteds[$type], - $results[$type], - 'expected was: ' . print_r($expecteds[$type], 1) . - 'but getFieldnames() returned ' . print_r($results[$type], 1) - ); - } - } + /** + * Tests the Base[Object]Peer::getFieldNames() method + */ + public function testGetFieldNames() + { + $types = array( + BasePeer::TYPE_PHPNAME, + BasePeer::TYPE_COLNAME, + BasePeer::TYPE_FIELDNAME, + BasePeer::TYPE_NUM + ); + $expecteds = array ( + BasePeer::TYPE_PHPNAME => array( + 0 => 'Id', + 1 => 'Title', + 2 => 'ISBN', + 3 => 'Price', + 4 => 'PublisherId', + 5 => 'AuthorId' + ), + BasePeer::TYPE_STUDLYPHPNAME => array( + 0 => 'id', + 1 => 'title', + 2 => 'iSBN', + 3 => 'price', + 4 => 'publisherId', + 5 => 'authorId' + ), + BasePeer::TYPE_COLNAME => array( + 0 => 'book.id', + 1 => 'book.title', + 2 => 'book.isbn', + 3 => 'book.price', + 4 => 'book.publisher_id', + 5 => 'book.author_id' + ), + BasePeer::TYPE_FIELDNAME => array( + 0 => 'id', + 1 => 'title', + 2 => 'isbn', + 3 => 'price', + 4 => 'publisher_id', + 5 => 'author_id' + ), + BasePeer::TYPE_NUM => array( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => 4, + 5 => 5 + ) + ); - /** - * Tests the Base[Object]Peer::translateFieldName() method - */ - public function testTranslateFieldName () { + foreach ($types as $type) { + $results[$type] = BookPeer::getFieldnames($type); + $this->assertEquals( + $expecteds[$type], + $results[$type], + 'expected was: ' . print_r($expecteds[$type], 1) . + 'but getFieldnames() returned ' . print_r($results[$type], 1) + ); + } + } - $types = array( - BasePeer::TYPE_PHPNAME, - BasePeer::TYPE_STUDLYPHPNAME, - BasePeer::TYPE_COLNAME, - BasePeer::TYPE_FIELDNAME, - BasePeer::TYPE_NUM - ); - $expecteds = array ( - BasePeer::TYPE_PHPNAME => 'AuthorId', - BasePeer::TYPE_STUDLYPHPNAME => 'authorId', - BasePeer::TYPE_COLNAME => 'book.AUTHOR_ID', - BasePeer::TYPE_FIELDNAME => 'author_id', - BasePeer::TYPE_NUM => 5, - ); - foreach ($types as $fromType) { - foreach ($types as $toType) { - $name = $expecteds[$fromType]; - $expected = $expecteds[$toType]; - $result = BookPeer::translateFieldName($name, $fromType, $toType); - $this->assertEquals($expected, $result); - } - } - } + /** + * Tests the Base[Object]Peer::translateFieldName() method + */ + public function testTranslateFieldName() + { + $types = array( + BasePeer::TYPE_PHPNAME, + BasePeer::TYPE_STUDLYPHPNAME, + BasePeer::TYPE_COLNAME, + BasePeer::TYPE_FIELDNAME, + BasePeer::TYPE_NUM + ); + $expecteds = array ( + BasePeer::TYPE_PHPNAME => 'AuthorId', + BasePeer::TYPE_STUDLYPHPNAME => 'authorId', + BasePeer::TYPE_COLNAME => 'book.author_id', + BasePeer::TYPE_FIELDNAME => 'author_id', + BasePeer::TYPE_NUM => 5, + ); + foreach ($types as $fromType) { + foreach ($types as $toType) { + $name = $expecteds[$fromType]; + $expected = $expecteds[$toType]; + $result = BookPeer::translateFieldName($name, $fromType, $toType); + $this->assertEquals($expected, $result); + } + } + } - /** - * Tests the BasePeer::getFieldNames() method - */ - public function testGetFieldNamesStatic () { + /** + * Tests the BasePeer::getFieldNames() method + */ + public function testGetFieldNamesStatic() + { + $types = array( + BasePeer::TYPE_PHPNAME, + BasePeer::TYPE_STUDLYPHPNAME, + BasePeer::TYPE_COLNAME, + BasePeer::TYPE_FIELDNAME, + BasePeer::TYPE_NUM + ); + $expecteds = array ( + BasePeer::TYPE_PHPNAME => array( + 0 => 'Id', + 1 => 'Title', + 2 => 'ISBN', + 3 => 'Price', + 4 => 'PublisherId', + 5 => 'AuthorId' + ), + BasePeer::TYPE_STUDLYPHPNAME => array( + 0 => 'id', + 1 => 'title', + 2 => 'iSBN', + 3 => 'price', + 4 => 'publisherId', + 5 => 'authorId' + ), + BasePeer::TYPE_COLNAME => array( + 0 => 'book.id', + 1 => 'book.title', + 2 => 'book.isbn', + 3 => 'book.price', + 4 => 'book.publisher_id', + 5 => 'book.author_id' + ), + BasePeer::TYPE_FIELDNAME => array( + 0 => 'id', + 1 => 'title', + 2 => 'isbn', + 3 => 'price', + 4 => 'publisher_id', + 5 => 'author_id' + ), + BasePeer::TYPE_NUM => array( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => 4, + 5 => 5 + ) + ); - $types = array( - BasePeer::TYPE_PHPNAME, - BasePeer::TYPE_STUDLYPHPNAME, - BasePeer::TYPE_COLNAME, - BasePeer::TYPE_FIELDNAME, - BasePeer::TYPE_NUM - ); - $expecteds = array ( - BasePeer::TYPE_PHPNAME => array( - 0 => 'Id', - 1 => 'Title', - 2 => 'ISBN', - 3 => 'Price', - 4 => 'PublisherId', - 5 => 'AuthorId' - ), - BasePeer::TYPE_STUDLYPHPNAME => array( - 0 => 'id', - 1 => 'title', - 2 => 'iSBN', - 3 => 'price', - 4 => 'publisherId', - 5 => 'authorId' - ), - BasePeer::TYPE_COLNAME => array( - 0 => 'book.ID', - 1 => 'book.TITLE', - 2 => 'book.ISBN', - 3 => 'book.PRICE', - 4 => 'book.PUBLISHER_ID', - 5 => 'book.AUTHOR_ID' - ), - BasePeer::TYPE_FIELDNAME => array( - 0 => 'id', - 1 => 'title', - 2 => 'isbn', - 3 => 'price', - 4 => 'publisher_id', - 5 => 'author_id' - ), - BasePeer::TYPE_NUM => array( - 0 => 0, - 1 => 1, - 2 => 2, - 3 => 3, - 4 => 4, - 5 => 5 - ) - ); + foreach ($types as $type) { + $results[$type] = BasePeer::getFieldnames('Book', $type); + $this->assertEquals( + $expecteds[$type], + $results[$type], + 'expected was: ' . print_r($expecteds[$type], 1) . + 'but getFieldnames() returned ' . print_r($results[$type], 1) + ); + } + } - foreach ($types as $type) { - $results[$type] = BasePeer::getFieldnames('Book', $type); - $this->assertEquals( - $expecteds[$type], - $results[$type], - 'expected was: ' . print_r($expecteds[$type], 1) . - 'but getFieldnames() returned ' . print_r($results[$type], 1) - ); - } - } + /** + * Tests the BasePeer::translateFieldName() method + */ + public function testTranslateFieldNameStatic() + { + $types = array( + BasePeer::TYPE_PHPNAME, + BasePeer::TYPE_STUDLYPHPNAME, + BasePeer::TYPE_COLNAME, + BasePeer::TYPE_FIELDNAME, + BasePeer::TYPE_NUM + ); + $expecteds = array ( + BasePeer::TYPE_PHPNAME => 'AuthorId', + BasePeer::TYPE_STUDLYPHPNAME => 'authorId', + BasePeer::TYPE_COLNAME => 'book.author_id', + BasePeer::TYPE_FIELDNAME => 'author_id', + BasePeer::TYPE_NUM => 5, + ); + foreach ($types as $fromType) { + foreach ($types as $toType) { + $name = $expecteds[$fromType]; + $expected = $expecteds[$toType]; + $result = BasePeer::translateFieldName('Book', $name, $fromType, $toType); + $this->assertEquals($expected, $result); + } + } + } - /** - * Tests the BasePeer::translateFieldName() method - */ - public function testTranslateFieldNameStatic () { + /** + * Tests the Base[Object]::getByName() method + */ + public function testGetByName() + { + $types = array( + BasePeer::TYPE_PHPNAME => 'Title', + BasePeer::TYPE_STUDLYPHPNAME => 'title', + BasePeer::TYPE_COLNAME => 'book.title', + BasePeer::TYPE_FIELDNAME => 'title', + BasePeer::TYPE_NUM => 1 + ); - $types = array( - BasePeer::TYPE_PHPNAME, - BasePeer::TYPE_STUDLYPHPNAME, - BasePeer::TYPE_COLNAME, - BasePeer::TYPE_FIELDNAME, - BasePeer::TYPE_NUM - ); - $expecteds = array ( - BasePeer::TYPE_PHPNAME => 'AuthorId', - BasePeer::TYPE_STUDLYPHPNAME => 'authorId', - BasePeer::TYPE_COLNAME => 'book.AUTHOR_ID', - BasePeer::TYPE_FIELDNAME => 'author_id', - BasePeer::TYPE_NUM => 5, - ); - foreach ($types as $fromType) { - foreach ($types as $toType) { - $name = $expecteds[$fromType]; - $expected = $expecteds[$toType]; - $result = BasePeer::translateFieldName('Book', $name, $fromType, $toType); - $this->assertEquals($expected, $result); - } - } - } + $book = new Book(); + $book->setTitle('Harry Potter and the Order of the Phoenix'); - /** - * Tests the Base[Object]::getByName() method - */ - public function testGetByName() { + $expected = 'Harry Potter and the Order of the Phoenix'; + foreach ($types as $type => $name) { + $result = $book->getByName($name, $type); + $this->assertEquals($expected, $result); + } + } - $types = array( - BasePeer::TYPE_PHPNAME => 'Title', - BasePeer::TYPE_STUDLYPHPNAME => 'title', - BasePeer::TYPE_COLNAME => 'book.TITLE', - BasePeer::TYPE_FIELDNAME => 'title', - BasePeer::TYPE_NUM => 1 - ); + /** + * Tests the Base[Object]::setByName() method + */ + public function testSetByName() + { + $book = new Book(); + $types = array( + BasePeer::TYPE_PHPNAME => 'Title', + BasePeer::TYPE_STUDLYPHPNAME => 'title', + BasePeer::TYPE_COLNAME => 'book.title', + BasePeer::TYPE_FIELDNAME => 'title', + BasePeer::TYPE_NUM => 1 + ); - $book = new Book(); - $book->setTitle('Harry Potter and the Order of the Phoenix'); + $title = 'Harry Potter and the Order of the Phoenix'; + foreach ($types as $type => $name) { + $book->setByName($name, $title, $type); + $result = $book->getTitle(); + $this->assertEquals($title, $result); + } + } - $expected = 'Harry Potter and the Order of the Phoenix'; - foreach ($types as $type => $name) { - $result = $book->getByName($name, $type); - $this->assertEquals($expected, $result); - } - } + /** + * Tests the Base[Object]::fromArray() method + * + * this also tests populateFromArray() because that's an alias + */ + public function testFromArray() + { + $types = array( + BasePeer::TYPE_PHPNAME, + BasePeer::TYPE_STUDLYPHPNAME, + BasePeer::TYPE_COLNAME, + BasePeer::TYPE_FIELDNAME, + BasePeer::TYPE_NUM + ); + $expecteds = array ( + BasePeer::TYPE_PHPNAME => array ( + 'Title' => 'Harry Potter and the Order of the Phoenix', + 'ISBN' => '043935806X' + ), + BasePeer::TYPE_STUDLYPHPNAME => array ( + 'title' => 'Harry Potter and the Order of the Phoenix', + 'iSBN' => '043935806X' + ), + BasePeer::TYPE_COLNAME => array ( + 'book.title' => 'Harry Potter and the Order of the Phoenix', + 'book.isbn' => '043935806X' + ), + BasePeer::TYPE_FIELDNAME => array ( + 'title' => 'Harry Potter and the Order of the Phoenix', + 'isbn' => '043935806X' + ), + BasePeer::TYPE_NUM => array ( + '1' => 'Harry Potter and the Order of the Phoenix', + '2' => '043935806X' + ) + ); - /** - * Tests the Base[Object]::setByName() method - */ - public function testSetByName() { + $book = new Book(); - $book = new Book(); - $types = array( - BasePeer::TYPE_PHPNAME => 'Title', - BasePeer::TYPE_STUDLYPHPNAME => 'title', - BasePeer::TYPE_COLNAME => 'book.TITLE', - BasePeer::TYPE_FIELDNAME => 'title', - BasePeer::TYPE_NUM => 1 - ); + foreach ($types as $type) { + $expected = $expecteds[$type]; + $book->fromArray($expected, $type); + $result = array(); + foreach (array_keys($expected) as $key) { + $result[$key] = $book->getByName($key, $type); + } + $this->assertEquals( + $expected, + $result, + 'expected was: ' . print_r($expected, 1) . + 'but fromArray() returned ' . print_r($result, 1) + ); + } + } - $title = 'Harry Potter and the Order of the Phoenix'; - foreach ($types as $type => $name) { - $book->setByName($name, $title, $type); - $result = $book->getTitle(); - $this->assertEquals($title, $result); - } - } + /** + * Tests the Base[Object]::toArray() method + */ + public function testToArray() + { + $types = array( + BasePeer::TYPE_PHPNAME, + BasePeer::TYPE_STUDLYPHPNAME, + BasePeer::TYPE_COLNAME, + BasePeer::TYPE_FIELDNAME, + BasePeer::TYPE_NUM + ); - /** - * Tests the Base[Object]::fromArray() method - * - * this also tests populateFromArray() because that's an alias - */ - public function testFromArray(){ + $book = new Book(); + $book->fromArray(array ( + 'Title' => 'Harry Potter and the Order of the Phoenix', + 'ISBN' => '043935806X' + )); - $types = array( - BasePeer::TYPE_PHPNAME, - BasePeer::TYPE_STUDLYPHPNAME, - BasePeer::TYPE_COLNAME, - BasePeer::TYPE_FIELDNAME, - BasePeer::TYPE_NUM - ); - $expecteds = array ( - BasePeer::TYPE_PHPNAME => array ( - 'Title' => 'Harry Potter and the Order of the Phoenix', - 'ISBN' => '043935806X' - ), - BasePeer::TYPE_STUDLYPHPNAME => array ( - 'title' => 'Harry Potter and the Order of the Phoenix', - 'iSBN' => '043935806X' - ), - BasePeer::TYPE_COLNAME => array ( - 'book.TITLE' => 'Harry Potter and the Order of the Phoenix', - 'book.ISBN' => '043935806X' - ), - BasePeer::TYPE_FIELDNAME => array ( - 'title' => 'Harry Potter and the Order of the Phoenix', - 'isbn' => '043935806X' - ), - BasePeer::TYPE_NUM => array ( - '1' => 'Harry Potter and the Order of the Phoenix', - '2' => '043935806X' - ) - ); + $expecteds = array ( + BasePeer::TYPE_PHPNAME => array ( + 'Title' => 'Harry Potter and the Order of the Phoenix', + 'ISBN' => '043935806X' + ), + BasePeer::TYPE_STUDLYPHPNAME => array ( + 'title' => 'Harry Potter and the Order of the Phoenix', + 'iSBN' => '043935806X' + ), + BasePeer::TYPE_COLNAME => array ( + 'book.title' => 'Harry Potter and the Order of the Phoenix', + 'book.isbn' => '043935806X' + ), + BasePeer::TYPE_FIELDNAME => array ( + 'title' => 'Harry Potter and the Order of the Phoenix', + 'isbn' => '043935806X' + ), + BasePeer::TYPE_NUM => array ( + '1' => 'Harry Potter and the Order of the Phoenix', + '2' => '043935806X' + ) + ); - $book = new Book(); - - foreach ($types as $type) { - $expected = $expecteds[$type]; - $book->fromArray($expected, $type); - $result = array(); - foreach (array_keys($expected) as $key) { - $result[$key] = $book->getByName($key, $type); - } - $this->assertEquals( - $expected, - $result, - 'expected was: ' . print_r($expected, 1) . - 'but fromArray() returned ' . print_r($result, 1) - ); - } - } - - /** - * Tests the Base[Object]::toArray() method - */ - public function testToArray(){ - - $types = array( - BasePeer::TYPE_PHPNAME, - BasePeer::TYPE_STUDLYPHPNAME, - BasePeer::TYPE_COLNAME, - BasePeer::TYPE_FIELDNAME, - BasePeer::TYPE_NUM - ); - - $book = new Book(); - $book->fromArray(array ( - 'Title' => 'Harry Potter and the Order of the Phoenix', - 'ISBN' => '043935806X' - )); - - $expecteds = array ( - BasePeer::TYPE_PHPNAME => array ( - 'Title' => 'Harry Potter and the Order of the Phoenix', - 'ISBN' => '043935806X' - ), - BasePeer::TYPE_STUDLYPHPNAME => array ( - 'title' => 'Harry Potter and the Order of the Phoenix', - 'iSBN' => '043935806X' - ), - BasePeer::TYPE_COLNAME => array ( - 'book.TITLE' => 'Harry Potter and the Order of the Phoenix', - 'book.ISBN' => '043935806X' - ), - BasePeer::TYPE_FIELDNAME => array ( - 'title' => 'Harry Potter and the Order of the Phoenix', - 'isbn' => '043935806X' - ), - BasePeer::TYPE_NUM => array ( - '1' => 'Harry Potter and the Order of the Phoenix', - '2' => '043935806X' - ) - ); - - foreach ($types as $type) { - $expected = $expecteds[$type]; - $result = $book->toArray($type); - // remove ID since its autoincremented at each test iteration - $result = array_slice($result, 1, 2, true); - $this->assertEquals( - $expected, - $result, - 'expected was: ' . print_r($expected, 1) . - 'but toArray() returned ' . print_r($result, 1) - ); - } - } + foreach ($types as $type) { + $expected = $expecteds[$type]; + $result = $book->toArray($type); + // remove ID since its autoincremented at each test iteration + $result = array_slice($result, 1, 2, true); + $this->assertEquals( + $expected, + $result, + 'expected was: ' . print_r($expected, 1) . + 'but toArray() returned ' . print_r($result, 1) + ); + } + } } diff --git a/airtime_mvc/library/propel/test/testsuite/misc/Issue617Test.php b/airtime_mvc/library/propel/test/testsuite/misc/Issue617Test.php new file mode 100644 index 000000000..8df3faa45 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/misc/Issue617Test.php @@ -0,0 +1,226 @@ +removeTables(); + } + + protected function tearDown() + { + $this->removeTables(); + parent::tearDown(); + } + + /** + * Remove issue617 tables. + */ + public function removeTables() + { + $this->con->query('DROP TABLE IF EXISTS `issue617_user`'); + $this->con->query('DROP TABLE IF EXISTS `issue617_group`'); + } + + /** + * Setups the initial schema. + */ + private function setupInitSchema() + { + /* + * Create issue617 tables with foreign keys + */ + $schema = ' + + + + + + + + + + + + + + +
+ + + + + + + + +
+
+'; + + $builder = new PropelQuickBuilder(); + $builder->setPlatform($this->database->getPlatform()); + $builder->setSchema($schema); + + $diff = PropelDatabaseComparator::computeDiff($this->database, $builder->getDatabase()); + $sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff); + + $expected = ' +# This is a fix for InnoDB in MySQL >= 4.1.x +# It "suspends judgement" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +DROP TABLE IF EXISTS `book`; + +DROP TABLE IF EXISTS `foo`; + +CREATE TABLE `issue617_user` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `full_name` VARCHAR(50) NOT NULL, + `group_id` INTEGER, + PRIMARY KEY (`id`), + INDEX `issue617_user_FI_1` (`group_id`), + CONSTRAINT `issue617_user_FK_1` + FOREIGN KEY (`group_id`) + REFERENCES `issue617_group` (`id`) + ON DELETE SET NULL +) ENGINE=InnoDB CHARACTER SET=\'utf8\'; + +CREATE TABLE `issue617_group` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `name` VARCHAR(50) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB CHARACTER SET=\'utf8\'; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; +'; + + $this->assertEquals($expected, $sql); + $this->updateSchema($builder->getDatabase()); + + } + + /** + * Drop the foreign key in the `_user` table and check whether it generates + * the correct `DROP` SQL. + */ + private function dropForeignKey() + { + /* + * Create issue617 tables without foreign keys + */ + + $this->readDatabase(); + $updatedSchema = ' + + + + + + + + +
+ + + + + + + + +
+
+'; + + $this->updatedBuilder = new PropelQuickBuilder(); + $this->updatedBuilder->setPlatform($this->database->getPlatform()); + $this->updatedBuilder->setSchema($updatedSchema); + + $diff = PropelDatabaseComparator::computeDiff($this->database, $this->updatedBuilder->getDatabase()); + $sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff); + + $expected = ' +# This is a fix for InnoDB in MySQL >= 4.1.x +# It "suspends judgement" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +DROP TABLE IF EXISTS `book`; + +DROP TABLE IF EXISTS `foo`; + +ALTER TABLE `issue617_user` DROP FOREIGN KEY `issue617_user_FK_1`; + +DROP INDEX `issue617_user_FI_1` ON `issue617_user`; + +ALTER TABLE `issue617_user` DROP `group_id`; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; +'; + + $this->assertEquals($expected, $sql); + $this->updateSchema($this->updatedBuilder->getDatabase()); + } + + /* + * Checks if FKs are really deleted. + */ + private function checkDeletedFk() + { + $this->readDatabase(); + $diff = PropelDatabaseComparator::computeDiff($this->database, $this->updatedBuilder->getDatabase()); + $sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff); + + $expected = ' +# This is a fix for InnoDB in MySQL >= 4.1.x +# It "suspends judgement" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +DROP TABLE IF EXISTS `book`; + +DROP TABLE IF EXISTS `foo`; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; +'; + + $this->assertEquals($expected, $sql); + + } + + /** + * Checks if a changed schema with removed FK does really delete the FK. + * Based on a real use-case, reverse classes and `computeDiff`. + */ + public function testDropForeignKey() + { + $this->readDatabase(); + + $this->setupInitSchema(); + $this->dropForeignKey(); + $this->checkDeletedFk(); + + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/misc/Issue651Test.php b/airtime_mvc/library/propel/test/testsuite/misc/Issue651Test.php new file mode 100644 index 000000000..9e199f02a --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/misc/Issue651Test.php @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + +
+ +'; + +$actual = " +# This is a fix for InnoDB in MySQL >= 4.1.x +# It \"suspends judgement\" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +-- --------------------------------------------------------------------- +-- notification +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `notification`; + +CREATE TABLE `notification` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `target_user_id` INTEGER NOT NULL, + `notification_type_unique_name` VARCHAR(255) NOT NULL, + `group_id` INTEGER, + `date` DATETIME NOT NULL, + `objects` TEXT, + `is_new` TINYINT(1) DEFAULT 1 NOT NULL, + PRIMARY KEY (`id`), + INDEX `FK_NOTIFICATION_TARGET_USER` (`target_user_id`), + INDEX `FK_NOTIFICATION_TYPENOTIFICATION` (`notification_type_unique_name`), + CONSTRAINT `FK_NOTIFICATION_TYPENOTIFICATION0` + FOREIGN KEY (`notification_type_unique_name`) + REFERENCES `notification_type` (`unique_name`) +) ENGINE=InnoDb; + +-- --------------------------------------------------------------------- +-- notification_type +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `notification_type`; + +CREATE TABLE `notification_type` +( + `module_unique_name` VARCHAR(255) NOT NULL, + `unique_name` VARCHAR(255) NOT NULL, + `is_correction` TINYINT(1) DEFAULT 0 NOT NULL, + `disabled_engine` VARCHAR(255), + PRIMARY KEY (`module_unique_name`,`unique_name`), + INDEX `FK_TYPENOTIFICATION_MODULE` (`module_unique_name`), + INDEX `I_referenced_FK_NOTIFICATION_TYPENOTIFICATION0_1` (`unique_name`), + CONSTRAINT `FK_TYPENOTIFICATION_MODULE0` + FOREIGN KEY (`module_unique_name`) + REFERENCES `module` (`unique_name`) + ON UPDATE CASCADE + ON DELETE CASCADE +) ENGINE=InnoDb; + +-- --------------------------------------------------------------------- +-- module +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `module`; + +CREATE TABLE `module` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `unique_name` VARCHAR(255) NOT NULL, + `label` VARCHAR(255) NOT NULL, + `description` VARCHAR(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDb; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; +"; + + $platform = new MysqlPlatform(); + $platform->setDefaultTableEngine('InnoDb'); + $updatedBuilder = new PropelQuickBuilder(); + $updatedBuilder->setPlatform($platform); + $updatedBuilder->setSchema($updatedSchema); + + $sql = $updatedBuilder->getSQL(); + $this->assertEquals($actual, $sql); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/misc/PoisonedCacheBugTest.php b/airtime_mvc/library/propel/test/testsuite/misc/PoisonedCacheBugTest.php new file mode 100644 index 000000000..cfdb0f526 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/misc/PoisonedCacheBugTest.php @@ -0,0 +1,170 @@ +setFirstName("Douglas"); + $a->setLastName("Adams"); + + $b1 = new Book(); + $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $b1->setIsbn('1145'); + $a->addBook($b1); + + $b2 = new Book(); + $b2->setTitle("The Restaurant At The End Of The Universe"); + $b2->setIsbn('1245'); + $a->addBook($b2); + + $a->save(); + + $this->author = $a; + $this->books = array($b1, $b2); + + Propel::enableInstancePooling(); + + // Clear author instance pool so the object would be fetched from the database + AuthorPeer::clearInstancePool(); + } + + public function testSetUp() + { + $this->assertTrue(Propel::isInstancePoolingEnabled()); + + $this->assertEquals(2, count($this->author->getBooks())); + $this->assertEquals(2, $this->author->countBooks()); + } + + /** + * Very common use case where fetching a book, and showing other books by the author + */ + public function testPoisonedCacheWhenDoSelectJoinAuthor() + { + $c = new Criteria(); + $c->add(BookPeer::ID, $this->books[0]->getId()); + + $books = BookPeer::doSelectJoinAuthor($c); + + $this->assertEquals(2, count($books[0]->getAuthor()->getBooks())); + $this->assertEquals(2, $books[0]->getAuthor()->countBooks()); + } + + /** + * To illustrate that instance pooling makes no difference + */ + public function testPoisonedCacheWithJoinInstancePoolingDisabled() + { + Propel::disableInstancePooling(); + + $this->testPoisonedCacheWhenDoSelectJoinAuthor(); + } + + public function testPoisonedCacheWhenSavingABook() + { + $b1 = BookPeer::retrieveByPK($this->books[0]->getId()); + + // if author is loaded then doSave will do addBook($b1) and poison the authors books cache + $b1->getAuthor(); + + // e.g. to update viewed count etc + $b1->save(); + + // ... later down the line fetch the author + $author = AuthorPeer::retrieveByPK($this->author->getId()); + + $this->assertEquals(2, count($author->getBooks())); + $this->assertEquals(2, $author->countBooks()); + } + + public function testAddingABook() + { + $author = AuthorPeer::retrieveByPK($this->author->getId()); + + $c1 = new Book(); + $c1->setTitle("ORM 101"); + $author->addBook($c1); + + $this->assertEquals(3, count($author->getBooks())); + $this->assertEquals(3, $author->countBooks()); + } + + public function testModifiedObjectsRemainInTheCollection() + { + $c = new Criteria(); + $c->add(BookPeer::ID, $this->books[0]->getId()); + + $books = BookPeer::doSelectJoinAuthor($c); + $books[0]->setTitle('Modified'); + + $books2 = $books[0]->getAuthor()->getBooks(); + $this->assertEquals(2, count($books2)); + $this->assertEquals(2, $books2[0]->getAuthor()->countBooks()); + + $this->assertEquals('Modified', $books2[0]->getTitle()); + } + + public function testSavingParentSavesRelatedObjects() + { + $author = AuthorPeer::retrieveByPK($this->author->getId()); + + $c = new Criteria(); + $c->add(BookPeer::ID, $this->books[0]->getId()); + + $books = $author->getBooks($c); + $books[0]->setTitle('Update to a book'); + + $author->save(); + + $this->assertFalse($books[0]->isModified()); + } + + public function testSavingParentSavesRelatedObjectsIncludingNew() + { + $author = AuthorPeer::retrieveByPK($this->author->getId()); + + // add new object before fetching old books + $b3 = new Book(); + $b3->setIsbn('124'); + $b3->setTitle('Title'); + $author->addBook($b3); + + $c = new Criteria(); + $c->add(BookPeer::ID, $this->books[0]->getId()); + + $books = $author->getBooks($c); + $books[0]->setTitle('Update to a book'); + + $author->save(); + + $this->assertEquals(3, $author->countBooks()); + $this->assertFalse($b3->isModified()); + $this->assertFalse($books[0]->isModified()); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/misc/Ticket520Test.php b/airtime_mvc/library/propel/test/testsuite/misc/Ticket520Test.php index e95390b05..e603dc77a 100644 --- a/airtime_mvc/library/propel/test/testsuite/misc/Ticket520Test.php +++ b/airtime_mvc/library/propel/test/testsuite/misc/Ticket520Test.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../tools/helpers/bookstore/BookstoreTestBase.php'; /* It's only fair to admit that these tests were carefully crafted after studying the current implementation to make it look as bad as @@ -19,232 +19,237 @@ possible. I am really sorry. :-( */ */ class Ticket520Test extends BookstoreTestBase { - public function testNewObjectsAvailableWhenSaveNotCalled() - { - $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + public function testNewObjectsAvailableWhenSaveNotCalled() + { + $a = new Author(); + $a->setFirstName("Douglas"); + $a->setLastName("Adams"); - $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); - $a->addBook($b1); + $b1 = new Book(); + $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $a->addBook($b1); - $b2 = new Book(); - $b2->setTitle("The Restaurant At The End Of The Universe"); - $a->addBook($b2); + $b2 = new Book(); + $b2->setTitle("The Restaurant At The End Of The Universe"); + $a->addBook($b2); - // Passing no Criteria means "use the internal collection or query the database" - // in that case two objects are added, so it should return 2 - $books = $a->getBooks(); - $this->assertEquals(2, count($books)); - } + // Passing no Criteria means "use the internal collection or query the database" + // in that case two objects are added, so it should return 2 + $books = $a->getBooks(); + $this->assertEquals(2, count($books)); + } - public function testNewObjectsNotAvailableWithCriteria() - { - $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + public function testNewObjectsNotAvailableWithCriteria() + { + $a = new Author(); + $a->setFirstName("Douglas"); + $a->setLastName("Adams"); - $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); - $a->addBook($b1); + $b1 = new Book(); + $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $a->addBook($b1); - $b2 = new Book(); - $b2->setTitle("The Restaurant At The End Of The Universe"); - $a->addBook($b2); + $b2 = new Book(); + $b2->setTitle("The Restaurant At The End Of The Universe"); + $a->addBook($b2); - $c = new Criteria(); - $c->add(BookPeer::TITLE, "%Hitchhiker%", Criteria::LIKE); + $c = new Criteria(); + $c->add(BookPeer::TITLE, "%Hitchhiker%", Criteria::LIKE); - $guides = $a->getBooks($c); - $this->assertEquals(0, count($guides), 'Passing a Criteria means "force a database query"'); - } + $guides = $a->getBooks($c); + $this->assertEquals(0, count($guides), 'Passing a Criteria means "force a database query"'); + } - public function testNewObjectsAvailableAfterCriteria() - { - $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + public function testNewObjectsAvailableAfterCriteria() + { + $a = new Author(); + $a->setFirstName("Douglas"); + $a->setLastName("Adams"); - $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); - $a->addBook($b1); + $b1 = new Book(); + $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $a->addBook($b1); - $b2 = new Book(); - $b2->setTitle("The Restaurant At The End Of The Universe"); - $a->addBook($b2); + $b2 = new Book(); + $b2->setTitle("The Restaurant At The End Of The Universe"); + $a->addBook($b2); - $c = new Criteria(); - $c->add(BookPeer::TITLE, "%Hitchhiker%", Criteria::LIKE); + $c = new Criteria(); + $c->add(BookPeer::TITLE, "%Hitchhiker%", Criteria::LIKE); - $guides = $a->getBooks($c); - - $books = $a->getBooks(); - $this->assertEquals(2, count($books), 'A previous query with a Criteria does not erase the internal collection'); - } + $guides = $a->getBooks($c); - public function testSavedObjectsWithCriteria() - { - $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + $books = $a->getBooks(); + $this->assertEquals(2, count($books), 'A previous query with a Criteria does not erase the internal collection'); + } - $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); - $a->addBook($b1); + public function testSavedObjectsWithCriteria() + { + $a = new Author(); + $a->setFirstName("Douglas"); + $a->setLastName("Adams"); - $b2 = new Book(); - $b2->setTitle("The Restaurant At The End Of The Universe"); - $a->addBook($b2); + $b1 = new Book(); + $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $b1->setIsbn('14'); + $a->addBook($b1); - $c = new Criteria(); - $c->add(BookPeer::TITLE, "%Hitchhiker%", Criteria::LIKE); + $b2 = new Book(); + $b2->setTitle("The Restaurant At The End Of The Universe"); + $b2->setIsbn('124'); + $a->addBook($b2); - $guides = $a->getBooks($c); + $c = new Criteria(); + $c->add(BookPeer::TITLE, "%Hitchhiker%", Criteria::LIKE); - $a->save(); - $booksAfterSave = $a->getBooks($c); - $this->assertEquals(1, count($booksAfterSave), 'A previous query with a Criteria is not cached'); - } + $guides = $a->getBooks($c); - public function testAddNewObjectAfterSave() - { - $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + $a->save(); + $booksAfterSave = $a->getBooks($c); + $this->assertEquals(1, count($booksAfterSave), 'A previous query with a Criteria is not cached'); + } - $a->save(); + public function testAddNewObjectAfterSave() + { + $a = new Author(); + $a->setFirstName("Douglas"); + $a->setLastName("Adams"); - $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); - $a->addBook($b1); + $a->save(); - $books = $a->getBooks(); - $this->assertEquals(1, count($books)); - $this->assertTrue($books->contains($b1)); + $b1 = new Book(); + $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $b1->setIsbn('13245'); + $a->addBook($b1); - /* Now this is the initial ticket 520: If we have a saved author, - add a new book but happen to call getBooks() before we call save() again, - the book used to be lost. */ - $a->save(); - $this->assertFalse($b1->isNew(), 'related objects are also saved after fetching them'); - } + $books = $a->getBooks(); + $this->assertEquals(1, count($books)); + $this->assertTrue($books->contains($b1)); - public function testAddNewObjectAfterSaveWithPoisonedCache() - { - /* This is like testAddNewObjectAfterSave(), - but this time we "poison" the author's $colBooks cache - before adding the book by calling getBooks(). */ + /* Now this is the initial ticket 520: If we have a saved author, + add a new book but happen to call getBooks() before we call save() again, + the book used to be lost. */ + $a->save(); + $this->assertFalse($b1->isNew(), 'related objects are also saved after fetching them'); + } - $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + public function testAddNewObjectAfterSaveWithPoisonedCache() + { + /* This is like testAddNewObjectAfterSave(), + but this time we "poison" the author's $colBooks cache + before adding the book by calling getBooks(). */ - $a->save(); - $a->getBooks(); + $a = new Author(); + $a->setFirstName("Douglas"); + $a->setLastName("Adams"); - $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); - $a->addBook($b1); + $a->save(); + $a->getBooks(); - $books = $a->getBooks(); - $this->assertEquals(1, count($books)); - $this->assertTrue($books->contains($b1), 'new related objects not deleted after fetching them'); - } + $b1 = new Book(); + $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $a->addBook($b1); - public function testCachePoisoning() - { - /* Like testAddNewObjectAfterSaveWithPoisonedCache, emphasizing - cache poisoning. */ + $books = $a->getBooks(); + $this->assertEquals(1, count($books)); + $this->assertTrue($books->contains($b1), 'new related objects not deleted after fetching them'); + } - $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + public function testCachePoisoning() + { + /* Like testAddNewObjectAfterSaveWithPoisonedCache, emphasizing + cache poisoning. */ - $a->save(); + $a = new Author(); + $a->setFirstName("Douglas"); + $a->setLastName("Adams"); - $c = new Criteria(); - $c->add(BookPeer::TITLE, "%Restaurant%", Criteria::LIKE); + $a->save(); - $this->assertEquals(0, count($a->getBooks($c))); + $c = new Criteria(); + $c->add(BookPeer::TITLE, "%Restaurant%", Criteria::LIKE); - $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); - $a->addBook($b1); + $this->assertEquals(0, count($a->getBooks($c))); - /* Like testAddNewObjectAfterSaveWithPoisonedCache, but this time - with a real criteria. */ - $this->assertEquals(0, count($a->getBooks($c))); + $b1 = new Book(); + $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $b1->setIsbn('12435'); + $a->addBook($b1); - $a->save(); - $this->assertFalse($b1->isNew()); - $this->assertEquals(0, count($a->getBooks($c))); - } + /* Like testAddNewObjectAfterSaveWithPoisonedCache, but this time + with a real criteria. */ + $this->assertEquals(0, count($a->getBooks($c))); - public function testDeletedBookDisappears() - { - $this->markTestSkipped(); - - $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + $a->save(); + $this->assertFalse($b1->isNew()); + $this->assertEquals(0, count($a->getBooks($c))); + } - $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); - $a->addBook($b1); + public function testDeletedBookDisappears() + { + $this->markTestSkipped(); - $b2 = new Book(); - $b2->setTitle("The Restaurant At The End Of The Universe"); - $a->addBook($b2); + $a = new Author(); + $a->setFirstName("Douglas"); + $a->setLastName("Adams"); - /* As you cannot write $a->remove($b2), you have to delete $b2 - directly. */ + $b1 = new Book(); + $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $a->addBook($b1); - /* All objects unsaved. As of revision 851, this circumvents the - $colBooks cache. Anyway, fails because getBooks() never checks if - a colBooks entry has been deleted. */ - $this->assertEquals(2, count($a->getBooks())); - $b2->delete(); - $this->assertEquals(1, count($a->getBooks())); + $b2 = new Book(); + $b2->setTitle("The Restaurant At The End Of The Universe"); + $a->addBook($b2); - /* Even if we had saved everything before and the delete() had - actually updated the DB, the $b2 would still be a "zombie" in - $a's $colBooks field. */ - } + /* As you cannot write $a->remove($b2), you have to delete $b2 + directly. */ - public function testNewObjectsGetLostOnJoin() { - /* While testNewObjectsAvailableWhenSaveNotCalled passed as of - revision 851, in this case we call getBooksJoinPublisher() instead - of just getBooks(). get...Join...() does not contain the check whether - the current object is new, it will always consult the DB and lose the - new objects entirely. Thus the test fails. (At least for Propel 1.2 ?!?) */ - $this->markTestSkipped(); - - $a = new Author(); - $a->setFirstName("Douglas"); - $a->setLastName("Adams"); + /* All objects unsaved. As of revision 851, this circumvents the + $colBooks cache. Anyway, fails because getBooks() never checks if + a colBooks entry has been deleted. */ + $this->assertEquals(2, count($a->getBooks())); + $b2->delete(); + $this->assertEquals(1, count($a->getBooks())); - $p = new Publisher(); - $p->setName('Pan Books Ltd.'); + /* Even if we had saved everything before and the delete() had + actually updated the DB, the $b2 would still be a "zombie" in + $a's $colBooks field. */ + } - $b1 = new Book(); - $b1->setTitle("The Hitchhikers Guide To The Galaxy"); - $b1->setPublisher($p); // uh... did not check that :^) - $a->addBook($b1); + public function testNewObjectsGetLostOnJoin() + { + /* While testNewObjectsAvailableWhenSaveNotCalled passed as of + revision 851, in this case we call getBooksJoinPublisher() instead + of just getBooks(). get...Join...() does not contain the check whether + the current object is new, it will always consult the DB and lose the + new objects entirely. Thus the test fails. (At least for Propel 1.2 ?!?) */ + $this->markTestSkipped(); - $b2 = new Book(); - $b2->setTitle("The Restaurant At The End Of The Universe"); - $b2->setPublisher($p); - $a->addBook($b2); + $a = new Author(); + $a->setFirstName("Douglas"); + $a->setLastName("Adams"); - $books = $a->getBooksJoinPublisher(); - $this->assertEquals(2, count($books)); - $this->assertContains($b1, $books); - $this->assertContains($b2, $books); + $p = new Publisher(); + $p->setName('Pan Books Ltd.'); - $a->save(); - $this->assertFalse($b1->isNew()); - $this->assertFalse($b2->isNew()); - } + $b1 = new Book(); + $b1->setTitle("The Hitchhikers Guide To The Galaxy"); + $b1->setPublisher($p); // uh... did not check that :^) + $a->addBook($b1); + + $b2 = new Book(); + $b2->setTitle("The Restaurant At The End Of The Universe"); + $b2->setPublisher($p); + $a->addBook($b2); + + $books = $a->getBooksJoinPublisher(); + $this->assertEquals(2, count($books)); + $this->assertContains($b1, $books); + $this->assertContains($b2, $books); + + $a->save(); + $this->assertFalse($b1->isNew()); + $this->assertFalse($b2->isNew()); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBAdapterTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBAdapterTest.php new file mode 100644 index 000000000..76650d4fb --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBAdapterTest.php @@ -0,0 +1,125 @@ +addSelectColumn(BookPeer::ID); + $db->turnSelectColumnsToAliases($c1); + + $c2 = new Criteria(); + $c2->addAsColumn('book_id', BookPeer::ID); + $this->assertTrue($c1->equals($c2)); + } + + public function testTurnSelectColumnsToAliasesPreservesAliases() + { + $db = Propel::getDB(BookPeer::DATABASE_NAME); + $c1 = new Criteria(); + $c1->addSelectColumn(BookPeer::ID); + $c1->addAsColumn('foo', BookPeer::TITLE); + $db->turnSelectColumnsToAliases($c1); + + $c2 = new Criteria(); + $c2->addAsColumn('book_id', BookPeer::ID); + $c2->addAsColumn('foo', BookPeer::TITLE); + $this->assertTrue($c1->equals($c2)); + } + + public function testTurnSelectColumnsToAliasesExisting() + { + $db = Propel::getDB(BookPeer::DATABASE_NAME); + $c1 = new Criteria(); + $c1->addSelectColumn(BookPeer::ID); + $c1->addAsColumn('book_id', BookPeer::ID); + $db->turnSelectColumnsToAliases($c1); + + $c2 = new Criteria(); + $c2->addAsColumn('book_id_1', BookPeer::ID); + $c2->addAsColumn('book_id', BookPeer::ID); + $this->assertTrue($c1->equals($c2)); + } + + public function testTurnSelectColumnsToAliasesDuplicate() + { + $db = Propel::getDB(BookPeer::DATABASE_NAME); + $c1 = new Criteria(); + $c1->addSelectColumn(BookPeer::ID); + $c1->addSelectColumn(BookPeer::ID); + $db->turnSelectColumnsToAliases($c1); + + $c2 = new Criteria(); + $c2->addAsColumn('book_id', BookPeer::ID); + $c2->addAsColumn('book_id_1', BookPeer::ID); + $this->assertTrue($c1->equals($c2)); + } + + public function testCreateSelectSqlPart() + { + $db = Propel::getDB(BookPeer::DATABASE_NAME); + $c = new Criteria(); + $c->addSelectColumn(BookPeer::ID); + $c->addAsColumn('book_ID', BookPeer::ID); + $fromClause = array(); + $selectSql = $db->createSelectSqlPart($c, $fromClause); + $this->assertEquals('SELECT book.id, book.id AS '.$db->quoteIdentifier('book_ID'), $selectSql, 'createSelectSqlPart() returns a SQL SELECT clause with both select and as columns'); + $this->assertEquals(array('book'), $fromClause, 'createSelectSqlPart() adds the tables from the select columns to the from clause'); + } + + public function testCreateSelectSqlPartWithFnc() + { + $db = Propel::getDB(BookPeer::DATABASE_NAME); + $c = new Criteria(); + $c->addSelectColumn(BookPeer::ID); + $c->addAsColumn('book_ID', 'IF(1, '.BookPeer::ID.', '.BookPeer::TITLE.')'); + $fromClause = array(); + $selectSql = $db->createSelectSqlPart($c, $fromClause); + $this->assertEquals('SELECT book.id, IF(1, book.id, book.title) AS '.$db->quoteIdentifier('book_ID'), $selectSql, 'createSelectSqlPart() returns a SQL SELECT clause with both select and as columns'); + $this->assertEquals(array('book'), $fromClause, 'createSelectSqlPart() adds the tables from the select columns to the from clause'); + } + + public function testCreateSelectSqlPartSelectModifier() + { + $db = Propel::getDB(BookPeer::DATABASE_NAME); + $c = new Criteria(); + $c->addSelectColumn(BookPeer::ID); + $c->addAsColumn('book_ID', BookPeer::ID); + $c->setDistinct(); + $fromClause = array(); + $selectSql = $db->createSelectSqlPart($c, $fromClause); + $this->assertEquals('SELECT DISTINCT book.id, book.id AS '.$db->quoteIdentifier('book_ID'), $selectSql, 'createSelectSqlPart() includes the select modifiers in the SELECT clause'); + $this->assertEquals(array('book'), $fromClause, 'createSelectSqlPart() adds the tables from the select columns to the from clause'); + } + + public function testCreateSelectSqlPartAliasAll() + { + $db = Propel::getDB(BookPeer::DATABASE_NAME); + $c = new Criteria(); + $c->addSelectColumn(BookPeer::ID); + $c->addAsColumn('book_id', BookPeer::ID); + $fromClause = array(); + $selectSql = $db->createSelectSqlPart($c, $fromClause, true); + $this->assertEquals('SELECT book.id AS '.$db->quoteIdentifier('book_id_1').', book.id AS '.$db->quoteIdentifier('book_id'), $selectSql, 'createSelectSqlPart() aliases all columns if passed true as last parameter'); + $this->assertEquals(array(), $fromClause, 'createSelectSqlPart() does not add the tables from an all-aliased list of select columns'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBAdapterTestAbstract.php b/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBAdapterTestAbstract.php new file mode 100644 index 000000000..55a40309f --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBAdapterTestAbstract.php @@ -0,0 +1,23 @@ + + * @package runtime.adapter + */ + +abstract class DBAdapterTestAbstract extends BookstoreTestBase +{ + abstract public function testQuotingIdentifiers(); + +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBMSSQLTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBMSSQLTest.php new file mode 100644 index 000000000..b35e3be88 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBMSSQLTest.php @@ -0,0 +1,43 @@ + + * @package runtime.adapter + */ +class DBMSSQLTest extends DBAdapterTestAbstract +{ + public function testSelectJoinOrderAlias() + { + $adapter = new DBMSSQL(); + $sql = 'SELECT Field, Related.Field AS [RelatedField] FROM Record LEFT JOIN Related ON Record.RelatedID = Related.ID ORDER BY [RelatedField] ASC'; + $adapter->applyLimit($sql, 10, 5); + $this->assertEquals('SELECT [Field], [RelatedField] FROM (SELECT ROW_NUMBER() OVER(ORDER BY Related.Field ASC) AS [RowNumber], Field AS [Field], Related.Field AS [RelatedField] FROM Record LEFT JOIN Related ON Record.RelatedID = Related.ID) AS derivedb WHERE RowNumber BETWEEN 11 AND 15', $sql); + } + + public function testQuotingIdentifiers() + { + $db = new DBMSSQL(); + $this->assertEquals('[Book ISBN]', $db->quoteIdentifier('Book ISBN')); + } + + public function testCaseQuery() + { + $adapter = new DBMSSQL(); + $sql = "SELECT Field1, CASE WHEN Field2 = 'non-relevant' THEN 0 ELSE 1 END AS [Relevant] FROM Record ORDER BY [Relevant] ASC"; + $adapter->applyLimit($sql, 10, 5); + $this->assertEquals("SELECT [Field1], [Relevant] FROM (SELECT ROW_NUMBER() OVER(ORDER BY CASE WHEN Field2 = 'non-relevant' THEN 0 ELSE 1 END ASC) AS [RowNumber], Field1 AS [Field1], CASE WHEN Field2 = 'non-relevant' THEN 0 ELSE 1 END AS [Relevant] FROM Record) AS derivedb WHERE RowNumber BETWEEN 11 AND 15", $sql); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBMySQLTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBMySQLTest.php new file mode 100644 index 000000000..55d5b926d --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBMySQLTest.php @@ -0,0 +1,115 @@ + 'dsn=my_dsn', + 'settings' => array( + 'charset' => array( + 'value' => 'foobar' + ) + ) + ) + ) + ); + } + + /** + * @dataProvider getConParams + * @expectedException PropelException + */ + public function testPrepareParamsThrowsException($conparams) + { + if (version_compare(PHP_VERSION, '5.3.6', '>=')) { + $this->markTestSkipped('PHP_VERSION >= 5.3.6, no need to throw an exception.'); + } + + $db = new DBMySQL(); + $db->prepareParams($conparams); + } + + /** + * @dataProvider getConParams + */ + public function testPrepareParams($conparams) + { + if (version_compare(PHP_VERSION, '5.3.6', '<')) { + $this->markTestSkipped('PHP_VERSION < 5.3.6 will throw an exception.'); + } + + $db = new DBMySQL(); + $params = $db->prepareParams($conparams); + + $this->assertTrue(is_array($params)); + $this->assertEquals('dsn=my_dsn;charset=foobar', $params['dsn'], 'The given charset is in the DSN string'); + $this->assertArrayNotHasKey('charset', $params['settings'], 'The charset should be removed'); + } + + /** + * @dataProvider getConParams + */ + public function testNoSetNameQueryExecuted($conparams) + { + if (version_compare(PHP_VERSION, '5.3.6', '<')) { + $this->markTestSkipped('PHP_VERSION < 5.3.6 will throw an exception.'); + } + + $db = new DBMySQL(); + $params = $db->prepareParams($conparams); + + $settings = array(); + if (isset($params['settings'])) { + $settings = $params['settings']; + } + + $db->initConnection($this->getPdoMock(), $settings); + } + + protected function getPdoMock() + { + $con = $this + ->getMockBuilder('mockPDO') + ->getMock(); + + $con + ->expects($this->never()) + ->method('exec'); + + return $con; + } + + public function testQuotingIdentifiers() + { + $db = new DBMySQL(); + $this->assertEquals('`Book ISBN`', $db->quoteIdentifier('Book ISBN')); + } +} + +// See: http://stackoverflow.com/questions/3138946/mocking-the-pdo-object-using-phpunit +class mockPDO extends PDO +{ + public function __construct() + { + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBOracleTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBOracleTest.php index 25f1f1d17..f99fd9904 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBOracleTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBOracleTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/DBAdapterTestAbstract.php'; /** * Tests the DbOracle adapter @@ -17,31 +17,74 @@ require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; * @author Francois EZaninotto * @package runtime.adapter */ -class DBOracleTest extends BookstoreTestBase +class DBOracleTest extends DBAdapterTestAbstract { - public function testApplyLimitSimple() - { - Propel::setDb('oracle', new DBOracle()); - $c = new Criteria(); - $c->setDbName('oracle'); - BookPeer::addSelectColumns($c); - $c->setLimit(1); - $params = array(); - $sql = BasePeer::createSelectSql($c, $params); - $this->assertEquals('SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM book) A ) B WHERE B.PROPEL_ROWNUM <= 1', $sql, 'applyLimit() creates a subselect with the original column names by default'); - } + public function testApplyLimitSimple() + { + Propel::setDb('oracle', new DBOracle()); + $c = new Criteria(); + $c->setDbName('oracle'); + BookPeer::addSelectColumns($c); + $c->setLimit(1); + $params = array(); + $sql = BasePeer::createSelectSql($c, $params); + $this->assertEquals('SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book) A ) B WHERE B.PROPEL_ROWNUM <= 1', $sql, 'applyLimit() creates a subselect with the original column names by default'); + } - public function testApplyLimitDuplicateColumnName() - { - Propel::setDb('oracle', new DBOracle()); - $c = new Criteria(); - $c->setDbName('oracle'); - BookPeer::addSelectColumns($c); - AuthorPeer::addSelectColumns($c); - $c->setLimit(1); - $params = array(); - $sql = BasePeer::createSelectSql($c, $params); - $this->assertEquals('SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.ID AS book_ID, book.TITLE AS book_TITLE, book.ISBN AS book_ISBN, book.PRICE AS book_PRICE, book.PUBLISHER_ID AS book_PUBLISHER_ID, book.AUTHOR_ID AS book_AUTHOR_ID, author.ID AS author_ID, author.FIRST_NAME AS author_FIRST_NAME, author.LAST_NAME AS author_LAST_NAME, author.EMAIL AS author_EMAIL, author.AGE AS author_AGESELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID, author.ID, author.FIRST_NAME, author.LAST_NAME, author.EMAIL, author.AGE FROM book, author) A ) B WHERE B.PROPEL_ROWNUM <= 1', $sql, 'applyLimit() creates a subselect with aliased column names when a duplicate column name is found'); - } + public function testApplyLimitDuplicateColumnName() + { + $db = new DBOracle(); + Propel::setDb('oracle', $db); + $c = new Criteria(); + $c->setDbName('oracle'); + BookPeer::addSelectColumns($c); + AuthorPeer::addSelectColumns($c); + $c->setLimit(1); + $params = array(); + $sql = BasePeer::createSelectSql($c, $params); + $this->assertEquals('SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.id AS '.$db->quoteIdentifier('ORA_COL_ALIAS_0').', book.title AS '.$db->quoteIdentifier('ORA_COL_ALIAS_1').', book.isbn AS '.$db->quoteIdentifier('ORA_COL_ALIAS_2').', book.price AS '.$db->quoteIdentifier('ORA_COL_ALIAS_3').', book.publisher_id AS '.$db->quoteIdentifier('ORA_COL_ALIAS_4').', book.author_id AS '.$db->quoteIdentifier('ORA_COL_ALIAS_5').', author.id AS '.$db->quoteIdentifier('ORA_COL_ALIAS_6').', author.first_name AS '.$db->quoteIdentifier('ORA_COL_ALIAS_7').', author.last_name AS '.$db->quoteIdentifier('ORA_COL_ALIAS_8').', author.email AS '.$db->quoteIdentifier('ORA_COL_ALIAS_9').', author.age AS '.$db->quoteIdentifier('ORA_COL_ALIAS_10').' FROM book, author) A ) B WHERE B.PROPEL_ROWNUM <= 1', $sql, 'applyLimit() creates a subselect with aliased column names when a duplicate column name is found'); + } -} \ No newline at end of file + public function testApplyLimitDuplicateColumnNameWithColumn() + { + $db = new DBOracle(); + Propel::setDb('oracle', $db); + $c = new Criteria(); + $c->setDbName('oracle'); + BookPeer::addSelectColumns($c); + AuthorPeer::addSelectColumns($c); + $c->addAsColumn('BOOK_PRICE', BookPeer::PRICE); + $c->setLimit(1); + $params = array(); + $asColumns = $c->getAsColumns(); + $sql = BasePeer::createSelectSql($c, $params); + $this->assertEquals('SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.id AS '.$db->quoteIdentifier('ORA_COL_ALIAS_0').', book.title AS '.$db->quoteIdentifier('ORA_COL_ALIAS_1').', book.isbn AS '.$db->quoteIdentifier('ORA_COL_ALIAS_2').', book.price AS '.$db->quoteIdentifier('ORA_COL_ALIAS_3').', book.publisher_id AS '.$db->quoteIdentifier('ORA_COL_ALIAS_4').', book.author_id AS '.$db->quoteIdentifier('ORA_COL_ALIAS_5').', author.id AS '.$db->quoteIdentifier('ORA_COL_ALIAS_6').', author.first_name AS '.$db->quoteIdentifier('ORA_COL_ALIAS_7').', author.last_name AS '.$db->quoteIdentifier('ORA_COL_ALIAS_8').', author.email AS '.$db->quoteIdentifier('ORA_COL_ALIAS_9').', author.age AS '.$db->quoteIdentifier('ORA_COL_ALIAS_10').', book.price AS '.$db->quoteIdentifier('BOOK_PRICE').' FROM book, author) A ) B WHERE B.PROPEL_ROWNUM <= 1', $sql, 'applyLimit() creates a subselect with aliased column names when a duplicate column name is found'); + $this->assertEquals($asColumns, $c->getAsColumns(), 'createSelectSql supplementary add alias column'); + } + + public function testCreateSelectSqlPart() + { + Propel::setDb('oracle', new DBOracle()); + $db = Propel::getDB(); + $c = new Criteria(); + $c->addSelectColumn(BookPeer::ID); + $c->addAsColumn('book_ID', BookPeer::ID); + $fromClause = array(); + $selectSql = $db->createSelectSqlPart($c, $fromClause); + $this->assertEquals('SELECT book.id, book.id AS '.$db->quoteIdentifier('book_ID'), $selectSql, 'createSelectSqlPart() returns a SQL SELECT clause with both select and as columns'); + $this->assertEquals(array('book'), $fromClause, 'createSelectSqlPart() adds the tables from the select columns to the from clause'); + } + + public function testGetExplainPlanQuery() + { + $db = new DBOracle(); + $explainQuery = $db->getExplainPlanQuery('SELECT B.* FROM (SELECT A.*, rownum AS '.$db->quoteIdentifier('PROPEL_ROWNUM').' FROM (SELECT book.id AS '.$db->quoteIdentifier('ORA_COL_ALIAS_0').', book.title AS '.$db->quoteIdentifier('ORA_COL_ALIAS_1').', book.isbn AS '.$db->quoteIdentifier('ORA_COL_ALIAS_2').', book.price AS '.$db->quoteIdentifier('ORA_COL_ALIAS_3').', book.publisher_id AS '.$db->quoteIdentifier('ORA_COL_ALIAS_4').', book.author_id AS '.$db->quoteIdentifier('ORA_COL_ALIAS_5').', author.id AS '.$db->quoteIdentifier('ORA_COL_ALIAS_6').', author.first_name AS '.$db->quoteIdentifier('ORA_COL_ALIAS_7').', author.last_name AS '.$db->quoteIdentifier('ORA_COL_ALIAS_8').', author.email AS '.$db->quoteIdentifier('ORA_COL_ALIAS_9').', author.age AS '.$db->quoteIdentifier('ORA_COL_ALIAS_10').', book.price AS '.$db->quoteIdentifier('BOOK_PRICE').' FROM book, author) A ) B WHERE B.PROPEL_ROWNUM <= 1', 'iuyiuyiu'); + $this->assertEquals('EXPLAIN PLAN SET STATEMENT_ID = \'iuyiuyiu\' FOR SELECT B.* FROM (SELECT A.*, rownum AS '.$db->quoteIdentifier('PROPEL_ROWNUM').' FROM (SELECT book.id AS '.$db->quoteIdentifier('ORA_COL_ALIAS_0').', book.title AS '.$db->quoteIdentifier('ORA_COL_ALIAS_1').', book.isbn AS '.$db->quoteIdentifier('ORA_COL_ALIAS_2').', book.price AS '.$db->quoteIdentifier('ORA_COL_ALIAS_3').', book.publisher_id AS '.$db->quoteIdentifier('ORA_COL_ALIAS_4').', book.author_id AS '.$db->quoteIdentifier('ORA_COL_ALIAS_5').', author.id AS '.$db->quoteIdentifier('ORA_COL_ALIAS_6').', author.first_name AS '.$db->quoteIdentifier('ORA_COL_ALIAS_7').', author.last_name AS '.$db->quoteIdentifier('ORA_COL_ALIAS_8').', author.email AS '.$db->quoteIdentifier('ORA_COL_ALIAS_9').', author.age AS '.$db->quoteIdentifier('ORA_COL_ALIAS_10').', book.price AS '.$db->quoteIdentifier('BOOK_PRICE').' FROM book, author) A ) B WHERE B.PROPEL_ROWNUM <= 1', $explainQuery, 'getExplainPlanQuery() returns a SQL Explain query'); + } + + public function testQuotingIdentifiers() + { + $db = new DBOracle(); + $this->assertEquals('"Book ISBN"', $db->quoteIdentifier('Book ISBN')); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBPostgresTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBPostgresTest.php new file mode 100644 index 000000000..b7013dfe1 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/adapter/DBPostgresTest.php @@ -0,0 +1,37 @@ + + * @package runtime.adapter + */ +class DBPostgresTest extends DBAdapterTestAbstract +{ + public function testGetExplainPlanQuery() + { + $db = new DBPostgres(); + $query = 'SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.ID AS ORA_COL_ALIAS_0, book.TITLE AS ORA_COL_ALIAS_1, book.ISBN AS ORA_COL_ALIAS_2, book.PRICE AS ORA_COL_ALIAS_3, book.PUBLISHER_ID AS ORA_COL_ALIAS_4, book.AUTHOR_ID AS ORA_COL_ALIAS_5, author.ID AS ORA_COL_ALIAS_6, author.FIRST_NAME AS ORA_COL_ALIAS_7, author.LAST_NAME AS ORA_COL_ALIAS_8, author.EMAIL AS ORA_COL_ALIAS_9, author.AGE AS ORA_COL_ALIAS_10, book.PRICE AS BOOK_PRICE FROM book, author) A ) B WHERE B.PROPEL_ROWNUM <= 1'; + + $this->assertEquals('EXPLAIN SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.ID AS ORA_COL_ALIAS_0, book.TITLE AS ORA_COL_ALIAS_1, book.ISBN AS ORA_COL_ALIAS_2, book.PRICE AS ORA_COL_ALIAS_3, book.PUBLISHER_ID AS ORA_COL_ALIAS_4, book.AUTHOR_ID AS ORA_COL_ALIAS_5, author.ID AS ORA_COL_ALIAS_6, author.FIRST_NAME AS ORA_COL_ALIAS_7, author.LAST_NAME AS ORA_COL_ALIAS_8, author.EMAIL AS ORA_COL_ALIAS_9, author.AGE AS ORA_COL_ALIAS_10, book.PRICE AS BOOK_PRICE FROM book, author) A ) B WHERE B.PROPEL_ROWNUM <= 1', $db->getExplainPlanQuery($query), 'getExplainPlanQuery() returns a SQL Explain query'); + } + + public function testQuotingIdentifiers() + { + $db = new DBPostgres(); + $this->assertEquals('"Book ISBN"', $db->quoteIdentifier('Book ISBN')); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelArrayCollectionTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelArrayCollectionTest.php index a6a374936..90f5dc70b 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelArrayCollectionTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelArrayCollectionTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Test class for PropelObjectCollection. @@ -19,134 +19,196 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; */ class PropelArrayCollectionTest extends BookstoreEmptyTestBase { - protected function setUp() - { - parent::setUp(); - BookstoreDataPopulator::populate($this->con); - } - - public function testSave() - { - $books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ARRAY)->find(); - foreach ($books as &$book) { - $book['Title'] = 'foo'; - } - $books->save(); - // check that the modifications are persisted - BookPeer::clearInstancePool(); - $books = PropelQuery::from('Book')->find(); - foreach ($books as $book) { - $this->assertEquals('foo', $book->getTitle('foo')); - } - } + protected function setUp() + { + parent::setUp(); + BookstoreDataPopulator::populate($this->con); + } - public function testDelete() - { - $books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ARRAY)->find(); - $books->delete(); - // check that the modifications are persisted - BookPeer::clearInstancePool(); - $books = PropelQuery::from('Book')->find(); - $this->assertEquals(0, count($books)); - } - - public function testGetPrimaryKeys() - { - $books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ARRAY)->find(); - $pks = $books->getPrimaryKeys(); - $this->assertEquals(4, count($pks)); - - $keys = array('Book_0', 'Book_1', 'Book_2', 'Book_3'); - $this->assertEquals($keys, array_keys($pks)); - - $pks = $books->getPrimaryKeys(false); - $keys = array(0, 1, 2, 3); - $this->assertEquals($keys, array_keys($pks)); - - $bookObjects = PropelQuery::from('Book')->find(); - foreach ($pks as $key => $value) { - $this->assertEquals($bookObjects[$key]->getPrimaryKey(), $value); - } - } + public function testSave() + { + $books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ARRAY)->find(); + foreach ($books as &$book) { + $book['Title'] = 'foo'; + } + $books->save(); + // check that the modifications are persisted + BookPeer::clearInstancePool(); + $books = PropelQuery::from('Book')->find(); + foreach ($books as $book) { + $this->assertEquals('foo', $book->getTitle('foo')); + } + } - public function testFromArray() - { - $author = new Author(); - $author->setFirstName('Jane'); - $author->setLastName('Austen'); - $author->save(); - $books = array( - array('Title' => 'Mansfield Park', 'AuthorId' => $author->getId()), - array('Title' => 'Pride And PRejudice', 'AuthorId' => $author->getId()) - ); - $col = new PropelArrayCollection(); - $col->setModel('Book'); - $col->fromArray($books); - $col->save(); - - $nbBooks = PropelQuery::from('Book')->count(); - $this->assertEquals(6, $nbBooks); - - $booksByJane = PropelQuery::from('Book b') - ->join('b.Author a') - ->where('a.LastName = ?', 'Austen') - ->count(); - $this->assertEquals(2, $booksByJane); - } + /** + * @expectedException PropelException + */ + public function testSaveOnReadOnlyEntityThrowsException() + { + $col = new PropelArrayCollection(); + $col->setModel('ContestView'); + $cv = new ContestView(); + $col []= $cv; + $col->save(); + } - public function testToArray() - { - $books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ARRAY)->find(); - $booksArray = $books->toArray(); - $this->assertEquals(4, count($booksArray)); - - $bookObjects = PropelQuery::from('Book')->find(); - foreach ($booksArray as $key => $book) { - $this->assertEquals($bookObjects[$key]->toArray(), $book); - } - - $booksArray = $books->toArray(); - $keys = array(0, 1, 2, 3); - $this->assertEquals($keys, array_keys($booksArray)); - - $booksArray = $books->toArray(null, true); - $keys = array('Book_0', 'Book_1', 'Book_2', 'Book_3'); - $this->assertEquals($keys, array_keys($booksArray)); + public function testDelete() + { + $books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ARRAY)->find(); + $books->delete(); + // check that the modifications are persisted + BookPeer::clearInstancePool(); + $books = PropelQuery::from('Book')->find(); + $this->assertEquals(0, count($books)); + } - $booksArray = $books->toArray('Title'); - $keys = array('Harry Potter and the Order of the Phoenix', 'Quicksilver', 'Don Juan', 'The Tin Drum'); - $this->assertEquals($keys, array_keys($booksArray)); + /** + * @expectedException PropelException + */ + public function testDeleteOnReadOnlyEntityThrowsException() + { + $col = new PropelArrayCollection(); + $col->setModel('ContestView'); + $cv = new ContestView(); + $cv->setNew(false); + $col []= $cv; + $col->delete(); + } - $booksArray = $books->toArray('Title', true); - $keys = array('Book_Harry Potter and the Order of the Phoenix', 'Book_Quicksilver', 'Book_Don Juan', 'Book_The Tin Drum'); - $this->assertEquals($keys, array_keys($booksArray)); - } + public function testGetPrimaryKeys() + { + $books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ARRAY)->find(); + $pks = $books->getPrimaryKeys(); + $this->assertEquals(4, count($pks)); - public function getWorkerObject() - { - $col = new TestablePropelArrayCollection(); - $col->setModel('Book'); - $book = $col->getWorkerObject(); - $this->assertTrue($book instanceof Book, 'getWorkerObject() returns an object of the collection model'); - $book->foo = 'bar'; - $this->assertEqual('bar', $col->getWorkerObject()->foo, 'getWorkerObject() returns always the same object'); - } + $keys = array('Book_0', 'Book_1', 'Book_2', 'Book_3'); + $this->assertEquals($keys, array_keys($pks)); - /** - * @expectedException PropelException - */ - public function testGetWorkerObjectNoModel() - { - $col = new TestablePropelArrayCollection(); - $col->getWorkerObject(); - } + $pks = $books->getPrimaryKeys(false); + $keys = array(0, 1, 2, 3); + $this->assertEquals($keys, array_keys($pks)); + + $bookObjects = PropelQuery::from('Book')->find(); + foreach ($pks as $key => $value) { + $this->assertEquals($bookObjects[$key]->getPrimaryKey(), $value); + } + } + + public function testFromArray() + { + $author = new Author(); + $author->setFirstName('Jane'); + $author->setLastName('Austen'); + $author->save(); + $books = array( + array('Title' => 'Mansfield Park', 'ISBN' => '234', 'AuthorId' => $author->getId()), + array('Title' => 'Pride And Prejudice', 'ISBN' => '124', 'AuthorId' => $author->getId()) + ); + $col = new PropelArrayCollection(); + $col->setModel('Book'); + $col->fromArray($books); + $col->save(); + + $nbBooks = PropelQuery::from('Book')->count(); + $this->assertEquals(6, $nbBooks); + + $booksByJane = PropelQuery::from('Book b') + ->join('b.Author a') + ->where('a.LastName = ?', 'Austen') + ->count(); + $this->assertEquals(2, $booksByJane); + } + + public function testToArray() + { + $books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ARRAY)->find(); + $booksArray = $books->toArray(); + $this->assertEquals(4, count($booksArray)); + + $bookObjects = PropelQuery::from('Book')->find(); + foreach ($booksArray as $key => $book) { + $this->assertEquals($bookObjects[$key]->toArray(), $book); + } + + $booksArray = $books->toArray(); + $keys = array(0, 1, 2, 3); + $this->assertEquals($keys, array_keys($booksArray)); + + $booksArray = $books->toArray(null, true); + $keys = array('Book_0', 'Book_1', 'Book_2', 'Book_3'); + $this->assertEquals($keys, array_keys($booksArray)); + + $booksArray = $books->toArray('Title'); + $keys = array('Harry Potter and the Order of the Phoenix', 'Quicksilver', 'Don Juan', 'The Tin Drum'); + $this->assertEquals($keys, array_keys($booksArray)); + + $booksArray = $books->toArray('Title', true); + $keys = array('Book_Harry Potter and the Order of the Phoenix', 'Book_Quicksilver', 'Book_Don Juan', 'Book_The Tin Drum'); + $this->assertEquals($keys, array_keys($booksArray)); + } + + public function testToArrayDeep() + { + $author = new Author(); + $author->setId(5678); + $author->setFirstName('George'); + $author->setLastName('Byron'); + $book = new Book(); + $book->setId(9012); + $book->setTitle('Don Juan'); + $book->setISBN('0140422161'); + $book->setPrice(12.99); + $book->setAuthor($author); + + $coll = new PropelArrayCollection(); + $coll->setModel('Book'); + $coll[]= $book->toArray(BasePeer::TYPE_PHPNAME, true, array(), true); + $expected = array(array( + 'Id' => 9012, + 'Title' => 'Don Juan', + 'ISBN' => '0140422161', + 'Price' => 12.99, + 'PublisherId' => null, + 'AuthorId' => 5678, + 'Author' => array( + 'Id' => 5678, + 'FirstName' => 'George', + 'LastName' => 'Byron', + 'Email' => null, + 'Age' => null, + 'Books' => array( + 'Book_0' => '*RECURSION*', + ) + ), + )); + $this->assertEquals($expected, $coll->toArray()); + } + + public function getWorkerObject() + { + $col = new TestablePropelArrayCollection(); + $col->setModel('Book'); + $book = $col->getWorkerObject(); + $this->assertTrue($book instanceof Book, 'getWorkerObject() returns an object of the collection model'); + $book->foo = 'bar'; + $this->assertEqual('bar', $col->getWorkerObject()->foo, 'getWorkerObject() returns always the same object'); + } + + /** + * @expectedException PropelException + */ + public function testGetWorkerObjectNoModel() + { + $col = new TestablePropelArrayCollection(); + $col->getWorkerObject(); + } } class TestablePropelArrayCollection extends PropelArrayCollection { - public function getWorkerObject() - { - return parent::getWorkerObject(); - } -} \ No newline at end of file + public function getWorkerObject() + { + return parent::getWorkerObject(); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelCollectionConvertTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelCollectionConvertTest.php new file mode 100644 index 000000000..21f0cfd19 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelCollectionConvertTest.php @@ -0,0 +1,238 @@ +setId(9012); + $book1->setTitle('Don Juan'); + $book1->setISBN('0140422161'); + $book1->setPrice(12.99); + $book1->setAuthorId(5678); + $book1->setPublisherId(1234); + $book1->resetModified(); + $book2 = new Book(); + $book2->setId(58); + $book2->setTitle('Harry Potter and the Order of the Phoenix'); + $book2->setISBN('043935806X'); + $book2->setPrice(10.99); + $book2->resetModified(); + + $this->coll = new PropelObjectCollection(); + $this->coll->setModel('Book'); + $this->coll[]= $book1; + $this->coll[]= $book2; + } + + public function toXmlDataProvider() + { + $expected = << + + + 9012 + <![CDATA[Don Juan]]> + + 12.99 + 1234 + 5678 + + + 58 + <![CDATA[Harry Potter and the Order of the Phoenix]]> + + 10.99 + + + + + +EOF; + + return array(array($expected)); + } + + /** + * @dataProvider toXmlDataProvider + */ + public function testToXML($expected) + { + $this->assertEquals($expected, $this->coll->toXML()); + } + + /** + * @dataProvider toXmlDataProvider + */ + public function testFromXML($expected) + { + $coll = new PropelObjectCollection(); + $coll->setModel('Book'); + $coll->fromXML($expected); + // fix modified columns order + foreach ($coll as $book) { + $book->resetModified(); + } + + $this->assertEquals($this->coll, $coll); + } + + public function toYamlDataProvider() + { + $expected = <<assertEquals($expected, $this->coll->toYAML()); + } + + /** + * @dataProvider toYamlDataProvider + */ + public function testFromYAML($expected) + { + $coll = new PropelObjectCollection(); + $coll->setModel('Book'); + $coll->fromYAML($expected); + // fix modified columns order + foreach ($coll as $book) { + $book->resetModified(); + } + + $this->assertEquals($this->coll, $coll); + } + + public function toJsonDataProvider() + { + $expected = <<assertEquals($expected, $this->coll->toJSON()); + } + + /** + * @dataProvider toJsonDataProvider + */ + public function testfromJSON($expected) + { + $coll = new PropelObjectCollection(); + $coll->setModel('Book'); + $coll->fromJSON($expected); + // fix modified columns order + foreach ($coll as $book) { + $book->resetModified(); + } + + $this->assertEquals($this->coll, $coll); + } + + public function toCsvDataProvider() + { + $expected = "Id,Title,ISBN,Price,PublisherId,AuthorId\r\n9012,Don Juan,0140422161,12.99,1234,5678\r\n58,Harry Potter and the Order of the Phoenix,043935806X,10.99,N;,N;\r\n"; + + return array(array($expected)); + } + + /** + * @dataProvider toCsvDataProvider + */ + public function testToCSV($expected) + { + $this->assertEquals($expected, $this->coll->toCSV()); + } + + /** + * @dataProvider toCsvDataProvider + */ + public function testfromCSV($expected) + { + $coll = new PropelObjectCollection(); + $coll->setModel('Book'); + $coll->fromCSV($expected); + // fix modified columns order + foreach ($coll as $book) { + $book->resetModified(); + } + + $this->assertEquals($this->coll, $coll); + } + + /** + * @dataProvider toYamlDataProvider + */ + public function testToStringUsesDefaultStringFormat($expected) + { + $this->assertEquals($expected, (string) $this->coll, 'PropelCollection::__toString() uses the YAML representation by default'); + } + + public function testToStringUsesCustomStringFormat() + { + $coll = new PropelObjectCollection(); + $coll->setModel('Publisher'); + $publisher = new Publisher(); + $publisher->setId(12345); + $publisher->setName('Penguinoo'); + $coll[]= $publisher; + $expected = << + + + 12345 + + + + +EOF; + $this->assertEquals($expected, (string) $coll); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelCollectionTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelCollectionTest.php index fa76def29..3e32ebdba 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelCollectionTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelCollectionTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; /** * Test class for PropelCollection. @@ -19,335 +19,444 @@ require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; */ class PropelCollectionTest extends BookstoreTestBase { - public function testArrayAccess() - { - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $this->assertEquals('bar1', $col[0], 'PropelCollection allows access via $foo[$index]'); - $this->assertEquals('bar2', $col[1], 'PropelCollection allows access via $foo[$index]'); - $this->assertEquals('bar3', $col[2], 'PropelCollection allows access via $foo[$index]'); - } + public function testArrayAccess() + { + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $this->assertEquals('bar1', $col[0], 'PropelCollection allows access via $foo[$index]'); + $this->assertEquals('bar2', $col[1], 'PropelCollection allows access via $foo[$index]'); + $this->assertEquals('bar3', $col[2], 'PropelCollection allows access via $foo[$index]'); + } - public function testGetData() - { - $col = new PropelCollection(); - $this->assertEquals(array(), $col->getData(), 'getData() returns an empty array for empty collections'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $this->assertEquals($data, $col->getData(), 'getData() returns the collection data'); - $col[0] = 'bar4'; - $this->assertEquals('bar1', $data[0], 'getData() returns a copy of the collection data'); - } + public function testGetData() + { + $col = new PropelCollection(); + $this->assertEquals(array(), $col->getData(), 'getData() returns an empty array for empty collections'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $this->assertEquals($data, $col->getData(), 'getData() returns the collection data'); + $col[0] = 'bar4'; + $this->assertEquals('bar1', $data[0], 'getData() returns a copy of the collection data'); + } - public function testSetData() - { - $col = new PropelCollection(); - $col->setData(array()); - $this->assertEquals(array(), $col->getArrayCopy(), 'setData() can set data to an empty array'); + public function testCloneContainingScalar() + { + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection(); - $col->setData($data); - $this->assertEquals($data, $col->getArrayCopy(), 'setData() sets the collection data'); - } - - public function testGetPosition() - { - $col = new PropelCollection(); - $this->assertEquals(0, $col->getPosition(), 'getPosition() returns 0 on an empty collection'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $expectedPositions = array(0, 1, 2); - foreach ($col as $element) { - $this->assertEquals(array_shift($expectedPositions), $col->getPosition(), 'getPosition() returns the current position'); - $this->assertEquals($element, $col->getCurrent(), 'getPosition() does not change the current position'); - } - } - - public function testGetFirst() - { - $col = new PropelCollection(); - $this->assertNull($col->getFirst(), 'getFirst() returns null on an empty collection'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $this->assertEquals('bar1', $col->getFirst(), 'getFirst() returns value of the first element in the collection'); - } + $clone = clone $col; - public function testIsFirst() - { - $col = new PropelCollection(); - $this->assertTrue($col->isFirst(), 'isFirst() returns true on an empty collection'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $expectedRes = array(true, false, false); - foreach ($col as $element) { - $this->assertEquals(array_shift($expectedRes), $col->isFirst(), 'isFirst() returns true only for the first element'); - $this->assertEquals($element, $col->getCurrent(), 'isFirst() does not change the current position'); - } - } - - public function testGetPrevious() - { - $col = new PropelCollection(); - $this->assertNull($col->getPrevious(), 'getPrevious() returns null on an empty collection'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $this->assertNull($col->getPrevious(), 'getPrevious() returns null when the internal pointer is at the beginning of the list'); - $col->getNext(); - $this->assertEquals('bar1', $col->getPrevious(), 'getPrevious() returns the previous element'); - $this->assertEquals('bar1', $col->getCurrent(), 'getPrevious() decrements the internal pointer'); - } + $orgCount = $col->getIterator()->count(); + $cloneCount = $clone->getIterator()->count(); - public function testGetCurrent() - { - $col = new PropelCollection(); - $this->assertNull($col->getCurrent(), 'getCurrent() returns null on an empty collection'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $this->assertEquals('bar1', $col->getCurrent(), 'getCurrent() returns the value of the first element when the internal pointer is at the beginning of the list'); - foreach ($col as $key => $value) { - $this->assertEquals($value, $col->getCurrent(), 'getCurrent() returns the value of the current element in the collection'); - } - } - - public function testGetNext() - { - $col = new PropelCollection(); - $this->assertNull($col->getNext(), 'getNext() returns null on an empty collection'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $this->assertEquals('bar2', $col->getNext(), 'getNext() returns the second element when the internal pointer is at the beginning of the list'); - $this->assertEquals('bar2', $col->getCurrent(), 'getNext() increments the internal pointer'); - $col->getNext(); - $this->assertNull($col->getNext(), 'getNext() returns null when the internal pointer is at the end of the list'); - } + $this->assertEquals($orgCount, $cloneCount, 'all entries will be cloned'); + } - public function testGetLast() - { - $col = new PropelCollection(); - $this->assertNull($col->getLast(), 'getLast() returns null on an empty collection'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $this->assertEquals('bar3', $col->getLast(), 'getLast() returns the last element'); - $this->assertEquals('bar3', $col->getCurrent(), 'getLast() moves the internal pointer to the last element'); - } + public function testCloneContainingObjects() + { + $a = new Author(); + $b= new Book(); + $b->setAuthor($a); + $b->setISBN('ISBN1'); - public function testIsLAst() - { - $col = new PropelCollection(); - $this->assertTrue($col->isLast(), 'isLast() returns true on an empty collection'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $expectedRes = array(false, false, true); - foreach ($col as $element) { - $this->assertEquals(array_shift($expectedRes), $col->isLast(), 'isLast() returns true only for the last element'); - $this->assertEquals($element, $col->getCurrent(), 'isLast() does not change the current position'); - } - } + $b1 = new Book(); + $b1->setPrice(5.55); - public function testIsEmpty() - { - $col = new PropelCollection(); - $this->assertTrue($col->isEmpty(), 'isEmpty() returns true on an empty collection'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $this->assertFalse($col->isEmpty(), 'isEmpty() returns false on a non empty collection'); - } + $col = new PropelCollection(array($b, $b1)); + $clone = clone $col; - public function testIsOdd() - { - $col = new PropelCollection(); - $this->assertFalse($col->isOdd(), 'isOdd() returns false on an empty collection'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection(); - $col->setData($data); - foreach ($col as $key => $value) { - $this->assertEquals((boolean) ($key % 2), $col->isOdd(), 'isOdd() returns true only when the key is odd'); - } - } + $orgCount = $col->getIterator()->count(); + $cloneCount = $clone->getIterator()->count(); + $this->assertEquals($orgCount, $cloneCount, 'cloned collections have the same size'); - public function testIsEven() - { - $col = new PropelCollection(); - $this->assertTrue($col->isEven(), 'isEven() returns true on an empty collection'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection(); - $col->setData($data); - foreach ($col as $key => $value) { - $this->assertEquals(!(boolean) ($key % 2), $col->isEven(), 'isEven() returns true only when the key is even'); - } - } - - public function testGet() - { - $col = new PropelCollection(array('foo', 'bar')); - $this->assertEquals('foo', $col->get(0), 'get() returns an element from its key'); - } + $this->assertEquals($b, $clone[0], 'cloned objects are equal'); + $this->assertEquals($b1, $clone[1], 'cloned objects are equal'); - /** - * @expectedException PropelException - */ - public function testGetUnknownOffset() - { - $col = new PropelCollection(); - $bar = $col->get('foo'); - } + $this->assertNotSame($b, $clone[0], 'cloned objects are copies, not identical'); + $this->assertNotSame($b1, $clone[1], 'cloned objects are copies, not identical'); + } - public function testPop() - { - $col = new PropelCollection(); - $this->assertNull($col->pop(), 'pop() returns null on an empty collection'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $this->assertEquals('bar3', $col->pop(), 'pop() returns the last element of the collection'); - $this->assertEquals(array('bar1', 'bar2'), $col->getData(), 'pop() removes the last element of the collection'); - } + public function testSetData() + { + $col = new PropelCollection(); + $col->setData(array()); + $this->assertEquals(array(), $col->getArrayCopy(), 'setData() can set data to an empty array'); - public function testShift() - { - $col = new PropelCollection(); - $this->assertNull($col->shift(), 'shift() returns null on an empty collection'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $this->assertEquals('bar1', $col->shift(), 'shift() returns the first element of the collection'); - $this->assertEquals(array('bar2', 'bar3'), $col->getData(), 'shift() removes the first element of the collection'); - } + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection(); + $col->setData($data); + $this->assertEquals($data, $col->getArrayCopy(), 'setData() sets the collection data'); + } - public function testPrepend() - { - $col = new PropelCollection(); - $this->assertEquals(1, $col->prepend('a'), 'prepend() returns 1 on an empty collection'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $this->assertEquals(4, $col->prepend('bar4'), 'prepend() returns the new number of elements in the collection when adding a variable'); - $this->assertEquals(array('bar4', 'bar1', 'bar2', 'bar3'), $col->getData(), 'prepend() adds new element to the beginning of the collection'); - } + public function testGetPosition() + { + $col = new PropelCollection(); + $this->assertEquals(0, $col->getPosition(), 'getPosition() returns 0 on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $expectedPositions = array(0, 1, 2); + foreach ($col as $element) { + $this->assertEquals(array_shift($expectedPositions), $col->getPosition(), 'getPosition() returns the current position'); + $this->assertEquals($element, $col->getCurrent(), 'getPosition() does not change the current position'); + } + } - public function testSet() - { - $col = new PropelCollection(); - $col->set(4, 'bar'); - $this->assertEquals(array(4 => 'bar'), $col->getData(), 'set() adds an element to the collection with a key'); + public function testGetFirst() + { + $col = new PropelCollection(); + $this->assertNull($col->getFirst(), 'getFirst() returns null on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $this->assertEquals('bar1', $col->getFirst(), 'getFirst() returns value of the first element in the collection'); + } - $col = new PropelCollection(); - $col->set(null, 'foo'); - $col->set(null, 'bar'); - $this->assertEquals(array('foo', 'bar'), $col->getData(), 'set() adds an element to the collection without a key'); - } - - public function testRemove() - { - $col = new PropelCollection(); - $col[0] = 'bar'; - $col[1] = 'baz'; - $col->remove(1); - $this->assertEquals(array('bar'), $col->getData(), 'remove() removes an element from its key'); - } - - /** - * @expectedException PropelException - */ - public function testRemoveUnknownOffset() - { - $col = new PropelCollection(); - $col->remove(2); - } + public function testIsFirst() + { + $col = new PropelCollection(); + $this->assertTrue($col->isFirst(), 'isFirst() returns true on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $expectedRes = array(true, false, false); + foreach ($col as $element) { + $this->assertEquals(array_shift($expectedRes), $col->isFirst(), 'isFirst() returns true only for the first element'); + $this->assertEquals($element, $col->getCurrent(), 'isFirst() does not change the current position'); + } + } - public function testClear() - { - $col = new PropelCollection(); - $col->clear(); - $this->assertEquals(array(), $col->getData(), 'clear() empties the collection'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $col->clear(); - $this->assertEquals(array(), $col->getData(), 'clear() empties the collection'); - } - - public function testContains() - { - $col = new PropelCollection(); - $this->assertFalse($col->contains('foo_1'), 'contains() returns false on an empty collection'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $this->assertTrue($col->contains('bar1'), 'contains() returns true when the key exists'); - $this->assertFalse($col->contains('bar4'), 'contains() returns false when the key does not exist'); - } + public function testGetPrevious() + { + $col = new PropelCollection(); + $this->assertNull($col->getPrevious(), 'getPrevious() returns null on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $this->assertNull($col->getPrevious(), 'getPrevious() returns null when the internal pointer is at the beginning of the list'); + $col->getNext(); + $this->assertEquals('bar1', $col->getPrevious(), 'getPrevious() returns the previous element'); + $this->assertEquals('bar1', $col->getCurrent(), 'getPrevious() decrements the internal pointer'); + } - public function testSearch() - { - $col = new PropelCollection(); - $this->assertFalse($col->search('bar1'), 'search() returns false on an empty collection'); - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $this->assertEquals(1, $col->search('bar2'), 'search() returns the key when the element exists'); - $this->assertFalse($col->search('bar4'), 'search() returns false when the element does not exist'); - } - - public function testSerializable() - { - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $col->setModel('Foo'); - $serializedCol = serialize($col); - - $col2 = unserialize($serializedCol); - $this->assertEquals($col, $col2, 'PropelCollection is serializable'); - } - - public function testGetIterator() - { - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $it1 = $col->getIterator(); - $it2 = $col->getIterator(); - $this->assertNotSame($it1, $it2, 'getIterator() returns always a new iterator'); - } + public function testGetCurrent() + { + $col = new PropelCollection(); + $this->assertNull($col->getCurrent(), 'getCurrent() returns null on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $this->assertEquals('bar1', $col->getCurrent(), 'getCurrent() returns the value of the first element when the internal pointer is at the beginning of the list'); + foreach ($col as $key => $value) { + $this->assertEquals($value, $col->getCurrent(), 'getCurrent() returns the value of the current element in the collection'); + } + } - public function testGetInternalIterator() - { - $data = array('bar1', 'bar2', 'bar3'); - $col = new PropelCollection($data); - $it1 = $col->getInternalIterator(); - $it2 = $col->getINternalIterator(); - $this->assertSame($it1, $it2, 'getInternalIterator() returns always the same iterator'); - $col->getInternalIterator()->next(); - $this->assertEquals('bar2', $col->getInternalIterator()->current(), 'getInternalIterator() returns always the same iterator'); - } + public function testGetNext() + { + $col = new PropelCollection(); + $this->assertNull($col->getNext(), 'getNext() returns null on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $this->assertEquals('bar2', $col->getNext(), 'getNext() returns the second element when the internal pointer is at the beginning of the list'); + $this->assertEquals('bar2', $col->getCurrent(), 'getNext() increments the internal pointer'); + $col->getNext(); + $this->assertNull($col->getNext(), 'getNext() returns null when the internal pointer is at the end of the list'); + } - public function testGetPeerClass() - { - $col = new PropelCollection(); - $col->setModel('Book'); - $this->assertEquals('BookPeer', $col->getPeerClass(), 'getPeerClass() returns the Peer class for the collection model'); - } + public function testGetLast() + { + $col = new PropelCollection(); + $this->assertNull($col->getLast(), 'getLast() returns null on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $this->assertEquals('bar3', $col->getLast(), 'getLast() returns the last element'); + $this->assertEquals('bar3', $col->getCurrent(), 'getLast() moves the internal pointer to the last element'); + } - /** - * @expectedException PropelException - */ - public function testGetPeerClassNoModel() - { - $col = new PropelCollection(); - $col->getPeerClass(); - } - - public function testGetConnection() - { - $col = new PropelCollection(); - $col->setModel('Book'); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $this->assertEquals($con, $col->getConnection(), 'getConnection() returns a connection for the collection model'); - $con = Propel::getConnection(BookPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - $this->assertEquals($con, $col->getConnection(Propel::CONNECTION_WRITE), 'getConnection() accepts a connection type parameter'); - } + public function testIsLAst() + { + $col = new PropelCollection(); + $this->assertTrue($col->isLast(), 'isLast() returns true on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $expectedRes = array(false, false, true); + foreach ($col as $element) { + $this->assertEquals(array_shift($expectedRes), $col->isLast(), 'isLast() returns true only for the last element'); + $this->assertEquals($element, $col->getCurrent(), 'isLast() does not change the current position'); + } + } - /** - * @expectedException PropelException - */ - public function testGetConnectionNoModel() - { - $col = new PropelCollection(); - $col->getConnection(); - } + public function testIsEmpty() + { + $col = new PropelCollection(); + $this->assertTrue($col->isEmpty(), 'isEmpty() returns true on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $this->assertFalse($col->isEmpty(), 'isEmpty() returns false on a non empty collection'); + } -} \ No newline at end of file + public function testIsOdd() + { + $col = new PropelCollection(); + $this->assertFalse($col->isOdd(), 'isOdd() returns false on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection(); + $col->setData($data); + foreach ($col as $key => $value) { + $this->assertEquals((boolean) ($key % 2), $col->isOdd(), 'isOdd() returns true only when the key is odd'); + } + } + + public function testIsEven() + { + $col = new PropelCollection(); + $this->assertTrue($col->isEven(), 'isEven() returns true on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection(); + $col->setData($data); + foreach ($col as $key => $value) { + $this->assertEquals(!(boolean) ($key % 2), $col->isEven(), 'isEven() returns true only when the key is even'); + } + } + + public function testGet() + { + $col = new PropelCollection(array('foo', 'bar')); + $this->assertEquals('foo', $col->get(0), 'get() returns an element from its key'); + } + + /** + * @expectedException PropelException + */ + public function testGetUnknownOffset() + { + $col = new PropelCollection(); + $bar = $col->get('foo'); + } + + public function testPop() + { + $col = new PropelCollection(); + $this->assertNull($col->pop(), 'pop() returns null on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $this->assertEquals('bar3', $col->pop(), 'pop() returns the last element of the collection'); + $this->assertEquals(array('bar1', 'bar2'), $col->getData(), 'pop() removes the last element of the collection'); + } + + public function testShift() + { + $col = new PropelCollection(); + $this->assertNull($col->shift(), 'shift() returns null on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $this->assertEquals('bar1', $col->shift(), 'shift() returns the first element of the collection'); + $this->assertEquals(array('bar2', 'bar3'), $col->getData(), 'shift() removes the first element of the collection'); + } + + public function testPrepend() + { + $col = new PropelCollection(); + $this->assertEquals(1, $col->prepend('a'), 'prepend() returns 1 on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $this->assertEquals(4, $col->prepend('bar4'), 'prepend() returns the new number of elements in the collection when adding a variable'); + $this->assertEquals(array('bar4', 'bar1', 'bar2', 'bar3'), $col->getData(), 'prepend() adds new element to the beginning of the collection'); + } + + public function testSet() + { + $col = new PropelCollection(); + $col->set(4, 'bar'); + $this->assertEquals(array(4 => 'bar'), $col->getData(), 'set() adds an element to the collection with a key'); + + $col = new PropelCollection(); + $col->set(null, 'foo'); + $col->set(null, 'bar'); + $this->assertEquals(array('foo', 'bar'), $col->getData(), 'set() adds an element to the collection without a key'); + } + + public function testRemove() + { + $col = new PropelCollection(); + $col[0] = 'bar'; + $col[1] = 'baz'; + $col->remove(1); + $this->assertEquals(array('bar'), $col->getData(), 'remove() removes an element from its key'); + } + + /** + * @expectedException PropelException + */ + public function testRemoveUnknownOffset() + { + $col = new PropelCollection(); + $col->remove(2); + } + + public function testClear() + { + $col = new PropelCollection(); + $col->clear(); + $this->assertEquals(array(), $col->getData(), 'clear() empties the collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $col->clear(); + $this->assertEquals(array(), $col->getData(), 'clear() empties the collection'); + } + + public function testContains() + { + $col = new PropelCollection(); + $this->assertFalse($col->contains('foo_1'), 'contains() returns false on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $this->assertTrue($col->contains('bar1'), 'contains() returns true when the key exists'); + $this->assertFalse($col->contains('bar4'), 'contains() returns false when the key does not exist'); + } + + public function testSearch() + { + $col = new PropelCollection(); + $this->assertFalse($col->search('bar1'), 'search() returns false on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $this->assertEquals(1, $col->search('bar2'), 'search() returns the key when the element exists'); + $this->assertFalse($col->search('bar4'), 'search() returns false when the element does not exist'); + } + + public function testSerializable() + { + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $col->setModel('Foo'); + $serializedCol = serialize($col); + + $col2 = unserialize($serializedCol); + $this->assertEquals($col, $col2, 'PropelCollection is serializable'); + } + + public function testGetIterator() + { + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $it1 = $col->getIterator(); + $it2 = $col->getIterator(); + $this->assertNotSame($it1, $it2, 'getIterator() returns always a new iterator'); + } + + public function testGetInternalIterator() + { + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelCollection($data); + $it1 = $col->getInternalIterator(); + $it2 = $col->getINternalIterator(); + $this->assertSame($it1, $it2, 'getInternalIterator() returns always the same iterator'); + $col->getInternalIterator()->next(); + $this->assertEquals('bar2', $col->getInternalIterator()->current(), 'getInternalIterator() returns always the same iterator'); + } + + public function testGetPeerClass() + { + $col = new PropelCollection(); + $col->setModel('Book'); + $this->assertEquals('BookPeer', $col->getPeerClass(), 'getPeerClass() returns the Peer class for the collection model'); + } + + /** + * @expectedException PropelException + */ + public function testGetPeerClassNoModel() + { + $col = new PropelCollection(); + $col->getPeerClass(); + } + + public function testGetConnection() + { + $col = new PropelCollection(); + $col->setModel('Book'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $this->assertEquals($con, $col->getConnection(), 'getConnection() returns a connection for the collection model'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); + $this->assertEquals($con, $col->getConnection(Propel::CONNECTION_WRITE), 'getConnection() accepts a connection type parameter'); + } + + /** + * @expectedException PropelException + */ + public function testGetConnectionNoModel() + { + $col = new PropelCollection(); + $col->getConnection(); + } + + public function testDiffWithEmptyCollectionReturnsCurrentCollection() + { + $col1 = new PropelCollection(); + $col2 = new PropelCollection(); + + $b = new Book(); + $col1[] = $b; + + $result = $col1->diff($col2); + + $this->assertInstanceOf('PropelCollection', $result); + $this->assertEquals(1, count($result)); + $this->assertSame($b, $result[0]); + } + + public function testDiffWithEmptyCollections() + { + $col1 = new PropelCollection(); + $col2 = new PropelCollection(); + + $result = $col1->diff($col2); + + $this->assertInstanceOf('PropelCollection', $result); + $this->assertEquals(0, count($result)); + } + + public function testDiffWithASimilarCollectionReturnsAnEmptyCollection() + { + $col1 = new PropelCollection(); + $col2 = new PropelCollection(); + + $b = new Book(); + $col1[] = $b; + $col2[] = $b; + + $result = $col1->diff($col2); + + $this->assertInstanceOf('PropelCollection', $result); + $this->assertEquals(0, count($result)); + } + + public function testDiffWithNonEmptyCollectionReturnsObjectsInTheFirstCollectionWhichAreNotInTheSecondCollection() + { + $col1 = new PropelCollection(); + $col2 = new PropelCollection(); + + $b = new Book(); + $b1 = new Book(); + $col1[] = $b; + $col1[] = $b1; + $col2[] = $b; + + $result = $col1->diff($col2); + + $this->assertInstanceOf('PropelCollection', $result); + $this->assertCount(1, $result); + $this->assertSame($b1, $result[0]); + } + + public function testDiffWithACollectionHavingObjectsNotPresentInTheFirstCollection() + { + $col1 = new PropelCollection(); + $col2 = new PropelCollection(); + + $b = new Book(); + $col2[] = $b; + + $result = $col1->diff($col2); + + $this->assertInstanceOf('PropelCollection', $result); + $this->assertEquals(0, count($result)); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelObjectCollectionTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelObjectCollectionTest.php index 55c14f2a9..cdfc127c9 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelObjectCollectionTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelObjectCollectionTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; /** * Test class for PropelObjectCollection. @@ -17,220 +17,275 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; * @version $Id: PropelObjectCollectionTest.php 1348 2009-12-03 21:49:00Z francois $ * @package runtime.collection */ -class PropelObjectCollectionTest extends BookstoreEmptyTestBase +class PropelObjectCollectionTest extends BookstoreTestBase { - protected function setUp() - { - parent::setUp(); - BookstoreDataPopulator::populate($this->con); - } - - public function testSave() - { - $books = PropelQuery::from('Book')->find(); - foreach ($books as $book) { - $book->setTitle('foo'); - } - $books->save(); - // check that all the books are saved - foreach ($books as $book) { - $this->assertFalse($book->isModified()); - } - // check that the modifications are persisted - BookPeer::clearInstancePool(); - $books = PropelQuery::from('Book')->find(); - foreach ($books as $book) { - $this->assertEquals('foo', $book->getTitle('foo')); - } - } - public function testDelete() - { - $books = PropelQuery::from('Book')->find(); - $books->delete(); - // check that all the books are deleted - foreach ($books as $book) { - $this->assertTrue($book->isDeleted()); - } - // check that the modifications are persisted - BookPeer::clearInstancePool(); - $books = PropelQuery::from('Book')->find(); - $this->assertEquals(0, count($books)); - } - - public function testGetPrimaryKeys() - { - $books = PropelQuery::from('Book')->find(); - $pks = $books->getPrimaryKeys(); - $this->assertEquals(4, count($pks)); - - $keys = array('Book_0', 'Book_1', 'Book_2', 'Book_3'); - $this->assertEquals($keys, array_keys($pks)); - - $pks = $books->getPrimaryKeys(false); - $keys = array(0, 1, 2, 3); - $this->assertEquals($keys, array_keys($pks)); - - foreach ($pks as $key => $value) { - $this->assertEquals($books[$key]->getPrimaryKey(), $value); - } - } + public function testContains() + { + $col = new PropelObjectCollection(); + $book1 = new Book(); + $book1->setTitle('Foo'); + $book2 = new Book(); + $book2->setTitle('Bar'); + $col = new PropelObjectCollection(); + $this->assertFalse($col->contains($book1)); + $this->assertFalse($col->contains($book2)); + $col []= $book1; + $this->assertTrue($col->contains($book1)); + $this->assertFalse($col->contains($book2)); + } - public function testFromArray() - { - $author = new Author(); - $author->setFirstName('Jane'); - $author->setLastName('Austen'); - $author->save(); - $books = array( - array('Title' => 'Mansfield Park', 'AuthorId' => $author->getId()), - array('Title' => 'Pride And PRejudice', 'AuthorId' => $author->getId()) - ); - $col = new PropelObjectCollection(); - $col->setModel('Book'); - $col->fromArray($books); - $col->save(); - - $nbBooks = PropelQuery::from('Book')->count(); - $this->assertEquals(6, $nbBooks); - - $booksByJane = PropelQuery::from('Book b') - ->join('b.Author a') - ->where('a.LastName = ?', 'Austen') - ->count(); - $this->assertEquals(2, $booksByJane); - } - - public function testToArray() - { - $books = PropelQuery::from('Book')->find(); - $booksArray = $books->toArray(); - $this->assertEquals(4, count($booksArray)); - - foreach ($booksArray as $key => $book) { - $this->assertEquals($books[$key]->toArray(), $book); - } - - $booksArray = $books->toArray(); - $keys = array(0, 1, 2, 3); - $this->assertEquals($keys, array_keys($booksArray)); - - $booksArray = $books->toArray(null, true); - $keys = array('Book_0', 'Book_1', 'Book_2', 'Book_3'); - $this->assertEquals($keys, array_keys($booksArray)); + /** + * @expectedException PropelException + */ + public function testSaveOnReadOnlyEntityThrowsException() + { + $col = new PropelObjectCollection(); + $col->setModel('ContestView'); + $cv = new ContestView(); + $col []= $cv; + $col->save(); + } - $booksArray = $books->toArray('Title'); - $keys = array('Harry Potter and the Order of the Phoenix', 'Quicksilver', 'Don Juan', 'The Tin Drum'); - $this->assertEquals($keys, array_keys($booksArray)); + /** + * @expectedException PropelException + */ + public function testDeleteOnReadOnlyEntityThrowsException() + { + $col = new PropelObjectCollection(); + $col->setModel('ContestView'); + $cv = new ContestView(); + $cv->setNew(false); + $col []= $cv; + $col->delete(); + } - $booksArray = $books->toArray('Title', true); - $keys = array('Book_Harry Potter and the Order of the Phoenix', 'Book_Quicksilver', 'Book_Don Juan', 'Book_The Tin Drum'); - $this->assertEquals($keys, array_keys($booksArray)); - } + public function testGetPrimaryKeys() + { + $books = new PropelObjectCollection(); + $books->setModel('Book'); + for ($i=0; $i < 4; $i++) { + $book = new Book(); + $book->setTitle('Title' . $i); + $book->setIsbn('124' . $i); + $book->save($this->con); - public function testGetArrayCopy() - { - $books = PropelQuery::from('Book')->find(); - $booksArray = $books->getArrayCopy(); - $this->assertEquals(4, count($booksArray)); - - foreach ($booksArray as $key => $book) { - $this->assertEquals($books[$key], $book); - } - - $booksArray = $books->getArrayCopy(); - $keys = array(0, 1, 2, 3); - $this->assertEquals($keys, array_keys($booksArray)); - - $booksArray = $books->getArrayCopy(null, true); - $keys = array('Book_0', 'Book_1', 'Book_2', 'Book_3'); - $this->assertEquals($keys, array_keys($booksArray)); + $books []= $book; + } - $booksArray = $books->getArrayCopy('Title'); - $keys = array('Harry Potter and the Order of the Phoenix', 'Quicksilver', 'Don Juan', 'The Tin Drum'); - $this->assertEquals($keys, array_keys($booksArray)); + $pks = $books->getPrimaryKeys(); + $this->assertEquals(4, count($pks)); - $booksArray = $books->getArrayCopy('Title', true); - $keys = array('Book_Harry Potter and the Order of the Phoenix', 'Book_Quicksilver', 'Book_Don Juan', 'Book_The Tin Drum'); - $this->assertEquals($keys, array_keys($booksArray)); - } + $keys = array('Book_0', 'Book_1', 'Book_2', 'Book_3'); + $this->assertEquals($keys, array_keys($pks)); - public function testToKeyValue() - { - $books = PropelQuery::from('Book')->find(); - - $expected = array(); - foreach ($books as $book) { - $expected[$book->getTitle()] = $book->getISBN(); - } - $booksArray = $books->toKeyValue('Title', 'ISBN'); - $this->assertEquals(4, count($booksArray)); - $this->assertEquals($expected, $booksArray, 'toKeyValue() turns the collection to an associative array'); + $pks = $books->getPrimaryKeys(false); + $keys = array(0, 1, 2, 3); + $this->assertEquals($keys, array_keys($pks)); - $expected = array(); - foreach ($books as $book) { - $expected[$book->getISBN()] = $book->getTitle(); - } - $booksArray = $books->toKeyValue('ISBN'); - $this->assertEquals($expected, $booksArray, 'toKeyValue() uses __toString() for the value if no second field name is passed'); - - $expected = array(); - foreach ($books as $book) { - $expected[$book->getId()] = $book->getTitle(); - } - $booksArray = $books->toKeyValue(); - $this->assertEquals($expected, $booksArray, 'toKeyValue() uses primary key for the key and __toString() for the value if no field name is passed'); - } + foreach ($pks as $key => $value) { + $this->assertEquals($books[$key]->getPrimaryKey(), $value); + } + } - public function testPopulateRelation() - { - AuthorPeer::clearInstancePool(); - BookPeer::clearInstancePool(); - $authors = AuthorQuery::create()->find(); - $books = $authors->populateRelation('Book'); - $this->assertTrue($books instanceof PropelObjectCollection, 'populateRelation() returns a PropelCollection instance'); - $this->assertEquals('Book', $books->getModel(), 'populateRelation() returns a collection of the related objects'); - $this->assertEquals(4, count($books), 'populateRelation() the list of related objects'); - } + public function testToArrayDeep() + { + $author = new Author(); + $author->setId(5678); + $author->setFirstName('George'); + $author->setLastName('Byron'); + $book = new Book(); + $book->setId(9012); + $book->setTitle('Don Juan'); + $book->setISBN('0140422161'); + $book->setPrice(12.99); + $book->setAuthor($author); - public function testPopulateRelationCriteria() - { - AuthorPeer::clearInstancePool(); - BookPeer::clearInstancePool(); - $authors = AuthorQuery::create()->find(); - $c = new Criteria(); - $c->setLimit(3); - $books = $authors->populateRelation('Book', $c); - $this->assertEquals(3, count($books), 'populateRelation() accepts an optional criteria object to filter the query'); - } - - public function testPopulateRelationOneToMany() - { - $con = Propel::getConnection(); - AuthorPeer::clearInstancePool(); - BookPeer::clearInstancePool(); - $authors = AuthorQuery::create()->find($con); - $count = $con->getQueryCount(); - $books = $authors->populateRelation('Book', null, $con); - foreach ($authors as $author) { - foreach ($author->getBooks() as $book) { - $this->assertEquals($author, $book->getAuthor()); - } - } - $this->assertEquals($count + 1, $con->getQueryCount(), 'populateRelation() populates a one-to-many relationship with a single supplementary query'); - } - - public function testPopulateRelationManyToOne() - { - $con = Propel::getConnection(); - AuthorPeer::clearInstancePool(); - BookPeer::clearInstancePool(); - $books = BookQuery::create()->find($con); - $count = $con->getQueryCount(); - $books->populateRelation('Author', null, $con); - foreach ($books as $book) { - $author = $book->getAuthor(); - } - $this->assertEquals($count + 1, $con->getQueryCount(), 'populateRelation() populates a many-to-one relationship with a single supplementary query'); - } -} \ No newline at end of file + $coll = new PropelObjectCollection(); + $coll->setModel('Book'); + $coll[]= $book; + $expected = array(array( + 'Id' => 9012, + 'Title' => 'Don Juan', + 'ISBN' => '0140422161', + 'Price' => 12.99, + 'PublisherId' => null, + 'AuthorId' => 5678, + 'Author' => array( + 'Id' => 5678, + 'FirstName' => 'George', + 'LastName' => 'Byron', + 'Email' => null, + 'Age' => null, + 'Books' => array( + 'Book_0' => '*RECURSION*', + ) + ), + )); + $this->assertEquals($expected, $coll->toArray()); + } + + public function testPopulateRelationOneToManyWithEmptyCollection() + { + $author = new Author(); + $author->setLastName('I who never wrote'); + $author->setFirstName('Foo'); + $author->save($this->con); + AuthorPeer::clearInstancePool(); + BookPeer::clearInstancePool(); + $coll = new PropelObjectCollection(); + $coll->setFormatter(new PropelObjectFormatter(new ModelCriteria(null, 'Author'))); + $coll []= $author; + $books = $coll->populateRelation('Book', null, $this->con); + $this->assertEquals(0, $books->count()); + $count = $this->con->getQueryCount(); + $this->assertEquals(0, $author->countBooks()); + $this->assertEquals($count, $this->con->getQueryCount()); + } + + public function testToKeyValue() + { + $author = new Author(); + $author->setId(5678); + $author->setFirstName('George'); + $author->setLastName('Byron'); + + $book = new Book(); + $book->setId(9012); + $book->setTitle('Don Juan'); + $book->setISBN('0140422161'); + $book->setPrice(12.99); + $book->setAuthor($author); + + $coll = new PropelObjectCollection(); + $coll->setModel('Book'); + $coll->append($book); + + $this->assertCount(1, $coll); + + // This will call $book->getId() + $this->assertEquals(array( + 9012 => 'Don Juan', + ), $coll->toKeyValue('Id', 'Title')); + + // This will call: $book->getAuthor()->getBooks()->getFirst()->getId() + $this->assertEquals(array( + 9012 => 'Don Juan', + ), $coll->toKeyValue(array('Author', 'Books', 'First', 'Id'), 'Title')); + } + + public function testContainsWithNoPersistentElements() + { + $col = new PropelObjectCollection(); + $this->assertFalse($col->contains('foo_1'), 'contains() returns false on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelObjectCollection($data); + $this->assertTrue($col->contains('bar1'), 'contains() returns true when the key exists'); + $this->assertFalse($col->contains('bar4'), 'contains() returns false when the key does not exist'); + } + + public function testSearchWithNoPersistentElements() + { + $col = new PropelObjectCollection(); + $this->assertFalse($col->search('bar1'), 'search() returns false on an empty collection'); + $data = array('bar1', 'bar2', 'bar3'); + $col = new PropelObjectCollection($data); + $this->assertEquals(1, $col->search('bar2'), 'search() returns the key when the element exists'); + $this->assertFalse($col->search('bar4'), 'search() returns false when the element does not exist'); + } + + public function testContainsWithClassicBehavior() + { + $col = new PropelObjectCollection(); + $b1 = new Book(); + $b1->setTitle('Bar'); + $b2 = new Book(); + $b2->setTitle('Foo'); + + $this->assertFalse($col->contains($b1), 'contains() returns false on an empty collection'); + + $col = new PropelObjectCollection(array($b1)); + + $this->assertTrue($col->contains($b1), 'contains() returns true when the key exists'); + $this->assertFalse($col->contains($b2), 'contains() returns false when the key does not exist'); + } + + public function testSearchWithClassicBehavior() + { + $col = new PropelObjectCollection(); + $b1 = new Book(); + $b1->setTitle('Bar'); + $b2 = new Book(); + $b2->setTitle('Foo'); + + $this->assertFalse($col->search($b1), 'search() returns false on an empty collection'); + + $col = new PropelObjectCollection(array($b1)); + $this->assertEquals(0, $col->search($b1), 'search() returns the key when the element exists'); + $this->assertFalse($col->search($b2), 'search() returns false when the element does not exist'); + } + + public function testContainsMatchesSimilarObjects() + { + $col = new PropelObjectCollection(); + $b1 = new Book(); + $b1->setTitle('Bar'); + $b1->setIsbn('1224'); + $b1->save(); + + $b2 = clone $b1; + + $this->assertFalse($col->contains($b1), 'contains() returns false on an empty collection'); + + $col = new PropelObjectCollection(array($b1)); + + $this->assertTrue($col->contains($b1)); + $this->assertTrue($col->contains($b2)); + } + + public function testSearchMatchesSimilarObjects() + { + $col = new PropelObjectCollection(); + $b1 = new Book(); + $b1->setTitle('Bar'); + $b1->setIsbn('1234'); + $b1->save(); + + $b2 = clone $b1; + + $this->assertFalse($col->search($b1), 'search() returns false on an empty collection'); + + $col = new PropelObjectCollection(array($b1)); + $this->assertTrue(0 === $col->search($b1)); + $this->assertTrue(0 === $col->search($b2)); + } + + public function testContainsMatchesSimilarNewObjects() + { + $col = new PropelObjectCollection(); + $b1 = new Book(); + $b1->setTitle('Bar'); + $b2 = clone $b1; + + $this->assertFalse($col->contains($b1), 'contains() returns false on an empty collection'); + + $col = new PropelObjectCollection(array($b1)); + + $this->assertTrue($col->contains($b1)); + $this->assertTrue($col->contains($b2)); + } + + public function testSearchMatchesSimilarNewObjects() + { + $col = new PropelObjectCollection(); + $b1 = new Book(); + $b1->setTitle('Bar'); + $b2 = clone $b1; + + $this->assertFalse($col->search($b1), 'search() returns false on an empty collection'); + + $col = new PropelObjectCollection(array($b1)); + $this->assertTrue(0 === $col->search($b1)); + $this->assertTrue(0 === $col->search($b2)); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelObjectCollectionWithFixturesTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelObjectCollectionWithFixturesTest.php new file mode 100644 index 000000000..2b15f8ecf --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelObjectCollectionWithFixturesTest.php @@ -0,0 +1,233 @@ +con); + } + + public function testSave() + { + $books = PropelQuery::from('Book')->find(); + foreach ($books as $book) { + $book->setTitle('foo'); + } + $books->save(); + // check that all the books are saved + foreach ($books as $book) { + $this->assertFalse($book->isModified()); + } + // check that the modifications are persisted + BookPeer::clearInstancePool(); + $books = PropelQuery::from('Book')->find(); + foreach ($books as $book) { + $this->assertEquals('foo', $book->getTitle('foo')); + } + } + + public function testDelete() + { + $books = PropelQuery::from('Book')->find(); + $books->delete(); + // check that all the books are deleted + foreach ($books as $book) { + $this->assertTrue($book->isDeleted()); + } + // check that the modifications are persisted + BookPeer::clearInstancePool(); + $books = PropelQuery::from('Book')->find(); + $this->assertEquals(0, count($books)); + } + + public function testFromArray() + { + $author = new Author(); + $author->setFirstName('Jane'); + $author->setLastName('Austen'); + $author->save(); + $books = array( + array('Title' => 'Mansfield Park', 'ISBN' => '1234', 'AuthorId' => $author->getId()), + array('Title' => 'Pride And Prejudice', 'ISBN' => '2342', 'AuthorId' => $author->getId()) + ); + $col = new PropelObjectCollection(); + $col->setModel('Book'); + $col->fromArray($books); + $col->save(); + + $nbBooks = PropelQuery::from('Book')->count(); + $this->assertEquals(6, $nbBooks); + + $booksByJane = PropelQuery::from('Book b') + ->join('b.Author a') + ->where('a.LastName = ?', 'Austen') + ->count(); + $this->assertEquals(2, $booksByJane); + } + + public function testToArray() + { + BookPeer::clearInstancePool(); + $books = PropelQuery::from('Book')->find(); + $booksArray = $books->toArray(); + $this->assertEquals(4, count($booksArray)); + + foreach ($booksArray as $key => $book) { + $this->assertEquals($books[$key]->toArray(), $book); + } + + $booksArray = $books->toArray(); + $keys = array(0, 1, 2, 3); + $this->assertEquals($keys, array_keys($booksArray)); + + $booksArray = $books->toArray(null, true); + $keys = array('Book_0', 'Book_1', 'Book_2', 'Book_3'); + $this->assertEquals($keys, array_keys($booksArray)); + + $booksArray = $books->toArray('Title'); + $keys = array('Harry Potter and the Order of the Phoenix', 'Quicksilver', 'Don Juan', 'The Tin Drum'); + $this->assertEquals($keys, array_keys($booksArray)); + + $booksArray = $books->toArray('Title', true); + $keys = array('Book_Harry Potter and the Order of the Phoenix', 'Book_Quicksilver', 'Book_Don Juan', 'Book_The Tin Drum'); + $this->assertEquals($keys, array_keys($booksArray)); + } + + public function testGetArrayCopy() + { + $books = PropelQuery::from('Book')->find(); + $booksArray = $books->getArrayCopy(); + $this->assertEquals(4, count($booksArray)); + + foreach ($booksArray as $key => $book) { + $this->assertEquals($books[$key], $book); + } + + $booksArray = $books->getArrayCopy(); + $keys = array(0, 1, 2, 3); + $this->assertEquals($keys, array_keys($booksArray)); + + $booksArray = $books->getArrayCopy(null, true); + $keys = array('Book_0', 'Book_1', 'Book_2', 'Book_3'); + $this->assertEquals($keys, array_keys($booksArray)); + + $booksArray = $books->getArrayCopy('Title'); + $keys = array('Harry Potter and the Order of the Phoenix', 'Quicksilver', 'Don Juan', 'The Tin Drum'); + $this->assertEquals($keys, array_keys($booksArray)); + + $booksArray = $books->getArrayCopy('Title', true); + $keys = array('Book_Harry Potter and the Order of the Phoenix', 'Book_Quicksilver', 'Book_Don Juan', 'Book_The Tin Drum'); + $this->assertEquals($keys, array_keys($booksArray)); + } + + public function testToKeyValue() + { + $books = PropelQuery::from('Book')->find(); + + $expected = array(); + foreach ($books as $book) { + $expected[$book->getTitle()] = $book->getISBN(); + } + $booksArray = $books->toKeyValue('Title', 'ISBN'); + $this->assertEquals(4, count($booksArray)); + $this->assertEquals($expected, $booksArray, 'toKeyValue() turns the collection to an associative array'); + + $expected = array(); + foreach ($books as $book) { + $expected[$book->getISBN()] = $book->getTitle(); + } + $booksArray = $books->toKeyValue('ISBN'); + $this->assertEquals($expected, $booksArray, 'toKeyValue() uses __toString() for the value if no second field name is passed'); + + $expected = array(); + foreach ($books as $book) { + $expected[$book->getId()] = $book->getTitle(); + } + $booksArray = $books->toKeyValue(); + $this->assertEquals($expected, $booksArray, 'toKeyValue() uses primary key for the key and __toString() for the value if no field name is passed'); + } + + public function testPopulateRelation() + { + AuthorPeer::clearInstancePool(); + BookPeer::clearInstancePool(); + $authors = AuthorQuery::create()->find(); + $books = $authors->populateRelation('Book'); + $this->assertTrue($books instanceof PropelObjectCollection, 'populateRelation() returns a PropelCollection instance'); + $this->assertEquals('Book', $books->getModel(), 'populateRelation() returns a collection of the related objects'); + $this->assertEquals(4, count($books), 'populateRelation() the list of related objects'); + } + + public function testPopulateRelationCriteria() + { + AuthorPeer::clearInstancePool(); + BookPeer::clearInstancePool(); + $authors = AuthorQuery::create()->find(); + $c = new Criteria(); + $c->setLimit(3); + $books = $authors->populateRelation('Book', $c); + $this->assertEquals(3, count($books), 'populateRelation() accepts an optional criteria object to filter the query'); + } + + public function testPopulateRelationEmpty() + { + AuthorPeer::clearInstancePool(); + BookPeer::clearInstancePool(); + $authors = AuthorQuery::create() + ->add(null, '1<>1', Criteria::CUSTOM) + ->find($this->con); + $count = $this->con->getQueryCount(); + $books = $authors->populateRelation('Book', null, $this->con); + $this->assertTrue($books instanceof PropelObjectCollection, 'populateRelation() returns a PropelCollection instance'); + $this->assertEquals('Book', $books->getModel(), 'populateRelation() returns a collection of the related objects'); + $this->assertEquals(0, count($books), 'populateRelation() the list of related objects'); + $this->assertEquals($count, $this->con->getQueryCount(), 'populateRelation() doesn\'t issue a new query on empty collections'); + } + + public function testPopulateRelationOneToMany() + { + AuthorPeer::clearInstancePool(); + BookPeer::clearInstancePool(); + $authors = AuthorQuery::create()->find($this->con); + $count = $this->con->getQueryCount(); + $books = $authors->populateRelation('Book', null, $this->con); + foreach ($authors as $author) { + foreach ($author->getBooks() as $book) { + $this->assertEquals($author, $book->getAuthor()); + } + } + $this->assertEquals($count + 1, $this->con->getQueryCount(), 'populateRelation() populates a one-to-many relationship with a single supplementary query'); + } + + public function testPopulateRelationManyToOne() + { + $con = Propel::getConnection(); + AuthorPeer::clearInstancePool(); + BookPeer::clearInstancePool(); + $books = BookQuery::create()->find($con); + $count = $con->getQueryCount(); + $books->populateRelation('Author', null, $con); + foreach ($books as $book) { + $author = $book->getAuthor(); + } + $this->assertEquals($count + 1, $con->getQueryCount(), 'populateRelation() populates a many-to-one relationship with a single supplementary query'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelOnDemandCollectionTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelOnDemandCollectionTest.php index 8ceddb22e..335a4b67e 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelOnDemandCollectionTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelOnDemandCollectionTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Test class for PropelOnDemandCollection. @@ -19,58 +19,87 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; */ class PropelOnDemandCollectionTest extends BookstoreEmptyTestBase { - protected function setUp() - { - parent::setUp(); - BookstoreDataPopulator::populate($this->con); - $this->books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find(); - } - - public function testSetFormatter() - { - $this->assertTrue($this->books instanceof PropelOnDemandCollection); - $this->assertEquals(4, count($this->books)); - } + protected function setUp() + { + parent::setUp(); + BookstoreDataPopulator::populate($this->con); + Propel::disableInstancePooling(); + $this->books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find(); + } - public function testKeys() - { - $i = 0; - foreach ($this->books as $key => $book) { - $this->assertEquals($i, $key); - $i++; - } - } + protected function tearDown() + { + parent::tearDown(); + Propel::enableInstancePooling(); + } - /** - * @expectedException PropelException - */ - public function testoffsetExists() - { - $this->books->offsetExists(2); - } - - /** - * @expectedException PropelException - */ - public function testoffsetGet() - { - $this->books->offsetGet(2); - } + public function testSetFormatter() + { + $this->assertTrue($this->books instanceof PropelOnDemandCollection); + $this->assertEquals(4, count($this->books)); + } - /** - * @expectedException PropelException - */ - public function testoffsetSet() - { - $this->books->offsetSet(2, 'foo'); - } + /** + * @expectedException PropelException + */ + public function testClone() + { + $clone = clone $this->books; + } - /** - * @expectedException PropelException - */ - public function testoffsetUnset() - { - $this->books->offsetUnset(2); - } + public function testKeys() + { + $i = 0; + foreach ($this->books as $key => $book) { + $this->assertEquals($i, $key); + $i++; + } + } -} \ No newline at end of file + /** + * @expectedException PropelException + */ + public function testoffsetExists() + { + $this->books->offsetExists(2); + } + + /** + * @expectedException PropelException + */ + public function testoffsetGet() + { + $this->books->offsetGet(2); + } + + /** + * @expectedException PropelException + */ + public function testoffsetSet() + { + $this->books->offsetSet(2, 'foo'); + } + + /** + * @expectedException PropelException + */ + public function testoffsetUnset() + { + $this->books->offsetUnset(2); + } + + public function testToArray() + { + $this->assertNotEquals(array(), $this->books->toArray()); + // since the code from toArray comes frmo PropelObjectCollection, we'll assume it's good + } + + /** + * @expectedException PropelException + */ + public function testFromArray() + { + $this->books->fromArray(array()); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelOnDemandIteratorTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelOnDemandIteratorTest.php index 587f4602e..0b2e6fd80 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelOnDemandIteratorTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/collection/PropelOnDemandIteratorTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Test class for PropelOnDemandIterator. @@ -19,41 +19,41 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; */ class PropelOnDemandIteratorTest extends BookstoreEmptyTestBase { - protected function setUp() - { - parent::setUp(); - BookstoreDataPopulator::populate($this->con); - } - - public function testInstancePoolingDisabled() - { - Propel::enableInstancePooling(); - $books = PropelQuery::from('Book') - ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND) - ->find($this->con); - foreach ($books as $book) { - $this->assertFalse(Propel::isInstancePoolingEnabled()); - } - } + protected function setUp() + { + parent::setUp(); + BookstoreDataPopulator::populate($this->con); + } - public function testInstancePoolingReenabled() - { - Propel::enableInstancePooling(); - $books = PropelQuery::from('Book') - ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND) - ->find($this->con); - foreach ($books as $book) { - } - $this->assertTrue(Propel::isInstancePoolingEnabled()); - - Propel::disableInstancePooling(); - $books = PropelQuery::from('Book') - ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND) - ->find($this->con); - foreach ($books as $book) { - } - $this->assertFalse(Propel::isInstancePoolingEnabled()); - Propel::enableInstancePooling(); - } + public function testInstancePoolingDisabled() + { + Propel::enableInstancePooling(); + $books = PropelQuery::from('Book') + ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND) + ->find($this->con); + foreach ($books as $book) { + $this->assertFalse(Propel::isInstancePoolingEnabled()); + } + } -} \ No newline at end of file + public function testInstancePoolingReenabled() + { + Propel::enableInstancePooling(); + $books = PropelQuery::from('Book') + ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND) + ->find($this->con); + foreach ($books as $book) { + } + $this->assertTrue(Propel::isInstancePoolingEnabled()); + + Propel::disableInstancePooling(); + $books = PropelQuery::from('Book') + ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND) + ->find($this->con); + foreach ($books as $book) { + } + $this->assertFalse(Propel::isInstancePoolingEnabled()); + Propel::enableInstancePooling(); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/config/PropelConfigurationTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/config/PropelConfigurationTest.php new file mode 100644 index 000000000..3f82841be --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/config/PropelConfigurationTest.php @@ -0,0 +1,205 @@ + 'bar0', + 'foo1' => array( + 'foo2' => 'bar1', + ), + 'a' => array( + 'b' => array( + 'c' => 'bar2', + ) + ) + ); + $c = new PropelConfiguration($initialConf); + + return array(array($c)); + } + + /** + * @dataProvider configurationProvider + */ + public function testConstructorArrayAccess($c) + { + $this->assertEquals('bar0', $c['foo']); + $this->assertEquals('bar1', $c['foo1']['foo2']); + $this->assertEquals('bar2', $c['a']['b']['c']); + } + + /** + * @dataProvider configurationProvider + */ + public function testConstructorFlastAccess($c) + { + $this->assertEquals('bar0', $c->getParameter('foo')); + $this->assertEquals('bar1', $c->getParameter('foo1.foo2')); + $this->assertEquals('bar2', $c->getParameter('a.b.c')); + } + + public function testArrayAccess() + { + $c = new PropelConfiguration(); + $this->assertFalse(isset($c[1])); + $c[1] = 2; + $this->assertTrue(isset($c[1])); + $this->assertEquals(2, $c[1]); + unset($c[1]); + $this->assertFalse(isset($c[1])); + } + + public function testNullValue() + { + $c = new PropelConfiguration(); + $c[1] = null; + $this->assertTrue(isset($c[1])); + } + + public function testSetParameterSimpleKey() + { + $c = new PropelConfiguration(); + $c->setParameter('foo', 'bar'); + $this->assertEquals('bar', $c['foo']); + $this->assertEquals('bar', $c->getParameter('foo')); + } + + public function testSetParameterSimpleKeyArrayValue() + { + $c = new PropelConfiguration(); + $c->setParameter('foo', array('bar1' => 'baz1')); + $this->assertEquals(array('bar1' => 'baz1'), $c['foo']); + $this->assertNull($c->getParameter('foo')); + $this->assertEquals('baz1', $c->getParameter('foo.bar1')); + } + + public function testSetParameterNamespacedKey() + { + $c = new PropelConfiguration(); + $c->setParameter('foo1.foo2', 'bar'); + $this->assertEquals('bar', $c['foo1']['foo2']); + $this->assertEquals('bar', $c->getParameter('foo1.foo2')); + } + + public function testSetParameterNamespacedKeyArrayValue() + { + $c = new PropelConfiguration(); + $c->setParameter('foo1.foo2', array('bar1' => 'baz1')); + $this->assertEquals(array('bar1' => 'baz1'), $c['foo1']['foo2']); + $this->assertNull($c->getParameter('foo1.foo2')); + $this->assertEquals('baz1', $c->getParameter('foo1.foo2.bar1')); + } + + public function testSetParameterMultiNamespacedKey() + { + $c = new PropelConfiguration(); + $c->setParameter('a.b.c', 'bar'); + $this->assertEquals('bar', $c['a']['b']['c']); + $this->assertEquals('bar', $c->getParameter('a.b.c')); + } + + public function testSetParameterMultiNamespacedKeyArrayValue() + { + $c = new PropelConfiguration(); + $c->setParameter('a.b.c', array('bar1' => 'baz1')); + $this->assertEquals(array('bar1' => 'baz1'), $c['a']['b']['c']); + $this->assertNull($c->getParameter('a.b.c')); + $this->assertEquals('baz1', $c->getParameter('a.b.c.bar1')); + } + + public function testGetParameterSimpleKey() + { + $c = new PropelConfiguration(); + $c['foo'] = 'bar'; + $this->assertEquals('bar', $c->getParameter('foo')); + } + + public function testGetParameterSimpleKeyArrayValue() + { + $c = new PropelConfiguration(); + $c['foo'] = array('bar1' => 'baz1'); + $this->assertNull($c->getParameter('foo')); + $this->assertEquals('baz1', $c->getParameter('foo.bar1')); + } + + public function testGetParameterNamespacedKey() + { + $c = new PropelConfiguration(); + $c['foo1'] = array('foo2' => 'bar'); + $this->assertEquals('bar', $c->getParameter('foo1.foo2')); + } + + public function testGetParameterNamespacedKeyArrayValue() + { + $c = new PropelConfiguration(); + $c['foo1'] = array('foo2' => array('bar1' => 'baz1')); + $this->assertNull($c->getParameter('foo1.foo2')); + $this->assertEquals('baz1', $c->getParameter('foo1.foo2.bar1')); + } + + public function testGetParameterMultiNamespacedKey() + { + $c = new PropelConfiguration(); + $c['a'] = array('b' => array('c' => 'bar')); + $this->assertEquals('bar', $c->getParameter('a.b.c')); + } + + public function testGetParameterMultiNamespacedKeyArrayValue() + { + $c = new PropelConfiguration(); + $c['a'] = array('b' => array('c' => array('bar1' => 'baz1'))); + $this->assertNull($c->getParameter('a.b.c')); + $this->assertEquals('baz1', $c->getParameter('a.b.c.bar1')); + } + + /** + * @dataProvider configurationProvider + */ + public function testGetParameters($c) + { + $expected = array( + 'foo' => 'bar0', + 'foo1' => array( + 'foo2' => 'bar1', + ), + 'a' => array( + 'b' => array( + 'c' => 'bar2', + ) + ) + ); + $this->assertEquals($expected, $c->getParameters()); + } + + /** + * @dataProvider configurationProvider + */ + public function testGetFlattenedParameters($c) + { + $expected = array( + 'foo' => 'bar0', + 'foo1.foo2' => 'bar1', + 'a.b.c' => 'bar2', + ); + $this->assertEquals($expected, $c->getFlattenedParameters()); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/connection/PropelPDOTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/connection/PropelPDOTest.php index 0befc1d1d..ad340560c 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/connection/PropelPDOTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/connection/PropelPDOTest.php @@ -8,10 +8,7 @@ * @license MIT License */ -require_once 'PHPUnit/Framework/TestCase.php'; -require_once dirname(__FILE__) . '/../../../../runtime/lib/connection/PropelPDO.php'; -set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes"); -Propel::init('fixtures/bookstore/build/conf/bookstore-conf.php'); +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; /** * Test for PropelPDO subclass. @@ -21,405 +18,650 @@ Propel::init('fixtures/bookstore/build/conf/bookstore-conf.php'); class PropelPDOTest extends PHPUnit_Framework_TestCase { - public function testSetAttribute() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $this->assertFalse($con->getAttribute(PropelPDO::PROPEL_ATTR_CACHE_PREPARES)); - $con->setAttribute(PropelPDO::PROPEL_ATTR_CACHE_PREPARES, true); - $this->assertTrue($con->getAttribute(PropelPDO::PROPEL_ATTR_CACHE_PREPARES)); + public function testSetAttribute() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $this->assertFalse($con->getAttribute(PropelPDO::PROPEL_ATTR_CACHE_PREPARES)); + $con->setAttribute(PropelPDO::PROPEL_ATTR_CACHE_PREPARES, true); + $this->assertTrue($con->getAttribute(PropelPDO::PROPEL_ATTR_CACHE_PREPARES)); - $con->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); - $this->assertEquals(PDO::CASE_LOWER, $con->getAttribute(PDO::ATTR_CASE)); - } - - public function testNestedTransactionCommit() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $driver = $con->getAttribute(PDO::ATTR_DRIVER_NAME); - - $this->assertEquals(0, $con->getNestedTransactionCount(), 'nested transaction is equal to 0 before transaction'); - $this->assertFalse($con->isInTransaction(), 'PropelPDO is not in transaction by default'); - - $con->beginTransaction(); - - $this->assertEquals(1, $con->getNestedTransactionCount(), 'nested transaction is incremented after main transaction begin'); - $this->assertTrue($con->isInTransaction(), 'PropelPDO is in transaction after main transaction begin'); - - try { - - $a = new Author(); - $a->setFirstName('Test'); - $a->setLastName('User'); - $a->save($con); - $authorId = $a->getId(); - $this->assertNotNull($authorId, "Expected valid new author ID"); - - $con->beginTransaction(); + $con->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); + $this->assertEquals(PDO::CASE_LOWER, $con->getAttribute(PDO::ATTR_CASE)); + } - $this->assertEquals(2, $con->getNestedTransactionCount(), 'nested transaction is incremented after nested transaction begin'); - $this->assertTrue($con->isInTransaction(), 'PropelPDO is in transaction after nested transaction begin'); + public function testCommitBeforeFetch() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + AuthorPeer::doDeleteAll($con); + $a = new Author(); + $a->setFirstName('Test'); + $a->setLastName('User'); + $a->save($con); - try { + $con->beginTransaction(); + $stmt = $con->prepare('SELECT author.FIRST_NAME, author.LAST_NAME FROM author'); - $a2 = new Author(); - $a2->setFirstName('Test2'); - $a2->setLastName('User2'); - $a2->save($con); - $authorId2 = $a2->getId(); - $this->assertNotNull($authorId2, "Expected valid new author ID"); - - $con->commit(); - - $this->assertEquals(1, $con->getNestedTransactionCount(), 'nested transaction decremented after nested transaction commit'); - $this->assertTrue($con->isInTransaction(), 'PropelPDO is in transaction after main transaction commit'); + $stmt->execute(); + $con->commit(); + $authorArr = array(0 => 'Test', 1 => 'User'); - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - - $con->commit(); - - $this->assertEquals(0, $con->getNestedTransactionCount(), 'nested transaction decremented after main transaction commit'); - $this->assertFalse($con->isInTransaction(), 'PropelPDO is not in transaction after main transaction commit'); + $i = 0; + try { + $row = $stmt->fetch( PDO::FETCH_NUM ); + $stmt->closeCursor(); + $this->assertEquals($authorArr, $row, 'PDO driver supports calling $stmt->fetch after the transaction has been closed'); + } catch (PDOException $e) { + $this->fail("PDO driver does not support calling \$stmt->fetch after the transaction has been closed.\nFails with error ".$e->getMessage()); + } + } - } catch (Exception $e) { - $con->rollBack(); - } - - AuthorPeer::clearInstancePool(); - $at = AuthorPeer::retrieveByPK($authorId); - $this->assertNotNull($at, "Committed transaction is persisted in database"); - $at2 = AuthorPeer::retrieveByPK($authorId2); - $this->assertNotNull($at2, "Committed transaction is persisted in database"); - } + public function testCommitAfterFetch() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + AuthorPeer::doDeleteAll($con); + $a = new Author(); + $a->setFirstName('Test'); + $a->setLastName('User'); + $a->save($con); - /** - * @link http://propel.phpdb.org/trac/ticket/699 - */ - public function testNestedTransactionRollBackRethrow() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $driver = $con->getAttribute(PDO::ATTR_DRIVER_NAME); - - $con->beginTransaction(); - try { - - $a = new Author(); - $a->setFirstName('Test'); - $a->setLastName('User'); - $a->save($con); - $authorId = $a->getId(); - - $this->assertNotNull($authorId, "Expected valid new author ID"); - - $con->beginTransaction(); + $con->beginTransaction(); + $stmt = $con->prepare('SELECT author.FIRST_NAME, author.LAST_NAME FROM author'); - $this->assertEquals(2, $con->getNestedTransactionCount(), 'nested transaction is incremented after nested transaction begin'); - $this->assertTrue($con->isInTransaction(), 'PropelPDO is in transaction after nested transaction begin'); + $stmt->execute(); + $authorArr = array(0 => 'Test', 1 => 'User'); - try { - $con->exec('INVALID SQL'); - $this->fail("Expected exception on invalid SQL"); - } catch (PDOException $x) { - $con->rollBack(); + $i = 0; + $row = $stmt->fetch( PDO::FETCH_NUM ); + $stmt->closeCursor(); + $con->commit(); + $this->assertEquals($authorArr, $row, 'PDO driver supports calling $stmt->fetch before the transaction has been closed'); + } - $this->assertEquals(1, $con->getNestedTransactionCount(), 'nested transaction decremented after nested transaction rollback'); - $this->assertTrue($con->isInTransaction(), 'PropelPDO is in transaction after main transaction rollback'); + public function testNestedTransactionCommit() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $driver = $con->getAttribute(PDO::ATTR_DRIVER_NAME); - throw $x; - } - - $con->commit(); - } catch (Exception $x) { - $con->rollBack(); - } - - AuthorPeer::clearInstancePool(); - $at = AuthorPeer::retrieveByPK($authorId); - $this->assertNull($at, "Rolled back transaction is not persisted in database"); - } - - /** - * @link http://propel.phpdb.org/trac/ticket/699 - */ - public function testNestedTransactionRollBackSwallow() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $driver = $con->getAttribute(PDO::ATTR_DRIVER_NAME); - - $con->beginTransaction(); - try { - - $a = new Author(); - $a->setFirstName('Test'); - $a->setLastName('User'); - $a->save($con); - - $authorId = $a->getId(); - $this->assertNotNull($authorId, "Expected valid new author ID"); - - $con->beginTransaction(); - try { + $this->assertEquals(0, $con->getNestedTransactionCount(), 'nested transaction is equal to 0 before transaction'); + $this->assertFalse($con->isInTransaction(), 'PropelPDO is not in transaction by default'); - $a2 = new Author(); - $a2->setFirstName('Test2'); - $a2->setLastName('User2'); - $a2->save($con); - $authorId2 = $a2->getId(); - $this->assertNotNull($authorId2, "Expected valid new author ID"); + $con->beginTransaction(); - $con->exec('INVALID SQL'); - $this->fail("Expected exception on invalid SQL"); - } catch (PDOException $e) { - $con->rollBack(); - // NO RETHROW - } - - $a3 = new Author(); - $a3->setFirstName('Test2'); - $a3->setLastName('User2'); - $a3->save($con); - - $authorId3 = $a3->getId(); - $this->assertNotNull($authorId3, "Expected valid new author ID"); - - $con->commit(); - $this->fail("Commit fails after a nested rollback"); - } catch (PropelException $e) { - $this->assertTrue(true, "Commit fails after a nested rollback"); - $con->rollback(); - } - - AuthorPeer::clearInstancePool(); - $at = AuthorPeer::retrieveByPK($authorId); - $this->assertNull($at, "Rolled back transaction is not persisted in database"); - $at2 = AuthorPeer::retrieveByPK($authorId2); - $this->assertNull($at2, "Rolled back transaction is not persisted in database"); - $at3 = AuthorPeer::retrieveByPK($authorId3); - $this->assertNull($at3, "Rolled back nested transaction is not persisted in database"); - } + $this->assertEquals(1, $con->getNestedTransactionCount(), 'nested transaction is incremented after main transaction begin'); + $this->assertTrue($con->isInTransaction(), 'PropelPDO is in transaction after main transaction begin'); - public function testNestedTransactionForceRollBack() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $driver = $con->getAttribute(PDO::ATTR_DRIVER_NAME); - - // main transaction - $con->beginTransaction(); - - $a = new Author(); - $a->setFirstName('Test'); - $a->setLastName('User'); - $a->save($con); - $authorId = $a->getId(); - - // nested transaction - $con->beginTransaction(); + try { - $a2 = new Author(); - $a2->setFirstName('Test2'); - $a2->setLastName('User2'); - $a2->save($con); - $authorId2 = $a2->getId(); - - // force rollback - $con->forceRollback(); - - $this->assertEquals(0, $con->getNestedTransactionCount(), 'nested transaction is null after nested transaction forced rollback'); - $this->assertFalse($con->isInTransaction(), 'PropelPDO is not in transaction after nested transaction force rollback'); - - AuthorPeer::clearInstancePool(); - $at = AuthorPeer::retrieveByPK($authorId); - $this->assertNull($at, "Rolled back transaction is not persisted in database"); - $at2 = AuthorPeer::retrieveByPK($authorId2); - $this->assertNull($at2, "Forced Rolled back nested transaction is not persisted in database"); - } - - public function testLatestQuery() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $con->setLastExecutedQuery(123); - $this->assertEquals(123, $con->getLastExecutedQuery(), 'PropelPDO has getter and setter for last executed query'); - } - - public function testLatestQueryMoreThanTenArgs() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c = new Criteria(); - $c->add(BookPeer::ID, array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), Criteria::IN); - $books = BookPeer::doSelect($c, $con); - $expected = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.ID IN (1,1,1,1,1,1,1,1,1,1,1,1)"; - $this->assertEquals($expected, $con->getLastExecutedQuery(), 'PropelPDO correctly replaces arguments in queries'); - } - - public function testQueryCount() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $count = $con->getQueryCount(); - $con->incrementQueryCount(); - $this->assertEquals($count + 1, $con->getQueryCount(), 'PropelPDO has getter and incrementer for query count'); - } + $a = new Author(); + $a->setFirstName('Test'); + $a->setLastName('User'); + $a->save($con); + $authorId = $a->getId(); + $this->assertNotNull($authorId, "Expected valid new author ID"); - public function testUseDebug() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $con->useDebug(false); - $this->assertEquals(array('PDOStatement'), $con->getAttribute(PDO::ATTR_STATEMENT_CLASS), 'Statement is PDOStatement when debug is false'); - $con->useDebug(true); - $this->assertEquals(array('DebugPDOStatement', array($con)), $con->getAttribute(PDO::ATTR_STATEMENT_CLASS), 'statement is DebugPDOStament when debug is true'); - } - - public function testDebugLatestQuery() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c = new Criteria(); - $c->add(BookPeer::TITLE, 'Harry%s', Criteria::LIKE); + $con->beginTransaction(); - $con->useDebug(false); - $this->assertEquals('', $con->getLastExecutedQuery(), 'PropelPDO reinitializes the latest query when debug is set to false'); + $this->assertEquals(2, $con->getNestedTransactionCount(), 'nested transaction is incremented after nested transaction begin'); + $this->assertTrue($con->isInTransaction(), 'PropelPDO is in transaction after nested transaction begin'); - $books = BookPeer::doSelect($c, $con); - $this->assertEquals('', $con->getLastExecutedQuery(), 'PropelPDO does not update the last executed query when useLogging is false'); + try { - $con->useDebug(true); - $books = BookPeer::doSelect($c, $con); - $latestExecutedQuery = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE LIKE 'Harry%s'"; - if (!Propel::getDB(BookPeer::DATABASE_NAME)->useQuoteIdentifier()) { - $latestExecutedQuery = str_replace('`', '', $latestExecutedQuery); - } - $this->assertEquals($latestExecutedQuery, $con->getLastExecutedQuery(), 'PropelPDO updates the last executed query when useLogging is true'); - - BookPeer::doDeleteAll($con); - $latestExecutedQuery = "DELETE FROM `book`"; - $this->assertEquals($latestExecutedQuery, $con->getLastExecutedQuery(), 'PropelPDO updates the last executed query on delete operations'); - - $sql = 'DELETE FROM book WHERE 1=1'; - $con->exec($sql); - $this->assertEquals($sql, $con->getLastExecutedQuery(), 'PropelPDO updates the last executed query on exec operations'); + $a2 = new Author(); + $a2->setFirstName('Test2'); + $a2->setLastName('User2'); + $a2->save($con); + $authorId2 = $a2->getId(); + $this->assertNotNull($authorId2, "Expected valid new author ID"); - $sql = 'DELETE FROM book WHERE 2=2'; - $con->query($sql); - $this->assertEquals($sql, $con->getLastExecutedQuery(), 'PropelPDO updates the last executed query on query operations'); + $con->commit(); - $stmt = $con->prepare('DELETE FROM book WHERE 1=:p1'); - $stmt->bindValue(':p1', '2'); - $stmt->execute(); - $this->assertEquals("DELETE FROM book WHERE 1='2'", $con->getLastExecutedQuery(), 'PropelPDO updates the last executed query on prapared statements'); + $this->assertEquals(1, $con->getNestedTransactionCount(), 'nested transaction decremented after nested transaction commit'); + $this->assertTrue($con->isInTransaction(), 'PropelPDO is in transaction after main transaction commit'); - $con->useDebug(false); - $this->assertEquals('', $con->getLastExecutedQuery(), 'PropelPDO reinitializes the latest query when debug is set to false'); + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } - $con->useDebug(true); - } + $con->commit(); - public function testDebugQueryCount() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c = new Criteria(); - $c->add(BookPeer::TITLE, 'Harry%s', Criteria::LIKE); + $this->assertEquals(0, $con->getNestedTransactionCount(), 'nested transaction decremented after main transaction commit'); + $this->assertFalse($con->isInTransaction(), 'PropelPDO is not in transaction after main transaction commit'); - $con->useDebug(false); - $this->assertEquals(0, $con->getQueryCount(), 'PropelPDO does not update the query count when useLogging is false'); + } catch (Exception $e) { + $con->rollBack(); + } - $books = BookPeer::doSelect($c, $con); - $this->assertEquals(0, $con->getQueryCount(), 'PropelPDO does not update the query count when useLogging is false'); + AuthorPeer::clearInstancePool(); + $at = AuthorPeer::retrieveByPK($authorId); + $this->assertNotNull($at, "Committed transaction is persisted in database"); + $at2 = AuthorPeer::retrieveByPK($authorId2); + $this->assertNotNull($at2, "Committed transaction is persisted in database"); + } - $con->useDebug(true); - $books = BookPeer::doSelect($c, $con); - $this->assertEquals(1, $con->getQueryCount(), 'PropelPDO updates the query count when useLogging is true'); - - BookPeer::doDeleteAll($con); - $this->assertEquals(2, $con->getQueryCount(), 'PropelPDO updates the query count on delete operations'); - - $sql = 'DELETE FROM book WHERE 1=1'; - $con->exec($sql); - $this->assertEquals(3, $con->getQueryCount(), 'PropelPDO updates the query count on exec operations'); + /** + * @link http://trac.propelorm.org/ticket/699 + */ + public function testNestedTransactionRollBackRethrow() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $driver = $con->getAttribute(PDO::ATTR_DRIVER_NAME); - $sql = 'DELETE FROM book WHERE 2=2'; - $con->query($sql); - $this->assertEquals(4, $con->getQueryCount(), 'PropelPDO updates the query count on query operations'); + $con->beginTransaction(); + try { - $stmt = $con->prepare('DELETE FROM book WHERE 1=:p1'); - $stmt->bindValue(':p1', '2'); - $stmt->execute(); - $this->assertEquals(5, $con->getQueryCount(), 'PropelPDO updates the query count on prapared statements'); + $a = new Author(); + $a->setFirstName('Test'); + $a->setLastName('User'); + $a->save($con); + $authorId = $a->getId(); - $con->useDebug(false); - $this->assertEquals(0, $con->getQueryCount(), 'PropelPDO reinitializes the query count when debug is set to false'); + $this->assertNotNull($authorId, "Expected valid new author ID"); - $con->useDebug(true); - } + $con->beginTransaction(); - public function testDebugLog() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT); - - // save data to return to normal state after test - $logger = $con->getLogger(); - - $testLog = new myLogger(); - $con->setLogger($testLog); - - $logEverything = array('PropelPDO::exec', 'PropelPDO::query', 'PropelPDO::beginTransaction', 'PropelPDO::commit', 'PropelPDO::rollBack', 'DebugPDOStatement::execute'); - Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT)->setParameter("debugpdo.logging.methods", $logEverything); - $con->useDebug(true); - - // test transaction log - $con->beginTransaction(); - $this->assertEquals('log: Begin transaction', $testLog->latestMessage, 'PropelPDO logs begin transation in debug mode'); - - $con->commit(); - $this->assertEquals('log: Commit transaction', $testLog->latestMessage, 'PropelPDO logs commit transation in debug mode'); - - $con->beginTransaction(); - $con->rollBack(); - $this->assertEquals('log: Rollback transaction', $testLog->latestMessage, 'PropelPDO logs rollback transation in debug mode'); + $this->assertEquals(2, $con->getNestedTransactionCount(), 'nested transaction is incremented after nested transaction begin'); + $this->assertTrue($con->isInTransaction(), 'PropelPDO is in transaction after nested transaction begin'); - $con->beginTransaction(); - $testLog->latestMessage = ''; - $con->beginTransaction(); - $this->assertEquals('', $testLog->latestMessage, 'PropelPDO does not log nested begin transation in debug mode'); - $con->commit(); - $this->assertEquals('', $testLog->latestMessage, 'PropelPDO does not log nested commit transation in debug mode'); - $con->beginTransaction(); - $con->rollBack(); - $this->assertEquals('', $testLog->latestMessage, 'PropelPDO does not log nested rollback transation in debug mode'); - $con->rollback(); - - // test query log - $con->beginTransaction(); - - $c = new Criteria(); - $c->add(BookPeer::TITLE, 'Harry%s', Criteria::LIKE); + try { + $con->exec('INVALID SQL'); + $this->fail("Expected exception on invalid SQL"); + } catch (PDOException $x) { + $con->rollBack(); - $books = BookPeer::doSelect($c, $con); - $latestExecutedQuery = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE LIKE 'Harry%s'"; - $this->assertEquals('log: ' . $latestExecutedQuery, $testLog->latestMessage, 'PropelPDO logs queries and populates bound parameters in debug mode'); + $this->assertEquals(1, $con->getNestedTransactionCount(), 'nested transaction decremented after nested transaction rollback'); + $this->assertTrue($con->isInTransaction(), 'PropelPDO is in transaction after main transaction rollback'); - BookPeer::doDeleteAll($con); - $latestExecutedQuery = "DELETE FROM `book`"; - $this->assertEquals('log: ' . $latestExecutedQuery, $testLog->latestMessage, 'PropelPDO logs deletion queries in debug mode'); - - $latestExecutedQuery = 'DELETE FROM book WHERE 1=1'; - $con->exec($latestExecutedQuery); - $this->assertEquals('log: ' . $latestExecutedQuery, $testLog->latestMessage, 'PropelPDO logs exec queries in debug mode'); - - $con->commit(); - - // return to normal state after test - $con->setLogger($logger); - $config->setParameter("debugpdo.logging.methods", array('PropelPDO::exec', 'PropelPDO::query', 'DebugPDOStatement::execute')); - } + throw $x; + } + + $con->commit(); + } catch (Exception $x) { + $con->rollBack(); + } + + AuthorPeer::clearInstancePool(); + $at = AuthorPeer::retrieveByPK($authorId); + $this->assertNull($at, "Rolled back transaction is not persisted in database"); + } + + /** + * @link http://trac.propelorm.org/ticket/699 + */ + public function testNestedTransactionRollBackSwallow() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $driver = $con->getAttribute(PDO::ATTR_DRIVER_NAME); + + $con->beginTransaction(); + try { + + $a = new Author(); + $a->setFirstName('Test'); + $a->setLastName('User'); + $a->save($con); + + $authorId = $a->getId(); + $this->assertNotNull($authorId, "Expected valid new author ID"); + + $con->beginTransaction(); + try { + + $a2 = new Author(); + $a2->setFirstName('Test2'); + $a2->setLastName('User2'); + $a2->save($con); + $authorId2 = $a2->getId(); + $this->assertNotNull($authorId2, "Expected valid new author ID"); + + $con->exec('INVALID SQL'); + $this->fail("Expected exception on invalid SQL"); + } catch (PDOException $e) { + $con->rollBack(); + // NO RETHROW + } + + $a3 = new Author(); + $a3->setFirstName('Test2'); + $a3->setLastName('User2'); + $a3->save($con); + + $authorId3 = $a3->getId(); + $this->assertNotNull($authorId3, "Expected valid new author ID"); + + $con->commit(); + $this->fail("Commit fails after a nested rollback"); + } catch (PropelException $e) { + $this->assertTrue(true, "Commit fails after a nested rollback"); + $con->rollback(); + } + + AuthorPeer::clearInstancePool(); + $at = AuthorPeer::retrieveByPK($authorId); + $this->assertNull($at, "Rolled back transaction is not persisted in database"); + $at2 = AuthorPeer::retrieveByPK($authorId2); + $this->assertNull($at2, "Rolled back transaction is not persisted in database"); + $at3 = AuthorPeer::retrieveByPK($authorId3); + $this->assertNull($at3, "Rolled back nested transaction is not persisted in database"); + } + + public function testNestedTransactionForceRollBack() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $driver = $con->getAttribute(PDO::ATTR_DRIVER_NAME); + + // main transaction + $con->beginTransaction(); + + $a = new Author(); + $a->setFirstName('Test'); + $a->setLastName('User'); + $a->save($con); + $authorId = $a->getId(); + + // nested transaction + $con->beginTransaction(); + + $a2 = new Author(); + $a2->setFirstName('Test2'); + $a2->setLastName('User2'); + $a2->save($con); + $authorId2 = $a2->getId(); + + // force rollback + $con->forceRollback(); + + $this->assertEquals(0, $con->getNestedTransactionCount(), 'nested transaction is null after nested transaction forced rollback'); + $this->assertFalse($con->isInTransaction(), 'PropelPDO is not in transaction after nested transaction force rollback'); + + AuthorPeer::clearInstancePool(); + $at = AuthorPeer::retrieveByPK($authorId); + $this->assertNull($at, "Rolled back transaction is not persisted in database"); + $at2 = AuthorPeer::retrieveByPK($authorId2); + $this->assertNull($at2, "Forced Rolled back nested transaction is not persisted in database"); + } + + public function testLatestQuery() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $con->setLastExecutedQuery(123); + $this->assertEquals(123, $con->getLastExecutedQuery(), 'PropelPDO has getter and setter for last executed query'); + } + + public function testLatestQueryMoreThanTenArgs() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new Criteria(); + $c->add(BookPeer::ID, array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), Criteria::IN); + $books = BookPeer::doSelect($c, $con); + $expected = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.id IN (1,1,1,1,1,1,1,1,1,1,1,1)"; + $this->assertEquals($expected, $con->getLastExecutedQuery(), 'PropelPDO correctly replaces arguments in queries'); + } + + public function testQueryCount() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $count = $con->getQueryCount(); + $con->incrementQueryCount(); + $this->assertEquals($count + 1, $con->getQueryCount(), 'PropelPDO has getter and incrementer for query count'); + } + + public function testUseDebug() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $con->useDebug(false); + $this->assertEquals(array('PDOStatement'), $con->getAttribute(PDO::ATTR_STATEMENT_CLASS), 'Statement is PDOStatement when debug is false'); + $con->useDebug(true); + $this->assertEquals(array('DebugPDOStatement', array($con)), $con->getAttribute(PDO::ATTR_STATEMENT_CLASS), 'statement is DebugPDOStatement when debug is true'); + } + + public function testDebugLatestQuery() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new Criteria(); + $c->add(BookPeer::TITLE, 'Harry%s', Criteria::LIKE); + + $con->useDebug(false); + $this->assertEquals('', $con->getLastExecutedQuery(), 'PropelPDO reinitializes the latest query when debug is set to false'); + + $books = BookPeer::doSelect($c, $con); + $this->assertEquals('', $con->getLastExecutedQuery(), 'PropelPDO does not update the last executed query when useLogging is false'); + + $con->useDebug(true); + $books = BookPeer::doSelect($c, $con); + $latestExecutedQuery = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.title LIKE 'Harry%s'"; + if (!Propel::getDB(BookPeer::DATABASE_NAME)->useQuoteIdentifier()) { + $latestExecutedQuery = str_replace('`', '', $latestExecutedQuery); + } + $this->assertEquals($latestExecutedQuery, $con->getLastExecutedQuery(), 'PropelPDO updates the last executed query when useLogging is true'); + + BookPeer::doDeleteAll($con); + $latestExecutedQuery = "DELETE FROM `book`"; + $this->assertEquals($latestExecutedQuery, $con->getLastExecutedQuery(), 'PropelPDO updates the last executed query on delete operations'); + + $sql = 'DELETE FROM book WHERE 1=1'; + $con->exec($sql); + $this->assertEquals($sql, $con->getLastExecutedQuery(), 'PropelPDO updates the last executed query on exec operations'); + + $sql = 'DELETE FROM book WHERE 2=2'; + $con->query($sql); + $this->assertEquals($sql, $con->getLastExecutedQuery(), 'PropelPDO updates the last executed query on query operations'); + + $stmt = $con->prepare('DELETE FROM book WHERE 1=:p1'); + $stmt->bindValue(':p1', '2'); + $stmt->execute(); + $this->assertEquals("DELETE FROM book WHERE 1='2'", $con->getLastExecutedQuery(), 'PropelPDO updates the last executed query on prapared statements'); + + $con->useDebug(false); + $this->assertEquals('', $con->getLastExecutedQuery(), 'PropelPDO reinitializes the latest query when debug is set to false'); + + $con->useDebug(true); + } + + public function testDebugQueryCount() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new Criteria(); + $c->add(BookPeer::TITLE, 'Harry%s', Criteria::LIKE); + + $con->useDebug(false); + $this->assertEquals(0, $con->getQueryCount(), 'PropelPDO does not update the query count when useLogging is false'); + + $books = BookPeer::doSelect($c, $con); + $this->assertEquals(0, $con->getQueryCount(), 'PropelPDO does not update the query count when useLogging is false'); + + $con->useDebug(true); + $books = BookPeer::doSelect($c, $con); + $this->assertEquals(1, $con->getQueryCount(), 'PropelPDO updates the query count when useLogging is true'); + + BookPeer::doDeleteAll($con); + $this->assertEquals(2, $con->getQueryCount(), 'PropelPDO updates the query count on delete operations'); + + $sql = 'DELETE FROM book WHERE 1=1'; + $con->exec($sql); + $this->assertEquals(3, $con->getQueryCount(), 'PropelPDO updates the query count on exec operations'); + + $sql = 'DELETE FROM book WHERE 2=2'; + $con->query($sql); + $this->assertEquals(4, $con->getQueryCount(), 'PropelPDO updates the query count on query operations'); + + $stmt = $con->prepare('DELETE FROM book WHERE 1=:p1'); + $stmt->bindValue(':p1', '2'); + $stmt->execute(); + $this->assertEquals(5, $con->getQueryCount(), 'PropelPDO updates the query count on prapared statements'); + + $con->useDebug(false); + $this->assertEquals(0, $con->getQueryCount(), 'PropelPDO reinitializes the query count when debug is set to false'); + + $con->useDebug(true); + } + + public function testDebugLog() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT); + + // save data to return to normal state after test + $logger = $con->getLogger(); + + $testLog = new myLogger(); + $con->setLogger($testLog); + + $logEverything = array('PropelPDO::exec', 'PropelPDO::query', 'PropelPDO::beginTransaction', 'PropelPDO::commit', 'PropelPDO::rollBack', 'DebugPDOStatement::execute'); + Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT)->setParameter("debugpdo.logging.methods", $logEverything, false); + $con->useDebug(true); + + // test transaction log + $con->beginTransaction(); + $this->assertEquals('log: Begin transaction', $testLog->latestMessage, 'PropelPDO logs begin transation in debug mode'); + + $con->commit(); + $this->assertEquals('log: Commit transaction', $testLog->latestMessage, 'PropelPDO logs commit transation in debug mode'); + + $con->beginTransaction(); + $con->rollBack(); + $this->assertEquals('log: Rollback transaction', $testLog->latestMessage, 'PropelPDO logs rollback transation in debug mode'); + + $con->beginTransaction(); + $testLog->latestMessage = ''; + $con->beginTransaction(); + $this->assertEquals('', $testLog->latestMessage, 'PropelPDO does not log nested begin transation in debug mode'); + $con->commit(); + $this->assertEquals('', $testLog->latestMessage, 'PropelPDO does not log nested commit transation in debug mode'); + $con->beginTransaction(); + $con->rollBack(); + $this->assertEquals('', $testLog->latestMessage, 'PropelPDO does not log nested rollback transation in debug mode'); + $con->rollback(); + + // test query log + $con->beginTransaction(); + + $c = new Criteria(); + $c->add(BookPeer::TITLE, 'Harry%s', Criteria::LIKE); + + $books = BookPeer::doSelect($c, $con); + $latestExecutedQuery = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.title LIKE 'Harry%s'"; + $this->assertEquals('log: ' . $latestExecutedQuery, $testLog->latestMessage, 'PropelPDO logs queries and populates bound parameters in debug mode'); + + BookPeer::doDeleteAll($con); + $latestExecutedQuery = "DELETE FROM `book`"; + $this->assertEquals('log: ' . $latestExecutedQuery, $testLog->latestMessage, 'PropelPDO logs deletion queries in debug mode'); + + $latestExecutedQuery = 'DELETE FROM book WHERE 1=1'; + $con->exec($latestExecutedQuery); + $this->assertEquals('log: ' . $latestExecutedQuery, $testLog->latestMessage, 'PropelPDO logs exec queries in debug mode'); + + $con->commit(); + + // return to normal state after test + $con->setLogger($logger); + $config->setParameter("debugpdo.logging.methods", array('PropelPDO::exec', 'PropelPDO::query', 'DebugPDOStatement::execute')); + } + + /** + * Testing if string values will be quoted correctly by DebugPDOStatement::getExecutedQueryString + */ + public function testDebugExecutedQueryStringValue() + { + + /** + * @var DebugPDO $con + */ + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + // different method must all result in this given querystring, using a string value + $bindParamStringValue = "%Harry%"; + $expectedQuery = "SELECT book.id FROM `book` WHERE book.title LIKE '{$bindParamStringValue}'"; + + // simple statement without params + $prepStmt = $con->prepare($expectedQuery); + $prepStmt->execute(); + $this->assertEquals($expectedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + // statement with named placeholder + $prepStmt = $con->prepare("SELECT book.id FROM `book` WHERE book.title LIKE :p1"); + $prepStmt->bindValue(':p1', '%Harry%'); // bind value variant + $prepStmt->execute(); + $this->assertEquals($expectedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + $prepStmt->bindParam(':p1', $bindParamStringValue); // bind param variant + $prepStmt->execute(); + $this->assertEquals($expectedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + // passing params directly + $prepStmt->execute(array(':p1' => '%Harry%')); + $this->assertEquals($expectedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + // statement with named placeholder, this one won't get substituted + $expectedNotSubstitutedQuery = "SELECT book.id FROM `book` WHERE book.title LIKE :name"; + $prepStmt = $con->prepare($expectedNotSubstitutedQuery); + $prepStmt->bindValue(':name', '%Harry%'); // bind value variant + $prepStmt->execute(); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + $prepStmt->bindParam(':name', $bindParamStringValue); // bind param variant + $prepStmt->execute(); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + // passing params directly + $prepStmt->execute(array(':name' => '%Harry%')); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + + // statement with positional placeholder, this one won't get substituted either + $expectedNotSubstitutedQuery = "SELECT book.id FROM `book` WHERE book.title LIKE ?"; + $prepStmt = $con->prepare($expectedNotSubstitutedQuery); + $prepStmt->bindValue(1, '%Harry%'); + $prepStmt->execute(); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + $prepStmt->bindParam(1, $bindParamStringValue); + $prepStmt->execute(); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + // passing params directly + $prepStmt->execute(array('%Harry%')); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + } + + /** + * Testing if integer values will be quoted correctly by DebugPDOStatement::getExecutedQueryString + */ + public function testDebugExecutedQueryIntegerValue() + { + /** + * @var DebugPDO $con + */ + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + // different method must all result in this given querystring, using an integer value + $bindParamIntegerValue = 123; + $expectedQuery = "SELECT book.title FROM `book` WHERE book.id = {$bindParamIntegerValue}"; + + // simple statement without params + $prepStmt = $con->prepare($expectedQuery); + $prepStmt->execute(); + $this->assertEquals($expectedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + // statement with named placeholder + $prepStmt = $con->prepare("SELECT book.title FROM `book` WHERE book.id = :p1"); + $prepStmt->bindValue(':p1', 123); // bind value variant + $prepStmt->execute(); + $this->assertEquals($expectedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + $prepStmt->bindParam(':p1', $bindParamIntegerValue); // bind param variant + $prepStmt->execute(); + $this->assertEquals($expectedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + // passing params directly + $prepStmt->execute(array(':p1' => 123)); + $this->assertEquals($expectedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + // statement with named placeholder, this one won't get substituted + $expectedNotSubstitutedQuery = "SELECT book.title FROM `book` WHERE book.id = :name"; + $prepStmt = $con->prepare($expectedNotSubstitutedQuery); + $prepStmt->bindValue(':name', 123); // bind value variant + $prepStmt->execute(); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + $prepStmt->bindParam(':name', $bindParamIntegerValue); // bind param variant + $prepStmt->execute(); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + // passing params directly + $prepStmt->execute(array(':name' => 123)); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + + // statement with positional placeholder, this one won't get substituted either + $expectedNotSubstitutedQuery = "SELECT book.title FROM `book` WHERE book.id = ?"; + $prepStmt = $con->prepare($expectedNotSubstitutedQuery); + $prepStmt->bindValue(1, 123); + $prepStmt->execute(); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + $prepStmt->bindParam(1, $bindParamIntegerValue); + $prepStmt->execute(); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + // passing params directly + $prepStmt->execute(array(123)); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + } + + /** + * Testing if numeric values will be quoted correctly by DebugPDOStatement::getExecutedQueryString + * Numeric values sometimes will get handled differently, since there are numeric values which are non-integer + */ + public function testDebugExecutedQueryNumericValue() + { + /** + * @var DebugPDO $con + */ + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + // different method must all result in this given querystring, using an integer value + $bindParamNumericValue = 0002000; + $expectedQuery = "SELECT book.title FROM `book` WHERE book.id = {$bindParamNumericValue}"; + + // simple statement without params + $prepStmt = $con->prepare($expectedQuery); + $prepStmt->execute(); + $this->assertEquals($expectedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + // statement with named placeholder + $prepStmt = $con->prepare("SELECT book.title FROM `book` WHERE book.id = :p1"); + $prepStmt->bindValue(':p1', 0002000); // bind value variant + $prepStmt->execute(); + $this->assertEquals($expectedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + $prepStmt->bindParam(':p1', $bindParamNumericValue); // bind param variant + $prepStmt->execute(); + $this->assertEquals($expectedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + // passing params directly + $prepStmt->execute(array(':p1' => 0002000)); + $this->assertEquals($expectedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + // statement with named placeholder, this one won't get substituted + $expectedNotSubstitutedQuery = "SELECT book.title FROM `book` WHERE book.id = :name"; + $prepStmt = $con->prepare($expectedNotSubstitutedQuery); + $prepStmt->bindValue(':name', 0002000); // bind value variant + $prepStmt->execute(); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + $prepStmt->bindParam(':name', $bindParamNumericValue); // bind param variant + $prepStmt->execute(); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + // passing params directly + $prepStmt->execute(array(':name' => 0002000)); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + + // statement with positional placeholder, this one won't get substituted either + $expectedNotSubstitutedQuery = "SELECT book.title FROM `book` WHERE book.id = ?"; + $prepStmt = $con->prepare($expectedNotSubstitutedQuery); + $prepStmt->bindValue(1, 0002000); + $prepStmt->execute(); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + $prepStmt->bindParam(1, $bindParamNumericValue); + $prepStmt->execute(); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + + // passing params directly + $prepStmt->execute(array(0002000)); + $this->assertEquals($expectedNotSubstitutedQuery, $con->getLastExecutedQuery(), 'DebugPDO failed to quote prepared statement on execute properly'); + } } class myLogger { - public $latestMessage = ''; - - public function __call($method, $arguments) - { - $this->latestMessage = $method . ': ' . array_shift($arguments); - } -} \ No newline at end of file + public $latestMessage = ''; + + public function __call($method, $arguments) + { + $this->latestMessage = $method . ': ' . array_shift($arguments); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/exception/PropelExceptionTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/exception/PropelExceptionTest.php new file mode 100644 index 000000000..8f31c57dd --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/exception/PropelExceptionTest.php @@ -0,0 +1,69 @@ +assertTrue($e instanceof Exception); + $this->assertEquals('this is an error', $e->getMessage()); + } + + public function testExceptionConstructor() + { + $e1 = new FooException('real cause'); + $e = new PropelException($e1); + $this->assertEquals(' [wrapped: real cause]', $e->getMessage()); + } + + public function testCompositeConstructor() + { + $e1 = new FooException('real cause'); + $e = new PropelException('this is an error', $e1); + $this->assertEquals('this is an error [wrapped: real cause]', $e->getMessage()); + } + + /** + * @expectedException PropelException + */ + public function testIsThrowable() + { + $e = new PropelException('this is an error'); + throw $e; + } + + public function testGetCause() + { + $e1 = new FooException('real cause'); + $e = new PropelException('this is an error', $e1); + $this->assertEquals($e1, $e->getCause()); + } + + public function testGetPrevious() + { + if (version_compare(PHP_VERSION, '5.3.0') < 0) { + $this->markTestSkipped(); + } + $e1 = new FooException('real cause'); + $e = new PropelException('this is an error', $e1); + $this->assertEquals($e1, $e->getPrevious()); + } +} + +class FooException extends Exception {} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelArrayFormatterTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelArrayFormatterTest.php index b1bcde670..247b713a7 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelArrayFormatterTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelArrayFormatterTest.php @@ -8,122 +8,121 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Test class for PropelArrayFormatter. * * @author Francois Zaninotto - * @version $Id: PropelArrayFormatterTest.php 1796 2010-06-14 11:45:49Z francois $ + * @version $Id$ * @package runtime.formatter */ class PropelArrayFormatterTest extends BookstoreEmptyTestBase { - protected function setUp() - { - parent::setUp(); - BookstoreDataPopulator::populate(); - } + protected function setUp() + { + parent::setUp(); + BookstoreDataPopulator::populate(); + } - public function testFormatNoCriteria() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); + public function testFormatNoCriteria() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $stmt = $con->query('SELECT * FROM book'); - $formatter = new PropelArrayFormatter(); - try { - $books = $formatter->format($stmt); - $this->fail('PropelArrayFormatter::format() throws an exception when called with no valid criteria'); - } catch (PropelException $e) { - $this->assertTrue(true,'PropelArrayFormatter::format() throws an exception when called with no valid criteria'); - } - } - - public function testFormatManyResults() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $stmt = $con->query('SELECT * FROM book'); + $formatter = new PropelArrayFormatter(); + try { + $books = $formatter->format($stmt); + $this->fail('PropelArrayFormatter::format() throws an exception when called with no valid criteria'); + } catch (PropelException $e) { + $this->assertTrue(true,'PropelArrayFormatter::format() throws an exception when called with no valid criteria'); + } + } - $stmt = $con->query('SELECT * FROM book'); - $formatter = new PropelArrayFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $books = $formatter->format($stmt); - - $this->assertTrue($books instanceof PropelCollection, 'PropelArrayFormatter::format() returns a PropelCollection'); - $this->assertEquals(4, count($books), 'PropelArrayFormatter::format() returns as many rows as the results in the query'); - foreach ($books as $book) { - $this->assertTrue(is_array($book), 'PropelArrayFormatter::format() returns an array of arrays'); - } - } + public function testFormatManyResults() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); - public function testFormatOneResult() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $stmt = $con->query('SELECT * FROM book'); + $formatter = new PropelArrayFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $books = $formatter->format($stmt); - $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "Quicksilver"'); - $formatter = new PropelArrayFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $books = $formatter->format($stmt); - - $this->assertTrue($books instanceof PropelCollection, 'PropelArrayFormatter::format() returns a PropelCollection'); - $this->assertEquals(1, count($books), 'PropelArrayFormatter::format() returns as many rows as the results in the query'); - $book = $books->shift(); - $this->assertTrue(is_array($book), 'PropelArrayFormatter::format() returns an array of arrays'); - $this->assertEquals('Quicksilver', $book['Title'], 'PropelArrayFormatter::format() returns the arrays matching the query'); - $expected = array('Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId'); - $this->assertEquals($expected, array_keys($book), 'PropelArrayFormatter::format() returns an associative array with column phpNames as keys'); - } + $this->assertTrue($books instanceof PropelCollection, 'PropelArrayFormatter::format() returns a PropelCollection'); + $this->assertEquals(4, count($books), 'PropelArrayFormatter::format() returns as many rows as the results in the query'); + foreach ($books as $book) { + $this->assertTrue(is_array($book), 'PropelArrayFormatter::format() returns an array of arrays'); + } + } - public function testFormatNoResult() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - - $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "foo"'); - $formatter = new PropelArrayFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $books = $formatter->format($stmt); - - $this->assertTrue($books instanceof PropelCollection, 'PropelArrayFormatter::format() returns a PropelCollection'); - $this->assertEquals(0, count($books), 'PropelArrayFormatter::format() returns as many rows as the results in the query'); - } + public function testFormatOneResult() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); - public function testFormatOneNoCriteria() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "Quicksilver"'); + $formatter = new PropelArrayFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $books = $formatter->format($stmt); - $stmt = $con->query('SELECT * FROM book'); - $formatter = new PropelArrayFormatter(); - try { - $book = $formatter->formatOne($stmt); - $this->fail('PropelArrayFormatter::formatOne() throws an exception when called with no valid criteria'); - } catch (PropelException $e) { - $this->assertTrue(true,'PropelArrayFormatter::formatOne() throws an exception when called with no valid criteria'); - } - } - - public function testFormatOneManyResults() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $this->assertTrue($books instanceof PropelCollection, 'PropelArrayFormatter::format() returns a PropelCollection'); + $this->assertEquals(1, count($books), 'PropelArrayFormatter::format() returns as many rows as the results in the query'); + $book = $books->shift(); + $this->assertTrue(is_array($book), 'PropelArrayFormatter::format() returns an array of arrays'); + $this->assertEquals('Quicksilver', $book['Title'], 'PropelArrayFormatter::format() returns the arrays matching the query'); + $expected = array('Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId'); + $this->assertEquals($expected, array_keys($book), 'PropelArrayFormatter::format() returns an associative array with column phpNames as keys'); + } - $stmt = $con->query('SELECT * FROM book'); - $formatter = new PropelArrayFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $book = $formatter->formatOne($stmt); - - $this->assertTrue(is_array($book), 'PropelArrayFormatter::formatOne() returns an array'); - $this->assertEquals(array('Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId'), array_keys($book), 'PropelArrayFormatter::formatOne() returns a single row even if the query has many results'); - } + public function testFormatNoResult() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); - public function testFormatOneNoResult() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - - $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "foo"'); - $formatter = new PropelArrayFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $book = $formatter->formatOne($stmt); - - $this->assertNull($book, 'PropelArrayFormatter::formatOne() returns null when no result'); - } + $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "foo"'); + $formatter = new PropelArrayFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $books = $formatter->format($stmt); + $this->assertTrue($books instanceof PropelCollection, 'PropelArrayFormatter::format() returns a PropelCollection'); + $this->assertEquals(0, count($books), 'PropelArrayFormatter::format() returns as many rows as the results in the query'); + } + + public function testFormatOneNoCriteria() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $stmt = $con->query('SELECT * FROM book'); + $formatter = new PropelArrayFormatter(); + try { + $book = $formatter->formatOne($stmt); + $this->fail('PropelArrayFormatter::formatOne() throws an exception when called with no valid criteria'); + } catch (PropelException $e) { + $this->assertTrue(true,'PropelArrayFormatter::formatOne() throws an exception when called with no valid criteria'); + } + } + + public function testFormatOneManyResults() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $stmt = $con->query('SELECT * FROM book'); + $formatter = new PropelArrayFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $book = $formatter->formatOne($stmt); + + $this->assertTrue(is_array($book), 'PropelArrayFormatter::formatOne() returns an array'); + $this->assertEquals(array('Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId'), array_keys($book), 'PropelArrayFormatter::formatOne() returns a single row even if the query has many results'); + } + + public function testFormatOneNoResult() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "foo"'); + $formatter = new PropelArrayFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $book = $formatter->formatOne($stmt); + + $this->assertNull($book, 'PropelArrayFormatter::formatOne() returns null when no result'); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelArrayFormatterWithTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelArrayFormatterWithTest.php index e0addfc46..477b7c986 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelArrayFormatterWithTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelArrayFormatterWithTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Test class for PropelArrayFormatter when Criteria uses with(). @@ -19,365 +19,436 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; */ class PropelArrayFormatterWithTest extends BookstoreEmptyTestBase { - protected function assertCorrectHydration1($c, $msg) - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $book = $c->findOne($con); - $count = $con->getQueryCount(); - $this->assertEquals($book['Title'], 'Don Juan', 'Main object is correctly hydrated ' . $msg); - $author = $book['Author']; - $this->assertEquals($author['LastName'], 'Byron', 'Related object is correctly hydrated ' . $msg); - $publisher = $book['Publisher']; - $this->assertEquals($publisher['Name'], 'Penguin', 'Related object is correctly hydrated ' . $msg); - } - - public function testFindOneWith() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ARRAY); - $c->orderBy('Book.Title'); - $c->join('Book.Author'); - $c->with('Author'); - $c->join('Book.Publisher'); - $c->with('Publisher'); - $this->assertCorrectHydration1($c, 'without instance pool'); - } + protected function assertCorrectHydration1($c, $msg) + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $book = $c->findOne($con); + $count = $con->getQueryCount(); + $this->assertEquals($book['Title'], 'Don Juan', 'Main object is correctly hydrated ' . $msg); + $author = $book['Author']; + $this->assertEquals($author['LastName'], 'Byron', 'Related object is correctly hydrated ' . $msg); + $publisher = $book['Publisher']; + $this->assertEquals($publisher['Name'], 'Penguin', 'Related object is correctly hydrated ' . $msg); + } - public function testFindOneWithAlias() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ARRAY); - $c->orderBy('Book.Title'); - $c->join('Book.Author a'); - $c->with('a'); - $c->join('Book.Publisher p'); - $c->with('p'); - $this->assertCorrectHydration1($c, 'with alias'); - } + public function testFindOneWith() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $c->orderBy('Book.Title'); + $c->join('Book.Author'); + $c->with('Author'); + $c->join('Book.Publisher'); + $c->with('Publisher'); + $this->assertCorrectHydration1($c, 'without instance pool'); + } - public function testFindOneWithMainAlias() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ARRAY); - $c->setModelAlias('b', true); - $c->orderBy('b.Title'); - $c->join('b.Author a'); - $c->with('a'); - $c->join('b.Publisher p'); - $c->with('p'); - $this->assertCorrectHydration1($c, 'with main alias'); - } - - public function testFindOneWithUsingInstancePool() - { - BookstoreDataPopulator::populate(); - // instance pool contains all objects by default, since they were just populated - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ARRAY); - $c->orderBy('Book.Title'); - $c->join('Book.Author'); - $c->with('Author'); - $c->join('Book.Publisher'); - $c->with('Publisher'); - $this->assertCorrectHydration1($c, 'with instance pool'); - } + public function testFindOneWithAlias() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $c->orderBy('Book.Title'); + $c->join('Book.Author a'); + $c->with('a'); + $c->join('Book.Publisher p'); + $c->with('p'); + $this->assertCorrectHydration1($c, 'with alias'); + } - public function testFindOneWithEmptyLeftJoin() - { - // save a book with no author - $b = new Book(); - $b->setTitle('Foo'); - $b->save(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ARRAY); - $c->where('Book.Title = ?', 'Foo'); - $c->leftJoin('Book.Author'); - $c->with('Author'); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $book = $c->findOne($con); - $count = $con->getQueryCount(); - $author = $book['Author']; - $this->assertEquals(array(), $author, 'Related object is not hydrated if empty'); - } + public function testFindOneWithMainAlias() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $c->setModelAlias('b', true); + $c->orderBy('b.Title'); + $c->join('b.Author a'); + $c->with('a'); + $c->join('b.Publisher p'); + $c->with('p'); + $this->assertCorrectHydration1($c, 'with main alias'); + } - public function testFindOneWithRelationName() - { - BookstoreDataPopulator::populate(); - BookstoreEmployeePeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'BookstoreEmployee'); - $c->setFormatter(ModelCriteria::FORMAT_ARRAY); - $c->join('BookstoreEmployee.Supervisor s'); - $c->with('s'); - $c->where('s.Name = ?', 'John'); - $emp = $c->findOne(); - $this->assertEquals($emp['Name'], 'Pieter', 'Main object is correctly hydrated'); - $sup = $emp['Supervisor']; - $this->assertEquals($sup['Name'], 'John', 'Related object is correctly hydrated'); - } - - /** - * @see http://www.propelorm.org/ticket/959 - */ - public function testFindOneWithSameRelatedObject() - { - BookPeer::doDeleteAll(); - AuthorPeer::doDeleteAll(); - $auth = new Author(); - $auth->setFirstName('John'); - $auth->save(); - $book1 = new Book(); - $book1->setTitle('Hello'); - $book1->setAuthor($auth); - $book1->save(); - $book2 = new Book(); - $book2->setTitle('World'); - $book2->setAuthor($auth); - $book2->save(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ARRAY); - $c->join('Book.Author'); - $c->with('Author'); - $books = $c->find(); - - $this->assertEquals(2, count($books)); - $firstBook = $books[0]; - $this->assertTrue(isset($firstBook['Author'])); - $secondBook = $books[1]; - $this->assertTrue(isset($secondBook['Author'])); - } - - public function testFindOneWithDuplicateRelation() - { - EssayPeer::doDeleteAll(); - $auth1 = new Author(); - $auth1->setFirstName('John'); - $auth1->save(); - $auth2 = new Author(); - $auth2->setFirstName('Jack'); - $auth2->save(); - $essay = new Essay(); - $essay->setTitle('Foo'); - $essay->setFirstAuthor($auth1->getId()); - $essay->setSecondAuthor($auth2->getId()); - $essay->save(); - AuthorPeer::clearInstancePool(); - EssayPeer::clearInstancePool(); - - $c = new ModelCriteria('bookstore', 'Essay'); - $c->setFormatter(ModelCriteria::FORMAT_ARRAY); - $c->join('Essay.AuthorRelatedByFirstAuthor'); - $c->with('AuthorRelatedByFirstAuthor'); - $c->where('Essay.Title = ?', 'Foo'); - $essay = $c->findOne(); - $this->assertEquals($essay['Title'], 'Foo', 'Main object is correctly hydrated'); - $firstAuthor = $essay['AuthorRelatedByFirstAuthor']; - $this->assertEquals($firstAuthor['FirstName'], 'John', 'Related object is correctly hydrated'); - $this->assertFalse(array_key_exists('AuthorRelatedBySecondAuthor', $essay), 'Only related object specified in with() is hydrated'); - } - - public function testFindOneWithDistantClass() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Review'); - $c->setFormatter(ModelCriteria::FORMAT_ARRAY); - $c->where('Review.Recommended = ?', true); - $c->join('Review.Book'); - $c->with('Book'); - $c->join('Book.Author'); - $c->with('Author'); - $review = $c->findOne(); - $this->assertEquals($review['ReviewedBy'], 'Washington Post', 'Main object is correctly hydrated'); - $book = $review['Book']; - $this->assertEquals('Harry Potter and the Order of the Phoenix', $book['Title'], 'Related object is correctly hydrated'); - $author = $book['Author']; - $this->assertEquals('J.K.', $author['FirstName'], 'Related object is correctly hydrated'); - } + public function testFindOneWithUsingInstancePool() + { + BookstoreDataPopulator::populate(); + // instance pool contains all objects by default, since they were just populated + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $c->orderBy('Book.Title'); + $c->join('Book.Author'); + $c->with('Author'); + $c->join('Book.Publisher'); + $c->with('Publisher'); + $this->assertCorrectHydration1($c, 'with instance pool'); + } - /** - * @expectedException PropelException - */ - public function testFindOneWithOneToManyAndLimit() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ARRAY); - $c->add(BookPeer::ISBN, '043935806X'); - $c->leftJoin('Book.Review'); - $c->with('Review'); - $c->limit(5); - $books = $c->find(); - } - - public function testFindOneWithOneToMany() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ARRAY); - $c->add(BookPeer::ISBN, '043935806X'); - $c->leftJoin('Book.Review'); - $c->with('Review'); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $books = $c->find($con); - $this->assertEquals(1, count($books), 'with() does not duplicate the main object'); - $book = $books[0]; - $this->assertEquals($book['Title'], 'Harry Potter and the Order of the Phoenix', 'Main object is correctly hydrated'); - $this->assertEquals(array('Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId', 'Reviews'), array_keys($book), 'with() adds a plural index for the one to many relationship'); - $reviews = $book['Reviews']; - $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); - $review1 = $reviews[0]; - $this->assertEquals(array('Id', 'ReviewedBy', 'ReviewDate', 'Recommended', 'Status', 'BookId'), array_keys($review1), 'with() Related objects are correctly hydrated'); - } + public function testFindOneWithEmptyLeftJoin() + { + // save a book with no author + $b = new Book(); + $b->setTitle('Foo'); + $b->setIsbn('Fr'); + $b->save(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $c->where('Book.Title = ?', 'Foo'); + $c->leftJoin('Book.Author'); + $c->with('Author'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $book = $c->findOne($con); + $count = $con->getQueryCount(); + $author = $book['Author']; + $this->assertEquals(array(), $author, 'Related object is not hydrated if empty'); + } - public function testFindOneWithOneToManyCustomOrder() - { - $author1 = new Author(); - $author1->setFirstName('AA'); - $author2 = new Author(); - $author2->setFirstName('BB'); - $book1 = new Book(); - $book1->setTitle('Aaa'); - $book1->setAuthor($author1); - $book1->save(); - $book2 = new Book(); - $book2->setTitle('Bbb'); - $book2->setAuthor($author2); - $book2->save(); - $book3 = new Book(); - $book3->setTitle('Ccc'); - $book3->setAuthor($author1); - $book3->save(); - $authors = AuthorQuery::create() - ->setFormatter(ModelCriteria::FORMAT_ARRAY) - ->leftJoin('Author.Book') - ->orderBy('Book.Title') - ->with('Book') - ->find(); - $this->assertEquals(2, count($authors), 'with() used on a many-to-many doesn\'t change the main object count'); - } - - public function testFindOneWithOneToManyThenManyToOne() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Author'); - $c->add(AuthorPeer::LAST_NAME, 'Rowling'); - $c->leftJoinWith('Author.Book'); - $c->leftJoinWith('Book.Review'); - $c->setFormatter(ModelCriteria::FORMAT_ARRAY); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $authors = $c->find($con); - $this->assertEquals(1, count($authors), 'with() does not duplicate the main object'); - $rowling = $authors[0]; - $this->assertEquals($rowling['FirstName'], 'J.K.', 'Main object is correctly hydrated'); - $books = $rowling['Books']; - $this->assertEquals(1, count($books), 'Related objects are correctly hydrated'); - $book = $books[0]; - $this->assertEquals($book['Title'], 'Harry Potter and the Order of the Phoenix', 'Related object is correctly hydrated'); - $reviews = $book['Reviews']; - $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); - } + public function testFindOneWithRelationName() + { + BookstoreDataPopulator::populate(); + BookstoreEmployeePeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'BookstoreEmployee'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $c->join('BookstoreEmployee.Supervisor s'); + $c->with('s'); + $c->where('s.Name = ?', 'John'); + $emp = $c->findOne(); + $this->assertEquals($emp['Name'], 'Pieter', 'Main object is correctly hydrated'); + $sup = $emp['Supervisor']; + $this->assertEquals($sup['Name'], 'John', 'Related object is correctly hydrated'); + } - public function testFindOneWithOneToManyThenManyToOneUsingAlias() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Author'); - $c->add(AuthorPeer::LAST_NAME, 'Rowling'); - $c->leftJoinWith('Author.Book b'); - $c->leftJoinWith('b.Review r'); - $c->setFormatter(ModelCriteria::FORMAT_ARRAY); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $authors = $c->find($con); - $this->assertEquals(1, count($authors), 'with() does not duplicate the main object'); - $rowling = $authors[0]; - $this->assertEquals($rowling['FirstName'], 'J.K.', 'Main object is correctly hydrated'); - $books = $rowling['Books']; - $this->assertEquals(1, count($books), 'Related objects are correctly hydrated'); - $book = $books[0]; - $this->assertEquals($book['Title'], 'Harry Potter and the Order of the Phoenix', 'Related object is correctly hydrated'); - $reviews = $book['Reviews']; - $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); - } - - public function testFindOneWithColumn() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ARRAY); - $c->filterByTitle('The Tin Drum'); - $c->join('Book.Author'); - $c->withColumn('Author.FirstName', 'AuthorName'); - $c->withColumn('Author.LastName', 'AuthorName2'); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $book = $c->findOne($con); - $this->assertEquals(array('Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId', 'AuthorName', 'AuthorName2'), array_keys($book), 'withColumn() do not change the resulting model class'); - $this->assertEquals('The Tin Drum', $book['Title']); - $this->assertEquals('Gunter', $book['AuthorName'], 'PropelArrayFormatter adds withColumns as columns'); - $this->assertEquals('Grass', $book['AuthorName2'], 'PropelArrayFormatter correctly hydrates all as columns'); - } - - public function testFindOneWithClassAndColumn() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ARRAY); - $c->filterByTitle('The Tin Drum'); - $c->join('Book.Author'); - $c->withColumn('Author.FirstName', 'AuthorName'); - $c->withColumn('Author.LastName', 'AuthorName2'); - $c->with('Author'); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $book = $c->findOne($con); - $this->assertEquals(array('Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId', 'Author', 'AuthorName', 'AuthorName2'), array_keys($book), 'withColumn() do not change the resulting model class'); - $this->assertEquals('The Tin Drum', $book['Title']); - $this->assertEquals('Gunter', $book['Author']['FirstName'], 'PropelArrayFormatter correctly hydrates withclass and columns'); - $this->assertEquals('Gunter', $book['AuthorName'], 'PropelArrayFormatter adds withColumns as columns'); - $this->assertEquals('Grass', $book['AuthorName2'], 'PropelArrayFormatter correctly hydrates all as columns'); - } + /** + * @see http://www.propelorm.org/ticket/959 + */ + public function testFindOneWithSameRelatedObject() + { + BookPeer::doDeleteAll(); + AuthorPeer::doDeleteAll(); + $auth = new Author(); + $auth->setFirstName('John'); + $auth->setLastName('Doe'); + $auth->save(); + $book1 = new Book(); + $book1->setTitle('Hello'); + $book1->setIsbn('135'); + $book1->setAuthor($auth); + $book1->save(); + $book2 = new Book(); + $book2->setTitle('World'); + $book2->setIsbn('235'); + $book2->setAuthor($auth); + $book2->save(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); - public function testFindPkWithOneToMany() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $book = BookQuery::create() - ->findOneByTitle('Harry Potter and the Order of the Phoenix', $con); - $pk = $book->getPrimaryKey(); - BookPeer::clearInstancePool(); - $book = BookQuery::create() - ->setFormatter(ModelCriteria::FORMAT_ARRAY) - ->joinWith('Review') - ->findPk($pk, $con); - $reviews = $book['Reviews']; - $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); - } + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $c->join('Book.Author'); + $c->with('Author'); + $books = $c->find(); + + $this->assertEquals(2, count($books)); + $firstBook = $books[0]; + $this->assertTrue(isset($firstBook['Author'])); + $secondBook = $books[1]; + $this->assertTrue(isset($secondBook['Author'])); + } + + public function testFindOneWithDuplicateRelation() + { + EssayPeer::doDeleteAll(); + $auth1 = new Author(); + $auth1->setFirstName('John'); + $auth1->setLastName('Doe'); + $auth1->save(); + $auth2 = new Author(); + $auth2->setFirstName('Jack'); + $auth2->setLastName('Sparrow'); + $auth2->save(); + $essay = new Essay(); + $essay->setTitle('Foo'); + $essay->setFirstAuthor($auth1->getId()); + $essay->setSecondAuthor($auth2->getId()); + $essay->save(); + AuthorPeer::clearInstancePool(); + EssayPeer::clearInstancePool(); + + $c = new ModelCriteria('bookstore', 'Essay'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $c->join('Essay.AuthorRelatedByFirstAuthor'); + $c->with('AuthorRelatedByFirstAuthor'); + $c->where('Essay.Title = ?', 'Foo'); + $essay = $c->findOne(); + $this->assertEquals($essay['Title'], 'Foo', 'Main object is correctly hydrated'); + $firstAuthor = $essay['AuthorRelatedByFirstAuthor']; + $this->assertEquals($firstAuthor['FirstName'], 'John', 'Related object is correctly hydrated'); + $this->assertFalse(array_key_exists('AuthorRelatedBySecondAuthor', $essay), 'Only related object specified in with() is hydrated'); + } + + public function testFindOneWithDistantClass() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Review'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $c->where('Review.Recommended = ?', true); + $c->join('Review.Book'); + $c->with('Book'); + $c->join('Book.Author'); + $c->with('Author'); + $review = $c->findOne(); + $this->assertEquals($review['ReviewedBy'], 'Washington Post', 'Main object is correctly hydrated'); + $book = $review['Book']; + $this->assertEquals('Harry Potter and the Order of the Phoenix', $book['Title'], 'Related object is correctly hydrated'); + $author = $book['Author']; + $this->assertEquals('J.K.', $author['FirstName'], 'Related object is correctly hydrated'); + } + + public function testFindOneWithDistantClassRenamedRelation() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + Propel::enableInstancePooling(); + $c = new ModelCriteria('bookstore', 'BookSummary'); + $c->joinWith('BookSummary.SummarizedBook'); + $c->joinWith('SummarizedBook.Author'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $summary = $c->findOne($con); + $count = $con->getQueryCount(); + $this->assertEquals('Harry Potter does some amazing magic!', $summary['Summary'], 'Main object is correctly hydrated'); + $book = $summary['SummarizedBook']; + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); + $this->assertEquals('Harry Potter and the Order of the Phoenix', $book['Title'], 'Related object is correctly hydrated'); + $author = $book['Author']; + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); + $this->assertEquals('J.K.', $author['FirstName'], 'Related object is correctly hydrated'); + } + + /** + * @expectedException PropelException + */ + public function testFindOneWithOneToManyAndLimit() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $c->add(BookPeer::ISBN, '043935806X'); + $c->leftJoin('Book.Review'); + $c->with('Review'); + $c->limit(5); + $books = $c->find(); + } + + public function testFindOneWithOneToMany() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $c->add(BookPeer::ISBN, '043935806X'); + $c->leftJoin('Book.Review'); + $c->with('Review'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $books = $c->find($con); + $this->assertEquals(1, count($books), 'with() does not duplicate the main object'); + $book = $books[0]; + $this->assertEquals($book['Title'], 'Harry Potter and the Order of the Phoenix', 'Main object is correctly hydrated'); + $this->assertEquals(array('Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId', 'Reviews'), array_keys($book), 'with() adds a plural index for the one to many relationship'); + $reviews = $book['Reviews']; + $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); + $review1 = $reviews[0]; + $this->assertEquals(array('Id', 'ReviewedBy', 'ReviewDate', 'Recommended', 'Status', 'BookId'), array_keys($review1), 'with() Related objects are correctly hydrated'); + } + + public function testFindOneWithOneToManyCustomOrder() + { + $author1 = new Author(); + $author1->setFirstName('AA'); + $author1->setLastName('AA'); + $author2 = new Author(); + $author2->setFirstName('BB'); + $author2->setLastName('BB'); + $book1 = new Book(); + $book1->setTitle('Aaa'); + $book1->setIsbn('124'); + $book1->setAuthor($author1); + $book1->save(); + $book2 = new Book(); + $book2->setTitle('Bbb'); + $book2->setIsbn('35T'); + $book2->setAuthor($author2); + $book2->save(); + $book3 = new Book(); + $book3->setTitle('Ccc'); + $book3->setIsbn('1256'); + $book3->setAuthor($author1); + $book3->save(); + $authors = AuthorQuery::create() + ->setFormatter(ModelCriteria::FORMAT_ARRAY) + ->leftJoin('Author.Book') + ->orderBy('Book.Title') + ->with('Book') + ->find(); + $this->assertEquals(2, count($authors), 'with() used on a many-to-many doesn\'t change the main object count'); + } + + public function testFindOneWithOneToManyThenManyToOne() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Author'); + $c->add(AuthorPeer::LAST_NAME, 'Rowling'); + $c->leftJoinWith('Author.Book'); + $c->leftJoinWith('Book.Review'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $authors = $c->find($con); + $this->assertEquals(1, count($authors), 'with() does not duplicate the main object'); + $rowling = $authors[0]; + $this->assertEquals($rowling['FirstName'], 'J.K.', 'Main object is correctly hydrated'); + $books = $rowling['Books']; + $this->assertEquals(1, count($books), 'Related objects are correctly hydrated'); + $book = $books[0]; + $this->assertEquals($book['Title'], 'Harry Potter and the Order of the Phoenix', 'Related object is correctly hydrated'); + $reviews = $book['Reviews']; + $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); + } + + public function testFindOneWithOneToManyThenManyToOneUsingAlias() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Author'); + $c->add(AuthorPeer::LAST_NAME, 'Rowling'); + $c->leftJoinWith('Author.Book b'); + $c->leftJoinWith('b.Review r'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $authors = $c->find($con); + $this->assertEquals(1, count($authors), 'with() does not duplicate the main object'); + $rowling = $authors[0]; + $this->assertEquals($rowling['FirstName'], 'J.K.', 'Main object is correctly hydrated'); + $books = $rowling['Books']; + $this->assertEquals(1, count($books), 'Related objects are correctly hydrated'); + $book = $books[0]; + $this->assertEquals($book['Title'], 'Harry Potter and the Order of the Phoenix', 'Related object is correctly hydrated'); + $reviews = $book['Reviews']; + $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); + } + + public function testFindWithLeftJoinWithOneToManyAndNullObject() + { + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $freud = new Author(); + $freud->setFirstName("Sigmund"); + $freud->setLastName("Freud"); + $freud->save($this->con); + $c = new ModelCriteria('bookstore', 'Author'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $c->add(AuthorPeer::LAST_NAME, 'Freud'); + $c->leftJoinWith('Author.Book'); + $c->leftJoinWith('Book.Review'); + // should not raise a notice + $authors = $c->find($this->con); + $this->assertTrue(true); + } + + public function testFindWithLeftJoinWithManyToOneAndNullObject() + { + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $review = new Review(); + $review->setReviewedBy('Toot'); + $review->setRecommended('0'); + $review->save($this->con); + $c = new ModelCriteria('bookstore', 'Review'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $c->leftJoinWith('Review.Book'); + $c->leftJoinWith('Book.Author'); + // should not raise a notice + $reviews = $c->find($this->con); + $this->assertTrue(true); + } + + public function testFindOneWithColumn() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $c->filterByTitle('The Tin Drum'); + $c->join('Book.Author'); + $c->withColumn('Author.FirstName', 'AuthorName'); + $c->withColumn('Author.LastName', 'AuthorName2'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $book = $c->findOne($con); + $this->assertEquals(array('Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId', 'AuthorName', 'AuthorName2'), array_keys($book), 'withColumn() do not change the resulting model class'); + $this->assertEquals('The Tin Drum', $book['Title']); + $this->assertEquals('Gunter', $book['AuthorName'], 'PropelArrayFormatter adds withColumns as columns'); + $this->assertEquals('Grass', $book['AuthorName2'], 'PropelArrayFormatter correctly hydrates all as columns'); + } + + public function testFindOneWithClassAndColumn() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ARRAY); + $c->filterByTitle('The Tin Drum'); + $c->join('Book.Author'); + $c->withColumn('Author.FirstName', 'AuthorName'); + $c->withColumn('Author.LastName', 'AuthorName2'); + $c->with('Author'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $book = $c->findOne($con); + $this->assertEquals(array('Id', 'Title', 'ISBN', 'Price', 'PublisherId', 'AuthorId', 'Author', 'AuthorName', 'AuthorName2'), array_keys($book), 'withColumn() do not change the resulting model class'); + $this->assertEquals('The Tin Drum', $book['Title']); + $this->assertEquals('Gunter', $book['Author']['FirstName'], 'PropelArrayFormatter correctly hydrates withclass and columns'); + $this->assertEquals('Gunter', $book['AuthorName'], 'PropelArrayFormatter adds withColumns as columns'); + $this->assertEquals('Grass', $book['AuthorName2'], 'PropelArrayFormatter correctly hydrates all as columns'); + } + + public function testFindPkWithOneToMany() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $book = BookQuery::create() + ->findOneByTitle('Harry Potter and the Order of the Phoenix', $con); + $pk = $book->getPrimaryKey(); + BookPeer::clearInstancePool(); + $book = BookQuery::create() + ->setFormatter(ModelCriteria::FORMAT_ARRAY) + ->joinWith('Review') + ->findPk($pk, $con); + $reviews = $book['Reviews']; + $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelFormatterTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelFormatterTest.php new file mode 100644 index 000000000..4dd013f94 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelFormatterTest.php @@ -0,0 +1,65 @@ +getMockForAbstractClass('PropelFormatter'); + + $method = new ReflectionMethod('PropelFormatter', 'getWorkerObject'); + $method->setAccessible(true); + + $classNames = array( + 'Bookstore', + 'BookReader', + 'BookClubList', + ); + + $col = 0; + foreach ($classNames as $className) { + // getWorkerObject() should always return an instance of the requested class, regardless of the value of $col + $result = $method->invoke($formatter, $col, $className); + + $this->assertEquals($className, get_class($result), 'getWorkerObject did not return an instance of the requested class'); + } + } + + public function testGetWorkerObjectCachedInstance() + { + $formatter = $this->getMockForAbstractClass('PropelFormatter'); + + $method = new ReflectionMethod('PropelFormatter', 'getWorkerObject'); + $method->setAccessible(true); + + $className = 'Bookstore'; + $col = 0; + + $result1 = $method->invoke($formatter, $col, $className); + $result2 = $method->invoke($formatter, $col, $className); + + $this->assertEquals(spl_object_hash($result1), spl_object_hash($result2), 'getWorkerObject should return a cached instance of a class at the same col index'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelObjectFormatterInheritanceTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelObjectFormatterInheritanceTest.php index 95ea1cce3..857c608d1 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelObjectFormatterInheritanceTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelObjectFormatterInheritanceTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Test class for PropelObjectFormatter. @@ -19,37 +19,37 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; */ class PropelObjectFormatterInheritanceTest extends BookstoreEmptyTestBase { - protected function setUp() - { - parent::setUp(); - $b1 = new BookstoreEmployee(); - $b1->setName('b1'); - $b1->save(); - $b2 = new BookstoreManager(); - $b2->setName('b2'); - $b2->save(); - $b3 = new BookstoreCashier(); - $b3->setName('b3'); - $b3->save(); - } + protected function setUp() + { + parent::setUp(); + $b1 = new BookstoreEmployee(); + $b1->setName('b1'); + $b1->save(); + $b2 = new BookstoreManager(); + $b2->setName('b2'); + $b2->save(); + $b3 = new BookstoreCashier(); + $b3->setName('b3'); + $b3->save(); + } + + public function testFormat() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + BookstoreEmployeePeer::clearInstancePool(); + + $stmt = $con->query('SELECT * FROM bookstore_employee'); + $formatter = new PropelObjectFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'BookstoreEmployee')); + $emps = $formatter->format($stmt); + $expectedClass = array( + 'b1' =>'BookstoreEmployee', + 'b2' =>'BookstoreManager', + 'b3' =>'BookstoreCashier' + ); + foreach ($emps as $emp) { + $this->assertEquals($expectedClass[$emp->getName()], get_class($emp), 'format() creates objects of the correct class when using inheritance'); + } + } - public function testFormat() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - BookstoreEmployeePeer::clearInstancePool(); - - $stmt = $con->query('SELECT * FROM bookstore_employee'); - $formatter = new PropelObjectFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'BookstoreEmployee')); - $emps = $formatter->format($stmt); - $expectedClass = array( - 'b1' =>'BookstoreEmployee', - 'b2' =>'BookstoreManager', - 'b3' =>'BookstoreCashier' - ); - foreach ($emps as $emp) { - $this->assertEquals($expectedClass[$emp->getName()], get_class($emp), 'format() creates objects of the correct class when using inheritance'); - } - } - } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelObjectFormatterTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelObjectFormatterTest.php index 7321a2fbf..e215744fb 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelObjectFormatterTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelObjectFormatterTest.php @@ -8,118 +8,187 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Test class for PropelObjectFormatter. * * @author Francois Zaninotto - * @version $Id: PropelObjectFormatterTest.php 1733 2010-05-04 14:25:27Z francois $ + * @version $Id$ * @package runtime.formatter */ class PropelObjectFormatterTest extends BookstoreEmptyTestBase { - protected function setUp() - { - parent::setUp(); - BookstoreDataPopulator::populate(); - } + protected function setUp() + { + parent::setUp(); - public function testFormatNoCriteria() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); + BookstoreDataPopulator::populate(null, true); + } - $stmt = $con->query('SELECT * FROM book'); - $formatter = new PropelObjectFormatter(); - try { - $books = $formatter->format($stmt); - $this->fail('PropelObjectFormatter::format() trows an exception when called with no valid criteria'); - } catch (PropelException $e) { - $this->assertTrue(true,'PropelObjectFormatter::format() trows an exception when called with no valid criteria'); - } - } - - public function testFormatManyResults() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); + public function testFormatNoCriteria() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $stmt = $con->query('SELECT * FROM book'); - $formatter = new PropelObjectFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $books = $formatter->format($stmt); - - $this->assertTrue($books instanceof PropelCollection, 'PropelObjectFormatter::format() returns a PropelCollection'); - $this->assertEquals(4, count($books), 'PropelObjectFormatter::format() returns as many rows as the results in the query'); - foreach ($books as $book) { - $this->assertTrue($book instanceof Book, 'PropelObjectFormatter::format() returns an array of Model objects'); - } - } + $stmt = $con->query('SELECT * FROM book'); + $formatter = new PropelObjectFormatter(); + try { + $books = $formatter->format($stmt); + $this->fail('PropelObjectFormatter::format() trows an exception when called with no valid criteria'); + } catch (PropelException $e) { + $this->assertTrue(true,'PropelObjectFormatter::format() trows an exception when called with no valid criteria'); + } + } - public function testFormatOneResult() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); + public function testFormatValidClass() + { + $stmt = $this->con->query('SELECT * FROM book'); + $formatter = new PropelObjectFormatter(); + $formatter->setClass('Book'); + $books = $formatter->format($stmt); + $this->assertTrue($books instanceof PropelObjectCollection); + $this->assertEquals(5, $books->count()); + } - $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "Quicksilver"'); - $formatter = new PropelObjectFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $books = $formatter->format($stmt); - - $this->assertTrue($books instanceof PropelCollection, 'PropelObjectFormatter::format() returns a PropelCollection'); - $this->assertEquals(1, count($books), 'PropelObjectFormatter::format() returns as many rows as the results in the query'); - $book = $books->shift(); - $this->assertTrue($book instanceof Book, 'PropelObjectFormatter::format() returns an array of Model objects'); - $this->assertEquals('Quicksilver', $book->getTitle(), 'PropelObjectFormatter::format() returns the model objects matching the query'); - } + public function testFormatManyResults() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); - public function testFormatNoResult() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - - $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "foo"'); - $formatter = new PropelObjectFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $books = $formatter->format($stmt); - - $this->assertTrue($books instanceof PropelCollection, 'PropelObjectFormatter::format() returns a PropelCollection'); - $this->assertEquals(0, count($books), 'PropelObjectFormatter::format() returns as many rows as the results in the query'); - } - - public function testFormatOneNoCriteria() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $stmt = $con->query('SELECT * FROM book'); + $formatter = new PropelObjectFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $books = $formatter->format($stmt); - $stmt = $con->query('SELECT * FROM book'); - $formatter = new PropelObjectFormatter(); - try { - $book = $formatter->formatOne($stmt); - $this->fail('PropelObjectFormatter::formatOne() throws an exception when called with no valid criteria'); - } catch (PropelException $e) { - $this->assertTrue(true,'PropelObjectFormatter::formatOne() throws an exception when called with no valid criteria'); - } - } - - public function testFormatOneManyResults() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $this->assertTrue($books instanceof PropelCollection, 'PropelObjectFormatter::format() returns a PropelCollection'); + $this->assertEquals(5, count($books), 'PropelObjectFormatter::format() returns as many rows as the results in the query'); + foreach ($books as $book) { + $this->assertTrue($book instanceof Book, 'PropelObjectFormatter::format() returns an array of Model objects'); + } + } - $stmt = $con->query('SELECT * FROM book'); - $formatter = new PropelObjectFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $book = $formatter->formatOne($stmt); - - $this->assertTrue($book instanceof Book, 'PropelObjectFormatter::formatOne() returns a model object'); - } + public function testFormatOneResult() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); - public function testFormatOneNoResult() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - - $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "foo"'); - $formatter = new PropelObjectFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $book = $formatter->formatOne($stmt); - - $this->assertNull($book, 'PropelObjectFormatter::formatOne() returns null when no result'); - } - + $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "Quicksilver"'); + $formatter = new PropelObjectFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $books = $formatter->format($stmt); + + $this->assertTrue($books instanceof PropelCollection, 'PropelObjectFormatter::format() returns a PropelCollection'); + $this->assertEquals(1, count($books), 'PropelObjectFormatter::format() returns as many rows as the results in the query'); + $book = $books->shift(); + $this->assertTrue($book instanceof Book, 'PropelObjectFormatter::format() returns an array of Model objects'); + $this->assertEquals('Quicksilver', $book->getTitle(), 'PropelObjectFormatter::format() returns the model objects matching the query'); + } + + public function testFormatNoResult() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "foo"'); + $formatter = new PropelObjectFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $books = $formatter->format($stmt); + + $this->assertTrue($books instanceof PropelCollection, 'PropelObjectFormatter::format() returns a PropelCollection'); + $this->assertEquals(0, count($books), 'PropelObjectFormatter::format() returns as many rows as the results in the query'); + } + + public function testFormatOneNoCriteria() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $stmt = $con->query('SELECT * FROM book'); + $formatter = new PropelObjectFormatter(); + try { + $book = $formatter->formatOne($stmt); + $this->fail('PropelObjectFormatter::formatOne() throws an exception when called with no valid criteria'); + } catch (PropelException $e) { + $this->assertTrue(true,'PropelObjectFormatter::formatOne() throws an exception when called with no valid criteria'); + } + } + + public function testFormatOneManyResults() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $stmt = $con->query('SELECT * FROM book'); + $formatter = new PropelObjectFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $book = $formatter->formatOne($stmt); + + $this->assertTrue($book instanceof Book, 'PropelObjectFormatter::formatOne() returns a model object'); + } + + public function testFormatOneNoResult() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "foo"'); + $formatter = new PropelObjectFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $book = $formatter->formatOne($stmt); + + $this->assertNull($book, 'PropelObjectFormatter::formatOne() returns null when no result'); + } + + public function testFormatOneWithRelatedObjects() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $con->useDebug(false); + $con->useDebug(true); + + $this->assertEquals(0, $con->getQueryCount()); + + $stmt = $con->query('SELECT * FROM author LEFT JOIN book ON (author.id = book.author_id) WHERE author.id = (SELECT author_id FROM book WHERE title = "The Tin Drum 2")'); + $formatter = new PropelObjectFormatter(); + + $criteria = new ModelCriteria('bookstore', 'Author'); + $criteria->joinWith('Book'); + + $formatter->init($criteria); + $author = $formatter->formatOne($stmt); + + $this->assertEquals(1, $con->getQueryCount()); + $this->assertTrue($author instanceof Author, 'PropelObjectFormatter::formatOne() returns a model object'); + + $this->assertTrue($author->getBooks() instanceof PropelCollection); + $this->assertEquals(2, $author->countBooks()); + + $this->assertEquals(1, $con->getQueryCount()); + } + + public function testFormaWithRelatedObjects() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $con->useDebug(false); + $con->useDebug(true); + + $this->assertEquals(0, $con->getQueryCount()); + + $stmt = $con->query('SELECT * FROM author LEFT JOIN book ON (author.id = book.author_id)'); + $formatter = new PropelObjectFormatter(); + + $criteria = new ModelCriteria('bookstore', 'Author'); + $criteria->joinWith('Book'); + + $formatter->init($criteria); + $authors = $formatter->format($stmt); + + $this->assertEquals(1, $con->getQueryCount()); + $this->assertTrue($authors instanceof PropelObjectCollection, 'PropelObjectFormatter::formatOne() returns a model object'); + + foreach ($authors as $author) { + $this->assertTrue($author->getBooks() instanceof PropelCollection); + + if ('Grass' === $author->getLastName()) { + $this->assertEquals(2, $author->countBooks()); + } else { + $this->assertEquals(1, $author->countBooks()); + } + } + + $this->assertEquals(1, $con->getQueryCount()); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelObjectFormatterWithTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelObjectFormatterWithTest.php index 14279d9a3..aad247dcb 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelObjectFormatterWithTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelObjectFormatterWithTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Test class for PropelObjectFormatter when Criteria uses with(). @@ -19,388 +19,577 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; */ class PropelObjectFormatterWithTest extends BookstoreEmptyTestBase { - protected function assertCorrectHydration1($c, $msg) - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $book = $c->findOne($con); - $count = $con->getQueryCount(); - $this->assertEquals($book->getTitle(), 'Don Juan', 'Main object is correctly hydrated ' . $msg); - $author = $book->getAuthor(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query ' . $msg); - $this->assertEquals($author->getLastName(), 'Byron', 'Related object is correctly hydrated ' . $msg); - $publisher = $book->getPublisher(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query ' . $msg); - $this->assertEquals($publisher->getName(), 'Penguin', 'Related object is correctly hydrated ' . $msg); - } - - public function testFindOneWith() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->orderBy('Book.Title'); - $c->join('Book.Author'); - $c->with('Author'); - $c->join('Book.Publisher'); - $c->with('Publisher'); - $this->assertCorrectHydration1($c, 'without instance pool'); - } + protected function assertCorrectHydration1($c, $msg) + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $book = $c->findOne($con); + $count = $con->getQueryCount(); + $this->assertEquals($book->getTitle(), 'Don Juan', 'Main object is correctly hydrated ' . $msg); + $author = $book->getAuthor(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query ' . $msg); + $this->assertEquals($author->getLastName(), 'Byron', 'Related object is correctly hydrated ' . $msg); + $publisher = $book->getPublisher(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query ' . $msg); + $this->assertEquals($publisher->getName(), 'Penguin', 'Related object is correctly hydrated ' . $msg); + } - public function testFindOneWithAlias() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->orderBy('Book.Title'); - $c->join('Book.Author a'); - $c->with('a'); - $c->join('Book.Publisher p'); - $c->with('p'); - $this->assertCorrectHydration1($c, 'with alias'); - } + public function testFindOneWith() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->orderBy('Book.Title'); + $c->join('Book.Author'); + $c->with('Author'); + $c->join('Book.Publisher'); + $c->with('Publisher'); + $this->assertCorrectHydration1($c, 'without instance pool'); + } - public function testFindOneWithMainAlias() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->setModelAlias('b', true); - $c->orderBy('b.Title'); - $c->join('b.Author a'); - $c->with('a'); - $c->join('b.Publisher p'); - $c->with('p'); - $this->assertCorrectHydration1($c, 'with main alias'); - } - - public function testFindOneWithUsingInstancePool() - { - BookstoreDataPopulator::populate(); - // instance pool contains all objects by default, since they were just populated - $c = new ModelCriteria('bookstore', 'Book'); - $c->orderBy('Book.Title'); - $c->join('Book.Author'); - $c->with('Author'); - $c->join('Book.Publisher'); - $c->with('Publisher'); - $this->assertCorrectHydration1($c, 'with instance pool'); - } + public function testFindOneWithAlias() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->orderBy('Book.Title'); + $c->join('Book.Author a'); + $c->with('a'); + $c->join('Book.Publisher p'); + $c->with('p'); + $this->assertCorrectHydration1($c, 'with alias'); + } - public function testFindOneWithoutUsingInstancePool() - { - BookstoreDataPopulator::populate(); - Propel::disableInstancePooling(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->orderBy('Book.Title'); - $c->join('Book.Author'); - $c->with('Author'); - $c->join('Book.Publisher'); - $c->with('Publisher'); - $this->assertCorrectHydration1($c, 'without instance pool'); - Propel::enableInstancePooling(); - } + public function testFindOneWithMainAlias() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->setModelAlias('b', true); + $c->orderBy('b.Title'); + $c->join('b.Author a'); + $c->with('a'); + $c->join('b.Publisher p'); + $c->with('p'); + $this->assertCorrectHydration1($c, 'with main alias'); + } - public function testFindOneWithEmptyLeftJoin() - { - // save a book with no author - $b = new Book(); - $b->setTitle('Foo'); - $b->save(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->where('Book.Title = ?', 'Foo'); - $c->leftJoin('Book.Author'); - $c->with('Author'); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $book = $c->findOne($con); - $count = $con->getQueryCount(); - $author = $book->getAuthor(); - $this->assertNull($author, 'Related object is not hydrated if empty'); - } + public function testFindOneWithUsingInstancePool() + { + BookstoreDataPopulator::populate(); + // instance pool contains all objects by default, since they were just populated + $c = new ModelCriteria('bookstore', 'Book'); + $c->orderBy('Book.Title'); + $c->join('Book.Author'); + $c->with('Author'); + $c->join('Book.Publisher'); + $c->with('Publisher'); + $this->assertCorrectHydration1($c, 'with instance pool'); + } - public function testFindOneWithRelationName() - { - BookstoreDataPopulator::populate(); - BookstoreEmployeePeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'BookstoreEmployee'); - $c->join('BookstoreEmployee.Supervisor s'); - $c->with('s'); - $c->where('s.Name = ?', 'John'); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $emp = $c->findOne($con); - $count = $con->getQueryCount(); - $this->assertEquals($emp->getName(), 'Pieter', 'Main object is correctly hydrated'); - $sup = $emp->getSupervisor(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); - $this->assertEquals($sup->getName(), 'John', 'Related object is correctly hydrated'); - } + public function testFindOneWithoutUsingInstancePool() + { + BookstoreDataPopulator::populate(); + Propel::disableInstancePooling(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->orderBy('Book.Title'); + $c->join('Book.Author'); + $c->with('Author'); + $c->join('Book.Publisher'); + $c->with('Publisher'); + $this->assertCorrectHydration1($c, 'without instance pool'); + Propel::enableInstancePooling(); + } - public function testFindOneWithDuplicateRelation() - { - EssayPeer::doDeleteAll(); - $auth1 = new Author(); - $auth1->setFirstName('John'); - $auth1->save(); - $auth2 = new Author(); - $auth2->setFirstName('Jack'); - $auth2->save(); - $essay = new Essay(); - $essay->setTitle('Foo'); - $essay->setFirstAuthor($auth1->getId()); - $essay->setSecondAuthor($auth2->getId()); - $essay->save(); - AuthorPeer::clearInstancePool(); - EssayPeer::clearInstancePool(); - - $c = new ModelCriteria('bookstore', 'Essay'); - $c->join('Essay.AuthorRelatedByFirstAuthor'); - $c->with('AuthorRelatedByFirstAuthor'); - $c->where('Essay.Title = ?', 'Foo'); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $essay = $c->findOne($con); - $count = $con->getQueryCount(); - $this->assertEquals($essay->getTitle(), 'Foo', 'Main object is correctly hydrated'); - $firstAuthor = $essay->getAuthorRelatedByFirstAuthor(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); - $this->assertEquals($firstAuthor->getFirstName(), 'John', 'Related object is correctly hydrated'); - $secondAuthor = $essay->getAuthorRelatedBySecondAuthor(); - $this->assertEquals($count + 1, $con->getQueryCount(), 'with() does not hydrate objects not in with'); - } - - public function testFindOneWithDistantClass() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - Propel::enableInstancePooling(); - $c = new ModelCriteria('bookstore', 'Review'); - $c->where('Review.Recommended = ?', true); - $c->join('Review.Book'); - $c->with('Book'); - $c->join('Book.Author'); - $c->with('Author'); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $review = $c->findOne($con); - $count = $con->getQueryCount(); - $this->assertEquals($review->getReviewedBy(), 'Washington Post', 'Main object is correctly hydrated'); - $book = $review->getBook(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); - $this->assertEquals('Harry Potter and the Order of the Phoenix', $book->getTitle(), 'Related object is correctly hydrated'); - $author = $book->getAuthor(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); - $this->assertEquals('J.K.', $author->getFirstName(), 'Related object is correctly hydrated'); - } - - /** - * @expectedException PropelException - */ - public function testFindOneWithOneToManyAndLimit() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->add(BookPeer::ISBN, '043935806X'); - $c->leftJoin('Book.Review'); - $c->with('Review'); - $c->limit(5); - $books = $c->find(); - } - - public function testFindOneWithOneToMany() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->add(BookPeer::ISBN, '043935806X'); - $c->leftJoin('Book.Review'); - $c->with('Review'); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $books = $c->find($con); - $this->assertEquals(1, count($books), 'with() does not duplicate the main object'); - $book = $books[0]; - $count = $con->getQueryCount(); - $this->assertEquals($book->getTitle(), 'Harry Potter and the Order of the Phoenix', 'Main object is correctly hydrated'); - $reviews = $book->getReviews(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query '); - $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); - try { - $book->save(); - } catch (Exception $e) { - $this->fail('with() does not force objects to be new'); - } - } - - public function testFindOneWithOneToManyCustomOrder() - { - $author1 = new Author(); - $author1->setFirstName('AA'); - $author2 = new Author(); - $author2->setFirstName('BB'); - $book1 = new Book(); - $book1->setTitle('Aaa'); - $book1->setAuthor($author1); - $book1->save(); - $book2 = new Book(); - $book2->setTitle('Bbb'); - $book2->setAuthor($author2); - $book2->save(); - $book3 = new Book(); - $book3->setTitle('Ccc'); - $book3->setAuthor($author1); - $book3->save(); - $authors = AuthorQuery::create() - ->leftJoin('Author.Book') - ->orderBy('Book.Title') - ->with('Book') - ->find(); - $this->assertEquals(2, count($authors), 'with() used on a many-to-many doesn\'t change the main object count'); - } - - public function testFindOneWithOneToManyThenManyToOne() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Author'); - $c->add(AuthorPeer::LAST_NAME, 'Rowling'); - $c->leftJoinWith('Author.Book'); - $c->leftJoinWith('Book.Review'); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $authors = $c->find($con); - $this->assertEquals(1, count($authors), 'with() does not duplicate the main object'); - $rowling = $authors[0]; - $count = $con->getQueryCount(); - $this->assertEquals($rowling->getFirstName(), 'J.K.', 'Main object is correctly hydrated'); - $books = $rowling->getBooks(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query '); - $this->assertEquals(1, count($books), 'Related objects are correctly hydrated'); - $book = $books[0]; - $this->assertEquals($book->getTitle(), 'Harry Potter and the Order of the Phoenix', 'Related object is correctly hydrated'); - $reviews = $book->getReviews(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query '); - $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); - } - - public function testFindOneWithOneToManyThenManyToOneUsingJoinRelated() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); + public function testFindOneWithEmptyLeftJoin() + { + // save a book with no author + $b = new Book(); + $b->setTitle('Foo'); + $b->setIsbn('124'); + $b->save(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->where('Book.Title = ?', 'Foo'); + $c->leftJoin('Book.Author'); + $c->with('Author'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $book = $c->findOne($con); + $count = $con->getQueryCount(); + $author = $book->getAuthor($con); + $this->assertNull($author, 'Related object is not hydrated if empty'); + $this->assertEquals($count, $con->getQueryCount()); + } - $con = Propel::getConnection(AuthorPeer::DATABASE_NAME); - $authors = AuthorQuery::create() - ->filterByLastName('Rowling') - ->joinBook('book') - ->with('book') - ->useQuery('book') - ->joinReview('review') - ->with('review') - ->endUse() - ->find($con); - $this->assertEquals(1, count($authors), 'with() does not duplicate the main object'); - $rowling = $authors[0]; - $count = $con->getQueryCount(); - $this->assertEquals($rowling->getFirstName(), 'J.K.', 'Main object is correctly hydrated'); - $books = $rowling->getBooks(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query '); - $this->assertEquals(1, count($books), 'Related objects are correctly hydrated'); - $book = $books[0]; - $this->assertEquals($book->getTitle(), 'Harry Potter and the Order of the Phoenix', 'Related object is correctly hydrated'); - $reviews = $book->getReviews(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query '); - $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); - } + public function testFindOneWithEmptyLeftJoinOneToMany() + { + // non-empty relation + $a1 = new Author(); + $a1->setFirstName('Foo'); + $a1->setLastName('Bar'); + $b1 = new Book(); + $b1->setTitle('Foo1'); + $b1->setIsbn('1245'); + $a1->addBook($b1); + $b2 = new Book(); + $b2->setTitle('Foo2'); + $b2->setIsbn('1245'); + $a1->addBook($b2); + $a1->save(); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $author = AuthorQuery::create() + ->filterByFirstName('Foo') + ->leftJoinWith('Author.Book') + ->findOne($con); + $count = $con->getQueryCount(); + $books = $author->getBooks(null, $con); + $this->assertEquals(2, $books->count()); + $this->assertEquals($count, $con->getQueryCount()); + // empty relation + $a2 = new Author(); + $a2->setFirstName('Bar'); + $a2->setLastName('Bar'); + $a2->save(); + $author = AuthorQuery::create() + ->filterByFirstName('Bar') + ->leftJoinWith('Author.Book') + ->findOne($con); + $count = $con->getQueryCount(); + $books = $author->getBooks(null, $con); + $this->assertEquals(0, $books->count()); + $this->assertEquals($count, $con->getQueryCount()); + } - public function testFindOneWithOneToManyThenManyToOneUsingAlias() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Author'); - $c->add(AuthorPeer::LAST_NAME, 'Rowling'); - $c->leftJoinWith('Author.Book b'); - $c->leftJoinWith('b.Review r'); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $authors = $c->find($con); - $this->assertEquals(1, count($authors), 'with() does not duplicate the main object'); - $rowling = $authors[0]; - $count = $con->getQueryCount(); - $this->assertEquals($rowling->getFirstName(), 'J.K.', 'Main object is correctly hydrated'); - $books = $rowling->getBooks(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query '); - $this->assertEquals(1, count($books), 'Related objects are correctly hydrated'); - $book = $books[0]; - $this->assertEquals($book->getTitle(), 'Harry Potter and the Order of the Phoenix', 'Related object is correctly hydrated'); - $reviews = $book->getReviews(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query '); - $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); - } - - public function testFindOneWithColumn() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->filterByTitle('The Tin Drum'); - $c->join('Book.Author'); - $c->withColumn('Author.FirstName', 'AuthorName'); - $c->withColumn('Author.LastName', 'AuthorName2'); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $book = $c->findOne($con); - $this->assertTrue($book instanceof Book, 'withColumn() do not change the resulting model class'); - $this->assertEquals('The Tin Drum', $book->getTitle()); - $this->assertEquals('Gunter', $book->getVirtualColumn('AuthorName'), 'PropelObjectFormatter adds withColumns as virtual columns'); - $this->assertEquals('Grass', $book->getVirtualColumn('AuthorName2'), 'PropelObjectFormatter correctly hydrates all virtual columns'); - $this->assertEquals('Gunter', $book->getAuthorName(), 'PropelObjectFormatter adds withColumns as virtual columns'); - } + public function testFindOneWithRelationName() + { + BookstoreDataPopulator::populate(); + BookstoreEmployeePeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'BookstoreEmployee'); + $c->join('BookstoreEmployee.Supervisor s'); + $c->with('s'); + $c->where('s.Name = ?', 'John'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $emp = $c->findOne($con); + $count = $con->getQueryCount(); + $this->assertEquals($emp->getName(), 'Pieter', 'Main object is correctly hydrated'); + $sup = $emp->getSupervisor(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); + $this->assertEquals($sup->getName(), 'John', 'Related object is correctly hydrated'); + } - public function testFindOneWithClassAndColumn() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->filterByTitle('The Tin Drum'); - $c->join('Book.Author'); - $c->withColumn('Author.FirstName', 'AuthorName'); - $c->withColumn('Author.LastName', 'AuthorName2'); - $c->with('Author'); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $book = $c->findOne($con); - $this->assertTrue($book instanceof Book, 'withColumn() do not change the resulting model class'); - $this->assertEquals('The Tin Drum', $book->getTitle()); - $this->assertTrue($book->getAuthor() instanceof Author, 'PropelObjectFormatter correctly hydrates with class'); - $this->assertEquals('Gunter', $book->getAuthor()->getFirstName(), 'PropelObjectFormatter correctly hydrates with class'); - $this->assertEquals('Gunter', $book->getVirtualColumn('AuthorName'), 'PropelObjectFormatter adds withColumns as virtual columns'); - $this->assertEquals('Grass', $book->getVirtualColumn('AuthorName2'), 'PropelObjectFormatter correctly hydrates all virtual columns'); - } + public function testFindOneWithDuplicateRelation() + { + EssayPeer::doDeleteAll(); + $auth1 = new Author(); + $auth1->setFirstName('John'); + $auth1->setLastName('Doe'); + $auth1->save(); + $auth2 = new Author(); + $auth2->setFirstName('Jack'); + $auth2->setLastName('Sparrow'); + $auth2->save(); + $essay = new Essay(); + $essay->setTitle('Foo'); + $essay->setFirstAuthor($auth1->getId()); + $essay->setSecondAuthor($auth2->getId()); + $essay->save(); + AuthorPeer::clearInstancePool(); + EssayPeer::clearInstancePool(); - public function testFindPkWithOneToMany() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $book = BookQuery::create() - ->findOneByTitle('Harry Potter and the Order of the Phoenix', $con); - $pk = $book->getPrimaryKey(); - BookPeer::clearInstancePool(); - $book = BookQuery::create() - ->joinWith('Review') - ->findPk($pk, $con); - $count = $con->getQueryCount(); - $reviews = $book->getReviews(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query '); - $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); - } + $c = new ModelCriteria('bookstore', 'Essay'); + $c->join('Essay.AuthorRelatedByFirstAuthor'); + $c->with('AuthorRelatedByFirstAuthor'); + $c->where('Essay.Title = ?', 'Foo'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $essay = $c->findOne($con); + $count = $con->getQueryCount(); + $this->assertEquals($essay->getTitle(), 'Foo', 'Main object is correctly hydrated'); + $firstAuthor = $essay->getAuthorRelatedByFirstAuthor(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); + $this->assertEquals($firstAuthor->getFirstName(), 'John', 'Related object is correctly hydrated'); + $secondAuthor = $essay->getAuthorRelatedBySecondAuthor(); + $this->assertEquals($count + 1, $con->getQueryCount(), 'with() does not hydrate objects not in with'); + } + + public function testFindOneWithEmptyDuplicateRelation() + { + EssayPeer::doDeleteAll(); + + $author = new Author(); + $author->setFirstName('Piet'); + $author->setLastName('Sous'); + $author->save(); + + AuthorPeer::clearInstancePool(); + EssayPeer::clearInstancePool(); + + $query = AuthorQuery::create() + ->useEssayRelatedByFirstAuthorQuery() + ->orderByTitle() + ->endUse() + ->with('EssayRelatedByFirstAuthor'); + + $author = $query->findOne(); // should not throw a notice + $this->assertTrue(true); + } + + public function testFindOneWithDistantClass() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + Propel::enableInstancePooling(); + $c = new ModelCriteria('bookstore', 'Review'); + $c->where('Review.Recommended = ?', true); + $c->join('Review.Book'); + $c->with('Book'); + $c->join('Book.Author'); + $c->with('Author'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $review = $c->findOne($con); + $count = $con->getQueryCount(); + $this->assertEquals($review->getReviewedBy(), 'Washington Post', 'Main object is correctly hydrated'); + $book = $review->getBook(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); + $this->assertEquals('Harry Potter and the Order of the Phoenix', $book->getTitle(), 'Related object is correctly hydrated'); + $author = $book->getAuthor(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); + $this->assertEquals('J.K.', $author->getFirstName(), 'Related object is correctly hydrated'); + } + + public function testFindOneWithDistantClassRenamedRelation() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + Propel::enableInstancePooling(); + $c = new ModelCriteria('bookstore', 'BookSummary'); + $c->joinWith('BookSummary.SummarizedBook'); + $c->joinWith('SummarizedBook.Author'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $summary = $c->findOne($con); + $count = $con->getQueryCount(); + $this->assertEquals('Harry Potter does some amazing magic!', $summary->getSummary(), 'Main object is correctly hydrated'); + $book = $summary->getSummarizedBook(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); + $this->assertEquals('Harry Potter and the Order of the Phoenix', $book->getTitle(), 'Related object is correctly hydrated'); + $author = $book->getAuthor(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); + $this->assertEquals('J.K.', $author->getFirstName(), 'Related object is correctly hydrated'); + } + + /** + * @expectedException PropelException + */ + public function testFindOneWithOneToManyAndLimit() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->add(BookPeer::ISBN, '043935806X'); + $c->leftJoin('Book.Review'); + $c->with('Review'); + $c->limit(5); + $books = $c->find(); + } + + public function testFindOneWithOneToMany() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->add(BookPeer::ISBN, '043935806X'); + $c->leftJoin('Book.Review'); + $c->with('Review'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $books = $c->find($con); + $this->assertEquals(1, count($books), 'with() does not duplicate the main object'); + $book = $books[0]; + $count = $con->getQueryCount(); + $this->assertEquals($book->getTitle(), 'Harry Potter and the Order of the Phoenix', 'Main object is correctly hydrated'); + $reviews = $book->getReviews(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query '); + $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); + try { + $book->save(); + } catch (Exception $e) { + $this->fail('with() does not force objects to be new'); + } + } + + public function testFindOneWithOneToManyCustomOrder() + { + $author1 = new Author(); + $author1->setFirstName('AA'); + $author1->setLastName('AA'); + $author2 = new Author(); + $author2->setFirstName('BB'); + $author2->setLastName('BB'); + $book1 = new Book(); + $book1->setTitle('Aaa'); + $book1->setIsbn('1245'); + $book1->setAuthor($author1); + $book1->save(); + $book2 = new Book(); + $book2->setTitle('Bbb'); + $book2->setIsbn('124'); + $book2->setAuthor($author2); + $book2->save(); + $book3 = new Book(); + $book3->setTitle('Ccc'); + $book3->setIsbn('AZ2R4'); + $book3->setAuthor($author1); + $book3->save(); + $authors = AuthorQuery::create() + ->leftJoin('Author.Book') + ->orderBy('Book.Title') + ->with('Book') + ->find(); + $this->assertEquals(2, count($authors), 'with() used on a many-to-many doesn\'t change the main object count'); + } + + public function testFindOneWithOneToManyThenManyToOne() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Author'); + $c->add(AuthorPeer::LAST_NAME, 'Rowling'); + $c->leftJoinWith('Author.Book'); + $c->leftJoinWith('Book.Review'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $authors = $c->find($con); + $this->assertEquals(1, count($authors), 'with() does not duplicate the main object'); + $rowling = $authors[0]; + $count = $con->getQueryCount(); + $this->assertEquals($rowling->getFirstName(), 'J.K.', 'Main object is correctly hydrated'); + $books = $rowling->getBooks(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query '); + $this->assertEquals(1, count($books), 'Related objects are correctly hydrated'); + $book = $books[0]; + $this->assertEquals($book->getTitle(), 'Harry Potter and the Order of the Phoenix', 'Related object is correctly hydrated'); + $reviews = $book->getReviews(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query '); + $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); + } + + public function testFindWithLeftJoinWithOneToManyAndNullObject() + { + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $freud = new Author(); + $freud->setFirstName("Sigmund"); + $freud->setLastName("Freud"); + $freud->save($this->con); + $c = new ModelCriteria('bookstore', 'Author'); + $c->add(AuthorPeer::LAST_NAME, 'Freud'); + $c->leftJoinWith('Author.Book'); + $c->leftJoinWith('Book.Review'); + // should not raise a notice + $authors = $c->find($this->con); + $this->assertTrue(true); + } + + public function testFindWithLeftJoinWithManyToOneAndNullObject() + { + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $review = new Review(); + $review->setReviewedBy('Toto'); + $review->setRecommended('0'); + $review->save($this->con); + $c = new ModelCriteria('bookstore', 'Review'); + $c->leftJoinWith('Review.Book'); + $c->leftJoinWith('Book.Author'); + // should not raise a notice + $reviews = $c->find($this->con); + $this->assertTrue(true); + } + + public function testFindOneWithOneToManyThenManyToOneUsingJoinRelated() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + + $con = Propel::getConnection(AuthorPeer::DATABASE_NAME); + $authors = AuthorQuery::create() + ->filterByLastName('Rowling') + ->joinBook('book') + ->with('book') + ->useQuery('book') + ->joinReview('review') + ->with('review') + ->endUse() + ->find($con); + $this->assertEquals(1, count($authors), 'with() does not duplicate the main object'); + $rowling = $authors[0]; + $count = $con->getQueryCount(); + $this->assertEquals($rowling->getFirstName(), 'J.K.', 'Main object is correctly hydrated'); + $books = $rowling->getBooks(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query '); + $this->assertEquals(1, count($books), 'Related objects are correctly hydrated'); + $book = $books[0]; + $this->assertEquals($book->getTitle(), 'Harry Potter and the Order of the Phoenix', 'Related object is correctly hydrated'); + $reviews = $book->getReviews(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query '); + $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); + } + + public function testFindOneWithOneToManyThenManyToOneUsingAlias() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Author'); + $c->add(AuthorPeer::LAST_NAME, 'Rowling'); + $c->leftJoinWith('Author.Book b'); + $c->leftJoinWith('b.Review r'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $authors = $c->find($con); + $this->assertEquals(1, count($authors), 'with() does not duplicate the main object'); + $rowling = $authors[0]; + $count = $con->getQueryCount(); + $this->assertEquals($rowling->getFirstName(), 'J.K.', 'Main object is correctly hydrated'); + $books = $rowling->getBooks(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query '); + $this->assertEquals(1, count($books), 'Related objects are correctly hydrated'); + $book = $books[0]; + $this->assertEquals($book->getTitle(), 'Harry Potter and the Order of the Phoenix', 'Related object is correctly hydrated'); + $reviews = $book->getReviews(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query '); + $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); + } + + public function testFindOneWithColumn() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->filterByTitle('The Tin Drum'); + $c->join('Book.Author'); + $c->withColumn('Author.FirstName', 'AuthorName'); + $c->withColumn('Author.LastName', 'AuthorName2'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $book = $c->findOne($con); + $this->assertTrue($book instanceof Book, 'withColumn() do not change the resulting model class'); + $this->assertEquals('The Tin Drum', $book->getTitle()); + $this->assertEquals('Gunter', $book->getVirtualColumn('AuthorName'), 'PropelObjectFormatter adds withColumns as virtual columns'); + $this->assertEquals('Grass', $book->getVirtualColumn('AuthorName2'), 'PropelObjectFormatter correctly hydrates all virtual columns'); + $this->assertEquals('Gunter', $book->getAuthorName(), 'PropelObjectFormatter adds withColumns as virtual columns'); + } + + public function testFindOneWithColumnAndAlias() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->filterByTitle('Harry Potter and the Order of the Phoenix'); + $c->joinWith('Book.BookSummary'); + $c->joinWith('Book.Review'); + $c->join('Book.Author'); + $c->withColumn('Author.FirstName', 'AuthorName'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $book = $c->findOne($con); + $count = $con->getQueryCount(); + $reviews = $book->getReviews(); + + //Washington Post + $this->assertTrue($book instanceof Book, 'withColumn() do not change the resulting model class'); + $this->assertEquals(1, count($reviews), 'Related objects are correctly hydrated'); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query '); + $this->assertEquals('J.K.', $book->getVirtualColumn('AuthorName'), 'PropelObjectFormatter adds withColumns as virtual columns'); + } + + public function testFindOneWithClassAndColumn() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->filterByTitle('The Tin Drum'); + $c->join('Book.Author'); + $c->withColumn('Author.FirstName', 'AuthorName'); + $c->withColumn('Author.LastName', 'AuthorName2'); + $c->with('Author'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $book = $c->findOne($con); + $this->assertTrue($book instanceof Book, 'withColumn() do not change the resulting model class'); + $this->assertEquals('The Tin Drum', $book->getTitle()); + $this->assertTrue($book->getAuthor() instanceof Author, 'PropelObjectFormatter correctly hydrates with class'); + $this->assertEquals('Gunter', $book->getAuthor()->getFirstName(), 'PropelObjectFormatter correctly hydrates with class'); + $this->assertEquals('Gunter', $book->getVirtualColumn('AuthorName'), 'PropelObjectFormatter adds withColumns as virtual columns'); + $this->assertEquals('Grass', $book->getVirtualColumn('AuthorName2'), 'PropelObjectFormatter correctly hydrates all virtual columns'); + } + + public function testFindPkWithOneToMany() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $book = BookQuery::create() + ->findOneByTitle('Harry Potter and the Order of the Phoenix', $con); + $pk = $book->getPrimaryKey(); + BookPeer::clearInstancePool(); + $book = BookQuery::create() + ->joinWith('Review') + ->findPk($pk, $con); + $count = $con->getQueryCount(); + $reviews = $book->getReviews(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query '); + $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated'); + } + + public function testFindOneWithLeftJoinWithOneToManyAndNullObjectsAndWithAdditionalJoins() + { + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + BookOpinionPeer::clearInstancePool(); + BookReaderPeer::clearInstancePool(); + + $freud = new Author(); + $freud->setFirstName("Sigmund"); + $freud->setLastName("Freud"); + $freud->save($this->con); + + $publisher = new Publisher(); + $publisher->setName('Psycho Books'); + $publisher->save(); + + $book = new Book(); + $book->setAuthor($freud); + $book->setTitle('Weirdness'); + $book->setIsbn('abc123456'); + $book->setPrice('14.99'); + $book->setPublisher($publisher); + $book->save(); + + $query = BookQuery::create() + ->filterByTitle('Weirdness') + ->innerJoinAuthor() + ->useBookOpinionQuery(null, Criteria::LEFT_JOIN) + ->leftJoinBookReader() + ->endUse() + ->with('Author') + ->with('BookOpinion') + ->with('BookReader'); + + $books = $query->findOne($this->con); + $this->assertEquals(0, count($books->getBookOpinions())); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelOnDemandFormatterTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelOnDemandFormatterTest.php index a4c29bb38..e6c3c3465 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelOnDemandFormatterTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelOnDemandFormatterTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Test class for PropelOnDemandFormatter. @@ -20,132 +20,155 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; class PropelOnDemandFormatterTest extends BookstoreEmptyTestBase { - public function testFormatNoCriteria() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); + public function testFormatNoCriteria() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $stmt = $con->query('SELECT * FROM book'); - $formatter = new PropelOnDemandFormatter(); - try { - $books = $formatter->format($stmt); - $this->fail('PropelOnDemandFormatter::format() trows an exception when called with no valid criteria'); - } catch (PropelException $e) { - $this->assertTrue(true,'PropelOnDemandFormatter::format() trows an exception when called with no valid criteria'); - } - } - - public function testFormatManyResults() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - BookstoreDataPopulator::populate($con); + $stmt = $con->query('SELECT * FROM book'); + $formatter = new PropelOnDemandFormatter(); + try { + $books = $formatter->format($stmt); + $this->fail('PropelOnDemandFormatter::format() trows an exception when called with no valid criteria'); + } catch (PropelException $e) { + $this->assertTrue(true,'PropelOnDemandFormatter::format() trows an exception when called with no valid criteria'); + } + } - $stmt = $con->query('SELECT * FROM book'); - $formatter = new PropelOnDemandFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $books = $formatter->format($stmt); - - $this->assertTrue($books instanceof PropelOnDemandCollection, 'PropelOnDemandFormatter::format() returns a PropelOnDemandCollection'); - $this->assertEquals(4, count($books), 'PropelOnDemandFormatter::format() returns a collection that counts as many rows as the results in the query'); - foreach ($books as $book) { - $this->assertTrue($book instanceof Book, 'PropelOnDemandFormatter::format() returns an traversable collection of Model objects'); - } - } + public function testFormatManyResults() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + BookstoreDataPopulator::populate($con); - /** - * @expectedException PropelException - */ - public function testFormatManyResultsIteratedTwice() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - BookstoreDataPopulator::populate($con); + $stmt = $con->query('SELECT * FROM book'); + $formatter = new PropelOnDemandFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $books = $formatter->format($stmt); - $stmt = $con->query('SELECT * FROM book'); - $formatter = new PropelOnDemandFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $books = $formatter->format($stmt); - - foreach ($books as $book) { - // do nothing - } - foreach ($books as $book) { - // this should throw a PropelException since we're iterating a second time over a stream - } - } + $this->assertTrue($books instanceof PropelOnDemandCollection, 'PropelOnDemandFormatter::format() returns a PropelOnDemandCollection'); + $this->assertEquals(4, count($books), 'PropelOnDemandFormatter::format() returns a collection that counts as many rows as the results in the query'); + foreach ($books as $book) { + $this->assertTrue($book instanceof Book, 'PropelOnDemandFormatter::format() returns an traversable collection of Model objects'); + } + } - public function testFormatALotOfResults() - { - $nbBooks = 50; - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - Propel::disableInstancePooling(); - $book = new Book(); - for ($i=0; $i < $nbBooks; $i++) { - $book->clear(); - $book->setTitle('BookTest' . $i); - $book->save($con); - } + /** + * @expectedException PropelException + */ + public function testFormatManyResultsIteratedTwice() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + BookstoreDataPopulator::populate($con); - $stmt = $con->query('SELECT * FROM book'); - $formatter = new PropelOnDemandFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $books = $formatter->format($stmt); - - $this->assertTrue($books instanceof PropelOnDemandCollection, 'PropelOnDemandFormatter::format() returns a PropelOnDemandCollection'); - $this->assertEquals($nbBooks, count($books), 'PropelOnDemandFormatter::format() returns a collection that counts as many rows as the results in the query'); - $i = 0; - foreach ($books as $book) { - $this->assertTrue($book instanceof Book, 'PropelOnDemandFormatter::format() returns a collection of Model objects'); - $this->assertEquals('BookTest' . $i, $book->getTitle(), 'PropelOnDemandFormatter::format() returns the model objects matching the query'); - $i++; - } - Propel::enableInstancePooling(); - } + $stmt = $con->query('SELECT * FROM book'); + $formatter = new PropelOnDemandFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $books = $formatter->format($stmt); + + foreach ($books as $book) { + // do nothing + } + foreach ($books as $book) { + // this should throw a PropelException since we're iterating a second time over a stream + } + } + + public function testFormatALotOfResults() + { + $nbBooks = 50; + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + Propel::disableInstancePooling(); + $book = new Book(); + for ($i=0; $i < $nbBooks; $i++) { + $book->clear(); + $book->setTitle('BookTest' . $i); + $book->setIsbn('124' . $i); + + $book->save($con); + } + + $stmt = $con->query('SELECT * FROM book'); + $formatter = new PropelOnDemandFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $books = $formatter->format($stmt); + + $this->assertTrue($books instanceof PropelOnDemandCollection, 'PropelOnDemandFormatter::format() returns a PropelOnDemandCollection'); + $this->assertEquals($nbBooks, count($books), 'PropelOnDemandFormatter::format() returns a collection that counts as many rows as the results in the query'); + $i = 0; + foreach ($books as $book) { + $this->assertTrue($book instanceof Book, 'PropelOnDemandFormatter::format() returns a collection of Model objects'); + $this->assertEquals('BookTest' . $i, $book->getTitle(), 'PropelOnDemandFormatter::format() returns the model objects matching the query'); + $i++; + } + Propel::enableInstancePooling(); + } - public function testFormatOneResult() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - BookstoreDataPopulator::populate($con); - - $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "Quicksilver"'); - $formatter = new PropelOnDemandFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $books = $formatter->format($stmt); - - $this->assertTrue($books instanceof PropelOnDemandCollection, 'PropelOnDemandFormatter::format() returns a PropelOnDemandCollection'); - $this->assertEquals(1, count($books), 'PropelOnDemandFormatter::format() returns a collection that counts as many rows as the results in the query'); - foreach ($books as $book) { - $this->assertTrue($book instanceof Book, 'PropelOnDemandFormatter::format() returns a collection of Model objects'); - $this->assertEquals('Quicksilver', $book->getTitle(), 'PropelOnDemandFormatter::format() returns the model objects matching the query'); - } - } + public function testFormatOneResult() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + BookstoreDataPopulator::populate($con); - public function testFormatNoResult() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - - $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "foo"'); - $formatter = new PropelOnDemandFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $books = $formatter->format($stmt); - - $this->assertTrue($books instanceof PropelOnDemandCollection, 'PropelOnDemandFormatter::format() returns a PropelCollection'); - $this->assertEquals(0, count($books), 'PropelOnDemandFormatter::format() returns an empty collection when no record match the query'); - foreach ($books as $book) { - $this->fail('PropelOnDemandFormatter returns an empty iterator when no record match the query'); - } - } - - public function testFormatOneManyResults() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - BookstoreDataPopulator::populate($con); + $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "Quicksilver"'); + $formatter = new PropelOnDemandFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $books = $formatter->format($stmt); - $stmt = $con->query('SELECT * FROM book'); - $formatter = new PropelOnDemandFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $book = $formatter->formatOne($stmt); - - $this->assertTrue($book instanceof Book, 'PropelOnDemandFormatter::formatOne() returns a model object'); - } - + $this->assertTrue($books instanceof PropelOnDemandCollection, 'PropelOnDemandFormatter::format() returns a PropelOnDemandCollection'); + $this->assertEquals(1, count($books), 'PropelOnDemandFormatter::format() returns a collection that counts as many rows as the results in the query'); + foreach ($books as $book) { + $this->assertTrue($book instanceof Book, 'PropelOnDemandFormatter::format() returns a collection of Model objects'); + $this->assertEquals('Quicksilver', $book->getTitle(), 'PropelOnDemandFormatter::format() returns the model objects matching the query'); + } + } + + public function testFormatNoResult() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "foo"'); + $formatter = new PropelOnDemandFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $books = $formatter->format($stmt); + + $this->assertTrue($books instanceof PropelOnDemandCollection, 'PropelOnDemandFormatter::format() returns a PropelCollection'); + $this->assertEquals(0, count($books), 'PropelOnDemandFormatter::format() returns an empty collection when no record match the query'); + foreach ($books as $book) { + $this->fail('PropelOnDemandFormatter returns an empty iterator when no record match the query'); + } + } + + public function testFormatOneManyResults() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + BookstoreDataPopulator::populate($con); + + $stmt = $con->query('SELECT * FROM book'); + $formatter = new PropelOnDemandFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $book = $formatter->formatOne($stmt); + + $this->assertTrue($book instanceof Book, 'PropelOnDemandFormatter::formatOne() returns a model object'); + } + + public function testFormatSingleTableInheritanceManyResults() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + BookstoreDataPopulator::populate($con); + + $stmt = $con->query('SELECT * FROM bookstore_employee'); + $formatter = new PropelOnDemandFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'BookstoreEmployee')); + + $employees = $formatter->format($stmt); + + foreach ($employees as $employee) { + $row = array(); + $row[1] = $employee->getClassKey(); + + $omClass = BookstoreEmployeePeer::getOMClass($row, 0, false); + $actualClass = get_class($employee); + + $this->assertEquals($omClass, $actualClass, 'PropelOnDemandFormatter::format() should handle single table inheritance'); + } + } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelOnDemandFormatterWithTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelOnDemandFormatterWithTest.php index 264d7b25e..e5af48ca2 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelOnDemandFormatterWithTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelOnDemandFormatterWithTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Test class for PropelOnDemandFormatter when Criteria uses with(). @@ -19,259 +19,303 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; */ class PropelOnDemandFormatterWithTest extends BookstoreEmptyTestBase { - protected function assertCorrectHydration1($c, $msg) - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c->limit(1); - $books = $c->find($con); - foreach ($books as $book) { - break; - } - $count = $con->getQueryCount(); - $this->assertEquals($book->getTitle(), 'Don Juan', 'Main object is correctly hydrated ' . $msg); - $author = $book->getAuthor(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query ' . $msg); - $this->assertEquals($author->getLastName(), 'Byron', 'Related object is correctly hydrated ' . $msg); - $publisher = $book->getPublisher(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query ' . $msg); - $this->assertEquals($publisher->getName(), 'Penguin', 'Related object is correctly hydrated ' . $msg); - } - - public function testFindOneWith() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); - $c->orderBy('Book.Title'); - $c->join('Book.Author'); - $c->with('Author'); - $c->join('Book.Publisher'); - $c->with('Publisher'); - $this->assertCorrectHydration1($c, 'without instance pool'); - } + protected function assertCorrectHydration1($c, $msg) + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c->limit(1); + $books = $c->find($con); + foreach ($books as $book) { + break; + } + $count = $con->getQueryCount(); + $this->assertEquals($book->getTitle(), 'Don Juan', 'Main object is correctly hydrated ' . $msg); + $author = $book->getAuthor(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query ' . $msg); + $this->assertEquals($author->getLastName(), 'Byron', 'Related object is correctly hydrated ' . $msg); + $publisher = $book->getPublisher(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query ' . $msg); + $this->assertEquals($publisher->getName(), 'Penguin', 'Related object is correctly hydrated ' . $msg); + } - public function testFindOneWithAlias() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); - $c->orderBy('Book.Title'); - $c->join('Book.Author a'); - $c->with('a'); - $c->join('Book.Publisher p'); - $c->with('p'); - $this->assertCorrectHydration1($c, 'with alias'); - } + public function testFindOneWith() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); + $c->orderBy('Book.Title'); + $c->join('Book.Author'); + $c->with('Author'); + $c->join('Book.Publisher'); + $c->with('Publisher'); + $this->assertCorrectHydration1($c, 'without instance pool'); + } - public function testFindOneWithMainAlias() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); - $c->setModelAlias('b', true); - $c->orderBy('b.Title'); - $c->join('b.Author a'); - $c->with('a'); - $c->join('b.Publisher p'); - $c->with('p'); - $this->assertCorrectHydration1($c, 'with main alias'); - } - - public function testFindOneWithUsingInstancePool() - { - BookstoreDataPopulator::populate(); - // instance pool contains all objects by default, since they were just populated - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); - $c->orderBy('Book.Title'); - $c->join('Book.Author'); - $c->with('Author'); - $c->join('Book.Publisher'); - $c->with('Publisher'); - $this->assertCorrectHydration1($c, 'with instance pool'); - } + public function testFindOneWithAlias() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); + $c->orderBy('Book.Title'); + $c->join('Book.Author a'); + $c->with('a'); + $c->join('Book.Publisher p'); + $c->with('p'); + $this->assertCorrectHydration1($c, 'with alias'); + } - public function testFindOneWithEmptyLeftJoin() - { - // save a book with no author - $b = new Book(); - $b->setTitle('Foo'); - $b->save(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); - $c->where('Book.Title = ?', 'Foo'); - $c->leftJoin('Book.Author'); - $c->with('Author'); - $c->limit(1); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $books = $c->find($con); - foreach ($books as $book) { - break; - } - $count = $con->getQueryCount(); - $author = $book->getAuthor(); - $this->assertNull($author, 'Related object is not hydrated if empty'); - } + public function testFindOneWithMainAlias() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); + $c->setModelAlias('b', true); + $c->orderBy('b.Title'); + $c->join('b.Author a'); + $c->with('a'); + $c->join('b.Publisher p'); + $c->with('p'); + $this->assertCorrectHydration1($c, 'with main alias'); + } - public function testFindOneWithRelationName() - { - BookstoreDataPopulator::populate(); - BookstoreEmployeePeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'BookstoreEmployee'); - $c->join('BookstoreEmployee.Supervisor s'); - $c->with('s'); - $c->where('s.Name = ?', 'John'); - $c->limit(1); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $emps = $c->find($con); - foreach ($emps as $emp) { - break; - } - $count = $con->getQueryCount(); - $this->assertEquals($emp->getName(), 'Pieter', 'Main object is correctly hydrated'); - $sup = $emp->getSupervisor(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); - $this->assertEquals($sup->getName(), 'John', 'Related object is correctly hydrated'); - } + public function testFindOneWithUsingInstancePool() + { + BookstoreDataPopulator::populate(); + // instance pool contains all objects by default, since they were just populated + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); + $c->orderBy('Book.Title'); + $c->join('Book.Author'); + $c->with('Author'); + $c->join('Book.Publisher'); + $c->with('Publisher'); + $this->assertCorrectHydration1($c, 'with instance pool'); + } - public function testFindOneWithDuplicateRelation() - { - EssayPeer::doDeleteAll(); - $auth1 = new Author(); - $auth1->setFirstName('John'); - $auth1->save(); - $auth2 = new Author(); - $auth2->setFirstName('Jack'); - $auth2->save(); - $essay = new Essay(); - $essay->setTitle('Foo'); - $essay->setFirstAuthor($auth1->getId()); - $essay->setSecondAuthor($auth2->getId()); - $essay->save(); - AuthorPeer::clearInstancePool(); - EssayPeer::clearInstancePool(); - - $c = new ModelCriteria('bookstore', 'Essay'); - $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); - $c->join('Essay.AuthorRelatedByFirstAuthor'); - $c->with('AuthorRelatedByFirstAuthor'); - $c->where('Essay.Title = ?', 'Foo'); - $c->limit(1); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $essays = $c->find($con); - foreach ($essays as $essay) { - break; - } - $count = $con->getQueryCount(); - $this->assertEquals($essay->getTitle(), 'Foo', 'Main object is correctly hydrated'); - $firstAuthor = $essay->getAuthorRelatedByFirstAuthor(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); - $this->assertEquals($firstAuthor->getFirstName(), 'John', 'Related object is correctly hydrated'); - $secondAuthor = $essay->getAuthorRelatedBySecondAuthor(); - $this->assertEquals($count + 1, $con->getQueryCount(), 'with() does not hydrate objects not in with'); - } - - public function testFindOneWithDistantClass() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Review'); - $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); - $c->where('Review.Recommended = ?', true); - $c->join('Review.Book'); - $c->with('Book'); - $c->join('Book.Author'); - $c->with('Author'); - $c->limit(1); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $reviews = $c->find($con); - foreach ($reviews as $review) { - break; - } - $count = $con->getQueryCount(); - $this->assertEquals($review->getReviewedBy(), 'Washington Post', 'Main object is correctly hydrated'); - $book = $review->getBook(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); - $this->assertEquals('Harry Potter and the Order of the Phoenix', $book->getTitle(), 'Related object is correctly hydrated'); - $author = $book->getAuthor(); - $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); - $this->assertEquals('J.K.', $author->getFirstName(), 'Related object is correctly hydrated'); - } + public function testFindOneWithEmptyLeftJoin() + { + // save a book with no author + $b = new Book(); + $b->setTitle('Foo'); + $b->setIsbn('124'); + $b->save(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); + $c->where('Book.Title = ?', 'Foo'); + $c->leftJoin('Book.Author'); + $c->with('Author'); + $c->limit(1); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $books = $c->find($con); + foreach ($books as $book) { + break; + } + $count = $con->getQueryCount(); + $author = $book->getAuthor(); + $this->assertNull($author, 'Related object is not hydrated if empty'); + } - /** - * @expectedException PropelException - */ - public function testFindOneWithOneToMany() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); - $c->add(BookPeer::ISBN, '043935806X'); - $c->leftJoin('Book.Review'); - $c->with('Review'); - $books = $c->find(); - } + public function testFindOneWithRelationName() + { + BookstoreDataPopulator::populate(); + BookstoreEmployeePeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'BookstoreEmployee'); + $c->join('BookstoreEmployee.Supervisor s'); + $c->with('s'); + $c->where('s.Name = ?', 'John'); + $c->limit(1); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $emps = $c->find($con); + foreach ($emps as $emp) { + break; + } + $count = $con->getQueryCount(); + $this->assertEquals($emp->getName(), 'Pieter', 'Main object is correctly hydrated'); + $sup = $emp->getSupervisor(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); + $this->assertEquals($sup->getName(), 'John', 'Related object is correctly hydrated'); + } - public function testFindOneWithColumn() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); - $c->filterByTitle('The Tin Drum'); - $c->join('Book.Author'); - $c->withColumn('Author.FirstName', 'AuthorName'); - $c->withColumn('Author.LastName', 'AuthorName2'); - $c->limit(1); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $books = $c->find($con); - foreach ($books as $book) { - break; - } - $this->assertTrue($book instanceof Book, 'withColumn() do not change the resulting model class'); - $this->assertEquals('The Tin Drum', $book->getTitle()); - $this->assertEquals('Gunter', $book->getVirtualColumn('AuthorName'), 'PropelObjectFormatter adds withColumns as virtual columns'); - $this->assertEquals('Grass', $book->getVirtualColumn('AuthorName2'), 'PropelObjectFormatter correctly hydrates all virtual columns'); - $this->assertEquals('Gunter', $book->getAuthorName(), 'PropelObjectFormatter adds withColumns as virtual columns'); - } + public function testFindOneWithDuplicateRelation() + { + EssayPeer::doDeleteAll(); + $auth1 = new Author(); + $auth1->setFirstName('John'); + $auth1->setLastName('Doe'); + $auth1->save(); + $auth2 = new Author(); + $auth2->setFirstName('Jack'); + $auth2->setLastName('Sparrow'); + $auth2->save(); + $essay = new Essay(); + $essay->setTitle('Foo'); + $essay->setFirstAuthor($auth1->getId()); + $essay->setSecondAuthor($auth2->getId()); + $essay->save(); + AuthorPeer::clearInstancePool(); + EssayPeer::clearInstancePool(); - public function testFindOneWithClassAndColumn() - { - BookstoreDataPopulator::populate(); - BookPeer::clearInstancePool(); - AuthorPeer::clearInstancePool(); - ReviewPeer::clearInstancePool(); - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); - $c->filterByTitle('The Tin Drum'); - $c->join('Book.Author'); - $c->withColumn('Author.FirstName', 'AuthorName'); - $c->withColumn('Author.LastName', 'AuthorName2'); - $c->with('Author'); - $c->limit(1); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $books = $c->find($con); - foreach ($books as $book) { - break; - } - $this->assertTrue($book instanceof Book, 'withColumn() do not change the resulting model class'); - $this->assertEquals('The Tin Drum', $book->getTitle()); - $this->assertTrue($book->getAuthor() instanceof Author, 'PropelObjectFormatter correctly hydrates with class'); - $this->assertEquals('Gunter', $book->getAuthor()->getFirstName(), 'PropelObjectFormatter correctly hydrates with class'); - $this->assertEquals('Gunter', $book->getVirtualColumn('AuthorName'), 'PropelObjectFormatter adds withColumns as virtual columns'); - $this->assertEquals('Grass', $book->getVirtualColumn('AuthorName2'), 'PropelObjectFormatter correctly hydrates all virtual columns'); - } + $c = new ModelCriteria('bookstore', 'Essay'); + $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); + $c->join('Essay.AuthorRelatedByFirstAuthor'); + $c->with('AuthorRelatedByFirstAuthor'); + $c->where('Essay.Title = ?', 'Foo'); + $c->limit(1); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $essays = $c->find($con); + foreach ($essays as $essay) { + break; + } + $count = $con->getQueryCount(); + $this->assertEquals($essay->getTitle(), 'Foo', 'Main object is correctly hydrated'); + $firstAuthor = $essay->getAuthorRelatedByFirstAuthor(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); + $this->assertEquals($firstAuthor->getFirstName(), 'John', 'Related object is correctly hydrated'); + $secondAuthor = $essay->getAuthorRelatedBySecondAuthor(); + $this->assertEquals($count + 1, $con->getQueryCount(), 'with() does not hydrate objects not in with'); + } + + public function testFindOneWithDistantClass() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Review'); + $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); + $c->where('Review.Recommended = ?', true); + $c->join('Review.Book'); + $c->with('Book'); + $c->join('Book.Author'); + $c->with('Author'); + $c->limit(1); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $reviews = $c->find($con); + foreach ($reviews as $review) { + break; + } + $count = $con->getQueryCount(); + $this->assertEquals($review->getReviewedBy(), 'Washington Post', 'Main object is correctly hydrated'); + $book = $review->getBook(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); + $this->assertEquals('Harry Potter and the Order of the Phoenix', $book->getTitle(), 'Related object is correctly hydrated'); + $author = $book->getAuthor(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); + $this->assertEquals('J.K.', $author->getFirstName(), 'Related object is correctly hydrated'); + } + + public function testFindOneWithDistantClassRenamedRelation() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + Propel::enableInstancePooling(); + $c = new ModelCriteria('bookstore', 'BookSummary'); + $c->joinWith('BookSummary.SummarizedBook'); + $c->joinWith('SummarizedBook.Author'); + $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $summary = $c->findOne($con); + $count = $con->getQueryCount(); + $this->assertEquals('Harry Potter does some amazing magic!', $summary->getSummary(), 'Main object is correctly hydrated'); + $book = $summary->getSummarizedBook(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); + $this->assertEquals('Harry Potter and the Order of the Phoenix', $book->getTitle(), 'Related object is correctly hydrated'); + $author = $book->getAuthor(); + $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query'); + $this->assertEquals('J.K.', $author->getFirstName(), 'Related object is correctly hydrated'); + } + + /** + * @expectedException PropelException + */ + public function testFindOneWithOneToMany() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); + $c->add(BookPeer::ISBN, '043935806X'); + $c->leftJoin('Book.Review'); + $c->with('Review'); + $books = $c->find(); + } + + public function testFindWithLeftJoinWithManyToOneAndNullObject() + { + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $review = new Review(); + $review->setReviewedBy('Toto'); + $review->setRecommended('0'); + $review->save($this->con); + $c = new ModelCriteria('bookstore', 'Review'); + $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); + $c->leftJoinWith('Review.Book'); + $c->leftJoinWith('Book.Author'); + // should not raise a notice + $reviews = $c->find($this->con); + $this->assertTrue(true); + } + + public function testFindOneWithColumn() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); + $c->filterByTitle('The Tin Drum'); + $c->join('Book.Author'); + $c->withColumn('Author.FirstName', 'AuthorName'); + $c->withColumn('Author.LastName', 'AuthorName2'); + $c->limit(1); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $books = $c->find($con); + foreach ($books as $book) { + break; + } + $this->assertTrue($book instanceof Book, 'withColumn() do not change the resulting model class'); + $this->assertEquals('The Tin Drum', $book->getTitle()); + $this->assertEquals('Gunter', $book->getVirtualColumn('AuthorName'), 'PropelObjectFormatter adds withColumns as virtual columns'); + $this->assertEquals('Grass', $book->getVirtualColumn('AuthorName2'), 'PropelObjectFormatter correctly hydrates all virtual columns'); + $this->assertEquals('Gunter', $book->getAuthorName(), 'PropelObjectFormatter adds withColumns as virtual columns'); + } + + public function testFindOneWithClassAndColumn() + { + BookstoreDataPopulator::populate(); + BookPeer::clearInstancePool(); + AuthorPeer::clearInstancePool(); + ReviewPeer::clearInstancePool(); + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND); + $c->filterByTitle('The Tin Drum'); + $c->join('Book.Author'); + $c->withColumn('Author.FirstName', 'AuthorName'); + $c->withColumn('Author.LastName', 'AuthorName2'); + $c->with('Author'); + $c->limit(1); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $books = $c->find($con); + foreach ($books as $book) { + break; + } + $this->assertTrue($book instanceof Book, 'withColumn() do not change the resulting model class'); + $this->assertEquals('The Tin Drum', $book->getTitle()); + $this->assertTrue($book->getAuthor() instanceof Author, 'PropelObjectFormatter correctly hydrates with class'); + $this->assertEquals('Gunter', $book->getAuthor()->getFirstName(), 'PropelObjectFormatter correctly hydrates with class'); + $this->assertEquals('Gunter', $book->getVirtualColumn('AuthorName'), 'PropelObjectFormatter adds withColumns as virtual columns'); + $this->assertEquals('Grass', $book->getVirtualColumn('AuthorName2'), 'PropelObjectFormatter correctly hydrates all virtual columns'); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelSimpleArrayFormatterTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelSimpleArrayFormatterTest.php new file mode 100644 index 000000000..b903e8fc5 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelSimpleArrayFormatterTest.php @@ -0,0 +1,72 @@ +query('SELECT 1 FROM book'); + + $formatter = new PropelSimpleArrayFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + + $books = $formatter->format($stmt); + $this->assertInstanceOf('PropelCollection', $books); + $this->assertCount(4, $books); + $this->assertSame('1', $books[0]); + } + + public function testFormatWithOneRowAndValueEqualsZero() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $stmt = $con->query('SELECT 0 FROM book'); + + $formatter = new PropelSimpleArrayFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + + $books = $formatter->format($stmt); + $this->assertInstanceOf('PropelCollection', $books); + $this->assertCount(4, $books); + $this->assertSame('0', $books[0]); + } + + public function testFormatOneWithOneRowAndValueIsNotZero() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $stmt = $con->query('SELECT 1 FROM book LIMIT 0, 1'); + + $formatter = new PropelSimpleArrayFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + + $book = $formatter->formatOne($stmt); + $this->assertSame('1', $book); + } + + public function testFormatOneWithOneRowAndValueEqualsZero() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $stmt = $con->query('SELECT 0 FROM book LIMIT 0, 1'); + + $formatter = new PropelSimpleArrayFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + + $book = $formatter->formatOne($stmt); + $this->assertSame('0', $book); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelStatementFormatterTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelStatementFormatterTest.php index c2ea8077e..2b8f8aba1 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelStatementFormatterTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/formatter/PropelStatementFormatterTest.php @@ -8,117 +8,117 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Test class for PropelStatementFormatter. * * @author Francois Zaninotto - * @version $Id: PropelStatementFormatterTest.php 1733 2010-05-04 14:25:27Z francois $ + * @version $Id$ * @package runtime.formatter */ class PropelStatementFormatterTest extends BookstoreEmptyTestBase { - protected function setUp() - { - parent::setUp(); - BookstoreDataPopulator::populate(); - } + protected function setUp() + { + parent::setUp(); + BookstoreDataPopulator::populate(); + } - public function testFormatNoCriteria() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); + public function testFormatNoCriteria() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $stmt = $con->query('SELECT * FROM book'); - $formatter = new PropelStatementFormatter(); - try { - $books = $formatter->format($stmt); - $this->assertTrue(true, 'PropelStatementFormatter::format() does not trow an exception when called with no valid criteria'); - } catch (PropelException $e) { - $this->fail('PropelStatementFormatter::format() does not trow an exception when called with no valid criteria'); - } - } - - public function testFormatManyResults() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $stmt = $con->query('SELECT * FROM book'); + $formatter = new PropelStatementFormatter(); + try { + $books = $formatter->format($stmt); + $this->assertTrue(true, 'PropelStatementFormatter::format() does not trow an exception when called with no valid criteria'); + } catch (PropelException $e) { + $this->fail('PropelStatementFormatter::format() does not trow an exception when called with no valid criteria'); + } + } - $stmt = $con->query('SELECT * FROM book'); - $formatter = new PropelStatementFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $books = $formatter->format($stmt); - - $this->assertTrue($books instanceof PDOStatement, 'PropelStatementFormatter::format() returns a PDOStatement'); - $this->assertEquals(4, $books->rowCount(), 'PropelStatementFormatter::format() returns as many rows as the results in the query'); - while ($book = $books->fetch()) { - $this->assertTrue(is_array($book), 'PropelStatementFormatter::format() returns a statement that can be fetched'); - } - } + public function testFormatManyResults() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); - public function testFormatOneResult() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $stmt = $con->query('SELECT * FROM book'); + $formatter = new PropelStatementFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $books = $formatter->format($stmt); - $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "Quicksilver"'); - $formatter = new PropelStatementFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $books = $formatter->format($stmt); - - $this->assertTrue($books instanceof PDOStatement, 'PropelStatementFormatter::format() returns a PDOStatement'); - $this->assertEquals(1, $books->rowCount(), 'PropelStatementFormatter::format() returns as many rows as the results in the query'); - $book = $books->fetch(PDO::FETCH_ASSOC); - $this->assertEquals('Quicksilver', $book['title'], 'PropelStatementFormatter::format() returns the rows matching the query'); - } + $this->assertTrue($books instanceof PDOStatement, 'PropelStatementFormatter::format() returns a PDOStatement'); + $this->assertEquals(4, $books->rowCount(), 'PropelStatementFormatter::format() returns as many rows as the results in the query'); + while ($book = $books->fetch()) { + $this->assertTrue(is_array($book), 'PropelStatementFormatter::format() returns a statement that can be fetched'); + } + } - public function testFormatNoResult() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - - $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "foo"'); - $formatter = new PropelStatementFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $books = $formatter->format($stmt); - - $this->assertTrue($books instanceof PDOStatement, 'PropelStatementFormatter::format() returns a PDOStatement'); - $this->assertEquals(0, $books->rowCount(), 'PropelStatementFormatter::format() returns as many rows as the results in the query'); - } - - public function testFormatoneNoCriteria() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); + public function testFormatOneResult() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $stmt = $con->query('SELECT * FROM book'); - $formatter = new PropelStatementFormatter(); - try { - $books = $formatter->formatOne($stmt); - $this->assertTrue(true, 'PropelStatementFormatter::formatOne() does not trow an exception when called with no valid criteria'); - } catch (PropelException $e) { - $this->fail('PropelStatementFormatter::formatOne() does not trow an exception when called with no valid criteria'); - } - } - - public function testFormatOneManyResults() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "Quicksilver"'); + $formatter = new PropelStatementFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $books = $formatter->format($stmt); - $stmt = $con->query('SELECT * FROM book'); - $formatter = new PropelStatementFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $book = $formatter->formatOne($stmt); - - $this->assertTrue($book instanceof PDOStatement, 'PropelStatementFormatter::formatOne() returns a PDO Statement'); - } + $this->assertTrue($books instanceof PDOStatement, 'PropelStatementFormatter::format() returns a PDOStatement'); + $this->assertEquals(1, $books->rowCount(), 'PropelStatementFormatter::format() returns as many rows as the results in the query'); + $book = $books->fetch(PDO::FETCH_ASSOC); + $this->assertEquals('Quicksilver', $book['title'], 'PropelStatementFormatter::format() returns the rows matching the query'); + } + + public function testFormatNoResult() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "foo"'); + $formatter = new PropelStatementFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $books = $formatter->format($stmt); + + $this->assertTrue($books instanceof PDOStatement, 'PropelStatementFormatter::format() returns a PDOStatement'); + $this->assertEquals(0, $books->rowCount(), 'PropelStatementFormatter::format() returns as many rows as the results in the query'); + } + + public function testFormatoneNoCriteria() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $stmt = $con->query('SELECT * FROM book'); + $formatter = new PropelStatementFormatter(); + try { + $books = $formatter->formatOne($stmt); + $this->assertTrue(true, 'PropelStatementFormatter::formatOne() does not trow an exception when called with no valid criteria'); + } catch (PropelException $e) { + $this->fail('PropelStatementFormatter::formatOne() does not trow an exception when called with no valid criteria'); + } + } + + public function testFormatOneManyResults() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $stmt = $con->query('SELECT * FROM book'); + $formatter = new PropelStatementFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $book = $formatter->formatOne($stmt); + + $this->assertTrue($book instanceof PDOStatement, 'PropelStatementFormatter::formatOne() returns a PDO Statement'); + } + + public function testFormatOneNoResult() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "foo"'); + $formatter = new PropelStatementFormatter(); + $formatter->init(new ModelCriteria('bookstore', 'Book')); + $book = $formatter->formatOne($stmt); + + $this->assertNull($book, 'PropelStatementFormatter::formatOne() returns null when no result'); + } - public function testFormatOneNoResult() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - - $stmt = $con->query('SELECT * FROM book WHERE book.TITLE = "foo"'); - $formatter = new PropelStatementFormatter(); - $formatter->init(new ModelCriteria('bookstore', 'Book')); - $book = $formatter->formatOne($stmt); - - $this->assertNull($book, 'PropelStatementFormatter::formatOne() returns null when no result'); - } - } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/map/ColumnMapTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/map/ColumnMapTest.php index f3225848f..cbb8ece6b 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/map/ColumnMapTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/map/ColumnMapTest.php @@ -8,134 +8,155 @@ * @license MIT License */ -require_once 'PHPUnit/Framework/TestCase.php'; -require_once dirname(__FILE__) . '/../../../../runtime/lib/map/ColumnMap.php'; -require_once dirname(__FILE__) . '/../../../../runtime/lib/map/TableMap.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; /** * Test class for TableMap. * * @author François Zaninotto - * @version $Id: ColumnMapTest.php 1773 2010-05-25 10:25:06Z francois $ + * @version $Id$ * @package runtime.map */ -class ColumnMapTest extends PHPUnit_Framework_TestCase -{ - protected $databaseMap; +class ColumnMapTest extends BookstoreTestBase +{ + protected $databaseMap; - protected function setUp() - { - parent::setUp(); - $this->dmap = new DatabaseMap('foodb'); - $this->tmap = new TableMap('foo', $this->dmap); - $this->columnName = 'bar'; - $this->cmap = new ColumnMap($this->columnName, $this->tmap); - } - - protected function tearDown() - { - // nothing to do for now - parent::tearDown(); - } - - public function testConstructor() - { - $this->assertEquals($this->columnName, $this->cmap->getName(), 'constructor sets the column name'); - $this->assertEquals($this->tmap, $this->cmap->getTable(), 'Constructor sets the table map'); - $this->assertNull($this->cmap->getType(), 'A new column map has no type'); - } - - public function testPhpName() - { - $this->assertNull($this->cmap->getPhpName(), 'phpName is empty until set'); - $this->cmap->setPhpName('FooBar'); - $this->assertEquals('FooBar', $this->cmap->getPhpName(), 'phpName is set by setPhpName()'); - } - - public function testType() - { - $this->assertNull($this->cmap->getType(), 'type is empty until set'); - $this->cmap->setType('FooBar'); - $this->assertEquals('FooBar', $this->cmap->getType(), 'type is set by setType()'); - } - - public function tesSize() - { - $this->assertEquals(0, $this->cmap->getSize(), 'size is empty until set'); - $this->cmap->setSize(123); - $this->assertEquals(123, $this->cmap->getSize(), 'size is set by setSize()'); - } - - public function testPrimaryKey() - { - $this->assertFalse($this->cmap->isPrimaryKey(), 'primaryKey is false by default'); - $this->cmap->setPrimaryKey(true); - $this->assertTrue($this->cmap->isPrimaryKey(), 'primaryKey is set by setPrimaryKey()'); - } - - public function testNotNull() - { - $this->assertFalse($this->cmap->isNotNull(), 'notNull is false by default'); - $this->cmap->setNotNull(true); - $this->assertTrue($this->cmap->isNotNull(), 'notNull is set by setPrimaryKey()'); - } - - public function testDefaultValue() - { - $this->assertNull($this->cmap->getDefaultValue(), 'defaultValue is empty until set'); - $this->cmap->setDefaultValue('FooBar'); - $this->assertEquals('FooBar', $this->cmap->getDefaultValue(), 'defaultValue is set by setDefaultValue()'); - } - - public function testGetForeignKey() - { - $this->assertFalse($this->cmap->isForeignKey(), 'foreignKey is false by default'); - try + protected function setUp() { - $this->cmap->getRelatedTable(); - $this->fail('getRelatedTable throws an exception when called on a column with no foreign key'); - } catch(PropelException $e) { - $this->assertTrue(true, 'getRelatedTable throws an exception when called on a column with no foreign key'); + parent::setUp(); + $this->dmap = new DatabaseMap('foodb'); + $this->tmap = new TableMap('foo', $this->dmap); + $this->columnName = 'bar'; + $this->cmap = new ColumnMap($this->columnName, $this->tmap); } - try + + protected function tearDown() { - $this->cmap->getRelatedColumn(); - $this->fail('getRelatedColumn throws an exception when called on a column with no foreign key'); - } catch(PropelException $e) { - $this->assertTrue(true, 'getRelatedColumn throws an exception when called on a column with no foreign key'); + // nothing to do for now + parent::tearDown(); } - $relatedTmap = $this->dmap->addTable('foo2'); - // required to let the database map use the foreign TableMap - $relatedCmap = $relatedTmap->addColumn('BAR2', 'Bar2', 'INTEGER'); - $this->cmap->setForeignKey('foo2', 'BAR2'); - $this->assertTrue($this->cmap->isForeignKey(), 'foreignKey is true after setting the foreign key via setForeignKey()'); - $this->assertEquals($relatedTmap, $this->cmap->getRelatedTable(), 'getRelatedTable returns the related TableMap object'); - $this->assertEquals($relatedCmap, $this->cmap->getRelatedColumn(), 'getRelatedColumn returns the related ColumnMap object'); - } - - public function testGetRelation() + + public function testConstructor() + { + $this->assertEquals($this->columnName, $this->cmap->getName(), 'constructor sets the column name'); + $this->assertEquals($this->tmap, $this->cmap->getTable(), 'Constructor sets the table map'); + $this->assertNull($this->cmap->getType(), 'A new column map has no type'); + } + + public function testPhpName() + { + $this->assertNull($this->cmap->getPhpName(), 'phpName is empty until set'); + $this->cmap->setPhpName('FooBar'); + $this->assertEquals('FooBar', $this->cmap->getPhpName(), 'phpName is set by setPhpName()'); + } + + public function testType() + { + $this->assertNull($this->cmap->getType(), 'type is empty until set'); + $this->cmap->setType('FooBar'); + $this->assertEquals('FooBar', $this->cmap->getType(), 'type is set by setType()'); + } + + public function tesSize() + { + $this->assertEquals(0, $this->cmap->getSize(), 'size is empty until set'); + $this->cmap->setSize(123); + $this->assertEquals(123, $this->cmap->getSize(), 'size is set by setSize()'); + } + + public function testPrimaryKey() + { + $this->assertFalse($this->cmap->isPrimaryKey(), 'primaryKey is false by default'); + $this->cmap->setPrimaryKey(true); + $this->assertTrue($this->cmap->isPrimaryKey(), 'primaryKey is set by setPrimaryKey()'); + } + + public function testNotNull() + { + $this->assertFalse($this->cmap->isNotNull(), 'notNull is false by default'); + $this->cmap->setNotNull(true); + $this->assertTrue($this->cmap->isNotNull(), 'notNull is set by setPrimaryKey()'); + } + + public function testDefaultValue() + { + $this->assertNull($this->cmap->getDefaultValue(), 'defaultValue is empty until set'); + $this->cmap->setDefaultValue('FooBar'); + $this->assertEquals('FooBar', $this->cmap->getDefaultValue(), 'defaultValue is set by setDefaultValue()'); + } + + public function testGetForeignKey() + { + $this->assertFalse($this->cmap->isForeignKey(), 'foreignKey is false by default'); + try { + $this->cmap->getRelatedTable(); + $this->fail('getRelatedTable throws an exception when called on a column with no foreign key'); + } catch (PropelException $e) { + $this->assertTrue(true, 'getRelatedTable throws an exception when called on a column with no foreign key'); + } + try { + $this->cmap->getRelatedColumn(); + $this->fail('getRelatedColumn throws an exception when called on a column with no foreign key'); + } catch (PropelException $e) { + $this->assertTrue(true, 'getRelatedColumn throws an exception when called on a column with no foreign key'); + } + $relatedTmap = $this->dmap->addTable('foo2'); + // required to let the database map use the foreign TableMap + $relatedCmap = $relatedTmap->addColumn('BAR2', 'Bar2', 'INTEGER'); + $this->cmap->setForeignKey('foo2', 'BAR2'); + $this->assertTrue($this->cmap->isForeignKey(), 'foreignKey is true after setting the foreign key via setForeignKey()'); + $this->assertEquals($relatedTmap, $this->cmap->getRelatedTable(), 'getRelatedTable returns the related TableMap object'); + $this->assertEquals($relatedCmap, $this->cmap->getRelatedColumn(), 'getRelatedColumn returns the related ColumnMap object'); + } + + public function testGetRelation() + { + $bookTable = BookPeer::getTableMap(); + $titleColumn = $bookTable->getColumn('title'); + $this->assertNull($titleColumn->getRelation(), 'getRelation() returns null for non-foreign key columns'); + $publisherColumn = $bookTable->getColumn('publisher_id'); + $this->assertEquals($publisherColumn->getRelation(), $bookTable->getRelation('Publisher'), 'getRelation() returns the RelationMap object for this foreign key'); + $bookstoreTable = BookstoreEmployeePeer::getTableMap(); + $supervisorColumn = $bookstoreTable->getColumn('supervisor_id'); + $this->assertEquals($supervisorColumn->getRelation(), $supervisorColumn->getRelation('Supervisor'), 'getRelation() returns the RelationMap object even without specific refPhpName'); + + } + + public function testNormalizeName() { - set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes"); - Propel::init('fixtures/bookstore/build/conf/bookstore-conf.php'); - $bookTable = BookPeer::getTableMap(); - $titleColumn = $bookTable->getColumn('TITLE'); - $this->assertNull($titleColumn->getRelation(), 'getRelation() returns null for non-foreign key columns'); - $publisherColumn = $bookTable->getColumn('PUBLISHER_ID'); - $this->assertEquals($publisherColumn->getRelation(), $bookTable->getRelation('Publisher'), 'getRelation() returns the RelationMap object for this foreign key'); - $bookstoreTable = BookstoreEmployeePeer::getTableMap(); - $supervisorColumn = $bookstoreTable->getColumn('SUPERVISOR_ID'); - $this->assertEquals($supervisorColumn->getRelation(), $supervisorColumn->getRelation('Supervisor'), 'getRelation() returns the RelationMap object even whit ha specific refPhpName'); - - } - - public function testNormalizeName() - { - $this->assertEquals('', ColumnMap::normalizeName(''), 'normalizeColumnName() returns an empty string when passed an empty string'); - $this->assertEquals('BAR', ColumnMap::normalizeName('bar'), 'normalizeColumnName() uppercases the input'); - $this->assertEquals('BAR_BAZ', ColumnMap::normalizeName('bar_baz'), 'normalizeColumnName() does not mind underscores'); - $this->assertEquals('BAR', ColumnMap::normalizeName('FOO.BAR'), 'normalizeColumnName() removes table prefix'); - $this->assertEquals('BAR', ColumnMap::normalizeName('BAR'), 'normalizeColumnName() leaves normalized column names unchanged'); - $this->assertEquals('BAR_BAZ', ColumnMap::normalizeName('foo.bar_baz'), 'normalizeColumnName() can do all the above at the same time'); + $this->assertEquals('', ColumnMap::normalizeName(''), 'normalizeColumnName() returns an empty string when passed an empty string'); + $this->assertEquals('bar', ColumnMap::normalizeName('bar'), 'normalizeColumnName() uppercases the input'); + $this->assertEquals('bar_baz', ColumnMap::normalizeName('bar_baz'), 'normalizeColumnName() does not mind underscores'); + $this->assertEquals('BAR', ColumnMap::normalizeName('FOO.BAR'), 'normalizeColumnName() removes table prefix'); + $this->assertEquals('BAR', ColumnMap::normalizeName('BAR'), 'normalizeColumnName() leaves normalized column names unchanged'); + $this->assertEquals('bar_baz', ColumnMap::normalizeName('foo.bar_baz'), 'normalizeColumnName() can do all the above at the same time'); } + public function testIsPrimaryString() + { + $bookTable = BookPeer::getTableMap(); + $idColumn = $bookTable->getColumn('id'); + $titleColumn = $bookTable->getColumn('title'); + $isbnColumn = $bookTable->getColumn('isbn'); + + $this->assertFalse($idColumn->isPrimaryString(), 'isPrimaryString() returns false by default.'); + $this->assertTrue($titleColumn->isPrimaryString(), 'isPrimaryString() returns true if set in schema.'); + $this->assertFalse($isbnColumn->isPrimaryString(), 'isPrimaryString() returns false if not set in schema.'); + + $titleColumn->setPrimaryString(false); + $this->assertFalse($titleColumn->isPrimaryString(), 'isPrimaryString() returns false if unset.'); + + $titleColumn->setPrimaryString(true); + $this->assertTrue($titleColumn->isPrimaryString(), 'isPrimaryString() returns true if set.'); + } + + public function testIsInteger() + { + $bookTable = BookPeer::getTableMap(); + $idColumn = $bookTable->getColumn('id'); // INTEGER + $titleColumn = $bookTable->getColumn('title'); // VARCHAR + + $this->assertTrue($idColumn->isInteger(), 'isInteger() returns true'); + $this->assertFalse($titleColumn->isInteger(), 'isInteger() returns false'); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/map/DatabaseMapTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/map/DatabaseMapTest.php index 7a078131d..01d27514d 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/map/DatabaseMapTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/map/DatabaseMapTest.php @@ -8,50 +8,17 @@ * @license MIT License */ -require_once 'PHPUnit/Framework/TestCase.php'; -require_once dirname(__FILE__) . '/../../../../runtime/lib/map/ColumnMap.php'; -require_once dirname(__FILE__) . '/../../../../runtime/lib/map/TableMap.php'; -require_once dirname(__FILE__) . '/../../../../runtime/lib/map/DatabaseMap.php'; - -class TestDatabaseBuilder -{ - protected static $dmap = null; - protected static $tmap = null; - public static function getDmap() - { - if (is_null(self::$dmap)) { - self::$dmap = new DatabaseMap('foodb'); - } - return self::$dmap; - } - public static function setTmap($tmap) - { - self::$tmap = $tmap; - } - public static function getTmap() - { - return self::$tmap; - } -} - -class BazTableMap extends TableMap -{ - public function initialize() - { - $this->setName('baz'); - $this->setPhpName('Baz'); - } -} +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; /** * Test class for DatabaseMap. * * @author François Zaninotto - * @version $Id: DatabaseMapTest.php 1773 2010-05-25 10:25:06Z francois $ + * @version $Id$ * @package runtime.map */ -class DatabaseMapTest extends PHPUnit_Framework_TestCase -{ +class DatabaseMapTest extends BookstoreTestBase +{ protected $databaseMap; protected function setUp() @@ -75,26 +42,24 @@ class DatabaseMapTest extends PHPUnit_Framework_TestCase public function testAddTable() { $this->assertFalse($this->databaseMap->hasTable('foo'), 'tables are empty by default'); - try - { + try { $this->databaseMap->getTable('foo'); $this->fail('getTable() throws an exception when called on an inexistent table'); - } catch(PropelException $e) { + } catch (PropelException $e) { $this->assertTrue(true, 'getTable() throws an exception when called on an inexistent table'); } $tmap = $this->databaseMap->addTable('foo'); $this->assertTrue($this->databaseMap->hasTable('foo'), 'hasTable() returns true when the table was added by way of addTable()'); $this->assertEquals($tmap, $this->databaseMap->getTable('foo'), 'getTable() returns a table by name when the table was added by way of addTable()'); } - + public function testAddTableObject() { $this->assertFalse($this->databaseMap->hasTable('foo2'), 'tables are empty by default'); - try - { + try { $this->databaseMap->getTable('foo2'); $this->fail('getTable() throws an exception when called on a table with no builder'); - } catch(PropelException $e) { + } catch (PropelException $e) { $this->assertTrue(true, 'getTable() throws an exception when called on a table with no builder'); } $tmap = new TableMap('foo2'); @@ -106,51 +71,46 @@ class DatabaseMapTest extends PHPUnit_Framework_TestCase public function testAddTableFromMapClass() { $table1 = $this->databaseMap->addTableFromMapClass('BazTableMap'); - try - { + try { $table2 = $this->databaseMap->getTable('baz'); $this->assertEquals($table1, $table2, 'addTableFromMapClass() adds a table from a map class'); - } catch(PropelException $e) { + } catch (PropelException $e) { $this->fail('addTableFromMapClass() adds a table from a map class'); } } public function testGetColumn() { - try - { + try { $this->databaseMap->getColumn('foo.BAR'); $this->fail('getColumn() throws an exception when called on column of an inexistent table'); - } catch(PropelException $e) { + } catch (PropelException $e) { $this->assertTrue(true, 'getColumn() throws an exception when called on column of an inexistent table'); } $tmap = $this->databaseMap->addTable('foo'); - try - { + try { $this->databaseMap->getColumn('foo.BAR'); $this->fail('getColumn() throws an exception when called on an inexistent column of an existent table'); - } catch(PropelException $e) { + } catch (PropelException $e) { $this->assertTrue(true, 'getColumn() throws an exception when called on an inexistent column of an existent table'); } $column = $tmap->addColumn('BAR', 'Bar', 'INTEGER'); $this->assertEquals($column, $this->databaseMap->getColumn('foo.BAR'), 'getColumn() returns a ColumnMap object based on a fully qualified name'); } - + public function testGetTableByPhpName() { - try - { + try { $this->databaseMap->getTableByPhpName('Foo1'); $this->fail('getTableByPhpName() throws an exception when called on an inexistent table'); - } catch(PropelException $e) { + } catch (PropelException $e) { $this->assertTrue(true, 'getTableByPhpName() throws an exception when called on an inexistent table'); } $tmap = $this->databaseMap->addTable('foo1'); - try - { + try { $this->databaseMap->getTableByPhpName('Foo1'); $this->fail('getTableByPhpName() throws an exception when called on a table with no phpName'); - } catch(PropelException $e) { + } catch (PropelException $e) { $this->assertTrue(true, 'getTableByPhpName() throws an exception when called on a table with no phpName'); } $tmap2 = new TableMap('foo2'); @@ -158,14 +118,73 @@ class DatabaseMapTest extends PHPUnit_Framework_TestCase $this->databaseMap->addTableObject($tmap2); $this->assertEquals($tmap2, $this->databaseMap->getTableByPhpName('Foo2'), 'getTableByPhpName() returns tableMap when phpName was set by way of TableMap::setPhpName()'); } - + + /** + * @dataProvider phpNameData + */ + public function testGetTableByPhpNameNamespaced($name, $phpName, $classname) + { + try { + $this->databaseMap->getTableByPhpName($classname); + $this->fail('getTableByPhpName() throws an exception when called on an inexistent table'); + } catch (PropelException $e) { + $this->assertTrue(true, 'getTableByPhpName() throws an exception when called on an inexistent table'); + } + $tmap2 = new TableMap($name); + $tmap2->setPhpName($phpName); + $tmap2->setClassname($classname); + $this->databaseMap->addTableObject($tmap2); + $this->assertEquals($tmap2, $this->databaseMap->getTableByPhpName($classname), 'getTableByPhpName() returns tableMap when phpName was set by way of TableMap::setPhpName()'); + } + + public static function phpNameData() + { + return array( + array('foo3', 'Foo3', 'Foo3'), + array('foo_bar', 'FooBar', 'FooBar'), + array('foo4', 'Foo4', 'myNameSpace\Foo4'), + array('foo_bar2', 'FooBar2', 'myNameSpace\FooBar2'), + array('baz6', 'Baz6', '\myNameSpace\FooBar\Baz6'), + array('foo7', 'Foo7', '\myNameSpace\Foo7'), + array('foo_bar8', 'FooBar8', '\myNameSpace\FooBar8'), + array('baz9', 'Baz9', '\myNameSpace\FooBar\Baz9') + ); + } + public function testGetTableByPhpNameNotLoaded() { - set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes"); - require_once 'bookstore/map/BookTableMap.php'; - require_once 'bookstore/om/BaseBookPeer.php'; - require_once 'bookstore/BookPeer.php'; - $this->assertEquals('book', Propel::getDatabaseMap('bookstore')->getTableByPhpName('Book')->getName(), 'getTableByPhpName() can autoload a TableMap when the Peer class is generated and autoloaded'); + $this->assertEquals('book', Propel::getDatabaseMap('bookstore')->getTableByPhpName('Book')->getName(), 'getTableByPhpName() can autoload a TableMap when the Peer class is generated and autoloaded'); + } + +} + +class TestDatabaseBuilder +{ + protected static $dmap = null; + protected static $tmap = null; + public static function getDmap() + { + if (is_null(self::$dmap)) { + self::$dmap = new DatabaseMap('foodb'); + } + + return self::$dmap; + } + public static function setTmap($tmap) + { + self::$tmap = $tmap; + } + public static function getTmap() + { + return self::$tmap; + } +} + +class BazTableMap extends TableMap +{ + public function initialize() + { + $this->setName('baz'); + $this->setPhpName('Baz'); } - } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/map/GeneratedRelationMapTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/map/GeneratedRelationMapTest.php index 62b84a77c..977a18add 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/map/GeneratedRelationMapTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/map/GeneratedRelationMapTest.php @@ -8,68 +8,68 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; /** * Test class for PHP5TableMapBuilder. * * @author François Zaninotto - * @version $Id: GeneratedRelationMapTest.php 1612 2010-03-16 22:56:21Z francois $ + * @version $Id$ * @package runtime.map */ -class GeneratedRelationMapTest extends BookstoreTestBase -{ - protected $databaseMap; +class GeneratedRelationMapTest extends BookstoreTestBase +{ + protected $databaseMap; - protected function setUp() - { - parent::setUp(); - $this->databaseMap = Propel::getDatabaseMap('bookstore'); - } + protected function setUp() + { + parent::setUp(); + $this->databaseMap = Propel::getDatabaseMap('bookstore'); + } - public function testGetRightTable() - { - $bookTable = $this->databaseMap->getTableByPhpName('Book'); - $authorTable = $this->databaseMap->getTableByPhpName('Author'); - $this->assertEquals($authorTable, $bookTable->getRelation('Author')->getRightTable(), 'getRightTable() returns correct table when called on a many to one relationship'); - $this->assertEquals($bookTable, $authorTable->getRelation('Book')->getRightTable(), 'getRightTable() returns correct table when called on a one to many relationship'); - $bookEmpTable = $this->databaseMap->getTableByPhpName('BookstoreEmployee'); - $bookEmpAccTable = $this->databaseMap->getTableByPhpName('BookstoreEmployeeAccount'); - $this->assertEquals($bookEmpAccTable, $bookEmpTable->getRelation('BookstoreEmployeeAccount')->getRightTable(), 'getRightTable() returns correct table when called on a one to one relationship'); - $this->assertEquals($bookEmpTable, $bookEmpAccTable->getRelation('BookstoreEmployee')->getRightTable(), 'getRightTable() returns correct table when called on a one to one relationship'); - } - - public function testColumnMappings() - { - $bookTable = $this->databaseMap->getTableByPhpName('Book'); - $this->assertEquals(array('book.AUTHOR_ID' => 'author.ID'), $bookTable->getRelation('Author')->getColumnMappings(), 'getColumnMappings returns local to foreign by default'); - $this->assertEquals(array('book.AUTHOR_ID' => 'author.ID'), $bookTable->getRelation('Author')->getColumnMappings(RelationMap::LEFT_TO_RIGHT), 'getColumnMappings returns local to foreign when asked left to right for a many to one relationship'); - - $authorTable = $this->databaseMap->getTableByPhpName('Author'); - $this->assertEquals(array('book.AUTHOR_ID' => 'author.ID'), $authorTable->getRelation('Book')->getColumnMappings(), 'getColumnMappings returns local to foreign by default'); - $this->assertEquals(array('author.ID' => 'book.AUTHOR_ID'), $authorTable->getRelation('Book')->getColumnMappings(RelationMap::LEFT_TO_RIGHT), 'getColumnMappings returns foreign to local when asked left to right for a one to many relationship'); - - $bookEmpTable = $this->databaseMap->getTableByPhpName('BookstoreEmployee'); - $this->assertEquals(array('bookstore_employee_account.EMPLOYEE_ID' => 'bookstore_employee.ID'), $bookEmpTable->getRelation('BookstoreEmployeeAccount')->getColumnMappings(), 'getColumnMappings returns local to foreign by default'); - $this->assertEquals(array('bookstore_employee.ID' => 'bookstore_employee_account.EMPLOYEE_ID'), $bookEmpTable->getRelation('BookstoreEmployeeAccount')->getColumnMappings(RelationMap::LEFT_TO_RIGHT), 'getColumnMappings returns foreign to local when asked left to right for a one to one relationship'); - } - - public function testCountColumnMappings() - { - $bookTable = $this->databaseMap->getTableByPhpName('Book'); - $this->assertEquals(1, $bookTable->getRelation('Author')->countColumnMappings()); - - $rfTable = $this->databaseMap->getTableByPhpName('ReaderFavorite'); - $this->assertEquals(2, $rfTable->getRelation('BookOpinion')->countColumnMappings()); - } + public function testGetRightTable() + { + $bookTable = $this->databaseMap->getTableByPhpName('Book'); + $authorTable = $this->databaseMap->getTableByPhpName('Author'); + $this->assertEquals($authorTable, $bookTable->getRelation('Author')->getRightTable(), 'getRightTable() returns correct table when called on a many to one relationship'); + $this->assertEquals($bookTable, $authorTable->getRelation('Book')->getRightTable(), 'getRightTable() returns correct table when called on a one to many relationship'); + $bookEmpTable = $this->databaseMap->getTableByPhpName('BookstoreEmployee'); + $bookEmpAccTable = $this->databaseMap->getTableByPhpName('BookstoreEmployeeAccount'); + $this->assertEquals($bookEmpAccTable, $bookEmpTable->getRelation('BookstoreEmployeeAccount')->getRightTable(), 'getRightTable() returns correct table when called on a one to one relationship'); + $this->assertEquals($bookEmpTable, $bookEmpAccTable->getRelation('BookstoreEmployee')->getRightTable(), 'getRightTable() returns correct table when called on a one to one relationship'); + } - public function testIsComposite() - { - $bookTable = $this->databaseMap->getTableByPhpName('Book'); - $this->assertFalse($bookTable->getRelation('Author')->isComposite()); - - $rfTable = $this->databaseMap->getTableByPhpName('ReaderFavorite'); - $this->assertTrue($rfTable->getRelation('BookOpinion')->isComposite()); - } + public function testColumnMappings() + { + $bookTable = $this->databaseMap->getTableByPhpName('Book'); + $this->assertEquals(array('book.author_id' => 'author.id'), $bookTable->getRelation('Author')->getColumnMappings(), 'getColumnMappings returns local to foreign by default'); + $this->assertEquals(array('book.author_id' => 'author.id'), $bookTable->getRelation('Author')->getColumnMappings(RelationMap::LEFT_TO_RIGHT), 'getColumnMappings returns local to foreign when asked left to right for a many to one relationship'); + + $authorTable = $this->databaseMap->getTableByPhpName('Author'); + $this->assertEquals(array('book.author_id' => 'author.id'), $authorTable->getRelation('Book')->getColumnMappings(), 'getColumnMappings returns local to foreign by default'); + $this->assertEquals(array('author.id' => 'book.author_id'), $authorTable->getRelation('Book')->getColumnMappings(RelationMap::LEFT_TO_RIGHT), 'getColumnMappings returns foreign to local when asked left to right for a one to many relationship'); + + $bookEmpTable = $this->databaseMap->getTableByPhpName('BookstoreEmployee'); + $this->assertEquals(array('bookstore_employee_account.employee_id' => 'bookstore_employee.id'), $bookEmpTable->getRelation('BookstoreEmployeeAccount')->getColumnMappings(), 'getColumnMappings returns local to foreign by default'); + $this->assertEquals(array('bookstore_employee.id' => 'bookstore_employee_account.employee_id'), $bookEmpTable->getRelation('BookstoreEmployeeAccount')->getColumnMappings(RelationMap::LEFT_TO_RIGHT), 'getColumnMappings returns foreign to local when asked left to right for a one to one relationship'); + } + + public function testCountColumnMappings() + { + $bookTable = $this->databaseMap->getTableByPhpName('Book'); + $this->assertEquals(1, $bookTable->getRelation('Author')->countColumnMappings()); + + $rfTable = $this->databaseMap->getTableByPhpName('ReaderFavorite'); + $this->assertEquals(2, $rfTable->getRelation('BookOpinion')->countColumnMappings()); + } + + public function testIsComposite() + { + $bookTable = $this->databaseMap->getTableByPhpName('Book'); + $this->assertFalse($bookTable->getRelation('Author')->isComposite()); + + $rfTable = $this->databaseMap->getTableByPhpName('ReaderFavorite'); + $this->assertTrue($rfTable->getRelation('BookOpinion')->isComposite()); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/map/GeneratedRelationMapWithSchemasTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/map/GeneratedRelationMapWithSchemasTest.php new file mode 100644 index 000000000..de90f2d32 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/map/GeneratedRelationMapWithSchemasTest.php @@ -0,0 +1,73 @@ +databaseMap = Propel::getDatabaseMap('bookstore-schemas'); + } + + public function testGetRightTable() + { + $bookTable = $this->databaseMap->getTableByPhpName('BookstoreSchemasBookstore'); + $contestTable = $this->databaseMap->getTableByPhpName('ContestBookstoreContest'); + $this->assertEquals( + $bookTable->getName(), + $contestTable->getRelation('BookstoreSchemasBookstore')->getRightTable()->getName(), + 'getRightTable() returns correct table when called on a many to one relationship' + ); + $this->assertEquals( + $contestTable->getName(), + $bookTable->getRelation('ContestBookstoreContest')->getRightTable()->getName(), + 'getRightTable() returns correct table when called on a one to many relationship' + ); + $bookCustomerTable = $this->databaseMap->getTableByPhpName('BookstoreSchemasCustomer'); + $bookCustomerAccTable = $this->databaseMap->getTableByPhpName('BookstoreSchemasCustomerAccount'); + $this->assertEquals( + $bookCustomerAccTable->getName(), + $bookCustomerTable->getRelation('BookstoreSchemasCustomerAccount')->getRightTable()->getName(), + 'getRightTable() returns correct table when called on a one to one relationship' + ); + $this->assertEquals( + $bookCustomerTable->getName(), + $bookCustomerAccTable->getRelation('BookstoreSchemasCustomer')->getRightTable()->getName(), + 'getRightTable() returns correct table when called on a one to one relationship' + ); + } + + public function testColumnMappings() + { + $contestTable = $this->databaseMap->getTableByPhpName('ContestBookstoreContest'); + $this->assertEquals(array('contest.bookstore_contest.bookstore_id' => 'bookstore_schemas.bookstore.id'), $contestTable->getRelation('BookstoreSchemasBookstore')->getColumnMappings(), 'getColumnMappings returns local to foreign by default'); + $this->assertEquals(array('contest.bookstore_contest.bookstore_id' => 'bookstore_schemas.bookstore.id'), $contestTable->getRelation('BookstoreSchemasBookstore')->getColumnMappings(RelationMap::LEFT_TO_RIGHT), 'getColumnMappings returns local to foreign when asked left to right for a many to one relationship'); + + $bookTable = $this->databaseMap->getTableByPhpName('BookstoreSchemasBookstore'); + $this->assertEquals(array('contest.bookstore_contest.bookstore_id' => 'bookstore_schemas.bookstore.id'), $bookTable->getRelation('ContestBookstoreContest')->getColumnMappings(), 'getColumnMappings returns local to foreign by default'); + $this->assertEquals(array('bookstore_schemas.bookstore.id' => 'contest.bookstore_contest.bookstore_id'), $bookTable->getRelation('ContestBookstoreContest')->getColumnMappings(RelationMap::LEFT_TO_RIGHT), 'getColumnMappings returns foreign to local when asked left to right for a one to many relationship'); + + $bookCustomerTable = $this->databaseMap->getTableByPhpName('BookstoreSchemasCustomer'); + $this->assertEquals(array('bookstore_schemas.customer_account.customer_id' => 'bookstore_schemas.customer.id'), $bookCustomerTable->getRelation('BookstoreSchemasCustomerAccount')->getColumnMappings(), 'getColumnMappings returns local to foreign by default'); + $this->assertEquals(array('bookstore_schemas.customer.id' => 'bookstore_schemas.customer_account.customer_id'), $bookCustomerTable->getRelation('BookstoreSchemasCustomerAccount')->getColumnMappings(RelationMap::LEFT_TO_RIGHT), 'getColumnMappings returns foreign to local when asked left to right for a one to one relationship'); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/map/RelatedMapSymmetricalTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/map/RelatedMapSymmetricalTest.php index 6737aa7df..586ed477d 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/map/RelatedMapSymmetricalTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/map/RelatedMapSymmetricalTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; /** * Test class for RelatedMap::getSymmetricalRelation. @@ -17,54 +17,54 @@ require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; * @version $Id: GeneratedRelationMapTest.php 1347 2009-12-03 21:06:36Z francois $ * @package runtime.map */ -class RelatedMapSymmetricalTest extends BookstoreTestBase -{ +class RelatedMapSymmetricalTest extends BookstoreTestBase +{ protected $databaseMap; protected function setUp() { - parent::setUp(); + parent::setUp(); $this->databaseMap = Propel::getDatabaseMap('bookstore'); } - public function testOneToMany() - { - $bookTable = $this->databaseMap->getTableByPhpName('Book'); - $bookToAuthor = $bookTable->getRelation('Author'); - $authorTable = $this->databaseMap->getTableByPhpName('Author'); - $authorToBook = $authorTable->getRelation('Book'); - $this->assertEquals($authorToBook, $bookToAuthor->getSymmetricalRelation()); - $this->assertEquals($bookToAuthor, $authorToBook->getSymmetricalRelation()); - } + public function testOneToMany() + { + $bookTable = $this->databaseMap->getTableByPhpName('Book'); + $bookToAuthor = $bookTable->getRelation('Author'); + $authorTable = $this->databaseMap->getTableByPhpName('Author'); + $authorToBook = $authorTable->getRelation('Book'); + $this->assertEquals($authorToBook, $bookToAuthor->getSymmetricalRelation()); + $this->assertEquals($bookToAuthor, $authorToBook->getSymmetricalRelation()); + } + + public function testOneToOne() + { + $accountTable = $this->databaseMap->getTableByPhpName('BookstoreEmployeeAccount'); + $accountToEmployee = $accountTable->getRelation('BookstoreEmployee'); + $employeeTable = $this->databaseMap->getTableByPhpName('BookstoreEmployee'); + $employeeToAccount = $employeeTable->getRelation('BookstoreEmployeeAccount'); + $this->assertEquals($accountToEmployee, $employeeToAccount->getSymmetricalRelation()); + $this->assertEquals($employeeToAccount, $accountToEmployee->getSymmetricalRelation()); + } + + public function testSeveralRelationsOnSameTable() + { + $authorTable = $this->databaseMap->getTableByPhpName('Author'); + $authorToEssay = $authorTable->getRelation('EssayRelatedByFirstAuthor'); + $essayTable = $this->databaseMap->getTableByPhpName('Essay'); + $essayToAuthor = $essayTable->getRelation('AuthorRelatedByFirstAuthor'); + $this->assertEquals($authorToEssay, $essayToAuthor->getSymmetricalRelation()); + $this->assertEquals($essayToAuthor, $authorToEssay->getSymmetricalRelation()); + } + + public function testCompositeForeignKey() + { + $favoriteTable = $this->databaseMap->getTableByPhpName('ReaderFavorite'); + $favoriteToOpinion = $favoriteTable->getRelation('BookOpinion'); + $opinionTable = $this->databaseMap->getTableByPhpName('BookOpinion'); + $opinionToFavorite = $opinionTable->getRelation('ReaderFavorite'); + $this->assertEquals($favoriteToOpinion, $opinionToFavorite->getSymmetricalRelation()); + $this->assertEquals($opinionToFavorite, $favoriteToOpinion->getSymmetricalRelation()); + } - public function testOneToOne() - { - $accountTable = $this->databaseMap->getTableByPhpName('BookstoreEmployeeAccount'); - $accountToEmployee = $accountTable->getRelation('BookstoreEmployee'); - $employeeTable = $this->databaseMap->getTableByPhpName('BookstoreEmployee'); - $employeeToAccount = $employeeTable->getRelation('BookstoreEmployeeAccount'); - $this->assertEquals($accountToEmployee, $employeeToAccount->getSymmetricalRelation()); - $this->assertEquals($employeeToAccount, $accountToEmployee->getSymmetricalRelation()); - } - - public function testSeveralRelationsOnSameTable() - { - $authorTable = $this->databaseMap->getTableByPhpName('Author'); - $authorToEssay = $authorTable->getRelation('EssayRelatedByFirstAuthor'); - $essayTable = $this->databaseMap->getTableByPhpName('Essay'); - $essayToAuthor = $essayTable->getRelation('AuthorRelatedByFirstAuthor'); - $this->assertEquals($authorToEssay, $essayToAuthor->getSymmetricalRelation()); - $this->assertEquals($essayToAuthor, $authorToEssay->getSymmetricalRelation()); - } - - public function testCompositeForeignKey() - { - $favoriteTable = $this->databaseMap->getTableByPhpName('ReaderFavorite'); - $favoriteToOpinion = $favoriteTable->getRelation('BookOpinion'); - $opinionTable = $this->databaseMap->getTableByPhpName('BookOpinion'); - $opinionToFavorite = $opinionTable->getRelation('ReaderFavorite'); - $this->assertEquals($favoriteToOpinion, $opinionToFavorite->getSymmetricalRelation()); - $this->assertEquals($opinionToFavorite, $favoriteToOpinion->getSymmetricalRelation()); - } - } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/map/RelatedMapSymmetricalWithSchemasTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/map/RelatedMapSymmetricalWithSchemasTest.php new file mode 100644 index 000000000..c672374a7 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/map/RelatedMapSymmetricalWithSchemasTest.php @@ -0,0 +1,72 @@ +databaseMap = Propel::getDatabaseMap('bookstore-schemas'); + } + + public function testOneToMany() + { + // passes on its own, but not with the full tests suite + $this->markTestSkipped(); + $contestTable = $this->databaseMap->getTableByPhpName('ContestBookstoreContest'); + $contestToBookstore = $contestTable->getRelation('BookstoreSchemasBookstore'); + $bookstoreTable = $this->databaseMap->getTableByPhpName('BookstoreSchemasBookstore'); + $bookstoreToContest = $bookstoreTable->getRelation('ContestBookstoreContest'); + $this->assertEquals($bookstoreToContest->getName(), $contestToBookstore->getSymmetricalRelation()->getName()); + $this->assertEquals($contestToBookstore->getName(), $bookstoreToContest->getSymmetricalRelation()->getName()); + } + + public function testOneToOne() + { + $accountTable = $this->databaseMap->getTableByPhpName('BookstoreSchemasCustomerAccount'); + $accountToCustomer = $accountTable->getRelation('BookstoreSchemasCustomer'); + $customerTable = $this->databaseMap->getTableByPhpName('BookstoreSchemasCustomer'); + $customerToAccount = $customerTable->getRelation('BookstoreSchemasCustomerAccount'); + $this->assertEquals($accountToCustomer, $customerToAccount->getSymmetricalRelation()); + $this->assertEquals($customerToAccount, $accountToCustomer->getSymmetricalRelation()); + } + + public function testSeveralRelationsOnSameTable() + { + $contestTable = $this->databaseMap->getTableByPhpName('ContestBookstoreContest'); + $contestToCustomer = $contestTable->getRelation('BookstoreSchemasCustomerRelatedByFirstContest'); + $customerTable = $this->databaseMap->getTableByPhpName('BookstoreSchemasCustomer'); + $customerToContest = $customerTable->getRelation('ContestBookstoreContestRelatedByFirstContest'); + $this->assertEquals($contestToCustomer, $customerToContest->getSymmetricalRelation()); + $this->assertEquals($customerToContest, $contestToCustomer->getSymmetricalRelation()); + } + + public function testCompositeForeignKey() + { + $entryTable = $this->databaseMap->getTableByPhpName('ContestBookstoreContestEntry'); + $entryToContest = $entryTable->getRelation('ContestBookstoreContest'); + $contestTable = $this->databaseMap->getTableByPhpName('ContestBookstoreContest'); + $contestToEntry = $contestTable->getRelation('ContestBookstoreContestEntry'); + $this->assertEquals($entryToContest, $contestToEntry->getSymmetricalRelation()); + $this->assertEquals($contestToEntry, $entryToContest->getSymmetricalRelation()); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/map/RelationMapTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/map/RelationMapTest.php index 202755781..31b08fb4f 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/map/RelationMapTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/map/RelationMapTest.php @@ -8,19 +8,20 @@ * @license MIT License */ -require_once 'PHPUnit/Framework/TestCase.php'; +require_once dirname(__FILE__) . '/../../../../runtime/lib/map/DatabaseMap.php'; require_once dirname(__FILE__) . '/../../../../runtime/lib/map/RelationMap.php'; +require_once dirname(__FILE__) . '/../../../../runtime/lib/map/ColumnMap.php'; require_once dirname(__FILE__) . '/../../../../runtime/lib/map/TableMap.php'; /** * Test class for RelationMap. * * @author François Zaninotto - * @version $Id: RelationMapTest.php 1773 2010-05-25 10:25:06Z francois $ + * @version $Id$ * @package runtime.map */ -class RelationMapTest extends PHPUnit_Framework_TestCase -{ +class RelationMapTest extends PHPUnit_Framework_TestCase +{ protected $databaseMap, $relationName, $rmap; protected function setUp() @@ -35,7 +36,7 @@ class RelationMapTest extends PHPUnit_Framework_TestCase { $this->assertEquals($this->relationName, $this->rmap->getName(), 'constructor sets the relation name'); } - + public function testLocalTable() { $this->assertNull($this->rmap->getLocalTable(), 'A new relation has no local table'); @@ -51,12 +52,11 @@ class RelationMapTest extends PHPUnit_Framework_TestCase $this->rmap->setForeignTable($tmap2); $this->assertEquals($tmap2, $this->rmap->getForeignTable(), 'The foreign table is set by setForeignTable()'); } - + public function testProperties() { $properties = array('type', 'onUpdate', 'onDelete'); - foreach ($properties as $property) - { + foreach ($properties as $property) { $getter = 'get' . ucfirst($property); $setter = 'set' . ucfirst($property); $this->assertNull($this->rmap->$getter(), "A new relation has no $property"); @@ -64,7 +64,7 @@ class RelationMapTest extends PHPUnit_Framework_TestCase $this->assertEquals('foo_value', $this->rmap->$getter(), "The $property is set by setType()"); } } - + public function testColumns() { $this->assertEquals(array(), $this->rmap->getLocalColumns(), 'A new relation has no local columns'); diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/map/TableMapTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/map/TableMapTest.php index 42e7e748b..6a7f7b2ba 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/map/TableMapTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/map/TableMapTest.php @@ -8,57 +8,21 @@ * @license MIT License */ -require_once 'PHPUnit/Framework/TestCase.php'; require_once dirname(__FILE__) . '/../../../../runtime/lib/map/ColumnMap.php'; +require_once dirname(__FILE__) . '/../../../../runtime/lib/map/RelationMap.php'; require_once dirname(__FILE__) . '/../../../../runtime/lib/map/TableMap.php'; - -class TestableTableMap extends TableMap -{ - public function hasPrefix($data) - { - return parent::hasPrefix($data); - } - - public function removePrefix($data) - { - return parent::removePrefix($data); - } - - public function normalizeColName($name) - { - return parent::normalizeColName($name); - } -} - -class FooTableMap extends TableMap -{ - public $rmap; - public function buildRelations() - { - $this->rmap = $this->addRelation('Bar', 'Bar', RelationMap::MANY_TO_ONE); - } -} - -class BarTableMap extends TableMap -{ - public function initialize() - { - $this->setName('bar'); - $this->setPhpName('Bar'); - } -} - - +require_once dirname(__FILE__) . '/../../../../runtime/lib/map/DatabaseMap.php'; +require_once dirname(__FILE__) . '/../../../../runtime/lib/exception/PropelException.php'; /** * Test class for TableMap. * * @author François Zaninotto - * @version $Id: TableMapTest.php 1773 2010-05-25 10:25:06Z francois $ + * @version $Id$ * @package runtime.map */ -class TableMapTest extends PHPUnit_Framework_TestCase -{ +class TableMapTest extends PHPUnit_Framework_TestCase +{ protected $databaseMap; protected function setUp() @@ -82,18 +46,17 @@ class TableMapTest extends PHPUnit_Framework_TestCase $this->assertEquals($this->databaseMap, $this->tmap->getDatabaseMap(), 'Constructor can set the database map'); try { $tmap = new TableMap(); - $this->assertTrue(true, 'A table map can be instanciated with no parameters'); + $this->assertTrue(true, 'A table map can be instantiated with no parameters'); } catch (Exception $e) { - $this->fail('A table map can be instanciated with no parameters'); + $this->fail('A table map can be instantiated with no parameters'); } } - + public function testProperties() { $tmap = new TableMap(); $properties = array('name', 'phpName', 'className', 'package'); - foreach ($properties as $property) - { + foreach ($properties as $property) { $getter = 'get' . ucfirst($property); $setter = 'set' . ucfirst($property); $this->assertNull($tmap->$getter(), "A new relation has no $property"); @@ -101,46 +64,43 @@ class TableMapTest extends PHPUnit_Framework_TestCase $this->assertEquals('foo_value', $tmap->$getter(), "The $property is set by setType()"); } } - + public function testHasColumn() { $this->assertFalse($this->tmap->hasColumn('BAR'), 'hascolumn() returns false when the column is not in the table map'); $column = $this->tmap->addColumn('BAR', 'Bar', 'INTEGER'); $this->assertTrue($this->tmap->hasColumn('BAR'), 'hascolumn() returns true when the column is in the table map'); - $this->assertTrue($this->tmap->hasColumn('foo.bar'), 'hascolumn() accepts a denormalized column name'); + $this->assertTrue($this->tmap->hasColumn('foo.BAR'), 'hascolumn() accepts a denormalized column name'); $this->assertFalse($this->tmap->hasColumn('foo.bar', false), 'hascolumn() accepts a $normalize parameter to skip name normalization'); $this->assertTrue($this->tmap->hasColumn('BAR', false), 'hascolumn() accepts a $normalize parameter to skip name normalization'); $this->assertTrue($this->tmap->hasColumn($column), 'hascolumn() accepts a ColumnMap object as parameter'); } - + public function testGetColumn() { $column = $this->tmap->addColumn('BAR', 'Bar', 'INTEGER'); $this->assertEquals($column, $this->tmap->getColumn('BAR'), 'getColumn returns a ColumnMap according to a column name'); - try - { + try { $this->tmap->getColumn('FOO'); $this->fail('getColumn throws an exception when called on an inexistent column'); - } catch(PropelException $e) {} - $this->assertEquals($column, $this->tmap->getColumn('foo.bar'), 'getColumn accepts a denormalized column name'); - try - { + } catch (PropelException $e) {} + $this->assertEquals($column, $this->tmap->getColumn('foo.BAR'), 'getColumn accepts a denormalized column name'); + try { $this->tmap->getColumn('foo.bar', false); $this->fail('getColumn accepts a $normalize parameter to skip name normalization'); - } catch(PropelException $e) {} + } catch (PropelException $e) {} } public function testGetColumnByPhpName() { $column = $this->tmap->addColumn('BAR_BAZ', 'BarBaz', 'INTEGER'); $this->assertEquals($column, $this->tmap->getColumnByPhpName('BarBaz'), 'getColumnByPhpName() returns a ColumnMap according to a column phpName'); - try - { + try { $this->tmap->getColumn('Foo'); $this->fail('getColumnByPhpName() throws an exception when called on an inexistent column'); - } catch(PropelException $e) {} + } catch (PropelException $e) {} } - + public function testGetColumns() { $this->assertEquals(array(), $this->tmap->getColumns(), 'getColumns returns an empty array when no columns were added'); @@ -148,7 +108,7 @@ class TableMapTest extends PHPUnit_Framework_TestCase $column2 = $this->tmap->addColumn('BAZ', 'Baz', 'INTEGER'); $this->assertEquals(array('BAR' => $column1, 'BAZ' => $column2), $this->tmap->getColumns(), 'getColumns returns the columns indexed by name'); } - + public function testAddPrimaryKey() { $column1 = $this->tmap->addPrimaryKey('BAR', 'Bar', 'INTEGER'); @@ -162,7 +122,7 @@ class TableMapTest extends PHPUnit_Framework_TestCase $column5 = $this->tmap->addForeignPrimaryKey('BAZZZZ', 'Bazzzz', 'INTEGER', 'table1', 'column1'); $this->assertTrue($column5->isPrimaryKey(), 'Columns added by way of addForeignPrimaryKey() are primary keys'); } - + public function testGetPrimaryKeyColumns() { $this->assertEquals(array(), $this->tmap->getPrimaryKeyColumns(), 'getPrimaryKeyColumns() returns an empty array by default'); @@ -171,7 +131,7 @@ class TableMapTest extends PHPUnit_Framework_TestCase $expected = array($column1, $column3); $this->assertEquals($expected, $this->tmap->getPrimaryKeyColumns(), 'getPrimaryKeyColumns() returns an array of the table primary keys'); } - + public function testGetPrimaryKeys() { $this->assertEquals(array(), $this->tmap->getPrimaryKeys(), 'getPrimaryKeys() returns an empty array by default'); @@ -180,7 +140,7 @@ class TableMapTest extends PHPUnit_Framework_TestCase $expected = array('BAR' => $column1, 'BAZZ' => $column3); $this->assertEquals($expected, $this->tmap->getPrimaryKeys(), 'getPrimaryKeys() returns an array of the table primary keys'); } - + public function testAddForeignKey() { $column1 = $this->tmap->addForeignKey('BAR', 'Bar', 'INTEGER', 'Table1', 'column1'); @@ -194,7 +154,7 @@ class TableMapTest extends PHPUnit_Framework_TestCase $column5 = $this->tmap->addForeignPrimaryKey('BAZZZZ', 'Bazzzz', 'INTEGER', 'table1', 'column1'); $this->assertTrue($column5->isForeignKey(), 'Columns added by way of addForeignPrimaryKey() are foreign keys'); } - + public function testGetForeignKeys() { $this->assertEquals(array(), $this->tmap->getForeignKeys(), 'getForeignKeys() returns an empty array by default'); @@ -203,15 +163,17 @@ class TableMapTest extends PHPUnit_Framework_TestCase $expected = array('BAR' => $column1, 'BAZZ' => $column3); $this->assertEquals($expected, $this->tmap->getForeignKeys(), 'getForeignKeys() returns an array of the table foreign keys'); } - + + /** + * @expectedException PropelException + */ + public function testLoadWrongRelations() + { + $this->tmap->getRelation('Bar'); + } + public function testLazyLoadRelations() { - try { - $this->tmap->getRelation('Bar'); - $this->fail('getRelation() throws an exception when called on a table with no relations'); - } catch (PropelException $e) { - $this->assertTrue(true, 'getRelation() throws an exception when called on a table with no relations'); - } $foreigntmap = new BarTableMap(); $this->databaseMap->addTableObject($foreigntmap); $localtmap = new FooTableMap(); @@ -219,7 +181,7 @@ class TableMapTest extends PHPUnit_Framework_TestCase $rmap = $localtmap->getRelation('Bar'); $this->assertEquals($rmap, $localtmap->rmap, 'getRelation() returns the relations lazy loaded by buildRelations()'); } - + public function testAddRelation() { $foreigntmap1 = new TableMap('bar'); @@ -232,42 +194,71 @@ class TableMapTest extends PHPUnit_Framework_TestCase $this->rmap2 = $this->tmap->addRelation('Bazz', 'Baz', RelationMap::ONE_TO_MANY); $this->tmap->getRelations(); // now on to the test - $this->assertEquals($this->rmap1->getLocalTable(), $this->tmap, 'adding a relation with HAS_ONE sets the local table to the current table'); + $this->assertEquals($this->rmap1->getLocalTable(), $this->tmap, 'adding a relation with HAS_ONE sets the local table to the current table'); $this->assertEquals($this->rmap1->getForeignTable(), $foreigntmap1, 'adding a relation with HAS_ONE sets the foreign table according to the name given'); $this->assertEquals(RelationMap::MANY_TO_ONE, $this->rmap1->getType(), 'adding a relation with HAS_ONE sets the foreign table type accordingly'); - $this->assertEquals($this->rmap2->getForeignTable(), $this->tmap, 'adding a relation with HAS_MANY sets the foreign table to the current table'); + $this->assertEquals($this->rmap2->getForeignTable(), $this->tmap, 'adding a relation with HAS_MANY sets the foreign table to the current table'); $this->assertEquals($this->rmap2->getLocalTable(), $foreigntmap2, 'adding a relation with HAS_MANY sets the local table according to the name given'); $this->assertEquals(RelationMap::ONE_TO_MANY, $this->rmap2->getType(), 'adding a relation with HAS_MANY sets the foreign table type accordingly'); - + $expectedRelations = array('Bar' => $this->rmap1, 'Bazz' => $this->rmap2); $this->assertEquals($expectedRelations, $this->tmap->getRelations(), 'getRelations() returns an associative array of all the relations'); } + public function testPrimaryStringAddColumn() + { + $this->assertFalse($this->tmap->hasPrimaryStringColumn(), 'hasPrimaryStringColumn() returns false while none set.'); + $this->assertNull($this->tmap->getPrimaryStringColumn(), 'getPrimaryStringColumn() returns null while none set.'); + + $column = $this->tmap->addColumn('FOO', 'Foo', 'VARCHAR'); + $this->assertFalse($this->tmap->hasPrimaryStringColumn(), 'hasPrimaryStringColumn() returns false when no pkStr column is set.'); + $this->assertNull($this->tmap->getPrimaryStringColumn(), 'getPrimaryStringColumn() returns null when no pkStr column is set.'); + + $column = $this->tmap->addColumn('PKSTR', 'pkStr', 'VARCHAR'); + $column->setPrimaryString(true); + $this->assertTrue($this->tmap->hasPrimaryStringColumn(), 'hasPrimaryStringColumn() returns true after adding pkStr column.'); + $this->assertEquals($column, $this->tmap->getPrimaryStringColumn(), 'getPrimaryStringColumn() returns correct column.'); + } + + public function testPrimaryStringAddConfiguredColumn() + { + $this->assertFalse($this->tmap->hasPrimaryStringColumn(), 'hasPrimaryStringColumn() returns false while none set.'); + + $column = new ColumnMap('BAR', $this->tmap); + $column->setPhpName('Bar'); + $column->setType('VARCHAR'); + $column->setPrimaryString(true); + $this->tmap->addConfiguredColumn($column); + + $this->assertTrue($this->tmap->hasPrimaryStringColumn(), 'hasPrimaryStringColumn() returns true after adding pkStr column.'); + $this->assertEquals($column, $this->tmap->getPrimaryStringColumn(), 'getPrimaryStringColumn() returns correct column.'); + } + // deprecated method public function testNormalizeColName() { $tmap = new TestableTableMap(); $this->assertEquals('', $tmap->normalizeColName(''), 'normalizeColName returns an empty string when passed an empty string'); - $this->assertEquals('BAR', $tmap->normalizeColName('bar'), 'normalizeColName uppercases the input'); - $this->assertEquals('BAR_BAZ', $tmap->normalizeColName('bar_baz'), 'normalizeColName does not mind underscores'); + $this->assertEquals('bar', $tmap->normalizeColName('bar'), 'normalizeColName uppercases the input'); + $this->assertEquals('bar_baz', $tmap->normalizeColName('bar_baz'), 'normalizeColName does not mind underscores'); $this->assertEquals('BAR', $tmap->normalizeColName('FOO.BAR'), 'normalizeColName removes table prefix'); $this->assertEquals('BAR', $tmap->normalizeColName('BAR'), 'normalizeColName leaves normalized column names unchanged'); - $this->assertEquals('BAR_BAZ', $tmap->normalizeColName('foo.bar_baz'), 'normalizeColName can do all the above at the same time'); + $this->assertEquals('bar_baz', $tmap->normalizeColName('foo.bar_baz'), 'normalizeColName can do all the above at the same time'); } - + // deprecated method public function testContainsColumn() { $this->assertFalse($this->tmap->containsColumn('BAR'), 'containsColumn returns false when the column is not in the table map'); $column = $this->tmap->addColumn('BAR', 'Bar', 'INTEGER'); $this->assertTrue($this->tmap->containsColumn('BAR'), 'containsColumn returns true when the column is in the table map'); - $this->assertTrue($this->tmap->containsColumn('foo.bar'), 'containsColumn accepts a denormalized column name'); + $this->assertTrue($this->tmap->containsColumn('foo.BAR'), 'containsColumn accepts a denormalized column name'); $this->assertFalse($this->tmap->containsColumn('foo.bar', false), 'containsColumn accepts a $normalize parameter to skip name normalization'); $this->assertTrue($this->tmap->containsColumn('BAR', false), 'containsColumn accepts a $normalize parameter to skip name normalization'); $this->assertTrue($this->tmap->containsColumn($column), 'containsColumn accepts a ColumnMap object as parameter'); } - + // deprecated methods public function testPrefix() { @@ -278,9 +269,45 @@ class TableMapTest extends PHPUnit_Framework_TestCase $this->assertEquals('bar', $tmap->getPrefix(), 'prefix is set by setPrefix()'); $this->assertTrue($tmap->hasPrefix('barbaz'), 'hasPrefix returns true when prefix is set and found in string'); $this->assertFalse($tmap->hasPrefix('baz'), 'hasPrefix returns false when prefix is set and not found in string'); - $this->assertFalse($tmap->hasPrefix('bazbar'), 'hasPrefix returns false when prefix is set and not found anywhere in string'); + $this->assertFalse($tmap->hasPrefix('bazbar'), 'hasPrefix returns false when prefix is set and not found anywhere in string'); $this->assertEquals('baz', $tmap->removePrefix('barbaz'), 'removePrefix returns string without prefix if found at the beginning'); $this->assertEquals('bazbaz', $tmap->removePrefix('bazbaz'), 'removePrefix returns original string when prefix is not found'); $this->assertEquals('bazbar', $tmap->removePrefix('bazbar'), 'removePrefix returns original string when prefix is not found at the beginning'); } } + +class TestableTableMap extends TableMap +{ + public function hasPrefix($data) + { + return parent::hasPrefix($data); + } + + public function removePrefix($data) + { + return parent::removePrefix($data); + } + + public function normalizeColName($name) + { + return parent::normalizeColName($name); + } +} + +class FooTableMap extends TableMap +{ + public $rmap; + public function buildRelations() + { + $this->rmap = $this->addRelation('Bar', 'Bar', RelationMap::MANY_TO_ONE); + } +} + +class BarTableMap extends TableMap +{ + public function initialize() + { + $this->setName('bar'); + $this->setClassName('Bar'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/om/BaseObjectConvertTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/om/BaseObjectConvertTest.php new file mode 100644 index 000000000..151a0523e --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/om/BaseObjectConvertTest.php @@ -0,0 +1,233 @@ +setId(1234); + $publisher->setName('Penguin'); + $author = new Author(); + $author->setId(5678); + $author->setFirstName('George'); + $author->setLastName('Byron'); + $book = new Book(); + $book->setId(9012); + $book->setTitle('Don Juan'); + $book->setISBN('0140422161'); + $book->setPrice(12.99); + $book->setAuthor($author); + $book->setPublisher($publisher); + $this->book = $book; + } + + public function toXmlDataProvider() + { + $expected = << + + 9012 + <![CDATA[Don Juan]]> + + 12.99 + 1234 + 5678 + + 1234 + + + + + + + 5678 + + + + + + + + + + +EOF; + + return array(array($expected)); + } + + /** + * @dataProvider toXmlDataProvider + */ + public function testToXML($expected) + { + $this->assertEquals($expected, $this->book->toXML()); + } + + /** + * @dataProvider toXmlDataProvider + */ + public function testFromXML($expected) + { + $book = new Book(); + $book->fromXML($expected); + // FIXME: fromArray() doesn't take related objects into account + $book->resetModified(); + $author = $this->book->getAuthor(); + $this->book->setAuthor(null); + $this->book->setAuthorId($author->getId()); + $publisher = $this->book->getPublisher(); + $this->book->setPublisher(null); + $this->book->setPublisherId($publisher->getId()); + $this->book->resetModified(); + + $this->assertEquals($this->book, $book); + } + + public function toYamlDataProvider() + { + $expected = <<assertEquals($expected, $this->book->toYAML()); + } + + /** + * @dataProvider toYamlDataProvider + */ + public function testFromYAML($expected) + { + $book = new Book(); + $book->fromYAML($expected); + // FIXME: fromArray() doesn't take related objects into account + $book->resetModified(); + $author = $this->book->getAuthor(); + $this->book->setAuthor(null); + $this->book->setAuthorId($author->getId()); + $publisher = $this->book->getPublisher(); + $this->book->setPublisher(null); + $this->book->setPublisherId($publisher->getId()); + $this->book->resetModified(); + + $this->assertEquals($this->book, $book); + } + + public function toJsonDataProvider() + { + $expected = <<assertEquals($expected, $this->book->toJSON()); + } + + /** + * @dataProvider toJsonDataProvider + */ + public function testfromJSON($expected) + { + $book = new Book(); + $book->fromJSON($expected); + // FIXME: fromArray() doesn't take related objects into account + $book->resetModified(); + $author = $this->book->getAuthor(); + $this->book->setAuthor(null); + $this->book->setAuthorId($author->getId()); + $publisher = $this->book->getPublisher(); + $this->book->setPublisher(null); + $this->book->setPublisherId($publisher->getId()); + $this->book->resetModified(); + + $this->assertEquals($this->book, $book); + } + + public function toCsvDataProvider() + { + $expected = "Id,Title,ISBN,Price,PublisherId,AuthorId,Publisher,Author\r\n9012,Don Juan,0140422161,12.99,1234,5678,\"a:3:{s:2:\\\"Id\\\";i:1234;s:4:\\\"Name\\\";s:7:\\\"Penguin\\\";s:5:\\\"Books\\\";a:1:{s:6:\\\"Book_0\\\";s:11:\\\"*RECURSION*\\\";}}\",\"a:6:{s:2:\\\"Id\\\";i:5678;s:9:\\\"FirstName\\\";s:6:\\\"George\\\";s:8:\\\"LastName\\\";s:5:\\\"Byron\\\";s:5:\\\"Email\\\";N;s:3:\\\"Age\\\";N;s:5:\\\"Books\\\";a:1:{s:6:\\\"Book_0\\\";s:11:\\\"*RECURSION*\\\";}}\"\r\n"; + + return array(array($expected)); + } + + /** + * @dataProvider toCsvDataProvider + */ + public function testToCSV($expected) + { + $this->assertEquals($expected, $this->book->toCSV()); + } + + /** + * @dataProvider toCsvDataProvider + */ + public function testfromCSV($expected) + { + $book = new Book(); + $book->fromCSV($expected); + // FIXME: fromArray() doesn't take related objects into account + $book->resetModified(); + $author = $this->book->getAuthor(); + $this->book->setAuthor(null); + $this->book->setAuthorId($author->getId()); + $publisher = $this->book->getPublisher(); + $this->book->setPublisher(null); + $this->book->setPublisherId($publisher->getId()); + $this->book->resetModified(); + + $this->assertEquals($this->book, $book); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/om/BaseObjectHashCodeTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/om/BaseObjectHashCodeTest.php new file mode 100644 index 000000000..20e3545d1 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/om/BaseObjectHashCodeTest.php @@ -0,0 +1,100 @@ +setTitle('Foo5'); + $book1->setISBN('1234'); + + $author = new Author(); + $author->setFirstName('JAne'); + $author->setLastName('JAne'); + $author->addBook($book1); + + $a = clone $author; + $a->hashCode(); + + $this->assertEquals($author, $a); + } + + public function testSavedObjectCallingHashCodeIsNotChangingObject() + { + $book1 = new Book(); + $book1->setTitle('Foo5'); + $book1->setISBN('1234'); + + $author = new Author(); + $author->setFirstName('JAne'); + $author->setLastName('JAne'); + $author->addBook($book1); + $author->save(); + + $a = clone $author; + $a->hashCode(); + + $this->assertEquals($author, $a); + } + + public function testUnsavedObjectCreatesSameHashForIdenticalObjects() + { + $book1 = new Book(); + $book1->setTitle('Foo5'); + $book1->setISBN('1234'); + + $author1 = new Author(); + $author1->setFirstName('JAne'); + $author1->setLastName('JAne'); + $author1->addBook($book1); + + $author2 = new Author(); + $author2->setFirstName('JAne'); + $author2->setLastName('JAne'); + $author2->addBook($book1); + + $this->assertEquals($author1->hashCode(), $author2->hashCode()); + } + + /** + * Primary key should differ + */ + public function testSavedObjectCreatesDifferentHashForIdenticalObjects() + { + $book1 = new Book(); + $book1->setTitle('Foo5'); + $book1->setISBN('1234'); + + $author1 = new Author(); + $author1->setFirstName('JAne'); + $author1->setLastName('JAne'); + $author1->addBook($book1); + $author1->save(); + + $author2 = new Author(); + $author2->setFirstName('JAne'); + $author2->setLastName('JAne'); + $author2->addBook($book1); + $author2->save(); + + $this->assertNotEquals($author1->hashCode(), $author2->hashCode()); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/om/BaseObjectSerializeTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/om/BaseObjectSerializeTest.php index 16a6fb836..9eef5b89c 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/om/BaseObjectSerializeTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/om/BaseObjectSerializeTest.php @@ -8,8 +8,8 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; -require_once 'tools/helpers/bookstore/BookstoreDataPopulator.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreDataPopulator.php'; /** * Test class for BaseObject serialization. @@ -20,76 +20,78 @@ require_once 'tools/helpers/bookstore/BookstoreDataPopulator.php'; */ class BaseObjectSerializeTest extends BookstoreTestBase { - public function testSerializeEmptyObject() - { - $book = new Book(); - $sb = serialize($book); - $this->assertEquals($book, unserialize($sb)); - } - - public function testSerializePopulatedObject() - { - $book = new Book(); - $book->setTitle('Foo1'); - $book->setISBN('1234'); - $sb = serialize($book); - $this->assertEquals($book, unserialize($sb)); - } - - public function testSerializePersistedObject() - { - $book = new Book(); - $book->setTitle('Foo2'); - $book->setISBN('1234'); - $book->save(); - $sb = serialize($book); - $this->assertEquals($book, unserialize($sb)); - } - - public function testSerializeHydratedObject() - { - $book = new Book(); - $book->setTitle('Foo3'); - $book->setISBN('1234'); - $book->save(); - BookPeer::clearInstancePool(); - - $book = BookQuery::create()->findOneByTitle('Foo3'); - $sb = serialize($book); - $this->assertEquals($book, unserialize($sb)); - } - - public function testSerializeObjectWithRelations() - { - $author = new Author(); - $author->setFirstName('John'); - $book = new Book(); - $book->setTitle('Foo4'); - $book->setISBN('1234'); - $book->setAuthor($author); - $book->save(); - $b = clone $book; - $sb = serialize($b); - $book->clearAllReferences(); - $this->assertEquals($book, unserialize($sb)); - } - - public function testSerializeObjectWithCollections() - { - $book1 = new Book(); - $book1->setTitle('Foo5'); - $book1->setISBN('1234'); - $book2 = new Book(); - $book2->setTitle('Foo6'); - $book2->setISBN('1234'); - $author = new Author(); - $author->setFirstName('JAne'); - $author->addBook($book1); - $author->addBook($book2); - $author->save(); - $a = clone $author; - $sa = serialize($a); - $author->clearAllReferences(); - $this->assertEquals($author, unserialize($sa)); - } -} \ No newline at end of file + public function testSerializeEmptyObject() + { + $book = new Book(); + $sb = serialize($book); + $this->assertEquals($book, unserialize($sb)); + } + + public function testSerializePopulatedObject() + { + $book = new Book(); + $book->setTitle('Foo1'); + $book->setISBN('1234'); + $sb = serialize($book); + $this->assertEquals($book, unserialize($sb)); + } + + public function testSerializePersistedObject() + { + $book = new Book(); + $book->setTitle('Foo2'); + $book->setISBN('1234'); + $book->save(); + $sb = serialize($book); + $this->assertEquals($book, unserialize($sb)); + } + + public function testSerializeHydratedObject() + { + $book = new Book(); + $book->setTitle('Foo3'); + $book->setISBN('1234'); + $book->save(); + BookPeer::clearInstancePool(); + + $book = BookQuery::create()->findOneByTitle('Foo3'); + $sb = serialize($book); + $this->assertEquals($book, unserialize($sb)); + } + + public function testSerializeObjectWithRelations() + { + $author = new Author(); + $author->setFirstName('John'); + $author->setLastName('Doe'); + $book = new Book(); + $book->setTitle('Foo4'); + $book->setISBN('1234'); + $book->setAuthor($author); + $book->save(); + $b = clone $book; + $sb = serialize($b); + $book->clearAllReferences(); + $this->assertEquals($book, unserialize($sb)); + } + + public function testSerializeObjectWithCollections() + { + $book1 = new Book(); + $book1->setTitle('Foo5'); + $book1->setISBN('1234'); + $book2 = new Book(); + $book2->setTitle('Foo6'); + $book2->setISBN('1234'); + $author = new Author(); + $author->setFirstName('JAne'); + $author->setLastName('JAne'); + $author->addBook($book1); + $author->addBook($book2); + $author->save(); + $a = clone $author; + $sa = serialize($a); + $author->clearAllReferences(); + $this->assertEquals($author, unserialize($sa)); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/om/BaseObjectTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/om/BaseObjectTest.php index dd3f4ebe2..c3eed1cf5 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/om/BaseObjectTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/om/BaseObjectTest.php @@ -8,7 +8,6 @@ * @license MIT License */ -require_once 'PHPUnit/Framework/TestCase.php'; require_once dirname(__FILE__) . '/../../../../runtime/lib/om/BaseObject.php'; /** @@ -18,52 +17,52 @@ require_once dirname(__FILE__) . '/../../../../runtime/lib/om/BaseObject.php'; * @version $Id: BaseObjectTest.php 1347 2009-12-03 21:06:36Z francois $ * @package runtime.om */ -class BaseObjectTest extends PHPUnit_Framework_TestCase -{ - public function testGetVirtualColumns() - { - $b = new TestableBaseObject(); - $this->assertEquals(array(), $b->getVirtualColumns(), 'getVirtualColumns() returns an empty array for new objects'); - $b->virtualColumns = array('foo' => 'bar'); - $this->assertEquals(array('foo' => 'bar'), $b->getVirtualColumns(), 'getVirtualColumns() returns an associative array of virtual columns'); - } +class BaseObjectTest extends PHPUnit_Framework_TestCase +{ + public function testGetVirtualColumns() + { + $b = new TestableBaseObject(); + $this->assertEquals(array(), $b->getVirtualColumns(), 'getVirtualColumns() returns an empty array for new objects'); + $b->virtualColumns = array('foo' => 'bar'); + $this->assertEquals(array('foo' => 'bar'), $b->getVirtualColumns(), 'getVirtualColumns() returns an associative array of virtual columns'); + } - public function testHasVirtualColumn() - { - $b = new TestableBaseObject(); - $this->assertFalse($b->hasVirtualColumn('foo'), 'hasVirtualColumn() returns false if the virtual column is not set'); - $b->virtualColumns = array('foo' => 'bar'); - $this->assertTrue($b->hasVirtualColumn('foo'), 'hasVirtualColumn() returns true if the virtual column is set'); - } - - /** - * @expectedException PropelException - */ - public function testGetVirtualColumnWrongKey() - { - $b = new TestableBaseObject(); - $b->getVirtualColumn('foo'); - } + public function testHasVirtualColumn() + { + $b = new TestableBaseObject(); + $this->assertFalse($b->hasVirtualColumn('foo'), 'hasVirtualColumn() returns false if the virtual column is not set'); + $b->virtualColumns = array('foo' => 'bar'); + $this->assertTrue($b->hasVirtualColumn('foo'), 'hasVirtualColumn() returns true if the virtual column is set'); + } - public function testGetVirtualColumn() - { - $b = new TestableBaseObject(); - $b->virtualColumns = array('foo' => 'bar'); - $this->assertEquals('bar', $b->getVirtualColumn('foo'), 'getVirtualColumn() returns a virtual column value based on its key'); - } - - public function testSetVirtualColumn() - { - $b = new TestableBaseObject(); - $b->setVirtualColumn('foo', 'bar'); - $this->assertEquals('bar', $b->getVirtualColumn('foo'), 'setVirtualColumn() sets a virtual column value based on its key'); - $b->setVirtualColumn('foo', 'baz'); - $this->assertEquals('baz', $b->getVirtualColumn('foo'), 'setVirtualColumn() can modify the value of an existing virtual column'); - $this->assertEquals($b, $b->setVirtualColumn('foo', 'bar'), 'setVirtualColumn() returns the current object'); - } + /** + * @expectedException PropelException + */ + public function testGetVirtualColumnWrongKey() + { + $b = new TestableBaseObject(); + $b->getVirtualColumn('foo'); + } + + public function testGetVirtualColumn() + { + $b = new TestableBaseObject(); + $b->virtualColumns = array('foo' => 'bar'); + $this->assertEquals('bar', $b->getVirtualColumn('foo'), 'getVirtualColumn() returns a virtual column value based on its key'); + } + + public function testSetVirtualColumn() + { + $b = new TestableBaseObject(); + $b->setVirtualColumn('foo', 'bar'); + $this->assertEquals('bar', $b->getVirtualColumn('foo'), 'setVirtualColumn() sets a virtual column value based on its key'); + $b->setVirtualColumn('foo', 'baz'); + $this->assertEquals('baz', $b->getVirtualColumn('foo'), 'setVirtualColumn() can modify the value of an existing virtual column'); + $this->assertEquals($b, $b->setVirtualColumn('foo', 'bar'), 'setVirtualColumn() returns the current object'); + } } class TestableBaseObject extends BaseObject { - public $virtualColumns = array(); -} \ No newline at end of file + public $virtualColumns = array(); +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelCSVParserTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelCSVParserTest.php new file mode 100644 index 000000000..0cf4d8d4c --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelCSVParserTest.php @@ -0,0 +1,114 @@ + 0, 'b' => null, 'c' => ''), "a,b,c\r\n0,N;,\r\n", 'associative array with empty values'), + array(array('a' => 1, 'b' => 'bar'), "a,b\r\n1,bar\r\n", 'associative array with strings'), + array(array('a' => '

Hello, World!

'), "a\r\n\"

Hello, World!

\"\r\n", 'associative array with code'), + array(array('a' => 1, 'b' => array('foo' => 2)), "a,b\r\n1,\"a:1:{s:3:\\\"foo\\\";i:2;}\"\r\n", 'nested associative arrays'), + array(array('Id' => 123, 'Title' => 'Pride and Prejudice', 'AuthorId' => 456, 'ISBN' => '0553213105', 'Author' => array('Id' => 456, 'FirstName' => 'Jane', 'LastName' => 'Austen')), "Id,Title,AuthorId,ISBN,Author\r\n123,Pride and Prejudice,456,0553213105,\"a:3:{s:2:\\\"Id\\\";i:456;s:9:\\\"FirstName\\\";s:4:\\\"Jane\\\";s:8:\\\"LastName\\\";s:6:\\\"Austen\\\";}\"\r\n", 'array resulting from an object conversion'), + array(array('a1' => 1, 'b2' => 2), "a1,b2\r\n1,2\r\n", 'keys with numbers'), + ); + } + + /** + * @dataProvider arrayCsvConversionDataProvider + */ + public function testFromArray($arrayData, $csvData, $type) + { + $parser = new PropelCSVParser(); + $this->assertEquals($csvData, $parser->fromArray($arrayData), 'PropelCSVParser::fromArray() converts from ' . $type . ' correctly'); + } + + /** + * @dataProvider arrayCsvConversionDataProvider + */ + public function testToCSV($arrayData, $csvData, $type) + { + $parser = new PropelCSVParser(); + $this->assertEquals($csvData, $parser->toCSV($arrayData), 'PropelCSVParser::toCSV() converts from ' . $type . ' correctly'); + } + + /** + * @dataProvider arrayCsvConversionDataProvider + */ + public function testToArray($arrayData, $csvData, $type) + { + $parser = new PropelCSVParser(); + $this->assertEquals($arrayData, $parser->toArray($csvData), 'PropelCSVParser::toArray() converts to ' . $type . ' correctly'); + } + + /** + * @dataProvider arrayCsvConversionDataProvider + */ + public function testFromCSV($arrayData, $csvData, $type) + { + $parser = new PropelCSVParser(); + $this->assertEquals($arrayData, $parser->fromCSV($csvData), 'PropelCSVParser::fromCSV() converts to ' . $type . ' correctly'); + } + + public static function listToCSVDataProvider() + { + $list = array( + array('Id' => 123, 'Title' => 'Pride and Prejudice', 'AuthorId' => 456, 'ISBN' => '0553213105', 'Author' => array('Id' => 456, 'FirstName' => 'Jane', 'LastName' => 'Austen')), + array('Id' => 82, 'Title' => 'Anna Karenina', 'AuthorId' => 543, 'ISBN' => '0143035002', 'Author' => array('Id' => 543, 'FirstName' => 'Leo', 'LastName' => 'Tolstoi')), + array('Id' => 567, 'Title' => 'War and Peace', 'AuthorId' => 543, 'ISBN' => '067003469X', 'Author' => array('Id' => 543, 'FirstName' => 'Leo', 'LastName' => 'Tolstoi')), + ); + $heading = <<lineTerminator = " +"; + $this->assertEquals($csv, $parser->toCSV($list, true, false)); + $this->assertEquals($heading . $csv, $parser->toCSV($list, true, true)); + } + + /** + * @dataProvider listToCSVDataProvider + */ + public function testCSVToList($list, $heading, $csv) + { + $parser = new PropelCSVParser(); + $parser->lineTerminator = " +"; + $this->assertEquals($list, $parser->fromCSV($heading . $csv, true, true)); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelJSONParserTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelJSONParserTest.php new file mode 100644 index 000000000..383fddc9d --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelJSONParserTest.php @@ -0,0 +1,106 @@ + 1, 'b' => 2), '{"a":1,"b":2}', 'associative array'), + array(array('a' => 0, 'b' => null, 'c' => ''), '{"a":0,"b":null,"c":""}', 'associative array with empty values'), + array(array('a' => 1, 'b' => 'bar'), '{"a":1,"b":"bar"}', 'associative array with strings'), + array(array('a' => '

Hello, World!

'), '{"a":"

Hello, World!<\/p><\/body><\/html>"}', 'associative array with code'), + array(array('a' => 1, 'b' => array('foo' => 2)), '{"a":1,"b":{"foo":2}}', 'nested associative arrays'), + array(array('Id' => 123, 'Title' => 'Pride and Prejudice', 'AuthorId' => 456, 'ISBN' => '0553213105', 'Author' => array('Id' => 456, 'FirstName' => 'Jane', 'LastName' => 'Austen')), '{"Id":123,"Title":"Pride and Prejudice","AuthorId":456,"ISBN":"0553213105","Author":{"Id":456,"FirstName":"Jane","LastName":"Austen"}}', 'array resulting from an object conversion'), + array(array('a1' => 1, 'b2' => 2), '{"a1":1,"b2":2}', 'keys with numbers'), + ); + } + + /** + * @dataProvider arrayJsonConversionDataProvider + */ + public function testFromArray($arrayData, $jsonData, $type) + { + $parser = new PropelJSONParser(); + $this->assertEquals($jsonData, $parser->fromArray($arrayData), 'PropelJSONParser::fromArray() converts from ' . $type . ' correctly'); + } + + /** + * @dataProvider arrayJsonConversionDataProvider + */ + public function testToJSON($arrayData, $jsonData, $type) + { + $parser = new PropelJSONParser(); + $this->assertEquals($jsonData, $parser->toJSON($arrayData), 'PropelJSONParser::toJSON() converts from ' . $type . ' correctly'); + } + + /** + * @dataProvider arrayJsonConversionDataProvider + */ + public function testToArray($arrayData, $jsonData, $type) + { + $parser = new PropelJSONParser(); + $this->assertEquals($arrayData, $parser->toArray($jsonData), 'PropelJSONParser::toArray() converts to ' . $type . ' correctly'); + } + + /** + * @dataProvider arrayJsonConversionDataProvider + */ + public function testFromJSON($arrayData, $jsonData, $type) + { + $parser = new PropelJSONParser(); + $this->assertEquals($arrayData, $parser->fromJSON($jsonData), 'PropelJSONParser::fromJSON() converts to ' . $type . ' correctly'); + } + + public static function listToJSONDataProvider() + { + $list = array( + 'book0' => array('Id' => 123, 'Title' => 'Pride and Prejudice', 'AuthorId' => 456, 'ISBN' => '0553213105', 'Author' => array('Id' => 456, 'FirstName' => 'Jane', 'LastName' => 'Austen')), + 'book1' => array('Id' => 82, 'Title' => 'Anna Karenina', 'AuthorId' => 543, 'ISBN' => '0143035002', 'Author' => array('Id' => 543, 'FirstName' => 'Leo', 'LastName' => 'Tolstoi')), + 'book2' => array('Id' => 567, 'Title' => 'War and Peace', 'AuthorId' => 543, 'ISBN' => '067003469X', 'Author' => array('Id' => 543, 'FirstName' => 'Leo', 'LastName' => 'Tolstoi')), + ); + $json = <<assertEquals($json, $parser->toJSON($list)); + } + + /** + * @dataProvider listToJSONDataProvider + */ + public function testJSONToList($list, $json) + { + $parser = new PropelJSONParser(); + $this->assertEquals($list, $parser->fromJSON($json)); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelParserTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelParserTest.php new file mode 100644 index 000000000..dd0b1253e --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelParserTest.php @@ -0,0 +1,64 @@ +assertTrue($parser instanceof PropelXMLParser); + } + + /** + * @expectedException PropelException + */ + public function testGetParserThrowsExceptionOnWrongParser() + { + $parser = PropelParser::getParser('Foo'); + } + + public function testLoad() + { + $fixtureFile = dirname(__FILE__) . '/fixtures/test_data.xml'; + $parser = PropelParser::getParser('XML'); + $content = $parser->load($fixtureFile); + $eol = PHP_EOL; + $expectedContent = <<{$eol} + + + + +EOF; + $this->assertEquals($expectedContent, $content, 'PropelParser::load() executes PHP code in files'); + } + + public function testDump() + { + $testContent = "Foo Content"; + $testFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'propel_test_' . microtime(); + $parser = PropelParser::getParser('XML'); + $parser->dump($testContent, $testFile); + $content = file_get_contents($testFile); + $this->assertEquals($testContent, $content); + unlink($testFile); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelXMLParserTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelXMLParserTest.php new file mode 100644 index 000000000..6d2feee82 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelXMLParserTest.php @@ -0,0 +1,198 @@ + + +", 'empty array'), + array(array('a' => 1, 'b' => 2), " + + 1 + 2 + +", 'associative array'), + array(array('a' => 0, 'b' => null, 'c' => ''), " + + 0 + + + +", 'associative array with empty values'), + array(array('a' => 1, 'b' => 'bar'), " + + 1 + + +", 'associative array with strings'), + array(array('a' => '

Hello, World!

'), " + + + +", 'associative array with code'), + array(array('a' => 1, 'b' => array('foo' => 2)), " + + 1 + + 2 + + +", 'nested associative arrays'), + array(array('Id' => 123, 'Title' => 'Pride and Prejudice', 'AuthorId' => 456, 'ISBN' => '0553213105', 'Author' => array('Id' => 456, 'FirstName' => 'Jane', 'LastName' => 'Austen')), " + + 123 + <![CDATA[Pride and Prejudice]]> + 456 + + + 456 + + + + +", 'array resulting from an object conversion'), + array(array('a1' => 1, 'b2' => 2), " + + 1 + 2 + +", 'keys with numbers'), + ); + } + + /** + * @dataProvider arrayXmlConversionDataProvider + */ + public function testFromArray($arrayData, $xmlData, $type) + { + $parser = new PropelXMLParser(); + $this->assertEquals($xmlData, $parser->fromArray($arrayData), 'PropelXMLParser::fromArray() converts from ' . $type . ' correctly'); + } + + /** + * @dataProvider arrayXmlConversionDataProvider + */ + public function testToXML($arrayData, $xmlData, $type) + { + $parser = new PropelXMLParser(); + $this->assertEquals($xmlData, $parser->toXML($arrayData), 'PropelXMLParser::toXML() converts from ' . $type . ' correctly'); + } + + /** + * @dataProvider arrayXmlConversionDataProvider + */ + public function testToArray($arrayData, $xmlData, $type) + { + $parser = new PropelXMLParser(); + $this->assertEquals($arrayData, $parser->toArray($xmlData), 'PropelXMLParser::toArray() converts to ' . $type . ' correctly'); + } + + /** + * @dataProvider arrayXmlConversionDataProvider + */ + public function testFromXML($arrayData, $xmlData, $type) + { + $parser = new PropelXMLParser(); + $this->assertEquals($arrayData, $parser->fromXML($xmlData), 'PropelXMLParser::fromXML() converts to ' . $type . ' correctly'); + } + + public function testToArrayRespectsNullValues() + { + $xmlData = " + + +<![CDATA[]]> +"; + $parser = new PropelXMLParser(); + $data = $parser->fromXML($xmlData); + $this->assertNull($data['Id']); + $this->assertSame('', $data['Title']); + } + + public static function listToXMLDataProvider() + { + $list = array( + 'book0' => array('Id' => 123, 'Title' => 'Pride and Prejudice', 'AuthorId' => 456, 'ISBN' => '0553213105', 'Author' => array('Id' => 456, 'FirstName' => 'Jane', 'LastName' => 'Austen')), + 'book1' => array('Id' => 82, 'Title' => 'Anna Karenina', 'AuthorId' => 543, 'ISBN' => '0143035002', 'Author' => array('Id' => 543, 'FirstName' => 'Leo', 'LastName' => 'Tolstoi')), + 'book2' => array('Id' => 567, 'Title' => 'War and Peace', 'AuthorId' => 543, 'ISBN' => '067003469X', 'Author' => array('Id' => 543, 'FirstName' => 'Leo', 'LastName' => 'Tolstoi')), + ); + $xml = << + + + 123 + <![CDATA[Pride and Prejudice]]> + 456 + + + 456 + + + + + + 82 + <![CDATA[Anna Karenina]]> + 543 + + + 543 + + + + + + 567 + <![CDATA[War and Peace]]> + 543 + + + 543 + + + + + + +EOF; + + return array(array($list, $xml)); + } + + /** + * @dataProvider listToXMLDataProvider + */ + public function testListToXML($list, $xml) + { + $parser = new PropelXMLParser(); + $this->assertEquals($xml, $parser->listToXML($list)); + } + + /** + * @dataProvider listToXMLDataProvider + */ + public function testXMLToList($list, $xml) + { + $parser = new PropelXMLParser(); + $this->assertEquals($list, $parser->fromXML($xml)); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelYAMLParserTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelYAMLParserTest.php new file mode 100644 index 000000000..9d5b96eb2 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/parser/PropelYAMLParserTest.php @@ -0,0 +1,173 @@ + 1, 'b' => 2), +"a: 1 +b: 2 +", 'associative array'), + array(array('a' => 0, 'b' => null, 'c' => ''), "a: 0 +b: null +c: '' +", 'associative array with empty values'), + array(array('a' => 1, 'b' => 'bar'), +"a: 1 +b: bar +", 'associative array with strings'), + array(array('a' => '

Hello, World!

'), +"a: '

Hello, World!

' +", 'associative array with code'), + array(array('a' => 1, 'b' => array('foo' => 2)), +"a: 1 +b: + foo: 2 +", 'nested associative arrays'), + array(array('Id' => 123, 'Title' => 'Pride and Prejudice', 'AuthorId' => 456, 'ISBN' => '0553213105', 'Author' => array('Id' => 456, 'FirstName' => 'Jane', 'LastName' => 'Austen')), +"Id: 123 +Title: 'Pride and Prejudice' +AuthorId: 456 +ISBN: '0553213105' +Author: + Id: 456 + FirstName: Jane + LastName: Austen +", 'array resulting from an object conversion'), + array(array('a1' => 1, 'b2' => 2), "a1: 1 +b2: 2 +", 'keys with numbers'), + ); + } + + /** + * @dataProvider arrayYAMLConversionDataProvider + */ + public function testFromArray($arrayData, $YAMLData, $type) + { + $parser = new PropelYAMLParser(); + $this->assertEquals($YAMLData, $parser->fromArray($arrayData), 'PropelYAMLParser::fromArray() converts from ' . $type . ' correctly'); + } + + /** + * @dataProvider arrayYAMLConversionDataProvider + */ + public function testToYAML($arrayData, $YAMLData, $type) + { + $parser = new PropelYAMLParser(); + $this->assertEquals($YAMLData, $parser->toYAML($arrayData), 'PropelYAMLParser::toYAML() converts from ' . $type . ' correctly'); + } + + /** + * @dataProvider arrayYAMLConversionDataProvider + */ + public function testToArray($arrayData, $YAMLData, $type) + { + $parser = new PropelYAMLParser(); + $this->assertEquals($arrayData, $parser->toArray($YAMLData), 'PropelYAMLParser::toArray() converts to ' . $type . ' correctly'); + } + + /** + * @dataProvider arrayYAMLConversionDataProvider + */ + public function testFromYAML($arrayData, $YAMLData, $type) + { + $parser = new PropelYAMLParser(); + $this->assertEquals($arrayData, $parser->fromYAML($YAMLData), 'PropelYAMLParser::fromYAML() converts to ' . $type . ' correctly'); + } + + public static function listToYAMLDataProvider() + { + $list = array( + 'book0' => array('Id' => 123, 'Title' => 'Pride and Prejudice', 'AuthorId' => 456, 'ISBN' => '0553213105', 'Author' => array('Id' => 456, 'FirstName' => 'Jane', 'LastName' => 'Austen')), + 'book1' => array('Id' => 82, 'Title' => 'Anna Karenina', 'AuthorId' => 543, 'ISBN' => '0143035002', 'Author' => array('Id' => 543, 'FirstName' => 'Leo', 'LastName' => 'Tolstoi')), + 'book2' => array('Id' => 567, 'Title' => 'War and Peace', 'AuthorId' => 543, 'ISBN' => '067003469X', 'Author' => array('Id' => 543, 'FirstName' => 'Leo', 'LastName' => 'Tolstoi')), + ); + $yaml = <<assertEquals($yaml, $parser->toYAML($list)); + } + + /** + * @dataProvider listToYAMLDataProvider + */ + public function testYAMLToList($list, $yaml) + { + $parser = new PropelYAMLParser(); + $this->assertEquals($list, $parser->fromYAML($yaml)); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/parser/fixtures/test_data.xml b/airtime_mvc/library/propel/test/testsuite/runtime/parser/fixtures/test_data.xml new file mode 100644 index 000000000..6026f8513 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/parser/fixtures/test_data.xml @@ -0,0 +1,6 @@ +' . PHP_EOL ?> + + + + + diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaCombineTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaCombineTest.php index d5cec12ea..df0b47cb1 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaCombineTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaCombineTest.php @@ -8,18 +8,17 @@ * @license MIT License */ -require_once 'tools/helpers/BaseTestCase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/BaseTestCase.php'; require_once dirname(__FILE__) . '/../../../../runtime/lib/query/Criteria.php'; require_once dirname(__FILE__) . '/../../../../runtime/lib/util/BasePeer.php'; -set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes"); -Propel::init('fixtures/bookstore/build/conf/bookstore-conf.php'); +Propel::init(dirname(__FILE__) . '/../../../fixtures/bookstore/build/conf/bookstore-conf.php'); /** * Test class for Criteria combinations. * * @author Francois Zaninotto - * @version $Id: CriteriaCombineTest.php 1773 2010-05-25 10:25:06Z francois $ + * @version $Id$ * @package runtime.query */ class CriteriaCombineTest extends BaseTestCase @@ -151,10 +150,10 @@ class CriteriaCombineTest extends BaseTestCase $cn1 = $this->c->getNewCriterion("INVOICE.COST", 1000, Criteria::GREATER_EQUAL); $cn2 = $this->c->getNewCriterion("INVOICE.COST", 5000, Criteria::LESS_EQUAL); $this->c->add($cn1->addAnd($cn2)); - + $expect = "SELECT FROM INVOICE WHERE (INVOICE.COST>=:p1 AND INVOICE.COST<=:p2)"; $expect_params = array( - array('table' => 'INVOICE', 'column' => 'COST', 'value' => 1000), + array('table' => 'INVOICE', 'column' => 'COST', 'value' => 1000), array('table' => 'INVOICE', 'column' => 'COST', 'value' => 5000), ); @@ -185,10 +184,10 @@ class CriteriaCombineTest extends BaseTestCase "SELECT FROM INVOICE WHERE ((INVOICE.COST>=:p1 AND INVOICE.COST<=:p2) OR (INVOICE.COST>=:p3 AND INVOICE.COST<=:p4))"; $expect_params = array( - array('table' => 'INVOICE', 'column' => 'COST', 'value' => '1000'), - array('table' => 'INVOICE', 'column' => 'COST', 'value' => '2000'), - array('table' => 'INVOICE', 'column' => 'COST', 'value' => '8000'), - array('table' => 'INVOICE', 'column' => 'COST', 'value' => '9000'), + array('table' => 'INVOICE', 'column' => 'COST', 'value' => '1000'), + array('table' => 'INVOICE', 'column' => 'COST', 'value' => '2000'), + array('table' => 'INVOICE', 'column' => 'COST', 'value' => '8000'), + array('table' => 'INVOICE', 'column' => 'COST', 'value' => '9000'), ); try { @@ -202,16 +201,16 @@ class CriteriaCombineTest extends BaseTestCase $this->assertEquals($expect_params, $params); } - public function testCombineCriterionAndSimple() - { + public function testCombineCriterionAndSimple() + { $this->c->addCond('cond1', "INVOICE.COST", "1000", Criteria::GREATER_EQUAL); $this->c->addCond('cond2', "INVOICE.COST", "2000", Criteria::LESS_EQUAL); $this->c->combine(array('cond1', 'cond2'), Criteria::LOGICAL_AND); $expect = "SELECT FROM INVOICE WHERE (INVOICE.COST>=:p1 AND INVOICE.COST<=:p2)"; $expect_params = array( - array('table' => 'INVOICE', 'column' => 'COST', 'value' => '1000'), - array('table' => 'INVOICE', 'column' => 'COST', 'value' => '2000'), + array('table' => 'INVOICE', 'column' => 'COST', 'value' => '1000'), + array('table' => 'INVOICE', 'column' => 'COST', 'value' => '2000'), ); $params = array(); @@ -219,10 +218,10 @@ class CriteriaCombineTest extends BaseTestCase $this->assertEquals($expect, $result); $this->assertEquals($expect_params, $params); - } + } - public function testCombineCriterionAndLessSimple() - { + public function testCombineCriterionAndLessSimple() + { $this->c->addCond('cond1', "INVOICE.COST1", "1000", Criteria::GREATER_EQUAL); $this->c->addCond('cond2', "INVOICE.COST2", "2000", Criteria::LESS_EQUAL); $this->c->add("INVOICE.COST3", "8000", Criteria::GREATER_EQUAL); @@ -231,10 +230,10 @@ class CriteriaCombineTest extends BaseTestCase $expect = "SELECT FROM INVOICE WHERE INVOICE.COST3>=:p1 AND (INVOICE.COST1>=:p2 AND INVOICE.COST2<=:p3) AND INVOICE.COST4<=:p4"; $expect_params = array( - array('table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'), - array('table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'), - array('table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'), - array('table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000'), + array('table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'), + array('table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'), + array('table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'), + array('table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000'), ); $params = array(); @@ -242,10 +241,10 @@ class CriteriaCombineTest extends BaseTestCase $this->assertEquals($expect, $result); $this->assertEquals($expect_params, $params); - } + } - public function testCombineCriterionAndMultiple() - { + public function testCombineCriterionAndMultiple() + { $this->c->addCond('cond1',"INVOICE.COST1", "1000", Criteria::GREATER_EQUAL); $this->c->addCond('cond2', "INVOICE.COST2", "2000", Criteria::LESS_EQUAL); $this->c->addCond('cond3', "INVOICE.COST3", "8000", Criteria::GREATER_EQUAL); @@ -254,10 +253,10 @@ class CriteriaCombineTest extends BaseTestCase $expect = "SELECT FROM INVOICE WHERE (((INVOICE.COST1>=:p1 AND INVOICE.COST2<=:p2) AND INVOICE.COST3>=:p3) AND INVOICE.COST4<=:p4)"; $expect_params = array( - array('table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'), - array('table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'), - array('table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'), - array('table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000'), + array('table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'), + array('table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'), + array('table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'), + array('table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000'), ); $params = array(); @@ -265,18 +264,18 @@ class CriteriaCombineTest extends BaseTestCase $this->assertEquals($expect, $result); $this->assertEquals($expect_params, $params); - } + } - public function testCombineCriterionOrSimple() - { + public function testCombineCriterionOrSimple() + { $this->c->addCond('cond1', "INVOICE.COST", "1000", Criteria::GREATER_EQUAL); $this->c->addCond('cond2', "INVOICE.COST", "2000", Criteria::LESS_EQUAL); $this->c->combine(array('cond1', 'cond2'), Criteria::LOGICAL_OR); $expect = "SELECT FROM INVOICE WHERE (INVOICE.COST>=:p1 OR INVOICE.COST<=:p2)"; $expect_params = array( - array('table' => 'INVOICE', 'column' => 'COST', 'value' => '1000'), - array('table' => 'INVOICE', 'column' => 'COST', 'value' => '2000'), + array('table' => 'INVOICE', 'column' => 'COST', 'value' => '1000'), + array('table' => 'INVOICE', 'column' => 'COST', 'value' => '2000'), ); $params = array(); @@ -284,10 +283,10 @@ class CriteriaCombineTest extends BaseTestCase $this->assertEquals($expect, $result); $this->assertEquals($expect_params, $params); - } + } - public function testCombineCriterionOrLessSimple() - { + public function testCombineCriterionOrLessSimple() + { $this->c->addCond('cond1', "INVOICE.COST1", "1000", Criteria::GREATER_EQUAL); $this->c->addCond('cond2', "INVOICE.COST2", "2000", Criteria::LESS_EQUAL); $this->c->add("INVOICE.COST3", "8000", Criteria::GREATER_EQUAL); @@ -296,10 +295,10 @@ class CriteriaCombineTest extends BaseTestCase $expect = "SELECT FROM INVOICE WHERE INVOICE.COST3>=:p1 AND ((INVOICE.COST1>=:p2 OR INVOICE.COST2<=:p3) OR INVOICE.COST4<=:p4)"; $expect_params = array( - array('table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'), - array('table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'), - array('table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'), - array('table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000'), + array('table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'), + array('table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'), + array('table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'), + array('table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000'), ); $params = array(); @@ -307,10 +306,10 @@ class CriteriaCombineTest extends BaseTestCase $this->assertEquals($expect, $result); $this->assertEquals($expect_params, $params); - } + } - public function testCombineCriterionOrMultiple() - { + public function testCombineCriterionOrMultiple() + { $this->c->addCond('cond1',"INVOICE.COST1", "1000", Criteria::GREATER_EQUAL); $this->c->addCond('cond2', "INVOICE.COST2", "2000", Criteria::LESS_EQUAL); $this->c->addCond('cond3', "INVOICE.COST3", "8000", Criteria::GREATER_EQUAL); @@ -319,10 +318,10 @@ class CriteriaCombineTest extends BaseTestCase $expect = "SELECT FROM INVOICE WHERE (((INVOICE.COST1>=:p1 OR INVOICE.COST2<=:p2) OR INVOICE.COST3>=:p3) OR INVOICE.COST4<=:p4)"; $expect_params = array( - array('table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'), - array('table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'), - array('table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'), - array('table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000'), + array('table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'), + array('table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'), + array('table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'), + array('table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000'), ); $params = array(); @@ -330,10 +329,10 @@ class CriteriaCombineTest extends BaseTestCase $this->assertEquals($expect, $result); $this->assertEquals($expect_params, $params); - } + } - public function testCombineNamedCriterions() - { + public function testCombineNamedCriterions() + { $this->c->addCond('cond1', "INVOICE.COST1", "1000", Criteria::GREATER_EQUAL); $this->c->addCond('cond2', "INVOICE.COST2", "2000", Criteria::LESS_EQUAL); $this->c->combine(array('cond1', 'cond2'), Criteria::LOGICAL_AND, 'cond12'); @@ -344,10 +343,10 @@ class CriteriaCombineTest extends BaseTestCase $expect = "SELECT FROM INVOICE WHERE ((INVOICE.COST1>=:p1 AND INVOICE.COST2<=:p2) OR (INVOICE.COST3>=:p3 AND INVOICE.COST4<=:p4))"; $expect_params = array( - array('table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'), - array('table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'), - array('table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'), - array('table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000'), + array('table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'), + array('table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'), + array('table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'), + array('table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000'), ); $params = array(); @@ -355,10 +354,10 @@ class CriteriaCombineTest extends BaseTestCase $this->assertEquals($expect, $result); $this->assertEquals($expect_params, $params); - } + } - public function testCombineDirtyOperators() - { + public function testCombineDirtyOperators() + { $this->c->addCond('cond1', "INVOICE.COST1", "1000", Criteria::GREATER_EQUAL); $this->c->addCond('cond2', "INVOICE.COST2", "2000", Criteria::LESS_EQUAL); $this->c->combine(array('cond1', 'cond2'), 'AnD', 'cond12'); @@ -369,10 +368,10 @@ class CriteriaCombineTest extends BaseTestCase $expect = "SELECT FROM INVOICE WHERE ((INVOICE.COST1>=:p1 AND INVOICE.COST2<=:p2) OR (INVOICE.COST3>=:p3 AND INVOICE.COST4<=:p4))"; $expect_params = array( - array('table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'), - array('table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'), - array('table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'), - array('table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000'), + array('table' => 'INVOICE', 'column' => 'COST1', 'value' => '1000'), + array('table' => 'INVOICE', 'column' => 'COST2', 'value' => '2000'), + array('table' => 'INVOICE', 'column' => 'COST3', 'value' => '8000'), + array('table' => 'INVOICE', 'column' => 'COST4', 'value' => '9000'), ); $params = array(); @@ -380,6 +379,6 @@ class CriteriaCombineTest extends BaseTestCase $this->assertEquals($expect, $result); $this->assertEquals($expect_params, $params); - } + } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaFluidConditionTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaFluidConditionTest.php index a2f0d2bbc..af155dacb 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaFluidConditionTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaFluidConditionTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/BaseTestCase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/BaseTestCase.php'; require_once dirname(__FILE__) . '/../../../../runtime/lib/query/Criteria.php'; require_once dirname(__FILE__) . '/../../../../runtime/lib/util/PropelConditionalProxy.php'; @@ -21,161 +21,314 @@ require_once dirname(__FILE__) . '/../../../../runtime/lib/util/PropelConditiona */ class CriteriaFluidConditionTest extends BaseTestCase { - public function testIf() - { - $f = new TestableCriteria(); - $f-> - _if(true)-> - test()-> - _endif(); - $this->assertTrue($f->getTest(), '_if() executes the next method if the test is true'); - $f = new TestableCriteria(); - $f-> - _if(false)-> - foo()-> - _endif(); - $this->assertFalse($f->getTest(), '_if() does not check the existence of the next method if the test is false'); - $f = new TestableCriteria(); - $f-> - _if(true)-> - dummy()-> - test()-> - _endif(); - $this->assertTrue($f->getTest(), '_if() executes the next methods until _endif() if the test is true'); - $f = new TestableCriteria(); - $f-> - _if(false)-> - dummy()-> - test()-> - _endif(); - $this->assertFalse($f->getTest(), '_if() does not execute the next methods until _endif() if the test is false'); - } - - /** - * @expectedException PropelException - */ - public function testNestedIf() - { - $f = new TestableCriteria(); - $f-> - _if(false)-> - _if(true)-> - test()-> - _endif(); - } + public function testIf() + { + $f = new TestableCriteria(); + $f-> + _if(true)-> + test()-> + _endif(); + $this->assertTrue($f->getTest(), '_if() executes the next method if the test is true'); + $f = new TestableCriteria(); + $f-> + _if(false)-> + foo()-> + _endif(); + $this->assertFalse($f->getTest(), '_if() does not check the existence of the next method if the test is false'); + $f = new TestableCriteria(); + $f-> + _if(true)-> + dummy()-> + test()-> + _endif(); + $this->assertTrue($f->getTest(), '_if() executes the next methods until _endif() if the test is true'); + $f = new TestableCriteria(); + $f-> + _if(false)-> + dummy()-> + test()-> + _endif(); + $this->assertFalse($f->getTest(), '_if() does not execute the next methods until _endif() if the test is false'); + } - public function testElseIf() - { - $f = new TestableCriteria(); - $f-> - _if(true)-> - _elseif(true)-> - test()-> - _endif(); - $this->assertFalse($f->getTest(), '_elseif() does not execute the next method if the main test is true'); - $f = new TestableCriteria(); - $f-> - _if(true)-> - _elseif(false)-> - test()-> - _endif(); - $this->assertFalse($f->getTest(), '_elseif() does not execute the next method if the main test is true'); - $f = new TestableCriteria(); - $f-> - _if(false)-> - _elseif(true)-> - test()-> - _endif(); - $this->assertTrue($f->getTest(), '_elseif() executes the next method if the main test is false and the elseif test is true'); - $f = new TestableCriteria(); - $f-> - _if(false)-> - _elseif(false)-> - test()-> - _endif(); - $this->assertFalse($f->getTest(), '_elseif() does not execute the next method if the main test is false and the elseif test is false'); - } - - public function testElse() - { - $f = new TestableCriteria(); - $f-> - _if(true)-> - _else()-> - test()-> - _endif(); - $this->assertFalse($f->getTest(), '_else() does not execute the next method if the main test is true'); - $f = new TestableCriteria(); - $f-> - _if(false)-> - _else()-> - test()-> - _endif(); - $this->assertTrue($f->getTest(), '_else() executes the next method if the main test is false'); - $f = new TestableCriteria(); - $f-> - _if(false)-> - _elseif(true)-> - _else()-> - test()-> - _endif(); - $this->assertFalse($f->getTest(), '_else() does not execute the next method if the previous test is true'); - $f-> - _if(false)-> - _elseif(false)-> - _else()-> - test()-> - _endif(); - $this->assertTrue($f->getTest(), '_else() executes the next method if all the previous tests are false'); - } - - public function testEndif() - { - $f = new TestableCriteria(); - $res = $f-> - _if(true)-> - test()-> - _endif(); - $this->assertEquals($res, $f, '_endif() returns the main object if the test is true'); - $f = new TestableCriteria(); - $res = $f-> - _if(false)-> - test()-> - _endif(); - $this->assertEquals($res, $f, '_endif() returns the main object if the test is false'); - $f = new TestableCriteria(); - $f-> - _if(true)-> - _endif()-> - test(); - $this->assertTrue($f->getTest(), '_endif() stops the condition check'); - $f = new TestableCriteria(); - $f-> - _if(false)-> - _endif()-> - test(); - $this->assertTrue($f->getTest(), '_endif() stops the condition check'); - } + public function testNestedIf() + { + $f = new TestableCriteria(); + $f-> + _if(false)-> + _if(true)-> + test()-> + _endif()-> + _endif(); + $this->assertFalse($f->getTest(), 'nested _if() is not executed if first condition is false'); + $f = new TestableCriteria(); + $f-> + _if(true)-> + _if(true)-> + test()-> + _endif()-> + _endif(); + $this->assertTrue($f->getTest(), 'nested _if() is executed if first condition is true'); + $f = new TestableCriteria(); + $f-> + _if(true)-> + _if(false)-> + test()-> + _endif()-> + _endif(); + $this->assertFalse($f->getTest(), 'nested _if() is not executed if second condition is false'); + $f = new TestableCriteria(); + $f-> + _if(true)-> + _if(false)-> + _else()-> + test()-> + _endif()-> + _endif(); + $this->assertTrue($f->getTest(), 'nested _else() is executed if second condition is false'); + $f = new TestableCriteria(); + $f-> + _if(true)-> + _if(true)-> + _else()-> + test()-> + _endif()-> + _endif(); + $this->assertFalse($f->getTest(), 'nested _else() is not executed if second condition is true'); + $f = new TestableCriteria(); + $f-> + _if(true)-> + _if(false)-> + _endif()-> + _else()-> + test()-> + _endif(); + $this->assertFalse($f->getTest(), 'first level _else() is not executed if first condition is true'); + $f = new TestableCriteria(); + $f-> + _if(false)-> + _if(true)-> + _endif()-> + _else()-> + test()-> + _endif(); + $this->assertTrue($f->getTest(), 'first level _else() is executed if first condition is false'); + $f = new TestableCriteria(); + $f-> + _if(true)-> + _if(true)-> + _if(true)-> + test()-> + _endif()-> + _endif()-> + _endif(); + $this->assertTrue($f->getTest(), '_if() can be nested on 3 levels'); + $f = new TestableCriteria(); + $f-> + _if(true)-> + _if(false)-> + _if(false)-> + test()-> + _endif()-> + _endif()-> + _endif(); + $this->assertFalse($f->getTest(), '_if() can be nested on 3 levels'); + } + + public function testElseIf() + { + $f = new TestableCriteria(); + $f-> + _if(true)-> + _elseif(true)-> + test()-> + _endif(); + $this->assertFalse($f->getTest(), '_elseif() does not execute the next method if the main test is true'); + $f = new TestableCriteria(); + $f-> + _if(true)-> + _elseif(false)-> + test()-> + _endif(); + $this->assertFalse($f->getTest(), '_elseif() does not execute the next method if the main test is true'); + $f = new TestableCriteria(); + $f-> + _if(true)-> + _elseif(false)-> + _elseif(true)-> + test()-> + _endif(); + $this->assertFalse($f->getTest(), '_elseif() does not execute the next method if the main test is true'); + $f = new TestableCriteria(); + $f-> + _if(false)-> + _elseif(true)-> + test()-> + _endif(); + $this->assertTrue($f->getTest(), '_elseif() executes the next method if the main test is false and the elseif test is true'); + $f = new TestableCriteria(); + $f-> + _if(false)-> + _elseif(false)-> + test()-> + _endif(); + $this->assertFalse($f->getTest(), '_elseif() does not execute the next method if the main test is false and the elseif test is false'); + $f = new TestableCriteria(); + $f-> + _if(false)-> + _elseif(true)-> + _elseif(true)-> + test()-> + _endif(); + $this->assertFalse($f->getTest(), '_elseif() does not executes the next method if the main test is true and the elseif test is true'); + } + + public function testElse() + { + $f = new TestableCriteria(); + $f-> + _if(true)-> + _else()-> + test()-> + _endif(); + $this->assertFalse($f->getTest(), '_else() does not execute the next method if the main test is true'); + $f = new TestableCriteria(); + $f-> + _if(false)-> + _else()-> + test()-> + _endif(); + $this->assertTrue($f->getTest(), '_else() executes the next method if the main test is false'); + $f = new TestableCriteria(); + $f-> + _if(false)-> + _elseif(true)-> + _else()-> + test()-> + _endif(); + $this->assertFalse($f->getTest(), '_else() does not execute the next method if the previous test is true'); + $f = new TestableCriteria(); + $f-> + _if(false)-> + _elseif(true)-> + _elseif(true)-> + _else()-> + test()-> + _endif(); + $this->assertFalse($f->getTest(), '_else() does not execute the next method if the previous test is true'); + $f = new TestableCriteria(); + $f-> + _if(false)-> + _elseif(false)-> + _else()-> + test()-> + _endif(); + $this->assertTrue($f->getTest(), '_else() executes the next method if all the previous tests are false'); + } + + public function testEndif() + { + $f = new TestableCriteria(); + $res = $f-> + _if(true)-> + test()-> + _endif(); + $this->assertEquals($res, $f, '_endif() returns the main object if the test is true'); + $f = new TestableCriteria(); + $res = $f-> + _if(false)-> + test()-> + _endif(); + $this->assertEquals($res, $f, '_endif() returns the main object if the test is false'); + $f = new TestableCriteria(); + $f-> + _if(true)-> + _endif()-> + test(); + $this->assertTrue($f->getTest(), '_endif() stops the condition check'); + $f = new TestableCriteria(); + $f-> + _if(false)-> + _endif()-> + test(); + $this->assertTrue($f->getTest(), '_endif() stops the condition check'); + } + + public function testHierarchy() + { + $f = new TestableCriteria(); + $f2 = $f-> + _if(true)-> + _else()-> + _endif(); + $this->assertEquals($f2, $f, '_endif returns criteria'); + $f = new TestableCriteria(); + $f2 = $f-> + _if(false)-> + _elseif(false)-> + _elseif(true)-> + _elseif(true)-> + _else()-> + _endif(); + $this->assertEquals($f2, $f, '_endif returns criteria'); + $f = new TestableCriteria(); + $f2 = $f-> + _if(true)-> + _else()-> + _endif()-> + _if(true)-> + _else()-> + _endif()-> + _if(false)-> + _else()-> + _endif(); + $this->assertEquals($f2, $f, '_endif can be chained'); + $f = new TestableCriteria(); + $f2 = $f-> + _if(false)-> + _else()-> + _endif(); + $this->assertEquals($f2, $f, '_endif returns criteria'); + $f = new TestableCriteria(); + $f2 = $f-> + _if(false)-> + _if(false)-> + _endif()-> + _elseif(false)-> + _if(false)-> + _endif()-> + _elseif(true)-> + _if(true)-> + _if(true)-> + _endif()-> + _endif()-> + _elseif(true)-> + _if(false)-> + _endif()-> + _else()-> + _endif(); + $this->assertEquals($f2, $f, '_endif returns criteria when nested'); + } } class TestableCriteria extends Criteria { - protected $test = false; + protected $test = false; - public function test() - { - $this->test = true; - - return $this; - } + public function test() + { + $this->test = true; - public function dummy() - { - return $this; - } + return $this; + } - public function getTest() - { - return $this->test; - } + public function dummy() + { + return $this; + } + + public function getTest() + { + return $this->test; + } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaFluidOperatorTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaFluidOperatorTest.php new file mode 100644 index 000000000..53dd278c6 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaFluidOperatorTest.php @@ -0,0 +1,119 @@ +addUsingOperator('foo', 'bar'); + $expected = 'SELECT FROM WHERE foo=:p1'; + + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + + $this->assertEquals($expected, $result); + } + + public function testDefaultOperatorIsAnd() + { + $c = new Criteria(); + $c->addUsingOperator('foo1', 'bar1'); + $c->addUsingOperator('foo2', 'bar2'); + $expected = 'SELECT FROM WHERE foo1=:p1 AND foo2=:p2'; + + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + + $this->assertEquals($expected, $result); + } + + public function testOrOverridesDefaultOperator() + { + $c = new Criteria(); + $c->addUsingOperator('foo1', 'bar1'); + $c->_or(); + $c->addUsingOperator('foo2', 'bar2'); + $expected = 'SELECT FROM WHERE (foo1=:p1 OR foo2=:p2)'; + + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + + $this->assertEquals($expected, $result); + } + + public function testOrWithNoExistingCriterionIsAnd() + { + $c = new Criteria(); + $c->_or(); + $c->addUsingOperator('foo', 'bar'); + $expected = 'SELECT FROM WHERE foo=:p1'; + + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + + $this->assertEquals($expected, $result); + } + + public function testOrWithNoExistingCriterionIsAnd2() + { + $c = new Criteria(); + $c->_or(); + $c->addUsingOperator('foo1', 'bar'); + $c->addUsingOperator('foo2', 'bar2'); + $expected = 'SELECT FROM WHERE foo1=:p1 AND foo2=:p2'; + + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + + $this->assertEquals($expected, $result); + } + + public function testOrCanBeCalledSeveralTimes() + { + $c = new Criteria(); + $c->addUsingOperator('foo1', 'bar1'); + $c->_or(); + $c->addUsingOperator('foo2', 'bar2'); + $c->_or(); + $c->addUsingOperator('foo3', 'bar3'); + $expected = 'SELECT FROM WHERE ((foo1=:p1 OR foo2=:p2) OR foo3=:p3)'; + + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + + $this->assertEquals($expected, $result); + } + + public function testaddUsingOperatorResetsDefaultOperator() + { + $c = new Criteria(); + $c->addUsingOperator('foo1', 'bar1'); + $c->_or(); + $c->addUsingOperator('foo2', 'bar2'); + $c->addUsingOperator('foo3', 'bar3'); + $expected = 'SELECT FROM WHERE (foo1=:p1 OR foo2=:p2) AND foo3=:p3'; + + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + + $this->assertEquals($expected, $result); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaMergeTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaMergeTest.php index e28d8a30b..9b2561d32 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaMergeTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaMergeTest.php @@ -8,13 +8,10 @@ * @license MIT License */ -require_once 'tools/helpers/BaseTestCase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; require_once dirname(__FILE__) . '/../../../../runtime/lib/query/Criteria.php'; require_once dirname(__FILE__) . '/../../../../runtime/lib/util/BasePeer.php'; -set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes"); -Propel::init('fixtures/bookstore/build/conf/bookstore-conf.php'); - /** * Test class for Criteria. * @@ -23,377 +20,419 @@ Propel::init('fixtures/bookstore/build/conf/bookstore-conf.php'); * @version $Id: CriteriaTest.php 1347 2009-12-03 21:06:36Z francois $ * @package runtime.query */ -class CriteriaMergeTest extends BaseTestCase +class CriteriaMergeTest extends BookstoreTestBase { - - protected function assertCriteriaTranslation($criteria, $expectedSql, $message = '') - { - $params = array(); - $result = BasePeer::createSelectSql($criteria, $params); - $this->assertEquals($expectedSql, $result, $message); - } - - public function testMergeWithLimit() - { - $c1 = new Criteria(); - $c1->setLimit(123); - $c2 = new Criteria(); - $c1->mergeWith($c2); - $this->assertEquals(123, $c1->getLimit(), 'mergeWith() does not remove an existing limit'); - $c1 = new Criteria(); - $c2 = new Criteria(); - $c2->setLimit(123); - $c1->mergeWith($c2); - $this->assertEquals(123, $c1->getLimit(), 'mergeWith() merges the limit'); - $c1 = new Criteria(); - $c1->setLimit(456); - $c2 = new Criteria(); - $c2->setLimit(123); - $c1->mergeWith($c2); - $this->assertEquals(456, $c1->getLimit(), 'mergeWith() does not merge the limit in case of conflict'); - } - public function testMergeWithOffset() - { - $c1 = new Criteria(); - $c1->setOffset(123); - $c2 = new Criteria(); - $c1->mergeWith($c2); - $this->assertEquals(123, $c1->getOffset(), 'mergeWith() does not remove an existing offset'); - $c1 = new Criteria(); - $c2 = new Criteria(); - $c2->setOffset(123); - $c1->mergeWith($c2); - $this->assertEquals(123, $c1->getOffset(), 'mergeWith() merges the offset'); - $c1 = new Criteria(); - $c1->setOffset(456); - $c2 = new Criteria(); - $c2->setOffset(123); - $c1->mergeWith($c2); - $this->assertEquals(456, $c1->getOffset(), 'mergeWith() does not merge the offset in case of conflict'); - } - - public function testMergeWithSelectModifiers() - { - $c1 = new Criteria(); - $c1->setDistinct(); - $c2 = new Criteria(); - $c1->mergeWith($c2); - $this->assertEquals(array(Criteria::DISTINCT), $c1->getSelectModifiers(), 'mergeWith() does not remove an existing select modifier'); - $c1 = new Criteria(); - $c2 = new Criteria(); - $c2->setDistinct(); - $c1->mergeWith($c2); - $this->assertEquals(array(Criteria::DISTINCT), $c1->getSelectModifiers(), 'mergeWith() merges the select modifiers'); - $c1 = new Criteria(); - $c1->setDistinct(); - $c2 = new Criteria(); - $c2->setDistinct(); - $c1->mergeWith($c2); - $this->assertEquals(array(Criteria::DISTINCT), $c1->getSelectModifiers(), 'mergeWith() does not duplicate select modifiers'); - $c1 = new Criteria(); - $c1->setAll(); - $c2 = new Criteria(); - $c2->setDistinct(); - $c1->mergeWith($c2); - $this->assertEquals(array(Criteria::ALL), $c1->getSelectModifiers(), 'mergeWith() does not merge the select modifiers in case of conflict'); - } + protected function assertCriteriaTranslation($criteria, $expectedSql, $message = '') + { + $params = array(); + $result = BasePeer::createSelectSql($criteria, $params); + $this->assertEquals($expectedSql, $result, $message); + } - public function testMergeWithSelectColumns() - { - $c1 = new Criteria(); - $c1->addSelectColumn(BookPeer::TITLE); - $c1->addSelectColumn(BookPeer::ID); - $c2 = new Criteria(); - $c1->mergeWith($c2); - $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getSelectColumns(), 'mergeWith() does not remove an existing select columns'); - $c1 = new Criteria(); - $c2 = new Criteria(); - $c2->addSelectColumn(BookPeer::TITLE); - $c2->addSelectColumn(BookPeer::ID); - $c1->mergeWith($c2); - $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getSelectColumns(), 'mergeWith() merges the select columns to an empty select'); - $c1 = new Criteria(); - $c1->addSelectColumn(BookPeer::TITLE); - $c2 = new Criteria(); - $c2->addSelectColumn(BookPeer::ID); - $c1->mergeWith($c2); - $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getSelectColumns(), 'mergeWith() merges the select columns after the existing select columns'); - $c1 = new Criteria(); - $c1->addSelectColumn(BookPeer::TITLE); - $c2 = new Criteria(); - $c2->addSelectColumn(BookPeer::TITLE); - $c1->mergeWith($c2); - $this->assertEquals(array(BookPeer::TITLE, BookPeer::TITLE), $c1->getSelectColumns(), 'mergeWith() merges the select columns to an existing select, even if duplicated'); - } + public function testMergeWithLimit() + { + $c1 = new Criteria(); + $c1->setLimit(123); + $c2 = new Criteria(); + $c1->mergeWith($c2); + $this->assertEquals(123, $c1->getLimit(), 'mergeWith() does not remove an existing limit'); + $c1 = new Criteria(); + $c2 = new Criteria(); + $c2->setLimit(123); + $c1->mergeWith($c2); + $this->assertEquals(123, $c1->getLimit(), 'mergeWith() merges the limit'); + $c1 = new Criteria(); + $c1->setLimit(456); + $c2 = new Criteria(); + $c2->setLimit(123); + $c1->mergeWith($c2); + $this->assertEquals(456, $c1->getLimit(), 'mergeWith() does not merge the limit in case of conflict'); + } - public function testMergeWithAsColumns() - { - $c1 = new Criteria(); - $c1->addAsColumn('foo', BookPeer::TITLE); - $c1->addAsColumn('bar', BookPeer::ID); - $c2 = new Criteria(); - $c1->mergeWith($c2); - $this->assertEquals(array('foo' => BookPeer::TITLE, 'bar' => BookPeer::ID), $c1->getAsColumns(), 'mergeWith() does not remove an existing as columns'); - $c1 = new Criteria(); - $c2 = new Criteria(); - $c2->addAsColumn('foo', BookPeer::TITLE); - $c2->addAsColumn('bar', BookPeer::ID); - $c1->mergeWith($c2); - $this->assertEquals(array('foo' => BookPeer::TITLE, 'bar' => BookPeer::ID), $c1->getAsColumns(), 'mergeWith() merges the select columns to an empty as'); - $c1 = new Criteria(); - $c1->addAsColumn('foo', BookPeer::TITLE); - $c2 = new Criteria(); - $c2->addAsColumn('bar', BookPeer::ID); - $c1->mergeWith($c2); - $this->assertEquals(array('foo' => BookPeer::TITLE, 'bar' => BookPeer::ID), $c1->getAsColumns(), 'mergeWith() merges the select columns after the existing as columns'); - } - - /** - * @expectedException PropelException - */ - public function testMergeWithAsColumnsThrowsException() - { - $c1 = new Criteria(); - $c1->addAsColumn('foo', BookPeer::TITLE); - $c2 = new Criteria(); - $c2->addAsColumn('foo', BookPeer::ID); - $c1->mergeWith($c2); - } + public function testMergeWithOffset() + { + $c1 = new Criteria(); + $c1->setOffset(123); + $c2 = new Criteria(); + $c1->mergeWith($c2); + $this->assertEquals(123, $c1->getOffset(), 'mergeWith() does not remove an existing offset'); + $c1 = new Criteria(); + $c2 = new Criteria(); + $c2->setOffset(123); + $c1->mergeWith($c2); + $this->assertEquals(123, $c1->getOffset(), 'mergeWith() merges the offset'); + $c1 = new Criteria(); + $c1->setOffset(456); + $c2 = new Criteria(); + $c2->setOffset(123); + $c1->mergeWith($c2); + $this->assertEquals(456, $c1->getOffset(), 'mergeWith() does not merge the offset in case of conflict'); + } - public function testMergeWithOrderByColumns() - { - $c1 = new Criteria(); - $c1->addAscendingOrderByColumn(BookPeer::TITLE); - $c1->addAscendingOrderByColumn(BookPeer::ID); - $c2 = new Criteria(); - $c1->mergeWith($c2); - $this->assertEquals(array(BookPeer::TITLE . ' ASC', BookPeer::ID . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() does not remove an existing orderby columns'); - $c1 = new Criteria(); - $c2 = new Criteria(); - $c2->addAscendingOrderByColumn(BookPeer::TITLE); - $c2->addAscendingOrderByColumn(BookPeer::ID); - $c1->mergeWith($c2); - $this->assertEquals(array(BookPeer::TITLE . ' ASC', BookPeer::ID . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() merges the select columns to an empty order by'); - $c1 = new Criteria(); - $c1->addAscendingOrderByColumn(BookPeer::TITLE); - $c2 = new Criteria(); - $c2->addAscendingOrderByColumn(BookPeer::ID); - $c1->mergeWith($c2); - $this->assertEquals(array(BookPeer::TITLE . ' ASC', BookPeer::ID . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() merges the select columns after the existing orderby columns'); - $c1 = new Criteria(); - $c1->addAscendingOrderByColumn(BookPeer::TITLE); - $c2 = new Criteria(); - $c2->addAscendingOrderByColumn(BookPeer::TITLE); - $c1->mergeWith($c2); - $this->assertEquals(array(BookPeer::TITLE . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() does not merge duplicated orderby columns'); - $c1 = new Criteria(); - $c1->addAscendingOrderByColumn(BookPeer::TITLE); - $c2 = new Criteria(); - $c2->addDescendingOrderByColumn(BookPeer::TITLE); - $c1->mergeWith($c2); - $this->assertEquals(array(BookPeer::TITLE . ' ASC', BookPeer::TITLE . ' DESC'), $c1->getOrderByColumns(), 'mergeWith() merges duplicated orderby columns with inverse direction'); - } + public function testMergeWithSelectModifiers() + { + $c1 = new Criteria(); + $c1->setDistinct(); + $c2 = new Criteria(); + $c1->mergeWith($c2); + $this->assertEquals(array(Criteria::DISTINCT), $c1->getSelectModifiers(), 'mergeWith() does not remove an existing select modifier'); + $c1 = new Criteria(); + $c2 = new Criteria(); + $c2->setDistinct(); + $c1->mergeWith($c2); + $this->assertEquals(array(Criteria::DISTINCT), $c1->getSelectModifiers(), 'mergeWith() merges the select modifiers'); + $c1 = new Criteria(); + $c1->setDistinct(); + $c2 = new Criteria(); + $c2->setDistinct(); + $c1->mergeWith($c2); + $this->assertEquals(array(Criteria::DISTINCT), $c1->getSelectModifiers(), 'mergeWith() does not duplicate select modifiers'); + $c1 = new Criteria(); + $c1->setAll(); + $c2 = new Criteria(); + $c2->setDistinct(); + $c1->mergeWith($c2); + $this->assertEquals(array(Criteria::ALL), $c1->getSelectModifiers(), 'mergeWith() does not merge the select modifiers in case of conflict'); + } - public function testMergeWithGroupByColumns() - { - $c1 = new Criteria(); - $c1->addGroupByColumn(BookPeer::TITLE); - $c1->addGroupByColumn(BookPeer::ID); - $c2 = new Criteria(); - $c1->mergeWith($c2); - $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getGroupByColumns(), 'mergeWith() does not remove an existing groupby columns'); - $c1 = new Criteria(); - $c2 = new Criteria(); - $c2->addGroupByColumn(BookPeer::TITLE); - $c2->addGroupByColumn(BookPeer::ID); - $c1->mergeWith($c2); - $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getGroupByColumns(), 'mergeWith() merges the select columns to an empty groupby'); - $c1 = new Criteria(); - $c1->addGroupByColumn(BookPeer::TITLE); - $c2 = new Criteria(); - $c2->addGroupByColumn(BookPeer::ID); - $c1->mergeWith($c2); - $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getGroupByColumns(), 'mergeWith() merges the select columns after the existing groupby columns'); - $c1 = new Criteria(); - $c1->addGroupByColumn(BookPeer::TITLE); - $c2 = new Criteria(); - $c2->addGroupByColumn(BookPeer::TITLE); - $c1->mergeWith($c2); - $this->assertEquals(array(BookPeer::TITLE), $c1->getGroupByColumns(), 'mergeWith() does not merge duplicated groupby columns'); - } - - public function testMergeWithWhereConditions() - { - $c1 = new Criteria(); - $c1->add(BookPeer::TITLE, 'foo'); - $c2 = new Criteria(); - $c1->mergeWith($c2); - $sql = 'SELECT FROM `book` WHERE book.TITLE=:p1'; - $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() does not remove an existing where condition'); - $c1 = new Criteria(); - $c2 = new Criteria(); - $c2->add(BookPeer::TITLE, 'foo'); - $c1->mergeWith($c2); - $sql = 'SELECT FROM `book` WHERE book.TITLE=:p1'; - $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to an empty condition'); - $c1 = new Criteria(); - $c1->add(BookPeer::ID, 123); - $c2 = new Criteria(); - $c2->add(BookPeer::TITLE, 'foo'); - $c1->mergeWith($c2); - $sql = 'SELECT FROM `book` WHERE book.ID=:p1 AND book.TITLE=:p2'; - $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions'); - $c1 = new Criteria(); - $c1->add(BookPeer::TITLE, 'foo'); - $c2 = new Criteria(); - $c2->add(BookPeer::TITLE, 'bar'); - $c1->mergeWith($c2); - $sql = 'SELECT FROM `book` WHERE (book.TITLE=:p1 AND book.TITLE=:p2)'; - $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the same column'); - $c1 = new Criteria(); - $c1->add(BookPeer::TITLE, 'foo'); - $c1->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::LEFT_JOIN); - $c2 = new Criteria(); - $c2->add(AuthorPeer::FIRST_NAME, 'bar'); - $c1->mergeWith($c2); - $sql = 'SELECT FROM `book` LEFT JOIN author ON (book.AUTHOR_ID=author.ID) WHERE book.TITLE=:p1 AND author.FIRST_NAME=:p2'; - $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the different tables'); - } + public function testMergeWithSelectColumns() + { + $c1 = new Criteria(); + $c1->addSelectColumn(BookPeer::TITLE); + $c1->addSelectColumn(BookPeer::ID); + $c2 = new Criteria(); + $c1->mergeWith($c2); + $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getSelectColumns(), 'mergeWith() does not remove an existing select columns'); + $c1 = new Criteria(); + $c2 = new Criteria(); + $c2->addSelectColumn(BookPeer::TITLE); + $c2->addSelectColumn(BookPeer::ID); + $c1->mergeWith($c2); + $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getSelectColumns(), 'mergeWith() merges the select columns to an empty select'); + $c1 = new Criteria(); + $c1->addSelectColumn(BookPeer::TITLE); + $c2 = new Criteria(); + $c2->addSelectColumn(BookPeer::ID); + $c1->mergeWith($c2); + $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getSelectColumns(), 'mergeWith() merges the select columns after the existing select columns'); + $c1 = new Criteria(); + $c1->addSelectColumn(BookPeer::TITLE); + $c2 = new Criteria(); + $c2->addSelectColumn(BookPeer::TITLE); + $c1->mergeWith($c2); + $this->assertEquals(array(BookPeer::TITLE, BookPeer::TITLE), $c1->getSelectColumns(), 'mergeWith() merges the select columns to an existing select, even if duplicated'); + } - public function testMergeOrWithWhereConditions() - { - $c1 = new Criteria(); - $c1->add(BookPeer::TITLE, 'foo'); - $c2 = new Criteria(); - $c1->mergeWith($c2, Criteria::LOGICAL_OR); - $sql = 'SELECT FROM `book` WHERE book.TITLE=:p1'; - $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() does not remove an existing where condition'); - $c1 = new Criteria(); - $c2 = new Criteria(); - $c2->add(BookPeer::TITLE, 'foo'); - $c1->mergeWith($c2, Criteria::LOGICAL_OR); - $sql = 'SELECT FROM `book` WHERE book.TITLE=:p1'; - $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to an empty condition'); - $c1 = new Criteria(); - $c1->add(BookPeer::ID, 123); - $c2 = new Criteria(); - $c2->add(BookPeer::TITLE, 'foo'); - $c1->mergeWith($c2, Criteria::LOGICAL_OR); - $sql = 'SELECT FROM `book` WHERE (book.ID=:p1 OR book.TITLE=:p2)'; - $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions'); - $c1 = new Criteria(); - $c1->add(BookPeer::TITLE, 'foo'); - $c2 = new Criteria(); - $c2->add(BookPeer::TITLE, 'bar'); - $c1->mergeWith($c2, Criteria::LOGICAL_OR); - $sql = 'SELECT FROM `book` WHERE (book.TITLE=:p1 OR book.TITLE=:p2)'; - $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the same column'); - $c1 = new Criteria(); - $c1->add(BookPeer::TITLE, 'foo'); - $c1->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::LEFT_JOIN); - $c2 = new Criteria(); - $c2->add(AuthorPeer::FIRST_NAME, 'bar'); - $c1->mergeWith($c2, Criteria::LOGICAL_OR); - $sql = 'SELECT FROM `book` LEFT JOIN author ON (book.AUTHOR_ID=author.ID) WHERE (book.TITLE=:p1 OR author.FIRST_NAME=:p2)'; - $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the different tables'); - } - - public function testMergeWithHavingConditions() - { - $c1 = new Criteria(); - $cton = $c1->getNewCriterion(BookPeer::TITLE, 'foo', Criteria::EQUAL); - $c1->addHaving($cton); - $c2 = new Criteria(); - $c1->mergeWith($c2); - $sql = 'SELECT FROM HAVING book.TITLE=:p1'; - $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() does not remove an existing having condition'); - $c1 = new Criteria(); - $c2 = new Criteria(); - $cton = $c2->getNewCriterion(BookPeer::TITLE, 'foo', Criteria::EQUAL); - $c2->addHaving($cton); - $c1->mergeWith($c2); - $sql = 'SELECT FROM HAVING book.TITLE=:p1'; - $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges having condition to an empty having'); - $c1 = new Criteria(); - $cton = $c1->getNewCriterion(BookPeer::TITLE, 'foo', Criteria::EQUAL); - $c1->addHaving($cton); - $c2 = new Criteria(); - $cton = $c2->getNewCriterion(BookPeer::TITLE, 'bar', Criteria::EQUAL); - $c2->addHaving($cton); - $c1->mergeWith($c2); - $sql = 'SELECT FROM HAVING (book.TITLE=:p1 AND book.TITLE=:p2)'; - $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() combines having with AND'); - } - - public function testMergeWithAliases() - { - $c1 = new Criteria(); - $c1->addAlias('b', BookPeer::TABLE_NAME); - $c2 = new Criteria(); - $c1->mergeWith($c2); - $this->assertEquals(array('b' => BookPeer::TABLE_NAME), $c1->getAliases(), 'mergeWith() does not remove an existing alias'); - $c1 = new Criteria(); - $c2 = new Criteria(); - $c2->addAlias('a', AuthorPeer::TABLE_NAME); - $c1->mergeWith($c2); - $this->assertEquals(array('a' => AuthorPeer::TABLE_NAME), $c1->getAliases(), 'mergeWith() merge aliases to an empty alias'); - $c1 = new Criteria(); - $c1->addAlias('b', BookPeer::TABLE_NAME); - $c2 = new Criteria(); - $c2->addAlias('a', AuthorPeer::TABLE_NAME); - $c1->mergeWith($c2); - $this->assertEquals(array('b' => BookPeer::TABLE_NAME, 'a' => AuthorPeer::TABLE_NAME), $c1->getAliases(), 'mergeWith() merge aliases to an existing alias'); - } + public function testMergeWithAsColumns() + { + $c1 = new Criteria(); + $c1->addAsColumn('foo', BookPeer::TITLE); + $c1->addAsColumn('bar', BookPeer::ID); + $c2 = new Criteria(); + $c1->mergeWith($c2); + $this->assertEquals(array('foo' => BookPeer::TITLE, 'bar' => BookPeer::ID), $c1->getAsColumns(), 'mergeWith() does not remove an existing as columns'); + $c1 = new Criteria(); + $c2 = new Criteria(); + $c2->addAsColumn('foo', BookPeer::TITLE); + $c2->addAsColumn('bar', BookPeer::ID); + $c1->mergeWith($c2); + $this->assertEquals(array('foo' => BookPeer::TITLE, 'bar' => BookPeer::ID), $c1->getAsColumns(), 'mergeWith() merges the select columns to an empty as'); + $c1 = new Criteria(); + $c1->addAsColumn('foo', BookPeer::TITLE); + $c2 = new Criteria(); + $c2->addAsColumn('bar', BookPeer::ID); + $c1->mergeWith($c2); + $this->assertEquals(array('foo' => BookPeer::TITLE, 'bar' => BookPeer::ID), $c1->getAsColumns(), 'mergeWith() merges the select columns after the existing as columns'); + } - /** - * @expectedException PropelException - */ - public function testMergeWithAliasesThrowsException() - { - $c1 = new Criteria(); - $c1->addAlias('b', BookPeer::TABLE_NAME); - $c2 = new Criteria(); - $c2->addAlias('b', AuthorPeer::TABLE_NAME); - $c1->mergeWith($c2); - } - - public function testMergeWithJoins() - { - $c1 = new Criteria(); - $c1->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::LEFT_JOIN); - $c2 = new Criteria(); - $c1->mergeWith($c2); - $joins = $c1->getJoins(); - $this->assertEquals(1, count($joins), 'mergeWith() does not remove an existing join'); - $this->assertEquals('LEFT JOIN : book.AUTHOR_ID=author.ID(ignoreCase not considered)', $joins[0]->toString(), 'mergeWith() does not remove an existing join'); - $c1 = new Criteria(); - $c2 = new Criteria(); - $c2->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::LEFT_JOIN); - $c1->mergeWith($c2); - $joins = $c1->getJoins(); - $this->assertEquals(1, count($joins), 'mergeWith() merge joins to an empty join'); - $this->assertEquals('LEFT JOIN : book.AUTHOR_ID=author.ID(ignoreCase not considered)', $joins[0]->toString(), 'mergeWith() merge joins to an empty join'); - $c1 = new Criteria(); - $c1->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::LEFT_JOIN); - $c2 = new Criteria(); - $c2->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID, Criteria::INNER_JOIN); - $c1->mergeWith($c2); - $joins = $c1->getJoins(); - $this->assertEquals(2, count($joins), 'mergeWith() merge joins to an existing join'); - $this->assertEquals('LEFT JOIN : book.AUTHOR_ID=author.ID(ignoreCase not considered)', $joins[0]->toString(), 'mergeWith() merge joins to an empty join'); - $this->assertEquals('INNER JOIN : book.PUBLISHER_ID=publisher.ID(ignoreCase not considered)', $joins[1]->toString(), 'mergeWith() merge joins to an empty join'); - } + /** + * @expectedException PropelException + */ + public function testMergeWithAsColumnsThrowsException() + { + $c1 = new Criteria(); + $c1->addAsColumn('foo', BookPeer::TITLE); + $c2 = new Criteria(); + $c2->addAsColumn('foo', BookPeer::ID); + $c1->mergeWith($c2); + } - public function testMergeWithFurtherModified() - { - $c1 = new Criteria(); - $c2 = new Criteria(); - $c2->setLimit(123); - $c1->mergeWith($c2); - $this->assertEquals(123, $c1->getLimit(), 'mergeWith() makes the merge'); - $c2->setLimit(456); - $this->assertEquals(123, $c1->getLimit(), 'further modifying a merged criteria does not affect the merger'); - } + public function testMergeWithOrderByColumns() + { + $c1 = new Criteria(); + $c1->addAscendingOrderByColumn(BookPeer::TITLE); + $c1->addAscendingOrderByColumn(BookPeer::ID); + $c2 = new Criteria(); + $c1->mergeWith($c2); + $this->assertEquals(array(BookPeer::TITLE . ' ASC', BookPeer::ID . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() does not remove an existing orderby columns'); + $c1 = new Criteria(); + $c2 = new Criteria(); + $c2->addAscendingOrderByColumn(BookPeer::TITLE); + $c2->addAscendingOrderByColumn(BookPeer::ID); + $c1->mergeWith($c2); + $this->assertEquals(array(BookPeer::TITLE . ' ASC', BookPeer::ID . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() merges the select columns to an empty order by'); + $c1 = new Criteria(); + $c1->addAscendingOrderByColumn(BookPeer::TITLE); + $c2 = new Criteria(); + $c2->addAscendingOrderByColumn(BookPeer::ID); + $c1->mergeWith($c2); + $this->assertEquals(array(BookPeer::TITLE . ' ASC', BookPeer::ID . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() merges the select columns after the existing orderby columns'); + $c1 = new Criteria(); + $c1->addAscendingOrderByColumn(BookPeer::TITLE); + $c2 = new Criteria(); + $c2->addAscendingOrderByColumn(BookPeer::TITLE); + $c1->mergeWith($c2); + $this->assertEquals(array(BookPeer::TITLE . ' ASC'), $c1->getOrderByColumns(), 'mergeWith() does not merge duplicated orderby columns'); + $c1 = new Criteria(); + $c1->addAscendingOrderByColumn(BookPeer::TITLE); + $c2 = new Criteria(); + $c2->addDescendingOrderByColumn(BookPeer::TITLE); + $c1->mergeWith($c2); + $this->assertEquals(array(BookPeer::TITLE . ' ASC', BookPeer::TITLE . ' DESC'), $c1->getOrderByColumns(), 'mergeWith() merges duplicated orderby columns with inverse direction'); + } + + public function testMergeWithGroupByColumns() + { + $c1 = new Criteria(); + $c1->addGroupByColumn(BookPeer::TITLE); + $c1->addGroupByColumn(BookPeer::ID); + $c2 = new Criteria(); + $c1->mergeWith($c2); + $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getGroupByColumns(), 'mergeWith() does not remove an existing groupby columns'); + $c1 = new Criteria(); + $c2 = new Criteria(); + $c2->addGroupByColumn(BookPeer::TITLE); + $c2->addGroupByColumn(BookPeer::ID); + $c1->mergeWith($c2); + $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getGroupByColumns(), 'mergeWith() merges the select columns to an empty groupby'); + $c1 = new Criteria(); + $c1->addGroupByColumn(BookPeer::TITLE); + $c2 = new Criteria(); + $c2->addGroupByColumn(BookPeer::ID); + $c1->mergeWith($c2); + $this->assertEquals(array(BookPeer::TITLE, BookPeer::ID), $c1->getGroupByColumns(), 'mergeWith() merges the select columns after the existing groupby columns'); + $c1 = new Criteria(); + $c1->addGroupByColumn(BookPeer::TITLE); + $c2 = new Criteria(); + $c2->addGroupByColumn(BookPeer::TITLE); + $c1->mergeWith($c2); + $this->assertEquals(array(BookPeer::TITLE), $c1->getGroupByColumns(), 'mergeWith() does not merge duplicated groupby columns'); + } + + public function testMergeWithWhereConditions() + { + $c1 = new Criteria(); + $c1->add(BookPeer::TITLE, 'foo'); + $c2 = new Criteria(); + $c1->mergeWith($c2); + $sql = 'SELECT FROM `book` WHERE book.title=:p1'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() does not remove an existing where condition'); + $c1 = new Criteria(); + $c2 = new Criteria(); + $c2->add(BookPeer::TITLE, 'foo'); + $c1->mergeWith($c2); + $sql = 'SELECT FROM `book` WHERE book.title=:p1'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to an empty condition'); + $c1 = new Criteria(); + $c1->add(BookPeer::ID, 123); + $c2 = new Criteria(); + $c2->add(BookPeer::TITLE, 'foo'); + $c1->mergeWith($c2); + $sql = 'SELECT FROM `book` WHERE book.id=:p1 AND book.title=:p2'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions'); + $c1 = new Criteria(); + $c1->add(BookPeer::TITLE, 'foo'); + $c2 = new Criteria(); + $c2->add(BookPeer::TITLE, 'bar'); + $c1->mergeWith($c2); + $sql = 'SELECT FROM `book` WHERE (book.title=:p1 AND book.title=:p2)'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the same column'); + $c1 = new Criteria(); + $c1->add(BookPeer::TITLE, 'foo'); + $c1->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::LEFT_JOIN); + $c2 = new Criteria(); + $c2->add(AuthorPeer::FIRST_NAME, 'bar'); + $c1->mergeWith($c2); + $sql = 'SELECT FROM `book` LEFT JOIN `author` ON (book.author_id=author.id) WHERE book.title=:p1 AND author.first_name=:p2'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the different tables'); + } + + public function testMergeOrWithWhereConditions() + { + $c1 = new Criteria(); + $c1->add(BookPeer::TITLE, 'foo'); + $c2 = new Criteria(); + $c1->mergeWith($c2, Criteria::LOGICAL_OR); + $sql = 'SELECT FROM `book` WHERE book.title=:p1'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() does not remove an existing where condition'); + $c1 = new Criteria(); + $c2 = new Criteria(); + $c2->add(BookPeer::TITLE, 'foo'); + $c1->mergeWith($c2, Criteria::LOGICAL_OR); + $sql = 'SELECT FROM `book` WHERE book.title=:p1'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to an empty condition'); + $c1 = new Criteria(); + $c1->add(BookPeer::ID, 123); + $c2 = new Criteria(); + $c2->add(BookPeer::TITLE, 'foo'); + $c1->mergeWith($c2, Criteria::LOGICAL_OR); + $sql = 'SELECT FROM `book` WHERE (book.id=:p1 OR book.title=:p2)'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions'); + $c1 = new Criteria(); + $c1->add(BookPeer::TITLE, 'foo'); + $c2 = new Criteria(); + $c2->add(BookPeer::TITLE, 'bar'); + $c1->mergeWith($c2, Criteria::LOGICAL_OR); + $sql = 'SELECT FROM `book` WHERE (book.title=:p1 OR book.title=:p2)'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the same column'); + $c1 = new Criteria(); + $c1->add(BookPeer::TITLE, 'foo'); + $c1->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::LEFT_JOIN); + $c2 = new Criteria(); + $c2->add(AuthorPeer::FIRST_NAME, 'bar'); + $c1->mergeWith($c2, Criteria::LOGICAL_OR); + $sql = 'SELECT FROM `book` LEFT JOIN `author` ON (book.author_id=author.id) WHERE (book.title=:p1 OR author.first_name=:p2)'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the different tables'); + } + + public function testMerge_OrWithWhereConditions() + { + $c1 = new Criteria(); + $c1->add(BookPeer::TITLE, 'foo'); + $c2 = new Criteria(); + $c1->_or(); + $c1->mergeWith($c2); + $sql = 'SELECT FROM `book` WHERE book.title=:p1'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() does not remove an existing where condition'); + $c1 = new Criteria(); + $c2 = new Criteria(); + $c2->add(BookPeer::TITLE, 'foo'); + $c1->_or(); + $c1->mergeWith($c2); + $sql = 'SELECT FROM `book` WHERE book.title=:p1'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to an empty condition'); + $c1 = new Criteria(); + $c1->add(BookPeer::ID, 123); + $c1->_or(); + $c2 = new Criteria(); + $c2->add(BookPeer::TITLE, 'foo'); + $c1->mergeWith($c2); + $sql = 'SELECT FROM `book` WHERE (book.id=:p1 OR book.title=:p2)'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions'); + $c1 = new Criteria(); + $c1->add(BookPeer::TITLE, 'foo'); + $c1->_or(); + $c2 = new Criteria(); + $c2->add(BookPeer::TITLE, 'bar'); + $c1->mergeWith($c2); + $sql = 'SELECT FROM `book` WHERE (book.title=:p1 OR book.title=:p2)'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the same column'); + $c1 = new Criteria(); + $c1->add(BookPeer::TITLE, 'foo'); + $c1->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::LEFT_JOIN); + $c1->_or(); + $c2 = new Criteria(); + $c2->add(AuthorPeer::FIRST_NAME, 'bar'); + $c1->mergeWith($c2); + $sql = 'SELECT FROM `book` LEFT JOIN `author` ON (book.author_id=author.id) WHERE (book.title=:p1 OR author.first_name=:p2)'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges where condition to existing conditions on the different tables'); + } + public function testMergeWithHavingConditions() + { + $c1 = new Criteria(); + $cton = $c1->getNewCriterion(BookPeer::TITLE, 'foo', Criteria::EQUAL); + $c1->addHaving($cton); + $c2 = new Criteria(); + $c1->mergeWith($c2); + $sql = 'SELECT FROM HAVING book.title=:p1'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() does not remove an existing having condition'); + $c1 = new Criteria(); + $c2 = new Criteria(); + $cton = $c2->getNewCriterion(BookPeer::TITLE, 'foo', Criteria::EQUAL); + $c2->addHaving($cton); + $c1->mergeWith($c2); + $sql = 'SELECT FROM HAVING book.title=:p1'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() merges having condition to an empty having'); + $c1 = new Criteria(); + $cton = $c1->getNewCriterion(BookPeer::TITLE, 'foo', Criteria::EQUAL); + $c1->addHaving($cton); + $c2 = new Criteria(); + $cton = $c2->getNewCriterion(BookPeer::TITLE, 'bar', Criteria::EQUAL); + $c2->addHaving($cton); + $c1->mergeWith($c2); + $sql = 'SELECT FROM HAVING (book.title=:p1 AND book.title=:p2)'; + $this->assertCriteriaTranslation($c1, $sql, 'mergeWith() combines having with AND'); + } + + public function testMergeWithAliases() + { + $c1 = new Criteria(); + $c1->addAlias('b', BookPeer::TABLE_NAME); + $c2 = new Criteria(); + $c1->mergeWith($c2); + $this->assertEquals(array('b' => BookPeer::TABLE_NAME), $c1->getAliases(), 'mergeWith() does not remove an existing alias'); + $c1 = new Criteria(); + $c2 = new Criteria(); + $c2->addAlias('a', AuthorPeer::TABLE_NAME); + $c1->mergeWith($c2); + $this->assertEquals(array('a' => AuthorPeer::TABLE_NAME), $c1->getAliases(), 'mergeWith() merge aliases to an empty alias'); + $c1 = new Criteria(); + $c1->addAlias('b', BookPeer::TABLE_NAME); + $c2 = new Criteria(); + $c2->addAlias('a', AuthorPeer::TABLE_NAME); + $c1->mergeWith($c2); + $this->assertEquals(array('b' => BookPeer::TABLE_NAME, 'a' => AuthorPeer::TABLE_NAME), $c1->getAliases(), 'mergeWith() merge aliases to an existing alias'); + } + + /** + * @expectedException PropelException + */ + public function testMergeWithAliasesThrowsException() + { + $c1 = new Criteria(); + $c1->addAlias('b', BookPeer::TABLE_NAME); + $c2 = new Criteria(); + $c2->addAlias('b', AuthorPeer::TABLE_NAME); + $c1->mergeWith($c2); + } + + public function testMergeWithJoins() + { + $c1 = new Criteria(); + $c1->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::LEFT_JOIN); + $c2 = new Criteria(); + $c1->mergeWith($c2); + $joins = $c1->getJoins(); + $this->assertEquals(1, count($joins), 'mergeWith() does not remove an existing join'); + $this->assertEquals('LEFT JOIN author ON (book.author_id=author.id)', $joins[0]->toString(), 'mergeWith() does not remove an existing join'); + $c1 = new Criteria(); + $c2 = new Criteria(); + $c2->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::LEFT_JOIN); + $c1->mergeWith($c2); + $joins = $c1->getJoins(); + $this->assertEquals(1, count($joins), 'mergeWith() merge joins to an empty join'); + $this->assertEquals('LEFT JOIN author ON (book.author_id=author.id)', $joins[0]->toString(), 'mergeWith() merge joins to an empty join'); + $c1 = new Criteria(); + $c1->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID, Criteria::LEFT_JOIN); + $c2 = new Criteria(); + $c2->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID, Criteria::INNER_JOIN); + $c1->mergeWith($c2); + $joins = $c1->getJoins(); + $this->assertEquals(2, count($joins), 'mergeWith() merge joins to an existing join'); + $this->assertEquals('LEFT JOIN author ON (book.author_id=author.id)', $joins[0]->toString(), 'mergeWith() merge joins to an empty join'); + $this->assertEquals('INNER JOIN publisher ON (book.publisher_id=publisher.id)', $joins[1]->toString(), 'mergeWith() merge joins to an empty join'); + } + + public function testMergeWithFurtherModified() + { + $c1 = new Criteria(); + $c2 = new Criteria(); + $c2->setLimit(123); + $c1->mergeWith($c2); + $this->assertEquals(123, $c1->getLimit(), 'mergeWith() makes the merge'); + $c2->setLimit(456); + $this->assertEquals(123, $c1->getLimit(), 'further modifying a merged criteria does not affect the merger'); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaTest.php index c05b9b0e8..972cbb7a1 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/query/CriteriaTest.php @@ -8,967 +8,1204 @@ * @license MIT License */ -require_once 'tools/helpers/BaseTestCase.php'; -require_once dirname(__FILE__) . '/../../../../runtime/lib/query/Criteria.php'; -require_once dirname(__FILE__) . '/../../../../runtime/lib/util/BasePeer.php'; - -set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes"); -Propel::init('fixtures/bookstore/build/conf/bookstore-conf.php'); +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; /** * Test class for Criteria. * * @author Christopher Elkins * @author Sam Joseph - * @version $Id: CriteriaTest.php 1773 2010-05-25 10:25:06Z francois $ + * @version $Id$ * @package runtime.query */ -class CriteriaTest extends BaseTestCase +class CriteriaTest extends BookstoreTestBase { - /** - * The criteria to use in the test. - * @var Criteria - */ - private $c; - - /** - * DB adapter saved for later. - * - * @var DBAdapter - */ - private $savedAdapter; - - protected function setUp() - { - parent::setUp(); - $this->c = new Criteria(); - $this->savedAdapter = Propel::getDB(null); - Propel::setDB(null, new DBSQLite()); - } - - protected function tearDown() - { - Propel::setDB(null, $this->savedAdapter); - parent::tearDown(); - } - - /** - * Test basic adding of strings. - */ - public function testAddString() - { - $table = "myTable"; - $column = "myColumn"; - $value = "myValue"; - - // Add the string - $this->c->add($table . '.' . $column, $value); - - // Verify that the key exists - $this->assertTrue($this->c->containsKey($table . '.' . $column)); - - // Verify that what we get out is what we put in - $this->assertTrue($this->c->getValue($table . '.' . $column) === $value); - } - - public function testAddAndSameColumns() - { - $table1 = "myTable1"; - $column1 = "myColumn1"; - $value1 = "myValue1"; - $key1 = "$table1.$column1"; - - $table2 = "myTable1"; - $column2 = "myColumn1"; - $value2 = "myValue2"; - $key2 = "$table2.$column2"; - - $this->c->add($key1, $value1, Criteria::EQUAL); - $this->c->addAnd($key2, $value2, Criteria::EQUAL); - - $expect = "SELECT FROM myTable1 WHERE (myTable1.myColumn1=:p1 AND myTable1.myColumn1=:p2)"; - - $params = array(); - $result = BasePeer::createSelectSql($this->c, $params); - - $expect_params = array( - array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue1'), - array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue2'), - ); - - $this->assertEquals($expect, $result, 'addAnd() called on an existing column creates a combined criterion'); - $this->assertEquals($expect_params, $params, 'addAnd() called on an existing column creates a combined criterion'); - } - - public function testAddAndSameColumnsPropel14Compatibility() - { - $table1 = "myTable1"; - $column1 = "myColumn1"; - $value1 = "myValue1"; - $key1 = "$table1.$column1"; - - $table2 = "myTable1"; - $column2 = "myColumn1"; - $value2 = "myValue2"; - $key2 = "$table2.$column2"; - - $table3 = "myTable3"; - $column3 = "myColumn3"; - $value3 = "myValue3"; - $key3 = "$table3.$column3"; - - $this->c->add($key1, $value1, Criteria::EQUAL); - $this->c->add($key3, $value3, Criteria::EQUAL); - $this->c->addAnd($key2, $value2, Criteria::EQUAL); - - $expect = "SELECT FROM myTable1, myTable3 WHERE (myTable1.myColumn1=:p1 AND myTable1.myColumn1=:p2) AND myTable3.myColumn3=:p3"; - - $params = array(); - $result = BasePeer::createSelectSql($this->c, $params); - - $expect_params = array( - array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue1'), - array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue2'), - array('table' => 'myTable3', 'column' => 'myColumn3', 'value' => 'myValue3'), - ); - - $this->assertEquals($expect, $result, 'addAnd() called on an existing column creates a combined criterion'); - $this->assertEquals($expect_params, $params, 'addAnd() called on an existing column creates a combined criterion'); - } - - public function testAddAndDistinctColumns() - { - $table1 = "myTable1"; - $column1 = "myColumn1"; - $value1 = "myValue1"; - $key1 = "$table1.$column1"; - - $table2 = "myTable2"; - $column2 = "myColumn2"; - $value2 = "myValue2"; - $key2 = "$table2.$column2"; - - $this->c->add($key1, $value1, Criteria::EQUAL); - $this->c->addAnd($key2, $value2, Criteria::EQUAL); - - $expect = "SELECT FROM myTable1, myTable2 WHERE myTable1.myColumn1=:p1 AND myTable2.myColumn2=:p2"; - - $params = array(); - $result = BasePeer::createSelectSql($this->c, $params); - - $expect_params = array( - array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue1'), - array('table' => 'myTable2', 'column' => 'myColumn2', 'value' => 'myValue2'), - ); - - $this->assertEquals($expect, $result, 'addAnd() called on a distinct column adds a criterion to the criteria'); - $this->assertEquals($expect_params, $params, 'addAnd() called on a distinct column adds a criterion to the criteria'); - } - - public function testAddOrSameColumns() - { - $table1 = "myTable1"; - $column1 = "myColumn1"; - $value1 = "myValue1"; - $key1 = "$table1.$column1"; - - $table2 = "myTable1"; - $column2 = "myColumn1"; - $value2 = "myValue2"; - $key2 = "$table2.$column2"; - - $this->c->add($key1, $value1, Criteria::EQUAL); - $this->c->addOr($key2, $value2, Criteria::EQUAL); - - $expect = "SELECT FROM myTable1 WHERE (myTable1.myColumn1=:p1 OR myTable1.myColumn1=:p2)"; - - $params = array(); - $result = BasePeer::createSelectSql($this->c, $params); - - $expect_params = array( - array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue1'), - array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue2'), - ); - - $this->assertEquals($expect, $result, 'addOr() called on an existing column creates a combined criterion'); - $this->assertEquals($expect_params, $params, 'addOr() called on an existing column creates a combined criterion'); - } - - public function testAddAndOrColumnsPropel14Compatibility() - { - $table1 = "myTable1"; - $column1 = "myColumn1"; - $value1 = "myValue1"; - $key1 = "$table1.$column1"; - - $table2 = "myTable1"; - $column2 = "myColumn1"; - $value2 = "myValue2"; - $key2 = "$table2.$column2"; - - $table3 = "myTable3"; - $column3 = "myColumn3"; - $value3 = "myValue3"; - $key3 = "$table3.$column3"; - - $this->c->add($key1, $value1, Criteria::EQUAL); - $this->c->add($key3, $value3, Criteria::EQUAL); - $this->c->addOr($key2, $value2, Criteria::EQUAL); - - $expect = "SELECT FROM myTable1, myTable3 WHERE (myTable1.myColumn1=:p1 OR myTable1.myColumn1=:p2) AND myTable3.myColumn3=:p3"; - - $params = array(); - $result = BasePeer::createSelectSql($this->c, $params); - - $expect_params = array( - array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue1'), - array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue2'), - array('table' => 'myTable3', 'column' => 'myColumn3', 'value' => 'myValue3'), - ); - - $this->assertEquals($expect, $result, 'addOr() called on an existing column creates a combined criterion'); - $this->assertEquals($expect_params, $params, 'addOr() called on an existing column creates a combined criterion'); - } - - public function testAddOrDistinctColumns() - { - $table1 = "myTable1"; - $column1 = "myColumn1"; - $value1 = "myValue1"; - $key1 = "$table1.$column1"; - - $table2 = "myTable2"; - $column2 = "myColumn2"; - $value2 = "myValue2"; - $key2 = "$table2.$column2"; - - $this->c->add($key1, $value1, Criteria::EQUAL); - $this->c->addOr($key2, $value2, Criteria::EQUAL); - - $expect = "SELECT FROM myTable1, myTable2 WHERE (myTable1.myColumn1=:p1 OR myTable2.myColumn2=:p2)"; - - $params = array(); - $result = BasePeer::createSelectSql($this->c, $params); - - $expect_params = array( - array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue1'), - array('table' => 'myTable2', 'column' => 'myColumn2', 'value' => 'myValue2'), - ); - - $this->assertEquals($expect, $result, 'addOr() called on a distinct column adds a criterion to the latest criterion'); - $this->assertEquals($expect_params, $params, 'addOr() called on a distinct column adds a criterion to the latest criterion'); - } - - public function testAddOrEmptyCriteria() - { - $table1 = "myTable1"; - $column1 = "myColumn1"; - $value1 = "myValue1"; - $key1 = "$table1.$column1"; - - $this->c->addOr($key1, $value1, Criteria::EQUAL); - - $expect = "SELECT FROM myTable1 WHERE myTable1.myColumn1=:p1"; - - $params = array(); - $result = BasePeer::createSelectSql($this->c, $params); - - $expect_params = array( - array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue1'), - ); - - $this->assertEquals($expect, $result, 'addOr() called on an empty Criteria adds a criterion to the criteria'); - $this->assertEquals($expect_params, $params, 'addOr() called on an empty Criteria adds a criterion to the criteria'); - } - - /** - * Test Criterion.setIgnoreCase(). - * As the output is db specific the test just prints the result to - * System.out - */ - public function testCriterionIgnoreCase() - { - $originalDB = Propel::getDB(); - $adapters = array(new DBMySQL(), new DBPostgres()); - $expectedIgnore = array("UPPER(TABLE.COLUMN) LIKE UPPER(:p1)", "TABLE.COLUMN ILIKE :p1"); - - $i =0; - foreach ($adapters as $adapter) { - - Propel::setDB(null, $adapter); - $myCriteria = new Criteria(); - - $myCriterion = $myCriteria->getNewCriterion( - "TABLE.COLUMN", "FoObAr", Criteria::LIKE); - $sb = ""; - $params=array(); - $myCriterion->appendPsTo($sb, $params); - $expected = "TABLE.COLUMN LIKE :p1"; - - $this->assertEquals($expected, $sb); - - $ignoreCriterion = $myCriterion->setIgnoreCase(true); - - $sb = ""; - $params=array(); - $ignoreCriterion->appendPsTo($sb, $params); - // $expected = "UPPER(TABLE.COLUMN) LIKE UPPER(?)"; - $this->assertEquals($expectedIgnore[$i], $sb); - $i++; - } - Propel::setDB(null, $originalDB); - } - - public function testOrderByIgnoreCase() - { - $originalDB = Propel::getDB(); - Propel::setDB(null, new DBMySQL()); - - $criteria = new Criteria(); - $criteria->setIgnoreCase(true); - $criteria->addAscendingOrderByColumn(BookPeer::TITLE); - BookPeer::addSelectColumns($criteria); - $params=array(); - $sql = BasePeer::createSelectSql($criteria, $params); - $expectedSQL = 'SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID, UPPER(book.TITLE) FROM `book` ORDER BY UPPER(book.TITLE) ASC'; - $this->assertEquals($expectedSQL, $sql); - - Propel::setDB(null, $originalDB); - } - - /** - * Test that true is evaluated correctly. - */ - public function testBoolean() - { - $this->c = new Criteria(); - $this->c->add("TABLE.COLUMN", true); - - $expect = "SELECT FROM TABLE WHERE TABLE.COLUMN=:p1"; - $expect_params = array( array('table' => 'TABLE', 'column' => 'COLUMN', 'value' => true), - ); - try { - $params = array(); - $result = BasePeer::createSelectSql($this->c, $params); - } catch (PropelException $e) { - $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); - } - - $this->assertEquals($expect, $result, "Boolean test failed."); - $this->assertEquals($expect_params, $params); - - } - - public function testCurrentDate() - { - $this->c = new Criteria(); - $this->c->add("TABLE.TIME_COLUMN", Criteria::CURRENT_TIME); - $this->c->add("TABLE.DATE_COLUMN", Criteria::CURRENT_DATE); - - $expect = "SELECT FROM TABLE WHERE TABLE.TIME_COLUMN=CURRENT_TIME AND TABLE.DATE_COLUMN=CURRENT_DATE"; - - $result = null; - try { - $params = array(); - $result = BasePeer::createSelectSql($this->c, $params); - } catch (PropelException $e) { - print $e->getTraceAsString(); - $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); - } - - $this->assertEquals($expect, $result, "Current date test failed!"); - - } - - public function testCountAster() - { - $this->c = new Criteria(); - $this->c->addSelectColumn("COUNT(*)"); - $this->c->add("TABLE.TIME_COLUMN", Criteria::CURRENT_TIME); - $this->c->add("TABLE.DATE_COLUMN", Criteria::CURRENT_DATE); - - $expect = "SELECT COUNT(*) FROM TABLE WHERE TABLE.TIME_COLUMN=CURRENT_TIME AND TABLE.DATE_COLUMN=CURRENT_DATE"; - - $result = null; - try { - $params = array(); - $result = BasePeer::createSelectSql($this->c, $params); - } catch (PropelException $e) { - print $e->getTraceAsString(); - $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); - } - - $this->assertEquals($expect, $result); - - } - - public function testIn() - { - $c = new Criteria(); - $c->addSelectColumn("*"); - $c->add("TABLE.SOME_COLUMN", array(), Criteria::IN); - $c->add("TABLE.OTHER_COLUMN", array(1, 2, 3), Criteria::IN); - - $expect = "SELECT * FROM TABLE WHERE 1<>1 AND TABLE.OTHER_COLUMN IN (:p1,:p2,:p3)"; - try { - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - } catch (PropelException $e) { - print $e->getTraceAsString(); - $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); - } - $this->assertEquals($expect, $result); - } - - public function testInEmptyAfterFull() - { - $c = new Criteria(); - $c->addSelectColumn("*"); - $c->add("TABLE.OTHER_COLUMN", array(1, 2, 3), Criteria::IN); - $c->add("TABLE.SOME_COLUMN", array(), Criteria::IN); - - $expect = "SELECT * FROM TABLE WHERE TABLE.OTHER_COLUMN IN (:p1,:p2,:p3) AND 1<>1"; - try { - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - } catch (PropelException $e) { - print $e->getTraceAsString(); - $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); - } - $this->assertEquals($expect, $result); - } - - public function testInNested() - { - // now do a nested logic test, just for sanity (not that this should be any surprise) - - $c = new Criteria(); - $c->addSelectColumn("*"); - $myCriterion = $c->getNewCriterion("TABLE.COLUMN", array(), Criteria::IN); - $myCriterion->addOr($c->getNewCriterion("TABLE.COLUMN2", array(1,2), Criteria::IN)); - $c->add($myCriterion); - - $expect = "SELECT * FROM TABLE WHERE (1<>1 OR TABLE.COLUMN2 IN (:p1,:p2))"; - try { - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - } catch (PropelException $e) { - print $e->getTraceAsString(); - $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); - } - $this->assertEquals($expect, $result); - - } - - public function testJoinObject () - { - $j = new Join('TABLE_A.COL_1', 'TABLE_B.COL_2'); - $this->assertEquals(null, $j->getJoinType()); - $this->assertEquals('TABLE_A.COL_1', $j->getLeftColumn()); - $this->assertEquals('TABLE_A', $j->getLeftTableName()); - $this->assertEquals('COL_1', $j->getLeftColumnName()); - $this->assertEquals('TABLE_B.COL_2', $j->getRightColumn()); - $this->assertEquals('TABLE_B', $j->getRightTableName()); - $this->assertEquals('COL_2', $j->getRightColumnName()); - - $j = new Join('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::LEFT_JOIN); - $this->assertEquals('LEFT JOIN', $j->getJoinType()); - $this->assertEquals('TABLE_A.COL_1', $j->getLeftColumn()); - $this->assertEquals('TABLE_B.COL_1', $j->getRightColumn()); - - $j = new Join('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::RIGHT_JOIN); - $this->assertEquals('RIGHT JOIN', $j->getJoinType()); - $this->assertEquals('TABLE_A.COL_1', $j->getLeftColumn()); - $this->assertEquals('TABLE_B.COL_1', $j->getRightColumn()); - - $j = new Join('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::INNER_JOIN); - $this->assertEquals('INNER JOIN', $j->getJoinType()); - $this->assertEquals('TABLE_A.COL_1', $j->getLeftColumn()); - $this->assertEquals('TABLE_B.COL_1', $j->getRightColumn()); - - $j = new Join(array('TABLE_A.COL_1', 'TABLE_A.COL_2'), array('TABLE_B.COL_1', 'TABLE_B.COL_2'), Criteria::INNER_JOIN); - $this->assertEquals('TABLE_A.COL_1', $j->getLeftColumn(0)); - $this->assertEquals('TABLE_A.COL_2', $j->getLeftColumn(1)); - $this->assertEquals('TABLE_B.COL_1', $j->getRightColumn(0)); - $this->assertEquals('TABLE_B.COL_2', $j->getRightColumn(1)); - } - - public function testAddStraightJoin () - { - $c = new Criteria(); - $c->addSelectColumn("*"); - $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_1'); // straight join - - $expect = "SELECT * FROM TABLE_A, TABLE_B WHERE TABLE_A.COL_1=TABLE_B.COL_1"; - try { - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - } catch (PropelException $e) { - print $e->getTraceAsString(); - $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); - } - $this->assertEquals($expect, $result); - } - - public function testAddSeveralJoins () - { - $c = new Criteria(); - $c->addSelectColumn("*"); - $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_1'); - $c->addJoin('TABLE_B.COL_X', 'TABLE_D.COL_X'); - - $expect = 'SELECT * FROM TABLE_A, TABLE_B, TABLE_D ' - .'WHERE TABLE_A.COL_1=TABLE_B.COL_1 AND TABLE_B.COL_X=TABLE_D.COL_X'; - try { - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - } catch (PropelException $e) { - print $e->getTraceAsString(); - $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); - } - $this->assertEquals($expect, $result); - } - - public function testAddLeftJoin () - { - $c = new Criteria(); - $c->addSelectColumn("TABLE_A.*"); - $c->addSelectColumn("TABLE_B.*"); - $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_2', Criteria::LEFT_JOIN); - - $expect = "SELECT TABLE_A.*, TABLE_B.* FROM TABLE_A LEFT JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_2)"; - try { - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - } catch (PropelException $e) { - print $e->getTraceAsString(); - $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); - } - $this->assertEquals($expect, $result); - } - - public function testAddSeveralLeftJoins () - { - // Fails.. Suspect answer in the chunk starting at BasePeer:605 - $c = new Criteria(); - $c->addSelectColumn('*'); - $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::LEFT_JOIN); - $c->addJoin('TABLE_A.COL_2', 'TABLE_C.COL_2', Criteria::LEFT_JOIN); - - $expect = 'SELECT * FROM TABLE_A ' - .'LEFT JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1) ' - .'LEFT JOIN TABLE_C ON (TABLE_A.COL_2=TABLE_C.COL_2)'; - try { - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - } catch (PropelException $e) { - print $e->getTraceAsString(); - $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); - } - $this->assertEquals($expect, $result); - } - - public function testAddRightJoin () - { - $c = new Criteria(); - $c->addSelectColumn("*"); - $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_2', Criteria::RIGHT_JOIN); - - $expect = "SELECT * FROM TABLE_A RIGHT JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_2)"; - try { - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - } catch (PropelException $e) { - print $e->getTraceAsString(); - $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); - } - $this->assertEquals($expect, $result); - } - - public function testAddSeveralRightJoins () - { - // Fails.. Suspect answer in the chunk starting at BasePeer:605 - $c = new Criteria(); - $c->addSelectColumn('*'); - $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::RIGHT_JOIN); - $c->addJoin('TABLE_A.COL_2', 'TABLE_C.COL_2', Criteria::RIGHT_JOIN); - - $expect = 'SELECT * FROM TABLE_A ' - .'RIGHT JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1) ' - .'RIGHT JOIN TABLE_C ON (TABLE_A.COL_2=TABLE_C.COL_2)'; - try { - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - } catch (PropelException $e) { - print $e->getTraceAsString(); - $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); - } - $this->assertEquals($expect, $result); - } - - public function testAddInnerJoin () - { - $c = new Criteria(); - $c->addSelectColumn("*"); - $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::INNER_JOIN); - - $expect = "SELECT * FROM TABLE_A INNER JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1)"; - try { - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - } catch (PropelException $e) { - print $e->getTraceAsString(); - $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); - } - $this->assertEquals($expect, $result); - } - - public function testAddSeveralInnerJoin () - { - $c = new Criteria(); - $c->addSelectColumn("*"); - $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::INNER_JOIN); - $c->addJoin('TABLE_B.COL_1', 'TABLE_C.COL_1', Criteria::INNER_JOIN); - - $expect = 'SELECT * FROM TABLE_A ' - .'INNER JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1) ' - .'INNER JOIN TABLE_C ON (TABLE_B.COL_1=TABLE_C.COL_1)'; - try { - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - } catch (PropelException $e) { - print $e->getTraceAsString(); - $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); - } - $this->assertEquals($expect, $result); - } - - /** - * @link http://propel.phpdb.org/trac/ticket/451 - */ - public function testSeveralMixedJoinOrders() - { - $c = new Criteria(); - $c->clearSelectColumns()-> - addJoin("TABLE_A.FOO_ID", "TABLE_B.ID", Criteria::LEFT_JOIN)-> - addJoin("TABLE_A.BAR_ID", "TABLE_C.ID")-> - addSelectColumn("TABLE_A.ID"); - - # These are no longer different, see http://propel.phpdb.org/trac/ticket/283#comment:8 - #$db = Propel::getDB(); - # - #if ($db instanceof DBMySQL) { - # $expect = 'SELECT TABLE_A.ID FROM (TABLE_A CROSS JOIN TABLE_C)' - # .' LEFT JOIN TABLE_B ON (TABLE_A.FOO_ID=TABLE_B.ID) WHERE TABLE_A.BAR_ID=TABLE_C.ID'; - #} else { - $expect = 'SELECT TABLE_A.ID FROM TABLE_A CROSS JOIN TABLE_C' - .' LEFT JOIN TABLE_B ON (TABLE_A.FOO_ID=TABLE_B.ID) WHERE TABLE_A.BAR_ID=TABLE_C.ID'; - #} - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - $this->assertEquals($expect, $result); - } - - /** - * @link http://propel.phpdb.org/trac/ticket/606 - */ - public function testAddJoinArray() - { - $c = new Criteria(); - $c->clearSelectColumns()-> - addJoin(array('TABLE_A.FOO_ID'), array('TABLE_B.ID'), Criteria::LEFT_JOIN)-> - addSelectColumn("TABLE_A.ID"); - - $expect = 'SELECT TABLE_A.ID FROM TABLE_A' - .' LEFT JOIN TABLE_B ON (TABLE_A.FOO_ID=TABLE_B.ID)'; - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - $this->assertEquals($expect, $result); - } - - /** - * @link http://propel.phpdb.org/trac/ticket/606 - */ - public function testAddJoinArrayMultiple() - { - $c = new Criteria(); - $c->clearSelectColumns()-> - addJoin( - array('TABLE_A.FOO_ID', 'TABLE_A.BAR'), - array('TABLE_B.ID', 'TABLE_B.BAZ'), - Criteria::LEFT_JOIN)-> - addSelectColumn("TABLE_A.ID"); - - $expect = 'SELECT TABLE_A.ID FROM TABLE_A' - .' LEFT JOIN TABLE_B ON (TABLE_A.FOO_ID=TABLE_B.ID AND TABLE_A.BAR=TABLE_B.BAZ)'; - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - $this->assertEquals($expect, $result); - } - - /** - * Test the Criteria::addJoinMultiple() method with an implicit join - * - * @link http://propel.phpdb.org/trac/ticket/606 - */ - public function testAddJoinMultiple() - { - $c = new Criteria(); - $c-> - clearSelectColumns()-> - addMultipleJoin(array( - array('TABLE_A.FOO_ID', 'TABLE_B.ID'), - array('TABLE_A.BAR', 'TABLE_B.BAZ')))-> - addSelectColumn("TABLE_A.ID"); - - $expect = 'SELECT TABLE_A.ID FROM TABLE_A, TABLE_B ' - . 'WHERE TABLE_A.FOO_ID=TABLE_B.ID AND TABLE_A.BAR=TABLE_B.BAZ'; - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - $this->assertEquals($expect, $result); - } - - /** - * Test the Criteria::addJoinMultiple() method with a value as second argument - * - * @link http://propel.phpdb.org/trac/ticket/606 - */ - public function testAddJoinMultipleValue() - { - $c = new Criteria(); - $c-> - clearSelectColumns()-> - addMultipleJoin(array( - array('TABLE_A.FOO_ID', 'TABLE_B.ID'), - array('TABLE_A.BAR', 3)))-> - addSelectColumn("TABLE_A.ID"); - - $expect = 'SELECT TABLE_A.ID FROM TABLE_A, TABLE_B ' - . 'WHERE TABLE_A.FOO_ID=TABLE_B.ID AND TABLE_A.BAR=3'; - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - $this->assertEquals($expect, $result); - } - - /** - * Test the Criteria::addJoinMultiple() method with a joinType - * - * @link http://propel.phpdb.org/trac/ticket/606 - */ - public function testAddJoinMultipleWithJoinType() - { - $c = new Criteria(); - $c-> - clearSelectColumns()-> - addMultipleJoin(array( - array('TABLE_A.FOO_ID', 'TABLE_B.ID'), - array('TABLE_A.BAR', 'TABLE_B.BAZ')), - Criteria::LEFT_JOIN)-> - addSelectColumn("TABLE_A.ID"); - - $expect = 'SELECT TABLE_A.ID FROM TABLE_A ' - . 'LEFT JOIN TABLE_B ON (TABLE_A.FOO_ID=TABLE_B.ID AND TABLE_A.BAR=TABLE_B.BAZ)'; - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - $this->assertEquals($expect, $result); - } + /** + * The criteria to use in the test. + * @var Criteria + */ + private $c; /** - * Test the Criteria::addJoinMultiple() method with operator - * - * @link http://propel.phpdb.org/trac/ticket/606 - */ - public function testAddJoinMultipleWithOperator() - { - $c = new Criteria(); - $c-> - clearSelectColumns()-> - addMultipleJoin(array( - array('TABLE_A.FOO_ID', 'TABLE_B.ID', Criteria::GREATER_EQUAL), - array('TABLE_A.BAR', 'TABLE_B.BAZ', Criteria::LESS_THAN)))-> - addSelectColumn("TABLE_A.ID"); - - $expect = 'SELECT TABLE_A.ID FROM TABLE_A, TABLE_B ' - . 'WHERE TABLE_A.FOO_ID>=TABLE_B.ID AND TABLE_A.BARassertEquals($expect, $result); - } - - /** - * Test the Criteria::addJoinMultiple() method with join type and operator - * - * @link http://propel.phpdb.org/trac/ticket/606 - */ - public function testAddJoinMultipleWithJoinTypeAndOperator() - { - $c = new Criteria(); - $c-> - clearSelectColumns()-> - addMultipleJoin(array( - array('TABLE_A.FOO_ID', 'TABLE_B.ID', Criteria::GREATER_EQUAL), - array('TABLE_A.BAR', 'TABLE_B.BAZ', Criteria::LESS_THAN)), - Criteria::LEFT_JOIN)-> - addSelectColumn("TABLE_A.ID"); - - $expect = 'SELECT TABLE_A.ID FROM TABLE_A ' - . 'LEFT JOIN TABLE_B ON (TABLE_A.FOO_ID>=TABLE_B.ID AND TABLE_A.BARassertEquals($expect, $result); - } - - /** - * Test the Criteria::CUSTOM behavior. - */ - public function testCustomOperator() - { - $c = new Criteria(); - $c->addSelectColumn('A.COL'); - $c->add('A.COL', 'date_part(\'YYYY\', A.COL) = \'2007\'', Criteria::CUSTOM); + * DB adapter saved for later. + * + * @var DBAdapter + */ + private $savedAdapter; - $expected = "SELECT A.COL FROM A WHERE date_part('YYYY', A.COL) = '2007'"; - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - $this->assertEquals($expected, $result); - } - - /** - * Tests adding duplicate joins. - * @link http://propel.phpdb.org/trac/ticket/613 - */ - public function testAddJoin_Duplicate() - { - $c = new Criteria(); - - $c->addJoin("tbl.COL1", "tbl.COL2", Criteria::LEFT_JOIN); - $c->addJoin("tbl.COL1", "tbl.COL2", Criteria::LEFT_JOIN); - $this->assertEquals(1, count($c->getJoins()), "Expected not to have duplciate LJOIN added."); - - $c->addJoin("tbl.COL1", "tbl.COL2", Criteria::RIGHT_JOIN); - $c->addJoin("tbl.COL1", "tbl.COL2", Criteria::RIGHT_JOIN); - $this->assertEquals(2, count($c->getJoins()), "Expected 1 new right join to be added."); - - $c->addJoin("tbl.COL1", "tbl.COL2"); - $c->addJoin("tbl.COL1", "tbl.COL2"); - $this->assertEquals(3, count($c->getJoins()), "Expected 1 new implicit join to be added."); - - $c->addJoin("tbl.COL3", "tbl.COL4"); - $this->assertEquals(4, count($c->getJoins()), "Expected new col join to be added."); - - } - - /** - * @link http://propel.phpdb.org/trac/ticket/634 - */ - public function testHasSelectClause() - { - $c = new Criteria(); - $c->addSelectColumn("foo"); - - $this->assertTrue($c->hasSelectClause()); - - $c = new Criteria(); - $c->addAsColumn("foo", "bar"); - - $this->assertTrue($c->hasSelectClause()); - } - - /** - * Tests including aliases in criterion objects. - * @link http://propel.phpdb.org/trac/ticket/636 - */ - public function testAliasInCriterion() - { - $c = new Criteria(); - $c->addAsColumn("column_alias", "tbl.COL1"); - $crit = $c->getNewCriterion("column_alias", "FOO"); - $this->assertNull($crit->getTable()); - $this->assertEquals("column_alias", $crit->getColumn()); - $c->addHaving($crit); // produces invalid SQL referring to '.olumn_alias' - } - - /** - * Test whether GROUP BY is being respected in equals() check. - * @link http://propel.phpdb.org/trac/ticket/674 - */ - public function testEqualsGroupBy() - { - $c1 = new Criteria(); - $c1->addGroupByColumn('GBY1'); - - $c2 = new Criteria(); - $c2->addGroupByColumn('GBY2'); - - $this->assertFalse($c2->equals($c1), "Expected Criteria NOT to be the same with different GROUP BY columns"); - - $c3 = new Criteria(); - $c3->addGroupByColumn('GBY1'); - $c4 = new Criteria(); - $c4->addGroupByColumn('GBY1'); - $this->assertTrue($c4->equals($c3), "Expected Criteria objects to match."); - } + protected function setUp() + { + parent::setUp(); + $this->c = new Criteria(); + $this->savedAdapter = Propel::getDB(null); + Propel::setDB(null, new DBSQLite()); + } - /** - * Test whether calling setDistinct twice puts in two distinct keywords or not. - * @link http://propel.phpdb.org/trac/ticket/716 - */ - public function testDoubleSelectModifiers() - { - $c = new Criteria(); - $c->setDistinct(); - $this->assertEquals(array(Criteria::DISTINCT), $c->getSelectModifiers(), 'Initial setDistinct works'); - $c->setDistinct(); - $this->assertEquals(array(Criteria::DISTINCT), $c->getSelectModifiers(), 'Calling setDistinct again leaves a single distinct'); - $c->setAll(); - $this->assertEquals(array(Criteria::ALL), $c->getSelectModifiers(), 'All keyword is swaps distinct out'); - $c->setAll(); - $this->assertEquals(array(Criteria::ALL), $c->getSelectModifiers(), 'Calling setAll leaves a single all'); - $c->setDistinct(); - $this->assertEquals(array(Criteria::DISTINCT), $c->getSelectModifiers(), 'All back to distinct works'); - - $c2 = new Criteria(); - $c2->setAll(); - $this->assertEquals(array(Criteria::ALL), $c2->getSelectModifiers(), 'Initial setAll works'); - } + protected function tearDown() + { + Propel::setDB(null, $this->savedAdapter); + parent::tearDown(); + } - public function testAddSelectModifier() - { - $c = new Criteria(); - $c->setDistinct(); - $c->addSelectModifier('SQL_CALC_FOUND_ROWS'); - $this->assertEquals(array(Criteria::DISTINCT, 'SQL_CALC_FOUND_ROWS'), $c->getSelectModifiers(), 'addSelectModifier() adds a select modifier to the Criteria'); - $c->addSelectModifier('SQL_CALC_FOUND_ROWS'); - $this->assertEquals(array(Criteria::DISTINCT, 'SQL_CALC_FOUND_ROWS'), $c->getSelectModifiers(), 'addSelectModifier() adds a select modifier only once'); - $params = array(); - $result = BasePeer::createSelectSql($c, $params); - $this->assertEquals('SELECT DISTINCT SQL_CALC_FOUND_ROWS FROM ', $result, 'addSelectModifier() adds a modifier to the final query'); - } - - public function testClone() - { - $c1 = new Criteria(); - $c1->add('tbl.COL1', 'foo', Criteria::EQUAL); - $c2 = clone $c1; - $c2->addAnd('tbl.COL1', 'bar', Criteria::EQUAL); - $nbCrit = 0; - foreach ($c1->keys() as $key) { - foreach ($c1->getCriterion($key)->getAttachedCriterion() as $criterion) { - $nbCrit++; - } - } - $this->assertEquals(1, $nbCrit, 'cloning a Criteria clones its Criterions'); - } - - public function testComment() - { - $c = new Criteria(); - $this->assertNull($c->getComment(), 'Comment is null by default'); - $c2 = $c->setComment('foo'); - $this->assertEquals('foo', $c->getComment(), 'Comment is set by setComment()'); - $this->assertEquals($c, $c2, 'setComment() returns the current Criteria'); - $c->setComment(); - $this->assertNull($c->getComment(), 'Comment is reset by setComment(null)'); - } + /** + * Test basic adding of strings. + */ + public function testAddString() + { + $table = "myTable"; + $column = "myColumn"; + $value = "myValue"; + + // Add the string + $this->c->add($table . '.' . $column, $value); + + // Verify that the key exists + $this->assertTrue($this->c->containsKey($table . '.' . $column)); + + // Verify that what we get out is what we put in + $this->assertTrue($this->c->getValue($table . '.' . $column) === $value); + } + + /** + * Test basic adding of strings for table with explicit schema. + */ + public function testAddStringWithSchemas() + { + $table = "mySchema.myTable"; + $column = "myColumn"; + $value = "myValue"; + + // Add the string + $this->c->add($table . '.' . $column, $value); + + // Verify that the key exists + $this->assertTrue($this->c->containsKey($table . '.' . $column)); + + // Verify that what we get out is what we put in + $this->assertTrue($this->c->getValue($table . '.' . $column) === $value); + } + + public function testAddAndSameColumns() + { + $table1 = "myTable1"; + $column1 = "myColumn1"; + $value1 = "myValue1"; + $key1 = "$table1.$column1"; + + $table2 = "myTable1"; + $column2 = "myColumn1"; + $value2 = "myValue2"; + $key2 = "$table2.$column2"; + + $this->c->add($key1, $value1, Criteria::EQUAL); + $this->c->addAnd($key2, $value2, Criteria::EQUAL); + + $expect = "SELECT FROM myTable1 WHERE (myTable1.myColumn1=:p1 AND myTable1.myColumn1=:p2)"; + + $params = array(); + $result = BasePeer::createSelectSql($this->c, $params); + + $expect_params = array( + array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue1'), + array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue2'), + ); + + $this->assertEquals($expect, $result, 'addAnd() called on an existing column creates a combined criterion'); + $this->assertEquals($expect_params, $params, 'addAnd() called on an existing column creates a combined criterion'); + } + + public function testAddAndSameColumnsPropel14Compatibility() + { + $table1 = "myTable1"; + $column1 = "myColumn1"; + $value1 = "myValue1"; + $key1 = "$table1.$column1"; + + $table2 = "myTable1"; + $column2 = "myColumn1"; + $value2 = "myValue2"; + $key2 = "$table2.$column2"; + + $table3 = "myTable3"; + $column3 = "myColumn3"; + $value3 = "myValue3"; + $key3 = "$table3.$column3"; + + $this->c->add($key1, $value1, Criteria::EQUAL); + $this->c->add($key3, $value3, Criteria::EQUAL); + $this->c->addAnd($key2, $value2, Criteria::EQUAL); + + $expect = "SELECT FROM myTable1, myTable3 WHERE (myTable1.myColumn1=:p1 AND myTable1.myColumn1=:p2) AND myTable3.myColumn3=:p3"; + + $params = array(); + $result = BasePeer::createSelectSql($this->c, $params); + + $expect_params = array( + array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue1'), + array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue2'), + array('table' => 'myTable3', 'column' => 'myColumn3', 'value' => 'myValue3'), + ); + + $this->assertEquals($expect, $result, 'addAnd() called on an existing column creates a combined criterion'); + $this->assertEquals($expect_params, $params, 'addAnd() called on an existing column creates a combined criterion'); + } + + public function testAddAndDistinctColumns() + { + $table1 = "myTable1"; + $column1 = "myColumn1"; + $value1 = "myValue1"; + $key1 = "$table1.$column1"; + + $table2 = "myTable2"; + $column2 = "myColumn2"; + $value2 = "myValue2"; + $key2 = "$table2.$column2"; + + $this->c->add($key1, $value1, Criteria::EQUAL); + $this->c->addAnd($key2, $value2, Criteria::EQUAL); + + $expect = "SELECT FROM myTable1, myTable2 WHERE myTable1.myColumn1=:p1 AND myTable2.myColumn2=:p2"; + + $params = array(); + $result = BasePeer::createSelectSql($this->c, $params); + + $expect_params = array( + array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue1'), + array('table' => 'myTable2', 'column' => 'myColumn2', 'value' => 'myValue2'), + ); + + $this->assertEquals($expect, $result, 'addAnd() called on a distinct column adds a criterion to the criteria'); + $this->assertEquals($expect_params, $params, 'addAnd() called on a distinct column adds a criterion to the criteria'); + } + + public function testAddOrSameColumns() + { + $table1 = "myTable1"; + $column1 = "myColumn1"; + $value1 = "myValue1"; + $key1 = "$table1.$column1"; + + $table2 = "myTable1"; + $column2 = "myColumn1"; + $value2 = "myValue2"; + $key2 = "$table2.$column2"; + + $this->c->add($key1, $value1, Criteria::EQUAL); + $this->c->addOr($key2, $value2, Criteria::EQUAL); + + $expect = "SELECT FROM myTable1 WHERE (myTable1.myColumn1=:p1 OR myTable1.myColumn1=:p2)"; + + $params = array(); + $result = BasePeer::createSelectSql($this->c, $params); + + $expect_params = array( + array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue1'), + array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue2'), + ); + + $this->assertEquals($expect, $result, 'addOr() called on an existing column creates a combined criterion'); + $this->assertEquals($expect_params, $params, 'addOr() called on an existing column creates a combined criterion'); + } + + public function testAddAndOrColumnsPropel14Compatibility() + { + $table1 = "myTable1"; + $column1 = "myColumn1"; + $value1 = "myValue1"; + $key1 = "$table1.$column1"; + + $table2 = "myTable1"; + $column2 = "myColumn1"; + $value2 = "myValue2"; + $key2 = "$table2.$column2"; + + $table3 = "myTable3"; + $column3 = "myColumn3"; + $value3 = "myValue3"; + $key3 = "$table3.$column3"; + + $this->c->add($key1, $value1, Criteria::EQUAL); + $this->c->add($key3, $value3, Criteria::EQUAL); + $this->c->addOr($key2, $value2, Criteria::EQUAL); + + $expect = "SELECT FROM myTable1, myTable3 WHERE (myTable1.myColumn1=:p1 OR myTable1.myColumn1=:p2) AND myTable3.myColumn3=:p3"; + + $params = array(); + $result = BasePeer::createSelectSql($this->c, $params); + + $expect_params = array( + array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue1'), + array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue2'), + array('table' => 'myTable3', 'column' => 'myColumn3', 'value' => 'myValue3'), + ); + + $this->assertEquals($expect, $result, 'addOr() called on an existing column creates a combined criterion'); + $this->assertEquals($expect_params, $params, 'addOr() called on an existing column creates a combined criterion'); + } + + public function testAddOrDistinctColumns() + { + $table1 = "myTable1"; + $column1 = "myColumn1"; + $value1 = "myValue1"; + $key1 = "$table1.$column1"; + + $table2 = "myTable2"; + $column2 = "myColumn2"; + $value2 = "myValue2"; + $key2 = "$table2.$column2"; + + $this->c->add($key1, $value1, Criteria::EQUAL); + $this->c->addOr($key2, $value2, Criteria::EQUAL); + + $expect = "SELECT FROM myTable1, myTable2 WHERE (myTable1.myColumn1=:p1 OR myTable2.myColumn2=:p2)"; + + $params = array(); + $result = BasePeer::createSelectSql($this->c, $params); + + $expect_params = array( + array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue1'), + array('table' => 'myTable2', 'column' => 'myColumn2', 'value' => 'myValue2'), + ); + + $this->assertEquals($expect, $result, 'addOr() called on a distinct column adds a criterion to the latest criterion'); + $this->assertEquals($expect_params, $params, 'addOr() called on a distinct column adds a criterion to the latest criterion'); + } + + public function testAddOrEmptyCriteria() + { + $table1 = "myTable1"; + $column1 = "myColumn1"; + $value1 = "myValue1"; + $key1 = "$table1.$column1"; + + $this->c->addOr($key1, $value1, Criteria::EQUAL); + + $expect = "SELECT FROM myTable1 WHERE myTable1.myColumn1=:p1"; + + $params = array(); + $result = BasePeer::createSelectSql($this->c, $params); + + $expect_params = array( + array('table' => 'myTable1', 'column' => 'myColumn1', 'value' => 'myValue1'), + ); + + $this->assertEquals($expect, $result, 'addOr() called on an empty Criteria adds a criterion to the criteria'); + $this->assertEquals($expect_params, $params, 'addOr() called on an empty Criteria adds a criterion to the criteria'); + } + + /** + * Test Criterion.setIgnoreCase(). + * As the output is db specific the test just prints the result to + * System.out + */ + public function testCriterionIgnoreCase() + { + $originalDB = Propel::getDB(); + $adapters = array(new DBMySQL(), new DBPostgres()); + $expectedIgnore = array("UPPER(TABLE.COLUMN) LIKE UPPER(:p1)", "TABLE.COLUMN ILIKE :p1"); + + $i =0; + foreach ($adapters as $adapter) { + + Propel::setDB(null, $adapter); + $myCriteria = new Criteria(); + + $myCriterion = $myCriteria->getNewCriterion( + "TABLE.COLUMN", "FoObAr", Criteria::LIKE); + $sb = ""; + $params=array(); + $myCriterion->appendPsTo($sb, $params); + $expected = "TABLE.COLUMN LIKE :p1"; + + $this->assertEquals($expected, $sb); + + $ignoreCriterion = $myCriterion->setIgnoreCase(true); + + $sb = ""; + $params=array(); + $ignoreCriterion->appendPsTo($sb, $params); + // $expected = "UPPER(TABLE.COLUMN) LIKE UPPER(?)"; + $this->assertEquals($expectedIgnore[$i], $sb); + $i++; + } + Propel::setDB(null, $originalDB); + } + + public function testOrderByIgnoreCase() + { + $originalDB = Propel::getDB(); + Propel::setDB(null, new DBMySQL()); + + $criteria = new Criteria(); + $criteria->setIgnoreCase(true); + $criteria->addAscendingOrderByColumn(BookPeer::TITLE); + BookPeer::addSelectColumns($criteria); + $params=array(); + $sql = BasePeer::createSelectSql($criteria, $params); + $expectedSQL = 'SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id, UPPER(book.title) FROM `book` ORDER BY UPPER(book.title) ASC'; + $this->assertEquals($expectedSQL, $sql); + + Propel::setDB(null, $originalDB); + } + + public function testOrderByIgnoreCaseWithWhereClause() + { + $originalDB = Propel::getDB(); + Propel::setDB(null, new DBMySQL()); + + $criteria = new Criteria(); + $criteria->setIgnoreCase(true); + $criteria->addAscendingOrderByColumn(BookPeer::TITLE); + $criteria->add('book.title', false); + BookPeer::addSelectColumns($criteria); + $params=array(); + $sql = BasePeer::createSelectSql($criteria, $params); + $expectedSQL = 'SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id, UPPER(book.title) FROM `book` WHERE UPPER(book.title)=UPPER(:p1) ORDER BY UPPER(book.title) ASC'; + $this->assertEquals($expectedSQL, $sql); + + Propel::setDB(null, $originalDB); + } + + /** + * Test that true is evaluated correctly. + */ + public function testBoolean() + { + $this->c = new Criteria(); + $this->c->add("TABLE.COLUMN", true); + + $expect = "SELECT FROM TABLE WHERE TABLE.COLUMN=:p1"; + $expect_params = array( array('table' => 'TABLE', 'column' => 'COLUMN', 'value' => true), + ); + try { + $params = array(); + $result = BasePeer::createSelectSql($this->c, $params); + } catch (PropelException $e) { + $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); + } + + $this->assertEquals($expect, $result, "Boolean test failed."); + $this->assertEquals($expect_params, $params); + + } + + public function testCurrentDate() + { + $this->c = new Criteria(); + $this->c->add("TABLE.TIME_COLUMN", Criteria::CURRENT_TIME); + $this->c->add("TABLE.DATE_COLUMN", Criteria::CURRENT_DATE); + + $expect = "SELECT FROM TABLE WHERE TABLE.TIME_COLUMN=CURRENT_TIME AND TABLE.DATE_COLUMN=CURRENT_DATE"; + + $result = null; + try { + $params = array(); + $result = BasePeer::createSelectSql($this->c, $params); + } catch (PropelException $e) { + print $e->getTraceAsString(); + $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); + } + + $this->assertEquals($expect, $result, "Current date test failed!"); + + } + + public function testCountAster() + { + $this->c = new Criteria(); + $this->c->addSelectColumn("COUNT(*)"); + $this->c->add("TABLE.TIME_COLUMN", Criteria::CURRENT_TIME); + $this->c->add("TABLE.DATE_COLUMN", Criteria::CURRENT_DATE); + + $expect = "SELECT COUNT(*) FROM TABLE WHERE TABLE.TIME_COLUMN=CURRENT_TIME AND TABLE.DATE_COLUMN=CURRENT_DATE"; + + $result = null; + try { + $params = array(); + $result = BasePeer::createSelectSql($this->c, $params); + } catch (PropelException $e) { + print $e->getTraceAsString(); + $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); + } + + $this->assertEquals($expect, $result); + + } + + public function testInOperator() + { + $c = new Criteria(); + $c->addSelectColumn("*"); + $c->add("TABLE.SOME_COLUMN", array(), Criteria::IN); + $c->add("TABLE.OTHER_COLUMN", array(1, 2, 3), Criteria::IN); + + $expect = "SELECT * FROM TABLE WHERE 1<>1 AND TABLE.OTHER_COLUMN IN (:p1,:p2,:p3)"; + try { + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + } catch (PropelException $e) { + print $e->getTraceAsString(); + $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); + } + $this->assertEquals($expect, $result); + } + + public function testInOperatorEmptyAfterFull() + { + $c = new Criteria(); + $c->addSelectColumn("*"); + $c->add("TABLE.OTHER_COLUMN", array(1, 2, 3), Criteria::IN); + $c->add("TABLE.SOME_COLUMN", array(), Criteria::IN); + + $expect = "SELECT * FROM TABLE WHERE TABLE.OTHER_COLUMN IN (:p1,:p2,:p3) AND 1<>1"; + try { + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + } catch (PropelException $e) { + print $e->getTraceAsString(); + $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); + } + $this->assertEquals($expect, $result); + } + + public function testInOperatorNested() + { + // now do a nested logic test, just for sanity (not that this should be any surprise) + + $c = new Criteria(); + $c->addSelectColumn("*"); + $myCriterion = $c->getNewCriterion("TABLE.COLUMN", array(), Criteria::IN); + $myCriterion->addOr($c->getNewCriterion("TABLE.COLUMN2", array(1,2), Criteria::IN)); + $c->add($myCriterion); + + $expect = "SELECT * FROM TABLE WHERE (1<>1 OR TABLE.COLUMN2 IN (:p1,:p2))"; + try { + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + } catch (PropelException $e) { + print $e->getTraceAsString(); + $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); + } + $this->assertEquals($expect, $result); + + } + + /** + * Test the Criteria::CUSTOM behavior. + */ + public function testCustomOperator() + { + $c = new Criteria(); + $c->addSelectColumn('A.COL'); + $c->add('A.COL', 'date_part(\'YYYY\', A.COL) = \'2007\'', Criteria::CUSTOM); + + $expected = "SELECT A.COL FROM A WHERE date_part('YYYY', A.COL) = '2007'"; + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + $this->assertEquals($expected, $result); + } + + public function testAddRaw() + { + $db = Propel::getDB(); + $c = new Criteria(); + $c->addSelectColumn('A.COL'); + $c->addAsColumn('foo', 'B.COL'); + $c->add('foo = ?', 123, PDO::PARAM_STR); + + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + $expected = 'SELECT A.COL, B.COL AS '.$db->quoteIdentifier('foo').' FROM A WHERE foo = :p1'; + $this->assertEquals($expected, $result); + $expected = array( + array('table' => null, 'type' => PDO::PARAM_STR, 'value' => 123) + ); + $this->assertEquals($expected, $params); + } + + public function testJoinObject() + { + $j = new Join('TABLE_A.COL_1', 'TABLE_B.COL_2'); + $this->assertEquals('INNER JOIN', $j->getJoinType()); + $this->assertEquals('TABLE_A.COL_1', $j->getLeftColumn()); + $this->assertEquals('TABLE_A', $j->getLeftTableName()); + $this->assertEquals('COL_1', $j->getLeftColumnName()); + $this->assertEquals('TABLE_B.COL_2', $j->getRightColumn()); + $this->assertEquals('TABLE_B', $j->getRightTableName()); + $this->assertEquals('COL_2', $j->getRightColumnName()); + + $j = new Join('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::LEFT_JOIN); + $this->assertEquals('LEFT JOIN', $j->getJoinType()); + $this->assertEquals('TABLE_A.COL_1', $j->getLeftColumn()); + $this->assertEquals('TABLE_B.COL_1', $j->getRightColumn()); + + $j = new Join('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::RIGHT_JOIN); + $this->assertEquals('RIGHT JOIN', $j->getJoinType()); + $this->assertEquals('TABLE_A.COL_1', $j->getLeftColumn()); + $this->assertEquals('TABLE_B.COL_1', $j->getRightColumn()); + + $j = new Join('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::INNER_JOIN); + $this->assertEquals('INNER JOIN', $j->getJoinType()); + $this->assertEquals('TABLE_A.COL_1', $j->getLeftColumn()); + $this->assertEquals('TABLE_B.COL_1', $j->getRightColumn()); + + $j = new Join(array('TABLE_A.COL_1', 'TABLE_A.COL_2'), array('TABLE_B.COL_1', 'TABLE_B.COL_2'), Criteria::INNER_JOIN); + $this->assertEquals('TABLE_A.COL_1', $j->getLeftColumn(0)); + $this->assertEquals('TABLE_A.COL_2', $j->getLeftColumn(1)); + $this->assertEquals('TABLE_B.COL_1', $j->getRightColumn(0)); + $this->assertEquals('TABLE_B.COL_2', $j->getRightColumn(1)); + } + + public function testAddStraightJoin() + { + $c = new Criteria(); + $c->addSelectColumn("*"); + $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_1'); // straight join + + $expect = "SELECT * FROM TABLE_A INNER JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1)"; + try { + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + } catch (PropelException $e) { + print $e->getTraceAsString(); + $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); + } + $this->assertEquals($expect, $result); + } + + public function testAddSeveralJoins() + { + $c = new Criteria(); + $c->addSelectColumn("*"); + $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_1'); + $c->addJoin('TABLE_B.COL_X', 'TABLE_D.COL_X'); + + $expect = 'SELECT * FROM TABLE_A INNER JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1)' + . ' INNER JOIN TABLE_D ON (TABLE_B.COL_X=TABLE_D.COL_X)'; + try { + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + } catch (PropelException $e) { + print $e->getTraceAsString(); + $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); + } + $this->assertEquals($expect, $result); + } + + public function testAddLeftJoin() + { + $c = new Criteria(); + $c->addSelectColumn("TABLE_A.*"); + $c->addSelectColumn("TABLE_B.*"); + $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_2', Criteria::LEFT_JOIN); + + $expect = "SELECT TABLE_A.*, TABLE_B.* FROM TABLE_A LEFT JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_2)"; + try { + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + } catch (PropelException $e) { + print $e->getTraceAsString(); + $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); + } + $this->assertEquals($expect, $result); + } + + public function testAddSeveralLeftJoins() + { + // Fails.. Suspect answer in the chunk starting at BasePeer:605 + $c = new Criteria(); + $c->addSelectColumn('*'); + $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::LEFT_JOIN); + $c->addJoin('TABLE_A.COL_2', 'TABLE_C.COL_2', Criteria::LEFT_JOIN); + + $expect = 'SELECT * FROM TABLE_A ' + .'LEFT JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1) ' + .'LEFT JOIN TABLE_C ON (TABLE_A.COL_2=TABLE_C.COL_2)'; + try { + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + } catch (PropelException $e) { + print $e->getTraceAsString(); + $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); + } + $this->assertEquals($expect, $result); + } + + public function testAddRightJoin() + { + $c = new Criteria(); + $c->addSelectColumn("*"); + $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_2', Criteria::RIGHT_JOIN); + + $expect = "SELECT * FROM TABLE_A RIGHT JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_2)"; + try { + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + } catch (PropelException $e) { + print $e->getTraceAsString(); + $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); + } + $this->assertEquals($expect, $result); + } + + public function testAddSeveralRightJoins() + { + // Fails.. Suspect answer in the chunk starting at BasePeer:605 + $c = new Criteria(); + $c->addSelectColumn('*'); + $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::RIGHT_JOIN); + $c->addJoin('TABLE_A.COL_2', 'TABLE_C.COL_2', Criteria::RIGHT_JOIN); + + $expect = 'SELECT * FROM TABLE_A ' + .'RIGHT JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1) ' + .'RIGHT JOIN TABLE_C ON (TABLE_A.COL_2=TABLE_C.COL_2)'; + try { + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + } catch (PropelException $e) { + print $e->getTraceAsString(); + $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); + } + $this->assertEquals($expect, $result); + } + + public function testAddInnerJoin() + { + $c = new Criteria(); + $c->addSelectColumn("*"); + $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::INNER_JOIN); + + $expect = "SELECT * FROM TABLE_A INNER JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1)"; + try { + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + } catch (PropelException $e) { + print $e->getTraceAsString(); + $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); + } + $this->assertEquals($expect, $result); + } + + public function testAddSeveralInnerJoin() + { + $c = new Criteria(); + $c->addSelectColumn("*"); + $c->addJoin('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::INNER_JOIN); + $c->addJoin('TABLE_B.COL_1', 'TABLE_C.COL_1', Criteria::INNER_JOIN); + + $expect = 'SELECT * FROM TABLE_A ' + .'INNER JOIN TABLE_B ON (TABLE_A.COL_1=TABLE_B.COL_1) ' + .'INNER JOIN TABLE_C ON (TABLE_B.COL_1=TABLE_C.COL_1)'; + try { + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + } catch (PropelException $e) { + print $e->getTraceAsString(); + $this->fail("PropelException thrown in BasePeer.createSelectSql(): ". $e->getMessage()); + } + $this->assertEquals($expect, $result); + } + + /** + * @link http://www.propelorm.org/ticket/451 + * @link http://www.propelorm.org/ticket/283#comment:8 + */ + public function testSeveralMixedJoinOrders() + { + $c = new Criteria(); + $c->clearSelectColumns()-> + addJoin("TABLE_A.FOO_ID", "TABLE_B.id", Criteria::LEFT_JOIN)-> + addJoin("TABLE_A.BAR_ID", "TABLE_C.id")-> + addSelectColumn("TABLE_A.id"); + + $expect = 'SELECT TABLE_A.id FROM TABLE_A LEFT JOIN TABLE_B ON (TABLE_A.FOO_ID=TABLE_B.id) INNER JOIN TABLE_C ON (TABLE_A.BAR_ID=TABLE_C.id)'; + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + $this->assertEquals($expect, $result); + } + + /** + * @link http://trac.propelorm.org/ticket/606 + */ + public function testAddJoinArray() + { + $c = new Criteria(); + $c->clearSelectColumns()-> + addJoin(array('TABLE_A.FOO_ID'), array('TABLE_B.id'), Criteria::LEFT_JOIN)-> + addSelectColumn("TABLE_A.id"); + + $expect = 'SELECT TABLE_A.id FROM TABLE_A LEFT JOIN TABLE_B ON TABLE_A.FOO_ID=TABLE_B.id'; + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + $this->assertEquals($expect, $result); + } + + /** + * @link http://trac.propelorm.org/ticket/606 + */ + public function testAddJoinArrayMultiple() + { + $c = new Criteria(); + $c->clearSelectColumns()-> + addJoin( + array('TABLE_A.FOO_ID', 'TABLE_A.BAR'), + array('TABLE_B.id', 'TABLE_B.BAZ'), + Criteria::LEFT_JOIN)-> + addSelectColumn("TABLE_A.id"); + + $expect = 'SELECT TABLE_A.id FROM TABLE_A LEFT JOIN TABLE_B ON (TABLE_A.FOO_ID=TABLE_B.id AND TABLE_A.BAR=TABLE_B.BAZ)'; + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + $this->assertEquals($expect, $result); + } + + /** + * Test the Criteria::addJoinMultiple() method with an implicit join + * + * @link http://trac.propelorm.org/ticket/606 + */ + public function testAddJoinMultiple() + { + $c = new Criteria(); + $c-> + clearSelectColumns()-> + addMultipleJoin(array( + array('TABLE_A.FOO_ID', 'TABLE_B.id'), + array('TABLE_A.BAR', 'TABLE_B.BAZ')))-> + addSelectColumn("TABLE_A.id"); + + $expect = 'SELECT TABLE_A.id FROM TABLE_A INNER JOIN TABLE_B ' + . 'ON (TABLE_A.FOO_ID=TABLE_B.id AND TABLE_A.BAR=TABLE_B.BAZ)'; + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + $this->assertEquals($expect, $result); + } + + /** + * Test the Criteria::addJoinMultiple() method with a value as second argument + * + * @link http://trac.propelorm.org/ticket/606 + */ + public function testAddJoinMultipleValue() + { + $c = new Criteria(); + $c-> + clearSelectColumns()-> + addMultipleJoin(array( + array('TABLE_A.FOO_ID', 'TABLE_B.id'), + array('TABLE_A.BAR', 3)))-> + addSelectColumn("TABLE_A.id"); + + $expect = 'SELECT TABLE_A.id FROM TABLE_A INNER JOIN TABLE_B ' + . 'ON (TABLE_A.FOO_ID=TABLE_B.id AND TABLE_A.BAR=:p1)'; + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + $this->assertEquals($expect, $result); + + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new Criteria(); + $c->addMultipleJoin(array( + array(AuthorPeer::ID, BookPeer::AUTHOR_ID), + array(BookPeer::ISBN, 3) + )); + AuthorPeer::doSelectOne($c, $con); + $expectedSQL = 'SELECT author.id, author.first_name, author.last_name, author.email, author.age FROM author INNER JOIN book ON (author.id=book.author_id AND book.isbn=3) LIMIT 1'; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery()); + } + + /** + * Test the Criteria::addJoinMultiple() method with a joinType + * + * @link http://trac.propelorm.org/ticket/606 + */ + public function testAddJoinMultipleWithJoinType() + { + $c = new Criteria(); + $c-> + clearSelectColumns()-> + addMultipleJoin(array( + array('TABLE_A.FOO_ID', 'TABLE_B.id'), + array('TABLE_A.BAR', 'TABLE_B.BAZ')), + Criteria::LEFT_JOIN)-> + addSelectColumn("TABLE_A.id"); + + $expect = 'SELECT TABLE_A.id FROM TABLE_A ' + . 'LEFT JOIN TABLE_B ON (TABLE_A.FOO_ID=TABLE_B.id AND TABLE_A.BAR=TABLE_B.BAZ)'; + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + $this->assertEquals($expect, $result); + } + + /** + * Test the Criteria::addJoinMultiple() method with operator + * + * @link http://trac.propelorm.org/ticket/606 + */ + public function testAddJoinMultipleWithOperator() + { + $c = new Criteria(); + $c-> + clearSelectColumns()-> + addMultipleJoin(array( + array('TABLE_A.FOO_ID', 'TABLE_B.id', Criteria::GREATER_EQUAL), + array('TABLE_A.BAR', 'TABLE_B.BAZ', Criteria::LESS_THAN)))-> + addSelectColumn("TABLE_A.id"); + + $expect = 'SELECT TABLE_A.id FROM TABLE_A INNER JOIN TABLE_B ' + . 'ON (TABLE_A.FOO_ID>=TABLE_B.id AND TABLE_A.BARassertEquals($expect, $result); + } + + /** + * Test the Criteria::addJoinMultiple() method with join type and operator + * + * @link http://trac.propelorm.org/ticket/606 + */ + public function testAddJoinMultipleWithJoinTypeAndOperator() + { + $c = new Criteria(); + $c-> + clearSelectColumns()-> + addMultipleJoin(array( + array('TABLE_A.FOO_ID', 'TABLE_B.id', Criteria::GREATER_EQUAL), + array('TABLE_A.BAR', 'TABLE_B.BAZ', Criteria::LESS_THAN)), + Criteria::LEFT_JOIN)-> + addSelectColumn("TABLE_A.id"); + + $expect = 'SELECT TABLE_A.id FROM TABLE_A ' + . 'LEFT JOIN TABLE_B ON (TABLE_A.FOO_ID>=TABLE_B.id AND TABLE_A.BARassertEquals($expect, $result); + } + + public function testAddJoinMultipleWithInOperator() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new Criteria(); + $c->addMultipleJoin(array( + array(AuthorPeer::ID, BookPeer::AUTHOR_ID), + array(BookPeer::ISBN, array(1, 7, 42), Criteria::IN) + ), Criteria::LEFT_JOIN); + AuthorPeer::doSelectOne($c, $con); + $expectedSQL = 'SELECT author.id, author.first_name, author.last_name, author.email, author.age FROM author LEFT JOIN book ON (author.id=book.author_id AND book.isbn IN (1,7,42)) LIMIT 1'; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery()); + } + + public function testAddJoinMultipleWithNotInOperator() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new Criteria(); + $c->addMultipleJoin(array( + array(AuthorPeer::ID, BookPeer::AUTHOR_ID), + array(BookPeer::ISBN, array(1, 7, 42), Criteria::NOT_IN) + ), Criteria::LEFT_JOIN); + AuthorPeer::doSelectOne($c, $con); + $expectedSQL = 'SELECT author.id, author.first_name, author.last_name, author.email, author.age FROM author LEFT JOIN book ON (author.id=book.author_id AND book.isbn NOT IN (1,7,42)) LIMIT 1'; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery()); + } + + /** + * Tests adding duplicate joins. + * @link http://trac.propelorm.org/ticket/613 + */ + public function testAddJoin_Duplicate() + { + $c = new Criteria(); + + $c->addJoin("tbl.COL1", "tbl.COL2", Criteria::LEFT_JOIN); + $c->addJoin("tbl.COL1", "tbl.COL2", Criteria::LEFT_JOIN); + $this->assertEquals(1, count($c->getJoins()), "Expected not to have duplicate LEFT JOIN added."); + + $c->addJoin("tbl.COL1", "tbl.COL2", Criteria::RIGHT_JOIN); + $c->addJoin("tbl.COL1", "tbl.COL2", Criteria::RIGHT_JOIN); + $this->assertEquals(2, count($c->getJoins()), "Expected 1 new right join to be added."); + + $c->addJoin("tbl.COL1", "tbl.COL2"); + $c->addJoin("tbl.COL1", "tbl.COL2"); + $this->assertEquals(3, count($c->getJoins()), "Expected 1 new implicit join to be added."); + + $c->addJoin("tbl.COL1", "tbl.COL2", Criteria::INNER_JOIN); + $this->assertEquals(3, count($c->getJoins()), "Expected to not add any new join + as INNER JOIN is default joinType and it is already added"); + + $c->addJoin("tbl.COL3", "tbl.COL4"); + $this->assertEquals(4, count($c->getJoins()), "Expected new col join to be added."); + + } + + /** + * @link http://trac.propelorm.org/ticket/634 + */ + public function testHasSelectClause() + { + $c = new Criteria(); + $c->addSelectColumn("foo"); + + $this->assertTrue($c->hasSelectClause()); + + $c = new Criteria(); + $c->addAsColumn("foo", "bar"); + + $this->assertTrue($c->hasSelectClause()); + } + + /** + * Tests including aliases in criterion objects. + * @link http://trac.propelorm.org/ticket/636 + */ + public function testAliasInCriterion() + { + $c = new Criteria(); + $c->addAsColumn("column_alias", "tbl.COL1"); + $crit = $c->getNewCriterion("column_alias", "FOO"); + $this->assertNull($crit->getTable()); + $this->assertEquals("column_alias", $crit->getColumn()); + } + + public function testQuotingAlias() + { + $db = Propel::getDB(); + $c = new Criteria(); + $c->addSelectColumn(BookPeer::TITLE); + $c->addAsColumn('Book ISBN', BookPeer::ISBN); + $expected = 'SELECT book.title, book.isbn AS '.$db->quoteIdentifier('Book ISBN').' FROM book'; + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + $this->assertEquals($expected, $result); + // Below is to ensure we test with adapter which quotes identifiers + $this->assertNotEquals('Book ISBN', $db->quoteIdentifier('Book ISBN')); + } + + public function testHaving() + { + $db = Propel::getDB(); + $c = new Criteria(); + $c->addSelectColumn(BookPeer::TITLE); + $c->addAsColumn('isb_n', BookPeer::ISBN); + $crit = $c->getNewCriterion('isb_n', '1234567890123'); + $c->addHaving($crit); + $expected = 'SELECT book.title, book.isbn AS '.$db->quoteIdentifier('isb_n').' FROM book HAVING isb_n=:p1'; + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + $this->assertEquals($expected, $result); + } + + public function testMultipleHaving() + { + $db = Propel::getDB(); + $c = new Criteria(); + $c->addSelectColumn(BookPeer::TITLE); + $c->addAsColumn('isb_n', BookPeer::ISBN); + $crit = $c->getNewCriterion('isb_n', '1234567890123'); + $crit->addAnd($c->getNewCriterion(BookPeer::TITLE, 'Foobar')); + $c->addHaving($crit); + $expected = 'SELECT book.title, book.isbn AS '.$db->quoteIdentifier('isb_n').' FROM book HAVING (isb_n=:p1 AND book.title=:p2)'; + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + $this->assertEquals($expected, $result); + } + + public function testHavingRaw() + { + $db = Propel::getDB(); + $c = new Criteria(); + $c->addSelectColumn(BookPeer::TITLE); + $c->addAsColumn("isb_n", BookPeer::ISBN); + $c->addHaving('isb_n = ?', '1234567890123', PDO::PARAM_STR); + $expected = 'SELECT book.title, book.isbn AS '.$db->quoteIdentifier('isb_n').' FROM book HAVING isb_n = :p1'; + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + $this->assertEquals($expected, $result); + } + + /** + * Test whether GROUP BY is being respected in equals() check. + * @link http://trac.propelorm.org/ticket/674 + */ + public function testEqualsGroupBy() + { + $c1 = new Criteria(); + $c1->addGroupByColumn('GBY1'); + + $c2 = new Criteria(); + $c2->addGroupByColumn('GBY2'); + + $this->assertFalse($c2->equals($c1), "Expected Criteria NOT to be the same with different GROUP BY columns"); + + $c3 = new Criteria(); + $c3->addGroupByColumn('GBY1'); + $c4 = new Criteria(); + $c4->addGroupByColumn('GBY1'); + $this->assertTrue($c4->equals($c3), "Expected Criteria objects to match."); + } + + /** + * Test whether calling setDistinct twice puts in two distinct keywords or not. + * @link http://trac.propelorm.org/ticket/716 + */ + public function testDoubleSelectModifiers() + { + $c = new Criteria(); + $c->setDistinct(); + $this->assertEquals(array(Criteria::DISTINCT), $c->getSelectModifiers(), 'Initial setDistinct works'); + $c->setDistinct(); + $this->assertEquals(array(Criteria::DISTINCT), $c->getSelectModifiers(), 'Calling setDistinct again leaves a single distinct'); + $c->setAll(); + $this->assertEquals(array(Criteria::ALL), $c->getSelectModifiers(), 'All keyword is swaps distinct out'); + $c->setAll(); + $this->assertEquals(array(Criteria::ALL), $c->getSelectModifiers(), 'Calling setAll leaves a single all'); + $c->setDistinct(); + $this->assertEquals(array(Criteria::DISTINCT), $c->getSelectModifiers(), 'All back to distinct works'); + + $c2 = new Criteria(); + $c2->setAll(); + $this->assertEquals(array(Criteria::ALL), $c2->getSelectModifiers(), 'Initial setAll works'); + } + + public function testAddSelectModifier() + { + $c = new Criteria(); + $c->setDistinct(); + $c->addSelectModifier('SQL_CALC_FOUND_ROWS'); + $this->assertEquals(array(Criteria::DISTINCT, 'SQL_CALC_FOUND_ROWS'), $c->getSelectModifiers(), 'addSelectModifier() adds a select modifier to the Criteria'); + $c->addSelectModifier('SQL_CALC_FOUND_ROWS'); + $this->assertEquals(array(Criteria::DISTINCT, 'SQL_CALC_FOUND_ROWS'), $c->getSelectModifiers(), 'addSelectModifier() adds a select modifier only once'); + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + $this->assertEquals('SELECT DISTINCT SQL_CALC_FOUND_ROWS FROM ', $result, 'addSelectModifier() adds a modifier to the final query'); + } + + public function testClone() + { + $c1 = new Criteria(); + $c1->add('tbl.COL1', 'foo', Criteria::EQUAL); + $c2 = clone $c1; + $c2->addAnd('tbl.COL1', 'bar', Criteria::EQUAL); + $nbCrit = 0; + foreach ($c1->keys() as $key) { + foreach ($c1->getCriterion($key)->getAttachedCriterion() as $criterion) { + $nbCrit++; + } + } + $this->assertEquals(1, $nbCrit, 'cloning a Criteria clones its Criterions'); + } + + public function testComment() + { + $c = new Criteria(); + $this->assertNull($c->getComment(), 'Comment is null by default'); + $c2 = $c->setComment('foo'); + $this->assertEquals('foo', $c->getComment(), 'Comment is set by setComment()'); + $this->assertEquals($c, $c2, 'setComment() returns the current Criteria'); + $c->setComment(); + $this->assertNull($c->getComment(), 'Comment is reset by setComment(null)'); + } + + public function testClear() + { + $c = new CriteriaForClearTest(); + $c->clear(); + + $this->assertTrue(is_array($c->getNamedCriterions()), 'namedCriterions is an array'); + $this->assertEquals(0, count($c->getNamedCriterions()), 'namedCriterions is empty by default'); + + $this->assertFalse($c->getIgnoreCase(), 'ignoreCase is false by default'); + + $this->assertFalse($c->getSingleRecord(), 'singleRecord is false by default'); + + $this->assertTrue(is_array($c->getSelectModifiers()), 'selectModifiers is an array'); + $this->assertEquals(0, count($c->getSelectModifiers()), 'selectModifiers is empty by default'); + + $this->assertTrue(is_array($c->getSelectColumns()), 'selectColumns is an array'); + $this->assertEquals(0, count($c->getSelectColumns()), 'selectColumns is empty by default'); + + $this->assertTrue(is_array($c->getOrderByColumns()), 'orderByColumns is an array'); + $this->assertEquals(0, count($c->getOrderByColumns()), 'orderByColumns is empty by default'); + + $this->assertTrue(is_array($c->getGroupByColumns()), 'groupByColumns is an array'); + $this->assertEquals(0, count($c->getGroupByColumns()), 'groupByColumns is empty by default'); + + $this->assertNull($c->getHaving(), 'having is null by default'); + + $this->assertTrue(is_array($c->getAsColumns()), 'asColumns is an array'); + $this->assertEquals(0, count($c->getAsColumns()), 'asColumns is empty by default'); + + $this->assertTrue(is_array($c->getJoins()), 'joins is an array'); + $this->assertEquals(0, count($c->getJoins()), 'joins is empty by default'); + + $this->assertTrue(is_array($c->getSelectQueries()), 'selectQueries is an array'); + $this->assertEquals(0, count($c->getSelectQueries()), 'selectQueries is empty by default'); + + $this->assertEquals(0, $c->getOffset(), 'offset is 0 by default'); + + $this->assertEquals(0, $c->getLimit(), 'limit is 0 by default'); + + $this->assertNull($c->getBlobFlag(), 'blobFlag is null by default'); + + $this->assertTrue(is_array($c->getAliases()), 'aliases is an array'); + $this->assertEquals(0, count($c->getAliases()), 'aliases is empty by default'); + + $this->assertFalse($c->getUseTransaction(), 'useTransaction is false by default'); + } + + public function testLimit() + { + $c = new Criteria(); + $this->assertEquals(0, $c->getLimit(), 'Limit is 0 by default'); + + $c2 = $c->setLimit(1); + $this->assertEquals(1, $c->getLimit(), 'Limit is set by setLimit'); + $this->assertSame($c, $c2, 'setLimit() returns the current Criteria'); + } + + public function testDistinct() + { + $c = new Criteria(); + $c->addSelectColumn('*'); + + $c->add('TABLE.string', 'foo'); + $c->setDistinct(); + + $c->add('TABLE.id', 10); + $c->setDistinct(); + + $params = array(); + $result = BasePeer::createSelectSql($c, $params); + + $this->assertEquals('SELECT DISTINCT * FROM TABLE WHERE TABLE.string=:p1 AND TABLE.id=:p2', $result); + } +} + +class CriteriaForClearTest extends Criteria +{ + public function getNamedCriterions() + { + return $this->namedCriterions; + } + + public function getIgnoreCase() + { + return $this->ignoreCase; + } + + public function getSingleRecord() + { + return $this->singleRecord; + } + + public function getUseTransaction() + { + return $this->useTransaction; + } + + public function getBlobFlag() + { + return $this->blobFlag; + } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/query/ExplainPlanTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/query/ExplainPlanTest.php new file mode 100644 index 000000000..fb03893a9 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/query/ExplainPlanTest.php @@ -0,0 +1,86 @@ +con); + BookstoreDataPopulator::populate($this->con); + + $db = Propel::getDb(BookPeer::DATABASE_NAME); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $c->where('Author.FirstName = ?', 'Neal'); + $c->select('Title'); + $explain = $c->explain($this->con); + + if ($db instanceof DBMySQL) { + $this->assertEquals(sizeof($explain), 2, 'Explain plan return two lines'); + + // explain can change sometime, test can't be strict + $this->assertArrayHasKey('select_type',$explain[0], 'Line 1, select_type key exist'); + $this->assertArrayHasKey('table',$explain[0], 'Line 1, table key exist'); + $this->assertArrayHasKey('type',$explain[0], 'Line 1, type key exist'); + $this->assertArrayHasKey('possible_keys',$explain[0], 'Line 1, possible_keys key exist'); + + $this->assertArrayHasKey('select_type',$explain[1], 'Line 2, select_type key exist'); + $this->assertArrayHasKey('table',$explain[1], 'Line 2, table key exist'); + $this->assertArrayHasKey('type',$explain[1], 'Line 2, type key exist'); + $this->assertArrayHasKey('possible_keys',$explain[1], 'Line 2, possible_keys key exist'); + } elseif ($db instanceof DBOracle) { + $this->assertTrue(sizeof($explain) > 2, 'Explain plan return more than 2 lines'); + } else { + $this->markTestSkipped('Cannot test explain plan on adapter ' . get_class($db)); + } + } + + public function testExplainPlanFromString() + { + BookstoreDataPopulator::depopulate($this->con); + BookstoreDataPopulator::populate($this->con); + + $db = Propel::getDb(BookPeer::DATABASE_NAME); + + $query = 'SELECT book.TITLE AS Title FROM book INNER JOIN author ON (book.AUTHOR_ID=author.ID) WHERE author.FIRST_NAME = \'Neal\''; + $stmt = $db->doExplainPlan($this->con, $query); + $explain = $stmt->fetchAll(PDO::FETCH_ASSOC); + + if ($db instanceof DBMySQL) { + $this->assertEquals(sizeof($explain), 2, 'Explain plan return two lines'); + + // explain can change sometime, test can't be strict + $this->assertArrayHasKey('select_type',$explain[0], 'Line 1, select_type key exist'); + $this->assertArrayHasKey('table',$explain[0], 'Line 1, table key exist'); + $this->assertArrayHasKey('type',$explain[0], 'Line 1, type key exist'); + $this->assertArrayHasKey('possible_keys',$explain[0], 'Line 1, possible_keys key exist'); + + $this->assertArrayHasKey('select_type',$explain[1], 'Line 2, select_type key exist'); + $this->assertArrayHasKey('table',$explain[1], 'Line 2, table key exist'); + $this->assertArrayHasKey('type',$explain[1], 'Line 2, type key exist'); + $this->assertArrayHasKey('possible_keys',$explain[1], 'Line 2, possible_keys key exist'); + } elseif ($db instanceof DBOracle) { + $this->assertTrue(sizeof($explain) > 2, 'Explain plan return more than 2 lines'); + } else { + $this->markTestSkipped('Cannot test explain plan on adapter ' . get_class($db)); + } + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/query/JoinTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/query/JoinTest.php index c3a324552..d0fdd553b 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/query/JoinTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/query/JoinTest.php @@ -8,20 +8,19 @@ * @license MIT License */ -require_once 'tools/helpers/BaseTestCase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/BaseTestCase.php'; require_once dirname(__FILE__) . '/../../../../runtime/lib/query/Criteria.php'; -set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes"); -Propel::init('fixtures/bookstore/build/conf/bookstore-conf.php'); +Propel::init(dirname(__FILE__) . '/../../../fixtures/bookstore/build/conf/bookstore-conf.php'); /** * Test class for Join. * * @author François Zaninotto - * @version $Id: JoinTest.php 1773 2010-05-25 10:25:06Z francois $ + * @version $Id$ * @package runtime.query */ -class JoinTest extends BaseTestCase +class JoinTest extends BaseTestCase { /** * DB adapter saved for later. @@ -48,7 +47,7 @@ class JoinTest extends BaseTestCase $j = new Join(); $this->assertEquals(array(), $j->getConditions()); } - + public function testAddCondition() { $j = new Join(); @@ -57,7 +56,7 @@ class JoinTest extends BaseTestCase $this->assertEquals('foo', $j->getLeftColumn()); $this->assertEquals('bar', $j->getRightColumn()); } - + public function testGetConditions() { $j = new Join(); @@ -65,7 +64,7 @@ class JoinTest extends BaseTestCase $expect = array(array('left' => 'foo', 'operator' => '=', 'right' => 'bar')); $this->assertEquals($expect, $j->getConditions()); } - + public function testAddConditionWithOperator() { $j = new Join(); @@ -73,7 +72,7 @@ class JoinTest extends BaseTestCase $expect = array(array('left' => 'foo', 'operator' => '>=', 'right' => 'bar')); $this->assertEquals($expect, $j->getConditions()); } - + public function testAddConditions() { $j = new Join(); @@ -88,20 +87,65 @@ class JoinTest extends BaseTestCase $this->assertEquals(array('bar', 'bal'), $j->getRightColumns()); $this->assertEquals($expect, $j->getConditions()); } - + + public function testAddExplicitConditionWithoutAlias() + { + $j = new Join(); + $j->addExplicitCondition('a', 'foo', null, 'b', 'bar', null); + $this->assertEquals('=', $j->getOperator()); + $this->assertEquals('a.foo', $j->getLeftColumn()); + $this->assertEquals('b.bar', $j->getRightColumn()); + $this->assertEquals('a', $j->getLeftTableName()); + $this->assertEquals('b', $j->getRightTableName()); + $this->assertNull($j->getLeftTableAlias()); + $this->assertNull($j->getRightTableAlias()); + $this->assertEquals(1, $j->countConditions()); + } + + public function testAddExplicitconditionWithOneAlias() + { + $j = new Join(); + $j->setJoinType(Criteria::LEFT_JOIN); + $j->addExplicitCondition('book', 'AUTHOR_ID', null, 'author', 'ID', 'a', Join::EQUAL); + $params = array(); + $this->assertEquals($j->getClause($params), 'LEFT JOIN author a ON (book.AUTHOR_ID=a.ID)'); + } + + public function testAddExplicitConditionWithAlias() + { + $j = new Join(); + $j->addExplicitCondition('a', 'foo', 'Alias', 'b', 'bar', 'Blias'); + $this->assertEquals('=', $j->getOperator()); + $this->assertEquals('Alias.foo', $j->getLeftColumn()); + $this->assertEquals('Blias.bar', $j->getRightColumn()); + $this->assertEquals('a', $j->getLeftTableName()); + $this->assertEquals('b', $j->getRightTableName()); + $this->assertEquals('Alias', $j->getLeftTableAlias()); + $this->assertEquals('Blias', $j->getRightTableAlias()); + } + + public function testAddExplicitConditionWithOperator() + { + $j = new Join(); + $j->addExplicitCondition('a', 'foo', null, 'b', 'bar', null, '>='); + $this->assertEquals('>=', $j->getOperator()); + $this->assertEquals('a.foo', $j->getLeftColumn()); + $this->assertEquals('b.bar', $j->getRightColumn()); + } + public function testEmptyJoinType() { $j = new Join(); - $this->assertNull($j->getJoinType()); + $this->assertEquals(Join::INNER_JOIN, $j->getJoinType()); } - + public function testSetJoinType() { $j = new Join(); $j->setJoinType('foo'); $this->assertEquals('foo', $j->getJoinType()); } - + public function testSimpleConstructor() { $j = new Join('foo', 'bar', 'LEFT JOIN'); @@ -109,7 +153,7 @@ class JoinTest extends BaseTestCase $this->assertEquals($expect, $j->getConditions()); $this->assertEquals('LEFT JOIN', $j->getJoinType()); } - + public function testCompositeeConstructor() { $j = new Join(array('foo1', 'foo2'), array('bar1', 'bar2'), 'LEFT JOIN'); @@ -120,7 +164,30 @@ class JoinTest extends BaseTestCase $this->assertEquals($expect, $j->getConditions()); $this->assertEquals('LEFT JOIN', $j->getJoinType()); } - + + public function testEquality() + { + $j1 = new Join('foo', 'bar', 'INNER JOIN'); + + $j2 = new Join('foo', 'bar', 'INNER JOIN'); + $this->assertTrue($j1->equals($j2)); + + $j3 = new Join('foo', 'bar', 'LEFT JOIN'); + $this->assertFalse($j1->equals($j3), 'INNER JOIN is not equal to LEFT JOIN'); + + $j4 = new Join('foo', 'bar', 'RIGHT JOIN'); + $this->assertFalse($j1->equals($j4), 'INNER JOIN is not equal to RIGHT JOIN'); + + $j5 = new Join('foo', 'bar'); + $j6 = new Join('foo', 'bar'); + $this->assertTrue($j5->equals($j6), 'Joins without specified join type should be equal, + as they fallback to default join type'); + + $j7 = new Join('foo', 'bar', 'INNER JOIN'); + $this->assertTrue($j5->equals($j7), 'Join without specified join type should be equal + to INNER JOIN, as it fallback to default join type'); + } + public function testCountConditions() { $j = new Join(); @@ -129,7 +196,6 @@ class JoinTest extends BaseTestCase $this->assertEquals(1, $j->countConditions()); $j->addCondition('foo1', 'bar1'); $this->assertEquals(2, $j->countConditions()); - } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaHooksTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaHooksTest.php index 8c1107a87..18ba6ae75 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaHooksTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaHooksTest.php @@ -8,8 +8,8 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; -require_once 'tools/helpers/bookstore/BookstoreDataPopulator.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreDataPopulator.php'; /** * Test class for ModelCriteria. @@ -20,177 +20,177 @@ require_once 'tools/helpers/bookstore/BookstoreDataPopulator.php'; */ class ModelCriteriaHooksTest extends BookstoreTestBase { - protected function setUp() - { - parent::setUp(); - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - } - - public function testPreSelect() - { - $c = new ModelCriteriaWithPreSelectHook('bookstore', 'Book'); - $books = $c->find(); - $this->assertEquals(1, count($books), 'preSelect() can modify the Criteria before find() fires the query'); - - $c = new ModelCriteriaWithPreSelectHook('bookstore', 'Book'); - $nbBooks = $c->count(); - $this->assertEquals(1, $nbBooks, 'preSelect() can modify the Criteria before count() fires the query'); - } - - public function testPreDelete() - { - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->find(); - $count = count($books); - $book = $books->shift(); - - $c = new ModelCriteriaWithPreDeleteHook('bookstore', 'Book', 'b'); - $c->where('b.Id = ?', $book->getId()); - $nbBooks = $c->delete(); - $this->assertEquals(12, $nbBooks, 'preDelete() can change the return value of delete()'); - - $c = new ModelCriteria('bookstore', 'Book'); - $nbBooks = $c->count(); - $this->assertEquals($count, $nbBooks, 'preDelete() can bypass the row deletion'); - - $c = new ModelCriteriaWithPreDeleteHook('bookstore', 'Book'); - $nbBooks = $c->deleteAll(); - $this->assertEquals(12, $nbBooks, 'preDelete() can change the return value of deleteAll()'); - - $c = new ModelCriteria('bookstore', 'Book'); - $nbBooks = $c->count(); - $this->assertEquals($count, $nbBooks, 'preDelete() can bypass the row deletion'); - } + protected function setUp() + { + parent::setUp(); + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + } - public function testPostDelete() - { - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->find(); - $count = count($books); - $book = $books->shift(); - - $this->con->lastAffectedRows = 0; - - $c = new ModelCriteriaWithPostDeleteHook('bookstore', 'Book', 'b'); - $c->where('b.Id = ?', $book->getId()); - $nbBooks = $c->delete($this->con); - $this->assertEquals(1, $this->con->lastAffectedRows, 'postDelete() is called after delete()'); - - $this->con->lastAffectedRows = 0; - - $c = new ModelCriteriaWithPostDeleteHook('bookstore', 'Book'); - $nbBooks = $c->deleteAll($this->con); - $this->assertEquals(3, $this->con->lastAffectedRows, 'postDelete() is called after deleteAll()'); - } + public function testPreSelect() + { + $c = new ModelCriteriaWithPreSelectHook('bookstore', 'Book'); + $books = $c->find(); + $this->assertEquals(1, count($books), 'preSelect() can modify the Criteria before find() fires the query'); - public function testPreAndPostDelete() - { - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->find(); - $count = count($books); - $book = $books->shift(); - - $this->con->lastAffectedRows = 0; - - $c = new ModelCriteriaWithPreAndPostDeleteHook('bookstore', 'Book', 'b'); - $c->where('b.Id = ?', $book->getId()); - $nbBooks = $c->delete($this->con); - $this->assertEquals(12, $this->con->lastAffectedRows, 'postDelete() is called after delete() even if preDelete() returns not null'); - - $this->con->lastAffectedRows = 0; - - $c = new ModelCriteriaWithPreAndPostDeleteHook('bookstore', 'Book'); - $nbBooks = $c->deleteAll($this->con); - $this->assertEquals(12, $this->con->lastAffectedRows, 'postDelete() is called after deleteAll() even if preDelete() returns not null'); - } - - public function testPreUpdate() - { - $c = new ModelCriteriaWithPreUpdateHook('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'Don Juan'); - $nbBooks = $c->update(array('Title' => 'foo')); - - $c = new ModelCriteriaWithPreUpdateHook('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'foo'); - $book = $c->findOne(); - - $this->assertEquals('1234', $book->getISBN(), 'preUpdate() can modify the values'); - } + $c = new ModelCriteriaWithPreSelectHook('bookstore', 'Book'); + $nbBooks = $c->count(); + $this->assertEquals(1, $nbBooks, 'preSelect() can modify the Criteria before count() fires the query'); + } - public function testPostUpdate() - { - $this->con->lastAffectedRows = 0; - - $c = new ModelCriteriaWithPostUpdateHook('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'Don Juan'); - $nbBooks = $c->update(array('Title' => 'foo'), $this->con); - $this->assertEquals(1, $this->con->lastAffectedRows, 'postUpdate() is called after update()'); - } + public function testPreDelete() + { + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->find(); + $count = count($books); + $book = $books->shift(); - public function testPreAndPostUpdate() - { - $this->con->lastAffectedRows = 0; - - $c = new ModelCriteriaWithPreAndPostUpdateHook('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'Don Juan'); - $nbBooks = $c->update(array('Title' => 'foo'), $this->con); - $this->assertEquals(52, $this->con->lastAffectedRows, 'postUpdate() is called after update() even if preUpdate() returns not null'); - } + $c = new ModelCriteriaWithPreDeleteHook('bookstore', 'Book', 'b'); + $c->where('b.Id = ?', $book->getId()); + $nbBooks = $c->delete(); + $this->assertEquals(12, $nbBooks, 'preDelete() can change the return value of delete()'); + + $c = new ModelCriteria('bookstore', 'Book'); + $nbBooks = $c->count(); + $this->assertEquals($count, $nbBooks, 'preDelete() can bypass the row deletion'); + + $c = new ModelCriteriaWithPreDeleteHook('bookstore', 'Book'); + $nbBooks = $c->deleteAll(); + $this->assertEquals(12, $nbBooks, 'preDelete() can change the return value of deleteAll()'); + + $c = new ModelCriteria('bookstore', 'Book'); + $nbBooks = $c->count(); + $this->assertEquals($count, $nbBooks, 'preDelete() can bypass the row deletion'); + } + + public function testPostDelete() + { + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->find(); + $count = count($books); + $book = $books->shift(); + + $this->con->lastAffectedRows = 0; + + $c = new ModelCriteriaWithPostDeleteHook('bookstore', 'Book', 'b'); + $c->where('b.Id = ?', $book->getId()); + $nbBooks = $c->delete($this->con); + $this->assertEquals(1, $this->con->lastAffectedRows, 'postDelete() is called after delete()'); + + $this->con->lastAffectedRows = 0; + + $c = new ModelCriteriaWithPostDeleteHook('bookstore', 'Book'); + $nbBooks = $c->deleteAll($this->con); + $this->assertEquals(3, $this->con->lastAffectedRows, 'postDelete() is called after deleteAll()'); + } + + public function testPreAndPostDelete() + { + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->find(); + $count = count($books); + $book = $books->shift(); + + $this->con->lastAffectedRows = 0; + + $c = new ModelCriteriaWithPreAndPostDeleteHook('bookstore', 'Book', 'b'); + $c->where('b.Id = ?', $book->getId()); + $nbBooks = $c->delete($this->con); + $this->assertEquals(12, $this->con->lastAffectedRows, 'postDelete() is called after delete() even if preDelete() returns not null'); + + $this->con->lastAffectedRows = 0; + + $c = new ModelCriteriaWithPreAndPostDeleteHook('bookstore', 'Book'); + $nbBooks = $c->deleteAll($this->con); + $this->assertEquals(12, $this->con->lastAffectedRows, 'postDelete() is called after deleteAll() even if preDelete() returns not null'); + } + + public function testPreUpdate() + { + $c = new ModelCriteriaWithPreUpdateHook('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'Don Juan'); + $nbBooks = $c->update(array('Title' => 'foo')); + + $c = new ModelCriteriaWithPreUpdateHook('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'foo'); + $book = $c->findOne(); + + $this->assertEquals('1234', $book->getISBN(), 'preUpdate() can modify the values'); + } + + public function testPostUpdate() + { + $this->con->lastAffectedRows = 0; + + $c = new ModelCriteriaWithPostUpdateHook('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'Don Juan'); + $nbBooks = $c->update(array('Title' => 'foo'), $this->con); + $this->assertEquals(1, $this->con->lastAffectedRows, 'postUpdate() is called after update()'); + } + + public function testPreAndPostUpdate() + { + $this->con->lastAffectedRows = 0; + + $c = new ModelCriteriaWithPreAndPostUpdateHook('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'Don Juan'); + $nbBooks = $c->update(array('Title' => 'foo'), $this->con); + $this->assertEquals(52, $this->con->lastAffectedRows, 'postUpdate() is called after update() even if preUpdate() returns not null'); + } } class ModelCriteriaWithPreSelectHook extends ModelCriteria -{ - public function preSelect(PropelPDO $con) - { - $this->where($this->getModelAliasOrName() . '.Title = ?', 'Don Juan'); - } +{ + public function preSelect(PropelPDO $con) + { + $this->where($this->getModelAliasOrName() . '.Title = ?', 'Don Juan'); + } } class ModelCriteriaWithPreDeleteHook extends ModelCriteria -{ - public function preDelete(PropelPDO $con) - { - return 12; - } +{ + public function preDelete(PropelPDO $con) + { + return 12; + } } class ModelCriteriaWithPostDeleteHook extends ModelCriteria { - public function postDelete($affectedRows, PropelPDO $con) - { - $con->lastAffectedRows = $affectedRows; - } + public function postDelete($affectedRows, PropelPDO $con) + { + $con->lastAffectedRows = $affectedRows; + } } class ModelCriteriaWithPreAndPostDeleteHook extends ModelCriteriaWithPostDeleteHook { - public function preDelete(PropelPDO $con) - { - return 12; - } + public function preDelete(PropelPDO $con) + { + return 12; + } } class ModelCriteriaWithPreUpdateHook extends ModelCriteria -{ - public function preUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false) - { - $values['ISBN'] = '1234'; - } +{ + public function preUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false) + { + $values['ISBN'] = '1234'; + } } class ModelCriteriaWithPostUpdateHook extends ModelCriteria { - public function postUpdate($affectedRows, PropelPDO $con) - { - $con->lastAffectedRows = $affectedRows; - } + public function postUpdate($affectedRows, PropelPDO $con) + { + $con->lastAffectedRows = $affectedRows; + } } class ModelCriteriaWithPreAndPostUpdateHook extends ModelCriteriaWithPostUpdateHook { - public function preUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false) - { - return 52; - } -} \ No newline at end of file + public function preUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false) + { + return 52; + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaSelectTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaSelectTest.php new file mode 100644 index 000000000..f96af83c5 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaSelectTest.php @@ -0,0 +1,469 @@ +select(''); + } + + /** + * @expectedException PropelException + */ + public function testSelectThrowsExceptionWhenCalledWithAnEmptyArray() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->select(array()); + } + + public function testSelectStringNoResult() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->where('Book.Title = ?', 'kdjfhlkdsh'); + $c->select('Title'); + $titles = $c->find($this->con); + + $expectedSQL = 'SELECT book.title AS `Title` FROM `book` WHERE book.title = \'kdjfhlkdsh\''; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'find() called after select(string) selects a single column'); + $this->assertTrue($titles instanceof PropelArrayCollection, 'find() called after select(string) returns a PropelArrayCollection object'); + $this->assertTrue(is_array($titles->getData()), 'find() called after select(string) returns an empty PropelArrayCollection object'); + $this->assertEquals(0, count($titles), 'find() called after select(string) returns an empty array if no record is found'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->where('Book.Title = ?', 'kdjfhlkdsh'); + $c->select('Title'); + $title = $c->findOne(); + $this->assertTrue(is_null($title), 'findOne() called after select(string) returns null when no record is found'); + } + + public function testSelectStringAcceptsColumnNames() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->select('Title'); + $titles = $c->find(); + $expectedSQL = 'SELECT book.title AS `Title` FROM `book`'; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'select() accepts short column names'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->select('Book.Title'); + $titles = $c->find(); + $expectedSQL = 'SELECT book.title AS `Book.Title` FROM `book`'; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'select() accepts complete column names'); + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->select('b.Title'); + $titles = $c->find(); + $expectedSQL = 'SELECT book.title AS `b.Title` FROM `book`'; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'select() accepts complete column names with table aliases'); + } + + public function testSelectStringFind() + { + BookstoreDataPopulator::depopulate($this->con); + BookstoreDataPopulator::populate($this->con); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->select('Title'); + $titles = $c->find($this->con); + $this->assertEquals($titles->count(), 4, 'find() called after select(string) returns an array with one row for each record'); + $this->assertEquals($titles->shift(), 'Harry Potter and the Order of the Phoenix', 'find() called after select(string) returns an array of column values'); + $this->assertEquals($titles->shift(), 'Quicksilver', 'find() called after select(string) returns an array of column values'); + + $c = new ModelCriteria('bookstore', 'Author'); + $c->where('Author.FirstName = ?', 'Neal'); + $c->select('FirstName'); + $authors = $c->find($this->con); + $this->assertEquals($authors->count(), 1, 'find() called after select(string) allows for where() statements'); + $expectedSQL = "SELECT author.first_name AS `FirstName` FROM `author` WHERE author.first_name = 'Neal'"; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'find() called after select(string) allows for where() statements'); + + $c = new ModelCriteria('bookstore', 'Author'); + $c->select(AuthorPeer::FIRST_NAME); + $author = $c->find($this->con); + $expectedSQL = "SELECT author.first_name AS `author.first_name` FROM `author`"; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'select(string) accepts model Peer Constants'); + } + + /** + * @expectedException PropelException + */ + public function testSelectStringFindCalledWithNonExistingColumn() + { + BookstoreDataPopulator::depopulate($this->con); + BookstoreDataPopulator::populate($this->con); + + $c = new ModelCriteria('bookstore', 'Author'); + $c->select('author.NOT_EXISTING_COLUMN'); + $author = $c->find($this->con); + } + + public function testSelectStringFindOne() + { + BookstoreDataPopulator::depopulate($this->con); + BookstoreDataPopulator::populate($this->con); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->select('Title'); + $title = $c->findOne($this->con); + $expectedSQL = 'SELECT book.title AS `Title` FROM `book` LIMIT 1'; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'findOne() called after select(string) selects a single column and requests a single row'); + $this->assertTrue(is_string($title),'findOne() called after select(string) returns a string'); + $this->assertEquals($title, 'Harry Potter and the Order of the Phoenix', 'findOne() called after select(string) returns the column value of the first row matching the query'); + + $c = new ModelCriteria('bookstore', 'Author'); + $c->where('Author.FirstName = ?', 'Neal'); + $c->select('FirstName'); + $author = $c->findOne($this->con); + $this->assertEquals(count($author), 1, 'findOne() called after select(string) allows for where() statements'); + $expectedSQL = "SELECT author.first_name AS `FirstName` FROM `author` WHERE author.first_name = 'Neal' LIMIT 1"; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'findOne() called after select(string) allows for where() statements'); + } + + public function testSelectStringJoin() + { + BookstoreDataPopulator::depopulate($this->con); + BookstoreDataPopulator::populate($this->con); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $c->where('Author.FirstName = ?', 'Neal'); + $c->select('Title'); + $titles = $c->find($this->con); + $this->assertEquals($titles->count(), 1, 'find() called after select(string) allows for join() statements'); + $expectedSQL = "SELECT book.title AS `Title` FROM `book` INNER JOIN `author` ON (book.author_id=author.id) WHERE author.first_name = 'Neal'"; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'find() called after select(string) allows for join() statements'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $c->where('Author.FirstName = ?', 'Neal'); + $c->select('Author.FirstName'); + $titles = $c->find($this->con); + $this->assertEquals($titles->shift(), 'Neal', 'find() called after select(string) will return values from the joined table using complete column names'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $c->where('Author.FirstName = ?', 'Neal'); + $c->select('Title'); + $title = $c->findOne($this->con); + $this->assertEquals(count($title), 1, 'findOne() called after select(string) allows for join() statements'); + $expectedSQL = "SELECT book.title AS `Title` FROM `book` INNER JOIN `author` ON (book.author_id=author.id) WHERE author.first_name = 'Neal' LIMIT 1"; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'findOne() called after select(string) allows for where() statements'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $c->where('Author.FirstName = ?', 'Neal'); + $c->select('Author.FirstName'); + $title = $c->findOne($this->con); + $this->assertEquals($title, 'Neal', 'findOne() called after select(string) will return values from the joined table using complete column names'); + } + + public function testSelectStringWildcard() + { + BookstoreDataPopulator::depopulate($this->con); + BookstoreDataPopulator::populate($this->con); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->select('*'); + $book = $c->findOne($this->con); + $expectedSQL = 'SELECT book.id AS `Book.Id`, book.title AS `Book.Title`, book.isbn AS `Book.ISBN`, book.price AS `Book.Price`, book.publisher_id AS `Book.PublisherId`, book.author_id AS `Book.AuthorId` FROM `book` LIMIT 1'; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'select(\'*\') selects all the columns from the main object'); + $this->assertTrue(is_array($book), 'findOne() called after select(\'*\') returns an array'); + $this->assertEquals(array_keys($book), array('Book.Id', 'Book.Title', 'Book.ISBN', 'Book.Price', 'Book.PublisherId', 'Book.AuthorId'), 'select(\'*\') returns all the columns from the main object, in complete form'); + } + + public function testSelectArrayFind() + { + BookstoreDataPopulator::depopulate($this->con); + BookstoreDataPopulator::populate($this->con); + + // fix for a bug/limitation in pdo_dblib where it truncates columnnames to a maximum of 31 characters when doing PDO::FETCH_ASSOC + $c = new ModelCriteria('bookstore', 'BookstoreEmployeeAccount'); + $c->select(array('BookstoreEmployeeAccount.Authenticator', 'BookstoreEmployeeAccount.Password')); + $account = $c->findOne($this->con); + $this->assertEquals($account, array('BookstoreEmployeeAccount.Authenticator' => 'Password', 'BookstoreEmployeeAccount.Password' => 'johnp4ss'), 'select() does not mind long column names'); + + $c = new ModelCriteria('bookstore', 'Author'); + $c->where('Author.FirstName = ?', 'Neal'); + $c->select(array('FirstName', 'LastName')); + $authors = $c->find($this->con); + $this->assertEquals($authors->count(), 1, 'find() called after select(array) allows for where() statements'); + $expectedSQL = "SELECT author.first_name AS `FirstName`, author.last_name AS `LastName` FROM `author` WHERE author.first_name = 'Neal'"; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'find() called after select(array) allows for where() statements'); + } + + public function testSelectArrayFindOne() + { + BookstoreDataPopulator::depopulate($this->con); + BookstoreDataPopulator::populate($this->con); + + $c = new ModelCriteria('bookstore', 'Author'); + $c->where('Author.FirstName = ?', 'Neal'); + $c->select(array('FirstName', 'LastName')); + $author = $c->findOne($this->con); + $this->assertEquals(count($author), 2, 'findOne() called after select(array) allows for where() statements'); + $expectedSQL = "SELECT author.first_name AS `FirstName`, author.last_name AS `LastName` FROM `author` WHERE author.first_name = 'Neal' LIMIT 1"; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'findOne() called after select(array) allows for where() statements'); + } + + public function testSelectArrayJoin() + { + BookstoreDataPopulator::depopulate($this->con); + BookstoreDataPopulator::populate($this->con); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $c->where('Author.FirstName = ?', 'Neal'); + $c->select(array('Title', 'ISBN')); + $titles = $c->find($this->con); + $this->assertEquals($titles->count(), 1, 'find() called after select(array) allows for join() statements'); + $expectedSQL = "SELECT book.title AS `Title`, book.isbn AS `ISBN` FROM `book` INNER JOIN `author` ON (book.author_id=author.id) WHERE author.first_name = 'Neal'"; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'find() called after select(array) allows for join() statements'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $c->where('Author.FirstName = ?', 'Neal'); + $c->select(array('Author.FirstName', 'Author.LastName')); + $titles = $c->find($this->con); + $this->assertEquals(array_values($titles->shift()), array('Neal', 'Stephenson'), 'find() called after select(array) will return values from the joined table using complete column names'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $c->where('Author.FirstName = ?', 'Neal'); + $c->select(array('Title', 'ISBN')); + $title = $c->findOne($this->con); + $this->assertEquals(count($title), 2, 'findOne() called after select(array) allows for join() statements'); + $expectedSQL = "SELECT book.title AS `Title`, book.isbn AS `ISBN` FROM `book` INNER JOIN `author` ON (book.author_id=author.id) WHERE author.first_name = 'Neal' LIMIT 1"; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'findOne() called after select(array) allows for join() statements'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $c->where('Author.FirstName = ?', 'Neal'); + $c->select(array('Author.FirstName', 'Author.LastName')); + $title = $c->findOne($this->con); + $this->assertEquals(array_values($title), array('Neal', 'Stephenson'), 'findOne() called after select(array) will return values from the joined table using complete column names'); + } + + public function testSelectArrayRelation() + { + BookstoreDataPopulator::depopulate($this->con); + BookstoreDataPopulator::populate($this->con); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $c->orderBy('Book.Title'); + $c->select(array('Author.LastName', 'Book.Title')); + $rows = $c->find($this->con); + $expectedSQL = 'SELECT author.last_name AS `Author.LastName`, book.title AS `Book.Title` FROM `book` INNER JOIN `author` ON (book.author_id=author.id) ORDER BY book.title ASC'; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'select(array) can select columns from several tables (many-to-one)'); + + $expectedRows = array( + array( + 'Author.LastName' => 'Byron', + 'Book.Title' => 'Don Juan', + ), + array( + 'Author.LastName' => 'Rowling', + 'Book.Title' => 'Harry Potter and the Order of the Phoenix', + ), + array( + 'Author.LastName' => 'Stephenson', + 'Book.Title' => 'Quicksilver', + ), + array( + 'Author.LastName' => 'Grass', + 'Book.Title' => 'The Tin Drum', + ), + ); + $this->assertEquals(serialize($rows->getData()), serialize($expectedRows), 'find() called after select(array) returns columns from several tables (many-to-one'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $c->select(array('Author.LastName', 'Book.Title')); + $c->orderBy('Book.Id'); + $c->orderBy('Author.Id'); + $rows = $c->find($this->con); + $expectedSQL = 'SELECT author.last_name AS `Author.LastName`, book.title AS `Book.Title` FROM `book` INNER JOIN `author` ON (book.author_id=author.id) ORDER BY book.id ASC,author.id ASC'; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'select(array) can select columns from several tables (many-to-one)'); + + $expectedRows = array ( + array ( + 'Author.LastName' => 'Rowling', + 'Book.Title' => 'Harry Potter and the Order of the Phoenix', + ), + array ( + 'Author.LastName' => 'Stephenson', + 'Book.Title' => 'Quicksilver', + ), + array ( + 'Author.LastName' => 'Byron', + 'Book.Title' => 'Don Juan', + ), + array ( + 'Author.LastName' => 'Grass', + 'Book.Title' => 'The Tin Drum', + ) + ); + $this->assertEquals(serialize($rows->getData()), serialize($expectedRows), 'find() called after select(array) returns columns from several tables (many-to-one'); + } + + public function testSelectArrayWithColumn() + { + BookstoreDataPopulator::depopulate($this->con); + BookstoreDataPopulator::populate($this->con); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $c->withColumn('LOWER(Book.Title)', 'LowercaseTitle'); + $c->select(array('LowercaseTitle', 'Book.Title')); + $c->orderBy('Book.Title'); + $rows = $c->find($this->con); + $expectedSQL = 'SELECT LOWER(book.title) AS `LowercaseTitle`, book.title AS `Book.Title` FROM `book` INNER JOIN `author` ON (book.author_id=author.id) ORDER BY book.title ASC'; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'find() called after select(array) can cope with a column added with withColumn()'); + + $expectedRows = array ( + array ( + 'LowercaseTitle' => 'don juan', + 'Book.Title' => 'Don Juan', + ), + array ( + 'LowercaseTitle' => 'harry potter and the order of the phoenix', + 'Book.Title' => 'Harry Potter and the Order of the Phoenix', + ), + array ( + 'LowercaseTitle' => 'quicksilver', + 'Book.Title' => 'Quicksilver', + ), + array ( + 'LowercaseTitle' => 'the tin drum', + 'Book.Title' => 'The Tin Drum', + ), + ); + $this->assertEquals(serialize($rows->getData()), serialize($expectedRows), 'find() called after select(array) can cope with a column added with withColumn()'); + } + + public function testSelectArrayWithColumnOrder() + { + BookstoreDataPopulator::depopulate($this->con); + BookstoreDataPopulator::populate($this->con); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $c->withColumn('LOWER(Book.Title)', 'LowercaseTitle'); + $c->withColumn('UPPER(Book.Title)', 'UppercaseTitle'); + $c->select(array('Book.ISBN', 'LowercaseTitle', 'Book.Title', 'UppercaseTitle')); + $c->orderBy('Book.Title'); + $rows = $c->find($this->con); + $expectedSQL = 'SELECT book.isbn AS `Book.ISBN`, LOWER(book.title) AS `LowercaseTitle`, book.title AS `Book.Title`, UPPER(book.title) AS `UppercaseTitle` FROM `book` INNER JOIN `author` ON (book.author_id=author.id) ORDER BY book.title ASC'; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery(), 'find() called after select(array) can cope with a column added with withColumn()'); + + $expectedRows = array ( + array ( + 'Book.ISBN' => '0140422161', + 'LowercaseTitle' => 'don juan', + 'Book.Title' => 'Don Juan', + 'UppercaseTitle' => 'DON JUAN', + ), + array ( + 'Book.ISBN' => '043935806X', + 'LowercaseTitle' => 'harry potter and the order of the phoenix', + 'Book.Title' => 'Harry Potter and the Order of the Phoenix', + 'UppercaseTitle' => 'HARRY POTTER AND THE ORDER OF THE PHOENIX', + ), + array ( + 'Book.ISBN' => '0380977427', + 'LowercaseTitle' => 'quicksilver', + 'Book.Title' => 'Quicksilver', + 'UppercaseTitle' => 'QUICKSILVER', + ), + array ( + 'Book.ISBN' => '067972575X', + 'LowercaseTitle' => 'the tin drum', + 'Book.Title' => 'The Tin Drum', + 'UppercaseTitle' => 'THE TIN DRUM', + ), + ); + $this->assertEquals(serialize($rows->getData()), serialize($expectedRows), 'find() called after select(array) can cope with a column added with withColumn()'); + } + + public function testSelectArrayPaginate() + { + BookstoreDataPopulator::depopulate($this->con); + BookstoreDataPopulator::populate($this->con); + + $pager = BookQuery::create() + ->select(array('Id', 'Title', 'ISBN', 'Price')) + ->paginate(1, 10, $this->con); + $this->assertInstanceOf('PropelModelPager', $pager); + foreach ($pager as $result) { + $this->assertEquals(array('Id', 'Title', 'ISBN', 'Price'), array_keys($result)); + } + } + + public function testGetSelectReturnsNullByDefault() + { + $c = new ModelCriteria('bookstore', 'Book'); + $this->assertNull($c->getSelect()); + } + + public function testGetSelectReturnsStringWhenSelectingASingleColumn() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->select('Title'); + $this->assertEquals('Title', $c->getSelect()); + } + + public function testGetSelectReturnsArrayWhenSelectingSeveralColumns() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->select(array('Id', 'Title')); + $this->assertEquals(array('Id', 'Title'), $c->getSelect()); + } + + public function testGetSelectReturnsArrayWhenSelectingASingleColumnAsArray() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->select(array('Title')); + $this->assertEquals(array('Title'), $c->getSelect()); + } + + public function testGetSelectReturnsArrayWhenSelectingAllColumns() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->select('*'); + $this->assertEquals(array('Book.Id', 'Book.Title', 'Book.ISBN', 'Book.Price', 'Book.PublisherId', 'Book.AuthorId'), $c->getSelect()); + } + + public function testQuotingAliases() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->withColumn('book.title', 'Book Title (*.)'); + $c->select('Book Title (*.)'); + $c->where('Book.Isbn = ?', '0380977427'); + $title = $c->findOne(); + $expectedSQL = "SELECT book.title AS `Book Title (*.)` FROM `book` WHERE book.isbn = '0380977427' LIMIT 1"; + $this->assertEquals($expectedSQL, $this->con->getLastExecutedQuery()); + $this->assertEquals('Quicksilver', $title); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaTest.php index fdd8efb69..0c23967b6 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaTest.php @@ -8,2061 +8,2695 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; -require_once 'tools/helpers/bookstore/BookstoreDataPopulator.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreDataPopulator.php'; /** * Test class for ModelCriteria. * * @author Francois Zaninotto - * @version $Id: ModelCriteriaTest.php 1796 2010-06-14 11:45:49Z francois $ + * @version $Id$ * @package runtime.query */ class ModelCriteriaTest extends BookstoreTestBase { - protected function assertCriteriaTranslation($criteria, $expectedSql, $expectedParams, $message = '') - { - $params = array(); - $result = BasePeer::createSelectSql($criteria, $params); - - $this->assertEquals($expectedSql, $result, $message); - $this->assertEquals($expectedParams, $params, $message); - } - - public function testGetModelName() - { - $c = new ModelCriteria('bookstore', 'Book'); - $this->assertEquals('Book', $c->getModelName(), 'getModelName() returns the name of the class associated to the model class'); - } - - public function testGetModelPeerName() - { - $c = new ModelCriteria('bookstore', 'Book'); - $this->assertEquals('BookPeer', $c->getModelPeerName(), 'getModelPeerName() returns the name of the Peer class associated to the model class'); - } - - public function testFormatter() - { - $c = new ModelCriteria('bookstore', 'Book'); - $this->assertTrue($c->getFormatter() instanceof PropelFormatter, 'getFormatter() returns a PropelFormatter instance'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->setFormatter(ModelCriteria::FORMAT_STATEMENT); - $this->assertTrue($c->getFormatter() instanceof PropelStatementFormatter, 'setFormatter() accepts the name of a PropelFormatter class'); - - try { - $c->setFormatter('Book'); - $this->fail('setFormatter() throws an exception when passed the name of a class not extending PropelFormatter'); - } catch(PropelException $e) { - $this->assertTrue(true, 'setFormatter() throws an exception when passed the name of a class not extending PropelFormatter'); - } - $c = new ModelCriteria('bookstore', 'Book'); - $formatter = new PropelStatementFormatter(); - $c->setFormatter($formatter); - $this->assertTrue($c->getFormatter() instanceof PropelStatementFormatter, 'setFormatter() accepts a PropelFormatter instance'); - - try { - $formatter = new Book(); - $c->setFormatter($formatter); - $this->fail('setFormatter() throws an exception when passed an object not extending PropelFormatter'); - } catch(PropelException $e) { - $this->assertTrue(true, 'setFormatter() throws an exception when passedan object not extending PropelFormatter'); - } - - } - - public static function conditionsForTestReplaceNames() - { - return array( - array('Book.Title = ?', 'Title', 'book.TITLE = ?'), // basic case - array('Book.Title=?', 'Title', 'book.TITLE=?'), // without spaces - array('Book.Id<= ?', 'Id', 'book.ID<= ?'), // with non-equal comparator - array('Book.AuthorId LIKE ?', 'AuthorId', 'book.AUTHOR_ID LIKE ?'), // with SQL keyword separator - array('(Book.AuthorId) LIKE ?', 'AuthorId', '(book.AUTHOR_ID) LIKE ?'), // with parenthesis - array('(Book.Id*1.5)=1', 'Id', '(book.ID*1.5)=1'), // ignore numbers - array('1=1', null, '1=1'), // with no name - array('', null, '') // with empty string - ); - } - - /** - * @dataProvider conditionsForTestReplaceNames - */ - public function testReplaceNames($origClause, $columnPhpName = false, $modifiedClause) - { - $c = new TestableModelCriteria('bookstore', 'Book'); - $c->replaceNames($origClause); - $columns = $c->replacedColumns; - if ($columnPhpName) { - $this->assertEquals(array(BookPeer::getTableMap()->getColumnByPhpName($columnPhpName)), $columns); - } - $this->assertEquals($modifiedClause, $origClause); - } - - public static function conditionsForTestReplaceMultipleNames() - { - return array( - array('(Book.Id+Book.Id)=1', array('Id', 'Id'), '(book.ID+book.ID)=1'), // match multiple names - array('CONCAT(Book.Title,"Book.Id")= ?', array('Title', 'Id'), 'CONCAT(book.TITLE,"Book.Id")= ?'), // ignore names in strings - array('CONCAT(Book.Title," Book.Id ")= ?', array('Title', 'Id'), 'CONCAT(book.TITLE," Book.Id ")= ?'), // ignore names in strings - array('MATCH (Book.Title,Book.ISBN) AGAINST (?)', array('Title', 'ISBN'), 'MATCH (book.TITLE,book.ISBN) AGAINST (?)'), - ); - } - - /** - * @dataProvider conditionsForTestReplaceMultipleNames - */ - public function testReplaceMultipleNames($origClause, $expectedColumns, $modifiedClause) - { - $c = new TestableModelCriteria('bookstore', 'Book'); - $c->replaceNames($origClause); - $foundColumns = $c->replacedColumns; - foreach ($foundColumns as $column) { - $expectedColumn = BookPeer::getTableMap()->getColumnByPhpName(array_shift($expectedColumns)); - $this->assertEquals($expectedColumn, $column); - } - $this->assertEquals($modifiedClause, $origClause); - } - - public function testTableAlias() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->setModelAlias('b'); - $c->where('b.Title = ?', 'foo'); - - $sql = "SELECT FROM `book` WHERE book.TITLE = :p1"; - $params = array( - array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'setModelAlias() allows the definition of the alias after constrution'); - - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'foo'); - - $sql = "SELECT FROM `book` WHERE book.TITLE = :p1"; - $params = array( - array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'A ModelCriteria accepts a model name with an alias'); - } - - public function testTrueTableAlias() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->setModelAlias('b', true); - $c->where('b.Title = ?', 'foo'); - $c->join('b.Author a'); - $c->where('a.FirstName = ?', 'john'); - - - $sql = "SELECT FROM `book` `b` INNER JOIN author a ON (b.AUTHOR_ID=a.ID) WHERE b.TITLE = :p1 AND a.FIRST_NAME = :p2"; - $params = array( - array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'), - array('table' => 'author', 'column' => 'FIRST_NAME', 'value' => 'john'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'setModelAlias() allows the definition of a true SQL alias after constrution'); - } - - public function testCondition() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->condition('cond1', 'Book.Title <> ?', 'foo'); - $c->condition('cond2', 'Book.Title like ?', '%bar%'); - $c->combine(array('cond1', 'cond2'), 'or'); - - $sql = "SELECT FROM `book` WHERE (book.TITLE <> :p1 OR book.TITLE like :p2)"; - $params = array( - array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'), - array('table' => 'book', 'column' => 'TITLE', 'value' => '%bar%'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'condition() can store condition for later combination'); - } - - public static function conditionsForTestWhere() - { - return array( - array('Book.Title = ?', 'foo', 'book.TITLE = :p1', array(array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'))), - array('Book.AuthorId = ?', 12, 'book.AUTHOR_ID = :p1', array(array('table' => 'book', 'column' => 'AUTHOR_ID', 'value' => 12))), - array('Book.AuthorId IS NULL', null, 'book.AUTHOR_ID IS NULL', array()), - array('Book.Id BETWEEN ? AND ?', array(3, 4), 'book.ID BETWEEN :p1 AND :p2', array(array('table' => 'book', 'column' => 'ID', 'value' => 3), array('table' => 'book', 'column' => 'ID', 'value' => 4))), - array('Book.Id betWEen ? and ?', array(3, 4), 'book.ID betWEen :p1 and :p2', array(array('table' => 'book', 'column' => 'ID', 'value' => 3), array('table' => 'book', 'column' => 'ID', 'value' => 4))), - array('Book.Id IN ?', array(1, 2, 3), 'book.ID IN (:p1,:p2,:p3)', array(array('table' => 'book', 'column' => 'ID', 'value' => 1), array('table' => 'book', 'column' => 'ID', 'value' => 2), array('table' => 'book', 'column' => 'ID', 'value' => 3))), - array('Book.Id in ?', array(1, 2, 3), 'book.ID in (:p1,:p2,:p3)', array(array('table' => 'book', 'column' => 'ID', 'value' => 1), array('table' => 'book', 'column' => 'ID', 'value' => 2), array('table' => 'book', 'column' => 'ID', 'value' => 3))), - array('Book.Id IN ?', array(), '1<>1', array()), - array('Book.Id not in ?', array(), '1=1', array()), - array('UPPER(Book.Title) = ?', 'foo', 'UPPER(book.TITLE) = :p1', array(array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'))), - array('MATCH (Book.Title,Book.ISBN) AGAINST (?)', 'foo', 'MATCH (book.TITLE,book.ISBN) AGAINST (:p1)', array(array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'))), - ); - } - - /** - * @dataProvider conditionsForTestWhere - */ - public function testWhere($clause, $value, $sql, $params) - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->where($clause, $value); - $sql = 'SELECT FROM `book` WHERE ' . $sql; - $this->assertCriteriaTranslation($c, $sql, $params, 'where() accepts a string clause'); - } - - public function testWhereTwiceSameColumn() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->where('Book.Id IN ?', array(1, 2, 3)); - $c->where('Book.Id <> ?', 5); - $params = array( - array('table' => 'book', 'column' => 'ID', 'value' => '1'), - array('table' => 'book', 'column' => 'ID', 'value' => '2'), - array('table' => 'book', 'column' => 'ID', 'value' => '3'), - array('table' => 'book', 'column' => 'ID', 'value' => '5'), - ); - $sql = 'SELECT FROM `book` WHERE (book.ID IN (:p1,:p2,:p3) AND book.ID <> :p4)'; - $this->assertCriteriaTranslation($c, $sql, $params, 'where() adds clauses on the same column correctly'); - } - - public function testWhereConditions() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->condition('cond1', 'Book.Title <> ?', 'foo'); - $c->condition('cond2', 'Book.Title like ?', '%bar%'); - $c->where(array('cond1', 'cond2')); - - $sql = "SELECT FROM `book` WHERE (book.TITLE <> :p1 AND book.TITLE like :p2)"; - $params = array( - array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'), - array('table' => 'book', 'column' => 'TITLE', 'value' => '%bar%'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'where() accepts an array of named conditions'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->condition('cond1', 'Book.Title <> ?', 'foo'); - $c->condition('cond2', 'Book.Title like ?', '%bar%'); - $c->where(array('cond1', 'cond2'), Criteria::LOGICAL_OR); - - $sql = "SELECT FROM `book` WHERE (book.TITLE <> :p1 OR book.TITLE like :p2)"; - $this->assertCriteriaTranslation($c, $sql, $params, 'where() accepts an array of named conditions with operator'); - } - - public function testWhereNoReplacement() - { - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'foo'); - $c->where('1=1'); - - $sql = "SELECT FROM `book` WHERE book.TITLE = :p1 AND 1=1"; - $params = array( - array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'where() results in a Criteria::CUSTOM if no column name is matched'); - - $c = new ModelCriteria('bookstore', 'Book'); - try { - $c->where('b.Title = ?', 'foo'); - $this->fail('where() throws an exception when it finds a ? but cannot determine a column'); - } catch (PropelException $e) { - $this->assertTrue(true, 'where() throws an exception when it finds a ? but cannot determine a column'); - } - } - - public function testWhereFunction() - { - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->where('UPPER(b.Title) = ?', 'foo'); - - $sql = "SELECT FROM `book` WHERE UPPER(book.TITLE) = :p1"; - $params = array( - array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'where() accepts a complex calculation'); - } - - public function testOrWhere() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->where('Book.Title <> ?', 'foo'); - $c->orWhere('Book.Title like ?', '%bar%'); - - $sql = "SELECT FROM `book` WHERE (book.TITLE <> :p1 OR book.TITLE like :p2)"; - $params = array( - array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'), - array('table' => 'book', 'column' => 'TITLE', 'value' => '%bar%'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'orWhere() combines the clause with the previous one using OR'); - } - - public function testOrWhereConditions() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->where('Book.Id = ?', 12); - $c->condition('cond1', 'Book.Title <> ?', 'foo'); - $c->condition('cond2', 'Book.Title like ?', '%bar%'); - $c->orWhere(array('cond1', 'cond2')); - - $sql = "SELECT FROM `book` WHERE (book.ID = :p1 OR (book.TITLE <> :p2 AND book.TITLE like :p3))"; - $params = array( - array('table' => 'book', 'column' => 'ID', 'value' => 12), - array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'), - array('table' => 'book', 'column' => 'TITLE', 'value' => '%bar%'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'orWhere() accepts an array of named conditions'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->where('Book.Id = ?', 12); - $c->condition('cond1', 'Book.Title <> ?', 'foo'); - $c->condition('cond2', 'Book.Title like ?', '%bar%'); - $c->orWhere(array('cond1', 'cond2'), Criteria::LOGICAL_OR); - - $sql = "SELECT FROM `book` WHERE (book.ID = :p1 OR (book.TITLE <> :p2 OR book.TITLE like :p3))"; - $this->assertCriteriaTranslation($c, $sql, $params, 'orWhere() accepts an array of named conditions with operator'); - } - - public function testMixedCriteria() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->where('Book.Title = ?', 'foo'); - $c->add(BookPeer::ID, array(1, 2), Criteria::IN); - - $sql = 'SELECT FROM `book` WHERE book.TITLE = :p1 AND book.ID IN (:p2,:p3)'; - $params = array( - array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'), - array('table' => 'book', 'column' => 'ID', 'value' => 1), - array('table' => 'book', 'column' => 'ID', 'value' => 2) - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'ModelCriteria accepts Criteria operators'); - } - - public function testFilterBy() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->filterBy('Title', 'foo'); - - $sql = 'SELECT FROM `book` WHERE book.TITLE=:p1'; - $params = array( - array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'filterBy() accepts a simple column name'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->filterBy('Title', 'foo', Criteria::NOT_EQUAL); - - $sql = 'SELECT FROM `book` WHERE book.TITLE<>:p1'; - $params = array( - array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'filterBy() accepts a sicustom comparator'); - - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->filterBy('Title', 'foo'); - - $sql = 'SELECT FROM `book` WHERE book.TITLE=:p1'; - $params = array( - array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'filterBy() accepts a simple column name, even if initialized with an alias'); - } - - public function testHaving() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->having('Book.Title <> ?', 'foo'); - - $sql = "SELECT FROM HAVING book.TITLE <> :p1"; - $params = array( - array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'having() accepts a string clause'); - } - - public function testHavingConditions() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->condition('cond1', 'Book.Title <> ?', 'foo'); - $c->condition('cond2', 'Book.Title like ?', '%bar%'); - $c->having(array('cond1', 'cond2')); - - $sql = "SELECT FROM HAVING (book.TITLE <> :p1 AND book.TITLE like :p2)"; - $params = array( - array('table' => 'book', 'column' => 'TITLE', 'value' => 'foo'), - array('table' => 'book', 'column' => 'TITLE', 'value' => '%bar%'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'having() accepts an array of named conditions'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->condition('cond1', 'Book.Title <> ?', 'foo'); - $c->condition('cond2', 'Book.Title like ?', '%bar%'); - $c->having(array('cond1', 'cond2'), Criteria::LOGICAL_OR); - - $sql = "SELECT FROM HAVING (book.TITLE <> :p1 OR book.TITLE like :p2)"; - $this->assertCriteriaTranslation($c, $sql, $params, 'having() accepts an array of named conditions with an operator'); - } - - public function testOrderBy() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->orderBy('Book.Title'); - - $sql = 'SELECT FROM ORDER BY book.TITLE ASC'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'orderBy() accepts a column name and adds an ORDER BY clause'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->orderBy('Book.Title', 'desc'); - - $sql = 'SELECT FROM ORDER BY book.TITLE DESC'; - $this->assertCriteriaTranslation($c, $sql, $params, 'orderBy() accepts an order parameter'); - - $c = new ModelCriteria('bookstore', 'Book'); - try { - $c->orderBy('Book.Foo'); - $this->fail('orderBy() throws an exception when called with an unkown column name'); - } catch (PropelException $e) { - $this->assertTrue(true, 'orderBy() throws an exception when called with an unkown column name'); - } - $c = new ModelCriteria('bookstore', 'Book'); - try { - $c->orderBy('Book.Title', 'foo'); - $this->fail('orderBy() throws an exception when called with an unkown order'); - } catch (PropelException $e) { - $this->assertTrue(true, 'orderBy() throws an exception when called with an unkown order'); - } - } - - public function testOrderBySimpleColumn() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->orderBy('Title'); - - $sql = 'SELECT FROM ORDER BY book.TITLE ASC'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'orderBy() accepts a simple column name and adds an ORDER BY clause'); - } - - public function testOrderByAlias() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->addAsColumn('t', BookPeer::TITLE); - $c->orderBy('t'); - - $sql = 'SELECT book.TITLE AS t FROM ORDER BY t ASC'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'orderBy() accepts a column alias and adds an ORDER BY clause'); - } - - public function testGroupBy() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->groupBy('Book.AuthorId'); - - $sql = 'SELECT FROM GROUP BY book.AUTHOR_ID'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'groupBy() accepts a column name and adds a GROUP BY clause'); - - $c = new ModelCriteria('bookstore', 'Book'); - try { - $c->groupBy('Book.Foo'); - $this->fail('groupBy() throws an exception when called with an unkown column name'); - } catch (PropelException $e) { - $this->assertTrue(true, 'groupBy() throws an exception when called with an unkown column name'); - } - } - - public function testGroupBySimpleColumn() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->groupBy('AuthorId'); - - $sql = 'SELECT FROM GROUP BY book.AUTHOR_ID'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'groupBy() accepts a simple column name and adds a GROUP BY clause'); - } - - public function testGroupByAlias() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->addAsColumn('t', BookPeer::TITLE); - $c->groupBy('t'); - - $sql = 'SELECT book.TITLE AS t FROM GROUP BY t'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'groupBy() accepts a column alias and adds a GROUP BY clause'); - } - - public function testDistinct() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->distinct(); - $sql = 'SELECT DISTINCT FROM '; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'distinct() adds a DISTINCT clause'); - } - - public function testLimit() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->limit(10); - $sql = 'SELECT FROM LIMIT 10'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'limit() adds a LIMIT clause'); - } - - public function testOffset() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->limit(50); - $c->offset(10); - $sql = 'SELECT FROM LIMIT 10, 50'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'offset() adds an OFFSET clause'); - } - - public function testJoin() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->join('Book.Author'); - $sql = 'SELECT FROM `book` INNER JOIN author ON (book.AUTHOR_ID=author.ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() uses a relation to guess the columns'); - - $c = new ModelCriteria('bookstore', 'Book'); - try { - $c->join('Book.Foo'); - $this->fail('join() throws an exception when called with a non-existing relation'); - } catch (PropelException $e) { - $this->assertTrue(true, 'join() throws an exception when called with a non-existing relation'); - } - - $c = new ModelCriteria('bookstore', 'Book'); - $c->join('Book.Author'); - $c->where('Author.FirstName = ?', 'Leo'); - $sql = 'SELECT FROM INNER JOIN author ON (book.AUTHOR_ID=author.ID) WHERE author.FIRST_NAME = :p1'; - $params = array( - array('table' => 'author', 'column' => 'FIRST_NAME', 'value' => 'Leo'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() uses a relation to guess the columns'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->join('Author'); - $c->where('Author.FirstName = ?', 'Leo'); - $sql = 'SELECT FROM INNER JOIN author ON (book.AUTHOR_ID=author.ID) WHERE author.FIRST_NAME = :p1'; - $params = array( - array('table' => 'author', 'column' => 'FIRST_NAME', 'value' => 'Leo'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() uses the current model name when given a simple relation name'); - } - - public function testJoinQuery() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - BookstoreDataPopulator::depopulate($con); - BookstoreDataPopulator::populate($con); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->join('Book.Author'); - $c->where('Author.FirstName = ?', 'Neal'); - $books = BookPeer::doSelect($c); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` INNER JOIN author ON (book.AUTHOR_ID=author.ID) WHERE author.FIRST_NAME = 'Neal'"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'join() issues a real JOIN query'); - $this->assertEquals(1, count($books), 'join() issues a real JOIN query'); - } - - public function testJoinRelationName() - { - $c = new ModelCriteria('bookstore', 'BookstoreEmployee'); - $c->join('BookstoreEmployee.Supervisor'); - $sql = 'SELECT FROM INNER JOIN bookstore_employee ON (bookstore_employee.SUPERVISOR_ID=bookstore_employee.ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() uses relation names as defined in schema.xml'); - } - - public function testJoinComposite() - { - $c = new ModelCriteria('bookstore', 'ReaderFavorite'); - $c->join('ReaderFavorite.BookOpinion'); - $sql = 'SELECT FROM `reader_favorite` INNER JOIN book_opinion ON (reader_favorite.BOOK_ID=book_opinion.BOOK_ID AND reader_favorite.READER_ID=book_opinion.READER_ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() knows how to create a JOIN clause for relationships with composite fkeys'); - } - - public function testJoinType() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->join('Book.Author'); - $sql = 'SELECT FROM `book` INNER JOIN author ON (book.AUTHOR_ID=author.ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() adds an INNER JOIN by default'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->join('Book.Author', Criteria::INNER_JOIN); - $sql = 'SELECT FROM `book` INNER JOIN author ON (book.AUTHOR_ID=author.ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() adds an INNER JOIN by default'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->join('Book.Author', Criteria::LEFT_JOIN); - $sql = 'SELECT FROM `book` LEFT JOIN author ON (book.AUTHOR_ID=author.ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() can add a LEFT JOIN'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->join('Book.Author', Criteria::RIGHT_JOIN); - $sql = 'SELECT FROM `book` RIGHT JOIN author ON (book.AUTHOR_ID=author.ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() can add a RIGHT JOIN'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->join('Book.Author', 'incorrect join'); - $sql = 'SELECT FROM `book` incorrect join author ON (book.AUTHOR_ID=author.ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() accepts any join string'); - } - - public function testJoinDirection() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->join('Book.Author'); - $sql = 'SELECT FROM `book` INNER JOIN author ON (book.AUTHOR_ID=author.ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() adds a JOIN clause correctly for many to one relationship'); - - $c = new ModelCriteria('bookstore', 'Author'); - $c->join('Author.Book'); - $sql = 'SELECT FROM `author` INNER JOIN book ON (author.ID=book.AUTHOR_ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() adds a JOIN clause correctly for one to many relationship'); - - $c = new ModelCriteria('bookstore', 'BookstoreEmployee'); - $c->join('BookstoreEmployee.BookstoreEmployeeAccount'); - $sql = 'SELECT FROM `bookstore_employee` INNER JOIN bookstore_employee_account ON (bookstore_employee.ID=bookstore_employee_account.EMPLOYEE_ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() adds a JOIN clause correctly for one to one relationship'); - - $c = new ModelCriteria('bookstore', 'BookstoreEmployeeAccount'); - $c->join('BookstoreEmployeeAccount.BookstoreEmployee'); - $sql = 'SELECT FROM `bookstore_employee_account` INNER JOIN bookstore_employee ON (bookstore_employee_account.EMPLOYEE_ID=bookstore_employee.ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() adds a JOIN clause correctly for one to one relationship'); - } - - public function testJoinSeveral() - { - $c = new ModelCriteria('bookstore', 'Author'); - $c->join('Author.Book'); - $c->join('Book.Publisher'); - $c->where('Publisher.Name = ?', 'foo'); - $sql = 'SELECT FROM INNER JOIN book ON (author.ID=book.AUTHOR_ID) INNER JOIN publisher ON (book.PUBLISHER_ID=publisher.ID) WHERE publisher.NAME = :p1'; - $params = array( - array('table' => 'publisher', 'column' => 'NAME', 'value' => 'foo'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() can guess relationships from related tables'); - } - - public function testJoinAlias() - { - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->join('b.Author'); - $sql = 'SELECT FROM `book` INNER JOIN author ON (book.AUTHOR_ID=author.ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() supports relation on main alias'); - - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->join('Author'); - $sql = 'SELECT FROM `book` INNER JOIN author ON (book.AUTHOR_ID=author.ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() can use a simple relation name when the model has an alias'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->join('Book.Author a'); - $sql = 'SELECT FROM `book` INNER JOIN author a ON (book.AUTHOR_ID=a.ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() supports relation alias'); - - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->join('b.Author a'); - $sql = 'SELECT FROM `book` INNER JOIN author a ON (book.AUTHOR_ID=a.ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() supports relation alias on main alias'); - - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->join('b.Author a'); - $c->where('a.FirstName = ?', 'Leo'); - $sql = 'SELECT FROM INNER JOIN author a ON (book.AUTHOR_ID=a.ID) WHERE a.FIRST_NAME = :p1'; - $params = array( - array('table' => 'author', 'column' => 'FIRST_NAME', 'value' => 'Leo'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() allows the use of relation alias in where()'); - - $c = new ModelCriteria('bookstore', 'Author', 'a'); - $c->join('a.Book b'); - $c->join('b.Publisher p'); - $c->where('p.Name = ?', 'foo'); - $sql = 'SELECT FROM INNER JOIN book b ON (author.ID=b.AUTHOR_ID) INNER JOIN publisher p ON (b.PUBLISHER_ID=p.ID) WHERE p.NAME = :p1'; - $params = array( - array('table' => 'publisher', 'column' => 'NAME', 'value' => 'foo'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() allows the use of relation alias in further join()'); - } - - public function testJoinTrueTableAlias() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->setModelAlias('b', true); - $c->join('b.Author'); - $sql = 'SELECT FROM `book` `b` INNER JOIN author ON (b.AUTHOR_ID=author.ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() supports relation on true table alias'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->setModelAlias('b', true); - $c->join('Author'); - $sql = 'SELECT FROM `book` `b` INNER JOIN author ON (b.AUTHOR_ID=author.ID)'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() supports relation without alias name on true table alias'); - } - - public function testJoinOnSameTable() - { - $c = new ModelCriteria('bookstore', 'BookstoreEmployee', 'be'); - $c->join('be.Supervisor sup'); - $c->join('sup.Subordinate sub'); - $c->where('sub.Name = ?', 'Foo'); - $sql = 'SELECT FROM INNER JOIN bookstore_employee sup ON (bookstore_employee.SUPERVISOR_ID=sup.ID) INNER JOIN bookstore_employee sub ON (sup.ID=sub.SUPERVISOR_ID) WHERE sub.NAME = :p1'; - $params = array( - array('table' => 'bookstore_employee', 'column' => 'NAME', 'value' => 'Foo'), - ); - $this->assertCriteriaTranslation($c, $sql, $params, 'join() allows two joins on the same table thanks to aliases'); - } - - public function testJoinAliasQuery() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->join('b.Author a'); - $c->where('a.FirstName = ?', 'Leo'); - $books = BookPeer::doSelect($c, $con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` INNER JOIN author a ON (book.AUTHOR_ID=a.ID) WHERE a.FIRST_NAME = 'Leo'"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'join() allows the use of relation alias in where()'); - - $c = new ModelCriteria('bookstore', 'BookstoreEmployee', 'be'); - $c->join('be.Supervisor sup'); - $c->join('sup.Subordinate sub'); - $c->where('sub.Name = ?', 'Foo'); - $employees = BookstoreEmployeePeer::doSelect($c, $con); - $expectedSQL = "SELECT bookstore_employee.ID, bookstore_employee.CLASS_KEY, bookstore_employee.NAME, bookstore_employee.JOB_TITLE, bookstore_employee.SUPERVISOR_ID FROM `bookstore_employee` INNER JOIN bookstore_employee sup ON (bookstore_employee.SUPERVISOR_ID=sup.ID) INNER JOIN bookstore_employee sub ON (sup.ID=sub.SUPERVISOR_ID) WHERE sub.NAME = 'Foo'"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'join() allows the use of relation alias in further joins()'); - } - - public function testGetJoin() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->join('Book.Author'); - - $joins = $c->getJoins(); - $this->assertEquals($joins['Author'], $c->getJoin('Author'), "getJoin() returns a specific Join from the ModelCriteria"); - } - - public function testWith() - { - $c = new TestableModelCriteria('bookstore', 'Book'); - $c->join('Book.Author'); - $c->with('Author'); - $withs = $c->getWith(); - $this->assertTrue(array_key_exists('Author', $withs), 'with() adds an entry to the internal list of Withs'); - $this->assertTrue($withs['Author'] instanceof ModelJoin, 'with() references the ModelJoin object'); - } - - /** - * @expectedException PropelException - */ - public function testWithThrowsExceptionWhenJoinLacks() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->with('Author'); - } - - public function testWithAlias() - { - $c = new TestableModelCriteria('bookstore', 'Book'); - $c->join('Book.Author a'); - $c->with('a'); - $withs = $c->getWith(); - $this->assertTrue(array_key_exists('a', $withs), 'with() uses the alias for the index of the internal list of Withs'); - } - - /** - * @expectedException PropelException - */ - public function testWithThrowsExceptionWhenNotUsingAlias() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->join('Book.Author a'); - $c->with('Author'); - } - - public function testWithAddsSelectColumns() - { - $c = new TestableModelCriteria('bookstore', 'Book'); - BookPeer::addSelectColumns($c); - $c->join('Book.Author'); - $c->with('Author'); - $expectedColumns = array( - BookPeer::ID, - BookPeer::TITLE, - BookPeer::ISBN, - BookPeer::PRICE, - BookPeer::PUBLISHER_ID, - BookPeer::AUTHOR_ID, - AuthorPeer::ID, - AuthorPeer::FIRST_NAME, - AuthorPeer::LAST_NAME, - AuthorPeer::EMAIL, - AuthorPeer::AGE - ); - $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the related table'); - } - - public function testWithAliasAddsSelectColumns() - { - $c = new TestableModelCriteria('bookstore', 'Book'); - BookPeer::addSelectColumns($c); - $c->join('Book.Author a'); - $c->with('a'); - $expectedColumns = array( - BookPeer::ID, - BookPeer::TITLE, - BookPeer::ISBN, - BookPeer::PRICE, - BookPeer::PUBLISHER_ID, - BookPeer::AUTHOR_ID, - 'a.ID', - 'a.FIRST_NAME', - 'a.LAST_NAME', - 'a.EMAIL', - 'a.AGE' - ); - $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the related table'); - } - - public function testWithAddsSelectColumnsOfMainTable() - { - $c = new TestableModelCriteria('bookstore', 'Book'); - $c->join('Book.Author'); - $c->with('Author'); - $expectedColumns = array( - BookPeer::ID, - BookPeer::TITLE, - BookPeer::ISBN, - BookPeer::PRICE, - BookPeer::PUBLISHER_ID, - BookPeer::AUTHOR_ID, - AuthorPeer::ID, - AuthorPeer::FIRST_NAME, - AuthorPeer::LAST_NAME, - AuthorPeer::EMAIL, - AuthorPeer::AGE - ); - $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the main table if required'); - } - - public function testWithAliasAddsSelectColumnsOfMainTable() - { - $c = new TestableModelCriteria('bookstore', 'Book'); - $c->setModelAlias('b', true); - $c->join('b.Author a'); - $c->with('a'); - $expectedColumns = array( - 'b.ID', - 'b.TITLE', - 'b.ISBN', - 'b.PRICE', - 'b.PUBLISHER_ID', - 'b.AUTHOR_ID', - 'a.ID', - 'a.FIRST_NAME', - 'a.LAST_NAME', - 'a.EMAIL', - 'a.AGE' - ); - $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the main table with an alias if required'); - } - - public function testWithOneToManyAddsSelectColumns() - { - $c = new TestableModelCriteria('bookstore', 'Author'); - AuthorPeer::addSelectColumns($c); - $c->leftJoin('Author.Book'); - $c->with('Book'); - $expectedColumns = array( - AuthorPeer::ID, - AuthorPeer::FIRST_NAME, - AuthorPeer::LAST_NAME, - AuthorPeer::EMAIL, - AuthorPeer::AGE, - BookPeer::ID, - BookPeer::TITLE, - BookPeer::ISBN, - BookPeer::PRICE, - BookPeer::PUBLISHER_ID, - BookPeer::AUTHOR_ID, - ); - $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the related table even in a one-to-many relationship'); - } - - public function testJoinWith() - { - $c = new TestableModelCriteria('bookstore', 'Book'); - $c->joinWith('Book.Author'); - $expectedColumns = array( - BookPeer::ID, - BookPeer::TITLE, - BookPeer::ISBN, - BookPeer::PRICE, - BookPeer::PUBLISHER_ID, - BookPeer::AUTHOR_ID, - AuthorPeer::ID, - AuthorPeer::FIRST_NAME, - AuthorPeer::LAST_NAME, - AuthorPeer::EMAIL, - AuthorPeer::AGE - ); - $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWith() adds the join'); - $joins = $c->getJoins(); - $join = $joins['Author']; - $this->assertEquals(Criteria::INNER_JOIN, $join->getJoinType(), 'joinWith() adds an INNER JOIN by default'); - } - - public function testJoinWithType() - { - $c = new TestableModelCriteria('bookstore', 'Book'); - $c->joinWith('Book.Author', Criteria::LEFT_JOIN); - $joins = $c->getJoins(); - $join = $joins['Author']; - $this->assertEquals(Criteria::LEFT_JOIN, $join->getJoinType(), 'joinWith() accepts a join type as second parameter'); - } - - public function testJoinWithAlias() - { - $c = new TestableModelCriteria('bookstore', 'Book'); - $c->joinWith('Book.Author a'); - $expectedColumns = array( - BookPeer::ID, - BookPeer::TITLE, - BookPeer::ISBN, - BookPeer::PRICE, - BookPeer::PUBLISHER_ID, - BookPeer::AUTHOR_ID, - 'a.ID', - 'a.FIRST_NAME', - 'a.LAST_NAME', - 'a.EMAIL', - 'a.AGE' - ); - $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWith() adds the join with the alias'); - } - - public function testJoinWithSeveral() - { - $c = new TestableModelCriteria('bookstore', 'Review'); - $c->joinWith('Review.Book'); - $c->joinWith('Book.Author'); - $c->joinWith('Book.Publisher'); - $expectedColumns = array( - ReviewPeer::ID, - ReviewPeer::REVIEWED_BY, - ReviewPeer::REVIEW_DATE, - ReviewPeer::RECOMMENDED, - ReviewPeer::STATUS, - ReviewPeer::BOOK_ID, - BookPeer::ID, - BookPeer::TITLE, - BookPeer::ISBN, - BookPeer::PRICE, - BookPeer::PUBLISHER_ID, - BookPeer::AUTHOR_ID, - AuthorPeer::ID, - AuthorPeer::FIRST_NAME, - AuthorPeer::LAST_NAME, - AuthorPeer::EMAIL, - AuthorPeer::AGE, - PublisherPeer::ID, - PublisherPeer::NAME - ); - $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWith() adds the with'); - $joins = $c->getJoins(); - $expectedJoinKeys = array('Book', 'Author', 'Publisher'); - $this->assertEquals($expectedJoinKeys, array_keys($joins), 'joinWith() adds the join'); - } - - public function testJoinWithTwice() - { - $c = new TestableModelCriteria('bookstore', 'Book'); - $c->join('Book.Review'); - $c->joinWith('Book.Author'); - $c->joinWith('Book.Review'); - $expectedColumns = array( - BookPeer::ID, - BookPeer::TITLE, - BookPeer::ISBN, - BookPeer::PRICE, - BookPeer::PUBLISHER_ID, - BookPeer::AUTHOR_ID, - AuthorPeer::ID, - AuthorPeer::FIRST_NAME, - AuthorPeer::LAST_NAME, - AuthorPeer::EMAIL, - AuthorPeer::AGE, - ReviewPeer::ID, - ReviewPeer::REVIEWED_BY, - ReviewPeer::REVIEW_DATE, - ReviewPeer::RECOMMENDED, - ReviewPeer::STATUS, - ReviewPeer::BOOK_ID, - ); - $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWith() adds the with'); - $joins = $c->getJoins(); - $expectedJoinKeys = array('Review', 'Author'); - $this->assertEquals($expectedJoinKeys, array_keys($joins), 'joinWith() adds the join'); - } - - public static function conditionsForTestWithColumn() - { - return array( - array('Book.Title', 'BookTitle', 'book.TITLE AS BookTitle'), - array('Book.Title', null, 'book.TITLE AS BookTitle'), - array('UPPER(Book.Title)', null, 'UPPER(book.TITLE) AS UPPERBookTitle'), - array('CONCAT(Book.Title, Book.ISBN)', 'foo', 'CONCAT(book.TITLE, book.ISBN) AS foo'), - ); - } - - /** - * @dataProvider conditionsForTestWithColumn - */ - public function testWithColumn($clause, $alias, $selectTranslation) - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->withColumn($clause, $alias); - $sql = 'SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID, ' . $selectTranslation . ' FROM `book`'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'withColumn() adds a calculated column to the select clause'); - } - - public function testWithColumnAndSelectColumns() - { - $c = new ModelCriteria('bookstore', 'Book'); - $c->withColumn('UPPER(Book.Title)', 'foo'); - $sql = 'SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID, UPPER(book.TITLE) AS foo FROM `book`'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'withColumn() adds the object columns if the criteria has no select columns'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->addSelectColumn('book.ID'); - $c->withColumn('UPPER(Book.Title)', 'foo'); - $sql = 'SELECT book.ID, UPPER(book.TITLE) AS foo FROM `book`'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'withColumn() does not add the object columns if the criteria already has select columns'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->addSelectColumn('book.ID'); - $c->withColumn('UPPER(Book.Title)', 'foo'); - $c->addSelectColumn('book.TITLE'); - $sql = 'SELECT book.ID, book.TITLE, UPPER(book.TITLE) AS foo FROM `book`'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'withColumn() does adds as column after the select columns even though the withColumn() method was called first'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->addSelectColumn('book.ID'); - $c->withColumn('UPPER(Book.Title)', 'foo'); - $c->withColumn('UPPER(Book.ISBN)', 'isbn'); - $sql = 'SELECT book.ID, UPPER(book.TITLE) AS foo, UPPER(book.ISBN) AS isbn FROM `book`'; - $params = array(); - $this->assertCriteriaTranslation($c, $sql, $params, 'withColumn() called repeatedly adds several as colums'); - } - - public function testKeepQuery() - { - $c = BookQuery::create(); - $this->assertFalse($c->isKeepQuery(), 'keepQuery is disabled by default'); - $c->keepQuery(); - $this->assertTrue($c->isKeepQuery(), 'keepQuery() enables the keepQuery property'); - $c->keepQuery(false); - $this->assertFalse($c->isKeepQuery(), 'keepQuery(false) disables the keepQuery property'); - } - - public function testKeepQueryFind() - { - $c = BookQuery::create(); - $c->filterByTitle('foo'); - $c->find(); - $expected = array('book.ID', 'book.TITLE', 'book.ISBN', 'book.PRICE', 'book.PUBLISHER_ID', 'book.AUTHOR_ID'); - $this->assertEquals($expected, $c->getSelectColumns(), 'find() modifies the query by default'); - - $c = BookQuery::create(); - $c->filterByTitle('foo'); - $c->keepQuery(); - $c->find(); - $this->assertEquals(array(), $c->getSelectColumns(), 'keepQuery() forces find() to use a clone and keep the original query unmodified'); - } - - public function testKeepQueryFindOne() - { - $c = BookQuery::create(); - $c->filterByTitle('foo'); - $c->findOne(); - $this->assertEquals(1, $c->getLimit(), 'findOne() modifies the query by default'); - - $c = BookQuery::create(); - $c->filterByTitle('foo'); - $c->keepQuery(); - $c->findOne(); - $this->assertEquals(0, $c->getLimit(), 'keepQuery() forces findOne() to use a clone and keep the original query unmodified'); - } - - public function testKeepQueryFindPk() - { - $c = BookQuery::create(); - $c->findPk(1); - $expected = array('book.ID', 'book.TITLE', 'book.ISBN', 'book.PRICE', 'book.PUBLISHER_ID', 'book.AUTHOR_ID'); - $this->assertEquals($expected, $c->getSelectColumns(), 'findPk() modifies the query by default'); - - $c = BookQuery::create(); - $c->keepQuery(); - $c->findPk(1); - $this->assertEquals(array(), $c->getSelectColumns(), 'keepQuery() forces findPk() to use a clone and keep the original query unmodified'); - } - - public function testKeepQueryCount() - { - $c = BookQuery::create(); - $c->orderByTitle(); - $c->count(); - $this->assertEquals(array(), $c->getOrderByColumns(), 'count() modifies the query by default'); - - $c = BookQuery::create(); - $c->orderByTitle(); - $c->keepQuery(); - $c->count(); - $this->assertEquals(array('book.TITLE ASC'), $c->getOrderByColumns(), 'keepQuery() forces count() to use a clone and keep the original query unmodified'); - } - - public function testFind() - { - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'foo'); - $books = $c->find(); - $this->assertTrue($books instanceof PropelCollection, 'find() returns a collection by default'); - $this->assertEquals(0, count($books), 'find() returns an empty array when the query returns no result'); - - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->join('b.Author a'); - $c->where('a.FirstName = ?', 'Neal'); - $books = $c->find(); - $this->assertTrue($books instanceof PropelCollection, 'find() returns a collection by default'); - $this->assertEquals(1, count($books), 'find() returns as many rows as the results in the query'); - $book = $books->shift(); - $this->assertTrue($book instanceof Book, 'find() returns an array of Model objects by default'); - $this->assertEquals('Quicksilver', $book->getTitle(), 'find() returns the model objects matching the query'); - } - - public function testFindAddsSelectColumns() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->find($con); - $sql = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book`"; - $this->assertEquals($sql, $con->getLastExecutedQuery(), 'find() adds the select columns of the current model'); - } - - public function testFindTrueAliasAddsSelectColumns() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c = new ModelCriteria('bookstore', 'Book'); - $c->setModelAlias('b', true); - $books = $c->find($con); - $sql = "SELECT b.ID, b.TITLE, b.ISBN, b.PRICE, b.PUBLISHER_ID, b.AUTHOR_ID FROM `book` `b`"; - $this->assertEquals($sql, $con->getLastExecutedQuery(), 'find() uses the true model alias if available'); - } - - public function testFindOne() - { - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'foo'); - $book = $c->findOne(); - $this->assertNull($book, 'findOne() returns null when the query returns no result'); - - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->orderBy('b.Title'); - $book = $c->findOne(); - $this->assertTrue($book instanceof Book, 'findOne() returns a Model object by default'); - $this->assertEquals('Don Juan', $book->getTitle(), 'find() returns the model objects matching the query'); - } - - public function testFindOneOrCreateNotExists() - { - BookQuery::create()->deleteAll(); - $book = BookQuery::create('b') - ->where('b.Title = ?', 'foo') - ->filterByPrice(125) - ->findOneOrCreate(); - $this->assertTrue($book instanceof Book, 'findOneOrCreate() returns an instance of the model when the request has no result'); - $this->assertTrue($book->isNew(), 'findOneOrCreate() returns a new instance of the model when the request has no result'); - $this->assertEquals('foo', $book->getTitle(), 'findOneOrCreate() returns a populated objects based on the conditions'); - $this->assertEquals(125, $book->getPrice(), 'findOneOrCreate() returns a populated objects based on the conditions'); - } - - public function testFindOneOrCreateNotExistsFormatter() - { - BookQuery::create()->deleteAll(); - $book = BookQuery::create('b') - ->where('b.Title = ?', 'foo') - ->filterByPrice(125) - ->setFormatter(ModelCriteria::FORMAT_ARRAY) - ->findOneOrCreate(); - $this->assertTrue(is_array($book), 'findOneOrCreate() uses the query formatter even when the request has no result'); - $this->assertEquals('foo', $book['Title'], 'findOneOrCreate() returns a populated array based on the conditions'); - $this->assertEquals(125, $book['Price'], 'findOneOrCreate() returns a populated array based on the conditions'); - } - - public function testFindOneOrCreateExists() - { - BookQuery::create()->deleteAll(); - $book = new Book(); - $book->setTitle('foo'); - $book->setPrice(125); - $book->save(); - $book = BookQuery::create('b') - ->where('b.Title = ?', 'foo') - ->filterByPrice(125) - ->findOneOrCreate(); - $this->assertTrue($book instanceof Book, 'findOneOrCreate() returns an instance of the model when the request has one result'); - $this->assertFalse($book->isNew(), 'findOneOrCreate() returns an existing instance of the model when the request has one result'); - $this->assertEquals('foo', $book->getTitle(), 'findOneOrCreate() returns a populated objects based on the conditions'); - $this->assertEquals(125, $book->getPrice(), 'findOneOrCreate() returns a populated objects based on the conditions'); - } - - public function testFindPkSimpleKey() - { - BookstoreDataPopulator::depopulate(); - - $c = new ModelCriteria('bookstore', 'Book'); - $book = $c->findPk(765432); - $this->assertNull($book, 'findPk() returns null when the primary key is not found'); - - BookstoreDataPopulator::populate(); - - // retrieve the test data - $c = new ModelCriteria('bookstore', 'Book'); - $testBook = $c->findOne(); - - $c = new ModelCriteria('bookstore', 'Book'); - $book = $c->findPk($testBook->getId()); - $this->assertEquals($testBook, $book, 'findPk() returns a model object corresponding to the pk'); - } - - public function testFindPksSimpleKey() - { - BookstoreDataPopulator::depopulate(); - - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->findPks(array(765432, 434535)); - $this->assertEquals($books instanceof PropelCollection, 'findPks() returns a PropelCollection'); - $this->assertEquals(0, count($books), 'findPks() returns an empty collection when the primary keys are not found'); - - BookstoreDataPopulator::populate(); - - // retrieve the test data - $c = new ModelCriteria('bookstore', 'Book'); - $testBooks = $c->find(); - $testBook1 = $testBooks->pop(); - $testBook2 = $testBooks->pop(); - - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->findPks(array($testBook1->getId(), $testBook2->getId())); - $this->assertEquals(array($testBook2, $testBook1), $books->getData(), 'findPks() returns an array of model objects corresponding to the pks'); - } - - public function testFindPkCompositeKey() - { - BookstoreDataPopulator::depopulate(); - - $c = new ModelCriteria('bookstore', 'BookListRel'); - $bookListRel = $c->findPk(array(1, 2)); - $this->assertNull($bookListRel, 'findPk() returns null when the composite primary key is not found'); - - Propel::enableInstancePooling(); - BookstoreDataPopulator::populate(); - - // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->find(); - foreach ($books as $book) { - $book->save(); - } - - // retrieve the test data - $c = new ModelCriteria('bookstore', 'BookListRel'); - $bookListRelTest = $c->findOne(); - $pk = $bookListRelTest->getPrimaryKey(); - - $c = new ModelCriteria('bookstore', 'BookListRel'); - $bookListRel = $c->findPk($pk); - $this->assertEquals($bookListRelTest, $bookListRel, 'findPk() can find objects with composite primary keys'); - } - - /** - * @expectedException PropelException - */ - public function testFindPksCompositeKey() - { - $c = new ModelCriteria('bookstore', 'BookListRel'); - $bookListRel = $c->findPks(array(array(1, 2))); - - } - - public function testFindBy() - { - try { - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->findBy('Foo', 'Bar'); - $this->fail('findBy() throws an exception when called on an unknown column name'); - } catch (PropelException $e) { - $this->assertTrue(true, 'findBy() throws an exception when called on an unknown column name'); - } - - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->findBy('Title', 'Don Juan', $con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE='Don Juan'"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findBy() adds simple column conditions'); - $this->assertTrue($books instanceof PropelCollection, 'findBy() issues a find()'); - $this->assertEquals(1, count($books), 'findBy() adds simple column conditions'); - $book = $books->shift(); - $this->assertTrue($book instanceof Book, 'findBy() returns an array of Model objects by default'); - $this->assertEquals('Don Juan', $book->getTitle(), 'findBy() returns the model objects matching the query'); - } - - public function testFindByArray() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->findByArray(array('Title' => 'Don Juan', 'ISBN' => 12345), $con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE='Don Juan' AND book.ISBN=12345"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findByArray() adds multiple column conditions'); - } - - public function testFindOneBy() - { - try { - $c = new ModelCriteria('bookstore', 'Book'); - $book = $c->findOneBy('Foo', 'Bar'); - $this->fail('findOneBy() throws an exception when called on an unknown column name'); - } catch (PropelException $e) { - $this->assertTrue(true, 'findOneBy() throws an exception when called on an unknown column name'); - } - - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c = new ModelCriteria('bookstore', 'Book'); - $book = $c->findOneBy('Title', 'Don Juan', $con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE='Don Juan' LIMIT 1"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findOneBy() adds simple column conditions'); - $this->assertTrue($book instanceof Book, 'findOneBy() returns a Model object by default'); - $this->assertEquals('Don Juan', $book->getTitle(), 'findOneBy() returns the model object matching the query'); - } - - public function testFindOneByArray() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c = new ModelCriteria('bookstore', 'Book'); - $book = $c->findOneByArray(array('Title' => 'Don Juan', 'ISBN' => 12345), $con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE='Don Juan' AND book.ISBN=12345 LIMIT 1"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findOneBy() adds multiple column conditions'); - } - - public function testCount() - { - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'foo'); - $nbBooks = $c->count(); - $this->assertTrue(is_int($nbBooks), 'count() returns an integer'); - $this->assertEquals(0, $nbBooks, 'count() returns 0 when the query returns no result'); - - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->join('b.Author a'); - $c->where('a.FirstName = ?', 'Neal'); - $nbBooks = $c->count(); - $this->assertTrue(is_int($nbBooks), 'count() returns an integer'); - $this->assertEquals(1, $nbBooks, 'count() returns the number of results in the query'); - } - - public function testPaginate() - { - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->join('b.Author a'); - $c->where('a.FirstName = ?', 'Neal'); - $books = $c->paginate(1, 5); - $this->assertTrue($books instanceof PropelModelPager, 'paginate() returns a PropelModelPager'); - $this->assertEquals(1, count($books), 'paginate() returns a countable pager with the correct count'); - foreach ($books as $book) { - $this->assertEquals('Neal', $book->getAuthor()->getFirstName(), 'paginate() returns an iterable pager'); - } - } - - public function testDelete() - { - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - - $c = new ModelCriteria('bookstore', 'Book'); - try { - $nbBooks = $c->delete(); - $this->fail('delete() throws an exception when called on an empty Criteria'); - } catch (PropelException $e) { - $this->assertTrue(true, 'delete() throws an exception when called on an empty Criteria'); - } - - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'foo'); - $nbBooks = $c->delete(); - $this->assertTrue(is_int($nbBooks), 'delete() returns an integer'); - $this->assertEquals(0, $nbBooks, 'delete() returns 0 when the query deleted no rows'); - - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'Don Juan'); - $nbBooks = $c->delete(); - $this->assertTrue(is_int($nbBooks), 'delete() returns an integer'); - $this->assertEquals(1, $nbBooks, 'delete() returns the number of the deleted rows'); - - $c = new ModelCriteria('bookstore', 'Book'); - $nbBooks = $c->count(); - $this->assertEquals(3, $nbBooks, 'delete() deletes rows in the database'); - } - - public function testDeleteUsingTableAlias() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->setModelAlias('b', false); - $c->where('b.Title = ?', 'foo'); - $c->delete(); - $expectedSQL = "DELETE FROM `book` WHERE book.TITLE = 'foo'"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'delete() also works on tables with table alias'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->setModelAlias('b', true); - $c->where('b.Title = ?', 'foo'); - $c->delete(); - $expectedSQL = "DELETE b FROM `book` AS b WHERE b.TITLE = 'foo'"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'delete() also works on tables with true table alias'); - } - - public function testDeleteAll() - { - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - - $c = new ModelCriteria('bookstore', 'Book'); - $nbBooks = $c->deleteAll(); - $this->assertTrue(is_int($nbBooks), 'deleteAll() returns an integer'); - $this->assertEquals(4, $nbBooks, 'deleteAll() returns the number of deleted rows'); - - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'Don Juan'); - $nbBooks = $c->deleteAll(); - $this->assertEquals(4, $nbBooks, 'deleteAll() ignores conditions on the criteria'); - } - - public function testUpdate() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - BookstoreDataPopulator::depopulate($con); - BookstoreDataPopulator::populate($con); - - $count = $con->getQueryCount(); - $c = new ModelCriteria('bookstore', 'Book'); - $nbBooks = $c->update(array('Title' => 'foo'), $con); - $this->assertEquals(4, $nbBooks, 'update() returns the number of updated rows'); - $this->assertEquals($count + 1, $con->getQueryCount(), 'update() updates all the objects in one query by default'); - - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'foo'); - $nbBooks = $c->count(); - $this->assertEquals(4, $nbBooks, 'update() updates all records by default'); - - BookstoreDataPopulator::depopulate($con); - BookstoreDataPopulator::populate($con); - - $count = $con->getQueryCount(); - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'Don Juan'); - $nbBooks = $c->update(array('ISBN' => '3456'), $con); - $this->assertEquals(1, $nbBooks, 'update() updates only the records matching the criteria'); - $this->assertEquals($count + 1, $con->getQueryCount(), 'update() updates all the objects in one query by default'); - - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'Don Juan'); - $book = $c->findOne(); - $this->assertEquals('3456', $book->getISBN(), 'update() updates only the records matching the criteria'); - } - - public function testUpdateUsingTableAlias() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->setModelAlias('b', false); - $c->where('b.Title = ?', 'foo'); - $c->update(array('Title' => 'foo2'), $con); - $expectedSQL = "UPDATE `book` SET `TITLE`='foo2' WHERE book.TITLE = 'foo'"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'update() also works on tables with table alias'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->setModelAlias('b', true); - $c->where('b.Title = ?', 'foo'); - $c->update(array('Title' => 'foo2'), $con); - $expectedSQL = "UPDATE `book` `b` SET `TITLE`='foo2' WHERE b.TITLE = 'foo'"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'update() also works on tables with true table alias'); - } - - public function testUpdateOneByOne() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - BookstoreDataPopulator::depopulate($con); - BookstoreDataPopulator::populate($con); - - // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->find(); - foreach ($books as $book) { - $book->save(); - } - - $count = $con->getQueryCount(); - $c = new ModelCriteria('bookstore', 'Book'); - $nbBooks = $c->update(array('Title' => 'foo'), $con, true); - $this->assertEquals(4, $nbBooks, 'update() returns the number of updated rows'); - $this->assertEquals($count + 1 + 4, $con->getQueryCount(), 'update() updates the objects one by one when called with true as last parameter'); - - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'foo'); - $nbBooks = $c->count(); - $this->assertEquals(4, $nbBooks, 'update() updates all records by default'); - - BookstoreDataPopulator::depopulate($con); - BookstoreDataPopulator::populate($con); - - // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->find(); - foreach ($books as $book) { - $book->save(); - } - - $count = $con->getQueryCount(); - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'Don Juan'); - $nbBooks = $c->update(array('ISBN' => '3456'), $con, true); - $this->assertEquals(1, $nbBooks, 'update() updates only the records matching the criteria'); - $this->assertEquals($count + 1 + 1, $con->getQueryCount(), 'update() updates the objects one by one when called with true as last parameter'); - - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->where('b.Title = ?', 'Don Juan'); - $book = $c->findOne(); - $this->assertEquals('3456', $book->getISBN(), 'update() updates only the records matching the criteria'); - } - - public static function conditionsForTestGetRelationName() - { - return array( - array('Author', 'Author'), - array('Book.Author', 'Author'), - array('Author.Book', 'Book'), - array('Book.Author a', 'a'), - ); - } - - /** - * @dataProvider conditionsForTestGetRelationName - */ - public function testGetRelationName($relation, $relationName) - { - $this->assertEquals($relationName, ModelCriteria::getrelationName($relation)); - } - - public function testMagicJoin() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->leftJoin('b.Author a'); - $c->where('a.FirstName = ?', 'Leo'); - $books = $c->findOne($con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` LEFT JOIN author a ON (book.AUTHOR_ID=a.ID) WHERE a.FIRST_NAME = 'Leo' LIMIT 1"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'leftJoin($x) is turned into join($x, Criteria::LEFT_JOIN)'); - - $books = BookQuery::create() - ->leftJoinAuthor('a') - ->where('a.FirstName = ?', 'Leo') - ->findOne($con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` LEFT JOIN author a ON (book.AUTHOR_ID=a.ID) WHERE a.FIRST_NAME = 'Leo' LIMIT 1"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'leftJoinX() is turned into join($x, Criteria::LEFT_JOIN)'); - - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->innerJoin('b.Author a'); - $c->where('a.FirstName = ?', 'Leo'); - $books = $c->findOne($con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` INNER JOIN author a ON (book.AUTHOR_ID=a.ID) WHERE a.FIRST_NAME = 'Leo' LIMIT 1"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'innerJoin($x) is turned into join($x, Criteria::INNER_JOIN)'); - - $books = BookQuery::create() - ->innerJoinAuthor('a') - ->where('a.FirstName = ?', 'Leo') - ->findOne($con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` INNER JOIN author a ON (book.AUTHOR_ID=a.ID) WHERE a.FIRST_NAME = 'Leo' LIMIT 1"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'innerJoinX() is turned into join($x, Criteria::INNER_JOIN)'); - - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->rightJoin('b.Author a'); - $c->where('a.FirstName = ?', 'Leo'); - $books = $c->findOne($con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` RIGHT JOIN author a ON (book.AUTHOR_ID=a.ID) WHERE a.FIRST_NAME = 'Leo' LIMIT 1"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'rightJoin($x) is turned into join($x, Criteria::RIGHT_JOIN)'); - - $books = BookQuery::create() - ->rightJoinAuthor('a') - ->where('a.FirstName = ?', 'Leo') - ->findOne($con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` RIGHT JOIN author a ON (book.AUTHOR_ID=a.ID) WHERE a.FIRST_NAME = 'Leo' LIMIT 1"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'rightJoinX() is turned into join($x, Criteria::RIGHT_JOIN)'); - - $books = BookQuery::create() - ->leftJoinAuthor() - ->where('Author.FirstName = ?', 'Leo') - ->findOne($con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` LEFT JOIN author ON (book.AUTHOR_ID=author.ID) WHERE author.FIRST_NAME = 'Leo' LIMIT 1"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'leftJoinX() is turned into join($x, Criteria::LEFT_JOIN)'); - } - - public function testMagicJoinWith() - { - $c = new TestableModelCriteria('bookstore', 'Book'); - $c->leftJoinWith('Book.Author a'); - $expectedColumns = array( - BookPeer::ID, - BookPeer::TITLE, - BookPeer::ISBN, - BookPeer::PRICE, - BookPeer::PUBLISHER_ID, - BookPeer::AUTHOR_ID, - 'a.ID', - 'a.FIRST_NAME', - 'a.LAST_NAME', - 'a.EMAIL', - 'a.AGE' - ); - $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'leftJoinWith() adds the join with the alias'); - $joins = $c->getJoins(); - $join = $joins['a']; - $this->assertEquals(Criteria::LEFT_JOIN, $join->getJoinType(), 'leftJoinWith() adds a LEFT JOIN'); - } - - public function testMagicJoinWithRelation() - { - $c = new TestableModelCriteria('bookstore', 'Book'); - $c->joinWithAuthor(); - $expectedColumns = array( - BookPeer::ID, - BookPeer::TITLE, - BookPeer::ISBN, - BookPeer::PRICE, - BookPeer::PUBLISHER_ID, - BookPeer::AUTHOR_ID, - AuthorPeer::ID, - AuthorPeer::FIRST_NAME, - AuthorPeer::LAST_NAME, - AuthorPeer::EMAIL, - AuthorPeer::AGE - ); - $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWithXXX() adds the join with the XXX relation'); - $joins = $c->getJoins(); - $join = $joins['Author']; - $this->assertEquals(Criteria::INNER_JOIN, $join->getJoinType(), 'joinWithXXX() adds an INNER JOIN'); - } - - public function testMagicJoinWithTypeAndRelation() - { - $c = new TestableModelCriteria('bookstore', 'Book'); - $c->leftJoinWithAuthor(); - $expectedColumns = array( - BookPeer::ID, - BookPeer::TITLE, - BookPeer::ISBN, - BookPeer::PRICE, - BookPeer::PUBLISHER_ID, - BookPeer::AUTHOR_ID, - AuthorPeer::ID, - AuthorPeer::FIRST_NAME, - AuthorPeer::LAST_NAME, - AuthorPeer::EMAIL, - AuthorPeer::AGE - ); - $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'leftJoinWithXXX() adds the join with the XXX relation'); - $joins = $c->getJoins(); - $join = $joins['Author']; - $this->assertEquals(Criteria::LEFT_JOIN, $join->getJoinType(), 'leftJoinWithXXX() adds an INNER JOIN'); - } - - public function testMagicFind() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->findByTitle('Don Juan'); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE='Don Juan'"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findByXXX($value) is turned into findBy(XXX, $value)'); - - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->findByTitleAndISBN('Don Juan', 1234); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE='Don Juan' AND book.ISBN=1234"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findByXXXAndYYY($value) is turned into findBy(array(XXX,YYY), $value)'); - - $c = new ModelCriteria('bookstore', 'Book'); - $book = $c->findOneByTitle('Don Juan'); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE='Don Juan' LIMIT 1"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findOneByXXX($value) is turned into findOneBy(XXX, $value)'); - - $c = new ModelCriteria('bookstore', 'Book'); - $book = $c->findOneByTitleAndISBN('Don Juan', 1234); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE='Don Juan' AND book.ISBN=1234 LIMIT 1"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findOneByXXX($value) is turned into findOneBy(XXX, $value)'); - } - - public function testMagicFilterBy() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->filterByTitle('Don Juan')->find($con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE='Don Juan'"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'filterByXXX($value) is turned into filterBy(XXX, $value)'); - } - - public function testMagicOrderBy() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->orderByTitle()->find($con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` ORDER BY book.TITLE ASC"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'orderByXXX() is turned into orderBy(XXX)'); - - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->orderByTitle(Criteria::DESC)->find($con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` ORDER BY book.TITLE DESC"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'orderByXXX($direction) is turned into orderBy(XXX, $direction)'); - } - - public function testMagicGroupBy() - { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - - $c = new ModelCriteria('bookstore', 'Book'); - $books = $c->groupByTitle()->find($con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` GROUP BY book.TITLE"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'groupByXXX() is turned into groupBy(XXX)'); - } - - public function testUseQuery() - { - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->thisIsMe = true; - $c->where('b.Title = ?', 'foo'); - $c->setOffset(10); - $c->leftJoin('b.Author'); - - $c2 = $c->useQuery('Author'); - $this->assertTrue($c2 instanceof AuthorQuery, 'useQuery() returns a secondary Criteria'); - $this->assertEquals($c, $c2->getPrimaryCriteria(), 'useQuery() sets the primary Criteria os the secondary Criteria'); - $c2->where('Author.FirstName = ?', 'john'); - $c2->limit(5); - - $c = $c2->endUse(); - $this->assertTrue($c->thisIsMe, 'endUse() returns the Primary Criteria'); - $this->assertEquals('Book', $c->getModelName(), 'endUse() returns the Primary Criteria'); - - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c->find($con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` LEFT JOIN author ON (book.AUTHOR_ID=author.ID) WHERE book.TITLE = 'foo' AND author.FIRST_NAME = 'john' LIMIT 10, 5"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and endUse() allow to merge a secondary criteria'); - } - - public function testUseQueryAlias() - { - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->thisIsMe = true; - $c->where('b.Title = ?', 'foo'); - $c->setOffset(10); - $c->leftJoin('b.Author a'); - - $c2 = $c->useQuery('a'); - $this->assertTrue($c2 instanceof AuthorQuery, 'useQuery() returns a secondary Criteria'); - $this->assertEquals($c, $c2->getPrimaryCriteria(), 'useQuery() sets the primary Criteria os the secondary Criteria'); - $this->assertEquals(array('a' => 'author'), $c2->getAliases(), 'useQuery() sets the secondary Criteria alias correctly'); - $c2->where('a.FirstName = ?', 'john'); - $c2->limit(5); - - $c = $c2->endUse(); - $this->assertTrue($c->thisIsMe, 'endUse() returns the Primary Criteria'); - $this->assertEquals('Book', $c->getModelName(), 'endUse() returns the Primary Criteria'); - - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c->find($con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` LEFT JOIN author a ON (book.AUTHOR_ID=a.ID) WHERE book.TITLE = 'foo' AND a.FIRST_NAME = 'john' LIMIT 10, 5"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and endUse() allow to merge a secondary criteria'); - } - - public function testUseQueryCustomClass() - { - $c = new ModelCriteria('bookstore', 'Book', 'b'); - $c->thisIsMe = true; - $c->where('b.Title = ?', 'foo'); - $c->setLimit(10); - $c->leftJoin('b.Author a'); - - $c2 = $c->useQuery('a', 'ModelCriteriaForUseQuery'); - $this->assertTrue($c2 instanceof ModelCriteriaForUseQuery, 'useQuery() returns a secondary Criteria with the custom class'); - $c2->withNoName(); - $c = $c2->endUse(); - - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c->find($con); - $expectedSQL = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` LEFT JOIN author a ON (book.AUTHOR_ID=a.ID) WHERE book.TITLE = 'foo' AND a.FIRST_NAME IS NOT NULL AND a.LAST_NAME IS NOT NULL LIMIT 10"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and endUse() allow to merge a custom secondary criteria'); - } - - public function testUseQueryJoinWithFind() - { - $c = new ModelCriteria('bookstore', 'Review'); - $c->joinWith('Book'); - - $c2 = $c->useQuery('Book'); - - $joins = $c->getJoins(); - $this->assertEquals($c->getPreviousJoin(), null, 'The default value for previousJoin remains null'); - $this->assertEquals($c2->getPreviousJoin(), $joins['Book'], 'useQuery() sets the previousJoin'); - - // join Book with Author, which is possible since previousJoin is set, which makes resolving of relations possible during hydration - $c2->joinWith('Author'); - - $c = $c2->endUse(); - - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c->find($con); - $expectedSQL = "SELECT review.ID, review.REVIEWED_BY, review.REVIEW_DATE, review.RECOMMENDED, review.STATUS, review.BOOK_ID, book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID, author.ID, author.FIRST_NAME, author.LAST_NAME, author.EMAIL, author.AGE FROM `review` INNER JOIN book ON (review.BOOK_ID=book.ID) INNER JOIN author ON (book.AUTHOR_ID=author.ID)"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and joinWith() can be used together and form a correct query'); - } - - public function testUseQueryCustomRelationPhpName() - { - $c = new ModelCriteria('bookstore', 'BookstoreContest'); - $c->leftJoin('BookstoreContest.Work'); - $c2 = $c->useQuery('Work'); - $this->assertTrue($c2 instanceof BookQuery, 'useQuery() returns a secondary Criteria'); - $this->assertEquals($c, $c2->getPrimaryCriteria(), 'useQuery() sets the primary Criteria os the secondary Criteria'); - //$this->assertEquals(array('a' => 'author'), $c2->getAliases(), 'useQuery() sets the secondary Criteria alias correctly'); - $c2->where('Work.Title = ?', 'War And Peace'); - - $c = $c2->endUse(); - $this->assertEquals('BookstoreContest', $c->getModelName(), 'endUse() returns the Primary Criteria'); - - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c->find($con); - $expectedSQL = "SELECT bookstore_contest.BOOKSTORE_ID, bookstore_contest.CONTEST_ID, bookstore_contest.PRIZE_BOOK_ID FROM `bookstore_contest` LEFT JOIN book ON (bookstore_contest.PRIZE_BOOK_ID=book.ID) WHERE book.TITLE = 'War And Peace'"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and endUse() allow to merge a secondary criteria'); - } - - public function testUseQueryCustomRelationPhpNameAndAlias() - { - $c = new ModelCriteria('bookstore', 'BookstoreContest'); - $c->leftJoin('BookstoreContest.Work w'); - $c2 = $c->useQuery('w'); - $this->assertTrue($c2 instanceof BookQuery, 'useQuery() returns a secondary Criteria'); - $this->assertEquals($c, $c2->getPrimaryCriteria(), 'useQuery() sets the primary Criteria os the secondary Criteria'); - //$this->assertEquals(array('a' => 'author'), $c2->getAliases(), 'useQuery() sets the secondary Criteria alias correctly'); - $c2->where('w.Title = ?', 'War And Peace'); - - $c = $c2->endUse(); - $this->assertEquals('BookstoreContest', $c->getModelName(), 'endUse() returns the Primary Criteria'); - - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - $c->find($con); - $expectedSQL = "SELECT bookstore_contest.BOOKSTORE_ID, bookstore_contest.CONTEST_ID, bookstore_contest.PRIZE_BOOK_ID FROM `bookstore_contest` LEFT JOIN book w ON (bookstore_contest.PRIZE_BOOK_ID=w.ID) WHERE w.TITLE = 'War And Peace'"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and endUse() allow to merge a secondary criteria'); - } - - public function testMergeWithJoins() - { - $c1 = new ModelCriteria('bookstore', 'Book', 'b'); - $c1->leftJoin('b.Author a'); - $c2 = new ModelCriteria('bookstore', 'Author'); - $c1->mergeWith($c2); - $joins = $c1->getJoins(); - $this->assertEquals(1, count($joins), 'mergeWith() does not remove an existing join'); - $this->assertEquals('LEFT JOIN : book.AUTHOR_ID=a.ID(ignoreCase not considered)', $joins['a']->toString(), 'mergeWith() does not remove an existing join'); - $c1 = new ModelCriteria('bookstore', 'Book', 'b'); - $c2 = new ModelCriteria('bookstore', 'Book', 'b'); - $c2->leftJoin('b.Author a'); - $c1->mergeWith($c2); - $joins = $c1->getJoins(); - $this->assertEquals(1, count($joins), 'mergeWith() merge joins to an empty join'); - $this->assertEquals('LEFT JOIN : book.AUTHOR_ID=a.ID(ignoreCase not considered)', $joins['a']->toString(), 'mergeWith() merge joins to an empty join'); - - $c1 = new ModelCriteria('bookstore', 'Book', 'b'); - $c1->leftJoin('b.Author a'); - $c2 = new ModelCriteria('bookstore', 'Book', 'b'); - $c2->innerJoin('b.Publisher p'); - $c1->mergeWith($c2); - $joins = $c1->getJoins(); - $this->assertEquals(2, count($joins), 'mergeWith() merge joins to an existing join'); - $this->assertEquals('LEFT JOIN : book.AUTHOR_ID=a.ID(ignoreCase not considered)', $joins['a']->toString(), 'mergeWith() merge joins to an empty join'); - $this->assertEquals('INNER JOIN : book.PUBLISHER_ID=p.ID(ignoreCase not considered)', $joins['p']->toString(), 'mergeWith() merge joins to an empty join'); - } - - public function testMergeWithWiths() - { - $c1 = new ModelCriteria('bookstore', 'Book', 'b'); - $c1->leftJoinWith('b.Author a'); - $c2 = new ModelCriteria('bookstore', 'Author'); - $c1->mergeWith($c2); - $with = $c1->getWith(); - $this->assertEquals(1, count($with), 'mergeWith() does not remove an existing join'); - $this->assertEquals('LEFT JOIN : book.AUTHOR_ID=a.ID(ignoreCase not considered) tableMap: AuthorTableMap relationMap: Author previousJoin: null relationAlias: a', $with['a']->__toString(), 'mergeWith() does not remove an existing join'); - - $c1 = new ModelCriteria('bookstore', 'Book', 'b'); - $c2 = new ModelCriteria('bookstore', 'Book', 'b'); - $c2->leftJoinWith('b.Author a'); - $c1->mergeWith($c2); - $with = $c1->getWith(); - $this->assertEquals(1, count($with), 'mergeWith() merge joins to an empty join'); - $this->assertEquals('LEFT JOIN : book.AUTHOR_ID=a.ID(ignoreCase not considered) tableMap: AuthorTableMap relationMap: Author previousJoin: null relationAlias: a', $with['a']->__toString(), 'mergeWith() merge joins to an empty join'); - - $c1 = new ModelCriteria('bookstore', 'Book', 'b'); - $c1->leftJoinWith('b.Author a'); - $c2 = new ModelCriteria('bookstore', 'Book', 'b'); - $c2->innerJoinWith('b.Publisher p'); - $c1->mergeWith($c2); - $with = $c1->getWith(); - $this->assertEquals(2, count($with), 'mergeWith() merge joins to an existing join'); - $this->assertEquals('LEFT JOIN : book.AUTHOR_ID=a.ID(ignoreCase not considered) tableMap: AuthorTableMap relationMap: Author previousJoin: null relationAlias: a', $with['a']->__toString(), 'mergeWith() merge joins to an empty join'); - $this->assertEquals('INNER JOIN : book.PUBLISHER_ID=p.ID(ignoreCase not considered) tableMap: PublisherTableMap relationMap: Publisher previousJoin: null relationAlias: p', $with['p']->__toString(), 'mergeWith() merge joins to an empty join'); - - } - - public function testGetAliasedColName() - { - $c = new ModelCriteria('bookstore', 'Book'); - $this->assertEquals(BookPeer::TITLE, $c->getAliasedColName(BookPeer::TITLE), 'getAliasedColName() returns the input when the table has no alias'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->setModelAlias('foo'); - $this->assertEquals(BookPeer::TITLE, $c->getAliasedColName(BookPeer::TITLE), 'getAliasedColName() returns the input when the table has a query alias'); - - $c = new ModelCriteria('bookstore', 'Book'); - $c->setModelAlias('foo', true); - $this->assertEquals('foo.TITLE', $c->getAliasedColName(BookPeer::TITLE), 'getAliasedColName() returns the column name with table alias when the table has a true alias'); - } - - public function testAddUsingAliasNoAlias() - { - $c1 = new ModelCriteria('bookstore', 'Book'); - $c1->addUsingAlias(BookPeer::TITLE, 'foo'); - $c2 = new ModelCriteria('bookstore', 'Book'); - $c2->add(BookPeer::TITLE, 'foo'); - $this->assertEquals($c2, $c1, 'addUsingalias() translates to add() when the table has no alias'); - } - - public function testAddUsingAliasQueryAlias() - { - $c1 = new ModelCriteria('bookstore', 'Book', 'b'); - $c1->addUsingAlias(BookPeer::TITLE, 'foo'); - $c2 = new ModelCriteria('bookstore', 'Book', 'b'); - $c2->add(BookPeer::TITLE, 'foo'); - $this->assertEquals($c2, $c1, 'addUsingalias() translates the colname using the table alias before calling add() when the table has a true alias'); - } - - public function testAddUsingAliasTrueAlias() - { - $c1 = new ModelCriteria('bookstore', 'Book'); - $c1->setModelAlias('b', true); - $c1->addUsingAlias(BookPeer::TITLE, 'foo'); - $c2 = new ModelCriteria('bookstore', 'Book'); - $c2->setModelAlias('b', true); - $c2->add('b.TITLE', 'foo'); - $this->assertEquals($c2, $c1, 'addUsingalias() translates to add() when the table has a true alias'); - } - - public function testAddUsingAliasTwice() - { - $c1 = new ModelCriteria('bookstore', 'Book'); - $c1->addUsingAlias(BookPeer::TITLE, 'foo'); - $c1->addUsingAlias(BookPeer::TITLE, 'bar'); - $c2 = new ModelCriteria('bookstore', 'Book'); - $c2->add(BookPeer::TITLE, 'foo'); - $c2->addAnd(BookPeer::TITLE, 'bar'); - $this->assertEquals($c2, $c1, 'addUsingalias() translates to addAnd() when the table already has a condition on the column'); - } - - public function testAddUsingAliasTrueAliasTwice() - { - $c1 = new ModelCriteria('bookstore', 'Book'); - $c1->setModelAlias('b', true); - $c1->addUsingAlias(BookPeer::TITLE, 'foo'); - $c1->addUsingAlias(BookPeer::TITLE, 'bar'); - $c2 = new ModelCriteria('bookstore', 'Book'); - $c2->setModelAlias('b', true); - $c2->add('b.TITLE', 'foo'); - $c2->addAnd('b.TITLE', 'bar'); - $this->assertEquals($c2, $c1, 'addUsingalias() translates to addAnd() when the table already has a condition on the column'); - } - - public function testClone() - { - $bookQuery1 = BookQuery::create() - ->filterByPrice(1); - $bookQuery2 = clone $bookQuery1; - $bookQuery2 - ->filterByPrice(2); - $params = array(); - $sql = BasePeer::createSelectSql($bookQuery1, $params); - $this->assertEquals('SELECT FROM `book` WHERE book.PRICE=:p1', $sql, 'conditions applied on a cloned query don\'t get applied on the original query'); - } + protected function assertCriteriaTranslation(Criteria $criteria, $expectedSql, $expectedParams, $message = '') + { + $params = array(); + $result = BasePeer::createSelectSql($criteria, $params); + + $this->assertEquals($expectedSql, $result, $message); + $this->assertEquals($expectedParams, $params, $message); + } + + public function testGetModelName() + { + $c = new ModelCriteria('bookstore', 'Book'); + $this->assertEquals('Book', $c->getModelName(), 'getModelName() returns the name of the class associated to the model class'); + } + + public function testGetModelPeerName() + { + $c = new ModelCriteria('bookstore', 'Book'); + $this->assertEquals('BookPeer', $c->getModelPeerName(), 'getModelPeerName() returns the name of the Peer class associated to the model class'); + } + + public function testFormatter() + { + $c = new ModelCriteria('bookstore', 'Book'); + $this->assertTrue($c->getFormatter() instanceof PropelFormatter, 'getFormatter() returns a PropelFormatter instance'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->setFormatter(ModelCriteria::FORMAT_STATEMENT); + $this->assertTrue($c->getFormatter() instanceof PropelStatementFormatter, 'setFormatter() accepts the name of a PropelFormatter class'); + + try { + $c->setFormatter('Book'); + $this->fail('setFormatter() throws an exception when passed the name of a class not extending PropelFormatter'); + } catch (PropelException $e) { + $this->assertTrue(true, 'setFormatter() throws an exception when passed the name of a class not extending PropelFormatter'); + } + $c = new ModelCriteria('bookstore', 'Book'); + $formatter = new PropelStatementFormatter(); + $c->setFormatter($formatter); + $this->assertTrue($c->getFormatter() instanceof PropelStatementFormatter, 'setFormatter() accepts a PropelFormatter instance'); + + try { + $formatter = new Book(); + $c->setFormatter($formatter); + $this->fail('setFormatter() throws an exception when passed an object not extending PropelFormatter'); + } catch (PropelException $e) { + $this->assertTrue(true, 'setFormatter() throws an exception when passedan object not extending PropelFormatter'); + } + + } + + public static function conditionsForTestReplaceNames() + { + return array( + array('Book.Title = ?', 'Title', 'book.title = ?'), // basic case + array('Book.Title=?', 'Title', 'book.title=?'), // without spaces + array('Book.Id<= ?', 'Id', 'book.id<= ?'), // with non-equal comparator + array('Book.AuthorId LIKE ?', 'AuthorId', 'book.author_id LIKE ?'), // with SQL keyword separator + array('(Book.AuthorId) LIKE ?', 'AuthorId', '(book.author_id) LIKE ?'), // with parenthesis + array('(Book.Id*1.5)=1', 'Id', '(book.id*1.5)=1'), // ignore numbers + // dealing with quotes + array("Book.Id + ' ' + Book.AuthorId", null, "book.id + ' ' + book.author_id"), + array("'Book.Id' + Book.AuthorId", null, "'Book.Id' + book.author_id"), + array("Book.Id + 'Book.AuthorId'", null, "book.id + 'Book.AuthorId'"), + array('1=1', null, '1=1'), // with no name + array('', null, '') // with empty string + ); + } + + /** + * @dataProvider conditionsForTestReplaceNames + */ + public function testReplaceNames($origClause, $columnPhpName = false, $modifiedClause) + { + $c = new TestableModelCriteria('bookstore', 'Book'); + $this->doTestReplaceNames($c, BookPeer::getTableMap(), $origClause, $columnPhpName = false, $modifiedClause); + } + + public function doTestReplaceNames($c, $tableMap, $origClause, $columnPhpName = false, $modifiedClause) + { + $c->replaceNames($origClause); + $columns = $c->replacedColumns; + if ($columnPhpName) { + $this->assertEquals(array($tableMap->getColumnByPhpName($columnPhpName)), $columns); + } + $this->assertEquals($modifiedClause, $origClause); + } + + public static function conditionsForTestReplaceMultipleNames() + { + return array( + array('(Book.Id+Book.Id)=1', array('Id', 'Id'), '(book.id+book.id)=1'), // match multiple names + array('CONCAT(Book.Title,"Book.Id")= ?', array('Title', 'Id'), 'CONCAT(book.title,"Book.Id")= ?'), // ignore names in strings + array('CONCAT(Book.Title," Book.Id ")= ?', array('Title', 'Id'), 'CONCAT(book.title," Book.Id ")= ?'), // ignore names in strings + array('MATCH (Book.Title,Book.isbn) AGAINST (?)', array('Title', 'ISBN'), 'MATCH (book.title,book.isbn) AGAINST (?)'), + ); + } + + /** + * @dataProvider conditionsForTestReplaceMultipleNames + */ + public function testReplaceMultipleNames($origClause, $expectedColumns, $modifiedClause) + { + $c = new TestableModelCriteria('bookstore', 'Book'); + $c->replaceNames($origClause); + $foundColumns = $c->replacedColumns; + foreach ($foundColumns as $column) { + $expectedColumn = BookPeer::getTableMap()->getColumnByPhpName(array_shift($expectedColumns)); + $this->assertEquals($expectedColumn, $column); + } + $this->assertEquals($modifiedClause, $origClause); + } + + public function testTableAlias() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->setModelAlias('b'); + $c->where('b.Title = ?', 'foo'); + + $sql = "SELECT FROM `book` WHERE book.title = :p1"; + $params = array( + array('table' => 'book', 'column' => 'title', 'value' => 'foo'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'setModelAlias() allows the definition of the alias after construction'); + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'foo'); + + $sql = "SELECT FROM `book` WHERE book.title = :p1"; + $params = array( + array('table' => 'book', 'column' => 'title', 'value' => 'foo'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'A ModelCriteria accepts a model name with an alias'); + } + + public function testTrueTableAlias() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->setModelAlias('b', true); + $c->where('b.Title = ?', 'foo'); + $c->join('b.Author a'); + $c->where('a.FirstName = ?', 'john'); + + $sql = "SELECT FROM `book` `b` INNER JOIN `author` `a` ON (b.author_id=a.id) WHERE b.title = :p1 AND a.first_name = :p2"; + $params = array( + array('table' => 'book', 'column' => 'title', 'value' => 'foo'), + array('table' => 'author', 'column' => 'first_name', 'value' => 'john'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'setModelAlias() allows the definition of a true SQL alias after construction'); + } + + public function testCondition() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->condition('cond1', 'Book.Title <> ?', 'foo'); + $c->condition('cond2', 'Book.Title like ?', '%bar%'); + $c->combine(array('cond1', 'cond2'), 'or'); + + $sql = "SELECT FROM `book` WHERE (book.title <> :p1 OR book.title like :p2)"; + $params = array( + array('table' => 'book', 'column' => 'title', 'value' => 'foo'), + array('table' => 'book', 'column' => 'title', 'value' => '%bar%'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'condition() can store condition for later combination'); + } + + public function testConditionCustomOperator() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->withColumn('SUBSTRING(Book.Title, 1, 4)', 'title_start'); + $c->condition('cond1', 'Book.Title <> ?', 'foo'); + $c->condition('cond2', 'title_start like ?', '%bar%', PDO::PARAM_STR); + $c->combine(array('cond1', 'cond2'), 'or'); + + $sql = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id, SUBSTRING(book.title, 1, 4) AS `title_start` FROM `book` WHERE (book.title <> :p1 OR title_start like :p2)"; + $params = array( + array('table' => 'book', 'column' => 'title', 'value' => 'foo'), + array('table' => null, 'type' => PDO::PARAM_STR, 'value' => '%bar%'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'condition() accepts RAW sql parameters'); + } + + public static function conditionsForTestWhere() + { + return array( + array('Book.Title = ?', 'foo', 'book.title = :p1', array(array('table' => 'book', 'column' => 'title', 'value' => 'foo'))), + array('Book.AuthorId = ?', 12, 'book.author_id = :p1', array(array('table' => 'book', 'column' => 'author_id', 'value' => 12))), + array('Book.AuthorId IS NULL', null, 'book.author_id IS NULL', array()), + array('Book.Id BETWEEN ? AND ?', array(3, 4), 'book.id BETWEEN :p1 AND :p2', array(array('table' => 'book', 'column' => 'id', 'value' => 3), array('table' => 'book', 'column' => 'id', 'value' => 4))), + array('Book.Id betWEen ? and ?', array(3, 4), 'book.id betWEen :p1 and :p2', array(array('table' => 'book', 'column' => 'id', 'value' => 3), array('table' => 'book', 'column' => 'id', 'value' => 4))), + array('Book.Id IN ?', array(1, 2, 3), 'book.id IN (:p1,:p2,:p3)', array(array('table' => 'book', 'column' => 'id', 'value' => 1), array('table' => 'book', 'column' => 'id', 'value' => 2), array('table' => 'book', 'column' => 'id', 'value' => 3))), + array('Book.Id in ?', array(1, 2, 3), 'book.id in (:p1,:p2,:p3)', array(array('table' => 'book', 'column' => 'id', 'value' => 1), array('table' => 'book', 'column' => 'id', 'value' => 2), array('table' => 'book', 'column' => 'id', 'value' => 3))), + array('Book.Id IN ?', array(), '1<>1', array()), + array('Book.Id not in ?', array(), '1=1', array()), + array('UPPER(Book.Title) = ?', 'foo', 'UPPER(book.title) = :p1', array(array('table' => 'book', 'column' => 'title', 'value' => 'foo'))), + array('MATCH (Book.Title,Book.isbn) AGAINST (?)', 'foo', 'MATCH (book.title,book.isbn) AGAINST (:p1)', array(array('table' => 'book', 'column' => 'title', 'value' => 'foo'))), + ); + } + + /** + * @dataProvider conditionsForTestWhere + */ + public function testWhere($clause, $value, $sql, $params) + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->where($clause, $value); + $sql = 'SELECT FROM `book` WHERE ' . $sql; + $this->assertCriteriaTranslation($c, $sql, $params, 'where() accepts a string clause'); + } + + public function testWhereUsesDefaultOperator() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->where('Book.Id = ?', 12); + $c->_or(); + $c->where('Book.Title = ?', 'foo'); + $sql = 'SELECT FROM `book` WHERE (book.id = :p1 OR book.title = :p2)'; + $params = array( + array('table' => 'book', 'column' => 'id', 'value' => '12'), + array('table' => 'book', 'column' => 'title', 'value' => 'foo'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'where() uses the default operator'); + } + + public function testWhereTwiceSameColumn() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->where('Book.Id IN ?', array(1, 2, 3)); + $c->where('Book.Id <> ?', 5); + $params = array( + array('table' => 'book', 'column' => 'id', 'value' => '1'), + array('table' => 'book', 'column' => 'id', 'value' => '2'), + array('table' => 'book', 'column' => 'id', 'value' => '3'), + array('table' => 'book', 'column' => 'id', 'value' => '5'), + ); + $sql = 'SELECT FROM `book` WHERE (book.id IN (:p1,:p2,:p3) AND book.id <> :p4)'; + $this->assertCriteriaTranslation($c, $sql, $params, 'where() adds clauses on the same column correctly'); + } + + public function testWhereConditions() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->condition('cond1', 'Book.Title <> ?', 'foo'); + $c->condition('cond2', 'Book.Title like ?', '%bar%'); + $c->where(array('cond1', 'cond2')); + + $sql = "SELECT FROM `book` WHERE (book.title <> :p1 AND book.title like :p2)"; + $params = array( + array('table' => 'book', 'column' => 'title', 'value' => 'foo'), + array('table' => 'book', 'column' => 'title', 'value' => '%bar%'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'where() accepts an array of named conditions'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->condition('cond1', 'Book.Title <> ?', 'foo'); + $c->condition('cond2', 'Book.Title like ?', '%bar%'); + $c->where(array('cond1', 'cond2'), Criteria::LOGICAL_OR); + + $sql = "SELECT FROM `book` WHERE (book.title <> :p1 OR book.title like :p2)"; + $this->assertCriteriaTranslation($c, $sql, $params, 'where() accepts an array of named conditions with operator'); + } + + public function testWhereNoReplacement() + { + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'foo'); + $c->where('1=1'); + + $sql = "SELECT FROM `book` WHERE book.title = :p1 AND 1=1"; + $params = array( + array('table' => 'book', 'column' => 'title', 'value' => 'foo'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'where() results in a Criteria::CUSTOM if no column name is matched'); + + $c = new ModelCriteria('bookstore', 'Book'); + try { + $c->where('b.Title = ?', 'foo'); + $this->fail('where() throws an exception when it finds a ? but cannot determine a column'); + } catch (PropelException $e) { + $this->assertTrue(true, 'where() throws an exception when it finds a ? but cannot determine a column'); + } + } + + public function testWhereFunction() + { + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->where('UPPER(b.Title) = ?', 'foo'); + + $sql = "SELECT FROM `book` WHERE UPPER(book.title) = :p1"; + $params = array( + array('table' => 'book', 'column' => 'title', 'value' => 'foo'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'where() accepts a complex calculation'); + } + + public function testWhereTypeValue() + { + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->where('LOCATE(\'foo\', b.Title) = ?', true, PDO::PARAM_BOOL); + + $sql = "SELECT FROM `book` WHERE LOCATE('foo', book.title) = :p1"; + $params = array( + array('table' => null, 'type' => PDO::PARAM_BOOL, 'value' => true), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'where() accepts a complex calculation'); + $c->find($this->con); + $expected = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE LOCATE('foo', book.title) = 1"; + $this->assertEquals($expected, $this->con->getLastExecutedQuery()); + } + + public function testOrWhere() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->where('Book.Title <> ?', 'foo'); + $c->orWhere('Book.Title like ?', '%bar%'); + + $sql = "SELECT FROM `book` WHERE (book.title <> :p1 OR book.title like :p2)"; + $params = array( + array('table' => 'book', 'column' => 'title', 'value' => 'foo'), + array('table' => 'book', 'column' => 'title', 'value' => '%bar%'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'orWhere() combines the clause with the previous one using OR'); + } + + public function testOrWhereConditions() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->where('Book.Id = ?', 12); + $c->condition('cond1', 'Book.Title <> ?', 'foo'); + $c->condition('cond2', 'Book.Title like ?', '%bar%'); + $c->orWhere(array('cond1', 'cond2')); + + $sql = "SELECT FROM `book` WHERE (book.id = :p1 OR (book.title <> :p2 AND book.title like :p3))"; + $params = array( + array('table' => 'book', 'column' => 'id', 'value' => 12), + array('table' => 'book', 'column' => 'title', 'value' => 'foo'), + array('table' => 'book', 'column' => 'title', 'value' => '%bar%'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'orWhere() accepts an array of named conditions'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->where('Book.Id = ?', 12); + $c->condition('cond1', 'Book.Title <> ?', 'foo'); + $c->condition('cond2', 'Book.Title like ?', '%bar%'); + $c->orWhere(array('cond1', 'cond2'), Criteria::LOGICAL_OR); + + $sql = "SELECT FROM `book` WHERE (book.id = :p1 OR (book.title <> :p2 OR book.title like :p3))"; + $this->assertCriteriaTranslation($c, $sql, $params, 'orWhere() accepts an array of named conditions with operator'); + } + + public function testMixedCriteria() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->where('Book.Title = ?', 'foo'); + $c->add(BookPeer::ID, array(1, 2), Criteria::IN); + + $sql = 'SELECT FROM `book` WHERE book.title = :p1 AND book.id IN (:p2,:p3)'; + $params = array( + array('table' => 'book', 'column' => 'title', 'value' => 'foo'), + array('table' => 'book', 'column' => 'id', 'value' => 1), + array('table' => 'book', 'column' => 'id', 'value' => 2) + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'ModelCriteria accepts Criteria operators'); + } + + public function testFilterBy() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->filterBy('Title', 'foo'); + + $sql = 'SELECT FROM `book` WHERE book.title=:p1'; + $params = array( + array('table' => 'book', 'column' => 'title', 'value' => 'foo'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'filterBy() accepts a simple column name'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->filterBy('Title', 'foo', Criteria::NOT_EQUAL); + + $sql = 'SELECT FROM `book` WHERE book.title<>:p1'; + $params = array( + array('table' => 'book', 'column' => 'title', 'value' => 'foo'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'filterBy() accepts a custom comparator'); + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->filterBy('Title', 'foo'); + + $sql = 'SELECT FROM `book` WHERE book.title=:p1'; + $params = array( + array('table' => 'book', 'column' => 'title', 'value' => 'foo'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'filterBy() accepts a simple column name, even if initialized with an alias'); + } + + public function testHaving() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->having('Book.Title <> ?', 'foo'); + + $sql = "SELECT FROM HAVING book.title <> :p1"; + $params = array( + array('table' => 'book', 'column' => 'title', 'value' => 'foo'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'having() accepts a string clause'); + } + + public function testHavingConditions() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->condition('cond1', 'Book.Title <> ?', 'foo'); + $c->condition('cond2', 'Book.Title like ?', '%bar%'); + $c->having(array('cond1', 'cond2')); + + $sql = "SELECT FROM HAVING (book.title <> :p1 AND book.title like :p2)"; + $params = array( + array('table' => 'book', 'column' => 'title', 'value' => 'foo'), + array('table' => 'book', 'column' => 'title', 'value' => '%bar%'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'having() accepts an array of named conditions'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->condition('cond1', 'Book.Title <> ?', 'foo'); + $c->condition('cond2', 'Book.Title like ?', '%bar%'); + $c->having(array('cond1', 'cond2'), Criteria::LOGICAL_OR); + + $sql = "SELECT FROM HAVING (book.title <> :p1 OR book.title like :p2)"; + $this->assertCriteriaTranslation($c, $sql, $params, 'having() accepts an array of named conditions with an operator'); + } + + public function testHavingWithColumn() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->withColumn('SUBSTRING(Book.Title, 1, 4)', 'title_start'); + $c->having('title_start = ?', 'foo', PDO::PARAM_STR); + + $sql = 'SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id, SUBSTRING(book.title, 1, 4) AS `title_start` FROM `book` HAVING title_start = :p1'; + $params = array( + array('table' => null, 'type' => 2, 'value' => 'foo'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'having() accepts a string clause'); + $c->find($this->con); + $expected = 'SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id, SUBSTRING(book.title, 1, 4) AS `title_start` FROM `book` HAVING title_start = \'foo\''; + $this->assertEquals($expected, $this->con->getLastExecutedQuery()); + } + + public function testOrderBy() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->orderBy('Book.Title'); + + $sql = 'SELECT FROM ORDER BY book.title ASC'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'orderBy() accepts a column name and adds an ORDER BY clause'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->orderBy('Book.Title', 'desc'); + + $sql = 'SELECT FROM ORDER BY book.title DESC'; + $this->assertCriteriaTranslation($c, $sql, $params, 'orderBy() accepts an order parameter'); + + $c = new ModelCriteria('bookstore', 'Book'); + try { + $c->orderBy('Book.Foo'); + $this->fail('orderBy() throws an exception when called with an unknown column name'); + } catch (PropelException $e) { + $this->assertTrue(true, 'orderBy() throws an exception when called with an unknown column name'); + } + $c = new ModelCriteria('bookstore', 'Book'); + try { + $c->orderBy('Book.Title', 'foo'); + $this->fail('orderBy() throws an exception when called with an unknown order'); + } catch (PropelException $e) { + $this->assertTrue(true, 'orderBy() throws an exception when called with an unknown order'); + } + } + + public function testOrderBySimpleColumn() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->orderBy('Title'); + + $sql = 'SELECT FROM ORDER BY book.title ASC'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'orderBy() accepts a simple column name and adds an ORDER BY clause'); + } + + public function testOrderByAlias() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->addAsColumn('t', BookPeer::TITLE); + $c->orderBy('t'); + + $sql = 'SELECT book.title AS `t` FROM ORDER BY t ASC'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'orderBy() accepts a column alias and adds an ORDER BY clause'); + } + + public function testGroupBy() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->groupBy('Book.AuthorId'); + + $sql = 'SELECT FROM GROUP BY book.author_id'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'groupBy() accepts a column name and adds a GROUP BY clause'); + + $c = new ModelCriteria('bookstore', 'Book'); + try { + $c->groupBy('Book.Foo'); + $this->fail('groupBy() throws an exception when called with an unknown column name'); + } catch (PropelException $e) { + $this->assertTrue(true, 'groupBy() throws an exception when called with an unknown column name'); + } + } + + public function testGroupBySimpleColumn() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->groupBy('AuthorId'); + + $sql = 'SELECT FROM GROUP BY book.author_id'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'groupBy() accepts a simple column name and adds a GROUP BY clause'); + } + + public function testGroupByAlias() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->addAsColumn('t', BookPeer::TITLE); + $c->groupBy('t'); + + $sql = 'SELECT book.title AS `t` FROM GROUP BY t'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'groupBy() accepts a column alias and adds a GROUP BY clause'); + } + + /** + * @expectedException PropelException + */ + public function testGroupByClassThrowsExceptionOnUnknownClass() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->groupByClass('Author'); + } + + public function testGroupByClass() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->groupByClass('Book'); + + $sql = 'SELECT FROM GROUP BY book.id,book.title,book.isbn,book.price,book.publisher_id,book.author_id'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'groupByClass() accepts a class name and adds a GROUP BY clause for all columns of the class'); + } + + public function testGroupByClassAlias() + { + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->groupByClass('b'); + + $sql = 'SELECT FROM GROUP BY book.id,book.title,book.isbn,book.price,book.publisher_id,book.author_id'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'groupByClass() accepts a class alias and adds a GROUP BY clause for all columns of the class'); + } + + public function testGroupByClassTrueAlias() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->setModelAlias('b', true); + $c->groupByClass('b'); + + $sql = 'SELECT FROM GROUP BY b.id,b.title,b.isbn,b.price,b.publisher_id,b.author_id'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'groupByClass() accepts a true class alias and adds a GROUP BY clause for all columns of the class'); + } + + public function testGroupByClassJoinedModel() + { + $c = new ModelCriteria('bookstore', 'Author'); + $c->join('Author.Book'); + $c->groupByClass('Book'); + + $sql = 'SELECT FROM `author` INNER JOIN `book` ON (author.id=book.author_id) GROUP BY book.id,book.title,book.isbn,book.price,book.publisher_id,book.author_id'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'groupByClass() accepts the class name of a joined model'); + } + + public function testGroupByClassJoinedModelWithAlias() + { + $c = new ModelCriteria('bookstore', 'Author'); + $c->join('Author.Book b'); + $c->groupByClass('b'); + + $sql = 'SELECT FROM `author` INNER JOIN `book` `b` ON (author.id=b.author_id) GROUP BY b.id,b.title,b.isbn,b.price,b.publisher_id,b.author_id'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'groupByClass() accepts the alias of a joined model'); + } + + public function testDistinct() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->distinct(); + $sql = 'SELECT DISTINCT FROM '; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'distinct() adds a DISTINCT clause'); + } + + public function testLimit() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->limit(10); + $sql = 'SELECT FROM LIMIT 10'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'limit() adds a LIMIT clause'); + } + + public function testOffset() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->limit(50); + $c->offset(10); + $sql = 'SELECT FROM LIMIT 10, 50'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'offset() adds an OFFSET clause'); + } + + public function testAddJoin() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID); + $c->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID); + $sql = 'SELECT FROM `book` INNER JOIN `author` ON (book.author_id=author.id) INNER JOIN `publisher` ON (book.publisher_id=publisher.id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'addJoin() works the same as in Criteria'); + } + + public function testJoin() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $sql = 'SELECT FROM `book` INNER JOIN `author` ON (book.author_id=author.id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() uses a relation to guess the columns'); + + $c = new ModelCriteria('bookstore', 'Book'); + try { + $c->join('Book.Foo'); + $this->fail('join() throws an exception when called with a non-existing relation'); + } catch (PropelException $e) { + $this->assertTrue(true, 'join() throws an exception when called with a non-existing relation'); + } + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $c->where('Author.FirstName = ?', 'Leo'); + $sql = 'SELECT FROM `book` INNER JOIN `author` ON (book.author_id=author.id) WHERE author.first_name = :p1'; + $params = array( + array('table' => 'author', 'column' => 'first_name', 'value' => 'Leo'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() uses a relation to guess the columns'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Author'); + $c->where('Author.FirstName = ?', 'Leo'); + $sql = 'SELECT FROM `book` INNER JOIN `author` ON (book.author_id=author.id) WHERE author.first_name = :p1'; + $params = array( + array('table' => 'author', 'column' => 'first_name', 'value' => 'Leo'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() uses the current model name when given a simple relation name'); + } + + public function testJoinQuery() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + BookstoreDataPopulator::depopulate($con); + BookstoreDataPopulator::populate($con); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $c->where('Author.FirstName = ?', 'Neal'); + $books = BookPeer::doSelect($c); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` INNER JOIN `author` ON (book.author_id=author.id) WHERE author.first_name = 'Neal'"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'join() issues a real JOIN query'); + $this->assertEquals(1, count($books), 'join() issues a real JOIN query'); + } + + public function testWhereWithJoinQuery() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->addSelectColumn('*'); + $c->join('Author'); + $c->where('Author.Id = Book.PublisherId'); + + $sql = 'SELECT * FROM `book` INNER JOIN `author` ON (book.author_id=author.id) WHERE author.id = book.publisher_id'; + $this->assertCriteriaTranslation($c, $sql, array()); + } + + public function testJoinRelationName() + { + $c = new ModelCriteria('bookstore', 'BookstoreEmployee'); + $c->join('BookstoreEmployee.Supervisor'); + $sql = 'SELECT FROM INNER JOIN `bookstore_employee` ON (bookstore_employee.supervisor_id=bookstore_employee.id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() uses relation names as defined in schema.xml'); + } + + public function testJoinComposite() + { + $c = new ModelCriteria('bookstore', 'ReaderFavorite'); + $c->join('ReaderFavorite.BookOpinion'); + $sql = 'SELECT FROM `reader_favorite` INNER JOIN `book_opinion` ON (reader_favorite.book_id=book_opinion.book_id AND reader_favorite.reader_id=book_opinion.reader_id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() knows how to create a JOIN clause for relationships with composite fkeys'); + } + + public function testJoinType() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $sql = 'SELECT FROM `book` INNER JOIN `author` ON (book.author_id=author.id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() adds an INNER JOIN by default'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author', Criteria::INNER_JOIN); + $sql = 'SELECT FROM `book` INNER JOIN `author` ON (book.author_id=author.id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() adds an INNER JOIN by default'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author', Criteria::LEFT_JOIN); + $sql = 'SELECT FROM `book` LEFT JOIN `author` ON (book.author_id=author.id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() can add a LEFT JOIN'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author', Criteria::RIGHT_JOIN); + $sql = 'SELECT FROM `book` RIGHT JOIN `author` ON (book.author_id=author.id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() can add a RIGHT JOIN'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author', 'incorrect join'); + $sql = 'SELECT FROM `book` incorrect join `author` ON (book.author_id=author.id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() accepts any join string'); + } + + public function testJoinDirection() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $sql = 'SELECT FROM `book` INNER JOIN `author` ON (book.author_id=author.id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() adds a JOIN clause correctly for many to one relationship'); + + $c = new ModelCriteria('bookstore', 'Author'); + $c->join('Author.Book'); + $sql = 'SELECT FROM `author` INNER JOIN `book` ON (author.id=book.author_id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() adds a JOIN clause correctly for one to many relationship'); + + $c = new ModelCriteria('bookstore', 'BookstoreEmployee'); + $c->join('BookstoreEmployee.BookstoreEmployeeAccount'); + $sql = 'SELECT FROM `bookstore_employee` INNER JOIN `bookstore_employee_account` ON (bookstore_employee.id=bookstore_employee_account.employee_id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() adds a JOIN clause correctly for one to one relationship'); + + $c = new ModelCriteria('bookstore', 'BookstoreEmployeeAccount'); + $c->join('BookstoreEmployeeAccount.BookstoreEmployee'); + $sql = 'SELECT FROM `bookstore_employee_account` INNER JOIN `bookstore_employee` ON (bookstore_employee_account.employee_id=bookstore_employee.id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() adds a JOIN clause correctly for one to one relationship'); + } + + public function testJoinSeveral() + { + $c = new ModelCriteria('bookstore', 'Author'); + $c->join('Author.Book'); + $c->join('Book.Publisher'); + $c->where('Publisher.Name = ?', 'foo'); + $sql = 'SELECT FROM `author` INNER JOIN `book` ON (author.id=book.author_id) INNER JOIN `publisher` ON (book.publisher_id=publisher.id) WHERE publisher.name = :p1'; + $params = array( + array('table' => 'publisher', 'column' => 'name', 'value' => 'foo'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() can guess relationships from related tables'); + } + + public function testJoinAlias() + { + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->join('b.Author'); + $sql = 'SELECT FROM `book` INNER JOIN `author` ON (book.author_id=author.id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() supports relation on main alias'); + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->join('Author'); + $sql = 'SELECT FROM `book` INNER JOIN `author` ON (book.author_id=author.id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() can use a simple relation name when the model has an alias'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author a'); + $sql = 'SELECT FROM `book` INNER JOIN `author` `a` ON (book.author_id=a.id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() supports relation alias'); + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->join('b.Author a'); + $sql = 'SELECT FROM `book` INNER JOIN `author` `a` ON (book.author_id=a.id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() supports relation alias on main alias'); + + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->join('b.Author a'); + $c->where('a.FirstName = ?', 'Leo'); + $sql = 'SELECT FROM `book` INNER JOIN `author` `a` ON (book.author_id=a.id) WHERE a.first_name = :p1'; + $params = array( + array('table' => 'author', 'column' => 'first_name', 'value' => 'Leo'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() allows the use of relation alias in where()'); + + $c = new ModelCriteria('bookstore', 'Author', 'a'); + $c->join('a.Book b'); + $c->join('b.Publisher p'); + $c->where('p.Name = ?', 'foo'); + $sql = 'SELECT FROM `author` INNER JOIN `book` `b` ON (author.id=b.author_id) INNER JOIN `publisher` `p` ON (b.publisher_id=p.id) WHERE p.name = :p1'; + $params = array( + array('table' => 'publisher', 'column' => 'name', 'value' => 'foo'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() allows the use of relation alias in further join()'); + } + + public function testJoinTrueTableAlias() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->setModelAlias('b', true); + $c->join('b.Author'); + $sql = 'SELECT FROM `book` `b` INNER JOIN `author` ON (b.author_id=author.id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() supports relation on true table alias'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->setModelAlias('b', true); + $c->join('Author'); + $sql = 'SELECT FROM `book` `b` INNER JOIN `author` ON (b.author_id=author.id)'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() supports relation without alias name on true table alias'); + } + + public function testJoinOnSameTable() + { + $c = new ModelCriteria('bookstore', 'BookstoreEmployee', 'be'); + $c->join('be.Supervisor sup'); + $c->join('sup.Subordinate sub'); + $c->where('sub.Name = ?', 'Foo'); + $sql = 'SELECT FROM `bookstore_employee` INNER JOIN `bookstore_employee` `sup` ON (bookstore_employee.supervisor_id=sup.id) INNER JOIN `bookstore_employee` `sub` ON (sup.id=sub.supervisor_id) WHERE sub.name = :p1'; + $params = array( + array('table' => 'bookstore_employee', 'column' => 'name', 'value' => 'Foo'), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'join() allows two joins on the same table thanks to aliases'); + } + + public function testJoinAliasQuery() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->join('b.Author a'); + $c->where('a.FirstName = ?', 'Leo'); + $books = BookPeer::doSelect($c, $con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` INNER JOIN `author` `a` ON (book.author_id=a.id) WHERE a.first_name = 'Leo'"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'join() allows the use of relation alias in where()'); + + $c = new ModelCriteria('bookstore', 'BookstoreEmployee', 'be'); + $c->join('be.Supervisor sup'); + $c->join('sup.Subordinate sub'); + $c->where('sub.Name = ?', 'Foo'); + $employees = BookstoreEmployeePeer::doSelect($c, $con); + $expectedSQL = "SELECT bookstore_employee.id, bookstore_employee.class_key, bookstore_employee.name, bookstore_employee.job_title, bookstore_employee.supervisor_id FROM `bookstore_employee` INNER JOIN `bookstore_employee` `sup` ON (bookstore_employee.supervisor_id=sup.id) INNER JOIN `bookstore_employee` `sub` ON (sup.id=sub.supervisor_id) WHERE sub.name = 'Foo'"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'join() allows the use of relation alias in further joins()'); + } + + public function testJoinDuplicate() + { + $c = new ModelCriteria('bookstore', 'Author'); + $c->addJoinObject(new Join('tbl.COL1', 'tbl.COL2', 'LEFT JOIN')); + $c->addJoinObject(new Join('tbl.COL1', 'tbl.COL2', 'LEFT JOIN')); + $this->assertEquals(1, count($c->getJoins()), 'Expected not to have duplicate LEFT JOIN added.'); + + $c->addJoinObject(new Join('tbl.COL1', 'tbl.COL2', 'RIGHT JOIN')); + $c->addJoinObject(new Join('tbl.COL1', 'tbl.COL2', 'RIGHT JOIN')); + $this->assertEquals(2, count($c->getJoins()), 'Expected 1 new right join to be added.'); + + $c->addJoinObject(new Join('tbl.COL1', 'tbl.COL2')); + $c->addJoinObject(new Join('tbl.COL1', 'tbl.COL2')); + $this->assertEquals(3, count($c->getJoins()), 'Expected 1 new implicit join to be added.'); + + $c->addJoinObject(new Join('tbl.COL1', 'tbl.COL2', 'INNER JOIN')); + $this->assertEquals(3, count($c->getJoins()), 'Expected to not add any new join + as INNER JOIN is default joinType and it is already added'); + + $c->addJoinObject(new Join('tbl.COL3', 'tbl.COL4')); + $this->assertEquals(4, count($c->getJoins()), "Expected new col join to be added."); + } + + public function testAddJoinConditionSimple() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author', Criteria::INNER_JOIN); + $c->addJoinCondition('Author', 'Book.Title IS NOT NULL'); + $books = BookPeer::doSelect($c, $con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` INNER JOIN `author` ON (book.author_id=author.id AND book.title IS NOT NULL)"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'addJoinCondition() allows the use of custom conditions'); + } + + public function testAddJoinConditionWithInOperator() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Author'); + $c->join('Author.Book', Criteria::LEFT_JOIN); + $c->addJoinCondition('Book', 'Book.isbn IN ?', array(1, 7, 42)); + $c->limit(1); + $books = AuthorPeer::doSelect($c, $con); + $expectedSQL = "SELECT author.id, author.first_name, author.last_name, author.email, author.age FROM `author` LEFT JOIN `book` ON (author.id=book.author_id AND book.isbn IN (1,7,42)) LIMIT 1"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'addJoinCondition() allows the use of custom conditions'); + } + + public function testAddJoinConditionWithNotInOperator() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Author'); + $c->join('Author.Book', Criteria::LEFT_JOIN); + $c->addJoinCondition('Book', 'Book.isbn NOT IN ?', array(1, 7, 42)); + $c->limit(1); + $books = AuthorPeer::doSelect($c, $con); + $expectedSQL = "SELECT author.id, author.first_name, author.last_name, author.email, author.age FROM `author` LEFT JOIN `book` ON (author.id=book.author_id AND book.isbn NOT IN (1,7,42)) LIMIT 1"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'addJoinCondition() allows the use of custom conditions'); + } + + public function testAddJoinConditionBinding() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author', Criteria::INNER_JOIN); + $c->addJoinCondition('Author', 'Book.Title = ?', 'foo'); + $books = BookPeer::doSelect($c, $con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` INNER JOIN `author` ON (book.author_id=author.id AND book.title = 'foo')"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'addJoinCondition() allows the use of custom conditions with values to bind'); + } + + public function testAddJoinConditionSeveral() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author', Criteria::INNER_JOIN); + $c->addJoinCondition('Author', 'Book.Title = ?', 'foo'); + $c->addJoinCondition('Author', 'Book.isbn IS NOT NULL'); + $books = BookPeer::doSelect($c, $con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` INNER JOIN `author` ON ((book.author_id=author.id AND book.title = 'foo') AND book.isbn IS NOT NULL)"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'addJoinCondition() allows the use of several custom conditions'); + } + + public function testAddJoinConditionBindingAndWhere() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Book'); + $c->where('Book.Title LIKE ?', 'foo%'); + $c->join('Book.Author', Criteria::INNER_JOIN); + $c->addJoinCondition('Author', 'Book.Title = ?', 'foo'); + $books = BookPeer::doSelect($c, $con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` INNER JOIN `author` ON (book.author_id=author.id AND book.title = 'foo') WHERE book.title LIKE 'foo%'"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'addJoinCondition() allows the use of custom conditions with values and lives well with WHERE conditions'); + } + + public function testAddJoinConditionAlias() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author a', Criteria::INNER_JOIN); + $c->addJoinCondition('a', 'Book.Title IS NOT NULL'); + $books = BookPeer::doSelect($c, $con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` INNER JOIN `author` `a` ON (book.author_id=a.id AND book.title IS NOT NULL)"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'addJoinCondition() allows the use of custom conditions even on aliased relations'); + } + + public function testAddJoinConditionOperator() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author', Criteria::INNER_JOIN); + $c->addJoinCondition('Author', 'Book.Title IS NOT NULL', null, Criteria::LOGICAL_OR); + $books = BookPeer::doSelect($c, $con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` INNER JOIN `author` ON (book.author_id=author.id OR book.title IS NOT NULL)"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'addJoinCondition() allows the use of custom conditions with a custom operator'); + } + + public function testSetJoinConditionCriterion() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author', Criteria::INNER_JOIN); + $criterion = $c->getNewCriterion(BookPeer::TITLE, BookPeer::TITLE . ' = ' . AuthorPeer::FIRST_NAME, Criteria::CUSTOM); + $c->setJoinCondition('Author', $criterion); + $books = BookPeer::doSelect($c, $con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` INNER JOIN `author` ON book.title = author.first_name"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'setJoinCondition() can override a previous join condition with a Criterion'); + } + + public function testSetJoinConditionNamedCondition() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author', Criteria::INNER_JOIN); + $c->condition('cond1', 'Book.Title = Author.FirstName'); + $c->setJoinCondition('Author', 'cond1'); + $books = BookPeer::doSelect($c, $con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` INNER JOIN `author` ON book.title = author.first_name"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'setJoinCondition() can override a previous join condition with a named condition'); + } + + public function testGetJoin() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + + $joins = $c->getJoins(); + $this->assertEquals($joins['Author'], $c->getJoin('Author'), "getJoin() returns a specific Join from the ModelCriteria"); + } + + public function testWith() + { + $c = new TestableModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $c->with('Author'); + $withs = $c->getWith(); + $this->assertTrue(array_key_exists('Author', $withs), 'with() adds an entry to the internal list of Withs'); + $this->assertTrue($withs['Author'] instanceof ModelWith, 'with() references the ModelWith object'); + } + + /** + * @expectedException PropelException + */ + public function testWithThrowsExceptionWhenJoinLacks() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->with('Author'); + } + + public function testWithAlias() + { + $c = new TestableModelCriteria('bookstore', 'Book'); + $c->join('Book.Author a'); + $c->with('a'); + $withs = $c->getWith(); + $this->assertTrue(array_key_exists('a', $withs), 'with() uses the alias for the index of the internal list of Withs'); + } + + /** + * @expectedException PropelException + */ + public function testWithThrowsExceptionWhenNotUsingAlias() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->join('Book.Author a'); + $c->with('Author'); + } + + public function testWithAddsSelectColumns() + { + $c = new TestableModelCriteria('bookstore', 'Book'); + BookPeer::addSelectColumns($c); + $c->join('Book.Author'); + $c->with('Author'); + $expectedColumns = array( + BookPeer::ID, + BookPeer::TITLE, + BookPeer::ISBN, + BookPeer::PRICE, + BookPeer::PUBLISHER_ID, + BookPeer::AUTHOR_ID, + AuthorPeer::ID, + AuthorPeer::FIRST_NAME, + AuthorPeer::LAST_NAME, + AuthorPeer::EMAIL, + AuthorPeer::AGE + ); + $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the related table'); + } + + public function testWithAliasAddsSelectColumns() + { + $c = new TestableModelCriteria('bookstore', 'Book'); + BookPeer::addSelectColumns($c); + $c->join('Book.Author a'); + $c->with('a'); + $expectedColumns = array( + BookPeer::ID, + BookPeer::TITLE, + BookPeer::ISBN, + BookPeer::PRICE, + BookPeer::PUBLISHER_ID, + BookPeer::AUTHOR_ID, + 'a.id', + 'a.first_name', + 'a.last_name', + 'a.email', + 'a.age' + ); + $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the related table'); + } + + public function testWithAddsSelectColumnsOfMainTable() + { + $c = new TestableModelCriteria('bookstore', 'Book'); + $c->join('Book.Author'); + $c->with('Author'); + $expectedColumns = array( + BookPeer::ID, + BookPeer::TITLE, + BookPeer::ISBN, + BookPeer::PRICE, + BookPeer::PUBLISHER_ID, + BookPeer::AUTHOR_ID, + AuthorPeer::ID, + AuthorPeer::FIRST_NAME, + AuthorPeer::LAST_NAME, + AuthorPeer::EMAIL, + AuthorPeer::AGE + ); + $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the main table if required'); + } + + public function testWithAliasAddsSelectColumnsOfMainTable() + { + $c = new TestableModelCriteria('bookstore', 'Book'); + $c->setModelAlias('b', true); + $c->join('b.Author a'); + $c->with('a'); + $expectedColumns = array( + 'b.id', + 'b.title', + 'b.isbn', + 'b.price', + 'b.publisher_id', + 'b.author_id', + 'a.id', + 'a.first_name', + 'a.last_name', + 'a.email', + 'a.age' + ); + $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the main table with an alias if required'); + } + + public function testWithOneToManyAddsSelectColumns() + { + $c = new TestableModelCriteria('bookstore', 'Author'); + AuthorPeer::addSelectColumns($c); + $c->leftJoin('Author.Book'); + $c->with('Book'); + $expectedColumns = array( + AuthorPeer::ID, + AuthorPeer::FIRST_NAME, + AuthorPeer::LAST_NAME, + AuthorPeer::EMAIL, + AuthorPeer::AGE, + BookPeer::ID, + BookPeer::TITLE, + BookPeer::ISBN, + BookPeer::PRICE, + BookPeer::PUBLISHER_ID, + BookPeer::AUTHOR_ID, + ); + $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'with() adds the columns of the related table even in a one-to-many relationship'); + } + + public function testJoinWith() + { + $c = new TestableModelCriteria('bookstore', 'Book'); + $c->joinWith('Book.Author'); + $expectedColumns = array( + BookPeer::ID, + BookPeer::TITLE, + BookPeer::ISBN, + BookPeer::PRICE, + BookPeer::PUBLISHER_ID, + BookPeer::AUTHOR_ID, + AuthorPeer::ID, + AuthorPeer::FIRST_NAME, + AuthorPeer::LAST_NAME, + AuthorPeer::EMAIL, + AuthorPeer::AGE + ); + $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWith() adds the join'); + $joins = $c->getJoins(); + $join = $joins['Author']; + $this->assertEquals(Criteria::INNER_JOIN, $join->getJoinType(), 'joinWith() adds an INNER JOIN by default'); + } + + public function testJoinWithType() + { + $c = new TestableModelCriteria('bookstore', 'Book'); + $c->joinWith('Book.Author', Criteria::LEFT_JOIN); + $joins = $c->getJoins(); + $join = $joins['Author']; + $this->assertEquals(Criteria::LEFT_JOIN, $join->getJoinType(), 'joinWith() accepts a join type as second parameter'); + } + + public function testJoinWithAlias() + { + $c = new TestableModelCriteria('bookstore', 'Book'); + $c->joinWith('Book.Author a'); + $expectedColumns = array( + BookPeer::ID, + BookPeer::TITLE, + BookPeer::ISBN, + BookPeer::PRICE, + BookPeer::PUBLISHER_ID, + BookPeer::AUTHOR_ID, + 'a.id', + 'a.first_name', + 'a.last_name', + 'a.email', + 'a.age' + ); + $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWith() adds the join with the alias'); + } + + public function testJoinWithSeveral() + { + $c = new TestableModelCriteria('bookstore', 'Review'); + $c->joinWith('Review.Book'); + $c->joinWith('Book.Author'); + $c->joinWith('Book.Publisher'); + $expectedColumns = array( + ReviewPeer::ID, + ReviewPeer::REVIEWED_BY, + ReviewPeer::REVIEW_DATE, + ReviewPeer::RECOMMENDED, + ReviewPeer::STATUS, + ReviewPeer::BOOK_ID, + BookPeer::ID, + BookPeer::TITLE, + BookPeer::ISBN, + BookPeer::PRICE, + BookPeer::PUBLISHER_ID, + BookPeer::AUTHOR_ID, + AuthorPeer::ID, + AuthorPeer::FIRST_NAME, + AuthorPeer::LAST_NAME, + AuthorPeer::EMAIL, + AuthorPeer::AGE, + PublisherPeer::ID, + PublisherPeer::NAME + ); + $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWith() adds the with'); + $joins = $c->getJoins(); + $expectedJoinKeys = array('Book', 'Author', 'Publisher'); + $this->assertEquals($expectedJoinKeys, array_keys($joins), 'joinWith() adds the join'); + } + + public function testJoinWithTwice() + { + $c = new TestableModelCriteria('bookstore', 'Book'); + $c->join('Book.Review'); + $c->joinWith('Book.Author'); + $c->joinWith('Book.Review'); + $expectedColumns = array( + BookPeer::ID, + BookPeer::TITLE, + BookPeer::ISBN, + BookPeer::PRICE, + BookPeer::PUBLISHER_ID, + BookPeer::AUTHOR_ID, + AuthorPeer::ID, + AuthorPeer::FIRST_NAME, + AuthorPeer::LAST_NAME, + AuthorPeer::EMAIL, + AuthorPeer::AGE, + ReviewPeer::ID, + ReviewPeer::REVIEWED_BY, + ReviewPeer::REVIEW_DATE, + ReviewPeer::RECOMMENDED, + ReviewPeer::STATUS, + ReviewPeer::BOOK_ID, + ); + $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWith() adds the with'); + $joins = $c->getJoins(); + $expectedJoinKeys = array('Review', 'Author'); + $this->assertEquals($expectedJoinKeys, array_keys($joins), 'joinWith() adds the join'); + } + + public static function conditionsForTestWithColumn() + { + return array( + array('Book.Title', 'BookTitle', 'book.title AS `BookTitle`'), + array('Book.Title', null, 'book.title AS `BookTitle`'), + array('UPPER(Book.Title)', null, 'UPPER(book.title) AS `UPPERBookTitle`'), + array('CONCAT(Book.Title, Book.isbn)', 'foo', 'CONCAT(book.title, book.isbn) AS `foo`'), + ); + } + + /** + * @dataProvider conditionsForTestWithColumn + */ + public function testWithColumn($clause, $alias, $selectTranslation) + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->withColumn($clause, $alias); + $sql = 'SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id, ' . $selectTranslation . ' FROM `book`'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'withColumn() adds a calculated column to the select clause'); + } + + public static function conditionsForTestWithColumnAndQuotes() + { + return array( + // Examples for simple string concatenation needed for MSSQL. + // MSSQL has no CONCAT() function so uses + to join strings. + array("CONVERT(varchar, Author.Age, 120) + \' GMT\'", 'GMTCreatedAt', "CONVERT(varchar, author.age, 120) + \' GMT\' AS `GMTCreatedAt`"), + array("(Author.FirstName + ' ' + Author.LastName)", 'AuthorFullname', "(author.first_name + ' ' + author.last_name) AS `AuthorFullname`"), + array("('\"' + Author.FirstName + ' ' + Author.LastName + '\"')", 'QuotedAuthorFullname', "('\"' + author.first_name + ' ' + author.last_name + '\"') AS `QuotedAuthorFullname`"), + + // Examples for simple string concatenation needed for Sqlite + // Sqlite has no CONCAT() function so uses || to join strings. || can also be used to join strings in PQSql and Oracle + array("(Author.FirstName || ' ' || Author.LastName)", 'AuthorFullname', "(author.first_name || ' ' || author.last_name) AS `AuthorFullname`"), + array("('\"' || Author.FirstName || ' ' || Author.LastName || '\"')", 'QuotedAuthorFullname', "('\"' || author.first_name || ' ' || author.last_name || '\"') AS `QuotedAuthorFullname`"), + ); + } + + /** + * @dataProvider conditionsForTestWithColumnAndQuotes + */ + public function testWithColumnAndQuotes($clause, $alias, $selectTranslation) + { + $c = new ModelCriteria('bookstore', 'Author'); + $c->withColumn($clause, $alias); + $sql = 'SELECT author.id, author.first_name, author.last_name, author.email, author.age, ' . $selectTranslation . ' FROM `author`'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'withColumn() adds a calculated column using quotes to the select clause'); + } + + public function testWithColumnAndSelect() + { + $c = new ModelCriteria('bookstore', 'Author'); + $c->join('Book'); + $c->withColumn('COUNT(Book.Id)', 'NbBooks'); + $c->select(array('FirstName', 'LastName')); + $collection = $c->find(); + + $this->assertThat($collection, $this->isInstanceOf('PropelCollection')); + + foreach ($collection as $array) { + $this->assertArrayHasKey('FirstName', $array); + $this->assertArrayHasKey('LastName', $array); + $this->assertArrayHasKey('NbBooks', $array); + } + } + + public function testWithColumnAndSelectColumns() + { + $c = new ModelCriteria('bookstore', 'Book'); + $c->withColumn('UPPER(Book.Title)', 'foo'); + $sql = 'SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id, UPPER(book.title) AS `foo` FROM `book`'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'withColumn() adds the object columns if the criteria has no select columns'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->addSelectColumn('book.id'); + $c->withColumn('UPPER(Book.Title)', 'foo'); + $sql = 'SELECT book.id, UPPER(book.title) AS `foo` FROM `book`'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'withColumn() does not add the object columns if the criteria already has select columns'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->addSelectColumn('book.id'); + $c->withColumn('UPPER(Book.Title)', 'foo'); + $c->addSelectColumn('book.title'); + $sql = 'SELECT book.id, book.title, UPPER(book.title) AS `foo` FROM `book`'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'withColumn() does adds as column after the select columns even though the withColumn() method was called first'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->addSelectColumn('book.id'); + $c->withColumn('UPPER(Book.Title)', 'foo'); + $c->withColumn('UPPER(Book.isbn)', 'isbn'); + $sql = 'SELECT book.id, UPPER(book.title) AS `foo`, UPPER(book.isbn) AS `isbn` FROM `book`'; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'withColumn() called repeatedly adds several as columns'); + } + + public function testKeepQuery() + { + $c = BookQuery::create(); + $this->assertTrue($c->isKeepQuery(), 'keepQuery is enabled by default'); + $c->keepQuery(false); + $this->assertFalse($c->isKeepQuery(), 'keepQuery(false) disables the keepQuery property'); + $c->keepQuery(); + $this->assertTrue($c->isKeepQuery(), 'keepQuery() enables the keepQuery property'); + } + + public function testKeepQueryFind() + { + $c = BookQuery::create(); + $c->filterByTitle('foo'); + $c->find(); + $this->assertEquals(array(), $c->getSelectColumns(), 'find() clones the query by default'); + + $c = BookQuery::create(); + $c->filterByTitle('foo'); + $c->keepQuery(false); + $c->find(); + $expected = array('book.id', 'book.title', 'book.isbn', 'book.price', 'book.publisher_id', 'book.author_id'); + $this->assertEquals($expected, $c->getSelectColumns(), 'keepQuery(false) forces find() to use the original query'); + } + + public function testKeepQueryFindOne() + { + $c = BookQuery::create(); + $c->filterByTitle('foo'); + $c->findOne(); + $this->assertEquals(0, $c->getLimit(), 'findOne() clones the query by default'); + + $c = BookQuery::create(); + $c->filterByTitle('foo'); + $c->keepQuery(false); + $c->findOne(); + $this->assertEquals(1, $c->getLimit(), 'keepQuery(false) forces findOne() to use the original query'); + } + + public function testKeepQueryFindPk() + { + $c = BookQuery::create(); + $c->findPk(1); + $this->assertEquals(array(), $c->getSelectColumns(), 'findPk() clones the query by default'); + + $c = BookQuery::create('b'); + $c->keepQuery(false); + $c->findPk(1); + $expected = array('book.id', 'book.title', 'book.isbn', 'book.price', 'book.publisher_id', 'book.author_id'); + $this->assertEquals($expected, $c->getSelectColumns(), 'keepQuery(false) forces findPk() to use the original query'); + } + + public function testKeepQueryCount() + { + $c = BookQuery::create(); + $c->orderByTitle(); + $c->count(); + $this->assertEquals(array('book.title ASC'), $c->getOrderByColumns(), 'count() clones the query by default'); + + $c = BookQuery::create(); + $c->orderByTitle(); + $c->keepQuery(false); + $c->count(); + $this->assertEquals(array(), $c->getOrderByColumns(), 'keepQuery() forces count() to use the original query'); + } + + public function testFind() + { + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'foo'); + $books = $c->find(); + $this->assertTrue($books instanceof PropelCollection, 'find() returns a collection by default'); + $this->assertEquals(0, count($books), 'find() returns an empty array when the query returns no result'); + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->join('b.Author a'); + $c->where('a.FirstName = ?', 'Neal'); + $books = $c->find(); + $this->assertTrue($books instanceof PropelCollection, 'find() returns a collection by default'); + $this->assertEquals(1, count($books), 'find() returns as many rows as the results in the query'); + $book = $books->shift(); + $this->assertTrue($book instanceof Book, 'find() returns an array of Model objects by default'); + $this->assertEquals('Quicksilver', $book->getTitle(), 'find() returns the model objects matching the query'); + } + + public function testFindAddsSelectColumns() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->find($con); + $sql = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book`"; + $this->assertEquals($sql, $con->getLastExecutedQuery(), 'find() adds the select columns of the current model'); + } + + public function testFindTrueAliasAddsSelectColumns() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Book'); + $c->setModelAlias('b', true); + $books = $c->find($con); + $sql = "SELECT b.id, b.title, b.isbn, b.price, b.publisher_id, b.author_id FROM `book` `b`"; + $this->assertEquals($sql, $con->getLastExecutedQuery(), 'find() uses the true model alias if available'); + } + + public function testFindOne() + { + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'foo'); + $book = $c->findOne(); + $this->assertNull($book, 'findOne() returns null when the query returns no result'); + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->orderBy('b.Title'); + $book = $c->findOne(); + $this->assertTrue($book instanceof Book, 'findOne() returns a Model object by default'); + $this->assertEquals('Don Juan', $book->getTitle(), 'find() returns the model objects matching the query'); + } + + public function testFindOneOrCreateNotExists() + { + BookQuery::create()->deleteAll(); + $book = BookQuery::create('b') + ->where('b.Title = ?', 'foo') + ->filterByPrice(125) + ->findOneOrCreate(); + $this->assertTrue($book instanceof Book, 'findOneOrCreate() returns an instance of the model when the request has no result'); + $this->assertTrue($book->isNew(), 'findOneOrCreate() returns a new instance of the model when the request has no result'); + $this->assertEquals('foo', $book->getTitle(), 'findOneOrCreate() returns a populated objects based on the conditions'); + $this->assertEquals(125, $book->getPrice(), 'findOneOrCreate() returns a populated objects based on the conditions'); + } + + public function testFindOneOrCreateNotExistsFormatter() + { + BookQuery::create()->deleteAll(); + $book = BookQuery::create('b') + ->where('b.Title = ?', 'foo') + ->filterByPrice(125) + ->setFormatter(ModelCriteria::FORMAT_ARRAY) + ->findOneOrCreate(); + $this->assertTrue(is_array($book), 'findOneOrCreate() uses the query formatter even when the request has no result'); + $this->assertEquals('foo', $book['Title'], 'findOneOrCreate() returns a populated array based on the conditions'); + $this->assertEquals(125, $book['Price'], 'findOneOrCreate() returns a populated array based on the conditions'); + } + + public function testFindOneOrCreateExists() + { + BookQuery::create()->deleteAll(); + $book = new Book(); + $book->setTitle('foo'); + $book->setPrice(125); + $book->setIsbn('1235'); + $book->save(); + $book = BookQuery::create('b') + ->where('b.Title = ?', 'foo') + ->filterByPrice(125) + ->findOneOrCreate(); + $this->assertTrue($book instanceof Book, 'findOneOrCreate() returns an instance of the model when the request has one result'); + $this->assertFalse($book->isNew(), 'findOneOrCreate() returns an existing instance of the model when the request has one result'); + $this->assertEquals('foo', $book->getTitle(), 'findOneOrCreate() returns a populated objects based on the conditions'); + $this->assertEquals(125, $book->getPrice(), 'findOneOrCreate() returns a populated objects based on the conditions'); + } + + /** + * @expectedException PropelException + */ + public function testFindOneOrCreateThrowsExceptionWhenQueryContainsJoin() + { + $book = BookQuery::create('b') + ->filterByPrice(125) + ->useAuthorQuery() + ->filterByFirstName('Leo') + ->endUse() + ->findOneOrCreate(); + } + + public function testFindOneOrCreateMakesOneQueryWhenRecordNotExists() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + BookQuery::create()->deleteAll($con); + $count = $con->getQueryCount(); + $book = BookQuery::create('b') + ->filterByPrice(125) + ->findOneOrCreate($con); + $this->assertEquals($count + 1, $con->getQueryCount(), 'findOneOrCreate() makes only a single query when the record doesn\'t exist'); + } + + public function testFindOneOrCreateMakesOneQueryWhenRecordExists() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + BookQuery::create()->deleteAll($con); + $book = new Book(); + $book->setPrice(125); + $book->setTitle('Title'); + $book->setIsbn('1245'); + $book->save($con); + $count = $con->getQueryCount(); + $book = BookQuery::create('b') + ->filterByPrice(125) + ->findOneOrCreate($con); + $this->assertEquals($count + 1, $con->getQueryCount(), 'findOneOrCreate() makes only a single query when the record exists'); + } + + public function testFindOneOrCreateWithEnums() + { + Book2Query::create()->deleteAll(); + + $book = Book2Query::create('b') + ->where('b.Title = ?', 'bar') + ->filterByStyle('poetry') + ->findOneOrCreate(); + $this->assertTrue($book instanceof Book2, 'findOneOrCreate() returns an instance of the model when the request has no result'); + $this->assertTrue($book->isNew(), 'findOneOrCreate() returns a new instance of the model when the request has no result'); + $this->assertEquals('bar', $book->getTitle(), 'findOneOrCreate() returns a populated objects based on the conditions'); + $this->assertEquals('poetry', $book->getStyle(), 'findOneOrCreate() returns a populated objects based on the conditions'); + + $book = Book2Query::create('b') + ->where('b.Title = ?', 'foobar') + ->filterByStyle('essay') + ->findOneOrCreate(); + $this->assertTrue($book instanceof Book2, 'findOneOrCreate() returns an instance of the model when the request has no result'); + $this->assertTrue($book->isNew(), 'findOneOrCreate() returns a new instance of the model when the request has no result'); + $this->assertEquals('foobar', $book->getTitle(), 'findOneOrCreate() returns a populated objects based on the conditions'); + $this->assertEquals('essay', $book->getStyle(), 'findOneOrCreate() returns a populated objects based on the conditions'); + + $book = Book2Query::create('b') + ->where('b.Style = ?', 'novel') + ->findOneOrCreate(); + $this->assertTrue($book instanceof Book2, 'findOneOrCreate() returns an instance of the model when the request has no result'); + $this->assertTrue($book->isNew(), 'findOneOrCreate() returns a new instance of the model when the request has no result'); + $this->assertEquals('novel', $book->getStyle(), 'findOneOrCreate() returns a populated objects based on the conditions'); + } + + public function testFindOneOrCreateWithArrays() + { + Book2Query::create()->deleteAll(); + + $book = Book2Query::create('b') + ->filterByTag('russian') + ->findOneOrCreate(); + $this->assertTrue($book instanceof Book2, 'findOneOrCreate() returns an instance of the model when the request has no result'); + $this->assertTrue($book->isNew(), 'findOneOrCreate() returns a new instance of the model when the request has no result'); + $this->assertTrue(is_array($book->getTags()), 'findOneOrCreate() returns a populated objects based on the conditions'); + $this->assertSame(array('russian'), $book->getTags(), 'findOneOrCreate() returns a populated objects based on the conditions'); + + $book = Book2Query::create('b') + ->filterByTags(array('poetry')) + ->findOneOrCreate(); + $this->assertTrue($book instanceof Book2, 'findOneOrCreate() returns an instance of the model when the request has no result'); + $this->assertTrue($book->isNew(), 'findOneOrCreate() returns a new instance of the model when the request has no result'); + $this->assertTrue(is_array($book->getTags()), 'findOneOrCreate() returns a populated objects based on the conditions'); + $this->assertSame(array('poetry'), $book->getTags(), 'findOneOrCreate() returns a populated objects based on the conditions'); + } + + public function testFindPkSimpleKey() + { + BookstoreDataPopulator::depopulate(); + + $c = new ModelCriteria('bookstore', 'Book'); + $book = $c->findPk(765432); + $this->assertNull($book, 'findPk() returns null when the primary key is not found'); + + BookstoreDataPopulator::populate(); + + // retrieve the test data + $c = new ModelCriteria('bookstore', 'Book'); + $testBook = $c->findOne(); + + $c = new ModelCriteria('bookstore', 'Book'); + $book = $c->findPk($testBook->getId()); + $this->assertEquals($testBook, $book, 'findPk() returns a model object corresponding to the pk'); + } + + public function testFindPksSimpleKey() + { + BookstoreDataPopulator::depopulate(); + + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->findPks(array(765432, 434535)); + $this->assertTrue($books instanceof PropelCollection, 'findPks() returns a PropelCollection'); + $this->assertEquals(0, count($books), 'findPks() returns an empty collection when the primary keys are not found'); + + BookstoreDataPopulator::populate(); + + // retrieve the test data + $c = new ModelCriteria('bookstore', 'Book'); + $testBooks = $c->find(); + $testBook1 = $testBooks->pop(); + $testBook2 = $testBooks->pop(); + + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->findPks(array($testBook1->getId(), $testBook2->getId())); + $this->assertEquals(array($testBook2, $testBook1), $books->getData(), 'findPks() returns an array of model objects corresponding to the pks'); + } + + public function testFindPkCompositeKey() + { + BookstoreDataPopulator::depopulate(); + + $c = new ModelCriteria('bookstore', 'BookListRel'); + $bookListRel = $c->findPk(array(1, 2)); + $this->assertNull($bookListRel, 'findPk() returns null when the composite primary key is not found'); + + Propel::enableInstancePooling(); + BookstoreDataPopulator::populate(); + + // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->find(); + foreach ($books as $book) { + $book->save(); + } + + // retrieve the test data + $c = new ModelCriteria('bookstore', 'BookListRel'); + $bookListRelTest = $c->findOne(); + $pk = $bookListRelTest->getPrimaryKey(); + + $c = new ModelCriteria('bookstore', 'BookListRel'); + $bookListRel = $c->findPk($pk); + $this->assertEquals($bookListRelTest, $bookListRel, 'findPk() can find objects with composite primary keys'); + } + + /** + * @expectedException PropelException + */ + public function testFindPksCompositeKey() + { + $c = new ModelCriteria('bookstore', 'BookListRel'); + $bookListRel = $c->findPks(array(array(1, 2))); + + } + + public function testFindBy() + { + try { + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->findBy('Foo', 'Bar'); + $this->fail('findBy() throws an exception when called on an unknown column name'); + } catch (PropelException $e) { + $this->assertTrue(true, 'findBy() throws an exception when called on an unknown column name'); + } + + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->findBy('Title', 'Don Juan', $con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.title='Don Juan'"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findBy() adds simple column conditions'); + $this->assertTrue($books instanceof PropelCollection, 'findBy() issues a find()'); + $this->assertEquals(1, count($books), 'findBy() adds simple column conditions'); + $book = $books->shift(); + $this->assertTrue($book instanceof Book, 'findBy() returns an array of Model objects by default'); + $this->assertEquals('Don Juan', $book->getTitle(), 'findBy() returns the model objects matching the query'); + } + + public function testFindByArray() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->findByArray(array('Title' => 'Don Juan', 'ISBN' => 12345), $con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.title='Don Juan' AND book.isbn=12345"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findByArray() adds multiple column conditions'); + } + + public function testFindOneBy() + { + try { + $c = new ModelCriteria('bookstore', 'Book'); + $book = $c->findOneBy('Foo', 'Bar'); + $this->fail('findOneBy() throws an exception when called on an unknown column name'); + } catch (PropelException $e) { + $this->assertTrue(true, 'findOneBy() throws an exception when called on an unknown column name'); + } + + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Book'); + $book = $c->findOneBy('Title', 'Don Juan', $con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.title='Don Juan' LIMIT 1"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findOneBy() adds simple column conditions'); + $this->assertTrue($book instanceof Book, 'findOneBy() returns a Model object by default'); + $this->assertEquals('Don Juan', $book->getTitle(), 'findOneBy() returns the model object matching the query'); + } + + public function testFindOneByArray() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Book'); + $book = $c->findOneByArray(array('Title' => 'Don Juan', 'ISBN' => 12345), $con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.title='Don Juan' AND book.isbn=12345 LIMIT 1"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findOneBy() adds multiple column conditions'); + } + + public function testCount() + { + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'foo'); + $nbBooks = $c->count(); + $this->assertTrue(is_int($nbBooks), 'count() returns an integer'); + $this->assertEquals(0, $nbBooks, 'count() returns 0 when the query returns no result'); + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->join('b.Author a'); + $c->where('a.FirstName = ?', 'Neal'); + $nbBooks = $c->count(); + $this->assertTrue(is_int($nbBooks), 'count() returns an integer'); + $this->assertEquals(1, $nbBooks, 'count() returns the number of results in the query'); + } + + public function testPaginate() + { + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->join('b.Author a'); + $c->where('a.FirstName = ?', 'Neal'); + $books = $c->paginate(1, 5); + $this->assertTrue($books instanceof PropelModelPager, 'paginate() returns a PropelModelPager'); + $this->assertEquals(1, count($books), 'paginate() returns a countable pager with the correct count'); + foreach ($books as $book) { + $this->assertEquals('Neal', $book->getAuthor()->getFirstName(), 'paginate() returns an iterable pager'); + } + } + + public function testDelete() + { + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + + $c = new ModelCriteria('bookstore', 'Book'); + try { + $nbBooks = $c->delete(); + $this->fail('delete() throws an exception when called on an empty Criteria'); + } catch (PropelException $e) { + $this->assertTrue(true, 'delete() throws an exception when called on an empty Criteria'); + } + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'foo'); + $nbBooks = $c->delete(); + $this->assertTrue(is_int($nbBooks), 'delete() returns an integer'); + $this->assertEquals(0, $nbBooks, 'delete() returns 0 when the query deleted no rows'); + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'Don Juan'); + $nbBooks = $c->delete(); + $this->assertTrue(is_int($nbBooks), 'delete() returns an integer'); + $this->assertEquals(1, $nbBooks, 'delete() returns the number of the deleted rows'); + + $c = new ModelCriteria('bookstore', 'Book'); + $nbBooks = $c->count(); + $this->assertEquals(3, $nbBooks, 'delete() deletes rows in the database'); + } + + public function testDeleteUsingTableAlias() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->setModelAlias('b', false); + $c->where('b.Title = ?', 'foo'); + $c->delete(); + $expectedSQL = "DELETE FROM `book` WHERE book.title = 'foo'"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'delete() also works on tables with table alias'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->setModelAlias('b', true); + $c->where('b.Title = ?', 'foo'); + $c->delete(); + $expectedSQL = "DELETE b FROM `book` AS b WHERE b.title = 'foo'"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'delete() also works on tables with true table alias'); + } + + public function testDeleteAll() + { + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + + $c = new ModelCriteria('bookstore', 'Book'); + $nbBooks = $c->deleteAll(); + $this->assertTrue(is_int($nbBooks), 'deleteAll() returns an integer'); + $this->assertEquals(4, $nbBooks, 'deleteAll() returns the number of deleted rows'); + + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'Don Juan'); + $nbBooks = $c->deleteAll(); + $this->assertEquals(4, $nbBooks, 'deleteAll() ignores conditions on the criteria'); + } + + public function testUpdate() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + BookstoreDataPopulator::depopulate($con); + BookstoreDataPopulator::populate($con); + + $count = $con->getQueryCount(); + $c = new ModelCriteria('bookstore', 'Book'); + $nbBooks = $c->update(array('Title' => 'foo'), $con); + $this->assertEquals(4, $nbBooks, 'update() returns the number of updated rows'); + $this->assertEquals($count + 1, $con->getQueryCount(), 'update() updates all the objects in one query by default'); + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'foo'); + $nbBooks = $c->count(); + $this->assertEquals(4, $nbBooks, 'update() updates all records by default'); + + BookstoreDataPopulator::depopulate($con); + BookstoreDataPopulator::populate($con); + + $count = $con->getQueryCount(); + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'Don Juan'); + $nbBooks = $c->update(array('ISBN' => '3456'), $con); + $this->assertEquals(1, $nbBooks, 'update() updates only the records matching the criteria'); + $this->assertEquals($count + 1, $con->getQueryCount(), 'update() updates all the objects in one query by default'); + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'Don Juan'); + $book = $c->findOne(); + $this->assertEquals('3456', $book->getISBN(), 'update() updates only the records matching the criteria'); + } + + public function testUpdateUsingTableAlias() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->setModelAlias('b', false); + $c->where('b.Title = ?', 'foo'); + $c->update(array('Title' => 'foo2'), $con); + $expectedSQL = "UPDATE `book` SET `title`='foo2' WHERE book.title = 'foo'"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'update() also works on tables with table alias'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->setModelAlias('b', true); + $c->where('b.Title = ?', 'foo'); + $c->update(array('Title' => 'foo2'), $con); + $expectedSQL = "UPDATE `book` `b` SET `title`='foo2' WHERE b.title = 'foo'"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'update() also works on tables with true table alias'); + } + + public function testUpdateOneByOne() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + BookstoreDataPopulator::depopulate($con); + BookstoreDataPopulator::populate($con); + + // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->find(); + foreach ($books as $book) { + $book->save(); + } + + $count = $con->getQueryCount(); + $c = new ModelCriteria('bookstore', 'Book'); + $nbBooks = $c->update(array('Title' => 'foo'), $con, true); + $this->assertEquals(4, $nbBooks, 'update() returns the number of updated rows'); + $this->assertEquals($count + 1 + 4, $con->getQueryCount(), 'update() updates the objects one by one when called with true as last parameter'); + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'foo'); + $nbBooks = $c->count(); + $this->assertEquals(4, $nbBooks, 'update() updates all records by default'); + + BookstoreDataPopulator::depopulate($con); + BookstoreDataPopulator::populate($con); + + // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->find(); + foreach ($books as $book) { + $book->save(); + } + + $count = $con->getQueryCount(); + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'Don Juan'); + $nbBooks = $c->update(array('ISBN' => '3456'), $con, true); + $this->assertEquals(1, $nbBooks, 'update() updates only the records matching the criteria'); + $this->assertEquals($count + 1 + 1, $con->getQueryCount(), 'update() updates the objects one by one when called with true as last parameter'); + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'Don Juan'); + $book = $c->findOne(); + $this->assertEquals('3456', $book->getISBN(), 'update() updates only the records matching the criteria'); + } + + public static function conditionsForTestGetRelationName() + { + return array( + array('Author', 'Author'), + array('Book.Author', 'Author'), + array('Author.Book', 'Book'), + array('Book.Author a', 'a'), + ); + } + + /** + * @dataProvider conditionsForTestGetRelationName + */ + public function testGetRelationName($relation, $relationName) + { + $this->assertEquals($relationName, ModelCriteria::getrelationName($relation)); + } + + public function testMagicJoin() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->leftJoin('b.Author a'); + $c->where('a.FirstName = ?', 'Leo'); + $books = $c->findOne($con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` LEFT JOIN `author` `a` ON (book.author_id=a.id) WHERE a.first_name = 'Leo' LIMIT 1"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'leftJoin($x) is turned into join($x, Criteria::LEFT_JOIN)'); + + $books = BookQuery::create() + ->leftJoinAuthor('a') + ->where('a.FirstName = ?', 'Leo') + ->findOne($con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` LEFT JOIN `author` `a` ON (book.author_id=a.id) WHERE a.first_name = 'Leo' LIMIT 1"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'leftJoinX() is turned into join($x, Criteria::LEFT_JOIN)'); + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->innerJoin('b.Author a'); + $c->where('a.FirstName = ?', 'Leo'); + $books = $c->findOne($con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` INNER JOIN `author` `a` ON (book.author_id=a.id) WHERE a.first_name = 'Leo' LIMIT 1"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'innerJoin($x) is turned into join($x, Criteria::INNER_JOIN)'); + + $books = BookQuery::create() + ->innerJoinAuthor('a') + ->where('a.FirstName = ?', 'Leo') + ->findOne($con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` INNER JOIN `author` `a` ON (book.author_id=a.id) WHERE a.first_name = 'Leo' LIMIT 1"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'innerJoinX() is turned into join($x, Criteria::INNER_JOIN)'); + + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->rightJoin('b.Author a'); + $c->where('a.FirstName = ?', 'Leo'); + $books = $c->findOne($con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` RIGHT JOIN `author` `a` ON (book.author_id=a.id) WHERE a.first_name = 'Leo' LIMIT 1"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'rightJoin($x) is turned into join($x, Criteria::RIGHT_JOIN)'); + + $books = BookQuery::create() + ->rightJoinAuthor('a') + ->where('a.FirstName = ?', 'Leo') + ->findOne($con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` RIGHT JOIN `author` `a` ON (book.author_id=a.id) WHERE a.first_name = 'Leo' LIMIT 1"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'rightJoinX() is turned into join($x, Criteria::RIGHT_JOIN)'); + + $books = BookQuery::create() + ->leftJoinAuthor() + ->where('Author.FirstName = ?', 'Leo') + ->findOne($con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` LEFT JOIN `author` ON (book.author_id=author.id) WHERE author.first_name = 'Leo' LIMIT 1"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'leftJoinX() is turned into join($x, Criteria::LEFT_JOIN)'); + } + + public function testMagicJoinWith() + { + $c = new TestableModelCriteria('bookstore', 'Book'); + $c->leftJoinWith('Book.Author a'); + $expectedColumns = array( + BookPeer::ID, + BookPeer::TITLE, + BookPeer::ISBN, + BookPeer::PRICE, + BookPeer::PUBLISHER_ID, + BookPeer::AUTHOR_ID, + 'a.id', + 'a.first_name', + 'a.last_name', + 'a.email', + 'a.age' + ); + $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'leftJoinWith() adds the join with the alias'); + $joins = $c->getJoins(); + $join = $joins['a']; + $this->assertEquals(Criteria::LEFT_JOIN, $join->getJoinType(), 'leftJoinWith() adds a LEFT JOIN'); + } + + public function testMagicJoinWithRelation() + { + $c = new TestableModelCriteria('bookstore', 'Book'); + $c->joinWithAuthor(); + $expectedColumns = array( + BookPeer::ID, + BookPeer::TITLE, + BookPeer::ISBN, + BookPeer::PRICE, + BookPeer::PUBLISHER_ID, + BookPeer::AUTHOR_ID, + AuthorPeer::ID, + AuthorPeer::FIRST_NAME, + AuthorPeer::LAST_NAME, + AuthorPeer::EMAIL, + AuthorPeer::AGE + ); + $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'joinWithXXX() adds the join with the XXX relation'); + $joins = $c->getJoins(); + $join = $joins['Author']; + $this->assertEquals(Criteria::INNER_JOIN, $join->getJoinType(), 'joinWithXXX() adds an INNER JOIN'); + } + + public function testMagicJoinWithTypeAndRelation() + { + $c = new TestableModelCriteria('bookstore', 'Book'); + $c->leftJoinWithAuthor(); + $expectedColumns = array( + BookPeer::ID, + BookPeer::TITLE, + BookPeer::ISBN, + BookPeer::PRICE, + BookPeer::PUBLISHER_ID, + BookPeer::AUTHOR_ID, + AuthorPeer::ID, + AuthorPeer::FIRST_NAME, + AuthorPeer::LAST_NAME, + AuthorPeer::EMAIL, + AuthorPeer::AGE + ); + $this->assertEquals($expectedColumns, $c->getSelectColumns(), 'leftJoinWithXXX() adds the join with the XXX relation'); + $joins = $c->getJoins(); + $join = $joins['Author']; + $this->assertEquals(Criteria::LEFT_JOIN, $join->getJoinType(), 'leftJoinWithXXX() adds an INNER JOIN'); + } + + public function testMagicFind() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->findByTitle('Don Juan'); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.title='Don Juan'"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findByXXX($value) is turned into findBy(XXX, $value)'); + + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->findByTitleAndISBN('Don Juan', 1234); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.title='Don Juan' AND book.isbn=1234"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findByXXXAndYYY($value) is turned into findBy(array(XXX,YYY), $value)'); + + $c = new ModelCriteria('bookstore', 'Book'); + $book = $c->findOneByTitle('Don Juan'); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.title='Don Juan' LIMIT 1"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findOneByXXX($value) is turned into findOneBy(XXX, $value)'); + + $c = new ModelCriteria('bookstore', 'Book'); + $book = $c->findOneByTitleAndISBN('Don Juan', 1234); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.title='Don Juan' AND book.isbn=1234 LIMIT 1"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findOneByXXX($value) is turned into findOneBy(XXX, $value)'); + } + + public function testMagicFindByObject() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new ModelCriteria('bookstore', 'Author'); + $testAuthor = $c->findOne(); + $q = BookQuery::create() + ->findByAuthor($testAuthor); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.author_id=" . $testAuthor->getId(); + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findByXXX($value) is turned into findBy(XXX, $value)'); + + $c = new ModelCriteria('bookstore', 'Author'); + $testAuthor = $c->findOne(); + $q = BookQuery::create() + ->findByAuthorAndISBN($testAuthor, 1234); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.author_id=" . $testAuthor->getId() . " AND book.isbn=1234"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'findByXXXAndYYY($value) is turned into findBy(array(XXX, YYY), $value)'); + } + + public function testMagicFilterBy() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->filterByTitle('Don Juan')->find($con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.title='Don Juan'"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'filterByXXX($value) is turned into filterBy(XXX, $value)'); + } + + public function testMagicOrderBy() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->orderByTitle()->find($con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` ORDER BY book.title ASC"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'orderByXXX() is turned into orderBy(XXX)'); + + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->orderByTitle(Criteria::DESC)->find($con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` ORDER BY book.title DESC"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'orderByXXX($direction) is turned into orderBy(XXX, $direction)'); + } + + public function testMagicGroupBy() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + + $c = new ModelCriteria('bookstore', 'Book'); + $books = $c->groupByTitle()->find($con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` GROUP BY book.title"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'groupByXXX() is turned into groupBy(XXX)'); + } + + public function testUseQuery() + { + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->thisIsMe = true; + $c->where('b.Title = ?', 'foo'); + $c->setOffset(10); + $c->leftJoin('b.Author'); + + $c2 = $c->useQuery('Author'); + $this->assertTrue($c2 instanceof AuthorQuery, 'useQuery() returns a secondary Criteria'); + $this->assertEquals($c, $c2->getPrimaryCriteria(), 'useQuery() sets the primary Criteria os the secondary Criteria'); + $c2->where('Author.FirstName = ?', 'john'); + $c2->limit(5); + + $c = $c2->endUse(); + $this->assertTrue($c->thisIsMe, 'endUse() returns the Primary Criteria'); + $this->assertEquals('Book', $c->getModelName(), 'endUse() returns the Primary Criteria'); + + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c->find($con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` LEFT JOIN `author` ON (book.author_id=author.id) WHERE book.title = 'foo' AND author.first_name = 'john' LIMIT 10, 5"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and endUse() allow to merge a secondary criteria'); + } + + public function testUseQueryAlias() + { + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->thisIsMe = true; + $c->where('b.Title = ?', 'foo'); + $c->setOffset(10); + $c->leftJoin('b.Author a'); + + $c2 = $c->useQuery('a'); + $this->assertTrue($c2 instanceof AuthorQuery, 'useQuery() returns a secondary Criteria'); + $this->assertEquals($c, $c2->getPrimaryCriteria(), 'useQuery() sets the primary Criteria os the secondary Criteria'); + $this->assertEquals(array('a' => 'author'), $c2->getAliases(), 'useQuery() sets the secondary Criteria alias correctly'); + $c2->where('a.FirstName = ?', 'john'); + $c2->limit(5); + + $c = $c2->endUse(); + $this->assertTrue($c->thisIsMe, 'endUse() returns the Primary Criteria'); + $this->assertEquals('Book', $c->getModelName(), 'endUse() returns the Primary Criteria'); + + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c->find($con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` LEFT JOIN `author` `a` ON (book.author_id=a.id) WHERE book.title = 'foo' AND a.first_name = 'john' LIMIT 10, 5"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and endUse() allow to merge a secondary criteria'); + } + + public function testUseQueryCustomClass() + { + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->thisIsMe = true; + $c->where('b.Title = ?', 'foo'); + $c->setLimit(10); + $c->leftJoin('b.Author a'); + + $c2 = $c->useQuery('a', 'ModelCriteriaForUseQuery'); + $this->assertTrue($c2 instanceof ModelCriteriaForUseQuery, 'useQuery() returns a secondary Criteria with the custom class'); + $c2->withNoName(); + $c = $c2->endUse(); + + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c->find($con); + $expectedSQL = "SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` LEFT JOIN `author` `a` ON (book.author_id=a.id) WHERE book.title = 'foo' AND a.first_name IS NOT NULL AND a.last_name IS NOT NULL LIMIT 10"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and endUse() allow to merge a custom secondary criteria'); + } + + public function testUseQueryJoinWithFind() + { + $c = new ModelCriteria('bookstore', 'Review'); + $c->joinWith('Book'); + + $c2 = $c->useQuery('Book'); + + $joins = $c->getJoins(); + $this->assertEquals($c->getPreviousJoin(), null, 'The default value for previousJoin remains null'); + $this->assertEquals($c2->getPreviousJoin(), $joins['Book'], 'useQuery() sets the previousJoin'); + + // join Book with Author, which is possible since previousJoin is set, which makes resolving of relations possible during hydration + $c2->joinWith('Author'); + + $c = $c2->endUse(); + + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c->find($con); + $expectedSQL = "SELECT review.id, review.reviewed_by, review.review_date, review.recommended, review.status, review.book_id, book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id, author.id, author.first_name, author.last_name, author.email, author.age FROM `review` INNER JOIN `book` ON (review.book_id=book.id) INNER JOIN `author` ON (book.author_id=author.id)"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and joinWith() can be used together and form a correct query'); + } + + public function testUseQueryCustomRelationPhpName() + { + $c = new ModelCriteria('bookstore', 'BookstoreContest'); + $c->leftJoin('BookstoreContest.Work'); + $c2 = $c->useQuery('Work'); + $this->assertTrue($c2 instanceof BookQuery, 'useQuery() returns a secondary Criteria'); + $this->assertEquals($c, $c2->getPrimaryCriteria(), 'useQuery() sets the primary Criteria os the secondary Criteria'); + //$this->assertEquals(array('a' => 'author'), $c2->getAliases(), 'useQuery() sets the secondary Criteria alias correctly'); + $c2->where('Work.Title = ?', 'War And Peace'); + + $c = $c2->endUse(); + $this->assertEquals('BookstoreContest', $c->getModelName(), 'endUse() returns the Primary Criteria'); + + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c->find($con); + $expectedSQL = "SELECT bookstore_contest.bookstore_id, bookstore_contest.contest_id, bookstore_contest.prize_book_id FROM `bookstore_contest` LEFT JOIN `book` ON (bookstore_contest.prize_book_id=book.id) WHERE book.title = 'War And Peace'"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and endUse() allow to merge a secondary criteria'); + } + + public function testUseQueryCustomRelationPhpNameAndAlias() + { + $c = new ModelCriteria('bookstore', 'BookstoreContest'); + $c->leftJoin('BookstoreContest.Work w'); + $c2 = $c->useQuery('w'); + $this->assertTrue($c2 instanceof BookQuery, 'useQuery() returns a secondary Criteria'); + $this->assertEquals($c, $c2->getPrimaryCriteria(), 'useQuery() sets the primary Criteria os the secondary Criteria'); + //$this->assertEquals(array('a' => 'author'), $c2->getAliases(), 'useQuery() sets the secondary Criteria alias correctly'); + $c2->where('w.Title = ?', 'War And Peace'); + + $c = $c2->endUse(); + $this->assertEquals('BookstoreContest', $c->getModelName(), 'endUse() returns the Primary Criteria'); + + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c->find($con); + $expectedSQL = "SELECT bookstore_contest.bookstore_id, bookstore_contest.contest_id, bookstore_contest.prize_book_id FROM `bookstore_contest` LEFT JOIN `book` `w` ON (bookstore_contest.prize_book_id=w.id) WHERE w.title = 'War And Peace'"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'useQuery() and endUse() allow to merge a secondary criteria'); + } + + public function testMergeWithJoins() + { + $c1 = new ModelCriteria('bookstore', 'Book', 'b'); + $c1->leftJoin('b.Author a'); + $c2 = new ModelCriteria('bookstore', 'Author'); + $c1->mergeWith($c2); + $joins = $c1->getJoins(); + $this->assertEquals(1, count($joins), 'mergeWith() does not remove an existing join'); + $this->assertEquals('LEFT JOIN author a ON (book.author_id=a.id)', $joins['a']->toString(), 'mergeWith() does not remove an existing join'); + $c1 = new ModelCriteria('bookstore', 'Book', 'b'); + $c2 = new ModelCriteria('bookstore', 'Book', 'b'); + $c2->leftJoin('b.Author a'); + $c1->mergeWith($c2); + $joins = $c1->getJoins(); + $this->assertEquals(1, count($joins), 'mergeWith() merge joins to an empty join'); + $this->assertEquals('LEFT JOIN author a ON (book.author_id=a.id)', $joins['a']->toString(), 'mergeWith() merge joins to an empty join'); + + $c1 = new ModelCriteria('bookstore', 'Book', 'b'); + $c1->leftJoin('b.Author a'); + $c2 = new ModelCriteria('bookstore', 'Book', 'b'); + $c2->innerJoin('b.Publisher p'); + $c1->mergeWith($c2); + $joins = $c1->getJoins(); + $this->assertEquals(2, count($joins), 'mergeWith() merge joins to an existing join'); + $this->assertEquals('LEFT JOIN author a ON (book.author_id=a.id)', $joins['a']->toString(), 'mergeWith() merge joins to an empty join'); + $this->assertEquals('INNER JOIN publisher p ON (book.publisher_id=p.id)', $joins['p']->toString(), 'mergeWith() merge joins to an empty join'); + } + + public function testMergeWithWiths() + { + $c1 = new ModelCriteria('bookstore', 'Book', 'b'); + $c1->leftJoinWith('b.Author a'); + $c2 = new ModelCriteria('bookstore', 'Author'); + $c1->mergeWith($c2); + $with = $c1->getWith(); + $this->assertEquals(1, count($with), 'mergeWith() does not remove an existing join'); + $this->assertEquals('modelName: Author, relationName: Author, relationMethod: setAuthor, leftPhpName: , rightPhpName: a', $with['a']->__toString(), 'mergeWith() does not remove an existing join'); + + $c1 = new ModelCriteria('bookstore', 'Book', 'b'); + $c2 = new ModelCriteria('bookstore', 'Book', 'b'); + $c2->leftJoinWith('b.Author a'); + $c1->mergeWith($c2); + $with = $c1->getWith(); + $this->assertEquals(1, count($with), 'mergeWith() merge joins to an empty join'); + $this->assertEquals('modelName: Author, relationName: Author, relationMethod: setAuthor, leftPhpName: , rightPhpName: a', $with['a']->__toString(), 'mergeWith() merge joins to an empty join'); + + $c1 = new ModelCriteria('bookstore', 'Book', 'b'); + $c1->leftJoinWith('b.Author a'); + $c2 = new ModelCriteria('bookstore', 'Book', 'b'); + $c2->innerJoinWith('b.Publisher p'); + $c1->mergeWith($c2); + $with = $c1->getWith(); + $this->assertEquals(2, count($with), 'mergeWith() merge joins to an existing join'); + $this->assertEquals('modelName: Author, relationName: Author, relationMethod: setAuthor, leftPhpName: , rightPhpName: a', $with['a']->__toString(), 'mergeWith() merge joins to an empty join'); + $this->assertEquals('modelName: Publisher, relationName: Publisher, relationMethod: setPublisher, leftPhpName: , rightPhpName: p', $with['p']->__toString(), 'mergeWith() merge joins to an empty join'); + + } + + public function testGetAliasedColName() + { + $c = new ModelCriteria('bookstore', 'Book'); + $this->assertEquals(BookPeer::TITLE, $c->getAliasedColName(BookPeer::TITLE), 'getAliasedColName() returns the input when the table has no alias'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->setModelAlias('foo'); + $this->assertEquals(BookPeer::TITLE, $c->getAliasedColName(BookPeer::TITLE), 'getAliasedColName() returns the input when the table has a query alias'); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->setModelAlias('foo', true); + $this->assertEquals('foo.title', $c->getAliasedColName(BookPeer::TITLE), 'getAliasedColName() returns the column name with table alias when the table has a true alias'); + } + + public function testAddUsingAliasNoAlias() + { + $c1 = new ModelCriteria('bookstore', 'Book'); + $c1->addUsingAlias(BookPeer::TITLE, 'foo'); + $c2 = new ModelCriteria('bookstore', 'Book'); + $c2->add(BookPeer::TITLE, 'foo'); + $this->assertEquals($c2, $c1, 'addUsingalias() translates to add() when the table has no alias'); + } + + public function testAddUsingAliasQueryAlias() + { + $c1 = new ModelCriteria('bookstore', 'Book', 'b'); + $c1->addUsingAlias(BookPeer::TITLE, 'foo'); + $c2 = new ModelCriteria('bookstore', 'Book', 'b'); + $c2->add(BookPeer::TITLE, 'foo'); + $this->assertEquals($c2, $c1, 'addUsingalias() translates the colname using the table alias before calling add() when the table has a true alias'); + } + + public function testAddUsingAliasTrueAlias() + { + $c1 = new ModelCriteria('bookstore', 'Book'); + $c1->setModelAlias('b', true); + $c1->addUsingAlias(BookPeer::TITLE, 'foo'); + $c2 = new ModelCriteria('bookstore', 'Book'); + $c2->setModelAlias('b', true); + $c2->add('b.title', 'foo'); + $this->assertEquals($c2, $c1, 'addUsingalias() translates to add() when the table has a true alias'); + } + + public function testAddUsingAliasTwice() + { + $c1 = new ModelCriteria('bookstore', 'Book'); + $c1->addUsingAlias(BookPeer::TITLE, 'foo'); + $c1->addUsingAlias(BookPeer::TITLE, 'bar'); + $c2 = new ModelCriteria('bookstore', 'Book'); + $c2->add(BookPeer::TITLE, 'foo'); + $c2->addAnd(BookPeer::TITLE, 'bar'); + $this->assertEquals($c2, $c1, 'addUsingalias() translates to addAnd() when the table already has a condition on the column'); + } + + public function testAddUsingAliasTrueAliasTwice() + { + $c1 = new ModelCriteria('bookstore', 'Book'); + $c1->setModelAlias('b', true); + $c1->addUsingAlias(BookPeer::TITLE, 'foo'); + $c1->addUsingAlias(BookPeer::TITLE, 'bar'); + $c2 = new ModelCriteria('bookstore', 'Book'); + $c2->setModelAlias('b', true); + $c2->add('b.title', 'foo'); + $c2->addAnd('b.title', 'bar'); + $this->assertEquals($c2, $c1, 'addUsingalias() translates to addAnd() when the table already has a condition on the column'); + } + + public function testCloneCopiesConditions() + { + $bookQuery1 = BookQuery::create() + ->filterByPrice(1); + $bookQuery2 = clone $bookQuery1; + $bookQuery2 + ->filterByPrice(2); + $params = array(); + $sql = BasePeer::createSelectSql($bookQuery1, $params); + $this->assertEquals('SELECT FROM `book` WHERE book.price=:p1', $sql, 'conditions applied on a cloned query don\'t get applied on the original query'); + } + + public function testCloneCopiesFormatter() + { + $formatter1 = new PropelArrayFormatter(); + $formatter1->test = false; + $bookQuery1 = BookQuery::create(); + $bookQuery1->setFormatter($formatter1); + $bookQuery2 = clone $bookQuery1; + $formatter2 = $bookQuery2->getFormatter(); + $this->assertFalse($formatter2->test); + $formatter2->test = true; + $this->assertFalse($formatter1->test); + } + + public function testCloneCopiesSelect() + { + $bookQuery1 = BookQuery::create(); + $bookQuery1->select(array('Id', 'Title')); + $bookQuery2 = clone $bookQuery1; + $bookQuery2->select(array('ISBN', 'Price')); + $this->assertEquals(array('Id', 'Title'), $bookQuery1->getSelect()); + } + + public function testSetIgnoreCaseWithWhereClause() + { + $q = BookQuery::create('b') + ->where('b.Title = ?', 'foo') + ->setIgnoreCase(true) + ->orderById() + ; + + try { + $q->find(); + + $this->assertTrue(true); + } catch (Exception $e) { + $this->fail('Unexpected exception catched: ' . $e->getMessage()); + } + } + + public function testOrderByWithInsensitiveCase() + { + $sql = 'SELECT FROM ORDER BY book.title ASC'; + $params = array(); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->orderBy('Book.title'); + $this->assertCriteriaTranslation($c, $sql, $params); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->orderBy('Book.TiTle'); + $this->assertCriteriaTranslation($c, $sql, $params); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->orderBy('Book.Title'); + $this->assertCriteriaTranslation($c, $sql, $params); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->orderBy('Book.title'); + $this->assertCriteriaTranslation($c, $sql, $params); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->orderBy('title'); + $this->assertCriteriaTranslation($c, $sql, $params); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->orderBy('Title'); + $this->assertCriteriaTranslation($c, $sql, $params); + + $c = new ModelCriteria('bookstore', 'Book'); + $c->orderBy('title'); + $this->assertCriteriaTranslation($c, $sql, $params); + } + + public function testExists() + { + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $this->assertTrue($c->exists()); + } + + public function testExistsWithNonExistentCondition() + { + $c = new ModelCriteria('bookstore', 'Book', 'b'); + $c->where('b.Title = ?', 'jenexistepas'); + $this->assertFalse($c->exists()); + } + + public function testCombineAndFilterBy() + { + $params = array(); + $sql = "SELECT FROM `book` WHERE ((book.title LIKE :p1 OR book.isbn LIKE :p2) AND book.title LIKE :p3)"; + $c = BookQuery::create() + ->condition('u1', 'book.title LIKE ?', '%test1%') + ->condition('u2', 'book.isbn LIKE ?', '%test2%') + ->combine(array('u1', 'u2'), 'or') + ->filterByTitle('%test3%'); + $result = BasePeer::createSelectSql($c, $params); + $this->assertEquals($result, $sql); + + $params = array(); + $sql = "SELECT FROM `book` WHERE (book.title LIKE :p1 AND (book.title LIKE :p2 OR book.isbn LIKE :p3))"; + $c = BookQuery::create() + ->filterByTitle('%test3%') + ->condition('u1', 'book.title LIKE ?', '%test1%') + ->condition('u2', 'book.isbn LIKE ?', '%test2%') + ->combine(array('u1', 'u2'), 'or'); + $result = BasePeer::createSelectSql($c, $params); + $this->assertEquals($result, $sql); + } + + public function testClear() + { + // initial assumptions + $c1 = BookQuery::create(); + $c2 = BookQuery::create(); + + $this->assertEquals($c1, $c2); + $this->assertNotSame($c1, $c2); + + $c1->clear(); + $this->assertEquals($c1, $c2); + + // alias is one of initialization parameters and as such should be preserved + // no matter how criteria object was created + $c1 = BookQuery::create('alias1'); + $c2 = BookQuery::create('alias1'); + $this->assertEquals($c1, $c2); + $c1->clear(); + $this->assertEquals($c1, $c2); + + $c1 = new ModelCriteria('bookstore', 'Book', 'alias2'); + $c2 = new ModelCriteria('bookstore', 'Book', 'alias2'); + $this->assertEquals($c1, $c2); + $c1->clear(); + $this->assertEquals($c1, $c2); + + // actual extensive criteria test + $c1 = BookQuery::create(); + $c2 = BookQuery::create(); + + // modifiers & flags + $c1->setModelAlias('b', true); + $c1->setLimit(1); + $c1->setOffset(1); + $c1->setDistinct(); + + // filters + $c1->filterByPrice(1); + + // where conditions + $c1->condition('u1', 'b.title LIKE ?', '%test1%'); + $c1->condition('u2', 'b.isbn LIKE ?', '%test2%'); + $c1->where('b.id = ?', 12); + $c1->_or(); + $c1->where(array('u1', 'u2'), Criteria::LOGICAL_AND); + + // select columns + $c1->select(array('ISBN', 'Price')); + $c1->add(BookPeer::TITLE, 'foo'); + $c1->addUsingAlias(BookPeer::PRICE, 'p'); + + // joins + $c1->leftJoinAuthor('alias1'); + $c1->rightJoinAuthor('alias2'); + $c1->innerJoinAuthor('alias3'); + $c1->withColumn('COUNT(alias1.Id)', 'NbAuthors'); + $c1->with('alias2'); + + // subquery use + $c1 + ->useAuthorQuery() + ->filterByFirstName('Leo') + ->endUse() + ; + + // meta + $c1->setIgnoreCase(true); + $c1->setComment('comment'); + $formatter = new PropelArrayFormatter(); + $formatter->diff = true; + $c1->setFormatter($formatter); + $c1->setSingleRecord(true); + $c1->setUseTransaction(true); + + $this->assertNotEquals($c1, $c2); + $c1->clear(); + $this->assertEquals($c1, $c2); + } } class TestableModelCriteria extends ModelCriteria { - public $joins = array(); - - public function replaceNames(&$clause) - { - return parent::replaceNames($clause); - } - + public $joins = array(); + + public function replaceNames(&$clause) + { + return parent::replaceNames($clause); + } + } class ModelCriteriaForUseQuery extends ModelCriteria { - public function __construct($dbName = 'bookstore', $modelName = 'Author', $modelAlias = null) - { - parent::__construct($dbName, $modelName, $modelAlias); - } + public function __construct($dbName = 'bookstore', $modelName = 'Author', $modelAlias = null) + { + parent::__construct($dbName, $modelName, $modelAlias); + } - public function withNoName() - { - return $this - ->filterBy('FirstName', null, Criteria::ISNOTNULL) - ->where($this->getModelAliasOrName() . '.LastName IS NOT NULL'); - } -} \ No newline at end of file + public function withNoName() + { + return $this + ->filterBy('FirstName', null, Criteria::ISNOTNULL) + ->where($this->getModelAliasOrName() . '.LastName IS NOT NULL'); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaWithNamespaceTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaWithNamespaceTest.php new file mode 100644 index 000000000..4ad74f5eb --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaWithNamespaceTest.php @@ -0,0 +1,66 @@ + + * @package runtime.query + */ +class ModelCriteriaWithNamespaceTest extends NamespacesTestBase +{ + public static function conditionsForTestReplaceNamesWithNamespaces() + { + return array( + array('Foo\\Bar\\NamespacedBook.Title = ?', 'Title', 'book.title = ?'), // basic case + array('Foo\\Bar\\NamespacedBook.Title=?', 'Title', 'book.title=?'), // without spaces + array('Foo\\Bar\\NamespacedBook.Id<= ?', 'Id', 'book.id<= ?'), // with non-equal comparator + array('Foo\\Bar\\NamespacedBook.AuthorId LIKE ?', 'AuthorId', 'book.author_id LIKE ?'), // with SQL keyword separator + array('(Foo\\Bar\\NamespacedBook.AuthorId) LIKE ?', 'AuthorId', '(book.author_id) LIKE ?'), // with parenthesis + array('(Foo\\Bar\\NamespacedBook.Id*1.5)=1', 'Id', '(book.id*1.5)=1'), // ignore numbers + // dealing with quotes + array("Foo\\Bar\\NamespacedBook.Id + ' ' + Foo\\Bar\\NamespacedBook.AuthorId", null, "book.id + ' ' + book.author_id"), + array("'Foo\\Bar\\NamespacedBook.Id' + Foo\\Bar\\NamespacedBook.AuthorId", null, "'Foo\\Bar\\NamespacedBook.Id' + book.author_id"), + array("Foo\\Bar\\NamespacedBook.Id + 'Foo\\Bar\\NamespacedBook.AuthorId'", null, "book.id + 'Foo\\Bar\\NamespacedBook.AuthorId'"), + ); + } + + /** + * @dataProvider conditionsForTestReplaceNamesWithNamespaces + */ + public function testReplaceNamesWithNamespaces($origClause, $columnPhpName = false, $modifiedClause) + { + $c = new TestableModelCriteriaWithNamespace('bookstore_namespaced', 'Foo\\Bar\\NamespacedBook'); + $this->doTestReplaceNames($c, Foo\Bar\NamespacedBookPeer::getTableMap(), $origClause, $columnPhpName = false, $modifiedClause); + } + + public function doTestReplaceNames($c, $tableMap, $origClause, $columnPhpName = false, $modifiedClause) + { + $c->replaceNames($origClause); + $columns = $c->replacedColumns; + if ($columnPhpName) { + $this->assertEquals(array($tableMap->getColumnByPhpName($columnPhpName)), $columns); + } + $this->assertEquals($modifiedClause, $origClause); + } + +} + +class TestableModelCriteriaWithNamespace extends ModelCriteria +{ + public $joins = array(); + + public function replaceNames(&$clause) + { + return parent::replaceNames($clause); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaWithSchemaTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaWithSchemaTest.php new file mode 100644 index 000000000..0bbe50110 --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelCriteriaWithSchemaTest.php @@ -0,0 +1,74 @@ +assertEquals($expectedSql, $result, $message); + $this->assertEquals($expectedParams, $params, $message); + } + + public static function conditionsForTestReplaceNamesWithSchemas() + { + return array( + array('ContestBookstoreContest.PrizeBookId = ?', 'PrizeBookId', 'contest.bookstore_contest.prize_book_id = ?'), // basic case + array('ContestBookstoreContest.PrizeBookId=?', 'PrizeBookId', 'contest.bookstore_contest.prize_book_id=?'), // without spaces + array('ContestBookstoreContest.Id<= ?', 'Id', 'contest.bookstore_contest.id<= ?'), // with non-equal comparator + array('ContestBookstoreContest.BookstoreId LIKE ?', 'BookstoreId', 'contest.bookstore_contest.bookstore_id LIKE ?'), // with SQL keyword separator + array('(ContestBookstoreContest.BookstoreId) LIKE ?', 'BookstoreId', '(contest.bookstore_contest.bookstore_id) LIKE ?'), // with parenthesis + array('(ContestBookstoreContest.Id*1.5)=1', 'Id', '(contest.bookstore_contest.id*1.5)=1') // ignore numbers + ); + } + + /** + * @dataProvider conditionsForTestReplaceNamesWithSchemas + */ + public function testReplaceNamesWithSchemas($origClause, $columnPhpName = false, $modifiedClause) + { + $c = new TestableModelCriteriaWithSchema('bookstore-schemas', 'ContestBookstoreContest'); + $this->doTestReplaceNames($c, ContestBookstoreContestPeer::getTableMap(), $origClause, $columnPhpName = false, $modifiedClause); + } + + public function doTestReplaceNames($c, $tableMap, $origClause, $columnPhpName = false, $modifiedClause) + { + $c->replaceNames($origClause); + $columns = $c->replacedColumns; + if ($columnPhpName) { + $this->assertEquals(array($tableMap->getColumnByPhpName($columnPhpName)), $columns); + } + $this->assertEquals($modifiedClause, $origClause); + } + +} + +class TestableModelCriteriaWithSchema extends ModelCriteria +{ + public $joins = array(); + + public function replaceNames(&$clause) + { + return parent::replaceNames($clause); + } + +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelJoinTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelJoinTest.php index afc89ff6d..eae48b06a 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelJoinTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelJoinTest.php @@ -8,8 +8,8 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; -require_once 'tools/helpers/bookstore/BookstoreDataPopulator.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreDataPopulator.php'; /** * Test class for ModelJoin. @@ -18,68 +18,67 @@ require_once 'tools/helpers/bookstore/BookstoreDataPopulator.php'; * @version $Id: ModelJoinTest.php 1347 2009-12-03 21:06:36Z francois $ * @package runtime.query */ -class ModelJoinTest extends BookstoreTestBase +class ModelJoinTest extends BookstoreTestBase { - public function testTableMap() - { - $join = new ModelJoin(); - $this->assertNull($join->getTableMap(), 'getTableMap() returns null as long as no table map is set'); - - $tmap = new TableMap(); - $tmap->foo = 'bar'; - - $join->setTableMap($tmap); - $this->assertEquals($tmap, $join->getTableMap(), 'getTableMap() returns the TableMap previously set by setTableMap()'); - } + public function testTableMap() + { + $join = new ModelJoin(); + $this->assertNull($join->getTableMap(), 'getTableMap() returns null as long as no table map is set'); - public function testSetRelationMap() - { - $join = new ModelJoin(); - $this->assertNull($join->getRelationMap(), 'getRelationMap() returns null as long as no relation map is set'); - $bookTable = BookPeer::getTableMap(); - $relationMap = $bookTable->getRelation('Author'); - $join->setRelationMap($relationMap); - $this->assertEquals($relationMap, $join->getRelationMap(), 'getRelationMap() returns the RelationMap previously set by setRelationMap()'); - } - - public function testSetRelationMapDefinesJoinColumns() - { - $bookTable = BookPeer::getTableMap(); - $join = new ModelJoin(); - $join->setTableMap($bookTable); - $join->setRelationMap($bookTable->getRelation('Author')); - $this->assertEquals(array(BookPeer::AUTHOR_ID), $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns'); - $this->assertEquals(array(AuthorPeer::ID), $join->getRightColumns(), 'setRelationMap() automatically sets the right columns'); - } + $tmap = new TableMap(); + $tmap->foo = 'bar'; - public function testSetRelationMapLeftAlias() - { - $bookTable = BookPeer::getTableMap(); - $join = new ModelJoin(); - $join->setTableMap($bookTable); - $join->setRelationMap($bookTable->getRelation('Author'), 'b'); - $this->assertEquals(array('b.AUTHOR_ID'), $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns using the left table alias'); - $this->assertEquals(array(AuthorPeer::ID), $join->getRightColumns(), 'setRelationMap() automatically sets the right columns'); - } + $join->setTableMap($tmap); + $this->assertEquals($tmap, $join->getTableMap(), 'getTableMap() returns the TableMap previously set by setTableMap()'); + } - public function testSetRelationMapRightAlias() - { - $bookTable = BookPeer::getTableMap(); - $join = new ModelJoin(); - $join->setTableMap($bookTable); - $join->setRelationMap($bookTable->getRelation('Author'), null, 'a'); - $this->assertEquals(array(BookPeer::AUTHOR_ID), $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns'); - $this->assertEquals(array('a.ID'), $join->getRightColumns(), 'setRelationMap() automatically sets the right columns using the right table alias'); - } + public function testSetRelationMap() + { + $join = new ModelJoin(); + $this->assertNull($join->getRelationMap(), 'getRelationMap() returns null as long as no relation map is set'); + $bookTable = BookPeer::getTableMap(); + $relationMap = $bookTable->getRelation('Author'); + $join->setRelationMap($relationMap); + $this->assertEquals($relationMap, $join->getRelationMap(), 'getRelationMap() returns the RelationMap previously set by setRelationMap()'); + } - public function testSetRelationMapComposite() - { - $table = ReaderFavoritePeer::getTableMap(); - $join = new ModelJoin(); - $join->setTableMap($table); - $join->setRelationMap($table->getRelation('BookOpinion')); - $this->assertEquals(array(ReaderFavoritePeer::BOOK_ID, ReaderFavoritePeer::READER_ID), $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns for composite relationships'); - $this->assertEquals(array(BookOpinionPeer::BOOK_ID, BookOpinionPeer::READER_ID), $join->getRightColumns(), 'setRelationMap() automatically sets the right columns for composite relationships'); - } + public function testSetRelationMapDefinesJoinColumns() + { + $bookTable = BookPeer::getTableMap(); + $join = new ModelJoin(); + $join->setTableMap($bookTable); + $join->setRelationMap($bookTable->getRelation('Author')); + $this->assertEquals(array(BookPeer::AUTHOR_ID), $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns'); + $this->assertEquals(array(AuthorPeer::ID), $join->getRightColumns(), 'setRelationMap() automatically sets the right columns'); + } + public function testSetRelationMapLeftAlias() + { + $bookTable = BookPeer::getTableMap(); + $join = new ModelJoin(); + $join->setTableMap($bookTable); + $join->setRelationMap($bookTable->getRelation('Author'), 'b'); + $this->assertEquals(array('b.author_id'), $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns using the left table alias'); + $this->assertEquals(array(AuthorPeer::ID), $join->getRightColumns(), 'setRelationMap() automatically sets the right columns'); + } + + public function testSetRelationMapRightAlias() + { + $bookTable = BookPeer::getTableMap(); + $join = new ModelJoin(); + $join->setTableMap($bookTable); + $join->setRelationMap($bookTable->getRelation('Author'), null, 'a'); + $this->assertEquals(array(BookPeer::AUTHOR_ID), $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns'); + $this->assertEquals(array('a.id'), $join->getRightColumns(), 'setRelationMap() automatically sets the right columns using the right table alias'); + } + + public function testSetRelationMapComposite() + { + $table = ReaderFavoritePeer::getTableMap(); + $join = new ModelJoin(); + $join->setTableMap($table); + $join->setRelationMap($table->getRelation('BookOpinion')); + $this->assertEquals(array(ReaderFavoritePeer::BOOK_ID, ReaderFavoritePeer::READER_ID), $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns for composite relationships'); + $this->assertEquals(array(BookOpinionPeer::BOOK_ID, BookOpinionPeer::READER_ID), $join->getRightColumns(), 'setRelationMap() automatically sets the right columns for composite relationships'); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelWithTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelWithTest.php index ffe5e8fe6..d94dc3140 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelWithTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/query/ModelWithTest.php @@ -8,8 +8,8 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; -require_once 'tools/helpers/bookstore/BookstoreDataPopulator.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreDataPopulator.php'; /** * Test class for ModelWith. @@ -18,166 +18,221 @@ require_once 'tools/helpers/bookstore/BookstoreDataPopulator.php'; * @version $Id: ModelJoinTest.php 1347 2009-12-03 21:06:36Z francois $ * @package runtime.query */ -class ModelWithTest extends BookstoreTestBase +class ModelWithTest extends BookstoreTestBase { - - public function testModelNameManyToOne() - { - $q = BookQuery::create() - ->joinAuthor(); - $joins = $q->getJoins(); - $join = $joins['Author']; - $with = new ModelWith($join); - $this->assertEquals($with->getModelName(), 'Author', 'A ModelWith computes the model name from the join'); - $this->assertEquals($with->getModelPeerName(), 'AuthorPeer', 'A ModelWith computes the model peer name from the join'); - } - public function testModelNameOneToMany() - { - $q = AuthorQuery::create() - ->joinBook(); - $joins = $q->getJoins(); - $join = $joins['Book']; - $with = new ModelWith($join); - $this->assertEquals($with->getModelName(), 'Book', 'A ModelWith computes the model peer name from the join'); - $this->assertEquals($with->getModelPeerName(), 'BookPeer', 'A ModelWith computes the model peer name from the join'); - } - - public function testModelNameAlias() - { - $q = BookQuery::create() - ->joinAuthor('a'); - $joins = $q->getJoins(); - $join = $joins['a']; - $with = new ModelWith($join); - $this->assertEquals($with->getModelName(), 'Author', 'A ModelWith computes the model peer name from the join'); - $this->assertEquals($with->getModelPeerName(), 'AuthorPeer', 'A ModelWith computes the model peer name from the join'); - } + public function testModelNameManyToOne() + { + $q = BookQuery::create() + ->joinAuthor(); + $joins = $q->getJoins(); + $join = $joins['Author']; + $with = new ModelWith($join); + $this->assertEquals($with->getModelName(), 'Author', 'A ModelWith computes the model name from the join'); + $this->assertEquals($with->getModelPeerName(), 'AuthorPeer', 'A ModelWith computes the model peer name from the join'); + } - public function testRelationManyToOne() - { - $q = BookQuery::create() - ->joinAuthor(); - $joins = $q->getJoins(); - $join = $joins['Author']; - $with = new ModelWith($join); - $this->assertEquals($with->getRelationMethod(), 'setAuthor', 'A ModelWith computes the relation method from the join'); - $this->assertEquals($with->getRelationName(), 'Author', 'A ModelWith computes the relation name from the join'); - $this->assertFalse($with->isAdd(), 'A ModelWith computes the relation cardinality from the join'); - } + public function testModelNameOneToMany() + { + $q = AuthorQuery::create() + ->joinBook(); + $joins = $q->getJoins(); + $join = $joins['Book']; + $with = new ModelWith($join); + $this->assertEquals($with->getModelName(), 'Book', 'A ModelWith computes the model peer name from the join'); + $this->assertEquals($with->getModelPeerName(), 'BookPeer', 'A ModelWith computes the model peer name from the join'); + } - public function testRelationOneToMany() - { - $q = AuthorQuery::create() - ->joinBook(); - $joins = $q->getJoins(); - $join = $joins['Book']; - $with = new ModelWith($join); - $this->assertEquals($with->getRelationMethod(), 'addBook', 'A ModelWith computes the relation method from the join'); - $this->assertEquals($with->getRelationName(), 'Books', 'A ModelWith computes the relation name from the join'); - $this->assertTrue($with->isAdd(), 'A ModelWith computes the relation cardinality from the join'); - } + public function testModelNameAlias() + { + $q = BookQuery::create() + ->joinAuthor('a'); + $joins = $q->getJoins(); + $join = $joins['a']; + $with = new ModelWith($join); + $this->assertEquals($with->getModelName(), 'Author', 'A ModelWith computes the model peer name from the join'); + $this->assertEquals($with->getModelPeerName(), 'AuthorPeer', 'A ModelWith computes the model peer name from the join'); + } - public function testRelationOneToOne() - { - $q = BookstoreEmployeeQuery::create() - ->joinBookstoreEmployeeAccount(); - $joins = $q->getJoins(); - $join = $joins['BookstoreEmployeeAccount']; - $with = new ModelWith($join); - $this->assertEquals($with->getRelationMethod(), 'setBookstoreEmployeeAccount', 'A ModelWith computes the relation method from the join'); - $this->assertEquals($with->getRelationName(), 'BookstoreEmployeeAccount', 'A ModelWith computes the relation name from the join'); - $this->assertFalse($with->isAdd(), 'A ModelWith computes the relation cardinality from the join'); - } - - public function testIsPrimary() - { - $q = AuthorQuery::create() - ->joinBook(); - $joins = $q->getJoins(); - $join = $joins['Book']; - $with = new ModelWith($join); - $this->assertTrue($with->isPrimary(), 'A ModelWith initialized from a primary join is primary'); + public function testRelationManyToOne() + { + $q = BookQuery::create() + ->joinAuthor(); + $joins = $q->getJoins(); + $join = $joins['Author']; + $with = new ModelWith($join); + $this->assertEquals($with->getRelationMethod(), 'setAuthor', 'A ModelWith computes the relation method from the join'); + $this->assertEquals($with->getRelationName(), 'Author', 'A ModelWith computes the relation name from the join'); + $this->assertFalse($with->isAdd(), 'A ModelWith computes the relation cardinality from the join'); + } - $q = BookQuery::create() - ->joinAuthor() - ->joinReview(); - $joins = $q->getJoins(); - $join = $joins['Review']; - $with = new ModelWith($join); - $this->assertTrue($with->isPrimary(), 'A ModelWith initialized from a primary join is primary'); - - $q = AuthorQuery::create() - ->join('Author.Book') - ->join('Book.Publisher'); - $joins = $q->getJoins(); - $join = $joins['Publisher']; - $with = new ModelWith($join); - $this->assertFalse($with->isPrimary(), 'A ModelWith initialized from a non-primary join is not primary'); - } - - public function testGetRelatedClass() - { - $q = AuthorQuery::create() - ->joinBook(); - $joins = $q->getJoins(); - $join = $joins['Book']; - $with = new ModelWith($join); - $this->assertNull($with->getRelatedClass(), 'A ModelWith initialized from a primary join has a null related class'); + public function testRelationOneToMany() + { + $q = AuthorQuery::create() + ->joinBook(); + $joins = $q->getJoins(); + $join = $joins['Book']; + $with = new ModelWith($join); + $this->assertEquals($with->getRelationMethod(), 'addBook', 'A ModelWith computes the relation method from the join'); + $this->assertEquals($with->getRelationName(), 'Books', 'A ModelWith computes the relation name from the join'); + $this->assertTrue($with->isAdd(), 'A ModelWith computes the relation cardinality from the join'); + } - $q = AuthorQuery::create('a') - ->joinBook(); - $joins = $q->getJoins(); - $join = $joins['Book']; - $with = new ModelWith($join); - $this->assertNull($with->getRelatedClass(), 'A ModelWith initialized from a primary join with alias has a null related class'); + public function testRelationOneToOne() + { + $q = BookstoreEmployeeQuery::create() + ->joinBookstoreEmployeeAccount(); + $joins = $q->getJoins(); + $join = $joins['BookstoreEmployeeAccount']; + $with = new ModelWith($join); + $this->assertEquals($with->getRelationMethod(), 'setBookstoreEmployeeAccount', 'A ModelWith computes the relation method from the join'); + $this->assertEquals($with->getRelationName(), 'BookstoreEmployeeAccount', 'A ModelWith computes the relation name from the join'); + $this->assertFalse($with->isAdd(), 'A ModelWith computes the relation cardinality from the join'); + } - $q = AuthorQuery::create() - ->joinBook('b'); - $joins = $q->getJoins(); - $join = $joins['b']; - $with = new ModelWith($join); - $this->assertNull($with->getRelatedClass(), 'A ModelWith initialized from a primary join with alias has a null related class'); - - $q = AuthorQuery::create() - ->join('Author.Book') - ->join('Book.Publisher'); - $joins = $q->getJoins(); - $join = $joins['Publisher']; - $with = new ModelWith($join); - $this->assertEquals($with->getRelatedClass(), 'Book', 'A ModelWith uses the previous join relation name as related class'); + public function testIsPrimary() + { + $q = AuthorQuery::create() + ->joinBook(); + $joins = $q->getJoins(); + $join = $joins['Book']; + $with = new ModelWith($join); + $this->assertTrue($with->isPrimary(), 'A ModelWith initialized from a primary join is primary'); - $q = ReviewQuery::create() - ->join('Review.Book') - ->join('Book.Author') - ->join('Book.Publisher'); - $joins = $q->getJoins(); - $join = $joins['Publisher']; - $with = new ModelWith($join); - $this->assertEquals($with->getRelatedClass(), 'Book', 'A ModelWith uses the previous join relation name as related class'); + $q = BookQuery::create() + ->joinAuthor() + ->joinReview(); + $joins = $q->getJoins(); + $join = $joins['Review']; + $with = new ModelWith($join); + $this->assertTrue($with->isPrimary(), 'A ModelWith initialized from a primary join is primary'); - $q = ReviewQuery::create() - ->join('Review.Book') - ->join('Book.BookOpinion') - ->join('BookOpinion.BookReader'); - $joins = $q->getJoins(); - $join = $joins['BookOpinion']; - $with = new ModelWith($join); - $this->assertEquals($with->getRelatedClass(), 'Book', 'A ModelWith uses the previous join relation name as related class'); - $join = $joins['BookReader']; - $with = new ModelWith($join); - $this->assertEquals($with->getRelatedClass(), 'BookOpinion', 'A ModelWith uses the previous join relation name as related class'); + $q = AuthorQuery::create() + ->join('Author.Book') + ->join('Book.Publisher'); + $joins = $q->getJoins(); + $join = $joins['Publisher']; + $with = new ModelWith($join); + $this->assertFalse($with->isPrimary(), 'A ModelWith initialized from a non-primary join is not primary'); + } - $q = BookReaderQuery::create() - ->join('BookReader.BookOpinion') - ->join('BookOpinion.Book') - ->join('Book.Author'); - $joins = $q->getJoins(); - $join = $joins['Book']; - $with = new ModelWith($join); - $this->assertEquals($with->getRelatedClass(), 'BookOpinion', 'A ModelWith uses the previous join relation name as related class'); - $join = $joins['Author']; - $with = new ModelWith($join); - $this->assertEquals($with->getRelatedClass(), 'Book', 'A ModelWith uses the previous join relation name as related class'); - } + public function testGetLeftPhpName() + { + $q = AuthorQuery::create() + ->joinBook(); + $joins = $q->getJoins(); + $join = $joins['Book']; + $with = new ModelWith($join); + $this->assertNull($with->getLeftPhpName(), 'A ModelWith initialized from a primary join has a null left phpName'); + + $q = AuthorQuery::create('a') + ->joinBook(); + $joins = $q->getJoins(); + $join = $joins['Book']; + $with = new ModelWith($join); + $this->assertNull($with->getLeftPhpName(), 'A ModelWith initialized from a primary join with alias has a null left phpName'); + + $q = AuthorQuery::create() + ->joinBook('b'); + $joins = $q->getJoins(); + $join = $joins['b']; + $with = new ModelWith($join); + $this->assertNull($with->getLeftPhpName(), 'A ModelWith initialized from a primary join with alias has a null left phpName'); + + $q = AuthorQuery::create() + ->join('Author.Book') + ->join('Book.Publisher'); + $joins = $q->getJoins(); + $join = $joins['Publisher']; + $with = new ModelWith($join); + $this->assertEquals('Book', $with->getLeftPhpName(), 'A ModelWith uses the previous join relation name as left phpName'); + + $q = ReviewQuery::create() + ->join('Review.Book') + ->join('Book.Author') + ->join('Book.Publisher'); + $joins = $q->getJoins(); + $join = $joins['Publisher']; + $with = new ModelWith($join); + $this->assertEquals('Book', $with->getLeftPhpName(), 'A ModelWith uses the previous join relation name as left phpName'); + + $q = ReviewQuery::create() + ->join('Review.Book') + ->join('Book.BookOpinion') + ->join('BookOpinion.BookReader'); + $joins = $q->getJoins(); + $join = $joins['BookOpinion']; + $with = new ModelWith($join); + $this->assertEquals('Book', $with->getLeftPhpName(), 'A ModelWith uses the previous join relation name as left phpName'); + $join = $joins['BookReader']; + $with = new ModelWith($join); + $this->assertEquals('BookOpinion', $with->getLeftPhpName(), 'A ModelWith uses the previous join relation name as left phpName'); + + $q = BookReaderQuery::create() + ->join('BookReader.BookOpinion') + ->join('BookOpinion.Book') + ->join('Book.Author'); + $joins = $q->getJoins(); + $join = $joins['Book']; + $with = new ModelWith($join); + $this->assertEquals('BookOpinion', $with->getLeftPhpName(), 'A ModelWith uses the previous join relation name as related class'); + $join = $joins['Author']; + $with = new ModelWith($join); + $this->assertEquals('Book', $with->getLeftPhpName(), 'A ModelWith uses the previous join relation name as left phpName'); + + $q = BookSummaryQuery::create() + ->join('BookSummary.SummarizedBook') + ->join('SummarizedBook.Author'); + $joins = $q->getJoins(); + $join = $joins['Author']; + $with = new ModelWith($join); + $this->assertEquals('SummarizedBook', $with->getLeftPhpName(), 'A ModelWith uses the previous join relation name as left phpName'); + } + + public function testGetRightPhpName() + { + $q = AuthorQuery::create() + ->joinBook(); + $joins = $q->getJoins(); + $join = $joins['Book']; + $with = new ModelWith($join); + $this->assertEquals('Book', $with->getRightPhpName(), 'A ModelWith initialized from a primary join has a right phpName'); + + $q = AuthorQuery::create('a') + ->joinBook(); + $joins = $q->getJoins(); + $join = $joins['Book']; + $with = new ModelWith($join); + $this->assertEquals('Book', $with->getRightPhpName(), 'A ModelWith initialized from a primary join with alias has a right phpName'); + + $q = AuthorQuery::create() + ->joinBook('b'); + $joins = $q->getJoins(); + $join = $joins['b']; + $with = new ModelWith($join); + $this->assertEquals('b', $with->getRightPhpName(), 'A ModelWith initialized from a primary join with alias uses the alias as right phpName'); + + $q = AuthorQuery::create() + ->join('Author.Book') + ->join('Book.Publisher'); + $joins = $q->getJoins(); + $join = $joins['Publisher']; + $with = new ModelWith($join); + $this->assertEquals('Publisher', $with->getRightPhpName(), 'A ModelWith has a right phpName even when there are previous joins'); + + $q = BookSummaryQuery::create() + ->join('BookSummary.SummarizedBook'); + $joins = $q->getJoins(); + $join = $joins['SummarizedBook']; + $with = new ModelWith($join); + $this->assertEquals('SummarizedBook', $with->getRightPhpName(), 'A ModelWith uses the relation name rather than the class phpName when it exists'); + + $q = BookSummaryQuery::create() + ->join('BookSummary.SummarizedBook') + ->join('SummarizedBook.Author'); + $joins = $q->getJoins(); + $join = $joins['Author']; + $with = new ModelWith($join); + $this->assertEquals('Author', $with->getRightPhpName(), 'A ModelWith has a right phpName even when there are previous joins with custom relation names'); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/query/PropelQueryTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/query/PropelQueryTest.php index 5ef619da1..ce1fe2eaa 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/query/PropelQueryTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/query/PropelQueryTest.php @@ -8,8 +8,8 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; -require_once 'tools/helpers/bookstore/BookstoreDataPopulator.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreDataPopulator.php'; /** * Test class for PropelQuery @@ -20,44 +20,136 @@ require_once 'tools/helpers/bookstore/BookstoreDataPopulator.php'; */ class PropelQueryTest extends BookstoreTestBase { - public function testFrom() - { - $q = PropelQuery::from('Book'); - $expected = new BookQuery(); - $this->assertEquals($expected, $q, 'from() returns a Model query instance based on the model name'); + public function testFrom() + { + $q = PropelQuery::from('Book'); + $expected = new BookQuery(); + $this->assertEquals($expected, $q, 'from() returns a Model query instance based on the model name'); - $q = PropelQuery::from('Book b'); - $expected = new BookQuery(); - $expected->setModelAlias('b'); - $this->assertEquals($expected, $q, 'from() sets the model alias if found after the blank'); + $q = PropelQuery::from('Book b'); + $expected = new BookQuery(); + $expected->setModelAlias('b'); + $this->assertEquals($expected, $q, 'from() sets the model alias if found after the blank'); - $q = PropelQuery::from('myBook'); - $expected = new myBookQuery(); - $this->assertEquals($expected, $q, 'from() can find custom query classes'); + $q = PropelQuery::from('myBook'); + $expected = new myBookQuery(); + $this->assertEquals($expected, $q, 'from() can find custom query classes'); - try { - $q = PropelQuery::from('Foo'); - $this->fail('PropelQuery::from() throws an exception when called on a non-existing query class'); - } catch (PropelException $e) { - $this->assertTrue(true, 'PropelQuery::from() throws an exception when called on a non-existing query class'); - } - } - - public function testQuery() - { - BookstoreDataPopulator::depopulate(); - BookstoreDataPopulator::populate(); - - $book = PropelQuery::from('Book b') - ->where('b.Title like ?', 'Don%') - ->orderBy('b.ISBN', 'desc') - ->findOne(); - $this->assertTrue($book instanceof Book); - $this->assertEquals('Don Juan', $book->getTitle()); - - } + try { + $q = PropelQuery::from('Foo'); + $this->fail('PropelQuery::from() throws an exception when called on a non-existing query class'); + } catch (PropelException $e) { + $this->assertTrue(true, 'PropelQuery::from() throws an exception when called on a non-existing query class'); + } + } + + public function testQuery() + { + BookstoreDataPopulator::depopulate(); + BookstoreDataPopulator::populate(); + + $book = PropelQuery::from('Book b') + ->where('b.Title like ?', 'Don%') + ->orderBy('b.ISBN', 'desc') + ->findOne(); + $this->assertTrue($book instanceof Book); + $this->assertEquals('Don Juan', $book->getTitle()); + + } + + /** + * testFilterById + * + * Various test for filterById functions + * Id's are autoincrement so we have to use a Select to get current ID's + * + */ + public function testFilterById() + { + // find by single id + $book = PropelQuery::from('Book b') + ->where('b.Title like ?', 'Don%') + ->orderBy('b.ISBN', 'desc') + ->findOne(); + + $c = BookQuery::create()->filterById($book->getId()); + + $book2 = $c->findOne(); + + $this->assertTrue($book2 instanceof Book); + $this->assertEquals('Don Juan', $book2->getTitle()); + + //find range + $booksAll = PropelQuery::from('Book b') + ->orderBy('b.ID', 'asc') + ->find(); + + $booksIn = BookQuery::create() + ->filterById(array($booksAll[1]->getId(), $booksAll[2]->getId())) + ->find(); + + $this->assertTrue($booksIn[0] == $booksAll[1]); + $this->assertTrue($booksIn[1] == $booksAll[2]); + + // filter by min value with greater equal + $booksIn = null; + + $booksIn = BookQuery::create() + ->filterById( + array('min' => $booksAll[2]->getId())) + ->find(); + + $this->assertTrue($booksIn[1] == $booksAll[3]); + + // filter by max value with less equal + $booksIn = null; + + $booksIn = BookQuery::create() + ->filterById( + array('max' => $booksAll[1]->getId()) ) + ->find(); + + $this->assertTrue($booksIn[1] == $booksAll[1]); + + // check backwards compatibility: + // SELECT FROM `book` WHERE book.id IN (:p1,:p2) + // must be the same as + // SELECT FROM `book` WHERE (book.id>=:p1 AND book.id<=:p2) + + $minMax = BookQuery::create() + ->filterById( + array('min' => $booksAll[1]->getId(), + 'max' => $booksAll[2]->getId()) + ) + ->find(); + + $In = BookQuery::create() + ->filterById( + array($booksAll[1]->getId(), + $booksAll[2]->getId()) + ) + ->find(); + + $this->assertTrue($minMax[0] === $In[0]); + $this->assertTrue(count($minMax->getData()) === count($In->getData())); + } + + public function testInstancePool() + { + $object = new Table6(); + $object->setTitle('test'); + $object->save(); + $key = $object->getId(); + + $this->assertSame($object, Table6Peer::getInstanceFromPool($key)); + Table6Peer::removeInstanceFromPool($object); + $this->assertNull(Table6Peer::getInstanceFromPool($key)); + + $object = Table6Query::create()->findPk($key); + $this->assertSame($object, Table6Peer::getInstanceFromPool($key)); + } } class myBookQuery extends BookQuery { -} \ No newline at end of file +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/query/SubQueryTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/query/SubQueryTest.php new file mode 100644 index 000000000..cb45b868f --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/query/SubQueryTest.php @@ -0,0 +1,246 @@ +assertEquals($expectedSql, $result, $message); + $this->assertEquals($expectedParams, $params, $message); + } + + public function testSubQueryExplicit() + { + $subCriteria = new BookQuery(); + BookPeer::addSelectColumns($subCriteria); + $subCriteria->orderByTitle(Criteria::ASC); + + $c = new BookQuery(); + BookPeer::addSelectColumns($c, 'subCriteriaAlias'); + $c->addSelectQuery($subCriteria, 'subCriteriaAlias', false); + $c->groupBy('subCriteriaAlias.AuthorId'); + + $sql = "SELECT subCriteriaAlias.id, subCriteriaAlias.title, subCriteriaAlias.isbn, subCriteriaAlias.price, subCriteriaAlias.publisher_id, subCriteriaAlias.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` ORDER BY book.title ASC) AS subCriteriaAlias GROUP BY subCriteriaAlias.author_id"; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'addSubQueryCriteriaInFrom() combines two queries successfully'); + } + + public function testSubQueryWithoutSelect() + { + $subCriteria = new BookQuery(); + // no addSelectColumns() + + $c = new BookQuery(); + $c->addSelectQuery($subCriteria, 'subCriteriaAlias'); + $c->filterByPrice(20, Criteria::LESS_THAN); + + $sql = "SELECT subCriteriaAlias.id, subCriteriaAlias.title, subCriteriaAlias.isbn, subCriteriaAlias.price, subCriteriaAlias.publisher_id, subCriteriaAlias.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book`) AS subCriteriaAlias WHERE subCriteriaAlias.price<:p1"; + $params = array( + array('table' => 'book', 'column' => 'price', 'value' => 20), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'addSelectQuery() adds select columns if none given'); + } + + public function testSubQueryWithoutAlias() + { + $subCriteria = new BookQuery(); + $subCriteria->addSelfSelectColumns(); + + $c = new BookQuery(); + $c->addSelectQuery($subCriteria); // no alias + $c->filterByPrice(20, Criteria::LESS_THAN); + + $sql = "SELECT alias_1.id, alias_1.title, alias_1.isbn, alias_1.price, alias_1.publisher_id, alias_1.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book`) AS alias_1 WHERE alias_1.price<:p1"; + $params = array( + array('table' => 'book', 'column' => 'price', 'value' => 20), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'addSelectQuery() forges a unique alias if none is given'); + } + + public function testSubQueryWithoutAliasAndSelect() + { + $subCriteria = new BookQuery(); + // no select + + $c = new BookQuery(); + $c->addSelectQuery($subCriteria); // no alias + $c->filterByPrice(20, Criteria::LESS_THAN); + + $sql = "SELECT alias_1.id, alias_1.title, alias_1.isbn, alias_1.price, alias_1.publisher_id, alias_1.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book`) AS alias_1 WHERE alias_1.price<:p1"; + $params = array( + array('table' => 'book', 'column' => 'price', 'value' => 20), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'addSelectQuery() forges a unique alias and adds select columns by default'); + } + + public function testSubQueryWithoutAliasSeveral() + { + $c1 = new BookQuery(); + $c1->filterByPrice(10, Criteria::GREATER_THAN); + + $c2 = new BookQuery(); + $c2->filterByPrice(20, Criteria::LESS_THAN); + + $c3 = new BookQuery(); + $c3->addSelectQuery($c1); // no alias + $c3->addSelectQuery($c2); // no alias + $c3->filterByTitle('War%'); + + $sql = "SELECT alias_1.id, alias_1.title, alias_1.isbn, alias_1.price, alias_1.publisher_id, alias_1.author_id, alias_2.id, alias_2.title, alias_2.isbn, alias_2.price, alias_2.publisher_id, alias_2.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.price>:p2) AS alias_1, (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.price<:p3) AS alias_2 WHERE alias_2.title LIKE :p1"; + $params = array( + array('table' => 'book', 'column' => 'title', 'value' => 'War%'), + array('table' => 'book', 'column' => 'price', 'value' => 10), + array('table' => 'book', 'column' => 'price', 'value' => 20), + ); + $this->assertCriteriaTranslation($c3, $sql, $params, 'addSelectQuery() forges a unique alias if none is given'); + } + + public function testSubQueryWithoutAliasRecursive() + { + $c1 = new BookQuery(); + + $c2 = new BookQuery(); + $c2->addSelectQuery($c1); // no alias + $c2->filterByPrice(20, Criteria::LESS_THAN); + + $c3 = new BookQuery(); + $c3->addSelectQuery($c2); // no alias + $c3->filterByTitle('War%'); + + $sql = "SELECT alias_2.id, alias_2.title, alias_2.isbn, alias_2.price, alias_2.publisher_id, alias_2.author_id FROM (SELECT alias_1.id, alias_1.title, alias_1.isbn, alias_1.price, alias_1.publisher_id, alias_1.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book`) AS alias_1 WHERE alias_1.price<:p2) AS alias_2 WHERE alias_2.title LIKE :p1"; + $params = array( + array('table' => 'book', 'column' => 'title', 'value' => 'War%'), + array('table' => 'book', 'column' => 'price', 'value' => 20), + ); + $this->assertCriteriaTranslation($c3, $sql, $params, 'addSelectQuery() forges a unique alias if none is given'); + } + + public function testSubQueryWithJoin() + { + $c1 = BookQuery::create() + ->useAuthorQuery() + ->filterByLastName('Rowling') + ->endUse(); + + $c2 = new BookQuery(); + $c2->addSelectQuery($c1, 'subQuery'); + $c2->filterByPrice(20, Criteria::LESS_THAN); + + $sql = "SELECT subQuery.id, subQuery.title, subQuery.isbn, subQuery.price, subQuery.publisher_id, subQuery.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` LEFT JOIN `author` ON (book.author_id=author.id) WHERE author.last_name=:p2) AS subQuery WHERE subQuery.price<:p1"; + $params = array( + array('table' => 'book', 'column' => 'price', 'value' => 20), + array('table' => 'author', 'column' => 'last_name', 'value' => 'Rowling'), + ); + $this->assertCriteriaTranslation($c2, $sql, $params, 'addSelectQuery() can add a select query with a join'); + } + + public function testSubQueryParameters() + { + $subCriteria = new BookQuery(); + $subCriteria->filterByAuthorId(123); + + $c = new BookQuery(); + $c->addSelectQuery($subCriteria, 'subCriteriaAlias'); + // and use filterByPrice method! + $c->filterByPrice(20, Criteria::LESS_THAN); + + $sql = "SELECT subCriteriaAlias.id, subCriteriaAlias.title, subCriteriaAlias.isbn, subCriteriaAlias.price, subCriteriaAlias.publisher_id, subCriteriaAlias.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.author_id=:p2) AS subCriteriaAlias WHERE subCriteriaAlias.price<:p1"; + $params = array( + array('table' => 'book', 'column' => 'price', 'value' => 20), + array('table' => 'book', 'column' => 'author_id', 'value' => 123), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'addSubQueryCriteriaInFrom() combines two queries successfully'); + } + + public function testSubQueryRecursive() + { + // sort the books (on date, if equal continue with id), filtered by a publisher + $sortedBookQuery = new BookQuery(); + $sortedBookQuery->addSelfSelectColumns(); + $sortedBookQuery->filterByPublisherId(123); + $sortedBookQuery->orderByTitle(Criteria::DESC); + $sortedBookQuery->orderById(Criteria::DESC); + + // group by author, after sorting! + $latestBookQuery = new BookQuery(); + $latestBookQuery->addSelectQuery($sortedBookQuery, 'sortedBookQuery'); + $latestBookQuery->groupBy('sortedBookQuery.AuthorId'); + + // filter from these latest books, find the ones cheaper than 12 euro + $c = new BookQuery(); + $c->addSelectQuery($latestBookQuery, 'latestBookQuery'); + $c->filterByPrice(12, Criteria::LESS_THAN); + + $sql = "SELECT latestBookQuery.id, latestBookQuery.title, latestBookQuery.isbn, latestBookQuery.price, latestBookQuery.publisher_id, latestBookQuery.author_id ". + "FROM (SELECT sortedBookQuery.id, sortedBookQuery.title, sortedBookQuery.isbn, sortedBookQuery.price, sortedBookQuery.publisher_id, sortedBookQuery.author_id ". + "FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id ". + "FROM `book` ". + "WHERE book.publisher_id=:p2 ". + "ORDER BY book.title DESC,book.id DESC) AS sortedBookQuery ". + "GROUP BY sortedBookQuery.author_id) AS latestBookQuery ". + "WHERE latestBookQuery.price<:p1"; + $params = array( + array('table' => 'book', 'column' => 'price', 'value' => 12), + array('table' => 'book', 'column' => 'publisher_id', 'value' => 123), + ); + $this->assertCriteriaTranslation($c, $sql, $params, 'addSubQueryCriteriaInFrom() combines two queries succesfully'); + } + + public function testSubQueryWithSelectColumns() + { + $subCriteria = new BookQuery(); + + $c = new TestableBookQuery(); + $c->addSelectQuery($subCriteria, 'alias1', false); + $c->select(array('alias1.Id')); + $c->configureSelectColumns(); + + $sql = "SELECT alias1.id AS `alias1.Id` FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book`) AS alias1"; + $params = array(); + $this->assertCriteriaTranslation($c, $sql, $params, 'addSelectQuery() forges a unique alias and adds select columns by default'); + } + + public function testSubQueryCount() + { + $subCriteria = new BookQuery(); + + $c = new BookQuery(); + $c->addSelectQuery($subCriteria, 'subCriteriaAlias'); + $c->filterByPrice(20, Criteria::LESS_THAN); + $nbBooks = $c->count(); + + $query = Propel::getConnection()->getLastExecutedQuery(); + + $sql = "SELECT COUNT(*) FROM (SELECT subCriteriaAlias.id, subCriteriaAlias.title, subCriteriaAlias.isbn, subCriteriaAlias.price, subCriteriaAlias.publisher_id, subCriteriaAlias.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book`) AS subCriteriaAlias WHERE subCriteriaAlias.price<20) propelmatch4cnt"; + + $this->assertEquals($sql, $query, 'addSelectQuery() doCount is defined as complexQuery'); + } +} + +class TestableBookQuery extends BookQuery +{ + public function configureSelectColumns() + { + return parent::configureSelectColumns(); + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/util/BasePeerExceptionsTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/util/BasePeerExceptionsTest.php index e3d56f2a6..cffdd7eeb 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/util/BasePeerExceptionsTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/util/BasePeerExceptionsTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; /** * Tests the exceptions thrown by the BasePeer classes. @@ -20,75 +20,75 @@ require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; class BasePeerExceptionsTest extends BookstoreTestBase { - public function testDoSelect() - { - try { - $c = new Criteria(); - $c->add(BookPeer::ID, 12, ' BAD SQL'); - BookPeer::addSelectColumns($c); - BasePeer::doSelect($c); - } catch (PropelException $e) { - $this->assertContains('[SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.ID BAD SQL:p1]', $e->getMessage(), 'SQL query is written in the exception message'); - } - } + public function testDoSelect() + { + try { + $c = new Criteria(); + $c->add(BookPeer::ID, 12, ' BAD SQL'); + BookPeer::addSelectColumns($c); + BasePeer::doSelect($c); + } catch (PropelException $e) { + $this->assertContains('[SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book` WHERE book.id BAD SQL:p1]', $e->getMessage(), 'SQL query is written in the exception message'); + } + } - public function testDoCount() - { - try { - $c = new Criteria(); - $c->add(BookPeer::ID, 12, ' BAD SQL'); - BookPeer::addSelectColumns($c); - BasePeer::doCount($c); - } catch (PropelException $e) { - $this->assertContains('[SELECT COUNT(*) FROM `book` WHERE book.ID BAD SQL:p1]', $e->getMessage(), 'SQL query is written in the exception message'); - } - } + public function testDoCount() + { + try { + $c = new Criteria(); + $c->add(BookPeer::ID, 12, ' BAD SQL'); + BookPeer::addSelectColumns($c); + BasePeer::doCount($c); + } catch (PropelException $e) { + $this->assertContains('[SELECT COUNT(*) FROM `book` WHERE book.id BAD SQL:p1]', $e->getMessage(), 'SQL query is written in the exception message'); + } + } + + public function testDoDelete() + { + try { + $c = new Criteria(); + $c->setPrimaryTableName(BookPeer::TABLE_NAME); + $c->add(BookPeer::ID, 12, ' BAD SQL'); + BasePeer::doDelete($c, Propel::getConnection()); + } catch (PropelException $e) { + $this->assertContains('[DELETE FROM `book` WHERE book.id BAD SQL:p1]', $e->getMessage(), 'SQL query is written in the exception message'); + } + } + + public function testDoDeleteAll() + { + try { + BasePeer::doDeleteAll('BAD TABLE', Propel::getConnection()); + } catch (PropelException $e) { + $this->assertContains('[DELETE FROM `BAD` `TABLE`]', $e->getMessage(), 'SQL query is written in the exception message'); + } + } + + public function testDoUpdate() + { + try { + $c1 = new Criteria(); + $c1->setPrimaryTableName(BookPeer::TABLE_NAME); + $c1->add(BookPeer::ID, 12, ' BAD SQL'); + $c2 = new Criteria(); + $c2->add(BookPeer::TITLE, 'Foo'); + BasePeer::doUpdate($c1, $c2, Propel::getConnection()); + } catch (PropelException $e) { + $this->assertContains('[UPDATE `book` SET `title`=:p1 WHERE book.id BAD SQL:p2]', $e->getMessage(), 'SQL query is written in the exception message'); + } + } + + public function testDoInsert() + { + try { + $c = new Criteria(); + $c->setPrimaryTableName(BookPeer::TABLE_NAME); + $c->add(BookPeer::AUTHOR_ID, 'lkhlkhj'); + BasePeer::doInsert($c, Propel::getConnection()); + } catch (PropelException $e) { + $this->assertContains('[INSERT INTO `book` (`author_id`) VALUES (:p1)]', $e->getMessage(), 'SQL query is written in the exception message'); + } + } - public function testDoDelete() - { - try { - $c = new Criteria(); - $c->setPrimaryTableName(BookPeer::TABLE_NAME); - $c->add(BookPeer::ID, 12, ' BAD SQL'); - BasePeer::doDelete($c, Propel::getConnection()); - } catch (PropelException $e) { - $this->assertContains('[DELETE FROM `book` WHERE book.ID BAD SQL:p1]', $e->getMessage(), 'SQL query is written in the exception message'); - } - } - - public function testDoDeleteAll() - { - try { - BasePeer::doDeleteAll('BAD TABLE', Propel::getConnection()); - } catch (PropelException $e) { - $this->assertContains('[DELETE FROM `BAD` `TABLE`]', $e->getMessage(), 'SQL query is written in the exception message'); - } - } - - public function testDoUpdate() - { - try { - $c1 = new Criteria(); - $c1->setPrimaryTableName(BookPeer::TABLE_NAME); - $c1->add(BookPeer::ID, 12, ' BAD SQL'); - $c2 = new Criteria(); - $c2->add(BookPeer::TITLE, 'Foo'); - BasePeer::doUpdate($c1, $c2, Propel::getConnection()); - } catch (PropelException $e) { - $this->assertContains('[UPDATE `book` SET `TITLE`=:p1 WHERE book.ID BAD SQL:p2]', $e->getMessage(), 'SQL query is written in the exception message'); - } - } - - public function testDoInsert() - { - try { - $c = new Criteria(); - $c->setPrimaryTableName(BookPeer::TABLE_NAME); - $c->add(BookPeer::AUTHOR_ID, 'lkhlkhj'); - BasePeer::doInsert($c, Propel::getConnection()); - } catch (PropelException $e) { - $this->assertContains('[INSERT INTO `book` (`AUTHOR_ID`) VALUES (:p1)]', $e->getMessage(), 'SQL query is written in the exception message'); - } - } - } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/util/BasePeerTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/util/BasePeerTest.php index cb8772ee5..7a2827424 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/util/BasePeerTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/util/BasePeerTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreTestBase.php'; /** * Tests the BasePeer classes. @@ -20,394 +20,335 @@ require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; class BasePeerTest extends BookstoreTestBase { - /** - * @link http://propel.phpdb.org/trac/ticket/425 - */ - public function testMultipleFunctionInCriteria() - { - $db = Propel::getDB(BookPeer::DATABASE_NAME); - try { - $c = new Criteria(); - $c->setDistinct(); - if ($db instanceof DBPostgres) { - $c->addSelectColumn("substring(".BookPeer::TITLE." from position('Potter' in ".BookPeer::TITLE.")) AS col"); - } else { - $this->markTestSkipped(); - } - $stmt = BookPeer::doSelectStmt( $c ); - } catch (PropelException $x) { - $this->fail("Paring of nested functions failed: " . $x->getMessage()); - } - } + /** + * @link http://trac.propelorm.org/ticket/425 + */ + public function testMultipleFunctionInCriteria() + { + $db = Propel::getDB(BookPeer::DATABASE_NAME); + try { + $c = new Criteria(); + $c->setDistinct(); + if ($db instanceof DBPostgres) { + $c->addSelectColumn("substring(".BookPeer::TITLE." from position('Potter' in ".BookPeer::TITLE.")) AS col"); + } else { + $this->markTestSkipped(); + } + $stmt = BookPeer::doSelectStmt( $c ); + } catch (PropelException $x) { + $this->fail("Paring of nested functions failed: " . $x->getMessage()); + } + } - public function testNeedsSelectAliases() - { - $c = new Criteria(); - $this->assertFalse(BasePeer::needsSelectAliases($c), 'Empty Criterias dont need aliases'); + public function testNeedsSelectAliases() + { + $c = new Criteria(); + $this->assertFalse(BasePeer::needsSelectAliases($c), 'Empty Criterias don\'t need aliases'); - $c = new Criteria(); - $c->addSelectColumn(BookPeer::ID); - $c->addSelectColumn(BookPeer::TITLE); - $this->assertFalse(BasePeer::needsSelectAliases($c), 'Criterias with distinct column names dont need aliases'); - - $c = new Criteria(); - BookPeer::addSelectColumns($c); - $this->assertFalse(BasePeer::needsSelectAliases($c), 'Criterias with only the columns of a model dont need aliases'); + $c = new Criteria(); + $c->addSelectColumn(BookPeer::ID); + $c->addSelectColumn(BookPeer::TITLE); + $this->assertFalse(BasePeer::needsSelectAliases($c), 'Criterias with distinct column names don\'t need aliases'); - $c = new Criteria(); - $c->addSelectColumn(BookPeer::ID); - $c->addSelectColumn(AuthorPeer::ID); - $this->assertTrue(BasePeer::needsSelectAliases($c), 'Criterias with common column names do need aliases'); - } - - public function testTurnSelectColumnsToAliases() - { - $c1 = new Criteria(); - $c1->addSelectColumn(BookPeer::ID); - BasePeer::turnSelectColumnsToAliases($c1); - - $c2 = new Criteria(); - $c2->addAsColumn('book_ID', BookPeer::ID); - $this->assertTrue($c1->equals($c2)); - } + $c = new Criteria(); + BookPeer::addSelectColumns($c); + $this->assertFalse(BasePeer::needsSelectAliases($c), 'Criterias with only the columns of a model don\'t need aliases'); - public function testTurnSelectColumnsToAliasesPreservesAliases() - { - $c1 = new Criteria(); - $c1->addSelectColumn(BookPeer::ID); - $c1->addAsColumn('foo', BookPeer::TITLE); - BasePeer::turnSelectColumnsToAliases($c1); - - $c2 = new Criteria(); - $c2->addAsColumn('book_ID', BookPeer::ID); - $c2->addAsColumn('foo', BookPeer::TITLE); - $this->assertTrue($c1->equals($c2)); - } + $c = new Criteria(); + $c->addSelectColumn(BookPeer::ID); + $c->addSelectColumn(AuthorPeer::ID); + $this->assertTrue(BasePeer::needsSelectAliases($c), 'Criterias with common column names do need aliases'); + } - public function testTurnSelectColumnsToAliasesExisting() - { - $c1 = new Criteria(); - $c1->addSelectColumn(BookPeer::ID); - $c1->addAsColumn('book_ID', BookPeer::ID); - BasePeer::turnSelectColumnsToAliases($c1); - - $c2 = new Criteria(); - $c2->addAsColumn('book_ID_1', BookPeer::ID); - $c2->addAsColumn('book_ID', BookPeer::ID); - $this->assertTrue($c1->equals($c2)); - } + public function testDoCountDuplicateColumnName() + { + $con = Propel::getConnection(); + $c = new Criteria(); + $c->addSelectColumn(BookPeer::ID); + $c->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID); + $c->addSelectColumn(AuthorPeer::ID); + $c->setLimit(3); + try { + $count = BasePeer::doCount($c, $con); + } catch (Exception $e) { + $this->fail('doCount() cannot deal with a criteria selecting duplicate column names '); + } + } - public function testTurnSelectColumnsToAliasesDuplicate() - { - $c1 = new Criteria(); - $c1->addSelectColumn(BookPeer::ID); - $c1->addSelectColumn(BookPeer::ID); - BasePeer::turnSelectColumnsToAliases($c1); - - $c2 = new Criteria(); - $c2->addAsColumn('book_ID', BookPeer::ID); - $c2->addAsColumn('book_ID_1', BookPeer::ID); - $this->assertTrue($c1->equals($c2)); - } - - public function testDoCountDuplicateColumnName() - { - $con = Propel::getConnection(); - $c = new Criteria(); - $c->addSelectColumn(BookPeer::ID); - $c->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID); - $c->addSelectColumn(AuthorPeer::ID); - $c->setLimit(3); - try { - $count = BasePeer::doCount($c, $con); - } catch (Exception $e) { - $this->fail('doCount() cannot deal with a criteria selecting duplicate column names '); - } - } - - public function testCreateSelectSqlPart() - { - $c = new Criteria(); - $c->addSelectColumn(BookPeer::ID); - $c->addAsColumn('book_ID', BookPeer::ID); - $fromClause = array(); - $selectSql = BasePeer::createSelectSqlPart($c, $fromClause); - $this->assertEquals('SELECT book.ID, book.ID AS book_ID', $selectSql, 'createSelectSqlPart() returns a SQL SELECT clause with both select and as columns'); - $this->assertEquals(array('book'), $fromClause, 'createSelectSqlPart() adds the tables from the select columns to the from clause'); - } + public function testBigIntIgnoreCaseOrderBy() + { + BookstorePeer::doDeleteAll(); - public function testCreateSelectSqlPartSelectModifier() - { - $c = new Criteria(); - $c->addSelectColumn(BookPeer::ID); - $c->addAsColumn('book_ID', BookPeer::ID); - $c->setDistinct(); - $fromClause = array(); - $selectSql = BasePeer::createSelectSqlPart($c, $fromClause); - $this->assertEquals('SELECT DISTINCT book.ID, book.ID AS book_ID', $selectSql, 'createSelectSqlPart() includes the select modifiers in the SELECT clause'); - $this->assertEquals(array('book'), $fromClause, 'createSelectSqlPart() adds the tables from the select columns to the from clause'); - } + // Some sample data + $b = new Bookstore(); + $b->setStoreName("SortTest1")->setPopulationServed(2000)->save(); - public function testCreateSelectSqlPartAliasAll() - { - $c = new Criteria(); - $c->addSelectColumn(BookPeer::ID); - $c->addAsColumn('book_ID', BookPeer::ID); - $fromClause = array(); - $selectSql = BasePeer::createSelectSqlPart($c, $fromClause, true); - $this->assertEquals('SELECT book.ID AS book_ID_1, book.ID AS book_ID', $selectSql, 'createSelectSqlPart() aliases all columns if passed true as last parameter'); - $this->assertEquals(array(), $fromClause, 'createSelectSqlPart() does not add the tables from an all-aliased list of select columns'); - } - - public function testBigIntIgnoreCaseOrderBy() - { - BookstorePeer::doDeleteAll(); + $b = new Bookstore(); + $b->setStoreName("SortTest2")->setPopulationServed(201)->save(); - // Some sample data - $b = new Bookstore(); - $b->setStoreName("SortTest1")->setPopulationServed(2000)->save(); + $b = new Bookstore(); + $b->setStoreName("SortTest3")->setPopulationServed(302)->save(); - $b = new Bookstore(); - $b->setStoreName("SortTest2")->setPopulationServed(201)->save(); + $b = new Bookstore(); + $b->setStoreName("SortTest4")->setPopulationServed(10000000)->save(); - $b = new Bookstore(); - $b->setStoreName("SortTest3")->setPopulationServed(302)->save(); + $c = new Criteria(); + $c->setIgnoreCase(true); + $c->add(BookstorePeer::STORE_NAME, 'SortTest%', Criteria::LIKE); + $c->addAscendingOrderByColumn(BookstorePeer::POPULATION_SERVED); - $b = new Bookstore(); - $b->setStoreName("SortTest4")->setPopulationServed(10000000)->save(); + $rows = BookstorePeer::doSelect($c); + $this->assertEquals('SortTest2', $rows[0]->getStoreName()); + $this->assertEquals('SortTest3', $rows[1]->getStoreName()); + $this->assertEquals('SortTest1', $rows[2]->getStoreName()); + $this->assertEquals('SortTest4', $rows[3]->getStoreName()); + } - $c = new Criteria(); - $c->setIgnoreCase(true); - $c->add(BookstorePeer::STORE_NAME, 'SortTest%', Criteria::LIKE); - $c->addAscendingOrderByColumn(BookstorePeer::POPULATION_SERVED); + /** + * + */ + public function testMixedJoinOrder() + { + $this->markTestSkipped('Famous cross join problem, to be solved one day'); + $c = new Criteria(BookPeer::DATABASE_NAME); + $c->addSelectColumn(BookPeer::ID); + $c->addSelectColumn(BookPeer::TITLE); - $rows = BookstorePeer::doSelect($c); - $this->assertEquals('SortTest2', $rows[0]->getStoreName()); - $this->assertEquals('SortTest3', $rows[1]->getStoreName()); - $this->assertEquals('SortTest1', $rows[2]->getStoreName()); - $this->assertEquals('SortTest4', $rows[3]->getStoreName()); - } + $c->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID, Criteria::LEFT_JOIN); + $c->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID); - /** - * - */ - public function testMixedJoinOrder() - { - $this->markTestSkipped('Famous cross join problem, to be solved one day'); - $c = new Criteria(BookPeer::DATABASE_NAME); - $c->addSelectColumn(BookPeer::ID); - $c->addSelectColumn(BookPeer::TITLE); + $params = array(); + $sql = BasePeer::createSelectSql($c, $params); - $c->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID, Criteria::LEFT_JOIN); - $c->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID); + $expectedSql = "SELECT book.id, book.title FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.id), author WHERE book.AUTHOR_ID=author.id"; + $this->assertEquals($expectedSql, $sql); + } - $params = array(); - $sql = BasePeer::createSelectSql($c, $params); + public function testMssqlApplyLimitNoOffset() + { + $db = Propel::getDB(BookPeer::DATABASE_NAME); + if (! ($db instanceof DBMSSQL)) { + $this->markTestSkipped(); + } - $expectedSql = "SELECT book.ID, book.TITLE FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.ID), author WHERE book.AUTHOR_ID=author.ID"; - $this->assertEquals($expectedSql, $sql); - } - - public function testMssqlApplyLimitNoOffset() - { - $db = Propel::getDB(BookPeer::DATABASE_NAME); - if(! ($db instanceof DBMSSQL)) - { - $this->markTestSkipped(); - } + $c = new Criteria(BookPeer::DATABASE_NAME); + $c->addSelectColumn(BookPeer::ID); + $c->addSelectColumn(BookPeer::TITLE); + $c->addSelectColumn(PublisherPeer::NAME); + $c->addAsColumn('PublisherName','(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID)'); - $c = new Criteria(BookPeer::DATABASE_NAME); - $c->addSelectColumn(BookPeer::ID); - $c->addSelectColumn(BookPeer::TITLE); - $c->addSelectColumn(PublisherPeer::NAME); - $c->addAsColumn('PublisherName','(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.ID = book.PUBLISHER_ID)'); + $c->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID, Criteria::LEFT_JOIN); - $c->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID, Criteria::LEFT_JOIN); + $c->setOffset(0); + $c->setLimit(20); - $c->setOffset(0); - $c->setLimit(20); + $params = array(); + $sql = BasePeer::createSelectSql($c, $params); - $params = array(); - $sql = BasePeer::createSelectSql($c, $params); + $expectedSql = "SELECT TOP 20 book.id, book.title, publisher.NAME, (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) AS PublisherName FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.id)"; + $this->assertEquals($expectedSql, $sql); + } - $expectedSql = "SELECT TOP 20 book.ID, book.TITLE, publisher.NAME, (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.ID = book.PUBLISHER_ID) AS PublisherName FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.ID)"; - $this->assertEquals($expectedSql, $sql); - } + public function testMssqlApplyLimitWithOffset() + { + $db = Propel::getDB(BookPeer::DATABASE_NAME); + if (! ($db instanceof DBMSSQL)) { + $this->markTestSkipped(); + } - public function testMssqlApplyLimitWithOffset() - { - $db = Propel::getDB(BookPeer::DATABASE_NAME); - if(! ($db instanceof DBMSSQL)) - { - $this->markTestSkipped(); - } + $c = new Criteria(BookPeer::DATABASE_NAME); + $c->addSelectColumn(BookPeer::ID); + $c->addSelectColumn(BookPeer::TITLE); + $c->addSelectColumn(PublisherPeer::NAME); + $c->addAsColumn('PublisherName','(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID)'); + $c->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID, Criteria::LEFT_JOIN); + $c->setOffset(20); + $c->setLimit(20); - $c = new Criteria(BookPeer::DATABASE_NAME); - $c->addSelectColumn(BookPeer::ID); - $c->addSelectColumn(BookPeer::TITLE); - $c->addSelectColumn(PublisherPeer::NAME); - $c->addAsColumn('PublisherName','(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.ID = book.PUBLISHER_ID)'); - $c->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID, Criteria::LEFT_JOIN); - $c->setOffset(20); - $c->setLimit(20); + $params = array(); - $params = array(); + $expectedSql = "SELECT [book.id], [book.title], [publisher.NAME], [PublisherName] FROM (SELECT ROW_NUMBER() OVER(ORDER BY book.id) AS [RowNumber], book.id AS [book.id], book.title AS [book.title], publisher.NAME AS [publisher.NAME], (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) AS [PublisherName] FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.id)) AS derivedb WHERE RowNumber BETWEEN 21 AND 40"; + $sql = BasePeer::createSelectSql($c, $params); + $this->assertEquals($expectedSql, $sql); + } - $expectedSql = "SELECT [book.ID], [book.TITLE], [publisher.NAME], [PublisherName] FROM (SELECT ROW_NUMBER() OVER(ORDER BY book.ID) AS RowNumber, book.ID AS [book.ID], book.TITLE AS [book.TITLE], publisher.NAME AS [publisher.NAME], (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.ID = book.PUBLISHER_ID) AS [PublisherName] FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.ID)) AS derivedb WHERE RowNumber BETWEEN 21 AND 40"; - $sql = BasePeer::createSelectSql($c, $params); - $this->assertEquals($expectedSql, $sql); - } + public function testMssqlApplyLimitWithOffsetOrderByAggregate() + { + $db = Propel::getDB(BookPeer::DATABASE_NAME); + if (! ($db instanceof DBMSSQL)) { + $this->markTestSkipped(); + } - public function testMssqlApplyLimitWithOffsetOrderByAggregate() - { - $db = Propel::getDB(BookPeer::DATABASE_NAME); - if(! ($db instanceof DBMSSQL)) - { - $this->markTestSkipped(); - } + $c = new Criteria(BookPeer::DATABASE_NAME); + $c->addSelectColumn(BookPeer::ID); + $c->addSelectColumn(BookPeer::TITLE); + $c->addSelectColumn(PublisherPeer::NAME); + $c->addAsColumn('PublisherName','(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID)'); + $c->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID, Criteria::LEFT_JOIN); + $c->addDescendingOrderByColumn('PublisherName'); + $c->setOffset(20); + $c->setLimit(20); - $c = new Criteria(BookPeer::DATABASE_NAME); - $c->addSelectColumn(BookPeer::ID); - $c->addSelectColumn(BookPeer::TITLE); - $c->addSelectColumn(PublisherPeer::NAME); - $c->addAsColumn('PublisherName','(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.ID = book.PUBLISHER_ID)'); - $c->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID, Criteria::LEFT_JOIN); - $c->addDescendingOrderByColumn('PublisherName'); - $c->setOffset(20); - $c->setLimit(20); + $params = array(); - $params = array(); + $expectedSql = "SELECT [book.id], [book.title], [publisher.NAME], [PublisherName] FROM (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) DESC) AS [RowNumber], book.id AS [book.id], book.title AS [book.title], publisher.NAME AS [publisher.NAME], (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) AS [PublisherName] FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.id)) AS derivedb WHERE RowNumber BETWEEN 21 AND 40"; + $sql = BasePeer::createSelectSql($c, $params); + $this->assertEquals($expectedSql, $sql); + } - $expectedSql = "SELECT [book.ID], [book.TITLE], [publisher.NAME], [PublisherName] FROM (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.ID = book.PUBLISHER_ID) DESC) AS RowNumber, book.ID AS [book.ID], book.TITLE AS [book.TITLE], publisher.NAME AS [publisher.NAME], (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.ID = book.PUBLISHER_ID) AS [PublisherName] FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.ID)) AS derivedb WHERE RowNumber BETWEEN 21 AND 40"; - $sql = BasePeer::createSelectSql($c, $params); - $this->assertEquals($expectedSql, $sql); - } + public function testMssqlApplyLimitWithOffsetMultipleOrderBy() + { + $db = Propel::getDB(BookPeer::DATABASE_NAME); + if (! ($db instanceof DBMSSQL)) { + $this->markTestSkipped(); + } - public function testMssqlApplyLimitWithOffsetMultipleOrderBy() - { - $db = Propel::getDB(BookPeer::DATABASE_NAME); - if(! ($db instanceof DBMSSQL)) - { - $this->markTestSkipped(); - } + $c = new Criteria(BookPeer::DATABASE_NAME); + $c->addSelectColumn(BookPeer::ID); + $c->addSelectColumn(BookPeer::TITLE); + $c->addSelectColumn(PublisherPeer::NAME); + $c->addAsColumn('PublisherName','(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID)'); + $c->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID, Criteria::LEFT_JOIN); + $c->addDescendingOrderByColumn('PublisherName'); + $c->addAscendingOrderByColumn(BookPeer::TITLE); + $c->setOffset(20); + $c->setLimit(20); - $c = new Criteria(BookPeer::DATABASE_NAME); - $c->addSelectColumn(BookPeer::ID); - $c->addSelectColumn(BookPeer::TITLE); - $c->addSelectColumn(PublisherPeer::NAME); - $c->addAsColumn('PublisherName','(SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.ID = book.PUBLISHER_ID)'); - $c->addJoin(BookPeer::PUBLISHER_ID, PublisherPeer::ID, Criteria::LEFT_JOIN); - $c->addDescendingOrderByColumn('PublisherName'); - $c->addAscendingOrderByColumn(BookPeer::TITLE); - $c->setOffset(20); - $c->setLimit(20); + $params = array(); - $params = array(); + $expectedSql = "SELECT [book.id], [book.title], [publisher.NAME], [PublisherName] FROM (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) DESC, book.title ASC) AS [RowNumber], book.id AS [book.id], book.title AS [book.title], publisher.NAME AS [publisher.NAME], (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.id = book.PUBLISHER_ID) AS [PublisherName] FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.id)) AS derivedb WHERE RowNumber BETWEEN 21 AND 40"; + $sql = BasePeer::createSelectSql($c, $params); + $this->assertEquals($expectedSql, $sql); + } - $expectedSql = "SELECT [book.ID], [book.TITLE], [publisher.NAME], [PublisherName] FROM (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.ID = book.PUBLISHER_ID) DESC, book.TITLE ASC) AS RowNumber, book.ID AS [book.ID], book.TITLE AS [book.TITLE], publisher.NAME AS [publisher.NAME], (SELECT MAX(publisher.NAME) FROM publisher WHERE publisher.ID = book.PUBLISHER_ID) AS [PublisherName] FROM book LEFT JOIN publisher ON (book.PUBLISHER_ID=publisher.ID)) AS derivedb WHERE RowNumber BETWEEN 21 AND 40"; - $sql = BasePeer::createSelectSql($c, $params); - $this->assertEquals($expectedSql, $sql); - } - - /** - * @expectedException PropelException - */ - public function testDoDeleteNoCondition() - { - $con = Propel::getConnection(); - $c = new Criteria(BookPeer::DATABASE_NAME); - BasePeer::doDelete($c, $con); - } - - public function testDoDeleteSimpleCondition() - { - $con = Propel::getConnection(); - $c = new Criteria(BookPeer::DATABASE_NAME); - $c->add(BookPeer::TITLE, 'War And Peace'); - BasePeer::doDelete($c, $con); - $expectedSQL = "DELETE FROM `book` WHERE book.TITLE='War And Peace'"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'doDelete() translates a contition into a WHERE'); - } + /** + * @expectedException PropelException + */ + public function testDoDeleteNoCondition() + { + $con = Propel::getConnection(); + $c = new Criteria(BookPeer::DATABASE_NAME); + BasePeer::doDelete($c, $con); + } - public function testDoDeleteSeveralConditions() - { - $con = Propel::getConnection(); - $c = new Criteria(BookPeer::DATABASE_NAME); - $c->add(BookPeer::TITLE, 'War And Peace'); - $c->add(BookPeer::ID, 12); - BasePeer::doDelete($c, $con); - $expectedSQL = "DELETE FROM `book` WHERE book.TITLE='War And Peace' AND book.ID=12"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'doDelete() combines conditions in WHERE whith an AND'); - } + /** + * @expectedException PropelException + */ + public function testDoDeleteJoin() + { + $con = Propel::getConnection(); + $c = new Criteria(BookPeer::DATABASE_NAME); + $c->add(BookPeer::TITLE, 'War And Peace'); + $c->addJoin(BookPeer::AUTHOR_ID, AuthorPeer::ID); + BasePeer::doDelete($c, $con); + } - public function testDoDeleteTableAlias() - { - $con = Propel::getConnection(); - $c = new Criteria(BookPeer::DATABASE_NAME); - $c->addAlias('b', BookPeer::TABLE_NAME); - $c->add('b.TITLE', 'War And Peace'); - BasePeer::doDelete($c, $con); - $expectedSQL = "DELETE b FROM `book` AS b WHERE b.TITLE='War And Peace'"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'doDelete() accepts a Criteria with a table alias'); - } + public function testDoDeleteSimpleCondition() + { + $con = Propel::getConnection(); + $c = new Criteria(BookPeer::DATABASE_NAME); + $c->add(BookPeer::TITLE, 'War And Peace'); + BasePeer::doDelete($c, $con); + $expectedSQL = "DELETE FROM `book` WHERE book.title='War And Peace'"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'doDelete() translates a condition into a WHERE'); + } - /** - * Not documented anywhere, and probably wrong - * @see http://www.propelorm.org/ticket/952 - */ - public function testDoDeleteSeveralTables() - { - $con = Propel::getConnection(); - $count = $con->getQueryCount(); - $c = new Criteria(BookPeer::DATABASE_NAME); - $c->add(BookPeer::TITLE, 'War And Peace'); - $c->add(AuthorPeer::FIRST_NAME, 'Leo'); - BasePeer::doDelete($c, $con); - $expectedSQL = "DELETE FROM `author` WHERE author.FIRST_NAME='Leo'"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'doDelete() issues two DELETE queries when passed conditions on two tables'); - $this->assertEquals($count + 2, $con->getQueryCount(), 'doDelete() issues two DELETE queries when passed conditions on two tables'); - - $c = new Criteria(BookPeer::DATABASE_NAME); - $c->add(AuthorPeer::FIRST_NAME, 'Leo'); - $c->add(BookPeer::TITLE, 'War And Peace'); - BasePeer::doDelete($c, $con); - $expectedSQL = "DELETE FROM `book` WHERE book.TITLE='War And Peace'"; - $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'doDelete() issues two DELETE queries when passed conditions on two tables'); - $this->assertEquals($count + 4, $con->getQueryCount(), 'doDelete() issues two DELETE queries when passed conditions on two tables'); - } - - public function testCommentDoSelect() - { - $c = new Criteria(); - $c->setComment('Foo'); - $c->addSelectColumn(BookPeer::ID); - $expected = 'SELECT /* Foo */ book.ID FROM `book`'; - $params = array(); - $this->assertEquals($expected, BasePeer::createSelectSQL($c, $params), 'Criteria::setComment() adds a comment to select queries'); - } - - public function testCommentDoUpdate() - { - $c1 = new Criteria(); - $c1->setPrimaryTableName(BookPeer::TABLE_NAME); - $c1->setComment('Foo'); - $c2 = new Criteria(); - $c2->add(BookPeer::TITLE, 'Updated Title'); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - BasePeer::doUpdate($c1, $c2, $con); - $expected = 'UPDATE /* Foo */ `book` SET `TITLE`=\'Updated Title\''; - $this->assertEquals($expected, $con->getLastExecutedQuery(), 'Criteria::setComment() adds a comment to update queries'); - } - - public function testCommentDoDelete() - { - $c = new Criteria(); - $c->setComment('Foo'); - $c->add(BookPeer::TITLE, 'War And Peace'); - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - BasePeer::doDelete($c, $con); - $expected = 'DELETE /* Foo */ FROM `book` WHERE book.TITLE=\'War And Peace\''; - $this->assertEquals($expected, $con->getLastExecutedQuery(), 'Criteria::setComment() adds a comment to delete queries'); - } - + public function testDoDeleteSeveralConditions() + { + $con = Propel::getConnection(); + $c = new Criteria(BookPeer::DATABASE_NAME); + $c->add(BookPeer::TITLE, 'War And Peace'); + $c->add(BookPeer::ID, 12); + BasePeer::doDelete($c, $con); + $expectedSQL = "DELETE FROM `book` WHERE book.title='War And Peace' AND book.id=12"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'doDelete() combines conditions in WHERE with an AND'); + } + + public function testDoDeleteTableAlias() + { + $con = Propel::getConnection(); + $c = new Criteria(BookPeer::DATABASE_NAME); + $c->addAlias('b', BookPeer::TABLE_NAME); + $c->add('b.title', 'War And Peace'); + BasePeer::doDelete($c, $con); + $expectedSQL = "DELETE b FROM `book` AS b WHERE b.title='War And Peace'"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'doDelete() accepts a Criteria with a table alias'); + } + + /** + * Not documented anywhere, and probably wrong + * @see http://www.propelorm.org/ticket/952 + */ + public function testDoDeleteSeveralTables() + { + $con = Propel::getConnection(); + $count = $con->getQueryCount(); + $c = new Criteria(BookPeer::DATABASE_NAME); + $c->add(BookPeer::TITLE, 'War And Peace'); + $c->add(AuthorPeer::FIRST_NAME, 'Leo'); + BasePeer::doDelete($c, $con); + $expectedSQL = "DELETE FROM `author` WHERE author.first_name='Leo'"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'doDelete() issues two DELETE queries when passed conditions on two tables'); + $this->assertEquals($count + 2, $con->getQueryCount(), 'doDelete() issues two DELETE queries when passed conditions on two tables'); + + $c = new Criteria(BookPeer::DATABASE_NAME); + $c->add(AuthorPeer::FIRST_NAME, 'Leo'); + $c->add(BookPeer::TITLE, 'War And Peace'); + BasePeer::doDelete($c, $con); + $expectedSQL = "DELETE FROM `book` WHERE book.title='War And Peace'"; + $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'doDelete() issues two DELETE queries when passed conditions on two tables'); + $this->assertEquals($count + 4, $con->getQueryCount(), 'doDelete() issues two DELETE queries when passed conditions on two tables'); + } + + public function testCommentDoSelect() + { + $c = new Criteria(); + $c->setComment('Foo'); + $c->addSelectColumn(BookPeer::ID); + $expected = 'SELECT /* Foo */ book.id FROM `book`'; + $params = array(); + $this->assertEquals($expected, BasePeer::createSelectSQL($c, $params), 'Criteria::setComment() adds a comment to select queries'); + } + + public function testCommentDoUpdate() + { + $c1 = new Criteria(); + $c1->setPrimaryTableName(BookPeer::TABLE_NAME); + $c1->setComment('Foo'); + $c2 = new Criteria(); + $c2->add(BookPeer::TITLE, 'Updated Title'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + BasePeer::doUpdate($c1, $c2, $con); + $expected = 'UPDATE /* Foo */ `book` SET `title`=\'Updated Title\''; + $this->assertEquals($expected, $con->getLastExecutedQuery(), 'Criteria::setComment() adds a comment to update queries'); + } + + public function testCommentDoDelete() + { + $c = new Criteria(); + $c->setComment('Foo'); + $c->add(BookPeer::TITLE, 'War And Peace'); + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + BasePeer::doDelete($c, $con); + $expected = 'DELETE /* Foo */ FROM `book` WHERE book.title=\'War And Peace\''; + $this->assertEquals($expected, $con->getLastExecutedQuery(), 'Criteria::setComment() adds a comment to delete queries'); + } + + public function testIneffectualUpdateUsingBookObject() + { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + $c = new Criteria(); + $book = BookPeer::doSelectOne($c, $con); + $count = $con->getQueryCount(); + $book->setTitle($book->getTitle()); + $book->setISBN($book->getISBN()); + try { + $rowCount = BookPeer::doUpdate($book, $con); + $this->assertEquals(0, $rowCount, 'BookPeer::doUpdate() should indicate zero rows updated'); + } catch (Exception $ex) { + $this->fail('BookPeer::doUpdate() threw an exception'); + } + + $this->assertEquals($count, $con->getQueryCount(), 'BookPeer::doUpdate() does not execute any queries when there are no changes'); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelConditionalProxyTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelConditionalProxyTest.php new file mode 100644 index 000000000..ce9e2f93b --- /dev/null +++ b/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelConditionalProxyTest.php @@ -0,0 +1,112 @@ + + * @version $Id: CriteriaCombineTest.php 1347 2009-12-03 21:06:36Z francois $ + * @package propel.runtime.util + */ +class PropelConditionalProxyTest extends BaseTestCase +{ + public function testFluidInterface() + { + $criteria = new ProxyTestCriteria(); + $p = new TestPropelConditionalProxy($criteria, false); + + $this->assertEquals($p->_elseif(false), $p, '_elseif returns fluid interface'); + + $this->assertEquals($p->_elseif(true), $criteria, '_elseif returns fluid interface'); + + $this->assertEquals($p->_elseif(false), $p, '_elseif returns fluid interface'); + + $this->assertEquals($p->_else(), $p, '_else returns fluid interface'); + + $criteria = new ProxyTestCriteria(); + + $p = new TestPropelConditionalProxy($criteria, true); + + $this->assertEquals($p->_elseif(true), $p, '_elseif returns fluid interface'); + + $this->assertEquals($p->_elseif(false), $p, '_elseif returns fluid interface'); + + $this->assertEquals($p->_else(), $p, '_else returns fluid interface'); + + $criteria = new ProxyTestCriteria(); + $p = new TestPropelConditionalProxy($criteria, false); + + $this->assertEquals($p->_elseif(false), $p, '_elseif returns fluid interface'); + + $this->assertEquals($p->_else(), $criteria, '_else returns fluid interface'); + + } + + public function testHierarchy() + { + $criteria = new ProxyTestCriteria(); + $p = new TestPropelConditionalProxy($criteria, true); + + $this->assertEquals($p->getCriteria(), $criteria, 'main object is the given one'); + + $this->assertInstanceOf('PropelConditionalProxy', $p2 = $p->_if(true), '_if returns fluid interface'); + + $this->assertEquals($p2->getCriteria(), $criteria, 'main object is the given one, even with nested proxies'); + + $this->assertEquals($p2->getParentProxy(), $p, 'nested proxy is respected'); + + $p = new PropelConditionalProxy($criteria, true); + + $this->assertEquals($criteria, $p->_if(true), '_if returns fluid interface'); + } +} + +class TestPropelConditionalProxy extends PropelConditionalProxy +{ + public function _if($cond) + { + return new TestPropelConditionalProxy($this->criteria, $cond, $this); + } + + public function getParentProxy() + { + return $this->parent; + } + + public function getCriteria() + { + return $this->criteria; + } +} + +class ProxyTestCriteria extends Criteria +{ + protected $test = false; + + public function test() + { + $this->test = true; + + return $this; + } + + public function dummy() + { + return $this; + } + + public function getTest() + { + return $this->test; + } +} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelConfigurationTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelConfigurationTest.php deleted file mode 100644 index d653f3318..000000000 --- a/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelConfigurationTest.php +++ /dev/null @@ -1,69 +0,0 @@ - array('fooo' => 'bar', 'fi' => array('fooooo' => 'bara')), 'baz' => 'bar2'); - - public function testConstruct() - { - $conf = new PropelConfiguration($this->testArray); - $this->assertEquals($this->testArray, $conf->getParameters(), 'constructor sets values from an associative array'); - } - - public function testGetParameters() - { - $conf = new PropelConfiguration($this->testArray); - $expected = array('foo.fooo' => 'bar', 'foo.fi.fooooo' => 'bara', 'baz' => 'bar2'); - $this->assertEquals($expected, $conf->getParameters(PropelConfiguration::TYPE_ARRAY_FLAT), 'getParameters can return a flat array'); - } - - public function testGetParameter() - { - $conf = new PropelConfiguration($this->testArray); - $this->assertEquals('bar', $conf->getParameter('foo.fooo'), 'getParameter accepts a flat key'); - $this->assertEquals('bara', $conf->getParameter('foo.fi.fooooo'), 'getParameter accepts a flat key'); - $this->assertEquals('bar2', $conf->getParameter('baz'), 'getParameter accepts a flat key'); - } - - public function testGetParameterDefault() - { - $conf = new PropelConfiguration($this->testArray); - $this->assertEquals('bar', $conf->getParameter('foo.fooo'), 'getParameter accepts a flat key'); - $this->assertEquals('', $conf->getParameter('foo.fooo2'), 'getParameter returns null for nonexistent keys'); - $this->assertEquals('babar', $conf->getParameter('foo.fooo3', 'babar'), 'getParameter accepts a default value'); - } - - public function testSetParameter() - { - $conf = new PropelConfiguration(array()); - $conf->setParameter('foo.fooo', 'bar'); - $conf->setParameter('foo.fi.fooooo', 'bara'); - $conf->setParameter('baz', 'bar2'); - $this->assertEquals($this->testArray, $conf->getParameters(), 'setParameter accepts a flat array'); - } - - public function testArrayAccess() - { - $conf = new PropelConfiguration($this->testArray); - $expected = array('fooo' => 'bar', 'fi' => array('fooooo' => 'bara')); - $this->assertEquals($expected, $conf['foo'], 'PropelConfiguration implements ArrayAccess for OffsetGet'); - $this->assertEquals('bar', $conf['foo']['fooo'], 'Array access allows deep access'); - } -} diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelDateTimeTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelDateTimeTest.php index af490e0e4..f71eefe15 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelDateTimeTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelDateTimeTest.php @@ -5,135 +5,191 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * - * @license MIT License + * @license MIT License */ -require_once 'tools/helpers/BaseTestCase.php'; require_once dirname(__FILE__) . '/../../../../runtime/lib/util/PropelDateTime.php'; +require_once dirname(__FILE__) . '/../../../../runtime/lib/exception/PropelException.php'; /** * Test for DateTime subclass to support serialization. * - * @author Alan Pinstein - * @author Soenke Ruempler - * @package runtime.util + * @author Alan Pinstein + * @author Soenke Ruempler + * @package runtime.util */ -class PropelDateTimeTest extends BaseTestCase +class PropelDateTimeTest extends PHPUnit_Framework_TestCase { - /** - * Assert that two dates are identical (equal and have same time zone). - */ - protected function assertDatesIdentical(DateTime $dt1, DateTime $dt2, $msg = "Expected DateTime1 IDENTICAL to DateTime2: %s") - { - $this->assertEquals($dt1->format('Y-m-d H:i:s'), $dt1->format('Y-m-d H:i:s'), sprintf($msg, "Dates w/ no timezone resolution were not the same.")); - $this->assertEquals($dt1->getTimeZone()->getName(), $dt2->getTimeZone()->getName(), sprintf($msg, "timezones were not the same.")); + /** + * Assert that two dates are identical (equal and have same time zone). + */ + protected function assertDatesIdentical(DateTime $dt1, DateTime $dt2, $msg = "Expected DateTime1 IDENTICAL to DateTime2: %s") + { + $this->assertEquals($dt1->format('Y-m-d H:i:s'), $dt1->format('Y-m-d H:i:s'), sprintf($msg, "Dates w/ no timezone resolution were not the same.")); + $this->assertEquals($dt1->getTimeZone()->getName(), $dt2->getTimeZone()->getName(), sprintf($msg, "timezones were not the same.")); + // We do this last, because a PHP bug will make this true while the dates + // may not truly be equal. + // See: http://bugs.php.net/bug.php?id=40743 + $this->assertTrue($dt1 == $dt2, sprintf($msg, "dates did not pass equality check (==).")); + } - // We do this last, because a PHP bug will make this true while the dates - // may not truly be equal. - // See: http://bugs.php.net/bug.php?id=40743 - $this->assertTrue($dt1 == $dt2, sprintf($msg, "dates did not pass equality check (==).")); - } + /** + * Assert that two dates are equal. + */ + protected function assertDatesEqual(DateTime $dt1, DateTime $dt2, $msg = "Expected DateTime1 == DateTime2: %s") + { + if ($dt1 != $dt2) { + if ($dt1->getTimeZone()->getName() != $dt2->getTimeZone()->getName()) { + $this->fail(sprintf($msg, "Timezones were not the same.")); + } else { + $this->fail(sprintf($msg, "Timezones were the same, but date values were different.")); + } + } + } - /** - * Assert that two dates are equal. - */ - protected function assertDatesEqual(DateTime $dt1, DateTime $dt2, $msg = "Expected DateTime1 == DateTime2: %s") - { - if ($dt1 != $dt2) { - if ($dt1->getTimeZone()->getName() != $dt2->getTimeZone()->getName()) { - $this->fail(sprintf($msg, "Timezones were not the same.")); - } else { - $this->fail(sprintf($msg, "Timezones were the same, but date values were different.")); - } - } - } + /** + * Assert that two dates are not equal. + */ + protected function assertDatesNotEqual(DateTime $dt1, DateTime $dt2, $msg = "Expected DateTime1 != DateTime2: %s") + { + $this->assertTrue($dt1 != $dt2, $msg); + } - /** - * Assert that two dates are not equal. - */ - protected function assertDatesNotEqual(DateTime $dt1, DateTime $dt2, $msg = "Expected DateTime1 != DateTime2: %s") - { - $this->assertTrue($dt1 != $dt2, $msg); - } + /** + * Ensure that our constructor matches DateTime constructor signature. + */ + public function testConstruct() + { - /** - * Ensure that our constructor matches DateTime constructor signature. - */ - public function testConstruct() - { + // Because of a PHP bug () + // we cannot use a timestamp format that includes a timezone. It gets weird. :) + $now = date('Y-m-d H:i:s'); - // Because of a PHP bug () - // we cannot use a timestamp format that includes a timezone. It gets weird. :) - $now = date('Y-m-d H:i:s'); + $dt = new DateTime($now); + $pdt = new PropelDateTime($now); + $this->assertDatesEqual($dt, $pdt, "Expected DateTime == PropelDateTime: %s"); - $dt = new DateTime($now); - $pdt = new PropelDateTime($now); - $this->assertDatesEqual($dt, $pdt, "Expected DateTime == PropelDateTime: %s"); + $dt = new DateTime($now, new DateTimeZone('UTC')); + $pdt = new PropelDateTime($now, new DateTimeZone('America/New_York')); + $this->assertDatesNotEqual($dt, $pdt, "Expected DateTime != PropelDateTime: %s"); - $dt = new DateTime($now, new DateTimeZone('UTC')); - $pdt = new PropelDateTime($now, new DateTimeZone('America/New_York')); - $this->assertDatesNotEqual($dt, $pdt, "Expected DateTime != PropelDateTime: %s"); + } - } + /** + * Tests the ability to serialize() a PropelDateTime object. + */ + public function testSerialize_NoTZ() + { + $now = date('Y-m-d H:i:s'); + $dt = new DateTime($now); + $pdt = new PropelDateTime($now); - /** - * Tests the ability to serialize() a PropelDateTime object. - */ - public function testSerialize_NoTZ() - { - $now = date('Y-m-d H:i:s'); - $dt = new DateTime($now); - $pdt = new PropelDateTime($now); + $this->assertDatesIdentical($dt, $pdt); - $this->assertDatesIdentical($dt, $pdt); + // We expect these to be the same -- there's no time zone info + $ser = serialize($pdt); + unset($pdt); - // We expect these to be the same -- there's no time zone info - $ser = serialize($pdt); - unset($pdt); + $pdt = unserialize($ser); + $this->assertDatesIdentical($dt, $pdt); + } - $pdt = unserialize($ser); - $this->assertDatesIdentical($dt, $pdt); - } + /** + * Tests the ability to serialize() a PropelDateTime object. + */ + public function testSerialize_SameTZ() + { + $now = date('Y-m-d H:i:s'); + $dt = new DateTime($now, new DateTimeZone('America/New_York')); + $pdt = new PropelDateTime($now, new DateTimeZone('America/New_York')); - /** - * Tests the ability to serialize() a PropelDateTime object. - */ - public function testSerialize_SameTZ() - { - $now = date('Y-m-d H:i:s'); - $dt = new DateTime($now, new DateTimeZone('America/New_York')); - $pdt = new PropelDateTime($now, new DateTimeZone('America/New_York')); + $this->assertDatesIdentical($dt, $pdt); - $this->assertDatesIdentical($dt, $pdt); + // We expect these to be the same -- there's no time zone info + $ser = serialize($pdt); + unset($pdt); - // We expect these to be the same -- there's no time zone info - $ser = serialize($pdt); - unset($pdt); + $pdt = unserialize($ser); + $this->assertDatesIdentical($dt, $pdt); + } - $pdt = unserialize($ser); - $this->assertDatesIdentical($dt, $pdt); - } + /** + * Tests the ability to serialize() a PropelDateTime object. + */ + public function testSerialize_DiffTZ() + { + $now = date('Y-m-d H:i:s'); + $dt = new DateTime($now, new DateTimeZone('UTC')); + $pdt = new PropelDateTime($now, new DateTimeZone('America/New_York')); - /** - * Tests the ability to serialize() a PropelDateTime object. - */ - public function testSerialize_DiffTZ() - { - $now = date('Y-m-d H:i:s'); - $dt = new DateTime($now, new DateTimeZone('UTC')); - $pdt = new PropelDateTime($now, new DateTimeZone('America/New_York')); + $this->assertDatesNotEqual($dt, $pdt); - $this->assertDatesNotEqual($dt, $pdt); + // We expect these to be the same -- there's no time zone info + $ser = serialize($pdt); + unset($pdt); - // We expect these to be the same -- there's no time zone info - $ser = serialize($pdt); - unset($pdt); + $pdt = unserialize($ser); + $this->assertDatesNotEqual($dt, $pdt); + } - $pdt = unserialize($ser); - $this->assertDatesNotEqual($dt, $pdt); - } + /** + * @dataProvider provideValidNewInstanceValues + */ + public function testNewInstance($value, $expected) + { + $originalTimezone = date_default_timezone_get(); + date_default_timezone_set('UTC'); + $dt = PropelDateTime::newInstance($value); + $this->assertEquals($expected, $dt->format('Y-m-d H:i:s')); + date_default_timezone_set($originalTimezone); + } + + /** + * @dataProvider provideValidNewInstanceValuesGmt1 + */ + public function testNewInstanceGmt1($value, $expected) + { + $originalTimezone = date_default_timezone_get(); + date_default_timezone_set('Europe/Paris'); + + $dt = PropelDateTime::newInstance($value); + $this->assertEquals($expected, $dt->format('Y-m-d H:i:s')); + + date_default_timezone_set($originalTimezone); + } + + /** + * @expectedException PropelException + */ + public function testNewInstanceInvalidValue() + { + $dt = PropelDateTime::newInstance('some string'); + } + + public function provideValidNewInstanceValues() + { + return array( + 'Y-m-d' => array('2011-08-10', '2011-08-10 00:00:00'), + // 1312960848 : Wed, 10 Aug 2011 07:20:48 GMT + 'unix_timestamp' => array('1312960848', '2011-08-10 07:20:48'), + 'Y-m-d H:is' => array('2011-08-10 10:22:15', '2011-08-10 10:22:15'), + 'datetime_object' => array(new DateTime('2011-08-10 10:23:10'), '2011-08-10 10:23:10') + ); + } + + public function provideValidNewInstanceValuesGmt1() + { + return array( + // "1312960848" : Wed, 10 Aug 2011 07:20:48 GMT + // "2011-08-10 09:20:48" : GMT+1 DST (= GMT +2) + 'unix_timestamp' => array('1312960848', '2011-08-10 09:20:48'), + // "1323517115" : Sat, 10 Dec 2011 11:38:35 GMT + // "2011-12-10 12:38:35" : GMT +1 + 'unix_timestamp' => array('1323517115', '2011-12-10 12:38:35'), + ); + } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelModelPagerTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelModelPagerTest.php index b622663df..71b482b4d 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelModelPagerTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelModelPagerTest.php @@ -8,7 +8,7 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Test the utility class PropelPager @@ -19,131 +19,234 @@ require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; */ class PropelModelPagerTest extends BookstoreEmptyTestBase { - private $authorId; - private $books; - - protected function createBooks($nb = 15, $con = null) - { - BookQuery::create()->deleteAll($con); - $books = new PropelObjectCollection(); - $books->setModel('Book'); - for ($i=0; $i < $nb; $i++) { - $b = new Book(); - $b->setTitle('Book' . $i); - $books[]= $b; - } - $books->save($con); - } - - protected function getPager($maxPerPage, $page = 1) - { - $pager = new PropelModelPager(BookQuery::create(), $maxPerPage); - $pager->setPage($page); - $pager->init(); - return $pager; - } - - public function testHaveToPaginate() - { - BookQuery::create()->deleteAll(); - $this->assertEquals(false, $this->getPager(0)->haveToPaginate(), 'haveToPaginate() returns false when there is no result'); - $this->createBooks(5); - $this->assertEquals(false, $this->getPager(0)->haveToPaginate(), 'haveToPaginate() returns false when the maxPerPage is null'); - $this->assertEquals(true, $this->getPager(2)->haveToPaginate(), 'haveToPaginate() returns true when the maxPerPage is less than the number of results'); - $this->assertEquals(false, $this->getPager(6)->haveToPaginate(), 'haveToPaginate() returns false when the maxPerPage is greater than the number of results'); - $this->assertEquals(false, $this->getPager(5)->haveToPaginate(), 'haveToPaginate() returns false when the maxPerPage is equal to the number of results'); - } + private $authorId; + private $books; - public function testGetNbResults() - { - BookQuery::create()->deleteAll(); - $pager = $this->getPager(4, 1); - $this->assertEquals(0, $pager->getNbResults(), 'getNbResults() returns 0 when there are no results'); - $this->createBooks(5); - $pager = $this->getPager(4, 1); - $this->assertEquals(5, $pager->getNbResults(), 'getNbResults() returns the total number of results'); - $pager = $this->getPager(2, 1); - $this->assertEquals(5, $pager->getNbResults(), 'getNbResults() returns the total number of results'); - $pager = $this->getPager(2, 2); - $this->assertEquals(5, $pager->getNbResults(), 'getNbResults() returns the total number of results'); - $pager = $this->getPager(7, 6); - $this->assertEquals(5, $pager->getNbResults(), 'getNbResults() returns the total number of results'); - $pager = $this->getPager(0, 0); - $this->assertEquals(5, $pager->getNbResults(), 'getNbResults() returns the total number of results'); - } - - public function testGetResults() - { - $this->createBooks(5); - $pager = $this->getPager(4, 1); - $this->assertTrue($pager->getResults() instanceof PropelObjectCollection, 'getResults() returns a PropelObjectCollection'); - $this->assertEquals(4, count($pager->getResults()), 'getResults() returns at most $maxPerPage results'); - $pager = $this->getPager(4, 2); - $this->assertEquals(1, count($pager->getResults()), 'getResults() returns the remaining results when in the last page'); - $pager = $this->getPager(4, 3); - $this->assertEquals(1, count($pager->getResults()), 'getResults() returns the results of the last page when called on nonexistent pages'); - } + protected function createBooks($nb = 15, $con = null) + { + BookQuery::create()->deleteAll($con); + $books = new PropelObjectCollection(); + $books->setModel('Book'); + for ($i=0; $i < $nb; $i++) { + $b = new Book(); + $b->setTitle('Book' . $i); + $b->setIsbn('12345' . $i); - public function testGetIterator() - { - $this->createBooks(5); + $books[]= $b; + } + $books->save($con); + } - $pager = $this->getPager(4, 1); - $i = 0; - foreach ($pager as $book) { - $this->assertEquals('Book' . $i, $book->getTitle(), 'getIterator() returns an iterator'); - $i++; - } - $this->assertEquals(4, $i, 'getIterator() uses the results collection'); - } + protected function getPager($maxPerPage, $page = 1) + { + $pager = new PropelModelPager(BookQuery::create(), $maxPerPage); + $pager->setPage($page); + $pager->init(); - public function testIterateTwice() - { - $this->createBooks(5); - $pager = $this->getPager(4, 1); - - $i = 0; - foreach ($pager as $book) { - $this->assertEquals('Book' . $i, $book->getTitle(), 'getIterator() returns an iterator'); - $i++; - } - $this->assertEquals(4, $i, 'getIterator() uses the results collection'); - - $i = 0; - foreach ($pager as $book) { - $this->assertEquals('Book' . $i, $book->getTitle()); - $i++; - } - $this->assertEquals(4, $i, 'getIterator() can be called several times'); - } - - public function testSetPage() - { - $this->createBooks(5); - $pager = $this->getPager(2, 2); - $i = 2; - foreach ($pager as $book) { - $this->assertEquals('Book' . $i, $book->getTitle(), 'setPage() sets the list to start on a given page'); - $i++; - } - $this->assertEquals(4, $i, 'setPage() doesn\'t change the page count'); - } - - public function testIsFirstPage() - { - $this->createBooks(5); - $pager = $this->getPager(4, 1); - $this->assertTrue($pager->isFirstPage(), 'isFirstPage() returns true on the first page'); - $pager = $this->getPager(4, 2); - $this->assertFalse($pager->isFirstPage(), 'isFirstPage() returns false when not on the first page'); - } + return $pager; + } + + public function testHaveToPaginate() + { + BookQuery::create()->deleteAll(); + $this->assertEquals(false, $this->getPager(0)->haveToPaginate(), 'haveToPaginate() returns false when there is no result'); + $this->createBooks(5); + $this->assertEquals(false, $this->getPager(0)->haveToPaginate(), 'haveToPaginate() returns false when the maxPerPage is null'); + $this->assertEquals(true, $this->getPager(2)->haveToPaginate(), 'haveToPaginate() returns true when the maxPerPage is less than the number of results'); + $this->assertEquals(false, $this->getPager(6)->haveToPaginate(), 'haveToPaginate() returns false when the maxPerPage is greater than the number of results'); + $this->assertEquals(false, $this->getPager(5)->haveToPaginate(), 'haveToPaginate() returns false when the maxPerPage is equal to the number of results'); + } + + public function testGetNbResults() + { + BookQuery::create()->deleteAll(); + $pager = $this->getPager(4, 1); + $this->assertEquals(0, $pager->getNbResults(), 'getNbResults() returns 0 when there are no results'); + $this->createBooks(5); + $pager = $this->getPager(4, 1); + $this->assertEquals(5, $pager->getNbResults(), 'getNbResults() returns the total number of results'); + $pager = $this->getPager(2, 1); + $this->assertEquals(5, $pager->getNbResults(), 'getNbResults() returns the total number of results'); + $pager = $this->getPager(2, 2); + $this->assertEquals(5, $pager->getNbResults(), 'getNbResults() returns the total number of results'); + $pager = $this->getPager(7, 6); + $this->assertEquals(5, $pager->getNbResults(), 'getNbResults() returns the total number of results'); + $pager = $this->getPager(0, 0); + $this->assertEquals(5, $pager->getNbResults(), 'getNbResults() returns the total number of results'); + } + + public function testGetResults() + { + $this->createBooks(5); + $pager = $this->getPager(4, 1); + $this->assertTrue($pager->getResults() instanceof PropelObjectCollection, 'getResults() returns a PropelObjectCollection'); + $this->assertEquals(4, count($pager->getResults()), 'getResults() returns at most $maxPerPage results'); + $pager = $this->getPager(4, 2); + $this->assertEquals(1, count($pager->getResults()), 'getResults() returns the remaining results when in the last page'); + $pager = $this->getPager(4, 3); + $this->assertEquals(1, count($pager->getResults()), 'getResults() returns the results of the last page when called on nonexistent pages'); + } + + public function testGetResultsRespectsFormatter() + { + $this->createBooks(5); + $query = BookQuery::create(); + $query->setFormatter(ModelCriteria::FORMAT_ARRAY); + $pager = new PropelModelPager($query, 4); + $pager->setPage(1); + $pager->init(); + $this->assertTrue($pager->getResults() instanceof PropelArrayCollection, 'getResults() returns a PropelArrayCollection if the query uses array hydration'); + } + + public function testGetIterator() + { + $this->createBooks(5); + + $pager = $this->getPager(4, 1); + $i = 0; + foreach ($pager as $book) { + $this->assertEquals('Book' . $i, $book->getTitle(), 'getIterator() returns an iterator'); + $i++; + } + $this->assertEquals(4, $i, 'getIterator() uses the results collection'); + } + + public function testIterateTwice() + { + $this->createBooks(5); + $pager = $this->getPager(4, 1); + + $i = 0; + foreach ($pager as $book) { + $this->assertEquals('Book' . $i, $book->getTitle(), 'getIterator() returns an iterator'); + $i++; + } + $this->assertEquals(4, $i, 'getIterator() uses the results collection'); + + $i = 0; + foreach ($pager as $book) { + $this->assertEquals('Book' . $i, $book->getTitle()); + $i++; + } + $this->assertEquals(4, $i, 'getIterator() can be called several times'); + } + + public function testSetPage() + { + $this->createBooks(5); + $pager = $this->getPager(2, 2); + $i = 2; + foreach ($pager as $book) { + $this->assertEquals('Book' . $i, $book->getTitle(), 'setPage() sets the list to start on a given page'); + $i++; + } + $this->assertEquals(4, $i, 'setPage() doesn\'t change the page count'); + } + + public function testIsFirstPage() + { + $this->createBooks(5); + $pager = $this->getPager(4, 1); + $this->assertTrue($pager->isFirstPage(), 'isFirstPage() returns true on the first page'); + $pager = $this->getPager(4, 2); + $this->assertFalse($pager->isFirstPage(), 'isFirstPage() returns false when not on the first page'); + } + + public function testIsLastPage() + { + $this->createBooks(5); + $pager = $this->getPager(4, 1); + $this->assertFalse($pager->isLastPage(), 'isLastPage() returns false when not on the last page'); + $pager = $this->getPager(4, 2); + $this->assertTrue($pager->isLastPage(), 'isLastPage() returns true on the last page'); + } + + public function testGetLastPage() + { + $this->createBooks(5); + $pager = $this->getPager(4, 1); + $this->assertEquals(2, $pager->getLastPage(), 'getLastPage() returns the last page number'); + $this->assertInternalType('integer', $pager->getLastPage(), 'getLastPage() returns an integer'); + } + + public function testIsFirstOnFirstPage() + { + $this->createBooks(5); + $pager = $this->getPager(3, 1); + foreach ($pager as $index => $book) { + if ($index == 0) { + $this->assertTrue($pager->isFirst()); + } else { + $this->assertFalse($pager->isFirst()); + } + } + } + + public function testIsFirstOnNonFirstPage() + { + $this->createBooks(5); + $pager = $this->getPager(3, 2); + foreach ($pager as $index => $book) { + if ($index == 0) { + $this->assertTrue($pager->isFirst()); + } else { + $this->assertFalse($pager->isFirst()); + } + } + } + + public function testIsLastOnNonLastPage() + { + $this->createBooks(5); + $pager = $this->getPager(3, 1); + foreach ($pager as $index => $book) { + if ($index == 2) { + $this->assertTrue($pager->isLast()); + } else { + $this->assertFalse($pager->isLast()); + } + } + } + + public function testIsLastOnLastPage() + { + $this->createBooks(5); + $pager = $this->getPager(3, 2); + foreach ($pager as $index => $book) { + if ($index == 1) { + $this->assertTrue($pager->isLast()); + } else { + $this->assertFalse($pager->isLast()); + } + } + } + + public function testIsEmptyIsTrueOnEmptyPagers() + { + $pager = $this->getPager(4, 1); + $this->assertTrue($pager->isEmpty()); + } + + public function testIsEmptyIsFalseOnNonEmptyPagers() + { + $this->createBooks(1); + $pager = $this->getPager(4, 1); + $this->assertFalse($pager->isEmpty()); + } + + public function testIsOddAndIsEven() + { + $this->createBooks(5); + $pager = $this->getPager(4, 1); + foreach ($pager as $index => $book) { + if ($index % 2) { + $this->assertTrue($pager->isOdd()); + $this->assertFalse($pager->isEven()); + } else { + $this->assertFalse($pager->isOdd()); + $this->assertTrue($pager->isEven()); + } + } + } - public function testIsLastPage() - { - $this->createBooks(5); - $pager = $this->getPager(4, 1); - $this->assertFalse($pager->isLastPage(), 'isLastPage() returns false when not on the last page'); - $pager = $this->getPager(4, 2); - $this->assertTrue($pager->isLastPage(), 'isLastPage() returns true on the last page'); - } } diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelPagerTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelPagerTest.php index 473f56c09..164b20639 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelPagerTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/util/PropelPagerTest.php @@ -7,7 +7,8 @@ * * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreEmptyTestBase.php'; + +require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/BookstoreEmptyTestBase.php'; /** * Test the utility class PropelPager @@ -20,12 +21,12 @@ class PropelPagerTest extends BookstoreEmptyTestBase { private $authorId; private $books; - + protected function setUp() { parent::setUp(); - BookstoreDataPopulator::populate(); - + BookstoreDataPopulator::populate(); + $cr = new Criteria(); $cr->add(AuthorPeer::LAST_NAME, "Rowling"); $cr->add(AuthorPeer::FIRST_NAME, "J.K."); @@ -90,7 +91,7 @@ class PropelPagerTest extends BookstoreEmptyTestBase $pager = new PropelPager($cr, "BookPeer", "doSelect"); $this->assertEquals(7, count($pager)); } - + public function testCountFirstPageWithLimits() { $cr = new Criteria(); @@ -98,7 +99,7 @@ class PropelPagerTest extends BookstoreEmptyTestBase $pager = new PropelPager($cr, "BookPeer", "doSelect", 1, 5); $this->assertEquals(5, count($pager)); } - + public function testCountLastPageWithLimits() { $cr = new Criteria(); @@ -106,7 +107,7 @@ class PropelPagerTest extends BookstoreEmptyTestBase $pager = new PropelPager($cr, "BookPeer", "doSelect", 2, 5); $this->assertEquals(2, count($pager)); } - + public function testIterateAll() { $cr = new Criteria(); @@ -118,7 +119,7 @@ class PropelPagerTest extends BookstoreEmptyTestBase } $this->assertEquals(7, $i); } - + public function testIterateWithLimits() { $cr = new Criteria(); @@ -130,7 +131,7 @@ class PropelPagerTest extends BookstoreEmptyTestBase } $this->assertEquals(2, $i); } - + public function testIterateCheckSecond() { $cr = new Criteria(); @@ -138,12 +139,12 @@ class PropelPagerTest extends BookstoreEmptyTestBase $cr->addAscendingOrderByColumn(BookPeer::TITLE); $pager = new PropelPager($cr, "BookPeer", "doSelect"); $books = array(); - foreach($pager as $book) { + foreach ($pager as $book) { $books[] = $book; } - $this->assertEquals("Harry Potter and the Goblet of Fire", $books[2]->getTitle()); + $this->assertEquals("Harry Potter and the Goblet of Fire", $books[2]->getTitle()); } - + public function testIterateTwice() { $cr = new Criteria(); @@ -151,10 +152,10 @@ class PropelPagerTest extends BookstoreEmptyTestBase $cr->addAscendingOrderByColumn(BookPeer::TITLE); $pager = new PropelPager($cr, "BookPeer", "doSelect"); $i = 0; - foreach($pager as $book) { + foreach ($pager as $book) { $i++; } - foreach($pager as $book) { + foreach ($pager as $book) { $i++; } $this->assertEquals(14, $i); diff --git a/airtime_mvc/library/propel/test/testsuite/runtime/validator/ValidatorTest.php b/airtime_mvc/library/propel/test/testsuite/runtime/validator/ValidatorTest.php index 323c58629..e642d68e9 100644 --- a/airtime_mvc/library/propel/test/testsuite/runtime/validator/ValidatorTest.php +++ b/airtime_mvc/library/propel/test/testsuite/runtime/validator/ValidatorTest.php @@ -1,7 +1,7 @@ setTitle("12345"); // min length is 10 + protected function setUp() + { + parent::setUp(); + BookstoreDataPopulator::populate(); + require_once dirname(__FILE__) . '/../../../tools/helpers/bookstore/validator/ISBNValidator.php'; + } - $res = $book->validate(); - $this->assertFalse($res, "Expected validation to fail."); + /** + * Test minLength validator. + * This also tests the ${value} substitution. + */ + public function testDoValidate_MinLength() + { + $book = new Book(); + $book->setTitle("12345"); // min length is 10 - $failures = $book->getValidationFailures(); - $this->assertSingleValidation($failures, "Book title must be more than 10 characters long."); - } + $res = $book->validate(); + $this->assertFalse($res, "Expected validation to fail."); - /** - * Test unique validator. - */ - public function testDoValidate_Unique() - { - $book = new Book(); - $book->setTitle("Don Juan"); + $failures = $book->getValidationFailures(); + $this->assertSingleValidation($failures, "Book title must be more than 10 characters long."); + } - $ret = $book->validate(); - $failures = $book->getValidationFailures(); - $this->assertSingleValidation($failures, "Book title already in database."); - } + /** + * Test unique validator. + */ + public function testDoValidate_Unique() + { + $book = new Book(); + $book->setTitle("Don Juan"); - /** - * Test recursive validaton. - */ - public function testDoValidate_Complex() - { - $book = new Book(); - $book->setTitle("12345"); // min length is 10 + $ret = $book->validate(); + $failures = $book->getValidationFailures(); + $this->assertSingleValidation($failures, "Book title already in database."); + } - $author = new Author(); - $author->setFirstName("Hans"); // last name required, valid email format, age > 0 + /** + * Test recursive validation. + */ + public function testDoValidate_Complex() + { + $book = new Book(); + $book->setTitle("12345"); // min length is 10 - $review = new Review(); - $review->setReviewDate("08/09/2001"); // reviewed_by column required, invalid status (new, reviewed, archived) + $author = new Author(); + $author->setFirstName("Hans"); // last name required, valid email format, age > 0 - $book->setAuthor($author); - $book->addReview($review); + $review = new Review(); + $review->setReviewDate("08/09/2001"); // reviewed_by column required, invalid status (new, reviewed, archived) - $res = $book->validate(); + $book->setAuthor($author); + $book->addReview($review); - $this->assertFalse($res, "Expected validation to fail."); + $res = $book->validate(); - $failures = $book->getValidationFailures(); + $this->assertFalse($res, "Expected validation to fail."); - /* Make sure 3 validation messages were returned; NOT 6, because the others were NULL */ - $this->assertEquals(3, count($failures), ""); + $failures = $book->getValidationFailures(); - /* Make sure correct columns failed */ - $expectedCols = array( - AuthorPeer::LAST_NAME, - BookPeer::TITLE, - ReviewPeer::REVIEWED_BY - ); - $returnedCols = array_keys($failures); + /* Make sure 3 validation messages were returned; NOT 6, because the others were NULL */ + $this->assertEquals(3, count($failures), ""); - /* implode for readability */ - $this->assertEquals(implode(',', $expectedCols), implode(',', $returnedCols)); - } + /* Make sure correct columns failed */ + $expectedCols = array( + AuthorPeer::LAST_NAME, + BookPeer::TITLE, + ReviewPeer::REVIEWED_BY + ); + $returnedCols = array_keys($failures); - /** - * Test recursive validaton with specified columns. - */ - public function testDoValidate_ComplexSpecifiedCols() - { - $book = new Book(); - $book->setTitle("12345"); // min length is 10 + /* implode for readability */ + $this->assertEquals(implode(',', $expectedCols), implode(',', $returnedCols)); + } - $author = new Author(); - $author->setFirstName("Hans"); // last name required, valid email format, age > 0 + /** + * Test recursive validation with specified columns. + */ + public function testDoValidate_ComplexSpecifiedCols() + { + $book = new Book(); + $book->setTitle("12345"); // min length is 10 - $review = new Review(); - $review->setReviewDate("08/09/2001"); // reviewed_by column required, invalid status (new, reviewed, archived) + $author = new Author(); + $author->setFirstName("Hans"); // last name required, valid email format, age > 0 - $book->setAuthor($author); - $book->addReview($review); + $review = new Review(); + $review->setReviewDate("08/09/2001"); // reviewed_by column required, invalid status (new, reviewed, archived) - $cols = array(AuthorPeer::LAST_NAME, ReviewPeer::REVIEWED_BY); + $book->setAuthor($author); + $book->addReview($review); - $res = $book->validate($cols); + $cols = array(AuthorPeer::LAST_NAME, ReviewPeer::REVIEWED_BY); - $this->assertFalse($res, "Expected validation to fail."); + $res = $book->validate($cols); - $failures = $book->getValidationFailures(); + $this->assertFalse($res, "Expected validation to fail."); - /* Make sure 3 validation messages were returned; NOT 6, because the others were NULL */ - $this->assertEquals(2, count($failures), ""); + $failures = $book->getValidationFailures(); - /* Make sure correct columns failed */ - $expectedCols = array( - AuthorPeer::LAST_NAME, - ReviewPeer::REVIEWED_BY - ); + /* Make sure 3 validation messages were returned; NOT 6, because the others were NULL */ + $this->assertEquals(2, count($failures), ""); - $returnedCols = array_keys($failures); + /* Make sure correct columns failed */ + $expectedCols = array( + AuthorPeer::LAST_NAME, + ReviewPeer::REVIEWED_BY + ); - /* implode for readability */ - $this->assertEquals(implode(',', $expectedCols), implode(',', $returnedCols)); - } + $returnedCols = array_keys($failures); - /** - * Test the fact that validators should not complain NULL values for non-required columns. - */ - public function testDoValidate_Nulls() - { - $author = new Author(); - $author->setFirstName("Malcolm"); // last name required, valid email format, age > 0 - $author->setLastName("X"); + /* implode for readability */ + $this->assertEquals(implode(',', $expectedCols), implode(',', $returnedCols)); + } - $author->setEmail(null); // just to be explicit, of course these are the defaults anyway - $author->setAge(null); + /** + * Test the fact that validators should not complain NULL values for non-required columns. + */ + public function testDoValidate_Nulls() + { + $author = new Author(); + $author->setFirstName("Malcolm"); // last name required, valid email format, age > 0 + $author->setLastName("X"); - $res = $author->validate(); + $author->setEmail(null); // just to be explicit, of course these are the defaults anyway + $author->setAge(null); + $res = $author->validate(); - $this->assertTrue($res, "Expected validation to pass with NULL columns"); + $this->assertTrue($res, "Expected validation to pass with NULL columns"); - $author->setEmail('malcolm@'); // fail - $res = $author->validate(); + $author->setEmail('malcolm@'); // fail + $res = $author->validate(); - $this->assertFalse($res, "Expected validation to fail."); + $this->assertFalse($res, "Expected validation to fail."); - $failures = $author->getValidationFailures(); - $this->assertEquals(1, count($failures), "Expected 1 column to fail validation."); - $this->assertEquals(array(AuthorPeer::EMAIL), array_keys($failures), "Expected EMAIL to fail validation."); + $failures = $author->getValidationFailures(); + $this->assertEquals(1, count($failures), "Expected 1 column to fail validation."); + $this->assertEquals(array(AuthorPeer::EMAIL), array_keys($failures), "Expected EMAIL to fail validation."); - } + } - public function testDoValidate_BasicValidatorObj() - { - $author = new Author(); - $author->setFirstName("Malcolm"); // last name required, valid email format, age > 0 - $author->setLastName("X"); - $author->setEmail('malcolm@'); // fail + public function testDoValidate_BasicValidatorObj() + { + $author = new Author(); + $author->setFirstName("Malcolm"); // last name required, valid email format, age > 0 + $author->setLastName("X"); + $author->setEmail('malcolm@'); // fail - $res = $author->validate(); + $res = $author->validate(); - $this->assertFalse($res, "Expected validation to fail."); + $this->assertFalse($res, "Expected validation to fail."); - $failures = $author->getValidationFailures(); + $failures = $author->getValidationFailures(); - $this->assertEquals(1, count($failures), "Expected 1 column to fail validation."); - $this->assertEquals(array(AuthorPeer::EMAIL), array_keys($failures), "Expected EMAIL to fail validation."); + $this->assertEquals(1, count($failures), "Expected 1 column to fail validation."); + $this->assertEquals(array(AuthorPeer::EMAIL), array_keys($failures), "Expected EMAIL to fail validation."); - $validator = $failures[AuthorPeer::EMAIL]->getValidator(); - $this->assertTrue($validator instanceof MatchValidator, "Expected validator that failed to be MatchValidator"); + $validator = $failures[AuthorPeer::EMAIL]->getValidator(); + $this->assertTrue($validator instanceof MatchValidator, "Expected validator that failed to be MatchValidator"); - } + } - public function testDoValidate_CustomValidator() - { - $book = new Book(); - $book->setTitle("testDoValidate_CustomValidator"); // (valid) - $book->setISBN("Foo.Bar.Baz"); // (invalid) + public function testDoValidate_CustomValidator() + { + $book = new Book(); + $book->setTitle("testDoValidate_CustomValidator"); // (valid) + $book->setISBN("Foo.Bar.Baz"); // (invalid) - $res = $book->validate(); + $res = $book->validate(); - $this->assertFalse($res, "Expected validation to fail."); + $this->assertFalse($res, "Expected validation to fail."); - $failures = $book->getValidationFailures(); + $failures = $book->getValidationFailures(); - $this->assertEquals(1, count($failures), "Expected 1 column to fail validation."); - $this->assertEquals(array(BookPeer::ISBN), array_keys($failures), "Expected EMAIL to fail validation."); + $this->assertEquals(1, count($failures), "Expected 1 column to fail validation."); + $this->assertEquals(array(BookPeer::ISBN), array_keys($failures), "Expected EMAIL to fail validation."); - $validator = $failures[BookPeer::ISBN]->getValidator(); - $this->assertType('ISBNValidator', $validator, "Expected validator that failed to be ISBNValidator"); - } + $validator = $failures[BookPeer::ISBN]->getValidator(); + $this->assertInstanceOf('ISBNValidator', $validator, "Expected validator that failed to be ISBNValidator"); + } - protected function assertSingleValidation($ret, $expectedMsg) - { - /* Make sure validation failed */ - $this->assertTrue($ret !== true, "Expected validation to fail !"); + protected function assertSingleValidation($ret, $expectedMsg) + { + /* Make sure validation failed */ + $this->assertTrue($ret !== true, "Expected validation to fail !"); - /* Make sure 1 validation message was returned */ - $count = count($ret); - $this->assertTrue($count === 1, "Expected that exactly one validation failed ($count) !"); + /* Make sure 1 validation message was returned */ + $count = count($ret); + $this->assertTrue($count === 1, "Expected that exactly one validation failed ($count) !"); - /* Make sure expected validation message was returned */ - $el = array_shift($ret); - $this->assertEquals($el->getMessage(), $expectedMsg, "Got unexpected validation failed message: " . $el->getMessage()); - } + /* Make sure expected validation message was returned */ + $el = array_shift($ret); + $this->assertEquals($el->getMessage(), $expectedMsg, "Got unexpected validation failed message: " . $el->getMessage()); + } } diff --git a/airtime_mvc/library/propel/test/tools/helpers/BaseTestCase.php b/airtime_mvc/library/propel/test/tools/helpers/BaseTestCase.php index f3827c24b..7fd35f309 100644 --- a/airtime_mvc/library/propel/test/tools/helpers/BaseTestCase.php +++ b/airtime_mvc/library/propel/test/tools/helpers/BaseTestCase.php @@ -9,7 +9,6 @@ */ require_once dirname(__FILE__) . '/../../../runtime/lib/Propel.php'; -require_once 'PHPUnit/Framework/TestCase.php'; /** * Base functionality to be extended by all Propel test cases. Test @@ -18,13 +17,13 @@ require_once 'PHPUnit/Framework/TestCase.php'; * @author Hans Lellelid (Propel) * @author Daniel Rall (Torque) * @author Christopher Elkins (Torque) - * @version $Revision: 1773 $ + * @version $Revision$ */ -abstract class BaseTestCase extends PHPUnit_Framework_TestCase { - - /** - * Conditional compilation flag. - */ - const DEBUG = false; +abstract class BaseTestCase extends PHPUnit_Framework_TestCase +{ + /** + * Conditional compilation flag. + */ + const DEBUG = false; } diff --git a/airtime_mvc/library/propel/test/tools/helpers/DummyPlatforms.php b/airtime_mvc/library/propel/test/tools/helpers/DummyPlatforms.php new file mode 100644 index 000000000..35efe7260 --- /dev/null +++ b/airtime_mvc/library/propel/test/tools/helpers/DummyPlatforms.php @@ -0,0 +1,11 @@ +oldPropelConfiguration = Propel::getConfiguration(); + } + + $xmlDom = new DOMDocument(); + $xmlDom->load(dirname(__FILE__) . '/../../fixtures/reverse/mysql/runtime-conf.xml'); + $xml = simplexml_load_string($xmlDom->saveXML()); + $phpconf = PlatformDatabaseBuildTimeBaseTask::simpleXmlToArray($xml); + + Propel::setConfiguration($phpconf); + Propel::initialize(); + $this->con = Propel::getConnection('reverse-bookstore'); + + $this->parser = new MysqlSchemaParser(Propel::getConnection('reverse-bookstore')); + $this->parser->setGeneratorConfig(new QuickGeneratorConfig(new MysqlPlatform())); + + parent::setUp(); + } + + public function readDatabase() + { + $this->database = new Database(); + $this->database->setPlatform(new MysqlPlatform()); + $this->parser->parse($this->database); + } + + protected function tearDown() + { + if ($this->oldPropelConfiguration) { + Propel::setConfiguration($this->oldPropelConfiguration); + Propel::initialize(); + } + parent::tearDown(); + } + + /** + * Detects the differences between current connected database and $pDatabase + * and updates the schema. This does not DROP tables. + * + * @param Database $pDatabase + */ + public function updateSchema($pDatabase) + { + $diff = PropelDatabaseComparator::computeDiff($this->database, $pDatabase); + $sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff); + + $statements = PropelSQLParser::parseString($sql); + foreach ($statements as $statement) { + if (strpos($statement, 'DROP') === 0) { + // drop statements cause errors since the table doesn't exist + continue; + } + $stmt = $this->con->prepare($statement); + if ($stmt instanceof PDOStatement) { + // only execute if has no error + $stmt->execute(); + } + } + } +} + +/* + * We needs this wrapper since `PropelConvertConfTask::simpleXmlToArray` is protected. + */ +class PlatformDatabaseBuildTimeBaseTask extends PropelConvertConfTask +{ + public static function simpleXmlToArray($xml) + { + return parent::simpleXmlToArray($xml); + } +} diff --git a/airtime_mvc/library/propel/test/tools/helpers/bookstore/BookstoreDataPopulator.php b/airtime_mvc/library/propel/test/tools/helpers/bookstore/BookstoreDataPopulator.php index 5dc3902be..acbbe4db6 100644 --- a/airtime_mvc/library/propel/test/tools/helpers/bookstore/BookstoreDataPopulator.php +++ b/airtime_mvc/library/propel/test/tools/helpers/bookstore/BookstoreDataPopulator.php @@ -22,226 +22,294 @@ define('_LOB_SAMPLE_FILE_PATH', dirname(__FILE__) . '/../../../etc/lob'); class BookstoreDataPopulator { - public static function populate($con = null) - { - if($con === null) { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - } - $con->beginTransaction(); - - // Add publisher records - // --------------------- + public static function populate($con = null, $loadMoreBooks = false) + { + if ($con === null) { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + } + $con->beginTransaction(); - $scholastic = new Publisher(); - $scholastic->setName("Scholastic"); - // do not save, will do later to test cascade + // Add publisher records + // --------------------- - $morrow = new Publisher(); - $morrow->setName("William Morrow"); - $morrow->save($con); - $morrow_id = $morrow->getId(); + $scholastic = new Publisher(); + $scholastic->setName("Scholastic"); + // do not save, will do later to test cascade - $penguin = new Publisher(); - $penguin->setName("Penguin"); - $penguin->save(); - $penguin_id = $penguin->getId(); + $morrow = new Publisher(); + $morrow->setName("William Morrow"); + $morrow->save($con); + $morrow_id = $morrow->getId(); - $vintage = new Publisher(); - $vintage->setName("Vintage"); - $vintage->save($con); - $vintage_id = $vintage->getId(); + $penguin = new Publisher(); + $penguin->setName("Penguin"); + $penguin->save(); + $penguin_id = $penguin->getId(); - $rowling = new Author(); - $rowling->setFirstName("J.K."); - $rowling->setLastName("Rowling"); - // no save() + $vintage = new Publisher(); + $vintage->setName("Vintage"); + $vintage->save($con); + $vintage_id = $vintage->getId(); - $stephenson = new Author(); - $stephenson->setFirstName("Neal"); - $stephenson->setLastName("Stephenson"); - $stephenson->save($con); - $stephenson_id = $stephenson->getId(); + $rowling = new Author(); + $rowling->setFirstName("J.K."); + $rowling->setLastName("Rowling"); + // no save() - $byron = new Author(); - $byron->setFirstName("George"); - $byron->setLastName("Byron"); - $byron->save($con); - $byron_id = $byron->getId(); + $stephenson = new Author(); + $stephenson->setFirstName("Neal"); + $stephenson->setLastName("Stephenson"); + $stephenson->save($con); + $stephenson_id = $stephenson->getId(); - $grass = new Author(); - $grass->setFirstName("Gunter"); - $grass->setLastName("Grass"); - $grass->save($con); - $grass_id = $grass->getId(); + $byron = new Author(); + $byron->setFirstName("George"); + $byron->setLastName("Byron"); + $byron->save($con); + $byron_id = $byron->getId(); - $phoenix = new Book(); - $phoenix->setTitle("Harry Potter and the Order of the Phoenix"); - $phoenix->setISBN("043935806X"); - $phoenix->setAuthor($rowling); - $phoenix->setPublisher($scholastic); - $phoenix->setPrice(10.99); - $phoenix->save($con); - $phoenix_id = $phoenix->getId(); + $grass = new Author(); + $grass->setFirstName("Gunter"); + $grass->setLastName("Grass"); + $grass->save($con); + $grass_id = $grass->getId(); - $qs = new Book(); - $qs->setISBN("0380977427"); - $qs->setTitle("Quicksilver"); - $qs->setPrice(11.99); - $qs->setAuthor($stephenson); - $qs->setPublisher($morrow); - $qs->save($con); - $qs_id = $qs->getId(); + $phoenix = new Book(); + $phoenix->setTitle("Harry Potter and the Order of the Phoenix"); + $phoenix->setISBN("043935806X"); + $phoenix->setAuthor($rowling); + $phoenix->setPublisher($scholastic); + $phoenix->setPrice(10.99); + $phoenix->save($con); + $phoenix_id = $phoenix->getId(); - $dj = new Book(); - $dj->setISBN("0140422161"); - $dj->setTitle("Don Juan"); - $dj->setPrice(12.99); - $dj->setAuthor($byron); - $dj->setPublisher($penguin); - $dj->save($con); - $dj_id = $dj->getId(); + $qs = new Book(); + $qs->setISBN("0380977427"); + $qs->setTitle("Quicksilver"); + $qs->setPrice(11.99); + $qs->setAuthor($stephenson); + $qs->setPublisher($morrow); + $qs->save($con); + $qs_id = $qs->getId(); - $td = new Book(); - $td->setISBN("067972575X"); - $td->setTitle("The Tin Drum"); - $td->setPrice(13.99); - $td->setAuthor($grass); - $td->setPublisher($vintage); - $td->save($con); - $td_id = $td->getId(); + $dj = new Book(); + $dj->setISBN("0140422161"); + $dj->setTitle("Don Juan"); + $dj->setPrice(12.99); + $dj->setAuthor($byron); + $dj->setPublisher($penguin); + $dj->save($con); + $dj_id = $dj->getId(); - $r1 = new Review(); - $r1->setBook($phoenix); - $r1->setReviewedBy("Washington Post"); - $r1->setRecommended(true); - $r1->setReviewDate(time()); - $r1->save($con); - $r1_id = $r1->getId(); + $td = new Book(); + $td->setISBN("067972575X"); + $td->setTitle("The Tin Drum"); + $td->setPrice(13.99); + $td->setAuthor($grass); + $td->setPublisher($vintage); + $td->save($con); + $td_id = $td->getId(); - $r2 = new Review(); - $r2->setBook($phoenix); - $r2->setReviewedBy("New York Times"); - $r2->setRecommended(false); - $r2->setReviewDate(time()); - $r2->save($con); - $r2_id = $r2->getId(); + if ($loadMoreBooks) { + $td2 = new Book(); + $td2->setISBN("067972575Y"); + $td2->setTitle("The Tin Drum 2"); + $td2->setPrice(23.99); + $td2->setAuthor($grass); + $td2->save($con); + $td2_id = $td2->getId(); + } - $blob_path = _LOB_SAMPLE_FILE_PATH . '/tin_drum.gif'; - $clob_path = _LOB_SAMPLE_FILE_PATH . '/tin_drum.txt'; + $r1 = new Review(); + $r1->setBook($phoenix); + $r1->setReviewedBy("Washington Post"); + $r1->setRecommended(true); + $r1->setReviewDate(time()); + $r1->save($con); + $r1_id = $r1->getId(); - $m1 = new Media(); - $m1->setBook($td); - $m1->setCoverImage(file_get_contents($blob_path)); - // CLOB is broken in PDO OCI, see http://pecl.php.net/bugs/bug.php?id=7943 - if (get_class(Propel::getDB()) != "DBOracle") { - $m1->setExcerpt(file_get_contents($clob_path)); - } - $m1->save($con); + $r2 = new Review(); + $r2->setBook($phoenix); + $r2->setReviewedBy("New York Times"); + $r2->setRecommended(false); + $r2->setReviewDate(time()); + $r2->save($con); + $r2_id = $r2->getId(); - // Add book list records - // --------------------- - // (this is for many-to-many tests) + $blob_path = _LOB_SAMPLE_FILE_PATH . '/tin_drum.gif'; + $clob_path = _LOB_SAMPLE_FILE_PATH . '/tin_drum.txt'; - $blc1 = new BookClubList(); - $blc1->setGroupLeader("Crazyleggs"); - $blc1->setTheme("Happiness"); + $m1 = new Media(); + $m1->setBook($td); + $m1->setCoverImage(file_get_contents($blob_path)); + // CLOB is broken in PDO OCI, see http://pecl.php.net/bugs/bug.php?id=7943 + if (get_class(Propel::getDB()) != "DBOracle") { + $m1->setExcerpt(file_get_contents($clob_path)); + } + $m1->save($con); - $brel1 = new BookListRel(); - $brel1->setBook($phoenix); + // Add book list records + // --------------------- + // (this is for many-to-many tests) - $brel2 = new BookListRel(); - $brel2->setBook($dj); + $blc1 = new BookClubList(); + $blc1->setGroupLeader("Crazyleggs"); + $blc1->setTheme("Happiness"); - $blc1->addBookListRel($brel1); - $blc1->addBookListRel($brel2); - - $blc1->save(); + $brel1 = new BookListRel(); + $brel1->setBook($phoenix); - $bemp1 = new BookstoreEmployee(); - $bemp1->setName("John"); - $bemp1->setJobTitle("Manager"); + $brel2 = new BookListRel(); + $brel2->setBook($dj); - $bemp2 = new BookstoreEmployee(); - $bemp2->setName("Pieter"); - $bemp2->setJobTitle("Clerk"); - $bemp2->setSupervisor($bemp1); - $bemp2->save($con); + $blc1->addBookListRel($brel1); + $blc1->addBookListRel($brel2); - $role = new AcctAccessRole(); - $role->setName("Admin"); + $blc1->save(); - $bempacct = new BookstoreEmployeeAccount(); - $bempacct->setBookstoreEmployee($bemp1); - $bempacct->setAcctAccessRole($role); - $bempacct->setLogin("john"); - $bempacct->setPassword("johnp4ss"); - $bempacct->save($con); + $bemp1 = new BookstoreEmployee(); + $bemp1->setName("John"); + $bemp1->setJobTitle("Manager"); - // Add bookstores + $bemp2 = new BookstoreEmployee(); + $bemp2->setName("Pieter"); + $bemp2->setJobTitle("Clerk"); + $bemp2->setSupervisor($bemp1); + $bemp2->save($con); - $store = new Bookstore(); - $store->setStoreName("Amazon"); - $store->setPopulationServed(5000000000); // world population - $store->setTotalBooks(300); - $store->save($con); + $bemp3 = new BookstoreCashier(); + $bemp3->setName("Tim"); + $bemp3->setJobTitle("Cashier"); + $bemp3->save($con); - $store = new Bookstore(); - $store->setStoreName("Local Store"); - $store->setPopulationServed(20); - $store->setTotalBooks(500000); - $store->save($con); - - $con->commit(); - } - - public static function populateOpinionFavorite($con = null) - { - if($con === null) { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - } - $con->beginTransaction(); - - $book1 = BookPeer::doSelectOne(new Criteria(), $con); - $reader1 = new BookReader(); - $reader1->save($con); - - $bo = new BookOpinion(); - $bo->setBook($book1); - $bo->setBookReader($reader1); - $bo->save($con); - - $rf = new ReaderFavorite(); - $rf->setBookOpinion($bo); - $rf->save($con); - - $con->commit(); - } + $role = new AcctAccessRole(); + $role->setName("Admin"); - public static function depopulate($con = null) - { - if($con === null) { - $con = Propel::getConnection(BookPeer::DATABASE_NAME); - } - $con->beginTransaction(); - AuthorPeer::doDeleteAll($con); - BookstorePeer::doDeleteAll($con); - BookstoreContestPeer::doDeleteAll($con); - BookstoreContestEntryPeer::doDeleteAll($con); - BookstoreEmployeePeer::doDeleteAll($con); - BookstoreEmployeeAccountPeer::doDeleteAll($con); - BookstoreSalePeer::doDeleteAll($con); - BookClubListPeer::doDeleteAll($con); - BookOpinionPeer::doDeleteAll($con); - BookReaderPeer::doDeleteAll($con); - BookListRelPeer::doDeleteAll($con); - BookPeer::doDeleteAll($con); - ContestPeer::doDeleteAll($con); - CustomerPeer::doDeleteAll($con); - MediaPeer::doDeleteAll($con); - PublisherPeer::doDeleteAll($con); - ReaderFavoritePeer::doDeleteAll($con); - ReviewPeer::doDeleteAll($con); - $con->commit(); - } + $bempacct = new BookstoreEmployeeAccount(); + $bempacct->setBookstoreEmployee($bemp1); + $bempacct->setAcctAccessRole($role); + $bempacct->setLogin("john"); + $bempacct->setPassword("johnp4ss"); + $bempacct->save($con); + + // Add bookstores + + $store = new Bookstore(); + $store->setStoreName("Amazon"); + $store->setPopulationServed(5000000000); // world population + $store->setTotalBooks(300); + $store->save($con); + + $store = new Bookstore(); + $store->setStoreName("Local Store"); + $store->setPopulationServed(20); + $store->setTotalBooks(500000); + $store->save($con); + + $summary = new BookSummary(); + $summary->setSummarizedBook($phoenix); + $summary->setSummary("Harry Potter does some amazing magic!"); + $summary->save(); + + // Add release_pool and record_label + $acuna = new RecordLabel(); + $acuna->setAbbr('acuna'); + $acuna->setName('Acunadeep'); + $acuna->save(); + + $fade = new RecordLabel(); + $fade->setAbbr('fade'); + $fade->setName('Fade Records'); + $fade->save(); + + $pool = new ReleasePool(); + $pool->setName('D.Chmelyuk - Revert Me Back'); + $pool->setRecordLabel($acuna); + $pool->save(); + + $pool = new ReleasePool(); + $pool->setName('VIF & Lola Palmer - Dreamer'); + $pool->setRecordLabel($acuna); + $pool->save(); + + $pool = new ReleasePool(); + $pool->setName('Lola Palmer - Do You Belong To Me'); + $pool->setRecordLabel($acuna); + $pool->save(); + + $pool = new ReleasePool(); + $pool->setName('Chris Forties - Despegue (foem.info Runners Up Remixes)'); + $pool->setRecordLabel($fade); + $pool->save(); + + $con->commit(); + } + + public static function populateOpinionFavorite($con = null) + { + if ($con === null) { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + } + $con->beginTransaction(); + + $book1 = BookPeer::doSelectOne(new Criteria(), $con); + $reader1 = new BookReader(); + $reader1->save($con); + + $bo = new BookOpinion(); + $bo->setBook($book1); + $bo->setBookReader($reader1); + $bo->save($con); + + $rf = new ReaderFavorite(); + $rf->setBookOpinion($bo); + $rf->save($con); + + $con->commit(); + } + + public static function depopulate($con = null) + { + $peerClasses = array( + 'AuthorPeer', + 'BookstorePeer', + 'BookstoreContestPeer', + 'BookstoreContestEntryPeer', + 'BookstoreEmployeePeer', + 'BookstoreEmployeeAccountPeer', + 'BookstoreSalePeer', + 'BookClubListPeer', + 'BookOpinionPeer', + 'BookReaderPeer', + 'BookListRelPeer', + 'BookPeer', + 'ContestPeer', + 'CustomerPeer', + 'MediaPeer', + 'PublisherPeer', + 'ReaderFavoritePeer', + 'ReviewPeer', + 'BookSummaryPeer', + ); + // free the memory from existing objects + foreach ($peerClasses as $peerClass) { + // $peerClass::$instances crashes on PHP 5.2, see http://www.propelorm.org/ticket/1388 + $r = new ReflectionClass($peerClass); + $p = $r->getProperty('instances'); + foreach ($p->getValue() as $o) { + $o->clearAllReferences(); + } + } + // delete records from the database + if ($con === null) { + $con = Propel::getConnection(BookPeer::DATABASE_NAME); + } + $con->beginTransaction(); + foreach ($peerClasses as $peerClass) { + // $peerClass::doDeleteAll() crashes on PHP 5.2, see http://www.propelorm.org/ticket/1388 + call_user_func(array($peerClass, 'doDeleteAll'), $con); + } + $con->commit(); + } } diff --git a/airtime_mvc/library/propel/test/tools/helpers/bookstore/BookstoreEmptyTestBase.php b/airtime_mvc/library/propel/test/tools/helpers/bookstore/BookstoreEmptyTestBase.php index 08efab6a8..50e322a83 100644 --- a/airtime_mvc/library/propel/test/tools/helpers/bookstore/BookstoreEmptyTestBase.php +++ b/airtime_mvc/library/propel/test/tools/helpers/bookstore/BookstoreEmptyTestBase.php @@ -9,30 +9,21 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; -require_once 'tools/helpers/bookstore/BookstoreDataPopulator.php'; +require_once 'BookstoreTestBase.php'; +require_once 'BookstoreDataPopulator.php'; /** * Base class contains some methods shared by subclass test cases. */ abstract class BookstoreEmptyTestBase extends BookstoreTestBase { - /** - * This is run before each unit test; it populates the database. - */ - protected function setUp() - { - parent::setUp(); - BookstoreDataPopulator::depopulate($this->con); - } - - /** - * This is run after each unit test. It empties the database. - */ - protected function tearDown() - { - BookstoreDataPopulator::depopulate($this->con); - parent::tearDown(); - } + /** + * This is run before each unit test; it empties the database. + */ + protected function setUp() + { + parent::setUp(); + BookstoreDataPopulator::depopulate($this->con); + } } diff --git a/airtime_mvc/library/propel/test/tools/helpers/bookstore/BookstoreTestBase.php b/airtime_mvc/library/propel/test/tools/helpers/bookstore/BookstoreTestBase.php index 4ea139e6d..2991d1a8f 100644 --- a/airtime_mvc/library/propel/test/tools/helpers/bookstore/BookstoreTestBase.php +++ b/airtime_mvc/library/propel/test/tools/helpers/bookstore/BookstoreTestBase.php @@ -8,40 +8,40 @@ * @license MIT License */ -require_once 'PHPUnit/Framework/TestCase.php'; -set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes"); -Propel::init('fixtures/bookstore/build/conf/bookstore-conf.php'); +require_once dirname(__FILE__) . '/../../../../runtime/lib/Propel.php'; +set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../../fixtures/bookstore/build/classes')); +Propel::init(dirname(__FILE__) . '/../../../fixtures/bookstore/build/conf/bookstore-conf.php'); /** * Base class contains some methods shared by subclass test cases. */ abstract class BookstoreTestBase extends PHPUnit_Framework_TestCase { - protected $con; - - /** - * This is run before each unit test; it populates the database. - */ - protected function setUp() - { - parent::setUp(); - $this->con = Propel::getConnection(BookPeer::DATABASE_NAME); - $this->con->beginTransaction(); - } + protected $con; - /** - * This is run after each unit test. It empties the database. - */ - protected function tearDown() - { - parent::tearDown(); - // Only commit if the transaction hasn't failed. - // This is because tearDown() is also executed on a failed tests, - // and we don't want to call PropelPDO::commit() in that case - // since it will trigger an exception on its own - // ('Cannot commit because a nested transaction was rolled back') - if ($this->con->isCommitable()) { - $this->con->commit(); - } - } + /** + * This is run before each unit test; it populates the database. + */ + protected function setUp() + { + parent::setUp(); + $this->con = Propel::getConnection(BookPeer::DATABASE_NAME); + $this->con->beginTransaction(); + } + + /** + * This is run after each unit test. It empties the database. + */ + protected function tearDown() + { + parent::tearDown(); + // Only commit if the transaction hasn't failed. + // This is because tearDown() is also executed on a failed tests, + // and we don't want to call PropelPDO::commit() in that case + // since it will trigger an exception on its own + // ('Cannot commit because a nested transaction was rolled back') + if ($this->con->isCommitable()) { + $this->con->commit(); + } + } } diff --git a/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/AddClassBehavior.php b/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/AddClassBehavior.php new file mode 100644 index 000000000..5ff0f9ca0 --- /dev/null +++ b/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/AddClassBehavior.php @@ -0,0 +1,16 @@ +getStubObjectBuilder()->getUnprefixedClassname() . 'FooClass'; + } + + /** + * Adds class phpdoc comment and opening of class. + * @param string &$script The script will be modified in this method. + */ + protected function addClassOpen(&$script) + { + $table = $this->getTable(); + $tableName = $table->getName(); + $script .= " +/** + * Test class for Additional builder enabled on the '$tableName' table. + * + * @package propel.generator.".$this->getPackage()." + */ +class ".$this->getClassname()." +{ +"; + } + + /** + * Specifies the methods that are added as part of the basic OM class. + * This can be overridden by subclasses that wish to add more methods. + * @see ObjectBuilder::addClassBody() + */ + protected function addClassBody(&$script) + { + $script .= " // no code"; + } + + /** + * Closes class. + * @param string &$script The script will be modified in this method. + */ + protected function addClassClose(&$script) + { + $script .= " +} // " . $this->getClassname() . " +"; + } +} diff --git a/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/BookstoreNestedSetTestBase.php b/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/BookstoreNestedSetTestBase.php index 222c0eb50..16cfde179 100644 --- a/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/BookstoreNestedSetTestBase.php +++ b/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/BookstoreNestedSetTestBase.php @@ -8,139 +8,144 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../BookstoreTestBase.php'; -class BookstoreNestedSetTestBase extends BookstoreTestBase +abstract class BookstoreNestedSetTestBase extends BookstoreTestBase { - public function dumpNodes($nodes) - { - $tree = array(); - foreach ($nodes as $node) { - $tree[$node->getTitle()] = array($node->getLeftValue(), $node->getRightValue(), $node->getLevel()); - } - return $tree; - } - - /** - * Tree used for tests - * t1 - * | \ - * t2 t3 - * | \ - * t4 t5 - * | \ - * t6 t7 - */ - protected function initTree() - { - Table9Peer::doDeleteAll(); - $ret = array(); - // shuffling the results so the db order is not the natural one - $fixtures = array( - 't2' => array(2, 3, 1), - 't5' => array(7, 12, 2), - 't4' => array(5, 6, 2), - 't7' => array(10, 11, 3), - 't1' => array(1, 14, 0), - 't6' => array(8, 9, 3), - 't3' => array(4, 13, 1), - ); - /* in correct order, this is: - 't1' => array(1, 14, 0), - 't2' => array(2, 3, 1), - 't3' => array(4, 13, 1), - 't4' => array(5, 6, 2), - 't5' => array(7, 12, 2), - 't6' => array(8, 9, 3), - 't7' => array(10, 11, 3), - */ - foreach ($fixtures as $key => $data) { - $t = new PublicTable9(); - $t->setTitle($key); - $t->setLeftValue($data[0]); - $t->setRightValue($data[1]); - $t->setLevel($data[2]); - $t->save(); - $ret[$key]= $t; - } - // reordering the results in the fixtures - ksort($ret); - return array_values($ret); - } - - protected function dumpTree() - { - $c = new Criteria(); - $c->addAscendingOrderBycolumn(Table9Peer::TITLE); - return $this->dumpNodes(Table9Peer::doSelect($c)); - } - - /** - * Tree used for tests - * Scope 1 - * t1 - * | \ - * t2 t3 - * | \ - * t4 t5 - * | \ - * t6 t7 - * Scope 2 - * t8 - * | \ - * t9 t10 - */ - protected function initTreeWithScope() - { - Table10Peer::doDeleteAll(); - $ret = array(); - $fixtures = array( - 't1' => array(1, 14, 0, 1), - 't2' => array(2, 3, 1, 1), - 't3' => array(4, 13, 1, 1), - 't4' => array(5, 6, 2, 1), - 't5' => array(7, 12, 2, 1), - 't6' => array(8, 9, 3, 1), - 't7' => array(10, 11, 3, 1), - 't8' => array(1, 6, 0, 2), - 't9' => array(2, 3, 1, 2), - 't10' => array(4, 5, 1, 2), - ); - foreach ($fixtures as $key => $data) { - $t = new PublicTable10(); - $t->setTitle($key); - $t->setLeftValue($data[0]); - $t->setRightValue($data[1]); - $t->setLevel($data[2]); - $t->setScopeValue($data[3]); - $t->save(); - $ret []= $t; - } - return $ret; - } - - protected function dumpTreeWithScope($scope) - { - $c = new Criteria(); - $c->add(Table10Peer::SCOPE_COL, $scope); - $c->addAscendingOrderBycolumn(Table10Peer::TITLE); - return $this->dumpNodes(Table10Peer::doSelect($c)); - } + public function dumpNodes($nodes) + { + $tree = array(); + foreach ($nodes as $node) { + $tree[$node->getTitle()] = array($node->getLeftValue(), $node->getRightValue(), $node->getLevel()); + } + + return $tree; + } + + /** + * Tree used for tests + * t1 + * | \ + * t2 t3 + * | \ + * t4 t5 + * | \ + * t6 t7 + */ + protected function initTree() + { + Table9Peer::doDeleteAll(); + $ret = array(); + // shuffling the results so the db order is not the natural one + $fixtures = array( + 't2' => array(2, 3, 1), + 't5' => array(7, 12, 2), + 't4' => array(5, 6, 2), + 't7' => array(10, 11, 3), + 't1' => array(1, 14, 0), + 't6' => array(8, 9, 3), + 't3' => array(4, 13, 1), + ); + /* in correct order, this is: + 't1' => array(1, 14, 0), + 't2' => array(2, 3, 1), + 't3' => array(4, 13, 1), + 't4' => array(5, 6, 2), + 't5' => array(7, 12, 2), + 't6' => array(8, 9, 3), + 't7' => array(10, 11, 3), + */ + foreach ($fixtures as $key => $data) { + $t = new PublicTable9(); + $t->setTitle($key); + $t->setLeftValue($data[0]); + $t->setRightValue($data[1]); + $t->setLevel($data[2]); + $t->save(); + $ret[$key]= $t; + } + // reordering the results in the fixtures + ksort($ret); + + return array_values($ret); + } + + protected function dumpTree() + { + $c = new Criteria(); + $c->addAscendingOrderBycolumn(Table9Peer::TITLE); + + return $this->dumpNodes(Table9Peer::doSelect($c)); + } + + /** + * Tree used for tests + * Scope 1 + * t1 + * | \ + * t2 t3 + * | \ + * t4 t5 + * | \ + * t6 t7 + * Scope 2 + * t8 + * | \ + * t9 t10 + */ + protected function initTreeWithScope() + { + Table10Peer::doDeleteAll(); + $ret = array(); + $fixtures = array( + 't1' => array(1, 14, 0, 1), + 't2' => array(2, 3, 1, 1), + 't3' => array(4, 13, 1, 1), + 't4' => array(5, 6, 2, 1), + 't5' => array(7, 12, 2, 1), + 't6' => array(8, 9, 3, 1), + 't7' => array(10, 11, 3, 1), + 't8' => array(1, 6, 0, 2), + 't9' => array(2, 3, 1, 2), + 't10' => array(4, 5, 1, 2), + ); + foreach ($fixtures as $key => $data) { + $t = new PublicTable10(); + $t->setTitle($key); + $t->setLeftValue($data[0]); + $t->setRightValue($data[1]); + $t->setLevel($data[2]); + $t->setScopeValue($data[3]); + $t->save(); + $ret []= $t; + } + + return $ret; + } + + protected function dumpTreeWithScope($scope) + { + $c = new Criteria(); + $c->add(Table10Peer::SCOPE_COL, $scope); + $c->addAscendingOrderBycolumn(Table10Peer::TITLE); + + return $this->dumpNodes(Table10Peer::doSelect($c)); + } } // we need this class to test protected methods class PublicTable9 extends Table9 { - public $hasParentNode = null; - public $parentNode = null; - public $hasPrevSibling = null; - public $prevSibling = null; - public $hasNextSibling = null; - public $nextSibling = null; + public $hasParentNode = null; + public $parentNode = null; + public $hasPrevSibling = null; + public $prevSibling = null; + public $hasNextSibling = null; + public $nextSibling = null; } class PublicTable10 extends Table10 { - public $hasParentNode = null; - public $parentNode = null; -} \ No newline at end of file + public $hasParentNode = null; + public $parentNode = null; +} diff --git a/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/BookstoreSortableTestBase.php b/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/BookstoreSortableTestBase.php index 2af39debe..e2f3113ed 100644 --- a/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/BookstoreSortableTestBase.php +++ b/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/BookstoreSortableTestBase.php @@ -8,97 +8,185 @@ * @license MIT License */ -require_once 'tools/helpers/bookstore/BookstoreTestBase.php'; +require_once dirname(__FILE__) . '/../BookstoreTestBase.php'; -class BookstoreSortableTestBase extends BookstoreTestBase +abstract class BookstoreSortableTestBase extends BookstoreTestBase { - protected function populateTable11() - { - Table11Peer::doDeleteAll(); - $t1 = new Table11(); - $t1->setRank(1); - $t1->setTitle('row1'); - $t1->save(); - $t2 = new Table11(); - $t2->setRank(4); - $t2->setTitle('row4'); - $t2->save(); - $t3 = new Table11(); - $t3->setRank(2); - $t3->setTitle('row2'); - $t3->save(); - $t4 = new Table11(); - $t4->setRank(3); - $t4->setTitle('row3'); - $t4->save(); - } - - protected function populateTable12() - { - /* List used for tests - scope=1 scope=2 - row1 row5 - row2 row6 - row3 - row4 - */ - Table12Peer::doDeleteAll(); - $t1 = new Table12(); - $t1->setRank(1); - $t1->setScopeValue(1); - $t1->setTitle('row1'); - $t1->save(); - $t2 = new Table12(); - $t2->setRank(4); - $t2->setScopeValue(1); - $t2->setTitle('row4'); - $t2->save(); - $t3 = new Table12(); - $t3->setRank(2); - $t3->setScopeValue(1); - $t3->setTitle('row2'); - $t3->save(); - $t4 = new Table12(); - $t4->setRank(1); - $t4->setScopeValue(2); - $t4->setTitle('row5'); - $t4->save(); - $t5 = new Table12(); - $t5->setRank(3); - $t5->setScopeValue(1); - $t5->setTitle('row3'); - $t5->save(); - $t6 = new Table12(); - $t6->setRank(2); - $t6->setScopeValue(2); - $t6->setTitle('row6'); - $t6->save(); - } - - protected function getFixturesArray() - { - $c = new Criteria(); - $c->addAscendingOrderByColumn(Table11Peer::RANK_COL); - $ts = Table11Peer::doSelect($c); - $ret = array(); - foreach ($ts as $t) { - $ret[$t->getRank()] = $t->getTitle(); - } - return $ret; - } - - protected function getFixturesArrayWithScope($scope = null) - { - $c = new Criteria(); - if ($scope !== null) { - $c->add(Table12Peer::SCOPE_COL, $scope); - } - $c->addAscendingOrderByColumn(Table12Peer::RANK_COL); - $ts = Table12Peer::doSelect($c); - $ret = array(); - foreach ($ts as $t) { - $ret[$t->getRank()] = $t->getTitle(); - } - return $ret; - } -} \ No newline at end of file + protected function populateTable11() + { + Table11Peer::doDeleteAll(); + $t1 = new Table11(); + $t1->setRank(1); + $t1->setTitle('row1'); + $t1->save(); + $t2 = new Table11(); + $t2->setRank(4); + $t2->setTitle('row4'); + $t2->save(); + $t3 = new Table11(); + $t3->setRank(2); + $t3->setTitle('row2'); + $t3->save(); + $t4 = new Table11(); + $t4->setRank(3); + $t4->setTitle('row3'); + $t4->save(); + } + + protected function populateTable12() + { + /* List used for tests + scope=1 scope=2 scope=null + row1 row5 row7 + row2 row6 row8 + row3 row9 + row4 row10 + */ + Table12Peer::doDeleteAll(); + $t1 = new Table12(); + $t1->setRank(1); + $t1->setScopeValue(1); + $t1->setTitle('row1'); + $t1->save(); + $t2 = new Table12(); + $t2->setRank(4); + $t2->setScopeValue(1); + $t2->setTitle('row4'); + $t2->save(); + $t3 = new Table12(); + $t3->setRank(2); + $t3->setScopeValue(1); + $t3->setTitle('row2'); + $t3->save(); + $t4 = new Table12(); + $t4->setRank(1); + $t4->setScopeValue(2); + $t4->setTitle('row5'); + $t4->save(); + $t5 = new Table12(); + $t5->setRank(3); + $t5->setScopeValue(1); + $t5->setTitle('row3'); + $t5->save(); + $t6 = new Table12(); + $t6->setRank(2); + $t6->setScopeValue(2); + $t6->setTitle('row6'); + $t6->save(); + $t7 = new Table12(); + $t7->setRank(1); + $t7->setTitle('row7'); + $t7->save(); + $t8 = new Table12(); + $t8->setRank(2); + $t8->setTitle('row8'); + $t8->save(); + $t9 = new Table12(); + $t9->setRank(3); + $t9->setTitle('row9'); + $t9->save(); + $t10 = new Table12(); + $t10->setRank(4); + $t10->setTitle('row10'); + $t10->save(); + } + + protected function populateFkScopeTable() + { + /* List used for tests + scope=1 scope=2 scope=null + row1 row4 row7 + row2 row5 row8 + row3 row6 row9 + */ + $this->populateTable11(); + + $s1 = Table11Peer::retrieveByRank(1)->getId(); + $s2 = Table11Peer::retrieveByRank(2)->getId(); + + FkScopeTablePeer::doDeleteAll(); + $t1 = new FkScopeTable(); + $t1->setRank(1); + $t1->setScopeValue($s1); + $t1->setTitle('row1'); + $t1->save(); + $t2 = new FkScopeTable(); + $t2->setRank(2); + $t2->setScopeValue($s1); + $t2->setTitle('row2'); + $t2->save(); + $t3 = new FkScopeTable(); + $t3->setRank(3); + $t3->setScopeValue($s1); + $t3->setTitle('row3'); + $t3->save(); + $t4 = new FkScopeTable(); + $t4->setRank(1); + $t4->setScopeValue($s2); + $t4->setTitle('row4'); + $t4->save(); + $t5 = new FkScopeTable(); + $t5->setRank(2); + $t5->setScopeValue($s2); + $t5->setTitle('row5'); + $t5->save(); + $t6 = new FkScopeTable(); + $t6->setRank(3); + $t6->setScopeValue($s2); + $t6->setTitle('row6'); + $t6->save(); + $t7 = new FkScopeTable(); + $t7->setRank(1); + $t7->setTitle('row7'); + $t7->save(); + $t8 = new FkScopeTable(); + $t8->setRank(2); + $t8->setTitle('row8'); + $t8->save(); + $t9 = new FkScopeTable(); + $t9->setRank(3); + $t9->setTitle('row9'); + $t9->save(); + } + + protected function getFixturesArray() + { + $c = new Criteria(); + $c->addAscendingOrderByColumn(Table11Peer::RANK_COL); + $ts = Table11Peer::doSelect($c); + $ret = array(); + foreach ($ts as $t) { + $ret[$t->getRank()] = $t->getTitle(); + } + + return $ret; + } + + protected function getFixturesArrayWithScope($scope = null) + { + $c = new Criteria(); + Table12Peer::sortableApplyScopeCriteria($c, $scope); + $c->addAscendingOrderByColumn(Table12Peer::RANK_COL); + $ts = Table12Peer::doSelect($c); + $ret = array(); + foreach ($ts as $t) { + $ret[$t->getRank()] = $t->getTitle(); + } + + return $ret; + } + + protected function getFixturesArrayWithFkScope($scope = null) + { + $c = new Criteria(); + FkScopeTablePeer::sortableApplyScopeCriteria($c, $scope); + $c->addAscendingOrderByColumn(FkScopeTablePeer::RANK_COL); + $ts = FkScopeTablePeer::doSelect($c); + $ret = array(); + foreach ($ts as $t) { + $ret[$t->getRank()] = $t->getTitle(); + } + + return $ret; + } +} diff --git a/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/DonothingBehavior.php b/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/DonothingBehavior.php index 2b6f2fb97..c2a03e747 100644 --- a/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/DonothingBehavior.php +++ b/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/DonothingBehavior.php @@ -6,8 +6,8 @@ * file that was distributed with this source code. * * @license MIT License - */ + */ class DonothingBehavior extends Behavior { -} \ No newline at end of file +} diff --git a/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/TestAuthor.php b/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/TestAuthor.php index cdb902be0..065013e1d 100644 --- a/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/TestAuthor.php +++ b/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/TestAuthor.php @@ -6,78 +6,91 @@ * file that was distributed with this source code. * * @license MIT License - */ + */ -class TestAuthor extends Author { - public function preInsert(PropelPDO $con = null) - { - parent::preInsert($con); - $this->setFirstName('PreInsertedFirstname'); - return true; - } +class TestAuthor extends Author +{ + public function preInsert(PropelPDO $con = null) + { + parent::preInsert($con); + $this->setFirstName('PreInsertedFirstname'); - public function postInsert(PropelPDO $con = null) - { - parent::postInsert($con); - $this->setLastName('PostInsertedLastName'); - } + return true; + } - public function preUpdate(PropelPDO $con = null) - { - parent::preUpdate($con); - $this->setFirstName('PreUpdatedFirstname'); - return true; - } + public function postInsert(PropelPDO $con = null) + { + parent::postInsert($con); + $this->setLastName('PostInsertedLastName'); + } - public function postUpdate(PropelPDO $con = null) - { - parent::postUpdate($con); - $this->setLastName('PostUpdatedLastName'); - } + public function preUpdate(PropelPDO $con = null) + { + parent::preUpdate($con); + $this->setFirstName('PreUpdatedFirstname'); - public function preSave(PropelPDO $con = null) - { - parent::preSave($con); - $this->setEmail("pre@save.com"); - return true; - } + return true; + } - public function postSave(PropelPDO $con = null) - { - parent::postSave($con); - $this->setAge(115); - } + public function postUpdate(PropelPDO $con = null) + { + parent::postUpdate($con); + $this->setLastName('PostUpdatedLastName'); + } - public function preDelete(PropelPDO $con = null) - { - parent::preDelete($con); - $this->setFirstName("Pre-Deleted"); - return true; - } + public function preSave(PropelPDO $con = null) + { + parent::preSave($con); + $this->setEmail("pre@save.com"); - public function postDelete(PropelPDO $con = null) - { - parent::postDelete($con); - $this->setLastName("Post-Deleted"); - } + return true; + } + + public function postSave(PropelPDO $con = null) + { + parent::postSave($con); + $this->setAge(115); + } + + public function preDelete(PropelPDO $con = null) + { + parent::preDelete($con); + $this->setFirstName("Pre-Deleted"); + + return true; + } + + public function postDelete(PropelPDO $con = null) + { + parent::postDelete($con); + $this->setLastName("Post-Deleted"); + } + + public function postHydrate($row, $startcol = 0, $rehydrate = false) + { + parent::postHydrate($row, $startcol, $rehydrate); + $this->setLastName("Post-Hydrated"); + } } class TestAuthorDeleteFalse extends TestAuthor { - public function preDelete(PropelPDO $con = null) - { - parent::preDelete($con); - $this->setFirstName("Pre-Deleted"); - return false; - } + public function preDelete(PropelPDO $con = null) + { + parent::preDelete($con); + $this->setFirstName("Pre-Deleted"); + + return false; + } } class TestAuthorSaveFalse extends TestAuthor { - public function preSave(PropelPDO $con = null) - { - parent::preSave($con); - $this->setEmail("pre@save.com"); - return false; - } - -} \ No newline at end of file + public function preSave(PropelPDO $con = null) + { + parent::preSave($con); + $this->setEmail("pre@save.com"); + + return false; + } + +} diff --git a/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/Testallhooksbehavior.php b/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/Testallhooksbehavior.php index 4a44c2323..7224eecb2 100644 --- a/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/Testallhooksbehavior.php +++ b/airtime_mvc/library/propel/test/tools/helpers/bookstore/behavior/Testallhooksbehavior.php @@ -11,40 +11,40 @@ class TestAllHooksBehavior extends Behavior { protected $tableModifier, $objectBuilderModifier, $peerBuilderModifier, $queryBuilderModifier; - + public function getTableModifier() { - if (is_null($this->tableModifier)) - { + if (is_null($this->tableModifier)) { $this->tableModifier = new TestAllHooksTableModifier($this); } + return $this->tableModifier; } - + public function getObjectBuilderModifier() { - if (is_null($this->objectBuilderModifier)) - { + if (is_null($this->objectBuilderModifier)) { $this->objectBuilderModifier = new TestAllHooksObjectBuilderModifier($this); } + return $this->objectBuilderModifier; } - + public function getPeerBuilderModifier() { - if (is_null($this->peerBuilderModifier)) - { + if (is_null($this->peerBuilderModifier)) { $this->peerBuilderModifier = new TestAllHooksPeerBuilderModifier($this); } + return $this->peerBuilderModifier; } public function getQueryBuilderModifier() { - if (is_null($this->queryBuilderModifier)) - { + if (is_null($this->queryBuilderModifier)) { $this->queryBuilderModifier = new TestAllHooksQueryBuilderModifier($this); } + return $this->queryBuilderModifier; } } @@ -52,13 +52,13 @@ class TestAllHooksBehavior extends Behavior class TestAllHooksTableModifier { protected $behavior, $table; - + public function __construct($behavior) { $this->behavior = $behavior; $this->table = $behavior->getTable(); } - + public function modifyTable() { $this->table->addColumn(array( @@ -69,17 +69,17 @@ class TestAllHooksTableModifier } class TestAllHooksObjectBuilderModifier -{ +{ public function objectAttributes($builder) { return 'public $customAttribute = 1;'; } - + public function preSave($builder) { return '$this->preSave = 1;$this->preSaveIsAfterSave = isset($affectedRows);$this->preSaveBuilder="' . get_class($builder) . '";'; } - + public function postSave($builder) { return '$this->postSave = 1;$this->postSaveIsAfterSave = isset($affectedRows);$this->postSaveBuilder="' . get_class($builder) . '";'; @@ -89,42 +89,47 @@ class TestAllHooksObjectBuilderModifier { return '$this->preInsert = 1;$this->preInsertIsAfterSave = isset($affectedRows);$this->preInsertBuilder="' . get_class($builder) . '";'; } - + public function postInsert($builder) { return '$this->postInsert = 1;$this->postInsertIsAfterSave = isset($affectedRows);$this->postInsertBuilder="' . get_class($builder) . '";'; } - + public function preUpdate($builder) { return '$this->preUpdate = 1;$this->preUpdateIsAfterSave = isset($affectedRows);$this->preUpdateBuilder="' . get_class($builder) . '";'; } - + public function postUpdate($builder) { return '$this->postUpdate = 1;$this->postUpdateIsAfterSave = isset($affectedRows);$this->postUpdateBuilder="' . get_class($builder) . '";'; } - + public function preDelete($builder) { return '$this->preDelete = 1;$this->preDeleteIsBeforeDelete = isset(Table3Peer::$instances[$this->id]);$this->preDeleteBuilder="' . get_class($builder) . '";'; } - + public function postDelete($builder) { return '$this->postDelete = 1;$this->postDeleteIsBeforeDelete = isset(Table3Peer::$instances[$this->id]);$this->postDeleteBuilder="' . get_class($builder) . '";'; } - + + public function postHydrate($builder) + { + return '$this->postHydrate = 1;$this->postHydrateIsAfterHydrate = isset($this->id);$this->postHydrateBuilder="' . get_class($builder) . '";'; + } + public function objectMethods($builder) { return 'public function hello() { return "' . get_class($builder) .'"; }'; } - + public function objectCall($builder) { - return 'if ($name == "foo") return "bar";'; + return 'if ($name == "foo") return "bar";'; } - + public function objectFilter(&$string, $builder) { $string .= 'class testObjectFilter { const FOO = "' . get_class($builder) . '"; }'; @@ -132,17 +137,17 @@ class TestAllHooksObjectBuilderModifier } class TestAllHooksPeerBuilderModifier -{ +{ public function staticAttributes($builder) { return 'public static $customStaticAttribute = 1;public static $staticAttributeBuilder = "' . get_class($builder) . '";'; } - + public function staticMethods($builder) { return 'public static function hello() { return "' . get_class($builder) . '"; }'; } - + public function preSelect($builder) { return '$con->preSelect = "' . get_class($builder) . '";'; @@ -156,28 +161,28 @@ class TestAllHooksPeerBuilderModifier class TestAllHooksQueryBuilderModifier { - public function preSelectQuery($builder) - { - return '// foo'; - } + public function preSelectQuery($builder) + { + return '// foo'; + } - public function preDeleteQuery($builder) - { - return '// foo'; - } + public function preDeleteQuery($builder) + { + return '// foo'; + } - public function postDeleteQuery($builder) - { - return '// foo'; - } + public function postDeleteQuery($builder) + { + return '// foo'; + } - public function preUpdateQuery($builder) - { - return '// foo'; - } + public function preUpdateQuery($builder) + { + return '// foo'; + } - public function postUpdateQuery($builder) - { - return '// foo'; - } -} \ No newline at end of file + public function postUpdateQuery($builder) + { + return '// foo'; + } +} diff --git a/airtime_mvc/library/propel/test/tools/helpers/bookstore/validator/ISBNValidator.php b/airtime_mvc/library/propel/test/tools/helpers/bookstore/validator/ISBNValidator.php index 690c81a40..c92413ca6 100644 --- a/airtime_mvc/library/propel/test/tools/helpers/bookstore/validator/ISBNValidator.php +++ b/airtime_mvc/library/propel/test/tools/helpers/bookstore/validator/ISBNValidator.php @@ -12,18 +12,18 @@ * A custom validator for ISBN. * * @author Hans Lellelid - * @version $Revision: 1612 $ + * @version $Revision$ * @package propel.validator */ class ISBNValidator implements BasicValidator { - const NOT_ISBN_REGEXP = '/[^0-9A-Z]/'; + const NOT_ISBN_REGEXP = '/[^0-9A-Z]/'; - /** - * Whether the passed string matches regular expression. - */ - public function isValid (ValidatorMap $map, $str) - { - return !(preg_match(self::NOT_ISBN_REGEXP, $str)); - } + /** + * Whether the passed string matches regular expression. + */ + public function isValid(ValidatorMap $map, $str) + { + return !(preg_match(self::NOT_ISBN_REGEXP, $str)); + } } diff --git a/airtime_mvc/library/propel/test/tools/helpers/cms/CmsDataPopulator.php b/airtime_mvc/library/propel/test/tools/helpers/cms/CmsDataPopulator.php index 2a05f3ff3..6e62404f1 100644 --- a/airtime_mvc/library/propel/test/tools/helpers/cms/CmsDataPopulator.php +++ b/airtime_mvc/library/propel/test/tools/helpers/cms/CmsDataPopulator.php @@ -13,131 +13,129 @@ * * @author Hans Lellelid */ -class CmsDataPopulator { +class CmsDataPopulator +{ + public static function populate($con = null) + { + if ($con === null) { + $con = Propel::getConnection(PagePeer::DATABASE_NAME); + } + $con->beginTransaction(); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 1,194,'home')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 2,5,'school')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 6,43,'education')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 44,45,'simulator')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 46,47,'ac')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 3,4,'history')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 7,14,'master-mariner')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 8,9,'education')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 48,85,'courses')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 98,101,'contact')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 10,11,'entrance')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 104,191,'intra')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 102,103,'services')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 12,13,'competency')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 15,22,'watchkeeping-officer')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 16,17,'education')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 18,19,'entrance')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 20,21,'competency')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 31,38,'watchkeeping-engineer')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 32,33,'education')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 34,35,'entrance')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 36,37,'competency')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 39,40,'practice')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 86,97,'news')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 95,96,'2007-02')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 99,100,'personnel')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 87,88,'2007-06')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 49,50,'nautical')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 51,52,'radiotechnical')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 53,54,'resourcemgmt')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 57,58,'safety')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 59,60,'firstaid')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 61,62,'sar')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 67,84,'upcoming')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 65,66,'languages')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 55,56,'cargomgmt')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 119,120,'timetable')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 63,64,'boaters')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 105,118,'bulletinboard')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 106,107,'sdf')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 41,42,'fristaende')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 23,30,'ingenj')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 24,25,'utbildn')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 26,27,'ansokn')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 93,94,'utexaminerade')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 89,92,'Massan')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 192,193,'lankar')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 68,69,'FRB')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 70,71,'pelastautumis')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 72,73,'CCM')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 74,75,'sjukvard')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 121,188,'Veckoscheman')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 134,135,'VS3VSVsjukv')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 122,123,'sjoarb')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 130,131,'fysik1')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 140,141,'kemi')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 76,77,'inr')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 78,79,'forare')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 144,145,'AlexandraYH2')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 132,133,'AlexandraVS2')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 80,81,'Maskin')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 126,127,'forstahjalp')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 136,137,'Juridik')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 142,143,'mate')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 82,83,'basic')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 124,125,'mask')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 108,109,'magnus')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 138,139,'sjosakerhet')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 28,29,'pate')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 148,149,'eng')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 146,147,'forstahjalpYH1')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 110,111,'kortoverlevnadskurs')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 158,159,'kortoverlevnadskurs')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 128,129,'metall')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 152,153,'fysik')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 156,157,'fardplan')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 154,155,'astro')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 90,91,'utstallare')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 150,151,'eng')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 160,161,'ent')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 162,163,'juridik')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 168,169,'svenska')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 164,165,'matemat')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 166,167,'operativa')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 170,171,'plan')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 172,173,'src')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 112,113,'sjukv')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 174,175,'matemati')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 176,177,'fysiikka')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 114,115,'hantv')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 116,117,'CCM')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 178,179,'haveri')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 180,181,'FRB')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 182,183,'kemia')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 184,185,'vaktrutiner')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 189,190,'laroplan')"); + $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 186,187,'SSOkurs')"); - public static function populate($con = null) - { - if($con === null) - { - $con = Propel::getConnection(PagePeer::DATABASE_NAME); - } - $con->beginTransaction(); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 1,194,'home')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 2,5,'school')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 6,43,'education')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 44,45,'simulator')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 46,47,'ac')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 3,4,'history')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 7,14,'master-mariner')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 8,9,'education')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 48,85,'courses')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 98,101,'contact')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 10,11,'entrance')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 104,191,'intra')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 102,103,'services')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 12,13,'competency')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 15,22,'watchkeeping-officer')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 16,17,'education')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 18,19,'entrance')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 20,21,'competency')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 31,38,'watchkeeping-engineer')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 32,33,'education')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 34,35,'entrance')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 36,37,'competency')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 39,40,'practice')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 86,97,'news')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 95,96,'2007-02')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 99,100,'personnel')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 87,88,'2007-06')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 49,50,'nautical')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 51,52,'radiotechnical')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 53,54,'resourcemgmt')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 57,58,'safety')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 59,60,'firstaid')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 61,62,'sar')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 67,84,'upcoming')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 65,66,'languages')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 55,56,'cargomgmt')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 119,120,'timetable')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 63,64,'boaters')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 105,118,'bulletinboard')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 106,107,'sdf')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 41,42,'fristaende')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 23,30,'ingenj')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 24,25,'utbildn')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 26,27,'ansokn')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 93,94,'utexaminerade')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 89,92,'Massan')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 192,193,'lankar')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 68,69,'FRB')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 70,71,'pelastautumis')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 72,73,'CCM')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 74,75,'sjukvard')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 121,188,'Veckoscheman')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 134,135,'VS3VSVsjukv')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 122,123,'sjoarb')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 130,131,'fysik1')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 140,141,'kemi')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 76,77,'inr')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 78,79,'forare')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 144,145,'AlexandraYH2')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 132,133,'AlexandraVS2')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 80,81,'Maskin')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 126,127,'forstahjalp')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 136,137,'Juridik')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 142,143,'mate')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 82,83,'basic')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 124,125,'mask')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 108,109,'magnus')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 138,139,'sjosakerhet')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 28,29,'pate')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 148,149,'eng')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 146,147,'forstahjalpYH1')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 110,111,'kortoverlevnadskurs')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 158,159,'kortoverlevnadskurs')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 128,129,'metall')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 152,153,'fysik')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 156,157,'fardplan')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 154,155,'astro')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 90,91,'utstallare')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 150,151,'eng')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 160,161,'ent')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 162,163,'juridik')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 168,169,'svenska')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 164,165,'matemat')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 166,167,'operativa')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 170,171,'plan')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 172,173,'src')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 112,113,'sjukv')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 174,175,'matemati')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 176,177,'fysiikka')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 114,115,'hantv')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 116,117,'CCM')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 178,179,'haveri')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 180,181,'FRB')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 182,183,'kemia')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 184,185,'vaktrutiner')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 189,190,'laroplan')"); - $con->exec("INSERT INTO Page (ScopeId, LeftChild, RightChild, Title) VALUES (1, 186,187,'SSOkurs')"); + $con->exec("INSERT INTO Category (LeftChild, RightChild, Title) VALUES (1, 8, 'Cat_1')"); + $con->exec("INSERT INTO Category (LeftChild, RightChild, Title) VALUES (2, 7, 'Cat_1_1')"); + $con->exec("INSERT INTO Category (LeftChild, RightChild, Title) VALUES (3, 6, 'Cat_1_1_1')"); + $con->exec("INSERT INTO Category (LeftChild, RightChild, Title) VALUES (4, 5, 'Cat_1_1_1_1')"); - $con->exec("INSERT INTO Category (LeftChild, RightChild, Title) VALUES (1, 8, 'Cat_1')"); - $con->exec("INSERT INTO Category (LeftChild, RightChild, Title) VALUES (2, 7, 'Cat_1_1')"); - $con->exec("INSERT INTO Category (LeftChild, RightChild, Title) VALUES (3, 6, 'Cat_1_1_1')"); - $con->exec("INSERT INTO Category (LeftChild, RightChild, Title) VALUES (4, 5, 'Cat_1_1_1_1')"); - - $con->commit(); - } + $con->commit(); + } - public static function depopulate($con = null) - { - if($con === null) - { - $con = Propel::getConnection(PagePeer::DATABASE_NAME); - } - $con->beginTransaction(); - $con->exec("DELETE FROM Page"); - $con->exec("DELETE FROM Category"); - - $con->commit(); - } + public static function depopulate($con = null) + { + if ($con === null) { + $con = Propel::getConnection(PagePeer::DATABASE_NAME); + } + $con->beginTransaction(); + $con->exec("DELETE FROM Page"); + $con->exec("DELETE FROM Category"); + + $con->commit(); + } } diff --git a/airtime_mvc/library/propel/test/tools/helpers/cms/CmsTestBase.php b/airtime_mvc/library/propel/test/tools/helpers/cms/CmsTestBase.php index 0d9c73791..979f55a43 100644 --- a/airtime_mvc/library/propel/test/tools/helpers/cms/CmsTestBase.php +++ b/airtime_mvc/library/propel/test/tools/helpers/cms/CmsTestBase.php @@ -8,38 +8,38 @@ * @license MIT License */ -require_once 'PHPUnit/Framework/TestCase.php'; -set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes"); -Propel::init('fixtures/bookstore/build/conf/bookstore-conf.php'); -include_once 'tools/helpers/cms/CmsDataPopulator.php'; +require_once dirname(__FILE__) . '/../../../../runtime/lib/Propel.php'; +set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../../fixtures/bookstore/build/classes')); +Propel::init(dirname(__FILE__) . '/../../../fixtures/bookstore/build/conf/bookstore-conf.php'); +include_once dirname(__FILE__) . '/CmsDataPopulator.php'; /** * Base class contains some methods shared by subclass test cases. */ abstract class CmsTestBase extends PHPUnit_Framework_TestCase { - protected $con; - - /** - * This is run before each unit test; it populates the database. - */ - protected function setUp() - { - parent::setUp(); - $this->con = Propel::getConnection(PagePeer::DATABASE_NAME); - $this->con->beginTransaction(); - CmsDataPopulator::depopulate($this->con); - CmsDataPopulator::populate($this->con); - } + protected $con; - /** - * This is run after each unit test. It empties the database. - */ - protected function tearDown() - { - CmsDataPopulator::depopulate($this->con); - $this->con->commit(); - parent::tearDown(); - } + /** + * This is run before each unit test; it populates the database. + */ + protected function setUp() + { + parent::setUp(); + $this->con = Propel::getConnection(PagePeer::DATABASE_NAME); + $this->con->beginTransaction(); + CmsDataPopulator::depopulate($this->con); + CmsDataPopulator::populate($this->con); + } + + /** + * This is run after each unit test. It empties the database. + */ + protected function tearDown() + { + CmsDataPopulator::depopulate($this->con); + $this->con->commit(); + parent::tearDown(); + } } diff --git a/airtime_mvc/library/propel/test/tools/helpers/namespaces/NamespacesTestBase.php b/airtime_mvc/library/propel/test/tools/helpers/namespaces/NamespacesTestBase.php new file mode 100644 index 000000000..5a8433925 --- /dev/null +++ b/airtime_mvc/library/propel/test/tools/helpers/namespaces/NamespacesTestBase.php @@ -0,0 +1,34 @@ +markTestSkipped('You must build the namespaced project fot this tests to run'); + } + Propel::init(dirname(__FILE__) . '/../../../fixtures/namespaced/build/conf/bookstore_namespaced-conf.php'); + } + + protected function tearDown() + { + parent::tearDown(); + Propel::init(dirname(__FILE__) . '/../../../fixtures/bookstore/build/conf/bookstore-conf.php'); + } +} diff --git a/airtime_mvc/library/propel/test/tools/helpers/schemas/SchemasTestBase.php b/airtime_mvc/library/propel/test/tools/helpers/schemas/SchemasTestBase.php new file mode 100644 index 000000000..f3cdd5d7b --- /dev/null +++ b/airtime_mvc/library/propel/test/tools/helpers/schemas/SchemasTestBase.php @@ -0,0 +1,34 @@ +markTestSkipped('You must build the schemas project fot this tests to run'); + } + Propel::init(dirname(__FILE__) . '/../../../fixtures/schemas/build/conf/bookstore-conf.php'); + } + + protected function tearDown() + { + parent::tearDown(); + Propel::init(dirname(__FILE__) . '/../../../fixtures/bookstore/build/conf/bookstore-conf.php'); + } +} diff --git a/airtime_mvc/library/propel/test/tools/phing/DefineTask.php b/airtime_mvc/library/propel/test/tools/phing/DefineTask.php index ef6f208be..648254308 100644 --- a/airtime_mvc/library/propel/test/tools/phing/DefineTask.php +++ b/airtime_mvc/library/propel/test/tools/phing/DefineTask.php @@ -15,44 +15,47 @@ require_once 'phing/Task.php'; * * This is handy if you want to initialize a constant to a value that is available only as build properties. */ -class DefineTask extends Task { +class DefineTask extends Task +{ + /** + * @var string + */ + private $name; - /** - * @var string - */ - private $name; + /** + * @var string + */ + private $value; - /** - * @var string - */ - private $value; + /** + * Sets the name for the constant. + * @param string $v + */ + public function setName($v) + { + $this->name = $v; + } - /** - * Sets the name for the constant. - * @param string $v - */ - public function setName($v) { - $this->name = $v; - } + /** + * Sets the value for the constant. + * @param string $v + */ + public function setValue($v) + { + $this->value = $v; + } - /** - * Sets the value for the constant. - * @param string $v - */ - public function setValue($v) { - $this->value = $v; - } - - public function main() { - if (!isset($this->name) || !isset($this->value)) { - throw new BuildException("Both name and value params are required.", $this->getLocation()); - } - $const = strtoupper($this->name); - if (defined($const)) { - $this->log("The constant $const has already been defined!", Project::MSG_ERR); - } else { - define($const, $this->value); - $this->log("Defined $const with value " . var_export($this->value, true), Project::MSG_INFO); - } - } + public function main() + { + if (!isset($this->name) || !isset($this->value)) { + throw new BuildException("Both name and value params are required.", $this->getLocation()); + } + $const = strtoupper($this->name); + if (defined($const)) { + $this->log("The constant $const has already been defined!", Project::MSG_ERR); + } else { + define($const, $this->value); + $this->log("Defined $const with value " . var_export($this->value, true), Project::MSG_INFO); + } + } } diff --git a/airtime_mvc/library/propel/test/tree-test.php b/airtime_mvc/library/propel/test/tree-test.php deleted file mode 100644 index c807f32e9..000000000 --- a/airtime_mvc/library/propel/test/tree-test.php +++ /dev/null @@ -1,426 +0,0 @@ -"; - -error_reporting(E_ALL); - -$conf_path = realpath(dirname(__FILE__) . '/fixtures/treetest/build/conf/treetest-conf.php'); -if (!file_exists($conf_path)) { - echo "Make sure that you specify properties in conf/treetest.properties and " - ."build propel before running this script."; - exit; -} - -// Add PHP_CLASSPATH, if set -if (getenv("PHP_CLASSPATH")) { - set_include_path(getenv("PHP_CLASSPATH") . PATH_SEPARATOR . get_include_path()); -} - - // Add build/classes/ and classes/ to path -set_include_path( - realpath(dirname(__FILE__) . '/fixtures/treetest/build/classes') . PATH_SEPARATOR . - dirname(__FILE__) . '/../runtime/classes' . PATH_SEPARATOR . - get_include_path() -); - - -// Require classes. -require_once 'propel/Propel.php'; -require_once 'treetest/TestNodePeer.php'; - -function dumpTree($node, $querydb = false, $con = null) -{ - $opts = array('querydb' => $querydb, - 'con' => $con); - - $node->setIteratorOptions('pre', $opts); - - $indent = 0; - $lastLevel = $node->getNodeLevel(); - - foreach ($node as $n) - { - $nodeLevel = $n->getNodeLevel(); - $indent += $nodeLevel - $lastLevel; - echo str_repeat(' ', $indent); - echo $n->getNodePath() . " -> " . $n->getLabel(); - echo "\n"; - $lastLevel = $nodeLevel; - } -} - -try { - // Initialize Propel - Propel::init($conf_path); -} catch (Exception $e) { - die("Error initializing propel: ". $e->__toString()); -} - -try { - - $nodeKeySep = TestNodePeer::NPATH_SEP; - - echo "\nCreating initial tree:\n"; - echo "-------------------------------------\n"; - - $a = new Test(); - $a->setLabel("a"); - $a = TestNodePeer::createNewRootNode($a); - echo "Created 'a' as new root\n"; - - $b = new TestNode(); - $b->setLabel('b'); - $a->addChildNode($b); - echo "Added 'b' as first child of 'a'\n"; - - $c = new TestNode(); - $c->setLabel('c'); - $a->addChildNode($c); - echo "Added 'c' as second child of 'a'\n"; - - $f = new TestNode(); - $f->setLabel('f'); - $b->addChildNode($f); - echo "Added 'f' as first child of 'b'\n"; - - $d = new TestNode(); - $d->setLabel('d'); - $b->addChildNode($d, $f); - echo "Added 'd' as first child of 'b' before 'f' (insert before first child test - f is now second child)\n"; - - $e = new TestNode(); - $e->setLabel('e'); - $b->addChildNode($e, $f); - echo "Added 'e' as second child of 'b' before 'f' (insert before last child test - f is now third child)\n"; - - $g = new TestNode(); - $g->setLabel('g'); - $c->addChildNode($g); - echo "Added 'g' as first child of 'c'\n"; - - $h = new TestNode(); - $h->setLabel('h'); - $c->addChildNode($h); - echo "Added 'h' as second child of 'c'\n"; - - $i = new TestNode(); - $i->setLabel('i'); - $d->addChildNode($i); - echo "Added 'i' as first child of 'd'\n"; - - $j = new TestNode(); - $j->setLabel('j'); - $f->addChildNode($j); - echo "Added 'j' as first child of 'f'\n"; - - $k = new TestNode(); - $k->setLabel('k'); - $j->addChildNode($k); - echo "Added 'k' as first child of 'j'\n"; - - $l = new TestNode(); - $l->setLabel('l'); - $j->addChildNode($l); - echo "Added 'l' as second child of 'j'\n"; - - dumpTree($a); - - - echo "\n\nDeleting 'd' node sub-tree:\n"; - echo "-------------------------------------\n"; - - $d->delete(); - - dumpTree($a); - - - echo "\n\nMove node tests:\n"; - echo "-------------------------------------\n"; - - echo "Move 'j' sub-tree to 'b' before 'e' (move tree/insert before first child test):\n"; - $b->addChildNode($j, $e); - dumpTree($a); - - echo "\nMove 'j' sub-tree to 'c' (move tree after last child test):\n"; - $c->addChildNode($j); - dumpTree($a); - - echo "\nMove 'j' sub-tree to 'g' (move tree to first child test):\n"; - $g->addChildNode($j); - dumpTree($a); - - - echo "\n\nCreating new (in-memory) sub-tree:\n"; - echo "-------------------------------------\n"; - - $m = new TestNode(); - $m->setLabel('m'); - echo "Created 'm' as root of new sub-tree\n"; - - $n = new TestNode(); - $n->setLabel('n'); - $m->addChildNode($n); - echo "Added 'n' as first child of 'm'\n"; - - $o = new TestNode(); - $o->setLabel('o'); - $m->addChildNode($o); - echo "Added 'o' as second child of 'm'\n"; - - $r = new TestNode(); - $r->setLabel('r'); - $n->addChildNode($r); - echo "Added 'r' as first child of 'n'\n"; - - $p = new TestNode(); - $p->setLabel('p'); - $n->addChildNode($p, $r); - echo "Added 'p' as first child of 'n' before 'r' (insert before first child test - r is now second child)\n"; - - $q = new TestNode(); - $q->setLabel('q'); - $n->addChildNode($q, $r); - echo "Added 'q' as second child of 'n' before 'r' (insert before last child test - r is now third child)\n"; - - $s = new TestNode(); - $s->setLabel('s'); - $o->addChildNode($s); - echo "Added 's' as first child of 'o'\n"; - - $t = new TestNode(); - $t->setLabel('t'); - $o->addChildNode($t); - echo "Added 't' as second child of 'o'\n"; - - $u = new TestNode(); - $u->setLabel('u'); - $p->addChildNode($u); - echo "Added 'u' as first child of 'p'\n"; - - $v = new TestNode(); - $v->setLabel('v'); - $r->addChildNode($v); - echo "Added 'v' as first child of 'r'\n"; - - $w = new TestNode(); - $w->setLabel('w'); - $v->addChildNode($w); - echo "Added 'w' as first child of 'v'\n"; - - $x = new TestNode(); - $x->setLabel('x'); - $v->addChildNode($x); - echo "Added 'x' as second child of 'v'\n"; - - dumpTree($m); - - - echo "\n\nDeleting in-memory 'p' node sub-tree:\n"; - echo "-------------------------------------\n"; - - $p->delete(); - - dumpTree($m); - - - echo "\n\nMove in-memory node tests:\n"; - echo "-------------------------------------\n"; - - echo "Move 'v' sub-tree to 'n' before 'q' (move tree/insert before first child test):\n"; - $n->addChildNode($v, $q); - dumpTree($m); - - echo "\nMove 'v' sub-tree to 'o' (move tree after last child test):\n"; - $o->addChildNode($v); - dumpTree($m); - - echo "\nMove 'v' sub-tree to 's' (move tree to first child test):\n"; - $s->addChildNode($v); - dumpTree($m); - - - echo "\n\nAdd in-memory 'm' sub-tree to 'a':\n"; - echo "-------------------------------------\n"; - - $a->addChildNode($m); - - dumpTree($a); - - - echo "\n\nInsert new root node 'z' and retrieve descendants on demand (via querydb param in iterator):\n"; - echo "-------------------------------------\n"; - $z = new Test(); - $z->setLabel("z"); - $z = TestNodePeer::insertNewRootNode($z); - - dumpTree($z, true); - -} catch (Exception $e) { - die("Error creating initial tree: " . $e->__toString()); -} - -try { - - echo "\n\nTest retrieveRootNode() (without descendants)\n"; - echo "-------------------------------------\n"; - $root = TestNodePeer::retrieveRootNode(false); - dumpTree($root); - - - echo "\n\nTest retrieveRootNode() (with descendants)\n"; - echo "-------------------------------------\n"; - $root = TestNodePeer::retrieveRootNode(true); - dumpTree($root); - - $m_addr = array(1,1,3); - - echo "\n\nTest retrieveNodeByNP() for 'm' (without descendants)\n"; - echo "-------------------------------------\n"; - $node = TestNodePeer::retrieveNodeByNP(implode($nodeKeySep, $m_addr), false, false); - dumpTree($node); - - - echo "\n\nTest retrieveNodeByNP() for 'm' (with descendants)\n"; - echo "-------------------------------------\n"; - $node = TestNodePeer::retrieveNodeByNP(implode($nodeKeySep, $m_addr), false, true); - dumpTree($node); - - - echo "\n\nTest getAncestors() for 'x' in one query:\n"; - echo "-------------------------------------\n"; - - $criteria = new Criteria(); - $criteria->add(TestPeer::LABEL, 'x', Criteria::EQUAL); - - $nodes = TestNodePeer::retrieveNodes($criteria, true, false); - $ancestors = $nodes[0]->getAncestors(false); - - foreach ($ancestors as $ancestor) - echo $ancestor->getNodePath() . " -> " . $ancestor->getLabel() . "\n"; - - - echo "\n\nTest retrieveNodeByNP() for 'o' (with ancestors and descendants in one query):\n"; - echo "-------------------------------------\n"; - - $o_addr = array(1,1,3,2); - - $node = TestNodePeer::retrieveNodeByNP(implode($nodeKeySep, $o_addr), true, true); - - echo "ancestors:\n"; - foreach ($node->getAncestors(false) as $ancestor) - echo $ancestor->getNodePath() . " -> " . $ancestor->getLabel() . "\n"; - - echo "\ndescendants:\n"; - dumpTree($node); - - - echo "\n\nTest retrieveNodes() between 'b' and 'g' (without descendants)\n"; - echo "-------------------------------------\n"; - - $criteria = new Criteria(); - $criteria->add(TestPeer::LABEL, 'b', Criteria::GREATER_EQUAL); - $criteria->addAnd(TestPeer::LABEL, 'g', Criteria::LESS_EQUAL); - $criteria->addAscendingOrderByColumn(TestPeer::LABEL); - - $nodes = TestNodePeer::retrieveNodes($criteria, false, false); - - foreach ($nodes as $node) - echo $node->getNodePath() . " -> " . $node->getLabel() . "\n"; - - - echo "\n\nTest retrieveNodes() between 'b' and 'g' (with descendants)\n"; - echo "-------------------------------------\n"; - - $criteria = new Criteria(); - $criteria->add(TestPeer::LABEL, 'b', Criteria::GREATER_EQUAL); - $criteria->addAnd(TestPeer::LABEL, 'g', Criteria::LESS_EQUAL); - $criteria->addAscendingOrderByColumn(TestPeer::LABEL); - - $nodes = TestNodePeer::retrieveNodes($criteria, false, true); - - foreach ($nodes as $node) - { - dumpTree($node); - echo "\n"; - } - - -} catch (Exception $e) { - die("Error retrieving nodes: " . $e->__toString()); -} - -try { - - echo "\nCreating new tree:\n"; - echo "-------------------------------------\n"; - - $a = new Test(); - $a->setLabel("a"); - $a = TestNodePeer::createNewRootNode($a); - echo "Created 'a' as new root\n"; - - echo "\nAdding 10 child nodes:\n"; - echo "-------------------------------------\n"; - - $b = new TestNode(); - $b->setLabel('b'); - $a->addChildNode($b); - - $c = new TestNode(); - $c->setLabel('c'); - $a->addChildNode($c); - - $d = new TestNode(); - $d->setLabel('d'); - $a->addChildNode($d); - - $e = new TestNode(); - $e->setLabel('e'); - $a->addChildNode($e); - - $f = new TestNode(); - $f->setLabel('f'); - $a->addChildNode($f); - - $g = new TestNode(); - $g->setLabel('g'); - $a->addChildNode($g); - - $h = new TestNode(); - $h->setLabel('h'); - $a->addChildNode($h); - - $i = new TestNode(); - $i->setLabel('i'); - $a->addChildNode($i); - - $j = new TestNode(); - $j->setLabel('j'); - $a->addChildNode($j); - - $k = new TestNode(); - $k->setLabel('k'); - $a->addChildNode($k); - - echo "\ndescendants:\n"; - dumpTree($a); - - echo "\nRetrieving last node:\n"; - echo "-------------------------------------\n"; - - $last = $a->getLastChildNode(true); - echo "Last child node is '" . $last->getLabel() . "' (" . $last->getNodePath() . ")\n"; - -} catch (Exception $e) { - die("Error creating tree with > 10 nodes: " . $e->__toString()); -} - -if (!isset($argc)) echo "";